Skip to content

Commit

Permalink
feat: add support for Cairo 2.6 (#1865)
Browse files Browse the repository at this point in the history
* wip

* make katana-primitives compilable

* make dojo-lang compilable

* make dojo-world compilable

* bump blockifier

* fix: start blockifier rework

* fix: ensure sozo can build

* fix: first dive into executor to have it compiling

* fix: fix tests with CAIRO_TESTS=1

* fix: use correct default value for profiler mode

* fix: ensure dojo-core compat with 2.6

* fix: fix some fields in tests

* fix: some clippy fixes

* make things compiled first

* disable any reference to the `sir` feature

* update test

* allow nonzero gas prices for now

* update test

* update manifest of types-test project

* fmt

* fix: ensure profiler can run correctly

* refacto testing for cairo compiler versions

* rework katana runner to have more friendly API

* rework dojo-world test to use KatanaRunner

* avoid race condition by using tmp projects for build/migrate

* use KatanaRunner for testing into sozo

* add updated manifest for example

* fmt / clippy

* doc: add contributing details + refacto script for tests

* fmt cairo code

* enable cairofmt in CI

* add fmt scripts

* fmt

* fix path for scarb fmt

* fix test and attempt fix CI scarb action

* fix CI again

* ensure checkout before test

* ci last try before disabling

* remove reference

* fix: remove type tests manifests

* fix: uses last scarb version to fix experimental features

* fix: ensure dojoup does not fail with invalid version

* fix: dojoup script to be reworked with new cargo version

* fix: devcontainer dockerfile and CI for new dojoup

* fix: add missing space

* CI: attempt CI debug

* Update Dockerfile with missing locked

* fix: attempt to remove dockerfile unfinite cycle

* fix: re-add variant for several step build

* ci: use more resources for devcontainer

* ci: remove manual workflow and attempt on push

* ci: change build docker to matrix and separated jobs

* ci: disable build dockerfile from scratch for arm64

* ci: update dev container

* ci: restore container image

* fix: re-enable experimental features as they seems to be needed again?

* fix: fix new world address in test

* ci: add again the manual trigger for devcontainer workflow

* ci: bump dojo container dev

* ci: add new prefix key for cache

* ci: check witout cairo native deps

* fix: enable experimental features only if required

* ci: use new dev container without SiR deps

* use larger runner for demanding jobs

* ci: restore workflows and re-build Katana before running tests

* fix: do not limit the runner bin to CI

* change devcontainer image

* fix: fix tests

* ci: fix katana runner path

* ci: attempt to have the katana runner bin correctly set

---------

Co-authored-by: Ammar Arif <[email protected]>
  • Loading branch information
glihm and kariy authored May 3, 2024
1 parent 836ee61 commit e95f86f
Show file tree
Hide file tree
Showing 114 changed files with 4,869 additions and 2,457 deletions.
8 changes: 7 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ ARG DOJO_VERSION=stable
RUN curl -L https://install.dojoengine.org | bash
RUN curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash
ENV PATH=${PATH}:/root/.dojo/bin
RUN dojoup -v $DOJO_VERSION
RUN if [ "$DOJO_VERSION" = "stable" ]; then \
echo "Installing latest stable version of Dojo"; \
dojoup; \
else \
echo "Installing Dojo version $DOJO_VERSION"; \
dojoup -v $DOJO_VERSION; \
fi

RUN chown -R root:root /usr/local/cargo
RUN chmod -R 700 /usr/local/cargo
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: bug
assignees: ''

assignees: ""
---

**Describe the bug**
Expand Down
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Is your feature request related to a problem? Please describe.**
Expand Down
40 changes: 40 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Description

<!--
A description of what this PR is solving.
-->

## Related issue

<!--
Please link related issues: Fixes #<issue_number>
More info: https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
-->

## Tests?

<!--
Please refer to the CONTRIBUTING.md file to know more about the testing process. Ensure you've tested at least the package you're modifying if running all the tests consumes too much memory on your system.
-->

- [ ] yes
- [ ] no, because they aren't needed
- [ ] no, because I need help

## Added to documentation?

<!--
If the changes are small, code comments are enough, otherwise, the documentation is needed. It
may be a README.md file added to your module/package, a DojoBook PR or both.
-->

- [ ] README.md
- [ ] [dojo book](https://github.com/dojoengine/book)
- [ ] no documentation needed

## Checklist

- [ ] I've formatted my code (`scripts/prettier.sh`, `scripts/rustfmt.sh`, `scripts/cairo_fmt.sh`)
- [ ] I've linted my code (`scripts/clippy.sh`, `scripts/docs.sh`)
- [ ] I've commented my code
- [ ] I've requested a review after addressing the comments
43 changes: 22 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ jobs:
test:
runs-on: ubuntu-latest-16-cores
container:
image: ghcr.io/dojoengine/dojo-dev:3153a80
image: ghcr.io/dojoengine/dojo-dev:8e395ea
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- run: |
cargo llvm-cov nextest --no-report --all-features --workspace --exclude katana --build-jobs 10
cargo build -r --bin katana
KATANA_RUNNER_BIN=$(pwd)/target/release/katana cargo llvm-cov nextest --no-report --all-features --workspace --exclude katana --build-jobs 10
cargo llvm-cov nextest --no-report -p katana
cargo llvm-cov nextest --no-report -p katana --no-default-features --features sir
# TODO(kariy): uncomment this line when `sir` feature support Cairo 2.6.3
# cargo llvm-cov nextest --no-report -p katana --no-default-features --features sir
cargo llvm-cov report --lcov --output-path lcov.info
- uses: codecov/codecov-action@v4
with:
Expand All @@ -31,7 +33,7 @@ jobs:
ensure-wasm:
runs-on: ubuntu-latest
container:
image: ghcr.io/dojoengine/dojo-dev:3153a80
image: ghcr.io/dojoengine/dojo-dev:8e395ea
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand All @@ -51,22 +53,21 @@ jobs:
repo-token: ${{ secrets.github_token }}
- run: cargo build --target x86_64-pc-windows-msvc --bins

# cairofmt:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: nightly-2022-11-03
# - uses: Swatinem/rust-cache@v2
# - run: cargo install cairo-lang-formatter
# - run: scripts/cairo_fmt.sh --check
cairofmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.6.3"
- run: |
scarb --manifest-path examples/spawn-and-move/Scarb.toml fmt --check
scarb --manifest-path crates/dojo-core/Scarb.toml fmt --check
dojo-core-test:
runs-on: ubuntu-latest
container:
image: ghcr.io/dojoengine/dojo-dev:3153a80
image: ghcr.io/dojoengine/dojo-dev:8e395ea
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand All @@ -75,7 +76,7 @@ jobs:
dojo-spawn-and-move-example-test:
runs-on: ubuntu-latest
container:
image: ghcr.io/dojoengine/dojo-dev:3153a80
image: ghcr.io/dojoengine/dojo-dev:8e395ea
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand All @@ -84,7 +85,7 @@ jobs:
dojo-world-bindings-check:
runs-on: ubuntu-latest
container:
image: ghcr.io/dojoengine/dojo-dev:3153a80
image: ghcr.io/dojoengine/dojo-dev:8e395ea
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand All @@ -93,7 +94,7 @@ jobs:
clippy:
runs-on: ubuntu-latest
container:
image: ghcr.io/dojoengine/dojo-dev:3153a80
image: ghcr.io/dojoengine/dojo-dev:8e395ea
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand All @@ -102,7 +103,7 @@ jobs:
fmt:
runs-on: ubuntu-latest
container:
image: ghcr.io/dojoengine/dojo-dev:3153a80
image: ghcr.io/dojoengine/dojo-dev:8e395ea
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand All @@ -111,7 +112,7 @@ jobs:
docs:
runs-on: ubuntu-latest
container:
image: ghcr.io/dojoengine/dojo-dev:3153a80
image: ghcr.io/dojoengine/dojo-dev:8e395ea
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scarb 2.6.3
49 changes: 47 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,34 @@ Following these guidelines helps to communicate that you respect the time of the

### Check the Issues

Before you start contributing, please check the [Issue Tracker](https://github.com/dojoengine/dojo/issues) to see if there are any existing issues that match what you're intending to do. If the issue doesn't exist, please create it.
Before you start contributing, please check the [Issue Tracker](https://github.com/dojoengine/dojo/issues) to see if there are any existing issues that match what you're intending to do. If the issue doesn't exist, please create it.

If you're creating a new issue, please provide a descriptive title and detailed description. If possible, include a code sample or an executable test case demonstrating the expected behavior that is not occurring.

### Fork and Clone the Repository

Once you've found an issue to work on, the next step is to fork the Dojo repo and clone it to your local machine. This is necessary because you probably won't have push access to the main repo.
Once you've found an issue to work on, the next step is to fork the Dojo repo and clone it to your local machine. This is necessary because you probably won't have push access to the main repo.

## Architecture

At the top level, dojo is composed of different folders:

- [`crates`](crates/): This folder contains the source code of the different crates (which are libraries) that make up Dojo.
- [`bin`](bin/): This folder contains the source code of the different binaries that make up Dojo.
- [`examples`](examples/): This folder contains the source code of simple Dojo projects that can be used as a starting point for new projects and also useful for testing.
- [`scripts`](scripts/): A set of useful scripts for developers and CI.

Inside `bin` and `crates` you will find source code related to Dojo stack components:

- `katana`: The Starknet sequencer tailored for gaming.
- `sozo`: The contract manager and Dojo compiler.
- `torii`: The indexer that store the state of your World.
- `dojo-core`: The core contract of Dojo written in Cairo.
- `dojo-lang`: The Dojo plugin for the Cairo compiler.

It is important to note that `bin` should only contain applications that gathers user inputs and delegates the work to the libraries present into the crates.

As an example, `sozo` is a CLI that gathers user inputs and delegates the work to run the commands code to the `sozo` crate.

## Making Changes

Expand All @@ -36,12 +57,36 @@ Your pull request will be reviewed by the maintainers of the Dojo project. They

Before you submit your pull request, you should run the test suite locally to make sure your changes haven't broken anything.

To run the test, you can execute the same command that will be exected on the CI by checking the [`.github/workflows/ci.yml`](.github/workflows/ci.yml) file.

```bash
# Run all the tests excluding Katana (due to SiR dependency, they may be run independently)
cargo nextest run --all-features --workspace --exclude katana

# To limit the resources, you can run the tests only on a package:
cargo nextest run --all-features -p sozo-ops
```

If you have to modify `dojo-core` or `dojo-lang` crates you must:

```bash
# First spin up a **fresh** Katana instance on default port.
cargo run --bin katana

# Then execute the script that will rebuild them.
bash scripts/rebuild_test_artifacts.sh
```

Additionally, when you push your changes, the built-in Continuous Integration (CI) will also run all the tests on the pushed code. You can see the result of these tests in the GitHub interface of your pull request. If the tests fail, you'll need to revise your code and push it again.

The CI uses a `devcontainer` to have all the dependencies installed and to run the tests. You can find more information about the devcontainer in the [`.devcontainer.json`](.devcontainer/devcontainer.json) file and see the latest releases on [GitHub package](https://github.com/dojoengine/dojo/pkgs/container/dojo-dev).

## Documentation

We strive to provide comprehensive, up-to-date documentation for Dojo. If your changes require updates to the documentation, please include those in your pull request.

The [dojo book repository](https://github.com/dojoengine/book) is where you should submit your changes to the documentation.

## Final Notes

Again, thank you for considering to contribute to Dojo. Your contribution is invaluable to us. We hope this guide makes the contribution process clear and answers any questions you might have. If not, feel free to ask on the [Discord](https://discord.gg/PwDa2mKhR4) or on [GitHub](https://github.com/dojoengine/dojo/issues).
Loading

0 comments on commit e95f86f

Please sign in to comment.