diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 20c25f2ce4..688d241a3c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -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 diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 7e55938ea5..5b254048b2 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -3,8 +3,7 @@ name: Bug report about: Create a report to help us improve title: "[BUG]" labels: bug -assignees: '' - +assignees: "" --- **Describe the bug** diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7d61..2bc5d5f711 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -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.** diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..70014f3f78 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,40 @@ +## Description + + + +## Related issue + + + +## Tests? + + + +- [ ] yes +- [ ] no, because they aren't needed +- [ ] no, because I need help + +## Added to documentation? + + + +- [ ] 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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66f013059b..27e718c9de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000000..f239fe235a --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +scarb 2.6.3 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 557b6b4b50..bcdde5399e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 @@ -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). diff --git a/Cargo.lock b/Cargo.lock index 096eab1c1e..2d6aebf056 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -871,8 +871,8 @@ dependencies = [ "memchr", "pin-project-lite", "tokio", - "zstd 0.13.0", - "zstd-safe 7.0.0", + "zstd", + "zstd-safe", ] [[package]] @@ -1471,9 +1471,10 @@ dependencies = [ [[package]] name = "blockifier" -version = "0.5.0-dev.0" -source = "git+https://github.com/dojoengine/blockifier?rev=d38b979#d38b9790cf36261d06e1409d98f0105cbc09d8e2" +version = "0.6.0-rc.2" +source = "git+https://github.com/dojoengine/blockifier?rev=935292bb#935292bb37843e4deb69f0da075dec0e5a15378b" dependencies = [ + "anyhow", "ark-ec", "ark-ff 0.4.2", "ark-secp256k1", @@ -1482,10 +1483,9 @@ dependencies = [ "cairo-felt", "cairo-lang-casm", "cairo-lang-runner", - "cairo-lang-starknet", + "cairo-lang-starknet-classes", "cairo-lang-utils", - "cairo-vm 0.9.2", - "ctor", + "cairo-vm", "derive_more", "indexmap 2.2.5", "itertools 0.10.5", @@ -1494,7 +1494,9 @@ dependencies = [ "num-bigint", "num-integer", "num-traits 0.2.18", + "once_cell", "phf", + "rstest 0.17.0", "serde", "serde_json", "sha3", @@ -1646,27 +1648,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" -[[package]] -name = "bzip2" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" -dependencies = [ - "bzip2-sys", - "libc", -] - -[[package]] -name = "bzip2-sys" -version = "0.1.11+1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - [[package]] name = "c-kzg" version = "1.0.0" @@ -1871,9 +1852,9 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ceb71a4cbf5b474bd671c79b2c05e8168a97199bfea1c01ef63b1bdaac3db03" +checksum = "10d9c31baeb6b52586b5adc88f01e90f86389d63d94363c562de5c79352e545b" dependencies = [ "cairo-lang-utils", "indoc 2.0.4", @@ -1885,9 +1866,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95c1aab3213462c5b7c21508f1a4330bdf0766c90e6dd4ed79b0002c2b96a715" +checksum = "7148cb2d72a3db24a6d2ef2b2602102cc5099cb9f6b913e5047fb009cb3a22a1" dependencies = [ "anyhow", "cairo-lang-defs", @@ -1902,23 +1883,24 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "salsa", + "smol_str", "thiserror", ] [[package]] name = "cairo-lang-debug" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03623ba892200c6b3c55fab260d4aa0bff833d6bcecdb1fb022565ac00d5a683" +checksum = "5a761eb8e31ea65a2dd45f729c74f1770315f97124dad93d1f6853a10d460c6b" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09131755b08a485322656e061ad05602215a198dd4a2daf3897e64dc76e7544e" +checksum = "f6d60bc5d72fe7a95ba34e041dcbdf1cf3bfccb87008a515514b74913fa8ff05" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -1933,9 +1915,9 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b8185cc9472c648ac9db970ce558595c71259eebd55d25a502fe569cb871448" +checksum = "356089e1b0a0ba9e115566191745613b3806a20259ad76764df82ab534d5412a" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1945,9 +1927,9 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae71750096b64d4dd54dd2c39ef50651bb4aff4bc829e3d07549a5035620e0a" +checksum = "fc43246cc2e5afd5a028bcdd63876ac3f8b1f4fb3ff785daaa0f0fbb51c9d906" dependencies = [ "cairo-lang-utils", "good_lp", @@ -1955,9 +1937,9 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1819ef5a5396df695dcec993500c46bc44c309590b503da26965c873dfe8a84a" +checksum = "6bcb9a4a40e53fa099774bd08bbcc3430f51213cc7fb1b50c2e9d01155731798" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -1969,9 +1951,9 @@ dependencies = [ [[package]] name = "cairo-lang-formatter" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4cfea8cf064ff275b469e2f92c7dfd1e296f00013f4fb59d852299d3c872f65" +checksum = "5626f853bef87ba54d3ba8cb3fe28d9e30b5465cd13ca640fe431f666ccce6ac" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -1990,9 +1972,9 @@ dependencies = [ [[package]] name = "cairo-lang-language-server" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0bdb1a3f19668c0a50ab5c4e197130d356b392370d45d4a0c2e2d6f55855a48" +checksum = "c04dd3889365d799bfdcc5784d5a6dbf60655d91354629651746083023b4f55f" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -2008,20 +1990,21 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-test-plugin", "cairo-lang-utils", - "log", "salsa", "scarb-metadata 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", "tokio", "tower-lsp", + "tracing", + "tracing-subscriber", ] [[package]] name = "cairo-lang-lowering" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0968f0da6117dca1a70d6ac7d2e252d8b1710f333458c54ce08dbef1c0323881" +checksum = "1ba60e1e2477aa0f610ccf29189097d580464607c94b51741e1c18e64d6cee5f" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -2042,11 +2025,36 @@ dependencies = [ "smol_str", ] +[[package]] +name = "cairo-lang-macro" +version = "0.0.1" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.4#c4c7c0bac3a30c23a4e2f1db145b967371b0e3c2" +dependencies = [ + "cairo-lang-macro-attributes", + "cairo-lang-macro-stable", + "linkme", +] + +[[package]] +name = "cairo-lang-macro-attributes" +version = "0.0.1" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.4#c4c7c0bac3a30c23a4e2f1db145b967371b0e3c2" +dependencies = [ + "quote", + "scarb-stable-hash", + "syn 2.0.55", +] + +[[package]] +name = "cairo-lang-macro-stable" +version = "1.0.0" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.4#c4c7c0bac3a30c23a4e2f1db145b967371b0e3c2" + [[package]] name = "cairo-lang-parser" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae556e49c0a90d30e52f068b0fb5ed4d419766661d3713a1644f3894a9255a5a" +checksum = "7f16ba1535e0cc5e79c2eff6592859bbdac03dc53d4dcdd26dbdbc04a77c3f5c" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -2064,9 +2072,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d319f3e84ff679159f97e3baa1d918d369ba9e3ade5ad490e0a9e4eca19591" +checksum = "81c8cf6e0ee3d6b19429cc1663738b22f1ecea7d51bf7452e8e1086f08798baf" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -2083,9 +2091,9 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fef002aac874d76492eb9577dab663f9a84fe4584b4215c7ebfda7d025fcadae" +checksum = "67f9da66325ce7ed6c002360f26106fe79deb9f8a2fca30abdbb8d388da7bb46" dependencies = [ "cairo-lang-debug", "quote", @@ -2094,23 +2102,23 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f384c26e6907de9c94b44051e386498159e8c9e1567b9b1eae9c22e16ff17e5" +checksum = "e198af1ab3d05c7fb8b6a9a7a2e9bce245a6c855df5f770b751d29874a23b152" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", "serde", "smol_str", "thiserror", - "toml 0.8.10", + "toml 0.8.12", ] [[package]] name = "cairo-lang-runner" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ccd9dce6f931508a21ac4d29965dadcaf7c22bbf2a237239763128b8647a53" +checksum = "0bf211f5431e2a6f4802b1b6483bf8e998e506a3be5369ed54a8807aae6e4dbf" dependencies = [ "ark-ff 0.4.2", "ark-secp256k1", @@ -2118,6 +2126,7 @@ dependencies = [ "ark-std 0.4.0", "cairo-felt", "cairo-lang-casm", + "cairo-lang-lowering", "cairo-lang-sierra", "cairo-lang-sierra-ap-change", "cairo-lang-sierra-generator", @@ -2125,7 +2134,7 @@ dependencies = [ "cairo-lang-sierra-type-size", "cairo-lang-starknet", "cairo-lang-utils", - "cairo-vm 0.9.2", + "cairo-vm", "itertools 0.11.0", "keccak", "num-bigint", @@ -2138,9 +2147,9 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "311434caae9542b7c442ac69a04e3c8eaa477654f215abe0bd7dfd3c0de70669" +checksum = "6d7df81521c2125e3e95b683cc99374db1aebd7ddb317c5ca3dd92a235a9eb13" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -2160,13 +2169,14 @@ dependencies = [ "once_cell", "salsa", "smol_str", + "toml 0.8.12", ] [[package]] name = "cairo-lang-sierra" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52c00c34fcaf97bbc4111d1631af8c65838841a38b3502b5bbc04355b7d46982" +checksum = "07da3ca1434c62a7cc7cd77d2941ef47a1c23b37325781b59407b78d8c61d863" dependencies = [ "anyhow", "cairo-felt", @@ -2190,9 +2200,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c99a0be021b359c51383cce4372cb1061f7d53438d80f208c56af2154583c98e" +checksum = "122c9055eb609a511178e3dce577de061819fd4c4c6b7452804557f76ca43bbf" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -2205,9 +2215,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f273d4de9d30e556e72ebe2751f9ed6bf3d84a70f6c76f52b178c24cddb12e43" +checksum = "cf049d9aea65c6e38da219a3700c72f78795d11449d9adcec28047ef8d63bd23" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -2220,9 +2230,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "734f72e9e8b1ec7a96208aa8dfba87ca1614188e3646ae67c519afe707569490" +checksum = "3e1d75e0830279ca1bd0189e3326720d6e081225f7d81ed060bbd22c6b37e980" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -2235,7 +2245,7 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "itertools 0.11.0", - "num-bigint", + "num-traits 0.2.18", "once_cell", "salsa", "smol_str", @@ -2243,9 +2253,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "842ae37ee3f1cd06b926aceb480fd70b84300aae82e9606b876678d30c21649a" +checksum = "6a3c3be88c8562fbf93b0803c186e7282f6daad93576c07f61b04a591fde468f" dependencies = [ "assert_matches", "cairo-felt", @@ -2264,9 +2274,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f969cbaf81f3beb1dc693674fc792a815bf8fc13471227020a5faf309d5faf80" +checksum = "a38da6f98c6b16945c89d2ae351c82d636ed38d3e6eb02f7c8679e3e03a63988" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -2274,13 +2284,12 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cd2d120f39369c7bd7d124dee638c250495054030d01d4e1d1b88f0063bd80" +checksum = "2c9ffa8b3b8c47138c36b1907cebb5047dfc4de29ec10ece5bd6d6853243ec50" dependencies = [ "anyhow", "cairo-felt", - "cairo-lang-casm", "cairo-lang-compiler", "cairo-lang-defs", "cairo-lang-diagnostics", @@ -2290,14 +2299,33 @@ dependencies = [ "cairo-lang-semantic", "cairo-lang-sierra", "cairo-lang-sierra-generator", - "cairo-lang-sierra-to-casm", + "cairo-lang-starknet-classes", "cairo-lang-syntax", "cairo-lang-utils", "const_format", - "convert_case 0.6.0", "indent", "indoc 2.0.4", "itertools 0.11.0", + "once_cell", + "serde", + "serde_json", + "smol_str", + "thiserror", +] + +[[package]] +name = "cairo-lang-starknet-classes" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47c64ae2bb00173e3a88760128bf72de356fa80eb19fa47602479063648b4003" +dependencies = [ + "cairo-felt", + "cairo-lang-casm", + "cairo-lang-sierra", + "cairo-lang-sierra-to-casm", + "cairo-lang-utils", + "convert_case 0.6.0", + "itertools 0.11.0", "num-bigint", "num-integer", "num-traits 0.2.18", @@ -2312,9 +2340,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552d3438fec55832976bc7c7d7490100e8ce7385d3f3f1539f9a46fffa2197c6" +checksum = "8262c426a57e1e5ec297db24278464841500613445e2cb1c43d5f71ad91ee8d6" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -2328,9 +2356,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dab4d07bd78658f0fdc3fd20f1236bc3e6ebdd8a8fc72ece95a5dd03b7a09da" +checksum = "70e2d692eae4bb4179a4a1148fd5eb738a91653d86750c813658ffad4a99fa97" dependencies = [ "genco", "xshell", @@ -2338,9 +2366,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-plugin" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5e416a932754f190de2de011f3b3eb20dcb8093fb073cad15a8e70be833c3d" +checksum = "29c2d77976328ac79509b9c33e4380d15aeff7c8ee07fbaea6b41dd469084738" dependencies = [ "anyhow", "cairo-felt", @@ -2354,6 +2382,7 @@ dependencies = [ "cairo-lang-sierra", "cairo-lang-sierra-generator", "cairo-lang-starknet", + "cairo-lang-starknet-classes", "cairo-lang-syntax", "cairo-lang-utils", "indoc 2.0.4", @@ -2365,9 +2394,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-runner" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26f97227443ce0393183be841cd3364e79446e79dddb098a5c05801463308d1" +checksum = "ed27173110729dcc69958b364053bcd0442fd0b19d1a5bd91b929a8030558191" dependencies = [ "anyhow", "cairo-felt", @@ -2375,6 +2404,7 @@ dependencies = [ "cairo-lang-filesystem", "cairo-lang-runner", "cairo-lang-sierra", + "cairo-lang-sierra-generator", "cairo-lang-sierra-to-casm", "cairo-lang-starknet", "cairo-lang-test-plugin", @@ -2387,9 +2417,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-utils" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ab221aa0119b6e613992127687a1352a896d30a2e55a9295c52eb9598bcc78" +checksum = "aa2891a07af4e55a029be8ad2ec88558fe6e78d6afd67f8c1308e99676586d3a" dependencies = [ "cairo-lang-utils", "colored", @@ -2399,9 +2429,9 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.5.4" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12d0939f42d40fb1d975cae073d7d4f82d83de4ba2149293115525245425f909" +checksum = "bf733a7cdc4166d0baf0ed8a98d9ada827daee6653b37d9326e334e53481c6d3" dependencies = [ "env_logger", "hashbrown 0.14.3", @@ -2410,6 +2440,7 @@ dependencies = [ "log", "num-bigint", "num-traits 0.2.18", + "parity-scale-codec", "schemars", "serde", "time", @@ -2463,40 +2494,6 @@ dependencies = [ "thiserror-no-std", ] -[[package]] -name = "cairo-vm" -version = "1.0.0-rc1" -source = "git+https://github.com/lambdaclass/cairo-vm?rev=3547089579dd74f815edbc2d1caa91e00fc8a2f7#3547089579dd74f815edbc2d1caa91e00fc8a2f7" -dependencies = [ - "anyhow", - "ark-ff 0.4.2", - "ark-std 0.4.0", - "bincode 2.0.0-rc.3", - "bitvec", - "cairo-lang-casm", - "cairo-lang-starknet", - "generic-array", - "hashbrown 0.14.3", - "hex", - "keccak", - "lazy_static", - "mimalloc", - "nom", - "num-bigint", - "num-integer", - "num-prime", - "num-traits 0.2.18", - "rand", - "serde", - "serde_json", - "sha2 0.10.8", - "sha3", - "starknet-crypto 0.6.2", - "starknet-types-core", - "thiserror-no-std", - "zip", -] - [[package]] name = "camino" version = "1.1.6" @@ -3001,12 +2998,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "convert_case" version = "0.4.0" @@ -3083,7 +3074,7 @@ dependencies = [ [[package]] name = "create-output-dir" version = "1.0.0" -source = "git+https://github.com/software-mansion/scarb?tag=v2.5.4#28dee92c87e97bacefb2a300e7a102455936eeca" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.4#c4c7c0bac3a30c23a4e2f1db145b967371b0e3c2" dependencies = [ "anyhow", "core-foundation", @@ -3234,16 +3225,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ctor" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d2b3721e861707777e3195b0158f950ae6dc4a27e4d02ff9f67e3eb3de199e" -dependencies = [ - "quote", - "syn 2.0.55", -] - [[package]] name = "ctr" version = "0.9.2" @@ -3691,6 +3672,7 @@ dependencies = [ "cairo-lang-semantic", "cairo-lang-sierra-generator", "cairo-lang-starknet", + "cairo-lang-starknet-classes", "cairo-lang-syntax", "cairo-lang-test-plugin", "cairo-lang-test-utils", @@ -3718,7 +3700,7 @@ dependencies = [ "starknet 0.9.0", "test-log", "thiserror", - "toml 0.7.8", + "toml 0.8.12", "tracing", "url", ] @@ -3824,6 +3806,7 @@ dependencies = [ "cairo-lang-filesystem", "cairo-lang-project", "cairo-lang-starknet", + "cairo-lang-starknet-classes", "camino", "convert_case 0.6.0", "dojo-lang", @@ -3832,6 +3815,7 @@ dependencies = [ "futures", "http 0.2.11", "ipfs-api-backend-hyper", + "katana-runner", "scarb", "serde", "serde_json", @@ -3843,7 +3827,7 @@ dependencies = [ "tempfile", "thiserror", "tokio", - "toml 0.7.8", + "toml 0.8.12", "tracing", "url", ] @@ -3853,6 +3837,7 @@ name = "dojo-world-abigen" version = "0.7.0-alpha.0" dependencies = [ "cairo-lang-starknet", + "cairo-lang-starknet-classes", "camino", "scarb", "scarb-ui", @@ -4599,18 +4584,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "getset" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e45727250e75cc04ff2846a66397da8ef2b3db8e40e0cef4df67950a07621eb9" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "ghash" version = "0.5.0" @@ -6835,7 +6808,6 @@ dependencies = [ "elliptic-curve", "once_cell", "sha2 0.10.8", - "signature", ] [[package]] @@ -6901,7 +6873,7 @@ dependencies = [ "async-trait", "cairo-lang-casm", "cairo-lang-starknet", - "cairo-vm 0.9.2", + "cairo-vm", "convert_case 0.6.0", "derive_more", "dojo-metrics", @@ -6937,7 +6909,7 @@ version = "0.7.0-alpha.0" dependencies = [ "anyhow", "cairo-lang-starknet", - "cairo-vm 0.9.2", + "cairo-vm", "criterion", "katana-primitives", "page_size", @@ -6960,22 +6932,19 @@ dependencies = [ "alloy-primitives", "anyhow", "blockifier", - "cairo-lang-sierra", - "cairo-vm 0.9.2", + "cairo-vm", "convert_case 0.6.0", "futures", "katana-primitives", "katana-provider", "katana-rpc-types", "parking_lot 0.12.1", - "rstest", + "rstest 0.18.2", "rstest_reuse", "serde_json", "similar-asserts", "starknet 0.9.0", - "starknet-types-core", "starknet_api", - "starknet_in_rust", "thiserror", "tokio", "tracing", @@ -6990,7 +6959,8 @@ dependencies = [ "base64 0.21.7", "cairo-lang-sierra", "cairo-lang-starknet", - "cairo-vm 0.9.2", + "cairo-lang-starknet-classes", + "cairo-vm", "derive_more", "flate2", "lazy_static", @@ -7021,7 +6991,7 @@ dependencies = [ "lazy_static", "parking_lot 0.12.1", "rand", - "rstest", + "rstest 0.18.2", "rstest_reuse", "serde_json", "starknet 0.9.0", @@ -7039,6 +7009,7 @@ dependencies = [ "anyhow", "assert_matches", "cairo-lang-starknet", + "cairo-lang-starknet-classes", "dojo-metrics", "dojo-test-utils", "flate2", @@ -7092,7 +7063,7 @@ dependencies = [ "katana-executor", "katana-primitives", "katana-provider", - "rstest", + "rstest 0.18.2", "serde", "serde_json", "serde_with", @@ -7117,6 +7088,7 @@ name = "katana-runner" version = "0.7.0-alpha.0" dependencies = [ "anyhow", + "assert_fs", "chrono", "home", "katana-core", @@ -7230,27 +7202,11 @@ dependencies = [ "regex", ] -[[package]] -name = "lambdaworks-crypto" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d4c222d5b2fdc0faf702d3ab361d14589b097f40eac9dc550e27083483edc65" -dependencies = [ - "lambdaworks-math", - "serde", - "sha2 0.10.8", - "sha3", -] - [[package]] name = "lambdaworks-math" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ee7dcab3968c71896b8ee4dc829147acc918cffe897af6265b1894527fe3add" -dependencies = [ - "serde", - "serde_json", -] [[package]] name = "lazy_static" @@ -7275,12 +7231,12 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-sys 0.48.0", + "windows-targets 0.52.0", ] [[package]] @@ -7883,6 +7839,26 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +[[package]] +name = "linkme" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb2cfee0de9bd869589fb9a015e155946d1be5ff415cb844c2caccc6cc4b5db9" +dependencies = [ + "linkme-impl", +] + +[[package]] +name = "linkme-impl" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adf157a4dc5a29b7b464aa8fe7edeff30076e07e13646a1c3874f58477dc99f8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.55", +] + [[package]] name = "linux-raw-sys" version = "0.3.8" @@ -8928,17 +8904,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "password-hash" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" -dependencies = [ - "base64ct", - "rand_core", - "subtle", -] - [[package]] name = "paste" version = "1.0.14" @@ -8976,9 +8941,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ "digest 0.10.7", - "hmac", - "password-hash", - "sha2 0.10.8", ] [[package]] @@ -9860,9 +9822,9 @@ dependencies = [ [[package]] name = "redb" -version = "1.5.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72623e6275cd430215b741f41ebda34db93a13ebde253f908b70871c46afc5ba" +checksum = "ed7508e692a49b6b2290b56540384ccae9b1fb4d77065640b165835b56ffe3bb" dependencies = [ "libc", ] @@ -10190,6 +10152,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rstest" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de1bb486a691878cd320c2f0d319ba91eeaa2e894066d8b5f8f117c000e9d962" +dependencies = [ + "futures", + "futures-timer", + "rstest_macros 0.17.0", + "rustc_version 0.4.0", +] + [[package]] name = "rstest" version = "0.18.2" @@ -10198,8 +10172,22 @@ checksum = "97eeab2f3c0a199bc4be135c36c924b6590b88c377d416494288c14f2db30199" dependencies = [ "futures", "futures-timer", - "rstest_macros", + "rstest_macros 0.18.2", + "rustc_version 0.4.0", +] + +[[package]] +name = "rstest_macros" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290ca1a1c8ca7edb7c3283bd44dc35dd54fdec6253a3912e201ba1072018fca8" +dependencies = [ + "cfg-if", + "proc-macro2", + "quote", "rustc_version 0.4.0", + "syn 1.0.109", + "unicode-ident", ] [[package]] @@ -10580,7 +10568,7 @@ dependencies = [ "async-trait", "cairo-felt", "cairo-proof-parser", - "cairo-vm 0.9.2", + "cairo-vm", "celestia-rpc", "celestia-types", "convert_case 0.6.0", @@ -10644,8 +10632,8 @@ dependencies = [ [[package]] name = "scarb" -version = "2.5.4" -source = "git+https://github.com/software-mansion/scarb?tag=v2.5.4#28dee92c87e97bacefb2a300e7a102455936eeca" +version = "2.6.4" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.4#c4c7c0bac3a30c23a4e2f1db145b967371b0e3c2" dependencies = [ "anyhow", "async-trait", @@ -10654,10 +10642,13 @@ dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", "cairo-lang-formatter", + "cairo-lang-macro", + "cairo-lang-macro-stable", "cairo-lang-semantic", - "cairo-lang-sierra", "cairo-lang-sierra-to-casm", "cairo-lang-starknet", + "cairo-lang-starknet-classes", + "cairo-lang-syntax", "cairo-lang-test-plugin", "cairo-lang-utils", "camino", @@ -10678,14 +10669,15 @@ dependencies = [ "include_dir", "indoc 2.0.4", "itertools 0.12.1", + "libloading", "once_cell", "pathdiff", "petgraph", "redb", "reqwest 0.11.24", "scarb-build-metadata", - "scarb-macro-interface", - "scarb-metadata 1.11.1 (git+https://github.com/software-mansion/scarb?tag=v2.5.4)", + "scarb-metadata 1.11.1 (git+https://github.com/software-mansion/scarb?tag=v2.6.4)", + "scarb-stable-hash", "scarb-ui", "semver 1.0.22", "serde", @@ -10699,8 +10691,8 @@ dependencies = [ "tar", "thiserror", "tokio", - "toml 0.8.10", - "toml_edit 0.22.6", + "toml 0.8.12", + "toml_edit 0.22.12", "tracing", "tracing-log 0.2.0", "tracing-subscriber", @@ -10709,30 +10701,18 @@ dependencies = [ "walkdir", "which 5.0.0", "windows-sys 0.52.0", - "xxhash-rust", "zip", - "zstd 0.13.0", + "zstd", ] [[package]] name = "scarb-build-metadata" -version = "2.5.4" -source = "git+https://github.com/software-mansion/scarb?tag=v2.5.4#28dee92c87e97bacefb2a300e7a102455936eeca" +version = "2.6.4" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.4#c4c7c0bac3a30c23a4e2f1db145b967371b0e3c2" dependencies = [ "cargo_metadata", ] -[[package]] -name = "scarb-macro-interface" -version = "0.0.1" -source = "git+https://github.com/software-mansion/scarb?tag=v2.5.4#28dee92c87e97bacefb2a300e7a102455936eeca" -dependencies = [ - "anyhow", - "libc", - "serde", - "serde_json", -] - [[package]] name = "scarb-metadata" version = "1.11.1" @@ -10749,7 +10729,7 @@ dependencies = [ [[package]] name = "scarb-metadata" version = "1.11.1" -source = "git+https://github.com/software-mansion/scarb?tag=v2.5.4#28dee92c87e97bacefb2a300e7a102455936eeca" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.4#c4c7c0bac3a30c23a4e2f1db145b967371b0e3c2" dependencies = [ "camino", "derive_builder", @@ -10759,17 +10739,26 @@ dependencies = [ "thiserror", ] +[[package]] +name = "scarb-stable-hash" +version = "1.0.0" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.4#c4c7c0bac3a30c23a4e2f1db145b967371b0e3c2" +dependencies = [ + "data-encoding", + "xxhash-rust", +] + [[package]] name = "scarb-ui" version = "0.1.3" -source = "git+https://github.com/software-mansion/scarb?tag=v2.5.4#28dee92c87e97bacefb2a300e7a102455936eeca" +source = "git+https://github.com/software-mansion/scarb?tag=v2.6.4#c4c7c0bac3a30c23a4e2f1db145b967371b0e3c2" dependencies = [ "anyhow", "camino", "clap", "console", "indicatif", - "scarb-metadata 1.11.1 (git+https://github.com/software-mansion/scarb?tag=v2.5.4)", + "scarb-metadata 1.11.1 (git+https://github.com/software-mansion/scarb?tag=v2.6.4)", "serde", "serde_json", ] @@ -11749,22 +11738,6 @@ dependencies = [ "uuid 1.7.0", ] -[[package]] -name = "starknet" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "351ffff1bcf6a1dc569a1b330dfd85779e16506e7d4a87baa8be3744cb5415a6" -dependencies = [ - "starknet-accounts 0.6.1", - "starknet-contract 0.6.0", - "starknet-core 0.7.2", - "starknet-crypto 0.6.2", - "starknet-ff", - "starknet-macros", - "starknet-providers 0.7.0", - "starknet-signers 0.5.0", -] - [[package]] name = "starknet" version = "0.8.0" @@ -11813,20 +11786,6 @@ dependencies = [ "starknet-signers 0.8.0", ] -[[package]] -name = "starknet-accounts" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7062b020f65d9da7f9dd9f1d97bfb644e881cda8ddb999799a799e6f2e408dd" -dependencies = [ - "async-trait", - "auto_impl", - "starknet-core 0.7.2", - "starknet-providers 0.7.0", - "starknet-signers 0.5.0", - "thiserror", -] - [[package]] name = "starknet-accounts" version = "0.7.0" @@ -11869,21 +11828,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "starknet-contract" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d858efc93d85de95065a5732cb3e94d0c746674964c0859aab442ffbb9de76b4" -dependencies = [ - "serde", - "serde_json", - "serde_with", - "starknet-accounts 0.6.1", - "starknet-core 0.7.2", - "starknet-providers 0.7.0", - "thiserror", -] - [[package]] name = "starknet-contract" version = "0.7.0" @@ -11929,24 +11873,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "starknet-core" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f1683ca7c63f0642310eddedb7d35056d8306084dff323d440711065c63ed87" -dependencies = [ - "base64 0.21.7", - "flate2", - "hex", - "serde", - "serde_json", - "serde_json_pythonic", - "serde_with", - "sha3", - "starknet-crypto 0.6.2", - "starknet-ff", -] - [[package]] name = "starknet-core" version = "0.8.1" @@ -12095,26 +12021,6 @@ dependencies = [ "syn 2.0.55", ] -[[package]] -name = "starknet-providers" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52072c2d258bf692affeccd602613d5f6c61a6ffc84da8f191ab4a1b0a5e24d1" -dependencies = [ - "async-trait", - "auto_impl", - "ethereum-types", - "flate2", - "log", - "reqwest 0.11.24", - "serde", - "serde_json", - "serde_with", - "starknet-core 0.7.2", - "thiserror", - "url", -] - [[package]] name = "starknet-providers" version = "0.8.0" @@ -12175,22 +12081,6 @@ dependencies = [ "url", ] -[[package]] -name = "starknet-signers" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "347b1bfc09846aafe16d2b3a5bc2d8a2f845e2958602442182d265fbd6011c2e" -dependencies = [ - "async-trait", - "auto_impl", - "crypto-bigint", - "eth-keystore", - "rand", - "starknet-core 0.7.2", - "starknet-crypto 0.6.2", - "thiserror", -] - [[package]] name = "starknet-signers" version = "0.6.0" @@ -12246,7 +12136,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d53160556d1f23425100f42b3230df747ea05763efee685a2cd939dfb640701" dependencies = [ "bitvec", - "lambdaworks-crypto", "lambdaworks-math", "lazy_static", "num-bigint", @@ -12257,17 +12146,15 @@ dependencies = [ [[package]] name = "starknet_api" -version = "0.7.0-dev.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88969610ab6ea9391e0e05a3e7c38acc49dc1cb49941b93ca52814075002b92f" +checksum = "9e6aeb260177f5ca6dde788e844825d8d83782905dbac1b24c0c620743284475" dependencies = [ - "cairo-lang-starknet", + "cairo-lang-starknet-classes", "derive_more", "hex", "indexmap 2.2.5", "once_cell", - "parity-scale-codec", - "parity-scale-codec-derive", "primitive-types", "serde", "serde_json", @@ -12277,45 +12164,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "starknet_in_rust" -version = "0.4.0" -source = "git+https://github.com/dojoengine/starknet_in_rust.git?rev=601a65e#601a65e473592d8d3c5e35a0b46868464cacef2f" -dependencies = [ - "anyhow", - "auto_impl", - "base64 0.21.7", - "cairo-felt", - "cairo-lang-casm", - "cairo-lang-runner", - "cairo-lang-sierra", - "cairo-lang-starknet", - "cairo-lang-utils", - "cairo-vm 1.0.0-rc1", - "flate2", - "getset", - "hex", - "k256", - "keccak", - "lazy_static", - "mimalloc", - "num-bigint", - "num-integer", - "num-traits 0.2.18", - "once_cell", - "p256", - "sec1", - "serde", - "serde_json", - "serde_json_pythonic", - "sha3", - "starknet 0.7.0", - "starknet-crypto 0.6.2", - "starknet_api", - "thiserror", - "tracing", -] - [[package]] name = "static_assertions" version = "1.1.0" @@ -12856,14 +12704,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.10" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.6", + "toml_edit 0.22.12", ] [[package]] @@ -12890,9 +12738,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.6" +version = "0.22.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" dependencies = [ "indexmap 2.2.5", "serde", @@ -13178,7 +13026,7 @@ dependencies = [ "tokio", "tokio-stream", "tokio-util", - "toml 0.7.8", + "toml 0.8.12", "torii-core", "tracing", "url", @@ -14768,27 +14616,10 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" dependencies = [ - "aes", "byteorder", - "bzip2", - "constant_time_eq", "crc32fast", "crossbeam-utils", "flate2", - "hmac", - "pbkdf2", - "sha1", - "time", - "zstd 0.11.2+zstd.1.5.2", -] - -[[package]] -name = "zstd" -version = "0.11.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" -dependencies = [ - "zstd-safe 5.0.2+zstd.1.5.2", ] [[package]] @@ -14797,17 +14628,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bffb3309596d527cfcba7dfc6ed6052f1d39dfbd7c867aa2e865e4a449c10110" dependencies = [ - "zstd-safe 7.0.0", -] - -[[package]] -name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" -dependencies = [ - "libc", - "zstd-sys", + "zstd-safe", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index baa2d04075..9b0adca3d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -102,27 +102,28 @@ anyhow = "1.0.80" assert_matches = "1.5.0" async-trait = "0.1.68" base64 = "0.21.2" -cairo-lang-compiler = "=2.5.4" -cairo-lang-debug = "=2.5.4" -cairo-lang-defs = "=2.5.4" -cairo-lang-diagnostics = "=2.5.4" -cairo-lang-filesystem = "=2.5.4" -cairo-lang-formatter = "=2.5.4" -cairo-lang-language-server = "=2.5.4" -cairo-lang-lowering = "=2.5.4" -cairo-lang-parser = "=2.5.4" -cairo-lang-plugins = { version = "=2.5.4", features = [ "testing" ] } -cairo-lang-project = "=2.5.4" -cairo-lang-semantic = { version = "=2.5.4", features = [ "testing" ] } -cairo-lang-sierra = "=2.5.4" -cairo-lang-sierra-generator = "=2.5.4" -cairo-lang-sierra-to-casm = "=2.5.4" -cairo-lang-starknet = "=2.5.4" -cairo-lang-syntax = "=2.5.4" -cairo-lang-test-plugin = "=2.5.4" -cairo-lang-test-runner = "=2.5.4" -cairo-lang-test-utils = "=2.5.4" -cairo-lang-utils = "=2.5.4" +cairo-lang-compiler = "=2.6.3" +cairo-lang-debug = "=2.6.3" +cairo-lang-defs = "=2.6.3" +cairo-lang-diagnostics = "=2.6.3" +cairo-lang-filesystem = "=2.6.3" +cairo-lang-formatter = "=2.6.3" +cairo-lang-language-server = "=2.6.3" +cairo-lang-lowering = "=2.6.3" +cairo-lang-parser = "=2.6.3" +cairo-lang-plugins = { version = "=2.6.3", features = [ "testing" ] } +cairo-lang-project = "=2.6.3" +cairo-lang-semantic = { version = "=2.6.3", features = [ "testing" ] } +cairo-lang-sierra = "=2.6.3" +cairo-lang-sierra-generator = "=2.6.3" +cairo-lang-sierra-to-casm = "=2.6.3" +cairo-lang-starknet = "=2.6.3" +cairo-lang-starknet-classes = "=2.6.3" +cairo-lang-syntax = "=2.6.3" +cairo-lang-test-plugin = "=2.6.3" +cairo-lang-test-runner = "=2.6.3" +cairo-lang-test-utils = "=2.6.3" +cairo-lang-utils = "=2.6.3" cairo-proof-parser = { git = "https://github.com/cartridge-gg/cairo-proof-parser", tag = "v0.3.0" } cairo-vm = "0.9.2" camino = { version = "1.1.2", features = [ "serde1" ] } @@ -149,8 +150,8 @@ rayon = "1.8.0" regex = "1.10.3" rpassword = "7.2.0" salsa = "0.16.1" -scarb = { git = "https://github.com/software-mansion/scarb", tag = "v2.5.4" } -scarb-ui = { git = "https://github.com/software-mansion/scarb", tag = "v2.5.4" } +scarb = { git = "https://github.com/software-mansion/scarb", tag = "v2.6.4" } +scarb-ui = { git = "https://github.com/software-mansion/scarb", tag = "v2.6.4" } semver = "1.0.5" serde = { version = "1.0.197", features = [ "derive" ] } serde_json = { version = "1.0", features = [ "arbitrary_precision" ] } @@ -160,13 +161,13 @@ smol_str = { version = "0.2.0", features = [ "serde" ] } sqlx = { version = "0.7.2", features = [ "chrono", "macros", "regexp", "runtime-async-std", "runtime-tokio", "sqlite", "uuid" ] } starknet = "0.9.0" starknet-crypto = "0.6.1" -starknet_api = "0.7.0-dev.0" +starknet_api = "0.10.0" strum = "0.25" strum_macros = "0.25" test-log = "0.2.11" thiserror = "1.0.32" tokio = { version = "1.32.0", features = [ "full" ] } -toml = "0.7.4" +toml = "0.8.12" tracing = "0.1.34" tracing-subscriber = { version = "0.3.16", features = [ "env-filter", "json" ] } url = { version = "2.4.0", features = [ "serde" ] } diff --git a/README.md b/README.md index b7757f02d2..8845192a81 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ See our [Environment setup](https://book.dojoengine.org/getting-started) for mor Dojo core smart contracts have been audited: -* feb-24: [Nethermind security](https://github.com/NethermindEth/PublicAuditReports/blob/main/NM0159-FINAL_DOJO.pdf) +- feb-24: [Nethermind security](https://github.com/NethermindEth/PublicAuditReports/blob/main/NM0159-FINAL_DOJO.pdf) ## Releasing diff --git a/bin/katana/Cargo.toml b/bin/katana/Cargo.toml index 8edb17a859..7294a1e061 100644 --- a/bin/katana/Cargo.toml +++ b/bin/katana/Cargo.toml @@ -7,6 +7,7 @@ repository.workspace = true version.workspace = true [dependencies] +alloy-primitives.workspace = true anyhow.workspace = true cfg-if = "1.0.0" clap.workspace = true @@ -26,7 +27,6 @@ tokio.workspace = true tracing-subscriber.workspace = true tracing.workspace = true url.workspace = true -alloy-primitives.workspace = true [dev-dependencies] assert_matches = "1.5.0" @@ -35,7 +35,8 @@ assert_matches = "1.5.0" default = [ "blockifier", "jemalloc", "messaging" ] blockifier = [ "katana-executor/blockifier" ] -sir = [ "katana-executor/sir" ] +# Disable until SIR support Cairo 2.6.3 +#sir = [ "katana-executor/sir" ] jemalloc = [ "dojo-metrics/jemalloc" ] messaging = [ "katana-core/messaging" ] diff --git a/bin/katana/src/main.rs b/bin/katana/src/main.rs index 958fc9f217..ffd96c4dec 100644 --- a/bin/katana/src/main.rs +++ b/bin/katana/src/main.rs @@ -63,19 +63,23 @@ async fn main() -> Result<(), Box> { ..Default::default() }; - cfg_if::cfg_if! { - if #[cfg(all(feature = "blockifier", feature = "sir"))] { - compile_error!("Cannot enable both `blockifier` and `sir` features at the same time"); - } else if #[cfg(feature = "blockifier")] { - use katana_executor::implementation::blockifier::BlockifierFactory; - let executor_factory = BlockifierFactory::new(cfg_env, simulation_flags); - } else if #[cfg(feature = "sir")] { - use katana_executor::implementation::sir::NativeExecutorFactory; - let executor_factory = NativeExecutorFactory::new(cfg_env, simulation_flags); - } else { - compile_error!("At least one of the following features must be enabled: blockifier, sir"); - } - } + // TODO: Uncomment this once we enable the 'sir' feature again because it's not compatible with + // our current Cairo version (2.6.3). cfg_if::cfg_if! { + // if #[cfg(all(feature = "blockifier", feature = "sir"))] { + // compile_error!("Cannot enable both `blockifier` and `sir` features at the same + // time"); } else if #[cfg(feature = "blockifier")] { + // use katana_executor::implementation::blockifier::BlockifierFactory; + // let executor_factory = BlockifierFactory::new(cfg_env, simulation_flags); + // } else if #[cfg(feature = "sir")] { + // use katana_executor::implementation::sir::NativeExecutorFactory; + // let executor_factory = NativeExecutorFactory::new(cfg_env, simulation_flags); + // } else { + // compile_error!("At least one of the following features must be enabled: blockifier, + // sir"); } + // } + + use katana_executor::implementation::blockifier::BlockifierFactory; + let executor_factory = BlockifierFactory::new(cfg_env, simulation_flags); if let Some(listen_addr) = args.metrics { let prometheus_handle = prometheus_exporter::install_recorder("katana")?; diff --git a/bin/sozo/src/commands/clean.rs b/bin/sozo/src/commands/clean.rs index 6ae1b12271..cd0d915b95 100644 --- a/bin/sozo/src/commands/clean.rs +++ b/bin/sozo/src/commands/clean.rs @@ -74,9 +74,11 @@ mod tests { #[test] fn test_clean() { let source_project = "../../examples/spawn-and-move/Scarb.toml"; + let dojo_core_path = "../../crates/dojo-core"; // Build a completely new project in it's own directory. - let (temp_project_dir, config, _) = compiler::copy_build_project_temp(source_project, true); + let (temp_project_dir, config, _) = + compiler::copy_build_project_temp(source_project, dojo_core_path, true); let runner = KatanaRunner::new().expect("Fail to set runner"); diff --git a/bin/sozo/src/commands/dev.rs b/bin/sozo/src/commands/dev.rs index e7707b1496..3cfa330750 100644 --- a/bin/sozo/src/commands/dev.rs +++ b/bin/sozo/src/commands/dev.rs @@ -16,7 +16,7 @@ use dojo_world::migration::world::WorldDiff; use dojo_world::migration::TxnConfig; use notify_debouncer_mini::notify::RecursiveMode; use notify_debouncer_mini::{new_debouncer, DebouncedEvent, DebouncedEventKind}; -use scarb::compiler::CompilationUnit; +use scarb::compiler::{CairoCompilationUnit, CompilationUnit, CompilationUnitAttributes}; use scarb::core::{Config, Workspace}; use sozo_ops::migration; use starknet::accounts::SingleOwnerAccount; @@ -181,7 +181,7 @@ fn handle_event(event: &DebouncedEvent) -> DevAction { struct DevContext<'a> { pub db: RootDatabase, - pub unit: CompilationUnit, + pub unit: CairoCompilationUnit, pub ws: Workspace<'a>, } @@ -191,15 +191,18 @@ fn load_context(config: &Config) -> Result> { let resolve = scarb::ops::resolve_workspace(&ws)?; let compilation_units = scarb::ops::generate_compilation_units(&resolve, &ws)? .into_iter() - .filter(|cu| packages.contains(&cu.main_package_id)) + .filter(|cu| packages.contains(&cu.main_package_id())) .collect::>(); // we have only 1 unit in projects // TODO: double check if we always have one with the new version and the order if many. trace!(unit_count = compilation_units.len(), "Gathering compilation units."); - let unit = compilation_units.first().unwrap(); - let db = build_scarb_root_database(unit).unwrap(); - Ok(DevContext { db, unit: unit.clone(), ws }) + if let CompilationUnit::Cairo(unit) = compilation_units.first().unwrap() { + let db = build_scarb_root_database(unit).unwrap(); + Ok(DevContext { db, unit: unit.clone(), ws }) + } else { + Err(anyhow!("Cairo Compilation Unit is expected at this point.")) + } } fn build(context: &mut DevContext<'_>) -> Result<()> { diff --git a/bin/sozo/src/commands/options/account.rs b/bin/sozo/src/commands/options/account.rs index f8a534c657..f413891c80 100644 --- a/bin/sozo/src/commands/options/account.rs +++ b/bin/sozo/src/commands/options/account.rs @@ -146,7 +146,7 @@ mod tests { assert!(cmd.account.account_address(None).is_err()); } - #[katana_runner::katana_test(2, true, "katana", "")] + #[katana_runner::katana_test(2, true)] async fn legacy_flag_works_as_expected() { let cmd = Command::parse_from([ "sozo", @@ -173,7 +173,7 @@ mod tests { assert!(*result.get(3).unwrap() == FieldElement::from_hex_be("0x0").unwrap()); } - #[katana_runner::katana_test(2, true, "katana", "")] + #[katana_runner::katana_test(2, true)] async fn without_legacy_flag_works_as_expected() { let cmd = Command::parse_from(["sozo", "--account-address", "0x0", "--private-key", "0x1"]); let dummy_call = vec![Call { diff --git a/bin/sozo/src/commands/test.rs b/bin/sozo/src/commands/test.rs index 9ca645c72c..624b48c1da 100644 --- a/bin/sozo/src/commands/test.rs +++ b/bin/sozo/src/commands/test.rs @@ -7,19 +7,36 @@ use cairo_lang_filesystem::cfg::{Cfg, CfgSet}; use cairo_lang_filesystem::ids::Directory; use cairo_lang_starknet::starknet_plugin_suite; use cairo_lang_test_plugin::test_plugin_suite; -use cairo_lang_test_runner::{CompiledTestRunner, TestCompiler, TestRunConfig}; +use cairo_lang_test_runner::{CompiledTestRunner, RunProfilerConfig, TestCompiler, TestRunConfig}; use clap::Args; use dojo_lang::compiler::{collect_core_crate_ids, collect_external_crate_ids, Props}; use dojo_lang::plugin::dojo_plugin_suite; use dojo_lang::scarb_internal::crates_config_for_compilation_unit; use scarb::compiler::helpers::collect_main_crate_ids; -use scarb::compiler::CompilationUnit; +use scarb::compiler::{CairoCompilationUnit, CompilationUnit, CompilationUnitAttributes}; use scarb::core::Config; use scarb::ops; use tracing::trace; pub(crate) const LOG_TARGET: &str = "sozo::cli::commands::test"; +#[derive(Debug, Clone, PartialEq, clap::ValueEnum)] +pub enum ProfilerMode { + None, + Cairo, + Sierra, +} + +impl From for RunProfilerConfig { + fn from(mode: ProfilerMode) -> Self { + match mode { + ProfilerMode::None => RunProfilerConfig::None, + ProfilerMode::Cairo => RunProfilerConfig::Cairo, + ProfilerMode::Sierra => RunProfilerConfig::Sierra, + } + } +} + /// Execute all unit tests of a local package. #[derive(Debug, Args)] pub struct TestArgs { @@ -32,9 +49,9 @@ pub struct TestArgs { /// Should we run only the ignored tests. #[arg(long, default_value_t = false)] ignored: bool, - /// Should we run the profiler. - #[arg(long, default_value_t = false)] - run_profiler: bool, + /// Should we run the profiler and with what mode. + #[arg(long, default_value = "none")] + profiler_mode: ProfilerMode, } impl TestArgs { @@ -48,13 +65,23 @@ impl TestArgs { // TODO: Compute all compilation units and remove duplicates, could be unnecessary in future // version of Scarb. let mut compilation_units = ops::generate_compilation_units(&resolve, &ws)?; - compilation_units.sort_by_key(|unit| unit.main_package_id); - compilation_units.dedup_by_key(|unit| unit.main_package_id); + compilation_units.sort_by_key(|unit| unit.main_package_id()); + compilation_units.dedup_by_key(|unit| unit.main_package_id()); for unit in compilation_units { + let unit = if let CompilationUnit::Cairo(unit) = unit { + unit + } else { + continue; + }; + let props: Props = unit.target().props()?; let db = build_root_database(&unit)?; + if DiagnosticsReporter::stderr().allow_warnings().check(&db) { + bail!("failed to compile"); + } + let mut main_crate_ids = collect_main_crate_ids(&unit, &db); let test_crate_ids = main_crate_ids.clone(); @@ -67,20 +94,20 @@ impl TestArgs { main_crate_ids.extend(collect_external_crate_ids(&db, external_contracts)); } - if DiagnosticsReporter::stderr().allow_warnings().check(&db) { - bail!("failed to compile"); - } - let config = TestRunConfig { filter: self.filter.clone(), ignored: self.ignored, include_ignored: self.include_ignored, - run_profiler: self.run_profiler, + run_profiler: self.profiler_mode.clone().into(), }; - let compiler = TestCompiler { db, main_crate_ids, test_crate_ids, starknet: true }; + let compiler = + TestCompiler { db: db.snapshot(), main_crate_ids, test_crate_ids, starknet: true }; + let runner = CompiledTestRunner { compiled: compiler.build()?, config }; - runner.run()?; + + // Database is required here for the profiler to work. + runner.run(Some(&db))?; println!(); } @@ -89,10 +116,10 @@ impl TestArgs { } } -pub(crate) fn build_root_database(unit: &CompilationUnit) -> Result { +pub(crate) fn build_root_database(unit: &CairoCompilationUnit) -> Result { let mut b = RootDatabase::builder(); b.with_project_config(build_project_config(unit)?); - b.with_cfg(CfgSet::from_iter([Cfg::name("test")])); + b.with_cfg(CfgSet::from_iter([Cfg::name("test"), Cfg::kv("target", "test")])); b.with_plugin_suite(test_plugin_suite()); b.with_plugin_suite(dojo_plugin_suite()); @@ -101,7 +128,7 @@ pub(crate) fn build_root_database(unit: &CompilationUnit) -> Result Result { +fn build_project_config(unit: &CairoCompilationUnit) -> Result { let crate_roots = unit .components .iter() @@ -111,6 +138,7 @@ fn build_project_config(unit: &CompilationUnit) -> Result { let corelib = unit.core_package_component().map(|c| Directory::Real(c.target.source_root().into())); + let crates_config = crates_config_for_compilation_unit(unit); let content = ProjectConfigContent { crate_roots, crates_config }; diff --git a/crates/benches/README.md b/crates/benches/README.md index 8378baaa6a..79e4302a86 100644 --- a/crates/benches/README.md +++ b/crates/benches/README.md @@ -6,10 +6,9 @@ To run benchmarks one can use `cargo test --no-default-features` ## Prerequisites -- `cargo` - for test case generation and runtime -- `katana` - as a local RPC server -- `sozo` - for contract compilation and deployment - +- `cargo` - for test case generation and runtime +- `katana` - as a local RPC server +- `sozo` - for contract compilation and deployment ## Katana Benchmarks @@ -20,7 +19,7 @@ After the change to `u16` is released it should take the system installed versio cargo build -r --bin katana ``` -And to run the benchamarks +And to run the benchamarks ```bash cargo test --manifest-path crates/benches/Cargo.toml -- --nocapture @@ -35,7 +34,6 @@ katana bash scripts/cargo_bench.sh ``` - ### Requirements for running While benchmarks are running a Katana instance has to be online either remotely or locally... diff --git a/crates/dojo-core/Scarb.toml b/crates/dojo-core/Scarb.toml index fcd41ee8a8..9e23066bca 100644 --- a/crates/dojo-core/Scarb.toml +++ b/crates/dojo-core/Scarb.toml @@ -1,9 +1,9 @@ [package] -cairo-version = "2.4.0" +cairo-version = "=2.6.3" description = "The Dojo Core library for autonomous worlds." name = "dojo" version = "0.6.0" [dependencies] dojo_plugin = { git = "https://github.com/dojoengine/dojo", tag = "v0.3.11" } -starknet = "2.4.0" +starknet = "=2.6.3" diff --git a/crates/dojo-core/src/base_test.cairo b/crates/dojo-core/src/base_test.cairo index 9eb1d05485..564870b3ac 100644 --- a/crates/dojo-core/src/base_test.cairo +++ b/crates/dojo-core/src/base_test.cairo @@ -109,7 +109,7 @@ mod invalid_model { // Pre-computed address of a contract deployed through the world. // To print this addres, run: // sozo test --manifest-path crates/dojo-core/Scarb.toml -f test_deploy_from_world_invalid_model - 0x7e40f4ebb8008ae9a80d9afde360978bfa4ef5c33bc9689941abc7ae4455573 + 0x2a9a994dd0f235c8f032fdc6252947e4418e5a3001764049016279b8c0ad19a } } } diff --git a/crates/dojo-lang/Cargo.toml b/crates/dojo-lang/Cargo.toml index 2541730c92..78c2e37700 100644 --- a/crates/dojo-lang/Cargo.toml +++ b/crates/dojo-lang/Cargo.toml @@ -24,6 +24,7 @@ cairo-lang-project.workspace = true cairo-lang-semantic.workspace = true cairo-lang-sierra-generator.workspace = true cairo-lang-starknet.workspace = true +cairo-lang-starknet-classes.workspace = true cairo-lang-syntax.workspace = true cairo-lang-test-plugin.workspace = true cairo-lang-utils.workspace = true diff --git a/crates/dojo-lang/src/compiler.rs b/crates/dojo-lang/src/compiler.rs index 010dab774a..b9fcaab338 100644 --- a/crates/dojo-lang/src/compiler.rs +++ b/crates/dojo-lang/src/compiler.rs @@ -11,10 +11,11 @@ use cairo_lang_filesystem::db::FilesGroup; use cairo_lang_filesystem::ids::{CrateId, CrateLongId}; use cairo_lang_formatter::format_string; use cairo_lang_semantic::db::SemanticGroup; -use cairo_lang_starknet::abi; +use cairo_lang_starknet::compile::compile_prepared_db; use cairo_lang_starknet::contract::{find_contracts, ContractDeclaration}; -use cairo_lang_starknet::contract_class::{compile_prepared_db, ContractClass}; use cairo_lang_starknet::plugin::aux_data::StarkNetContractAuxData; +use cairo_lang_starknet_classes::abi; +use cairo_lang_starknet_classes::contract_class::ContractClass; use cairo_lang_utils::UpcastMut; use camino::{Utf8Path, Utf8PathBuf}; use convert_case::{Case, Casing}; @@ -24,7 +25,7 @@ use dojo_world::manifest::{ }; use itertools::Itertools; use scarb::compiler::helpers::{build_compiler_config, collect_main_crate_ids}; -use scarb::compiler::{CompilationUnit, Compiler}; +use scarb::compiler::{CairoCompilationUnit, CompilationUnitAttributes, Compiler}; use scarb::core::{PackageName, TargetKind, Workspace}; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; @@ -85,7 +86,7 @@ impl Compiler for DojoCompiler { fn compile( &self, - unit: CompilationUnit, + unit: CairoCompilationUnit, db: &mut RootDatabase, ws: &Workspace<'_>, ) -> Result<()> { diff --git a/crates/dojo-lang/src/compiler_test.rs b/crates/dojo-lang/src/compiler_test.rs index 6169ba02e7..29c24b7f63 100644 --- a/crates/dojo-lang/src/compiler_test.rs +++ b/crates/dojo-lang/src/compiler_test.rs @@ -4,18 +4,15 @@ use scarb::ops::CompileOpts; use crate::scarb_internal; -// TODO: Remove this ignore after issue mentioned in this PR is resolved: -// https://github.com/dojoengine/dojo/pull/1485 -#[ignore] #[test] -fn test_compiler() { - let config = build_test_config("../../examples/spawn-and-move/Scarb.toml").unwrap(); - assert!( - scarb_internal::compile_workspace( - &config, - CompileOpts { include_targets: vec![], exclude_targets: vec![TargetKind::TEST] }, - ) - .is_ok(), - "compilation failed" - ); +fn test_compiler_cairo_features() { + let config = build_test_config("./src/manifest_test_data/compiler_cairo/Scarb.toml").unwrap(); + + let compile_info = scarb_internal::compile_workspace( + &config, + CompileOpts { include_targets: vec![], exclude_targets: vec![TargetKind::TEST] }, + ) + .unwrap(); + + assert_eq!(compile_info.compile_error_units, Vec::::default()); } diff --git a/crates/dojo-lang/src/event.rs b/crates/dojo-lang/src/event.rs index 38cdad880b..8aca28df36 100644 --- a/crates/dojo-lang/src/event.rs +++ b/crates/dojo-lang/src/event.rs @@ -4,7 +4,8 @@ use cairo_lang_starknet::plugin::aux_data::StarkNetEventAuxData; use cairo_lang_starknet::plugin::consts::{ EVENT_TRAIT, EVENT_TYPE_NAME, KEY_ATTR, NESTED_ATTR, SERDE_ATTR, }; -use cairo_lang_starknet::plugin::events::{EventData, EventFieldKind}; +use cairo_lang_starknet::plugin::events::EventData; +use cairo_lang_starknet_classes::abi::EventFieldKind; use cairo_lang_syntax::node::db::SyntaxGroup; use cairo_lang_syntax::node::helpers::QueryAttrs; use cairo_lang_syntax::node::{ast, Terminal, TypedSyntaxNode}; diff --git a/crates/dojo-lang/src/manifest_test_data/cairo_v240 b/crates/dojo-lang/src/manifest_test_data/cairo_v240 deleted file mode 100644 index e5d36f9aaf..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/cairo_v240 +++ /dev/null @@ -1,993 +0,0 @@ -//! > Test for cairo v2.4.0 compatibility - -//! > test_runner_name -test_compiler_cairo_v240 - -//! > expected_manifest_file -{ - "world": { - "name": "dojo::world::world", - "address": null, - "class_hash": "0x5ad96ceea29160aa7305bb078d1ade41f73b487363ae12778dbea6393cc00b2", - "abi": [ - { - "type": "impl", - "name": "World", - "interface_name": "dojo::world::IWorld" - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::resource_metadata::ResourceMetadata", - "members": [ - { - "name": "resource_id", - "type": "core::felt252" - }, - { - "name": "metadata_uri", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "core::bool", - "variants": [ - { - "name": "False", - "type": "()" - }, - { - "name": "True", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::IWorld", - "items": [ - { - "type": "function", - "name": "metadata", - "inputs": [ - { - "name": "resource_id", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::resource_metadata::ResourceMetadata" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_metadata", - "inputs": [ - { - "name": "metadata", - "type": "dojo::resource_metadata::ResourceMetadata" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "model", - "inputs": [ - { - "name": "name", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "register_model", - "inputs": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "deploy_contract", - "inputs": [ - { - "name": "salt", - "type": "core::felt252" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_contract", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "uuid", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "emit", - "inputs": [ - { - "name": "keys", - "type": "core::array::Array::" - }, - { - "name": "values", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "function", - "name": "entity", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "keys", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "core::array::Span::" - } - ], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_entity", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "keys", - "type": "core::array::Span::" - }, - { - "name": "values", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "base", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "delete_entity", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "keys", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "is_owner", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "resource", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_owner", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "resource", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_owner", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "resource", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "is_writer", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "system", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_writer", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "system", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_writer", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "system", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableWorld", - "interface_name": "dojo::world::IUpgradeableWorld" - }, - { - "type": "interface", - "name": "dojo::world::IUpgradeableWorld", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [ - { - "name": "contract_base", - "type": "core::starknet::class_hash::ClassHash" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::WorldSpawned", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "creator", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::ContractDeployed", - "kind": "struct", - "members": [ - { - "name": "salt", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::ContractUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::WorldUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::MetadataUpdate", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "uri", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::ModelRegistered", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "prev_class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "prev_address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::StoreSetRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::StoreDelRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::WriterUpdated", - "kind": "struct", - "members": [ - { - "name": "model", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "system", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::OwnerUpdated", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::Event", - "kind": "enum", - "variants": [ - { - "name": "WorldSpawned", - "type": "dojo::world::world::WorldSpawned", - "kind": "nested" - }, - { - "name": "ContractDeployed", - "type": "dojo::world::world::ContractDeployed", - "kind": "nested" - }, - { - "name": "ContractUpgraded", - "type": "dojo::world::world::ContractUpgraded", - "kind": "nested" - }, - { - "name": "WorldUpgraded", - "type": "dojo::world::world::WorldUpgraded", - "kind": "nested" - }, - { - "name": "MetadataUpdate", - "type": "dojo::world::world::MetadataUpdate", - "kind": "nested" - }, - { - "name": "ModelRegistered", - "type": "dojo::world::world::ModelRegistered", - "kind": "nested" - }, - { - "name": "StoreSetRecord", - "type": "dojo::world::world::StoreSetRecord", - "kind": "nested" - }, - { - "name": "StoreDelRecord", - "type": "dojo::world::world::StoreDelRecord", - "kind": "nested" - }, - { - "name": "WriterUpdated", - "type": "dojo::world::world::WriterUpdated", - "kind": "nested" - }, - { - "name": "OwnerUpdated", - "type": "dojo::world::world::OwnerUpdated", - "kind": "nested" - } - ] - } - ], - "reads": [], - "writes": [], - "computed": [] - }, - "base": { - "name": "dojo::base::base", - "class_hash": "0x794d5ed2f7eb970f92e0ed9be8f73bbbdf18f7db2a9a296fa12c2d9c33e6ab3", - "abi": [ - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::components::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::components::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [] - }, - { - "type": "event", - "name": "dojo::components::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::components::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::components::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo::base::base::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::components::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } - ] - }, - "resource_metadata": { - "name": "dojo::resource_metadata::resource_metadata", - "address": null, - "class_hash": "0x6a2f06cde4aad60e0b6dd595edebe8dca1fbefe5b36cfc2f46a1d1159757df9", - "abi": [ - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "view" - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, core::array::Span::)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, core::array::Span::)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, core::array::Span::)>" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::>" - }, - { - "name": "Array", - "type": "core::integer::u32" - } - ] - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - }, - { - "type": "struct", - "name": "dojo::resource_metadata::ResourceMetadata", - "members": [ - { - "name": "resource_id", - "type": "core::felt252" - }, - { - "name": "metadata_uri", - "type": "core::array::Span::" - } - ] - }, - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo::resource_metadata::ResourceMetadata" - } - ], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "event", - "name": "dojo::resource_metadata::resource_metadata::Event", - "kind": "enum", - "variants": [] - } - ], - "reads": [], - "writes": [], - "computed": [] - }, - "contracts": [ - { - "name": "cairo_v240::cairo_v240", - "address": null, - "class_hash": "0x6517f8b97f269ae354fabcafe7428eda4ce60efbecc55dad8ac662144b8f469", - "abi": [ - { - "type": "event", - "name": "cairo_v240::cairo_v240::Event", - "kind": "enum", - "variants": [] - } - ], - "reads": [], - "writes": [], - "computed": [] - } - ], - "models": [] -} diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo_v240/.gitignore b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/.gitignore similarity index 100% rename from crates/dojo-lang/src/manifest_test_data/compiler_cairo_v240/.gitignore rename to crates/dojo-lang/src/manifest_test_data/compiler_cairo/.gitignore diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo_v240/Scarb.lock b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.lock similarity index 88% rename from crates/dojo-lang/src/manifest_test_data/compiler_cairo_v240/Scarb.lock rename to crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.lock index b2780e275d..6f542bc33a 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo_v240/Scarb.lock +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.lock @@ -2,7 +2,7 @@ version = 1 [[package]] -name = "cairo_v240" +name = "compiler_cairo" version = "0.1.0" dependencies = [ "dojo", @@ -10,7 +10,7 @@ dependencies = [ [[package]] name = "dojo" -version = "0.5.1" +version = "0.6.0" dependencies = [ "dojo_plugin", ] diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo_v240/Scarb.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.toml similarity index 75% rename from crates/dojo-lang/src/manifest_test_data/compiler_cairo_v240/Scarb.toml rename to crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.toml index d04b4e8e47..971e710469 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo_v240/Scarb.toml +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.toml @@ -1,8 +1,8 @@ [package] -name = "cairo_v240" +name = "compiler_cairo" version = "0.1.0" edition = "2023_10" -cairo-version = "2.4.0" +cairo-version = "2.6.3" # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html @@ -16,8 +16,8 @@ dojo = { path = "../../../../dojo-core" } build-external-contracts = [ ] [tool.dojo.world] -description = "Cairo 240 features" -name = "compiler_cairo_240" +description = "Cairo compiler features" +name = "compiler_cairo_features" [tool.dojo.env] rpc_url = "http://localhost:5050/" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/contracts/compiler_cairo_cairo_24_cairo_v240.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/contracts/compiler_cairo_cairo_24_cairo_v240.json new file mode 100644 index 0000000000..fdb8ff1c75 --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/contracts/compiler_cairo_cairo_24_cairo_v240.json @@ -0,0 +1,8 @@ +[ + { + "type": "event", + "name": "compiler_cairo::cairo_24::cairo_v240::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/contracts/compiler_cairo_cairo_26_cairo_v260.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/contracts/compiler_cairo_cairo_26_cairo_v260.json new file mode 100644 index 0000000000..86eebdcf3f --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/contracts/compiler_cairo_cairo_26_cairo_v260.json @@ -0,0 +1,8 @@ +[ + { + "type": "event", + "name": "compiler_cairo::cairo_26::cairo_v260::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/crates/torii/types-test/manifests/dev/abis/base/dojo_world_world.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/dojo_world_world.json similarity index 100% rename from crates/torii/types-test/manifests/dev/abis/base/dojo_world_world.json rename to crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/dojo_world_world.json diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/compiler_cairo_cairo_24_cairo_v240.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/compiler_cairo_cairo_24_cairo_v240.toml new file mode 100644 index 0000000000..a62805594e --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/compiler_cairo_cairo_24_cairo_v240.toml @@ -0,0 +1,9 @@ +kind = "DojoContract" +class_hash = "0x7468fbf6e47eb66fd898a4a68bbe801560fdd42b0d6909ec4f75fb38c613702" +original_class_hash = "0x7468fbf6e47eb66fd898a4a68bbe801560fdd42b0d6909ec4f75fb38c613702" +base_class_hash = "0x0" +abi = "manifests/dev/abis/base/contracts/compiler_cairo_cairo_24_cairo_v240.json" +reads = [] +writes = [] +computed = [] +name = "compiler_cairo::cairo_24::cairo_v240" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/compiler_cairo_cairo_26_cairo_v260.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/compiler_cairo_cairo_26_cairo_v260.toml new file mode 100644 index 0000000000..e4f5304c0d --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/compiler_cairo_cairo_26_cairo_v260.toml @@ -0,0 +1,9 @@ +kind = "DojoContract" +class_hash = "0x4bbfcdc8d95ecfa332201e21f615e98b4d12e08f77d176761e32bb34e3bc333" +original_class_hash = "0x4bbfcdc8d95ecfa332201e21f615e98b4d12e08f77d176761e32bb34e3bc333" +base_class_hash = "0x0" +abi = "manifests/dev/abis/base/contracts/compiler_cairo_cairo_26_cairo_v260.json" +reads = [] +writes = [] +computed = [] +name = "compiler_cairo::cairo_26::cairo_v260" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_base_base.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_base_base.toml new file mode 100644 index 0000000000..6c4b5de67e --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_base_base.toml @@ -0,0 +1,4 @@ +kind = "Class" +class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" +original_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" +name = "dojo::base::base" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml new file mode 100644 index 0000000000..d9220cfb88 --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml @@ -0,0 +1,5 @@ +kind = "Class" +class_hash = "0x301ba8a1a13cec9291b049dea531f73a600e0812908cefa26d17214da411e9c" +original_class_hash = "0x301ba8a1a13cec9291b049dea531f73a600e0812908cefa26d17214da411e9c" +abi = "manifests/dev/abis/base/dojo_world_world.json" +name = "dojo::world::world" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo_v240/src/lib.cairo b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/cairo_24.cairo similarity index 84% rename from crates/dojo-lang/src/manifest_test_data/compiler_cairo_v240/src/lib.cairo rename to crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/cairo_24.cairo index e3a0cb13f3..cd525d49bf 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo_v240/src/lib.cairo +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/cairo_24.cairo @@ -20,8 +20,8 @@ mod cairo_v240 { fn formatter(self: @ContractState) { let var = 5; let mut formatter: Formatter = Default::default(); - write!(formatter, "test"); - write!(formatter, "{var:?}"); + write!(formatter, "test").unwrap(); + write!(formatter, "{var:?}").unwrap(); println!("{}", formatter.buffer); //prints test5 } @@ -29,9 +29,9 @@ mod cairo_v240 { let var1 = 5; let var2: ByteArray = "hello"; let var3 = 5_u32; - let ba = format!("{},{},{}", var1, var2, var3); - let ba = format!("{var1}{var2}{var3}"); - let ba = format!("{var1:?}{var2:?}{var3:?}"); + let _ba = format!("{},{},{}", var1, var2, var3); + let _ba = format!("{var1}{var2}{var3}"); + let _ba = format!("{var1:?}{var2:?}{var3:?}"); } fn long_panic(self: @ContractState) { diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/cairo_26.cairo b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/cairo_26.cairo new file mode 100644 index 0000000000..3eb6ba807d --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/cairo_26.cairo @@ -0,0 +1,53 @@ +//! Cairo 2.6.0 feature testing. +#[starknet::contract] +mod cairo_v260 { + // Constants. + enum ThreeOptions { + A: felt252, + B: (u256, u256), + C, + } + + struct ThreeOptionsPair { + a: ThreeOptions, + b: ThreeOptions, + } + + const V: ThreeOptionsPair = ThreeOptionsPair { + a: ThreeOptions::A(1337), + b: ThreeOptions::C, + }; + + #[storage] + struct Storage {} + + #[derive(Drop)] + enum MyEnum { + Foo, + Bar + } + + fn if_let() { + let number = Option::Some(5); + let foo_or_bar = MyEnum::Foo; + + if let Option::Some(i) = number { + println!("{}", i); + } + + if let MyEnum::Bar = foo_or_bar { + println!("bar"); + } + } + + fn while_let(mut arr: Array) -> felt252 { + let mut sum = 0; + while let Option::Some(x) = arr.pop_front() { + sum += x; + }; + sum + } + + fn const_reference() -> ThreeOptionsPair { V } + fn const_box() -> Box { BoxTrait::new(V) } +} diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/lib.cairo b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/lib.cairo new file mode 100644 index 0000000000..bf8bc5f9aa --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/src/lib.cairo @@ -0,0 +1,2 @@ +mod cairo_24; +mod cairo_26; diff --git a/crates/dojo-lang/src/scarb_internal/mod.rs b/crates/dojo-lang/src/scarb_internal/mod.rs index c6ff1cd3a4..a3b9e0d014 100644 --- a/crates/dojo-lang/src/scarb_internal/mod.rs +++ b/crates/dojo-lang/src/scarb_internal/mod.rs @@ -7,14 +7,14 @@ use anyhow::Result; use cairo_lang_compiler::db::RootDatabase; use cairo_lang_compiler::project::{ProjectConfig, ProjectConfigContent}; -use cairo_lang_filesystem::db::CrateSettings; +use cairo_lang_filesystem::db::{CrateSettings, ExperimentalFeaturesConfig}; use cairo_lang_filesystem::ids::Directory; use cairo_lang_project::AllCratesConfig; use cairo_lang_starknet::starknet_plugin_suite; use cairo_lang_test_plugin::test_plugin_suite; use cairo_lang_utils::ordered_hash_map::OrderedHashMap; use camino::Utf8PathBuf; -use scarb::compiler::CompilationUnit; +use scarb::compiler::{CairoCompilationUnit, CompilationUnit, CompilationUnitAttributes}; use scarb::core::Config; use scarb::ops::CompileOpts; use smol_str::SmolStr; @@ -24,22 +24,41 @@ use crate::plugin::dojo_plugin_suite; pub(crate) const LOG_TARGET: &str = "dojo_lang::scarb_internal"; -#[derive(Debug)] +/// Compilation information of all the units found in the workspace. +#[derive(Debug, Default)] pub struct CompileInfo { + /// The name of the profile used to compile. pub profile_name: String, + /// The path to the manifest file. pub manifest_path: Utf8PathBuf, + /// The path to the target directory. pub target_dir: Utf8PathBuf, + /// The name of the root package. pub root_package_name: Option, + /// The list of units that failed to compile. + pub compile_error_units: Vec, } -pub fn crates_config_for_compilation_unit(unit: &CompilationUnit) -> AllCratesConfig { +pub fn crates_config_for_compilation_unit(unit: &CairoCompilationUnit) -> AllCratesConfig { let crates_config: OrderedHashMap = unit - .components + .components() .iter() .map(|component| { + // Ensure experimental features are only enable if required. + let experimental_features = component.package.manifest.experimental_features.clone(); + let experimental_features = experimental_features.unwrap_or_default(); + ( component.cairo_package_name(), - CrateSettings { edition: component.package.manifest.edition, ..Default::default() }, + CrateSettings { + edition: component.package.manifest.edition, + experimental_features: ExperimentalFeaturesConfig { + negative_impls: experimental_features + .contains(&SmolStr::new_inline("negative_impls")), + coupons: experimental_features.contains(&SmolStr::new_inline("coupons")), + }, + ..Default::default() + }, ) }) .collect(); @@ -49,7 +68,7 @@ pub fn crates_config_for_compilation_unit(unit: &CompilationUnit) -> AllCratesCo /// Builds the scarb root database injecting the dojo plugin suite, additionaly to the /// default Starknet and Test suites. -pub fn build_scarb_root_database(unit: &CompilationUnit) -> Result { +pub fn build_scarb_root_database(unit: &CairoCompilationUnit) -> Result { let mut b = RootDatabase::builder(); b.with_project_config(build_project_config(unit)?); b.with_cfg(unit.cfg_set.clone()); @@ -74,14 +93,20 @@ pub fn compile_workspace(config: &Config, opts: CompileOpts) -> Result>(); + let mut compile_error_units = vec![]; for unit in compilation_units { - let mut db = build_scarb_root_database(&unit).unwrap(); - - if let Err(err) = ws.config().compilers().compile(unit.clone(), &mut (db), &ws) { - ws.config().ui().anyhow(&err) + if let CompilationUnit::Cairo(unit) = unit { + let mut db = build_scarb_root_database(&unit).unwrap(); + + if let Err(err) = ws.config().compilers().compile(unit.clone(), &mut (db), &ws) { + ws.config().ui().anyhow(&err); + compile_error_units.push(unit.name()); + } + } else { + tracing::warn!(target: LOG_TARGET, name = unit.name(), "Skipping compilation unit."); } } @@ -100,12 +125,18 @@ pub fn compile_workspace(config: &Config, opts: CompileOpts) -> Result Result { +fn build_project_config(unit: &CairoCompilationUnit) -> Result { let crate_roots = unit - .components + .components() .iter() .filter(|model| !model.package.id.is_core()) .map(|model| (model.cairo_package_name(), model.target.source_root().into())) diff --git a/crates/dojo-lang/src/semantics/test_data/array_cap b/crates/dojo-lang/src/semantics/test_data/array_cap index 9cd17d8c22..c3b99ac28b 100644 --- a/crates/dojo-lang/src/semantics/test_data/array_cap +++ b/crates/dojo-lang/src/semantics/test_data/array_cap @@ -76,6 +76,7 @@ Block( ExprFunctionCall { function: core::array::ArrayImpl::::new, args: [], + coupon_arg: None, ty: core::array::Array::, }, ), @@ -110,6 +111,7 @@ Block( ), ), ], + coupon_arg: None, ty: (), }, ), @@ -133,6 +135,7 @@ Block( ), ), ], + coupon_arg: None, ty: (), }, ), diff --git a/crates/dojo-lang/src/semantics/test_data/get b/crates/dojo-lang/src/semantics/test_data/get index 04d1b0419a..0a9856e20e 100644 --- a/crates/dojo-lang/src/semantics/test_data/get +++ b/crates/dojo-lang/src/semantics/test_data/get @@ -136,6 +136,7 @@ Block( ExprFunctionCall { function: core::array::ArrayImpl::::new, args: [], + coupon_arg: None, ty: core::array::Array::, }, ), @@ -161,6 +162,7 @@ Block( LocalVarId(test::__get_macro_keys__), ), ], + coupon_arg: None, ty: (), }, ), @@ -186,6 +188,7 @@ Block( ), ), ], + coupon_arg: None, ty: core::array::Span::, }, ), @@ -200,6 +203,7 @@ Block( ExprFunctionCall { function: core::array::ArrayImpl::::new, args: [], + coupon_arg: None, ty: core::array::Array::, }, ), @@ -215,6 +219,7 @@ Block( LocalVarId(test::__Health_layout__), ), ], + coupon_arg: None, ty: (), }, ), @@ -240,6 +245,7 @@ Block( ), ), ], + coupon_arg: None, ty: core::array::Array::, }, ), @@ -265,6 +271,7 @@ Block( ), ), ], + coupon_arg: None, ty: core::array::Span::, }, ), @@ -290,6 +297,7 @@ Block( ), ), ], + coupon_arg: None, ty: core::array::Span::, }, ), @@ -328,6 +336,7 @@ Block( ), ), ], + coupon_arg: None, ty: core::array::Span::, }, ), @@ -342,6 +351,7 @@ Block( ExprFunctionCall { function: core::array::ArrayImpl::::new, args: [], + coupon_arg: None, ty: core::array::Array::, }, ), @@ -362,6 +372,7 @@ Block( LocalVarId(test::__Health_model__), ), ], + coupon_arg: None, ty: (), }, ), @@ -382,6 +393,7 @@ Block( LocalVarId(test::__Health_model__), ), ], + coupon_arg: None, ty: (), }, ), @@ -407,6 +419,7 @@ Block( ), ), ], + coupon_arg: None, ty: core::array::Span::, }, ), @@ -425,6 +438,7 @@ Block( LocalVarId(test::__Health_model_span__), ), ], + coupon_arg: None, ty: core::option::Option::, }, ), @@ -434,23 +448,26 @@ Block( StatementExpr { expr: If( ExprIf { - condition: FunctionCall( - ExprFunctionCall { - function: core::option::OptionTraitImpl::::is_none, - args: [ - Value( - Snapshot( - ExprSnapshot { - inner: Var( - LocalVarId(test::__Health), - ), - ty: @core::option::Option::, - }, + condition: BoolExpr( + FunctionCall( + ExprFunctionCall { + function: core::option::OptionTraitImpl::::is_none, + args: [ + Value( + Snapshot( + ExprSnapshot { + inner: Var( + LocalVarId(test::__Health), + ), + ty: @core::option::Option::, + }, + ), ), - ), - ], - ty: core::bool, - }, + ], + coupon_arg: None, + ty: core::bool, + }, + ), ), if_block: Block( ExprBlock { @@ -469,6 +486,7 @@ Block( ExprFunctionCall { function: core::fmt::FormatterDefault::default, args: [], + coupon_arg: None, ty: core::fmt::Formatter, }, ), @@ -510,6 +528,7 @@ Block( ), ), ], + coupon_arg: None, ty: (), }, ), @@ -541,6 +560,7 @@ Block( ), ), ], + coupon_arg: None, ty: (), }, ), @@ -572,6 +592,7 @@ Block( ), ), ], + coupon_arg: None, ty: (), }, ), @@ -603,6 +624,7 @@ Block( ), ), ], + coupon_arg: None, ty: (), }, ), @@ -634,6 +656,7 @@ Block( ), ), ], + coupon_arg: None, ty: (), }, ), @@ -643,12 +666,7 @@ Block( tail: Some( EnumVariantCtor( ExprEnumVariantCtor { - variant: ConcreteVariant { - concrete_enum_id: core::result::Result::<(), core::fmt::Error>, - id: VariantId(core::result::Ok), - ty: (), - idx: 0, - }, + variant: Result::Ok, value_expr: Tuple( ExprTuple { items: [], @@ -664,6 +682,7 @@ Block( ), ), ], + coupon_arg: None, ty: (), }, ), @@ -693,6 +712,7 @@ Block( ), ), ], + coupon_arg: None, ty: core::never, }, ), @@ -728,6 +748,7 @@ Block( ), ), ], + coupon_arg: None, ty: test::Health, }, ), diff --git a/crates/dojo-lang/src/semantics/test_data/set b/crates/dojo-lang/src/semantics/test_data/set index 8f62ef682d..12baaf817f 100644 --- a/crates/dojo-lang/src/semantics/test_data/set +++ b/crates/dojo-lang/src/semantics/test_data/set @@ -182,6 +182,7 @@ Block( ), ), ], + coupon_arg: None, ty: core::felt252, }, ), @@ -202,6 +203,7 @@ Block( ), ), ], + coupon_arg: None, ty: core::array::Span::, }, ), @@ -222,6 +224,7 @@ Block( ), ), ], + coupon_arg: None, ty: core::array::Span::, }, ), @@ -242,11 +245,13 @@ Block( ), ), ], + coupon_arg: None, ty: core::array::Span::, }, ), ), ], + coupon_arg: None, ty: (), }, ), diff --git a/crates/dojo-lang/src/semantics/utils.rs b/crates/dojo-lang/src/semantics/utils.rs index 36fb365a46..a2e588c024 100644 --- a/crates/dojo-lang/src/semantics/utils.rs +++ b/crates/dojo-lang/src/semantics/utils.rs @@ -2,7 +2,9 @@ use std::collections::{BTreeSet, HashMap}; use cairo_lang_compiler::db::RootDatabase; use cairo_lang_defs::db::DefsGroup; -use cairo_lang_defs::ids::{FunctionWithBodyId, ImplItemId, LookupItemId, ModuleId, ModuleItemId}; +use cairo_lang_defs::ids::{ + FunctionWithBodyId, ImplItemId, LookupItemId, ModuleId, ModuleItemId, NamedLanguageElementId, +}; use cairo_lang_lowering::db::LoweringGroup; use cairo_lang_lowering::ids::{self as low, SemanticFunctionWithBodyIdEx}; use cairo_lang_lowering::Statement; diff --git a/crates/dojo-test-utils/src/compiler.rs b/crates/dojo-test-utils/src/compiler.rs index 06ab15362d..9a60e0d5d8 100644 --- a/crates/dojo-test-utils/src/compiler.rs +++ b/crates/dojo-test-utils/src/compiler.rs @@ -1,5 +1,5 @@ use std::fs::File; -use std::io::{Read, Write}; +use std::io::Read; use std::path::PathBuf; use std::{env, fs, io}; @@ -8,13 +8,31 @@ use camino::{Utf8Path, Utf8PathBuf}; use dojo_lang::compiler::DojoCompiler; use dojo_lang::plugin::CairoPluginRepository; use dojo_lang::scarb_internal::{compile_workspace, CompileInfo}; -use scarb::compiler::CompilerRepository; +use scarb::compiler::{CompilationUnit, CompilerRepository}; use scarb::core::{Config, TargetKind}; use scarb::ops; use scarb::ops::CompileOpts; use scarb_ui::Verbosity; use toml::{Table, Value}; +/// Copies a project into a temporary directory and loads a config from the copied project. +/// +/// # Returns +/// +/// A [`Config`] object loaded from the spawn-and-moves Scarb.toml file. +pub fn copy_tmp_config(source_project_dir: &Utf8PathBuf, dojo_core_path: &Utf8PathBuf) -> Config { + let temp_project_dir = Utf8PathBuf::from( + assert_fs::TempDir::new().unwrap().to_path_buf().to_string_lossy().to_string(), + ); + + let temp_project_path = temp_project_dir.join("Scarb").with_extension("toml").to_string(); + + // Copy all the files, including manifests. As we will not re-build, mostly only migrate. + copy_project_temp(source_project_dir, &temp_project_dir, dojo_core_path, &[]).unwrap(); + + build_test_config(&temp_project_path).unwrap_or_else(|c| panic!("Error loading config: {c:?}")) +} + /// Copies a project to a new location, excluding the manifests /// and target directories, build the temporary project and /// return the temporary project directory. @@ -28,6 +46,7 @@ use toml::{Table, Value}; /// it wisely. pub fn copy_build_project_temp( source_project_path: &str, + dojo_core_path: &str, do_build: bool, ) -> (Utf8PathBuf, Config, Option) { let source_project_dir = Utf8PathBuf::from(source_project_path).parent().unwrap().to_path_buf(); @@ -38,9 +57,13 @@ pub fn copy_build_project_temp( let temp_project_path = temp_project_dir.join("Scarb").with_extension("toml").to_string(); - copy_project_temp(&source_project_dir, &temp_project_dir).unwrap(); + let dojo_core_path = Utf8PathBuf::from(dojo_core_path); + let ignore_dirs = ["manifests", "target"]; + + copy_project_temp(&source_project_dir, &temp_project_dir, &dojo_core_path, &ignore_dirs) + .unwrap(); - let config = build_test_config_default(&temp_project_path).unwrap(); + let config = build_test_config(&temp_project_path).unwrap(); let compile_info = if do_build { Some( @@ -65,9 +88,9 @@ pub fn copy_build_project_temp( pub fn copy_project_temp( source_dir: &Utf8PathBuf, destination_dir: &Utf8PathBuf, + dojo_core_path: &Utf8PathBuf, + ignore_dirs: &[&str], ) -> io::Result<()> { - let ignore_dirs = ["manifests", "target"]; - if !destination_dir.exists() { fs::create_dir_all(destination_dir)?; } @@ -88,16 +111,20 @@ pub fn copy_project_temp( copy_project_temp( &Utf8PathBuf::from_path_buf(path).unwrap(), &destination_dir.join(dir_name), + dojo_core_path, + ignore_dirs, )?; } else { let file_name = entry.file_name().to_string_lossy().to_string(); let dest_path = destination_dir.join(&file_name); + fs::copy(&path, &dest_path)?; + // Replace in the Scarb.toml the path of dojo crate with the // absolute path. if file_name == "Scarb.toml" { let mut contents = String::new(); - File::open(&path) + File::open(&dest_path) .and_then(|mut file| file.read_to_string(&mut contents)) .unwrap_or_else(|_| panic!("Failed to read {file_name}")); @@ -105,20 +132,14 @@ pub fn copy_project_temp( let dojo = table["dependencies"]["dojo"].as_table_mut().unwrap(); - let absolute_path = Value::String( - fs::canonicalize(Utf8PathBuf::from(dojo["path"].as_str().unwrap())) - .unwrap() - .to_string_lossy() - .to_string(), - ); - - dojo["path"] = absolute_path; + if dojo.contains_key("path") { + dojo["path"] = Value::String( + fs::canonicalize(dojo_core_path).unwrap().to_string_lossy().to_string(), + ); - File::create(&dest_path) - .and_then(|mut file| file.write_all(table.to_string().as_bytes())) - .expect("Failed to write to Scab.toml"); - } else { - fs::copy(path, dest_path)?; + fs::write(dest_path.to_path_buf(), table.to_string().as_bytes()) + .expect("Failed to write to Scab.toml"); + } } } } @@ -126,14 +147,28 @@ pub fn copy_project_temp( Ok(()) } -pub fn build_test_config_default(path: &str) -> anyhow::Result { +/// Builds a test config with a temporary cache directory. +/// +/// As manifests files are not related to the target_dir, it is recommended +/// to use copy_build_project_temp to copy the project to a temporary location +/// and build the config from there. This ensures safe and non conflicting +/// manipulation of the artifacts and manifests. +/// +/// # Arguments +/// +/// * `path` - The path to the Scarb.toml file to build the config for. +pub fn build_test_config(path: &str) -> anyhow::Result { let mut compilers = CompilerRepository::empty(); compilers.add(Box::new(DojoCompiler)).unwrap(); let cairo_plugins = CairoPluginRepository::default(); + // If the cache_dir is not overriden, we can't run tests in parallel. + let cache_dir = TempDir::new().unwrap(); + let path = Utf8PathBuf::from_path_buf(path.into()).unwrap(); Config::builder(path.canonicalize_utf8().unwrap()) + .global_cache_dir_override(Some(Utf8Path::from_path(cache_dir.path()).unwrap())) .ui_verbosity(Verbosity::Verbose) .log_filter_directive(env::var_os("SCARB_LOG")) .compilers(compilers) @@ -141,54 +176,17 @@ pub fn build_test_config_default(path: &str) -> anyhow::Result { .build() } -pub fn build_test_config(path: &str) -> anyhow::Result { - build_full_test_config(path, true) -} - -pub fn build_full_test_config(path: &str, override_dirs: bool) -> anyhow::Result { - let mut compilers = CompilerRepository::empty(); - compilers.add(Box::new(DojoCompiler)).unwrap(); - - let cairo_plugins = CairoPluginRepository::default(); - let path = Utf8PathBuf::from_path_buf(path.into()).unwrap(); - - if override_dirs { - let cache_dir = TempDir::new().unwrap(); - let config_dir = TempDir::new().unwrap(); - let target_dir = TempDir::new().unwrap(); - - Config::builder(path.canonicalize_utf8().unwrap()) - .global_cache_dir_override(Some(Utf8Path::from_path(cache_dir.path()).unwrap())) - .global_config_dir_override(Some(Utf8Path::from_path(config_dir.path()).unwrap())) - .target_dir_override(Some( - Utf8Path::from_path(target_dir.path()).unwrap().to_path_buf(), - )) - .ui_verbosity(Verbosity::Verbose) - .log_filter_directive(env::var_os("SCARB_LOG")) - .compilers(compilers) - .cairo_plugins(cairo_plugins.into()) - .build() - } else { - Config::builder(path.canonicalize_utf8().unwrap()) - .ui_verbosity(Verbosity::Verbose) - .log_filter_directive(env::var_os("SCARB_LOG")) - .compilers(compilers) - .cairo_plugins(cairo_plugins.into()) - .build() - } -} - pub fn corelib() -> PathBuf { let config = build_test_config("./src/manifest_test_data/spawn-and-move/Scarb.toml").unwrap(); let ws = ops::read_workspace(config.manifest_path(), &config).unwrap(); let resolve = ops::resolve_workspace(&ws).unwrap(); let compilation_units = ops::generate_compilation_units(&resolve, &ws).unwrap(); - compilation_units[0] - .core_package_component() - .expect("should have component") - .target - .source_root() - .into() + + if let CompilationUnit::Cairo(unit) = &compilation_units[0] { + unit.core_package_component().expect("should have component").target.source_root().into() + } else { + panic!("should have cairo compilation unit") + } } #[cfg(test)] @@ -228,10 +226,13 @@ mod tests { let mut ignored_sub_file = File::create(ignored_sub_file_path).unwrap(); writeln!(ignored_sub_file, "This should be ignored!").unwrap(); - // Perform the copy + let ignore_dirs = ["manifests", "target"]; + copy_project_temp( &Utf8PathBuf::from(&project_dir.to_string_lossy()), &Utf8PathBuf::from(&dest_dir.to_string_lossy()), + &Utf8PathBuf::from("../dojo-core"), + &ignore_dirs, ) .unwrap(); diff --git a/crates/dojo-world/Cargo.toml b/crates/dojo-world/Cargo.toml index 3780dd8211..a6ff41601b 100644 --- a/crates/dojo-world/Cargo.toml +++ b/crates/dojo-world/Cargo.toml @@ -12,6 +12,7 @@ async-trait.workspace = true cairo-lang-filesystem.workspace = true cairo-lang-project.workspace = true cairo-lang-starknet.workspace = true +cairo-lang-starknet-classes.workspace = true camino.workspace = true convert_case.workspace = true futures.workspace = true @@ -38,6 +39,7 @@ assert_fs = "1.0.9" assert_matches.workspace = true dojo-lang.workspace = true dojo-test-utils = { path = "../dojo-test-utils" } +katana-runner.workspace = true similar-asserts.workspace = true tokio.workspace = true tempfile = "3.3.0" diff --git a/crates/dojo-world/abigen/Cargo.toml b/crates/dojo-world/abigen/Cargo.toml index 267f9fd16c..517f00af1e 100644 --- a/crates/dojo-world/abigen/Cargo.toml +++ b/crates/dojo-world/abigen/Cargo.toml @@ -12,3 +12,4 @@ scarb.workspace = true serde.workspace = true serde_json.workspace = true cairo-lang-starknet.workspace = true +cairo-lang-starknet-classes.workspace = true diff --git a/crates/dojo-world/abigen/src/main.rs b/crates/dojo-world/abigen/src/main.rs index 50af94b9e7..4b0d2bbf03 100644 --- a/crates/dojo-world/abigen/src/main.rs +++ b/crates/dojo-world/abigen/src/main.rs @@ -3,7 +3,7 @@ use std::fs::{self, File}; use std::io::Write; use std::path::Path; -use cairo_lang_starknet::contract_class::ContractClass; +use cairo_lang_starknet_classes::contract_class::ContractClass; use camino::Utf8PathBuf; use scarb::core::{Config, TargetKind}; use scarb::ops::CompileOpts; diff --git a/crates/dojo-world/src/contracts/abi/README.md b/crates/dojo-world/src/contracts/abi/README.md index e218c37e56..dc3953a1ce 100644 --- a/crates/dojo-world/src/contracts/abi/README.md +++ b/crates/dojo-world/src/contracts/abi/README.md @@ -3,6 +3,7 @@ To ease the re-use of `dojo-world` crate on other projects that are not aware of the whole dojo stack, the ABI used for binding generation are decoupled from the compilation process. To generate the ABI in `world.rs` or `executor.rs`, please consider to run: + ```bash cargo run --bin dojo-world-abigen ``` diff --git a/crates/dojo-world/src/contracts/model_test.rs b/crates/dojo-world/src/contracts/model_test.rs index 039f18d4f4..5edbbb6d8e 100644 --- a/crates/dojo-world/src/contracts/model_test.rs +++ b/crates/dojo-world/src/contracts/model_test.rs @@ -1,11 +1,10 @@ use camino::Utf8PathBuf; -use dojo_test_utils::sequencer::{ - get_default_test_starknet_config, SequencerConfig, TestSequencer, -}; +use dojo_test_utils::compiler; use dojo_types::primitive::Primitive; use dojo_types::schema::{Enum, EnumOption, Member, Struct, Ty}; +use katana_runner::KatanaRunner; use starknet::accounts::ConnectedAccount; -use starknet::core::types::FieldElement; +use starknet::macros::felt; use crate::contracts::model::ModelReader; use crate::contracts::world::test::deploy_world; @@ -13,16 +12,19 @@ use crate::contracts::world::WorldContractReader; #[tokio::test(flavor = "multi_thread")] async fn test_model() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; - let account = sequencer.account(); + let runner = KatanaRunner::new().expect("Fail to set runner"); + let account = runner.account(0); let provider = account.provider(); - let world_address = deploy_world( - &sequencer, - &Utf8PathBuf::from_path_buf("../../examples/spawn-and-move".into()).unwrap(), - &Utf8PathBuf::from_path_buf("../../examples/spawn-and-move/target/dev".into()).unwrap(), - ) - .await; + + let config = compiler::copy_tmp_config( + &Utf8PathBuf::from("../../examples/spawn-and-move"), + &Utf8PathBuf::from("../dojo-core"), + ); + + let manifest_dir = config.manifest_path().parent().unwrap(); + let target_dir = manifest_dir.join("target").join("dev"); + + let world_address = deploy_world(&runner, &manifest_dir.into(), &target_dir).await; let world = WorldContractReader::new(world_address, provider); let position = world.model_reader("Position").await.unwrap(); @@ -63,10 +65,7 @@ async fn test_model() { assert_eq!( position.class_hash(), - FieldElement::from_hex_be( - "0x00b33ae053213ccb2a57967ffc4411901f3efab24781ca867adcd0b90f2fece5" - ) - .unwrap() + felt!("0x0151d4e1655053bc12c41f2e46ff6cb740c024320f129d92331cb1d2e59e4aa3") ); let moves = world.model_reader("Moves").await.unwrap(); diff --git a/crates/dojo-world/src/contracts/world_test.rs b/crates/dojo-world/src/contracts/world_test.rs index 2edf50cf6e..3c5afe8886 100644 --- a/crates/dojo-world/src/contracts/world_test.rs +++ b/crates/dojo-world/src/contracts/world_test.rs @@ -2,9 +2,8 @@ use std::time::Duration; use camino::Utf8PathBuf; use dojo_lang::compiler::{BASE_DIR, MANIFESTS_DIR}; -use dojo_test_utils::sequencer::{ - get_default_test_starknet_config, SequencerConfig, TestSequencer, -}; +use dojo_test_utils::compiler; +use katana_runner::KatanaRunner; use starknet::accounts::{Account, ConnectedAccount}; use starknet::core::types::FieldElement; @@ -16,22 +15,25 @@ use crate::migration::{Declarable, Deployable, TxnConfig}; #[tokio::test(flavor = "multi_thread")] async fn test_world_contract_reader() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; - let account = sequencer.account(); + let runner = KatanaRunner::new().expect("Fail to set runner"); + let config = compiler::copy_tmp_config( + &Utf8PathBuf::from("../../examples/spawn-and-move"), + &Utf8PathBuf::from("../dojo-core"), + ); + + let manifest_dir = config.manifest_path().parent().unwrap(); + let target_dir = manifest_dir.join("target").join("dev"); + + let account = runner.account(0); let provider = account.provider(); - let world_address = deploy_world( - &sequencer, - &Utf8PathBuf::from_path_buf("../../examples/spawn-and-move".into()).unwrap(), - &Utf8PathBuf::from_path_buf("../../examples/spawn-and-move/target/dev".into()).unwrap(), - ) - .await; + let world_address = + deploy_world(&runner, &manifest_dir.to_path_buf(), &target_dir.to_path_buf()).await; let _world = WorldContractReader::new(world_address, provider); } pub async fn deploy_world( - sequencer: &TestSequencer, + sequencer: &KatanaRunner, manifest_dir: &Utf8PathBuf, target_dir: &Utf8PathBuf, ) -> FieldElement { @@ -43,7 +45,7 @@ pub async fn deploy_world( ) .unwrap(); let world = WorldDiff::compute(manifest.clone(), None); - let account = sequencer.account(); + let account = sequencer.account(0); let strategy = prepare_for_migration( None, diff --git a/crates/dojo-world/src/manifest/manifest_test.rs b/crates/dojo-world/src/manifest/manifest_test.rs index c39d7b4ad0..13cab35c4e 100644 --- a/crates/dojo-world/src/manifest/manifest_test.rs +++ b/crates/dojo-world/src/manifest/manifest_test.rs @@ -2,10 +2,9 @@ use std::io::Write; use camino::Utf8PathBuf; use dojo_lang::compiler::{BASE_DIR, MANIFESTS_DIR}; +use dojo_test_utils::compiler; use dojo_test_utils::rpc::MockJsonRpcTransport; -use dojo_test_utils::sequencer::{ - get_default_test_starknet_config, SequencerConfig, TestSequencer, -}; +use katana_runner::KatanaRunner; use serde_json::json; use starknet::accounts::ConnectedAccount; use starknet::core::types::contract::AbiEntry; @@ -364,28 +363,35 @@ fn events_without_block_number_arent_parsed() { similar_asserts::assert_eq!(actual_contracts, expected_contracts); } -#[tokio::test(flavor = "multi_thread")] -async fn fetch_remote_manifest() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; +#[test] +fn fetch_remote_manifest() { + let runner = KatanaRunner::new().expect("Fail to set runner"); - let account = sequencer.account(); + let account = runner.account(0); let provider = account.provider(); - let manifest_path = Utf8PathBuf::from_path_buf("../../examples/spawn-and-move".into()).unwrap(); - let artifacts_path = - Utf8PathBuf::from_path_buf("../../examples/spawn-and-move/target/dev".into()).unwrap(); + let source_project = "../../examples/spawn-and-move/Scarb.toml"; + let dojo_core_path = "../dojo-core"; + let profile_name = "dev"; - let world_address = deploy_world(&sequencer, &manifest_path, &artifacts_path).await; + // Build a completely new project in it's own directory. + let (temp_project_dir, config, _) = + compiler::copy_build_project_temp(source_project, dojo_core_path, true); - let profile_name = "dev"; + let artifacts_path = temp_project_dir.join(format!("target/{profile_name}")); + + let world_address = config + .tokio_handle() + .block_on(async { deploy_world(&runner, &temp_project_dir, &artifacts_path).await }); let local_manifest = BaseManifest::load_from_path( - &manifest_path.join(MANIFESTS_DIR).join(profile_name).join(BASE_DIR), + &temp_project_dir.join(MANIFESTS_DIR).join(profile_name).join(BASE_DIR), ) .unwrap(); - let remote_manifest = - DeploymentManifest::load_from_remote(provider, world_address).await.unwrap(); + + let remote_manifest = config.tokio_handle().block_on(async { + DeploymentManifest::load_from_remote(provider, world_address).await.unwrap() + }); assert_eq!(local_manifest.models.len(), 4); assert_eq!(local_manifest.contracts.len(), 1); diff --git a/crates/dojo-world/src/metadata_test.rs b/crates/dojo-world/src/metadata_test.rs index 5a9b5ea7bd..ec48befb6f 100644 --- a/crates/dojo-world/src/metadata_test.rs +++ b/crates/dojo-world/src/metadata_test.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use camino::Utf8PathBuf; -use dojo_test_utils::compiler::build_full_test_config; +use dojo_test_utils::compiler; use scarb::ops; use url::Url; @@ -111,7 +111,7 @@ website = "https://dojoengine.org" #[tokio::test] async fn get_full_dojo_metadata_from_workspace() { - let config = build_full_test_config("../../examples/spawn-and-move/Scarb.toml", false).unwrap(); + let config = compiler::build_test_config("../../examples/spawn-and-move/Scarb.toml").unwrap(); let ws = ops::read_workspace(config.manifest_path(), &config) .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); @@ -147,7 +147,7 @@ async fn get_full_dojo_metadata_from_workspace() { assert!( env.world_address .unwrap() - .eq("0x1385f25d20a724edc9c7b3bd9636c59af64cbaf9fcd12f33b3af96b2452f295") + .eq("0x3898144a24151443f0c6501a1de46a6e9e27abd9fb5d08cdeeff5a5127d1d25") ); assert!(env.keystore_path.is_none()); diff --git a/crates/dojo-world/src/migration/mod.rs b/crates/dojo-world/src/migration/mod.rs index 2eb5df13d0..2c9a4b2938 100644 --- a/crates/dojo-world/src/migration/mod.rs +++ b/crates/dojo-world/src/migration/mod.rs @@ -4,8 +4,8 @@ use std::sync::Arc; use anyhow::{anyhow, Result}; use async_trait::async_trait; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; -use cairo_lang_starknet::contract_class::ContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::contract_class::ContractClass; use starknet::accounts::{Account, AccountError, Call, ConnectedAccount, SingleOwnerAccount}; use starknet::core::types::contract::{CompiledClass, SierraClass}; use starknet::core::types::{ @@ -27,6 +27,13 @@ pub mod world; pub type DeclareOutput = DeclareTransactionResult; +// TODO: this was taken from the current network limit +// https://docs.starknet.io/documentation/tools/limits_and_triggers/. +// This constant is also used into `katana-primitives`, which common crate +// should expose this value to have it configurable. +// Or should we just accept any size here? +pub const MAX_BYTECODE_SIZE: usize = 81_290; + #[derive(Clone, Debug)] pub struct DeployOutput { pub transaction_hash: FieldElement, @@ -101,6 +108,12 @@ pub struct TxnConfig { pub max_fee_raw: Option, } +impl TxnConfig { + pub fn init_wait() -> Self { + Self { wait: true, ..Default::default() } + } +} + #[cfg_attr(not(target_arch = "wasm32"), async_trait)] #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] pub trait Declarable { @@ -362,7 +375,8 @@ pub fn read_class(artifact_path: &PathBuf) -> Result { fn get_compiled_class_hash(artifact_path: &PathBuf) -> Result { let file = File::open(artifact_path)?; let casm_contract_class: ContractClass = serde_json::from_reader(file)?; - let casm_contract = CasmContractClass::from_contract_class(casm_contract_class, true)?; + let casm_contract = + CasmContractClass::from_contract_class(casm_contract_class, true, MAX_BYTECODE_SIZE)?; let res = serde_json::to_string_pretty(&casm_contract)?; let compiled_class: CompiledClass = serde_json::from_str(&res)?; Ok(compiled_class.class_hash()?) diff --git a/crates/katana/contracts/messaging/README.md b/crates/katana/contracts/messaging/README.md index a86193d384..f98c0138e5 100644 --- a/crates/katana/contracts/messaging/README.md +++ b/crates/katana/contracts/messaging/README.md @@ -4,11 +4,12 @@ Please before starting, install: -- [scarb](https://docs.swmansion.com/scarb/) to build cairo contracts. -- [starkli](https://github.com/xJonathanLEI/starkli) to interact with Katana. -- [foundry](https://book.getfoundry.sh/getting-started/installation) to interact with Anvil. +- [scarb](https://docs.swmansion.com/scarb/) to build cairo contracts. +- [starkli](https://github.com/xJonathanLEI/starkli) to interact with Katana. +- [foundry](https://book.getfoundry.sh/getting-started/installation) to interact with Anvil. If it's the first time you run the example file, please install forge dependencies: + ```bash cd ~/dojo/crates/katana/core/contracts/messaging/solidity forge install @@ -38,8 +39,9 @@ To test this scenario, you can use the associated Makefiles. But the flow is the How to run the scripts: -- Start Anvil in a terminal. -- Start Katana in an other terminal on default port 5050 with the messaging configuration that is inside the: +- Start Anvil in a terminal. +- Start Katana in an other terminal on default port 5050 with the messaging configuration that is inside the: + ```bash # From installed katana. katana --messaging ~/dojo/crates/katana/contracts/messaging/anvil.messaging.json @@ -47,7 +49,8 @@ How to run the scripts: # Dev mode cargo run --bin katana -- --messaging ~/dojo/crates/katana/contracts/messaging/anvil.messaging.json ``` -- Open an other terminal and `cd ~/dojo/crates/katana/core/contracts/messaging`. + +- Open an other terminal and `cd ~/dojo/crates/katana/core/contracts/messaging`. Then you can then use pre-defined commands to interact with the contracts. If you change the code or addresses, you may want to edit the Makefile. But @@ -70,10 +73,13 @@ make -sC solidity/ send_msg selector_str=msg_handler_struct payload="[1,2]" # Send message L2 -> L1 to be manually consumed. make -sC cairo/ send_msg_value_l1 value=2 ``` + Then you've to wait the message to be sent to L1, Katana will display it: + ``` 2024-04-22T23:42:52.478200Z INFO messaging: Message sent to settlement layer. hash=0xb5c9a1d3b8eb1c9d37ee5ffdacf09560a68d0c9e53fa4b1cc91d967095bc4ac7 from_address=0x609f8e7a76b6cc36f3ff86f09f6e5fdd0e6320f117d817e4344c1bf9fac7d67 to_address=0xe7f1725e7734ce288f8367e1bb143e90bb3f0512 payload=0x2 ``` + ``` # Consume the messag previously sent. You can try to call it once and see the second one reverting. make -sC solidity/ consume_msg payload="[2]" @@ -98,9 +104,9 @@ You can also use the Makefile to setup the chains, but the flow is the following Then you can deploy `contract_1.cairo` to send/consume message and test the execution of smart contract function on Starknet from the appchain. - You can totally deploy `appchain_messaging.cairo` on Starknet to test. **Please be aware - this contract is not audited for now and only experimental without security considerations yet**. - Be sure you control who is able to send/execute messages to be safe. + You can totally deploy `appchain_messaging.cairo` on Starknet to test. **Please be aware + this contract is not audited for now and only experimental without security considerations yet**. + Be sure you control who is able to send/execute messages to be safe. 2. Starting Katana (2) to represent your appchain. On this Katana instance, you will deploy `contract_msg_starknet.cairo` contract. This contract can send/execute/receive message @@ -110,8 +116,9 @@ You can also use the Makefile to setup the chains, but the flow is the following How to run the scripts: -- Starts Katana (1) to simulate starknet on a new terminal with default port 5050. -- Starts Katana (2) for your appchain on a new terminal with port 6060 and the configuration for messaging: +- Starts Katana (1) to simulate starknet on a new terminal with default port 5050. +- Starts Katana (2) for your appchain on a new terminal with port 6060 and the configuration for messaging: + ```bash # From installed Katana. katana --messaging crates/katana/contracts/messaging/l3.messaging.json -p 6060` @@ -120,7 +127,7 @@ How to run the scripts: cargo run --bin katana --features "starknet-messaging" -- --messaging crates/katana/contracts/messaging/l3.messaging.json -p 6060 ``` -- Open an other terminal and `cd ~/dojo/crates/katana/core/contracts/messaging`. +- Open an other terminal and `cd ~/dojo/crates/katana/core/contracts/messaging`. Then you can then use pre-defined commands to interact with the contracts. If you change the code or addresses, you may want to edit the Makefile. But diff --git a/crates/katana/contracts/messaging/solidity/README.md b/crates/katana/contracts/messaging/solidity/README.md index 19084a9a64..931acc023f 100644 --- a/crates/katana/contracts/messaging/solidity/README.md +++ b/crates/katana/contracts/messaging/solidity/README.md @@ -27,4 +27,3 @@ using: ``` (code: 3, message: execution reverted: INVALID_MESSAGE_TO_CONSUME, data: Some(String("0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001a494e56414c49445f4d4553534147455f544f5f434f4e53554d45000000000000"))) ``` - diff --git a/crates/katana/docs/database.md b/crates/katana/docs/database.md index 96404850c7..7560d770a8 100644 --- a/crates/katana/docs/database.md +++ b/crates/katana/docs/database.md @@ -7,7 +7,7 @@ erDiagram Headers { KEY BlockNumber - VALUE Header + VALUE Header } BlockHashes { diff --git a/crates/katana/executor/Cargo.toml b/crates/katana/executor/Cargo.toml index dca77a1056..013739321c 100644 --- a/crates/katana/executor/Cargo.toml +++ b/crates/katana/executor/Cargo.toml @@ -22,13 +22,14 @@ tracing.workspace = true alloy-primitives.workspace = true # blockifier deps -blockifier = { git = "https://github.com/dojoengine/blockifier", rev = "d38b979", optional = true } +blockifier = { git = "https://github.com/dojoengine/blockifier", rev = "935292bb", features = [ "testing" ], optional = true } cairo-vm = { workspace = true, optional = true } -# starknet_in_rust deps -cairo-lang-sierra = { workspace = true, optional = true } -sir = { package = "starknet_in_rust", git = "https://github.com/dojoengine/starknet_in_rust.git", rev = "601a65e", optional = true } -starknet-types-core = { version = "0.0.9", optional = true } +# Disable SIR for now until they support Cairo 2.6.3 +# # starknet_in_rust deps +# cairo-lang-sierra = { workspace = true, optional = true } +# sir = { package = "starknet_in_rust", git = "https://github.com/dojoengine/starknet_in_rust.git", rev = "601a65e", optional = true } +# starknet-types-core = { version = "0.0.9", optional = true } [dev-dependencies] anyhow.workspace = true @@ -42,8 +43,7 @@ similar-asserts.workspace = true tokio.workspace = true [features] -default = [ "blockifier", "sir" ] - blockifier = [ "dep:blockifier", "dep:cairo-vm" ] +default = [ "blockifier" ] # native = [ "sir", "sir/cairo-native" ] -sir = [ "dep:sir", "dep:starknet-types-core" ] +# sir = [ "dep:sir", "dep:starknet-types-core" ] diff --git a/crates/katana/executor/README.md b/crates/katana/executor/README.md index 6533c5fdfa..eae619ec44 100644 --- a/crates/katana/executor/README.md +++ b/crates/katana/executor/README.md @@ -3,11 +3,11 @@ This crate provides a set of abstractions for performing transaction executions in Katana. It includes [implementations](./src/implementation/) for the different execution engines that Katana supports: 1. [blockifier](https://github.com/dojoengine/blockifier) by StarkWare -2. [starknet_in_rust](https://github.com/dojoengine/starknet_in_rust) by LambdaClass. +2. [starknet_in_rust](https://github.com/dojoengine/starknet_in_rust) by LambdaClass. -They are feature-gated under `blockifier` and `sir` features respectively and enabled by **default**. +They are feature-gated under `blockifier` and `sir` features respectively and enabled by **default**. -This crate also includes a [*noop*](./src/implementation/noop.rs) implementation for testing purposes. +This crate also includes a [_noop_](./src/implementation/noop.rs) implementation for testing purposes. ### Cairo Native support @@ -20,7 +20,7 @@ katana-executor = { .., features = [ "native" ] } and the following needs to be setup: -LLVM 17 needs to be installed and the `MLIR_SYS_170_PREFIX` and `TABLEGEN_170_PREFIX` environment variable needs to point to said installation. +LLVM 17 needs to be installed and the `MLIR_SYS_170_PREFIX` and `TABLEGEN_170_PREFIX` environment variable needs to point to said installation. In macOS, run @@ -37,5 +37,3 @@ export TABLEGEN_170_PREFIX=/opt/homebrew/opt/llvm@17 ``` and you're set. - - diff --git a/crates/katana/executor/src/implementation/blockifier/mod.rs b/crates/katana/executor/src/implementation/blockifier/mod.rs index cfa44c2f3c..842b5b77de 100644 --- a/crates/katana/executor/src/implementation/blockifier/mod.rs +++ b/crates/katana/executor/src/implementation/blockifier/mod.rs @@ -2,11 +2,14 @@ mod error; mod state; mod utils; -use blockifier::block_context::BlockContext; -use blockifier::state::cached_state::{self, MutRefState}; +use std::num::NonZeroU128; + +use blockifier::block::{BlockInfo, GasPrices}; +use blockifier::context::BlockContext; +use blockifier::state::cached_state::{self, GlobalContractCache, MutRefState}; use blockifier::state::state_api::StateReader; use blockifier::transaction::objects::TransactionExecutionInfo; -use katana_primitives::block::{ExecutableBlock, GasPrices, PartialHeader}; +use katana_primitives::block::{ExecutableBlock, GasPrices as KatanaGasPrices, PartialHeader}; use katana_primitives::env::{BlockEnv, CfgEnv}; use katana_primitives::fee::TxFeeInfo; use katana_primitives::transaction::{ExecutableTx, ExecutableTxWithHash, TxWithHash}; @@ -25,6 +28,12 @@ use crate::{ pub(crate) const LOG_TARGET: &str = "katana::executor::blockifier"; +// TODO: @kariy Which value should be considered here? I took the default +// value from the previous implementation. +// Previous: https://github.com/dojoengine/blockifier/blob/7459891173b64b148a7ce870c0b1d5907af15b8d/crates/blockifier/src/state/cached_state.rs#L731 +// New code: https://github.com/starkware-libs/blockifier/blob/a6200402ab635d8a8e175f7f135be5914c960007/crates/blockifier/src/state/global_cache.rs#L17C11-L17C46 +pub(crate) const CACHE_SIZE: usize = 100; + #[derive(Debug)] pub struct BlockifierFactory { cfg: CfgEnv, @@ -88,15 +97,36 @@ impl<'a> StarknetVMProcessor<'a> { fn fill_block_env_from_header(&mut self, header: &PartialHeader) { let number = BlockNumber(header.number); let timestamp = BlockTimestamp(header.timestamp); - let eth_l1_gas_price = header.gas_prices.eth; - let strk_l1_gas_price = header.gas_prices.strk; - - self.block_context.block_info.block_number = number; - self.block_context.block_info.block_timestamp = timestamp; - self.block_context.block_info.gas_prices.eth_l1_gas_price = eth_l1_gas_price; - self.block_context.block_info.gas_prices.strk_l1_gas_price = strk_l1_gas_price; - self.block_context.block_info.sequencer_address = - utils::to_blk_address(header.sequencer_address); + + // TODO: should we enforce the gas price to not be 0, + // as there's a flag to disable gas uasge instead? + let eth_l1_gas_price = unsafe { NonZeroU128::new_unchecked(header.gas_prices.eth) }; + let strk_l1_gas_price = unsafe { NonZeroU128::new_unchecked(header.gas_prices.strk) }; + + // TODO: which values is correct for those one? + let eth_l1_data_gas_price = eth_l1_gas_price; + let strk_l1_data_gas_price = strk_l1_gas_price; + + // TODO: @kariy, not sure here if we should add some functions to alter it + // instead of cloning. Or did I miss a function? + // https://github.com/starkware-libs/blockifier/blob/a6200402ab635d8a8e175f7f135be5914c960007/crates/blockifier/src/context.rs#L23 + let versioned_constants = self.block_context.versioned_constants(); + let chain_info = self.block_context.chain_info(); + let block_info = BlockInfo { + block_number: number, + block_timestamp: timestamp, + sequencer_address: utils::to_blk_address(header.sequencer_address), + gas_prices: GasPrices { + eth_l1_gas_price, + strk_l1_gas_price, + eth_l1_data_gas_price, + strk_l1_data_gas_price, + }, + use_kzg_da: false, + }; + + self.block_context = + BlockContext::new_unchecked(&block_info, chain_info, versioned_constants); } fn simulate_with( @@ -113,7 +143,10 @@ impl<'a> StarknetVMProcessor<'a> { { let block_context = &self.block_context; let state = &mut self.state.0.write().inner; - let mut state = cached_state::CachedState::new(MutRefState::new(state), Default::default()); + let mut state = cached_state::CachedState::new( + MutRefState::new(state), + GlobalContractCache::new(CACHE_SIZE), + ); let mut results = Vec::with_capacity(transactions.len()); for exec_tx in transactions { @@ -204,13 +237,16 @@ impl<'a> BlockExecutor<'a> for StarknetVMProcessor<'a> { } fn block_env(&self) -> BlockEnv { + let eth_l1_gas_price = self.block_context.block_info().gas_prices.eth_l1_gas_price; + let strk_l1_gas_price = self.block_context.block_info().gas_prices.strk_l1_gas_price; + BlockEnv { - number: self.block_context.block_info.block_number.0, - timestamp: self.block_context.block_info.block_timestamp.0, - sequencer_address: utils::to_address(self.block_context.block_info.sequencer_address), - l1_gas_prices: GasPrices { - eth: self.block_context.block_info.gas_prices.eth_l1_gas_price, - strk: self.block_context.block_info.gas_prices.strk_l1_gas_price, + number: self.block_context.block_info().block_number.0, + timestamp: self.block_context.block_info().block_timestamp.0, + sequencer_address: utils::to_address(self.block_context.block_info().sequencer_address), + l1_gas_prices: KatanaGasPrices { + eth: eth_l1_gas_price.into(), + strk: strk_l1_gas_price.into(), }, } } diff --git a/crates/katana/executor/src/implementation/blockifier/state.rs b/crates/katana/executor/src/implementation/blockifier/state.rs index 79305b12e6..c6d7f27572 100644 --- a/crates/katana/executor/src/implementation/blockifier/state.rs +++ b/crates/katana/executor/src/implementation/blockifier/state.rs @@ -17,6 +17,7 @@ use starknet_api::patricia_key; use starknet_api::state::StorageKey; use super::utils::{self}; +use super::CACHE_SIZE; use crate::StateProviderDb; /// A helper trait to enforce that a type must implement both [StateProvider] and [StateReader]. @@ -62,7 +63,7 @@ impl<'a> StateReader for StateProviderDb<'a> { let class = utils::to_class(class).map_err(|e| StateError::StateReadError(e.to_string()))?; - Ok(class) + Ok(class.contract_class()) } else { Err(StateError::UndeclaredClassHash(class_hash)) } @@ -109,7 +110,8 @@ pub(super) struct CachedStateInner { impl CachedState { pub(super) fn new(state: S) -> Self { let declared_classes = HashMap::new(); - let cached_state = cached_state::CachedState::new(state, GlobalContractCache::default()); + let cached_state = + cached_state::CachedState::new(state, GlobalContractCache::new(CACHE_SIZE)); let inner = CachedStateInner { inner: cached_state, declared_classes }; Self(Arc::new(RwLock::new(inner))) } @@ -319,11 +321,11 @@ mod tests { assert_eq!(actual_compiled_hash.0, felt!("0x456").into()); assert_eq!( actual_class, - utils::to_class(DEFAULT_OZ_ACCOUNT_CONTRACT_CASM.clone()).unwrap() + utils::to_class(DEFAULT_OZ_ACCOUNT_CONTRACT_CASM.clone()).unwrap().contract_class() ); assert_eq!( actual_legacy_class, - utils::to_class(DEFAULT_LEGACY_ERC20_CONTRACT_CASM.clone()).unwrap() + utils::to_class(DEFAULT_LEGACY_ERC20_CONTRACT_CASM.clone()).unwrap().contract_class() ); Ok(()) @@ -379,10 +381,12 @@ mod tests { let storage_key = StorageKey(patricia_key!(new_storage_key)); let storage_value = new_storage_value.into(); let class_hash = ClassHash(new_class_hash.into()); - let class = utils::to_class(new_compiled_sierra_class.clone()).unwrap(); + let class = + utils::to_class(new_compiled_sierra_class.clone()).unwrap().contract_class(); let compiled_hash = CompiledClassHash(new_compiled_hash.into()); let legacy_class_hash = ClassHash(new_legacy_class_hash.into()); - let legacy_class = utils::to_class(DEFAULT_LEGACY_UDC_CASM.clone()).unwrap(); + let legacy_class = + utils::to_class(DEFAULT_LEGACY_UDC_CASM.clone()).unwrap().contract_class(); let legacy_compiled_hash = CompiledClassHash(new_legacy_compiled_hash.into()); blk_state.increment_nonce(address)?; diff --git a/crates/katana/executor/src/implementation/blockifier/utils.rs b/crates/katana/executor/src/implementation/blockifier/utils.rs index 21bae0ac89..f8f7aed194 100644 --- a/crates/katana/executor/src/implementation/blockifier/utils.rs +++ b/crates/katana/executor/src/implementation/blockifier/utils.rs @@ -1,29 +1,33 @@ use std::collections::{BTreeMap, HashMap}; +use std::num::NonZeroU128; use std::sync::Arc; -use blockifier::block_context::{BlockContext, BlockInfo, ChainInfo, FeeTokenAddresses, GasPrices}; +use blockifier::block::{BlockInfo, GasPrices}; +use blockifier::context::{BlockContext, ChainInfo, FeeTokenAddresses, TransactionContext}; use blockifier::execution::call_info::{ CallExecution, CallInfo, OrderedEvent, OrderedL2ToL1Message, }; use blockifier::execution::common_hints::ExecutionMode; -use blockifier::execution::contract_class::{ContractClass, ContractClassV0, ContractClassV1}; -use blockifier::execution::entry_point::{ - CallEntryPoint, CallType, EntryPointExecutionContext, ExecutionResources, +use blockifier::execution::contract_class::{ + ClassInfo, ContractClass, ContractClassV0, ContractClassV1, }; -use blockifier::fee::fee_utils::{calculate_tx_fee, calculate_tx_l1_gas_usages}; -use blockifier::state::cached_state::{self}; +use blockifier::execution::entry_point::{CallEntryPoint, CallType, EntryPointExecutionContext}; +use blockifier::fee::fee_utils::{calculate_tx_fee, calculate_tx_gas_vector}; +use blockifier::state::cached_state::{self, GlobalContractCache}; use blockifier::state::state_api::{State, StateReader}; use blockifier::transaction::account_transaction::AccountTransaction; use blockifier::transaction::objects::{ - AccountTransactionContext, DeprecatedAccountTransactionContext, FeeType, HasRelatedFeeType, - TransactionExecutionInfo, + DeprecatedTransactionInfo, FeeType, HasRelatedFeeType, TransactionExecutionInfo, + TransactionInfo, }; use blockifier::transaction::transaction_execution::Transaction; use blockifier::transaction::transactions::{ DeclareTransaction, DeployAccountTransaction, ExecutableTransaction, InvokeTransaction, L1HandlerTransaction, }; +use blockifier::versioned_constants::VersionedConstants; use cairo_vm::types::errors::program_errors::ProgramError; +use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use katana_primitives::env::{BlockEnv, CfgEnv}; use katana_primitives::fee::TxFeeInfo; use katana_primitives::state::{StateUpdates, StateUpdatesWithDeclaredClasses}; @@ -31,7 +35,7 @@ use katana_primitives::trace::TxExecInfo; use katana_primitives::transaction::{ DeclareTx, DeployAccountTx, ExecutableTx, ExecutableTxWithHash, InvokeTx, }; -use katana_primitives::{event, message, trace, FieldElement}; +use katana_primitives::{class, event, message, trace, FieldElement}; use katana_provider::traits::contract::ContractClassProvider; use starknet::core::types::PriceUnit; use starknet::core::utils::parse_cairo_short_string; @@ -53,6 +57,7 @@ use starknet_api::transaction::{ }; use super::state::{CachedState, StateDb}; +use super::CACHE_SIZE; use crate::abstraction::{EntryPointCall, SimulationFlag}; use crate::ExecutionError; @@ -87,14 +92,16 @@ pub(super) fn transact( info.actual_fee.0 }; - let gas_consumed = calculate_tx_l1_gas_usages(&info.actual_resources, block_context)?.gas_usage; + let gas_consumed = + calculate_tx_gas_vector(&info.actual_resources, block_context.versioned_constants())? + .l1_gas; let (unit, gas_price) = match fee_type { - FeeType::Eth => (PriceUnit::Wei, block_context.block_info.gas_prices.eth_l1_gas_price), - FeeType::Strk => (PriceUnit::Fri, block_context.block_info.gas_prices.strk_l1_gas_price), + FeeType::Eth => (PriceUnit::Wei, block_context.block_info().gas_prices.eth_l1_gas_price), + FeeType::Strk => (PriceUnit::Fri, block_context.block_info().gas_prices.strk_l1_gas_price), }; - let fee = TxFeeInfo { gas_consumed, gas_price, unit, overall_fee }; + let fee = TxFeeInfo { gas_consumed, gas_price: gas_price.into(), unit, overall_fee }; Ok((info, fee)) } @@ -105,7 +112,7 @@ pub fn call( block_context: &BlockContext, initial_gas: u128, ) -> Result, ExecutionError> { - let mut state = cached_state::CachedState::new(state, Default::default()); + let mut state = cached_state::CachedState::new(state, GlobalContractCache::new(CACHE_SIZE)); let call = CallEntryPoint { initial_gas: initial_gas as u64, @@ -120,17 +127,20 @@ pub fn call( // Now, the max step is not given directly to this function. // It's computed by a new function max_steps, and it tooks the values - // from teh block context itself instead of the input give. - // https://github.com/starkware-libs/blockifier/blob/51b343fe38139a309a69b2482f4b484e8caa5edf/crates/blockifier/src/execution/entry_point.rs#L165 - // The blockifier patch must be adjusted to modify this function to return - // the limit we have into the block context without min applied: - // https://github.com/starkware-libs/blockifier/blob/51b343fe38139a309a69b2482f4b484e8caa5edf/crates/blockifier/src/execution/entry_point.rs#L215 + // from the block context itself instead of the input give. The dojoengine + // fork of the blockifier ensures we're not limited by the min function applied + // by starkware. + // https://github.com/starkware-libs/blockifier/blob/4fd71645b45fd1deb6b8e44802414774ec2a2ec1/crates/blockifier/src/execution/entry_point.rs#L159 + // https://github.com/dojoengine/blockifier/blob/5f58be8961ddf84022dd739a8ab254e32c435075/crates/blockifier/src/execution/entry_point.rs#L188 + let res = call.execute( &mut state, &mut ExecutionResources::default(), &mut EntryPointExecutionContext::new( - block_context, - &AccountTransactionContext::Deprecated(DeprecatedAccountTransactionContext::default()), + Arc::new(TransactionContext { + block_context: block_context.clone(), + tx_info: TransactionInfo::Deprecated(DeprecatedTransactionInfo::default()), + }), ExecutionMode::Execute, limit_steps_by_resources, ) @@ -332,27 +342,34 @@ pub(crate) fn block_context_from_envs(block_env: &BlockEnv, cfg_env: &CfgEnv) -> strk_fee_token_address: to_blk_address(cfg_env.fee_token_addresses.strk), }; + let eth_l1_gas_price = unsafe { NonZeroU128::new_unchecked(block_env.l1_gas_prices.eth) }; + let strk_l1_gas_price = unsafe { NonZeroU128::new_unchecked(block_env.l1_gas_prices.strk) }; + let gas_prices = GasPrices { - eth_l1_gas_price: block_env.l1_gas_prices.eth, - strk_l1_gas_price: block_env.l1_gas_prices.strk, - eth_l1_data_gas_price: 0, - strk_l1_data_gas_price: 0, + eth_l1_gas_price, + strk_l1_gas_price, + // TODO: should those be the same value? + eth_l1_data_gas_price: eth_l1_gas_price, + strk_l1_data_gas_price: strk_l1_gas_price, }; - BlockContext { - block_info: BlockInfo { - gas_prices, - use_kzg_da: false, - block_number: BlockNumber(block_env.number), - block_timestamp: BlockTimestamp(block_env.timestamp), - sequencer_address: to_blk_address(block_env.sequencer_address), - max_recursion_depth: cfg_env.max_recursion_depth, - validate_max_n_steps: cfg_env.validate_max_n_steps, - invoke_tx_max_n_steps: cfg_env.invoke_tx_max_n_steps, - vm_resource_fee_cost: cfg_env.vm_resource_fee_cost.clone().into(), - }, - chain_info: ChainInfo { fee_token_addresses, chain_id: to_blk_chain_id(cfg_env.chain_id) }, - } + let block_info = BlockInfo { + block_number: BlockNumber(block_env.number), + block_timestamp: BlockTimestamp(block_env.timestamp), + sequencer_address: to_blk_address(block_env.sequencer_address), + gas_prices, + use_kzg_da: false, + }; + + let chain_info = ChainInfo { fee_token_addresses, chain_id: to_blk_chain_id(cfg_env.chain_id) }; + + let mut versioned_constants = VersionedConstants::latest_constants().clone(); + versioned_constants.max_recursion_depth = cfg_env.max_recursion_depth; + versioned_constants.validate_max_n_steps = cfg_env.validate_max_n_steps; + versioned_constants.invoke_tx_max_n_steps = cfg_env.invoke_tx_max_n_steps; + versioned_constants.vm_resource_fee_cost = cfg_env.vm_resource_fee_cost.clone().into(); + + BlockContext::new_unchecked(&block_info, &chain_info, &versioned_constants) } pub(super) fn state_update_from_cached_state( @@ -489,15 +506,25 @@ pub fn to_blk_chain_id(chain_id: katana_primitives::chain::ChainId) -> ChainId { } } -pub fn to_class( - class: katana_primitives::class::CompiledClass, -) -> Result { +pub fn to_class(class: class::CompiledClass) -> Result { + // TODO: @kariy not sure of the variant that must be used in this case. Should we change the + // return type to include this case of error for contract class conversions? match class { - katana_primitives::class::CompiledClass::Deprecated(class) => { - Ok(ContractClass::V0(ContractClassV0::try_from(class)?)) + class::CompiledClass::Deprecated(class) => { + // For cairo 0, the sierra_program_length must be 0. + Ok(ClassInfo::new(&ContractClass::V0(ContractClassV0::try_from(class)?), 0, 0) + .map_err(|e| ProgramError::ConstWithoutValue(format!("{e}")))?) } - katana_primitives::class::CompiledClass::Class(class) => { - Ok(ContractClass::V1(ContractClassV1::try_from(class.casm)?)) + + class::CompiledClass::Class(class) => { + let sierra_program_len = class.sierra.program.statements.len(); + // TODO: @kariy not sure from where the ABI length can be grasped. + Ok(ClassInfo::new( + &ContractClass::V1(ContractClassV1::try_from(class.casm)?), + sierra_program_len, + 0, + ) + .map_err(|e| ProgramError::ConstWithoutValue(format!("{e}")))?) } } } @@ -536,10 +563,10 @@ fn to_call_info(call: CallInfo) -> trace::CallInfo { let calldata = call.call.calldata.0.iter().map(|f| (*f).into()).collect(); let retdata = call.execution.retdata.0.into_iter().map(|f| f.into()).collect(); - let builtin_counter = call.vm_resources.builtin_instance_counter; + let builtin_counter = call.resources.builtin_instance_counter; let execution_resources = trace::ExecutionResources { - n_steps: call.vm_resources.n_steps as u64, - n_memory_holes: call.vm_resources.n_memory_holes as u64, + n_steps: call.resources.n_steps as u64, + n_memory_holes: call.resources.n_memory_holes as u64, builtin_instance_counter: builtin_counter.into_iter().map(|(k, v)| (k, v as u64)).collect(), }; @@ -678,7 +705,7 @@ mod tests { }, storage_read_values: vec![stark_felt!(1_u8), stark_felt!(2_u8)], accessed_storage_keys: HashSet::from([3u128.into(), 4u128.into(), 5u128.into()]), - vm_resources: ExecutionResources { + resources: ExecutionResources { n_steps: 1_000_000, n_memory_holes: 9_000, builtin_instance_counter: HashMap::from([ @@ -705,10 +732,10 @@ mod tests { let expected_retdata: Vec = call.execution.retdata.0.iter().map(|f| (*f).into()).collect(); - let builtin_counter = call.vm_resources.builtin_instance_counter.clone(); + let builtin_counter = call.resources.builtin_instance_counter.clone(); let expected_execution_resources = trace::ExecutionResources { - n_steps: call.vm_resources.n_steps as u64, - n_memory_holes: call.vm_resources.n_memory_holes as u64, + n_steps: call.resources.n_steps as u64, + n_memory_holes: call.resources.n_memory_holes as u64, builtin_instance_counter: builtin_counter .into_iter() .map(|(k, v)| (k, v as u64)) diff --git a/crates/katana/executor/src/implementation/mod.rs b/crates/katana/executor/src/implementation/mod.rs index 3e4f93f2b9..48db83e370 100644 --- a/crates/katana/executor/src/implementation/mod.rs +++ b/crates/katana/executor/src/implementation/mod.rs @@ -1,7 +1,7 @@ #[cfg(feature = "blockifier")] pub mod blockifier; -#[cfg(feature = "sir")] -pub mod sir; +// #[cfg(feature = "sir")] +// pub mod sir; pub mod noop; diff --git a/crates/katana/executor/tests/executor.rs b/crates/katana/executor/tests/executor.rs index 3d64cf2393..b35c9ae409 100644 --- a/crates/katana/executor/tests/executor.rs +++ b/crates/katana/executor/tests/executor.rs @@ -3,7 +3,7 @@ mod fixtures; use std::collections::HashMap; use fixtures::{state_provider, valid_blocks}; -use katana_executor::{ExecutionOutput, ExecutorFactory}; +use katana_executor::{ExecutionOutput, ExecutionResult, ExecutorFactory}; use katana_primitives::block::ExecutableBlock; use katana_primitives::contract::ContractAddress; use katana_primitives::genesis::constant::{ @@ -53,6 +53,15 @@ fn test_executor_with_valid_blocks_impl( let transactions = executor.transactions(); assert_eq!(transactions.len(), 2, "2 transactions were executed"); + // ensure that all transactions succeeded, if not panic with the error message and tx index + let has_failed = transactions.iter().enumerate().find_map(|(i, (_, res))| { + if let ExecutionResult::Failed { error } = res { Some((i, error)) } else { None } + }); + + if let Some((pos, error)) = has_failed { + panic!("transaction at index {pos} failed: {error}"); + } + // asserts that the states are updated correctly after executing the 1st block let state_provider = executor.state(); diff --git a/crates/katana/executor/tests/fixtures/mod.rs b/crates/katana/executor/tests/fixtures/mod.rs index d11bf0e1ff..67a4871fea 100644 --- a/crates/katana/executor/tests/fixtures/mod.rs +++ b/crates/katana/executor/tests/fixtures/mod.rs @@ -137,7 +137,7 @@ pub fn valid_blocks() -> [ExecutableBlock; 3] { sierra_class: Some(sierra), transaction: DeclareTx::V2(DeclareTxV2 { nonce: FieldElement::ONE, - max_fee: 982300000000000, + max_fee: 1503400000000000, chain_id, signature: vec![], sender_address, diff --git a/crates/katana/primitives/Cargo.toml b/crates/katana/primitives/Cargo.toml index d09ce22a75..5d8b67f8df 100644 --- a/crates/katana/primitives/Cargo.toml +++ b/crates/katana/primitives/Cargo.toml @@ -26,6 +26,7 @@ thiserror.workspace = true alloy-primitives.workspace = true cairo-lang-sierra.workspace = true cairo-lang-starknet.workspace = true +cairo-lang-starknet-classes.workspace = true flate2.workspace = true starknet_api.workspace = true diff --git a/crates/katana/primitives/src/class.rs b/crates/katana/primitives/src/class.rs index 610b58c3c6..58d54c182e 100644 --- a/crates/katana/primitives/src/class.rs +++ b/crates/katana/primitives/src/class.rs @@ -1,4 +1,4 @@ -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use crate::FieldElement; @@ -18,7 +18,7 @@ pub type DeprecatedCompiledClass = ::starknet_api::deprecated_contract_class::Co #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SierraProgram { pub program: cairo_lang_sierra::program::Program, - pub entry_points_by_type: cairo_lang_starknet::contract_class::ContractEntryPoints, + pub entry_points_by_type: cairo_lang_starknet_classes::contract_class::ContractEntryPoints, } #[derive(Debug, Clone, Eq, PartialEq)] diff --git a/crates/katana/primitives/src/conversion/rpc.rs b/crates/katana/primitives/src/conversion/rpc.rs index 2b27cd2b7e..3713386146 100644 --- a/crates/katana/primitives/src/conversion/rpc.rs +++ b/crates/katana/primitives/src/conversion/rpc.rs @@ -3,7 +3,7 @@ use std::io::{self, Read, Write}; use std::mem; use anyhow::{Context, Result}; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use serde::Deserialize; use serde_json::json; use serde_with::serde_as; @@ -27,6 +27,7 @@ use crate::class::{ ClassHash, CompiledClassHash, DeprecatedCompiledClass, FlattenedSierraClass, SierraCompiledClass, SierraProgram, }; +use crate::utils::class::MAX_BYTECODE_SIZE; use crate::FieldElement; /// Converts the legacy inner compiled class type [DeprecatedCompiledClass] into its RPC equivalent @@ -148,7 +149,7 @@ pub fn flattened_sierra_to_compiled_class( let entry_points_by_type = class.entry_points_by_type.clone(); let sierra = SierraProgram { program, entry_points_by_type }; - let casm = CasmContractClass::from_contract_class(class, true)?; + let casm = CasmContractClass::from_contract_class(class, true, MAX_BYTECODE_SIZE)?; let compiled_hash = FieldElement::from_bytes_be(&casm.compiled_class_hash().to_be_bytes())?; let class = crate::class::CompiledClass::Class(SierraCompiledClass { casm, sierra }); @@ -160,7 +161,7 @@ pub fn compiled_class_hash_from_flattened_sierra_class( contract_class: &FlattenedSierraClass, ) -> Result { let contract_class = rpc_to_cairo_contract_class(contract_class)?; - let casm = CasmContractClass::from_contract_class(contract_class, true)?; + let casm = CasmContractClass::from_contract_class(contract_class, true, MAX_BYTECODE_SIZE)?; let compiled_class: CompiledClass = serde_json::from_str(&serde_json::to_string(&casm)?)?; Ok(compiled_class.class_hash()?) } @@ -186,10 +187,10 @@ pub fn legacy_rpc_to_compiled_class( /// [ContractClass](cairo_lang_starknet::contract_class::ContractClass) type. fn rpc_to_cairo_contract_class( contract_class: &FlattenedSierraClass, -) -> Result { +) -> Result { let value = serde_json::to_value(contract_class)?; - Ok(cairo_lang_starknet::contract_class::ContractClass { + Ok(cairo_lang_starknet_classes::contract_class::ContractClass { abi: serde_json::from_value(value["abi"].clone()).ok(), sierra_program: serde_json::from_value(value["sierra_program"].clone())?, entry_points_by_type: serde_json::from_value(value["entry_points_by_type"].clone())?, diff --git a/crates/katana/primitives/src/genesis/json.rs b/crates/katana/primitives/src/genesis/json.rs index 84a97e101e..102020e7c9 100644 --- a/crates/katana/primitives/src/genesis/json.rs +++ b/crates/katana/primitives/src/genesis/json.rs @@ -12,7 +12,7 @@ use std::sync::Arc; use alloy_primitives::U256; use base64::prelude::*; -use cairo_lang_starknet::casm_contract_class::StarknetSierraCompilationError; +use cairo_lang_starknet_classes::casm_contract_class::StarknetSierraCompilationError; use cairo_vm::types::errors::program_errors::ProgramError; use rayon::prelude::*; use serde::de::value::MapAccessDeserializer; diff --git a/crates/katana/primitives/src/utils/class.rs b/crates/katana/primitives/src/utils/class.rs index de2d83e10f..b195d34af5 100644 --- a/crates/katana/primitives/src/utils/class.rs +++ b/crates/katana/primitives/src/utils/class.rs @@ -1,12 +1,19 @@ use anyhow::Result; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; -use cairo_lang_starknet::contract_class::ContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::contract_class::ContractClass; use serde_json::Value; use crate::class::{ CompiledClass, DeprecatedCompiledClass, SierraClass, SierraCompiledClass, SierraProgram, }; +// TODO: this was taken from the current network limit +// https://docs.starknet.io/documentation/tools/limits_and_triggers/. +// We may want to make this configurable. +// We also need this value into `dojo-world`.. which is not ideal as we don't want +// primitives to depend on `dojo-world` or vice-versa. +pub const MAX_BYTECODE_SIZE: usize = 81_290; + pub fn parse_compiled_class(artifact: Value) -> Result { if let Ok(class) = parse_compiled_class_v1(artifact.clone()) { Ok(CompiledClass::Class(class)) @@ -22,7 +29,7 @@ pub fn parse_compiled_class_v1(class: Value) -> Result { let entry_points_by_type = class.entry_points_by_type.clone(); let sierra = SierraProgram { program, entry_points_by_type }; - let casm = CasmContractClass::from_contract_class(class, true)?; + let casm = CasmContractClass::from_contract_class(class, true, MAX_BYTECODE_SIZE)?; Ok(SierraCompiledClass { casm, sierra }) } diff --git a/crates/katana/rpc/rpc/Cargo.toml b/crates/katana/rpc/rpc/Cargo.toml index 1cf0531841..0ffc37bd24 100644 --- a/crates/katana/rpc/rpc/Cargo.toml +++ b/crates/katana/rpc/rpc/Cargo.toml @@ -38,6 +38,7 @@ tracing.workspace = true [dev-dependencies] assert_matches = "1.5.0" cairo-lang-starknet.workspace = true +cairo-lang-starknet-classes.workspace = true dojo-test-utils.workspace = true jsonrpsee = { workspace = true, features = [ "client" ] } katana-rpc-api = { workspace = true, features = [ "client" ] } diff --git a/crates/katana/rpc/rpc/tests/common/mod.rs b/crates/katana/rpc/rpc/tests/common/mod.rs index 321cb8b0ee..52d78f4e67 100644 --- a/crates/katana/rpc/rpc/tests/common/mod.rs +++ b/crates/katana/rpc/rpc/tests/common/mod.rs @@ -2,9 +2,10 @@ use std::fs::File; use std::path::PathBuf; use anyhow::{anyhow, Result}; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; -use cairo_lang_starknet::contract_class::ContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::contract_class::ContractClass; use katana_primitives::conversion::rpc::CompiledClass; +use katana_primitives::utils::class::MAX_BYTECODE_SIZE; use starknet::accounts::Call; use starknet::core::types::contract::SierraClass; use starknet::core::types::{FieldElement, FlattenedSierraClass}; @@ -29,8 +30,9 @@ fn get_flattened_class(artifact_path: &PathBuf) -> Result fn get_compiled_class_hash(artifact_path: &PathBuf) -> Result { let file = File::open(artifact_path)?; let casm_contract_class: ContractClass = serde_json::from_reader(file)?; - let casm_contract = CasmContractClass::from_contract_class(casm_contract_class, true) - .map_err(|e| anyhow!("CasmContractClass from ContractClass error: {e}"))?; + let casm_contract = + CasmContractClass::from_contract_class(casm_contract_class, true, MAX_BYTECODE_SIZE) + .map_err(|e| anyhow!("CasmContractClass from ContractClass error: {e}"))?; let res = serde_json::to_string_pretty(&casm_contract)?; let compiled_class: CompiledClass = serde_json::from_str(&res)?; Ok(compiled_class.class_hash()?) diff --git a/crates/katana/runner/Cargo.toml b/crates/katana/runner/Cargo.toml index 687955bd68..f89597d378 100644 --- a/crates/katana/runner/Cargo.toml +++ b/crates/katana/runner/Cargo.toml @@ -6,6 +6,7 @@ version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +assert_fs = "1.0.9" runner-macro = { path = "./runner-macro" } katana-core.workspace = true katana-primitives.workspace = true diff --git a/crates/katana/runner/runner-macro/src/lib.rs b/crates/katana/runner/runner-macro/src/lib.rs index 0887924b95..77867a284f 100644 --- a/crates/katana/runner/runner-macro/src/lib.rs +++ b/crates/katana/runner/runner-macro/src/lib.rs @@ -2,20 +2,52 @@ use proc_macro::TokenStream; use quote::quote; use syn::{parse_macro_input, parse_quote, Stmt}; -fn parse_metadata(metadata: String) -> (u16, String, bool) { +/// Default runner block interval +const DEFAULT_BLOCK_TIME: u64 = 3000; // 3 seconds + +/// Parses the metadata string into the number of accounts and the block time. +/// +/// # Arguments +/// +/// * `metadata` - The metadata string to parse. The string is expected to be in the format of +/// `n_accounts,executable,block_time` where `block_time` is either a number (time block is ms) or +/// a boolean with `false` to use instand mining, and `true` to use the default block time. +/// +/// # Returns +/// +/// A tuple containing the number of accounts, the path to the katana program and the block time. +fn parse_metadata(metadata: String) -> (u16, Option, Option) { if metadata.is_empty() { - return (2, "katana".into(), false); + return (2, None, None); } + let args = metadata.split(',').collect::>(); let n_accounts = if !args.is_empty() { args[0].parse::().unwrap() } else { 1 }; - let with_blocks = if args.len() >= 2 { args[1].trim().parse::().unwrap() } else { false }; + // Block time can be `false` to be `None`, or a number to be `Some(block_time_ms)`. + // if set to `true`, we use a default block time. + let block_time = if args.len() >= 2 { + if let Ok(b) = args[1].trim().parse::() { + if !b { None } else { Some(DEFAULT_BLOCK_TIME) } + } else if let Ok(block_time_ms) = args[1].trim().parse::() { + Some(block_time_ms) + } else { + None + } + } else { + None + }; + + let executable = if args.len() >= 3 { + args[2].trim() + } else { + return (2, None, None); + }; - let executable = if args.len() >= 3 { args[2].trim() } else { "katana" }; let executable = executable.replace('"', ""); // plus one as the first account is used for deployment - (n_accounts + 1, executable, with_blocks) + (n_accounts + 1, Some(executable), block_time) } #[proc_macro_attribute] @@ -23,11 +55,23 @@ pub fn katana_test(metadata: TokenStream, input: TokenStream) -> TokenStream { let mut test_function = parse_macro_input!(input as syn::ItemFn); let function_name = test_function.sig.ident.to_string(); - let (n_accounts, executable, with_blocks) = parse_metadata(metadata.to_string()); + let (n_accounts, executable, block_time) = parse_metadata(metadata.to_string()); + + let block_time = block_time.map(|b| quote!(Some(#b))).unwrap_or(quote!(None)); + + let program_name = executable.map(|b| quote!(Some(String::from(#b)))).unwrap_or(quote!(None)); let header: Stmt = parse_quote! { let runner = - katana_runner::KatanaRunner::new_with_args(#executable, #function_name, #n_accounts, #with_blocks) + katana_runner::KatanaRunner::new_with_config( + katana_runner::KatanaRunnerConfig { + program_name: #program_name, + run_name: Some(String::from(#function_name)), + block_time: #block_time, + n_accounts: #n_accounts, + ..Default::default() + } + ) .expect("failed to start katana"); }; @@ -52,11 +96,24 @@ pub fn runner(metadata: TokenStream) -> TokenStream { let mut args = metadata.split(',').collect::>(); let function_name = args.remove(0); - let (n_accounts, executable, with_blocks) = parse_metadata(args.join(",")); + let (n_accounts, executable, block_time) = parse_metadata(args.join(",")); + + let block_time = block_time.map(|b| quote!(Some(#b))).unwrap_or(quote!(None)); + + let program_name = executable.map(|b| quote!(Some(String::from(#b)))).unwrap_or(quote!(None)); + TokenStream::from(quote! { lazy_static::lazy_static! { pub static ref RUNNER: std::sync::Arc = std::sync::Arc::new( - katana_runner::KatanaRunner::new_with_args(#executable, #function_name, #n_accounts, #with_blocks) + katana_runner::KatanaRunner::new_with_config( + katana_runner::KatanaRunnerConfig { + program_name: #program_name, + run_name: Some(String::from(#function_name)), + block_time: #block_time, + n_accounts: #n_accounts, + ..Default::default() + } + ) .expect("failed to start katana") ); diff --git a/crates/katana/runner/src/lib.rs b/crates/katana/runner/src/lib.rs index 72625147f9..13a19fe771 100644 --- a/crates/katana/runner/src/lib.rs +++ b/crates/katana/runner/src/lib.rs @@ -9,6 +9,7 @@ use std::thread; use std::time::Duration; use anyhow::{Context, Result}; +use assert_fs::TempDir; use katana_primitives::contract::ContractAddress; use katana_primitives::genesis::allocation::{DevAllocationsGenerator, DevGenesisAccount}; use katana_primitives::FieldElement; @@ -25,59 +26,62 @@ pub struct KatanaRunner { port: u16, provider: JsonRpcClient, accounts: Vec<(ContractAddress, DevGenesisAccount)>, - log_filename: PathBuf, + log_file_path: PathBuf, contract: Mutex>, } -pub const BLOCK_TIME_IF_ENABLED: u64 = 3000; +/// Configuration for the KatanaRunner. +#[derive(Debug)] +pub struct KatanaRunnerConfig { + /// The name of the katana program to run. + pub program_name: Option, + /// The name used in the log file suffix, the port number is used otherwise. + pub run_name: Option, + /// The number of accounts to predeployed. + pub n_accounts: u16, + /// Whether to disable the fee. + pub disable_fee: bool, + /// The block time in milliseconds. + pub block_time: Option, + /// The port to run the katana runner on, if None, a random free port is chosen. + pub port: Option, +} + +impl Default for KatanaRunnerConfig { + fn default() -> Self { + Self { + n_accounts: 2, + disable_fee: false, + block_time: None, + port: None, + program_name: None, + run_name: None, + } + } +} impl KatanaRunner { + /// Creates a new KatanaRunner with default values. pub fn new() -> Result { - Self::new_with_port(find_free_port()) + Self::setup_and_start(KatanaRunnerConfig::default()) } - pub fn new_with_name(name: &str) -> Result { - Self::new_with_port_and_filename( - "katana", - find_free_port(), - format!("logs/katana-{}.log", name), - 2, - false, - ) + /// Creates a new KatanaRunner with the given configuration. + pub fn new_with_config(config: KatanaRunnerConfig) -> Result { + Self::setup_and_start(config) } - pub fn new_with_args( - program: &str, - name: &str, - n_accounts: u16, - with_blocks: bool, - ) -> Result { - Self::new_with_port_and_filename( - program, - find_free_port(), - format!("katana-logs/{}.log", name), - n_accounts, - with_blocks, - ) - } + /// Starts a new KatanaRunner with the given configuration. + /// + /// # Arguments + /// + /// * `config` - The configuration for the katana runner. + fn setup_and_start(config: KatanaRunnerConfig) -> Result { + let program = config.program_name.clone().unwrap_or_else(determine_default_program_path); - pub fn new_with_port(port: u16) -> Result { - Self::new_with_port_and_filename( - "katana", - port, - format!("katana-logs/{}.log", port), - 2, - false, - ) - } + let port = config.port.unwrap_or_else(find_free_port); + let n_accounts = config.n_accounts; - fn new_with_port_and_filename( - program: &str, - port: u16, - log_filename: String, - n_accounts: u16, - with_blocks: bool, - ) -> Result { let mut command = Command::new(program); command .args(["-p", &port.to_string()]) @@ -85,8 +89,12 @@ impl KatanaRunner { .args(["--max-connections", &format!("{}", 10000)]) .args(["--accounts", &format!("{}", n_accounts)]); - if with_blocks { - command.args(["--block-time", &format!("{}", BLOCK_TIME_IF_ENABLED)]); + if let Some(block_time_ms) = config.block_time { + command.args(["--block-time", &format!("{}", block_time_ms)]); + } + + if config.disable_fee { + command.args(["--disable-fee"]); } let mut child = @@ -94,11 +102,19 @@ impl KatanaRunner { let stdout = child.stdout.take().context("failed to take subprocess stdout")?; - let log_filename_sent = PathBuf::from(log_filename); - let log_filename = log_filename_sent.clone(); + let log_dir = TempDir::new().unwrap(); + + let log_filename = PathBuf::from(format!( + "katana-{}.log", + config.run_name.clone().unwrap_or_else(|| port.to_string()) + )); + + let log_file_path = log_dir.join(log_filename); + let log_file_path_sent = log_file_path.clone(); + let (sender, receiver) = mpsc::channel(); thread::spawn(move || { - utils::wait_for_server_started_and_signal(&log_filename_sent, stdout, sender); + utils::wait_for_server_started_and_signal(&log_file_path_sent, stdout, sender); }); receiver @@ -118,7 +134,11 @@ impl KatanaRunner { .collect(); let contract = Mutex::new(Option::None); - Ok(KatanaRunner { child, port, provider, accounts, log_filename, contract }) + Ok(KatanaRunner { child, port, provider, accounts, log_file_path, contract }) + } + + pub fn log_file_path(&self) -> &PathBuf { + &self.log_file_path } pub fn provider(&self) -> &JsonRpcClient { @@ -129,6 +149,10 @@ impl KatanaRunner { format!("http://127.0.0.1:{}/", self.port) } + pub fn url(&self) -> Url { + Url::parse(&self.endpoint()).context("Failed to parse url").unwrap() + } + pub fn owned_provider(&self) -> JsonRpcClient { let url = Url::parse(&self.endpoint()).context("Failed to parse url").unwrap(); JsonRpcClient::new(HttpTransport::new(url)) @@ -157,3 +181,25 @@ impl Drop for KatanaRunner { } } } + +/// Determines the default program path for the katana runner based on the KATANA_RUNNER_BIN +/// environment variable. If not set, try to to use katana from the PATH. +fn determine_default_program_path() -> String { + if let Ok(bin) = std::env::var("KATANA_RUNNER_BIN") { bin } else { "katana".to_string() } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_determine_default_program_path() { + // Set the environment variable to test the first branch + std::env::set_var("KATANA_RUNNER_BIN", "custom_katana_path"); + assert_eq!(determine_default_program_path(), "custom_katana_path"); + + // Unset the environment variable to test the fallback branch + std::env::remove_var("KATANA_RUNNER_BIN"); + assert_eq!(determine_default_program_path(), "katana"); + } +} diff --git a/crates/katana/runner/src/logs.rs b/crates/katana/runner/src/logs.rs index 3c699ef940..29d70da32e 100644 --- a/crates/katana/runner/src/logs.rs +++ b/crates/katana/runner/src/logs.rs @@ -25,7 +25,7 @@ pub type Log = TimedLog; impl KatanaRunner { pub fn blocks(&self) -> Vec { - BufReader::new(File::open(&self.log_filename).unwrap()) + BufReader::new(File::open(&self.log_file_path).unwrap()) .lines() .map_while(Result::ok) .filter_map(|line| match serde_json::from_str(&line) { @@ -91,7 +91,7 @@ impl KatanaRunner { pub async fn steps(&self) -> Vec { let matching = "Transaction resource usage: Steps: "; - BufReader::new(File::open(&self.log_filename).unwrap()) + BufReader::new(File::open(&self.log_file_path).unwrap()) .lines() .filter_map(|line| { let line = line.unwrap(); diff --git a/crates/katana/runner/src/prefunded.rs b/crates/katana/runner/src/prefunded.rs index 0a04515897..2f1d54ecab 100644 --- a/crates/katana/runner/src/prefunded.rs +++ b/crates/katana/runner/src/prefunded.rs @@ -19,6 +19,10 @@ impl KatanaRunner { self.accounts_data().iter().map(|account| self.account_to_single_owned(account)).collect() } + pub fn account_data(&self, index: usize) -> &(ContractAddress, DevGenesisAccount) { + &self.accounts_data()[index] + } + pub fn account( &self, index: usize, diff --git a/crates/katana/runner/tests/runner.rs b/crates/katana/runner/tests/runner.rs index 7571aa9887..684230dbe2 100644 --- a/crates/katana/runner/tests/runner.rs +++ b/crates/katana/runner/tests/runner.rs @@ -1,11 +1,15 @@ use katana_runner::*; use starknet::providers::Provider; -#[katana_test(2, false, "katana", "")] +#[katana_test(2, false)] async fn test_run() { for i in 0..10 { let logname = format!("katana-test_run-{}", i); - let runner = KatanaRunner::new_with_name(&logname).expect("failed to start another katana"); + let runner = KatanaRunner::new_with_config(KatanaRunnerConfig { + run_name: Some(logname), + ..Default::default() + }) + .expect("failed to start another katana"); let _block_number = runner.provider().block_number().await.unwrap(); // created by the macro at the beginning of the test @@ -13,7 +17,7 @@ async fn test_run() { } } -#[katana_test(2, true, "katana", "")] +#[katana_test(2, true)] async fn basic_macro_usage() { let _block_number = runner.provider().block_number().await.unwrap(); } diff --git a/crates/saya/README.md b/crates/saya/README.md index 5c0542d503..f33e6514e4 100644 --- a/crates/saya/README.md +++ b/crates/saya/README.md @@ -27,15 +27,17 @@ The hash function depends on which verifier will be used (keccak, perdersen, pos The prover is the service responsible of generating a proof for the given `Starknet OS` output. Saya will be able to use several provers: -* **SHARP**: a StarkWare shared proving service. This service generates the proof AND send the proof and the facts on Ethereum directly. -* **Stone**: [Stone](https://github.com/starkware-libs/stone-prover) is being used to generate the proof associated with the [cairo verifier written by Herodotus](https://github.com/HerodotusDev/cairo-verifier). -* **Platinum**: The [Platinum](https://github.com/lambdaclass/lambdaworks) prover from LambdaClass. + +- **SHARP**: a StarkWare shared proving service. This service generates the proof AND send the proof and the facts on Ethereum directly. +- **Stone**: [Stone](https://github.com/starkware-libs/stone-prover) is being used to generate the proof associated with the [cairo verifier written by Herodotus](https://github.com/HerodotusDev/cairo-verifier). +- **Platinum**: The [Platinum](https://github.com/lambdaclass/lambdaworks) prover from LambdaClass. ## Verifier and facts registry The on-chain verifier options so far are: -* **Ethereum**: StarkWare contracts on Ethereum which are tailored to receive the SHARP proofs and facts. -* **Starknet**: Soon, the cairo verifier from Herodotus will enable verification on Starknet. + +- **Ethereum**: StarkWare contracts on Ethereum which are tailored to receive the SHARP proofs and facts. +- **Starknet**: Soon, the cairo verifier from Herodotus will enable verification on Starknet. A verifier comes along a fact registry. A fact registry keep track of which fact (the hash of the program class hash of `Starknet OS` in our case and the hash of it's output) has been proven. @@ -61,11 +63,11 @@ To ensure we've the exact same result, Saya must run the same version (or at lea In new Cairo VM version, there are breaking changes as mentioned in the release not, which implies a bump of Cairo VM for Katana and at the same time we could bump to cairo `2.5.0`. However, papyrus and blockifier which we depend on are still in `-dev` version, where also some breaking changes must be addressed. -* Cairo VM (currently dojo is using 0.8, and others are in 0.9) -* Blockifier (uses Cairo VM and cairo-lang `-dev`) -* Papyrus (used by blockifier and use blockifier and cairo-lang `-dev`) -* cairo-lang (we should support `2.5` now) -* scarb (breaking changes between 2.4 and 2.5 to be addresses, not required to only build saya and SNOS) +- Cairo VM (currently dojo is using 0.8, and others are in 0.9) +- Blockifier (uses Cairo VM and cairo-lang `-dev`) +- Papyrus (used by blockifier and use blockifier and cairo-lang `-dev`) +- cairo-lang (we should support `2.5` now) +- scarb (breaking changes between 2.4 and 2.5 to be addresses, not required to only build saya and SNOS) ## Local Testing @@ -75,6 +77,7 @@ cargo run -r -p sozo -- build --manifest-path examples/spawn-and-move/Scarb.toml cargo run -r -p sozo -- migrate --manifest-path examples/spawn-and-move/Scarb.toml # Make some transactions cargo run -r --bin saya -- --rpc-url http://localhost:5050 # Run Saya ``` + ## Additional documentation [Hackmd note](https://hackmd.io/@glihm/saya) diff --git a/crates/sozo/ops/src/tests/auth.rs b/crates/sozo/ops/src/tests/auth.rs index 0535b56384..854892941f 100644 --- a/crates/sozo/ops/src/tests/auth.rs +++ b/crates/sozo/ops/src/tests/auth.rs @@ -1,8 +1,6 @@ -use dojo_test_utils::sequencer::{ - get_default_test_starknet_config, SequencerConfig, TestSequencer, -}; use dojo_world::contracts::world::WorldContract; use dojo_world::migration::TxnConfig; +use katana_runner::KatanaRunner; use starknet::accounts::{Account, ConnectedAccount}; use starknet::core::utils::cairo_short_string_to_felt; @@ -14,13 +12,12 @@ const ACTION_CONTRACT_NAME: &str = "dojo_examples::actions::actions"; #[tokio::test(flavor = "multi_thread")] async fn auth_grant_writer_ok() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); let world = setup::setup(&sequencer).await.unwrap(); // Shouldn't have any permission at this point. - let account2 = sequencer.account_at_index(2); + let account2 = sequencer.account(1); // Setup new world contract handler with account 2. let world_2 = WorldContract::new(world.address, account2); @@ -53,13 +50,12 @@ async fn auth_grant_writer_ok() { #[tokio::test(flavor = "multi_thread")] async fn auth_revoke_writer_ok() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); let world = setup::setup(&sequencer).await.unwrap(); // Shouldn't have any permission at this point. - let account2 = sequencer.account_at_index(2); + let account2 = sequencer.account(1); // Setup new world contract handler with account 2. let world_2 = WorldContract::new(world.address, account2); @@ -106,13 +102,12 @@ async fn auth_revoke_writer_ok() { #[tokio::test(flavor = "multi_thread")] async fn auth_grant_owner_ok() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); let world = setup::setup(&sequencer).await.unwrap(); // Shouldn't have any permission at this point. - let account_2 = sequencer.account_at_index(2); + let account_2 = sequencer.account(1); let account_2_addr = account_2.address(); // Setup new world contract handler with account 2. @@ -145,13 +140,12 @@ async fn auth_grant_owner_ok() { #[tokio::test(flavor = "multi_thread")] async fn auth_revoke_owner_ok() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); let world = setup::setup(&sequencer).await.unwrap(); // Shouldn't have any permission at this point. - let account_2 = sequencer.account_at_index(2); + let account_2 = sequencer.account(1); let account_2_addr = account_2.address(); // Setup new world contract handler with account 2. diff --git a/crates/sozo/ops/src/tests/call.rs b/crates/sozo/ops/src/tests/call.rs index 331215c03f..84d6c4f5bc 100644 --- a/crates/sozo/ops/src/tests/call.rs +++ b/crates/sozo/ops/src/tests/call.rs @@ -1,7 +1,5 @@ -use dojo_test_utils::sequencer::{ - get_default_test_starknet_config, SequencerConfig, TestSequencer, -}; use dojo_world::contracts::WorldContractReader; +use katana_runner::KatanaRunner; use starknet::accounts::SingleOwnerAccount; use starknet::providers::jsonrpc::HttpTransport; use starknet::providers::JsonRpcClient; @@ -16,8 +14,7 @@ const ENTRYPOINT: &str = "tile_terrain"; #[tokio::test] async fn call_with_bad_address() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); let world = setup::setup(&sequencer).await.unwrap(); let provider = sequencer.provider(); @@ -38,8 +35,7 @@ async fn call_with_bad_address() { #[tokio::test] async fn call_with_bad_name() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); let world = setup::setup(&sequencer).await.unwrap(); let provider = sequencer.provider(); @@ -60,8 +56,7 @@ async fn call_with_bad_name() { #[tokio::test] async fn call_with_bad_entrypoint() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); let world = setup::setup(&sequencer).await.unwrap(); let provider = sequencer.provider(); @@ -82,8 +77,7 @@ async fn call_with_bad_entrypoint() { #[tokio::test] async fn call_with_bad_calldata() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); let world = setup::setup(&sequencer).await.unwrap(); let provider = sequencer.provider(); @@ -98,8 +92,7 @@ async fn call_with_bad_calldata() { #[tokio::test] async fn call_with_contract_name() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); let world = setup::setup(&sequencer).await.unwrap(); let provider = sequencer.provider(); @@ -120,8 +113,7 @@ async fn call_with_contract_name() { #[tokio::test] async fn call_with_contract_address() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); let world = setup::setup(&sequencer).await.unwrap(); let provider = sequencer.provider(); diff --git a/crates/sozo/ops/src/tests/migration.rs b/crates/sozo/ops/src/tests/migration.rs index 1a3379015b..b2038b1b85 100644 --- a/crates/sozo/ops/src/tests/migration.rs +++ b/crates/sozo/ops/src/tests/migration.rs @@ -2,11 +2,7 @@ use std::str; use camino::Utf8Path; use dojo_lang::compiler::{BASE_DIR, MANIFESTS_DIR}; -use dojo_test_utils::compiler::build_full_test_config; use dojo_test_utils::migration::prepare_migration_with_world_and_seed; -use dojo_test_utils::sequencer::{ - get_default_test_starknet_config, SequencerConfig, StarknetConfig, TestSequencer, -}; use dojo_world::contracts::WorldContractReader; use dojo_world::manifest::{BaseManifest, DeploymentManifest, WORLD_CONTRACT_NAME}; use dojo_world::metadata::{ @@ -18,80 +14,67 @@ use dojo_world::migration::world::WorldDiff; use dojo_world::migration::TxnConfig; use futures::TryStreamExt; use ipfs_api_backend_hyper::{HyperBackend, IpfsApi, IpfsClient, TryFromUri}; -use starknet::accounts::{ExecutionEncoding, SingleOwnerAccount}; -use starknet::core::chain_id; +use katana_runner::{KatanaRunner, KatanaRunnerConfig}; use starknet::core::types::{BlockId, BlockTag}; use starknet::core::utils::{get_selector_from_name, parse_cairo_short_string}; use starknet::macros::felt; use starknet::providers::jsonrpc::HttpTransport; use starknet::providers::JsonRpcClient; -use starknet::signers::{LocalWallet, SigningKey}; use starknet_crypto::FieldElement; -use super::setup::{load_config, setup_migration, setup_ws}; +use super::setup; use crate::migration::{execute_strategy, upload_metadata}; use crate::utils::get_contract_address_from_reader; #[tokio::test(flavor = "multi_thread")] async fn migrate_with_auto_mine() { - let config = load_config(); - let ws = setup_ws(&config); + let config = setup::load_config(); + let ws = setup::setup_ws(&config); - let migration = setup_migration().unwrap(); + let migration = setup::setup_migration(&config).unwrap(); - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Fail to start runner"); - let mut account = sequencer.account(); + let mut account = sequencer.account(0); account.set_block_id(BlockId::Tag(BlockTag::Pending)); execute_strategy(&ws, &migration, &account, TxnConfig::default()).await.unwrap(); - - sequencer.stop().unwrap(); } #[tokio::test(flavor = "multi_thread")] async fn migrate_with_block_time() { - let config = load_config(); - let ws = setup_ws(&config); + let config = setup::load_config(); + let ws = setup::setup_ws(&config); - let migration = setup_migration().unwrap(); + let migration = setup::setup_migration(&config).unwrap(); - let sequencer = TestSequencer::start( - SequencerConfig { block_time: Some(1000), ..Default::default() }, - get_default_test_starknet_config(), - ) - .await; + let sequencer = KatanaRunner::new_with_config(KatanaRunnerConfig { + block_time: Some(1000), + ..Default::default() + }) + .expect("Fail to start runner"); - let mut account = sequencer.account(); + let mut account = sequencer.account(0); account.set_block_id(BlockId::Tag(BlockTag::Pending)); execute_strategy(&ws, &migration, &account, TxnConfig::default()).await.unwrap(); - sequencer.stop().unwrap(); } +#[should_panic] #[tokio::test(flavor = "multi_thread")] async fn migrate_with_small_fee_multiplier_will_fail() { - let config = load_config(); - let ws = setup_ws(&config); + let config = setup::load_config(); + let ws = setup::setup_ws(&config); - let migration = setup_migration().unwrap(); + let migration = setup::setup_migration(&config).unwrap(); - let sequencer = TestSequencer::start( - Default::default(), - StarknetConfig { disable_fee: false, ..Default::default() }, - ) - .await; + let sequencer = KatanaRunner::new_with_config(KatanaRunnerConfig { + disable_fee: true, + ..Default::default() + }) + .expect("Fail to start runner"); - let account = SingleOwnerAccount::new( - JsonRpcClient::new(HttpTransport::new(sequencer.url())), - LocalWallet::from_signing_key(SigningKey::from_secret_scalar( - sequencer.raw_account().private_key, - )), - sequencer.raw_account().account_address, - chain_id::TESTNET, - ExecutionEncoding::New, - ); + let account = sequencer.account(0); assert!( execute_strategy( @@ -103,34 +86,24 @@ async fn migrate_with_small_fee_multiplier_will_fail() { .await .is_err() ); - sequencer.stop().unwrap(); } #[tokio::test] async fn migration_from_remote() { - let config = load_config(); - let ws = setup_ws(&config); + let config = setup::load_config(); + let ws = setup::setup_ws(&config); - let base = "../../../examples/spawn-and-move"; + let base = config.manifest_path().parent().unwrap(); let target_dir = format!("{}/target/dev", base); - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); - let account = SingleOwnerAccount::new( - JsonRpcClient::new(HttpTransport::new(sequencer.url())), - LocalWallet::from_signing_key(SigningKey::from_secret_scalar( - sequencer.raw_account().private_key, - )), - sequencer.raw_account().account_address, - chain_id::TESTNET, - ExecutionEncoding::New, - ); + let account = sequencer.account(0); let profile_name = ws.current_profile().unwrap().to_string(); let manifest = BaseManifest::load_from_path( - &Utf8Path::new(base).to_path_buf().join(MANIFESTS_DIR).join(&profile_name).join(BASE_DIR), + &base.to_path_buf().join(MANIFESTS_DIR).join(&profile_name).join(BASE_DIR), ) .unwrap(); @@ -147,7 +120,7 @@ async fn migration_from_remote() { execute_strategy(&ws, &migration, &account, TxnConfig::default()).await.unwrap(); let local_manifest = BaseManifest::load_from_path( - &Utf8Path::new(base).to_path_buf().join(MANIFESTS_DIR).join(&profile_name).join(BASE_DIR), + &base.to_path_buf().join(MANIFESTS_DIR).join(&profile_name).join(BASE_DIR), ) .unwrap(); @@ -158,8 +131,6 @@ async fn migration_from_remote() { .await .unwrap(); - sequencer.stop().unwrap(); - assert_eq!(local_manifest.world.inner.class_hash, remote_manifest.world.inner.class_hash); assert_eq!(local_manifest.models.len(), remote_manifest.models.len()); } @@ -168,21 +139,19 @@ async fn migration_from_remote() { #[ignore] #[tokio::test(flavor = "multi_thread")] async fn migrate_with_metadata() { - let config = build_full_test_config("../../../examples/spawn-and-move/Scarb.toml", false) - .unwrap_or_else(|c| panic!("Error loading config: {c:?}")); - let ws = setup_ws(&config); + let config = setup::load_config(); + let ws = setup::setup_ws(&config); - let migration = setup_migration().unwrap(); + let migration = setup::setup_migration(&config).unwrap(); - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Fail to start runner"); - let mut account = sequencer.account(); + let mut account = sequencer.account(0); account.set_block_id(BlockId::Tag(BlockTag::Pending)); - let output = execute_strategy(&ws, &migration, &account, TxnConfig::default()).await.unwrap(); + let output = execute_strategy(&ws, &migration, &account, TxnConfig::init_wait()).await.unwrap(); - let res = upload_metadata(&ws, &account, output.clone(), TxnConfig::default()).await; + let res = upload_metadata(&ws, &account, output.clone(), TxnConfig::init_wait()).await; assert!(res.is_ok()); let provider = sequencer.provider(); @@ -242,21 +211,28 @@ async fn migrate_with_metadata() { #[tokio::test(flavor = "multi_thread")] async fn migration_with_mismatching_world_address_and_seed() { - let base_dir = "../../../examples/spawn-and-move"; - let target_dir = format!("{}/target/dev", base_dir); + let config = setup::load_config(); + + let base_dir = config.manifest_path().parent().unwrap().to_path_buf(); + let target_dir = base_dir.join("target").join("dev"); let result = prepare_migration_with_world_and_seed( - base_dir.into(), - target_dir.into(), + base_dir, + target_dir, Some(felt!("0x1")), "sozo_test", ); - assert!(result.is_err_and(|e| e.to_string().contains( + assert!(result.is_err()); + + let error_message = result.unwrap_err().to_string(); + + assert_eq!( + error_message, "Calculated world address doesn't match provided world address.\nIf you are deploying \ with custom seed make sure `world_address` is correctly configured (or not set) \ `Scarb.toml`" - ))); + ); } /// Get the hash from a IPFS URI diff --git a/crates/sozo/ops/src/tests/setup.rs b/crates/sozo/ops/src/tests/setup.rs index 7c0777d937..2591acc1cf 100644 --- a/crates/sozo/ops/src/tests/setup.rs +++ b/crates/sozo/ops/src/tests/setup.rs @@ -1,10 +1,11 @@ use anyhow::Result; -use dojo_test_utils::compiler::build_test_config; +use camino::Utf8PathBuf; +use dojo_test_utils::compiler; use dojo_test_utils::migration::prepare_migration_with_world_and_seed; -use dojo_test_utils::sequencer::TestSequencer; use dojo_world::contracts::world::WorldContract; use dojo_world::migration::strategy::MigrationStrategy; use dojo_world::migration::TxnConfig; +use katana_runner::KatanaRunner; use scarb::core::{Config, Workspace}; use scarb::ops; use starknet::accounts::SingleOwnerAccount; @@ -15,14 +16,22 @@ use starknet::signers::LocalWallet; use crate::migration; -/// Load the spawn-and-moves project configuration. +/// Load the spawn-and-moves project configuration from a copy of the project +/// into a temporary directory to avoid any race during multithreading testing. +/// +/// We may in the future add locking mechanism to ensure sozo locks each file +/// being read, to avoid race conditions. /// /// # Returns /// /// A [`Config`] object loaded from the spawn-and-moves Scarb.toml file. pub fn load_config() -> Config { - build_test_config("../../../examples/spawn-and-move/Scarb.toml") - .unwrap_or_else(|c| panic!("Error loading config: {c:?}")) + // To avoid race conditions with other tests, all the project files + // are copied to ensure safe parallel execution. + let source_project_dir = Utf8PathBuf::from("../../../examples/spawn-and-move/"); + let dojo_core_path = Utf8PathBuf::from("../../dojo-core"); + + compiler::copy_tmp_config(&source_project_dir, &dojo_core_path) } /// Setups the workspace for the spawn-and-moves project. @@ -43,8 +52,9 @@ pub fn setup_ws(config: &Config) -> Workspace<'_> { /// # Returns /// /// A [`MigrationStrategy`] to execute to migrate the full spawn-and-moves project. -pub fn setup_migration() -> Result { - let base_dir = "../../../examples/spawn-and-move"; +pub fn setup_migration(config: &Config) -> Result { + let manifest_path = config.manifest_path(); + let base_dir = manifest_path.parent().unwrap(); let target_dir = format!("{}/target/dev", base_dir); prepare_migration_with_world_and_seed(base_dir.into(), target_dir.into(), None, "sozo_test") @@ -61,14 +71,14 @@ pub fn setup_migration() -> Result { /// A [`WorldContract`] initialized with the migrator account, /// the account 0 of the sequencer. pub async fn setup( - sequencer: &TestSequencer, + sequencer: &KatanaRunner, ) -> Result, LocalWallet>>> { let config = load_config(); let ws = setup_ws(&config); - let migration = setup_migration()?; + let migration = setup_migration(&config)?; - let mut account = sequencer.account(); + let mut account = sequencer.account(0); account.set_block_id(BlockId::Tag(BlockTag::Pending)); let output = migration::execute_strategy( diff --git a/crates/sozo/ops/src/tests/utils.rs b/crates/sozo/ops/src/tests/utils.rs index 71859f079e..6fe0351fd4 100644 --- a/crates/sozo/ops/src/tests/utils.rs +++ b/crates/sozo/ops/src/tests/utils.rs @@ -1,8 +1,6 @@ -use dojo_test_utils::sequencer::{ - get_default_test_starknet_config, SequencerConfig, TestSequencer, -}; use dojo_world::contracts::world::WorldContract; use dojo_world::contracts::WorldContractReader; +use katana_runner::KatanaRunner; use starknet::accounts::ConnectedAccount; use starknet::core::types::{BlockId, BlockTag, FieldElement}; @@ -13,8 +11,7 @@ const ACTION_CONTRACT_NAME: &str = "dojo_examples::actions::actions"; #[tokio::test(flavor = "multi_thread")] async fn get_contract_address_from_world() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); let world = setup::setup(&sequencer).await.unwrap(); @@ -26,10 +23,9 @@ async fn get_contract_address_from_world() { #[tokio::test(flavor = "multi_thread")] async fn get_contract_address_from_string() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); - let account = sequencer.account(); + let account = sequencer.account(0); let world = WorldContract::new(FieldElement::ZERO, account); let contract_address = utils::get_contract_address(&world, "0x1234".to_string()).await.unwrap(); @@ -39,11 +35,10 @@ async fn get_contract_address_from_string() { #[tokio::test(flavor = "multi_thread")] async fn get_contract_address_from_world_with_world_reader() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); let world = setup::setup(&sequencer).await.unwrap(); - let account = sequencer.account(); + let account = sequencer.account(0); let provider = account.provider(); let world_reader = WorldContractReader::new(world.address, provider); @@ -57,10 +52,10 @@ async fn get_contract_address_from_world_with_world_reader() { #[tokio::test(flavor = "multi_thread")] async fn get_contract_address_from_string_with_world_reader() { - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); - let provider = sequencer.provider(); + let account = sequencer.account(0); + let provider = account.provider(); let world_reader = WorldContractReader::new(FieldElement::ZERO, provider); let contract_address = diff --git a/crates/torii/.gitignore b/crates/torii/.gitignore index 1de565933b..be1022fc59 100644 --- a/crates/torii/.gitignore +++ b/crates/torii/.gitignore @@ -1 +1,2 @@ -target \ No newline at end of file +target +types-test/manifests diff --git a/crates/torii/types-test/manifests/dev/base/contracts/types_test_contracts_records.toml b/crates/torii/types-test/manifests/dev/base/contracts/types_test_contracts_records.toml deleted file mode 100644 index 27cbb6f796..0000000000 --- a/crates/torii/types-test/manifests/dev/base/contracts/types_test_contracts_records.toml +++ /dev/null @@ -1,9 +0,0 @@ -kind = "DojoContract" -class_hash = "0x658309df749cea1c32e21920740011e829626ab06c9b4d0c05b75f82a20693b" -original_class_hash = "0x658309df749cea1c32e21920740011e829626ab06c9b4d0c05b75f82a20693b" -base_class_hash = "0x0" -abi = "manifests/dev/abis/base/contracts/types_test_contracts_records.json" -reads = [] -writes = [] -computed = [] -name = "types_test::contracts::records" diff --git a/crates/torii/types-test/manifests/dev/base/dojo_base_base.toml b/crates/torii/types-test/manifests/dev/base/dojo_base_base.toml deleted file mode 100644 index d926bca4d7..0000000000 --- a/crates/torii/types-test/manifests/dev/base/dojo_base_base.toml +++ /dev/null @@ -1,4 +0,0 @@ -kind = "Class" -class_hash = "0x679177a2cb757694ac4f326d01052ff0963eac0bc2a17116a2b87badcdf6f76" -original_class_hash = "0x679177a2cb757694ac4f326d01052ff0963eac0bc2a17116a2b87badcdf6f76" -name = "dojo::base::base" diff --git a/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml b/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml index 0b131a3405..d9220cfb88 100644 --- a/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml +++ b/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x5a8881181fc47d7cba049ce2861ce9327f33e04827d70233e22ce218a947ccf" -original_class_hash = "0x5a8881181fc47d7cba049ce2861ce9327f33e04827d70233e22ce218a947ccf" +class_hash = "0x301ba8a1a13cec9291b049dea531f73a600e0812908cefa26d17214da411e9c" +original_class_hash = "0x301ba8a1a13cec9291b049dea531f73a600e0812908cefa26d17214da411e9c" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/crates/torii/types-test/manifests/dev/base/models/types_test_models_record.toml b/crates/torii/types-test/manifests/dev/base/models/types_test_models_record.toml deleted file mode 100644 index 1474e6e48a..0000000000 --- a/crates/torii/types-test/manifests/dev/base/models/types_test_models_record.toml +++ /dev/null @@ -1,95 +0,0 @@ -kind = "DojoModel" -class_hash = "0x134456282bbaf00e0895ff43f286af8d490202baf6279d2b05be9bc0c05f059" -original_class_hash = "0x134456282bbaf00e0895ff43f286af8d490202baf6279d2b05be9bc0c05f059" -abi = "manifests/dev/abis/base/models/types_test_models_record.json" -name = "types_test::models::record" - -[[members]] -name = "record_id" -type = "u32" -key = true - -[[members]] -name = "depth" -type = "Depth" -key = false - -[[members]] -name = "type_u8" -type = "u8" -key = false - -[[members]] -name = "type_u16" -type = "u16" -key = false - -[[members]] -name = "type_u32" -type = "u32" -key = false - -[[members]] -name = "type_u64" -type = "u64" -key = false - -[[members]] -name = "type_u128" -type = "u128" -key = false - -[[members]] -name = "type_u256" -type = "u256" -key = false - -[[members]] -name = "type_bool" -type = "bool" -key = false - -[[members]] -name = "type_felt" -type = "felt252" -key = false - -[[members]] -name = "type_class_hash" -type = "ClassHash" -key = false - -[[members]] -name = "type_contract_address" -type = "ContractAddress" -key = false - -[[members]] -name = "type_deeply_nested" -type = "Nested" -key = false - -[[members]] -name = "type_nested_one" -type = "NestedMost" -key = false - -[[members]] -name = "type_nested_two" -type = "NestedMost" -key = false - -[[members]] -name = "random_u8" -type = "u8" -key = false - -[[members]] -name = "random_u128" -type = "u128" -key = false - -[[members]] -name = "composite_u256" -type = "u256" -key = false diff --git a/crates/torii/types-test/manifests/dev/base/models/types_test_models_record_sibling.toml b/crates/torii/types-test/manifests/dev/base/models/types_test_models_record_sibling.toml deleted file mode 100644 index cf795b24b0..0000000000 --- a/crates/torii/types-test/manifests/dev/base/models/types_test_models_record_sibling.toml +++ /dev/null @@ -1,15 +0,0 @@ -kind = "DojoModel" -class_hash = "0x4e92336e21ac7970b9bd9f4e294705f7864c0b29f53fdbf42ff7a9d7f0a53f3" -original_class_hash = "0x4e92336e21ac7970b9bd9f4e294705f7864c0b29f53fdbf42ff7a9d7f0a53f3" -abi = "manifests/dev/abis/base/models/types_test_models_record_sibling.json" -name = "types_test::models::record_sibling" - -[[members]] -name = "record_id" -type = "u32" -key = true - -[[members]] -name = "random_u8" -type = "u8" -key = false diff --git a/crates/torii/types-test/manifests/dev/base/models/types_test_models_subrecord.toml b/crates/torii/types-test/manifests/dev/base/models/types_test_models_subrecord.toml deleted file mode 100644 index 36158d7d9f..0000000000 --- a/crates/torii/types-test/manifests/dev/base/models/types_test_models_subrecord.toml +++ /dev/null @@ -1,25 +0,0 @@ -kind = "DojoModel" -class_hash = "0x7a47c3a9c8509a1d4a0379e50799eba7b173db6e41961341fe3f856a51d627" -original_class_hash = "0x7a47c3a9c8509a1d4a0379e50799eba7b173db6e41961341fe3f856a51d627" -abi = "manifests/dev/abis/base/models/types_test_models_subrecord.json" -name = "types_test::models::subrecord" - -[[members]] -name = "record_id" -type = "u32" -key = true - -[[members]] -name = "subrecord_id" -type = "u32" -key = true - -[[members]] -name = "type_u8" -type = "u8" -key = false - -[[members]] -name = "random_u8" -type = "u8" -key = false diff --git a/examples/spawn-and-move/.gitignore b/examples/spawn-and-move/.gitignore index 8b12f5d163..b61463aafe 100644 --- a/examples/spawn-and-move/.gitignore +++ b/examples/spawn-and-move/.gitignore @@ -1,2 +1,2 @@ target -generated \ No newline at end of file +generated diff --git a/examples/spawn-and-move/README.md b/examples/spawn-and-move/README.md index 9293592c12..5d1bc4cbb3 100644 --- a/examples/spawn-and-move/README.md +++ b/examples/spawn-and-move/README.md @@ -43,7 +43,7 @@ sozo model get Moves 0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786b > last_direction: Direction = None, > } -# The returned value is 0 since we haven't spawned yet. +# The returned value is 0 since we haven't spawned yet. # We can spawn a player using the actions contract address. sozo execute 0x152dcff993befafe5001975149d2c50bd9621da7cbaed74f68e7d5e54e65abc spawn @@ -55,7 +55,7 @@ sozo model get Moves 0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786b > remaining: u8 = 1, > last_direction: Direction = None, > } -> +> > enum Direction { > None > Left diff --git a/examples/spawn-and-move/Scarb.toml b/examples/spawn-and-move/Scarb.toml index 602db7b248..9db0a4f2c8 100644 --- a/examples/spawn-and-move/Scarb.toml +++ b/examples/spawn-and-move/Scarb.toml @@ -1,5 +1,5 @@ [package] -cairo-version = "2.4.0" +cairo-version = "=2.6.3" name = "dojo_examples" version = "0.6.0" # Use the prelude with the less imports as possible @@ -25,4 +25,4 @@ rpc_url = "http://localhost:5050/" # Default account for katana with seed = 0 account_address = "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03" private_key = "0x1800000000300000180000000000030000000000003006001800006600" -world_address = "0x1385f25d20a724edc9c7b3bd9636c59af64cbaf9fcd12f33b3af96b2452f295" +world_address = "0x3898144a24151443f0c6501a1de46a6e9e27abd9fb5d08cdeeff5a5127d1d25" diff --git a/crates/torii/types-test/manifests/dev/abis/base/contracts/types_test_contracts_records.json b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json similarity index 59% rename from crates/torii/types-test/manifests/dev/abis/base/contracts/types_test_contracts_records.json rename to examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json index e09ff4b854..279700126b 100644 --- a/crates/torii/types-test/manifests/dev/abis/base/contracts/types_test_contracts_records.json +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json @@ -55,32 +55,124 @@ }, { "type": "impl", - "name": "RecordsImpl", - "interface_name": "types_test::contracts::IRecords" + "name": "ActionsComputedImpl", + "interface_name": "dojo_examples::actions::IActionsComputed" + }, + { + "type": "struct", + "name": "dojo_examples::models::Vec2", + "members": [ + { + "name": "x", + "type": "core::integer::u32" + }, + { + "name": "y", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::Position", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "vec", + "type": "dojo_examples::models::Vec2" + } + ] }, { "type": "interface", - "name": "types_test::contracts::IRecords", + "name": "dojo_examples::actions::IActionsComputed", "items": [ { "type": "function", - "name": "create", + "name": "tile_terrain", "inputs": [ { - "name": "num_records", + "name": "vec", + "type": "dojo_examples::models::Vec2" + } + ], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "quadrant", + "inputs": [ + { + "name": "pos", + "type": "dojo_examples::models::Position" + } + ], + "outputs": [ + { "type": "core::integer::u8" } ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "ActionsImpl", + "interface_name": "dojo_examples::actions::IActions" + }, + { + "type": "enum", + "name": "dojo_examples::models::Direction", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::actions::IActions", + "items": [ + { + "type": "function", + "name": "spawn", + "inputs": [], "outputs": [], "state_mutability": "view" }, { "type": "function", - "name": "delete", + "name": "move", "inputs": [ { - "name": "record_id", - "type": "core::integer::u32" + "name": "direction", + "type": "dojo_examples::models::Direction" } ], "outputs": [], @@ -137,45 +229,13 @@ }, { "type": "event", - "name": "types_test::contracts::records::RecordLogged", - "kind": "struct", - "members": [ - { - "name": "record_id", - "type": "core::integer::u32", - "kind": "key" - }, - { - "name": "type_u8", - "type": "core::integer::u8", - "kind": "key" - }, - { - "name": "type_felt", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "random_u128", - "type": "core::integer::u128", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "types_test::contracts::records::Event", + "name": "dojo_examples::actions::actions::Event", "kind": "enum", "variants": [ { "name": "UpgradeableEvent", "type": "dojo::components::upgradeable::upgradeable::Event", "kind": "nested" - }, - { - "name": "RecordLogged", - "type": "types_test::contracts::records::RecordLogged", - "kind": "nested" } ] } diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json b/examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json new file mode 100644 index 0000000000..3cf772f1ca --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json @@ -0,0 +1,866 @@ +[ + { + "type": "impl", + "name": "World", + "interface_name": "dojo::world::IWorld" + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::resource_metadata::ResourceMetadata", + "members": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "metadata_uri", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorld", + "items": [ + { + "type": "function", + "name": "metadata", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "dojo::resource_metadata::ResourceMetadata" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_metadata", + "inputs": [ + { + "name": "metadata", + "type": "dojo::resource_metadata::ResourceMetadata" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "model", + "inputs": [ + { + "name": "name", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "register_model", + "inputs": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "deploy_contract", + "inputs": [ + { + "name": "salt", + "type": "core::felt252" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_contract", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "uuid", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "emit", + "inputs": [ + { + "name": "keys", + "type": "core::array::Array::" + }, + { + "name": "values", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "core::array::Span::" + } + ], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "values", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "base", + "inputs": [], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "delete_entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "is_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "is_writer", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "system", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_writer", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "system", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_writer", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "system", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableWorld", + "interface_name": "dojo::world::IUpgradeableWorld" + }, + { + "type": "interface", + "name": "dojo::world::IUpgradeableWorld", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableState", + "interface_name": "dojo::interfaces::IUpgradeableState" + }, + { + "type": "struct", + "name": "dojo::interfaces::StorageUpdate", + "members": [ + { + "name": "key", + "type": "core::felt252" + }, + { + "name": "value", + "type": "core::felt252" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::interfaces::ProgramOutput", + "members": [ + { + "name": "prev_state_root", + "type": "core::felt252" + }, + { + "name": "new_state_root", + "type": "core::felt252" + }, + { + "name": "block_number", + "type": "core::felt252" + }, + { + "name": "block_hash", + "type": "core::felt252" + }, + { + "name": "config_hash", + "type": "core::felt252" + }, + { + "name": "world_da_hash", + "type": "core::felt252" + }, + { + "name": "message_to_starknet_segment", + "type": "core::array::Span::" + }, + { + "name": "message_to_appchain_segment", + "type": "core::array::Span::" + } + ] + }, + { + "type": "interface", + "name": "dojo::interfaces::IUpgradeableState", + "items": [ + { + "type": "function", + "name": "upgrade_state", + "inputs": [ + { + "name": "new_state", + "type": "core::array::Span::" + }, + { + "name": "program_output", + "type": "dojo::interfaces::ProgramOutput" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "ConfigImpl", + "interface_name": "dojo::config::interface::IConfig" + }, + { + "type": "interface", + "name": "dojo::config::interface::IConfig", + "items": [ + { + "type": "function", + "name": "set_program_hash", + "inputs": [ + { + "name": "program_hash", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "get_program_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_facts_registry", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "get_facts_registry", + "inputs": [], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [ + { + "name": "contract_base", + "type": "core::starknet::class_hash::ClassHash" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WorldSpawned", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "creator", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ContractDeployed", + "kind": "struct", + "members": [ + { + "name": "salt", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ContractUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WorldUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::MetadataUpdate", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "uri", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ModelRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "prev_class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "prev_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StoreSetRecord", + "kind": "struct", + "members": [ + { + "name": "table", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StoreDelRecord", + "kind": "struct", + "members": [ + { + "name": "table", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WriterUpdated", + "kind": "struct", + "members": [ + { + "name": "model", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "system", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::OwnerUpdated", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::ProgramHashUpdate", + "kind": "struct", + "members": [ + { + "name": "program_hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::FactsRegistryUpdate", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::Event", + "kind": "enum", + "variants": [ + { + "name": "ProgramHashUpdate", + "type": "dojo::config::component::Config::ProgramHashUpdate", + "kind": "nested" + }, + { + "name": "FactsRegistryUpdate", + "type": "dojo::config::component::Config::FactsRegistryUpdate", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StateUpdated", + "kind": "struct", + "members": [ + { + "name": "da_hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::Event", + "kind": "enum", + "variants": [ + { + "name": "WorldSpawned", + "type": "dojo::world::world::WorldSpawned", + "kind": "nested" + }, + { + "name": "ContractDeployed", + "type": "dojo::world::world::ContractDeployed", + "kind": "nested" + }, + { + "name": "ContractUpgraded", + "type": "dojo::world::world::ContractUpgraded", + "kind": "nested" + }, + { + "name": "WorldUpgraded", + "type": "dojo::world::world::WorldUpgraded", + "kind": "nested" + }, + { + "name": "MetadataUpdate", + "type": "dojo::world::world::MetadataUpdate", + "kind": "nested" + }, + { + "name": "ModelRegistered", + "type": "dojo::world::world::ModelRegistered", + "kind": "nested" + }, + { + "name": "StoreSetRecord", + "type": "dojo::world::world::StoreSetRecord", + "kind": "nested" + }, + { + "name": "StoreDelRecord", + "type": "dojo::world::world::StoreDelRecord", + "kind": "nested" + }, + { + "name": "WriterUpdated", + "type": "dojo::world::world::WriterUpdated", + "kind": "nested" + }, + { + "name": "OwnerUpdated", + "type": "dojo::world::world::OwnerUpdated", + "kind": "nested" + }, + { + "name": "ConfigEvent", + "type": "dojo::config::component::Config::Event", + "kind": "nested" + }, + { + "name": "StateUpdated", + "type": "dojo::world::world::StateUpdated", + "kind": "nested" + } + ] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_actions_actions_moved.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_actions_actions_moved.json new file mode 100644 index 0000000000..55206aa098 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_actions_actions_moved.json @@ -0,0 +1,239 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IDojoModel" + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, core::array::Span::)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, core::array::Span::)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, core::array::Span::)>" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::>" + }, + { + "name": "Array", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IDojoModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "movedImpl", + "interface_name": "dojo_examples::actions::actions::Imoved" + }, + { + "type": "enum", + "name": "dojo_examples::models::Direction", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::actions::actions::Moved", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "direction", + "type": "dojo_examples::models::Direction" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::actions::actions::Imoved", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::actions::actions::Moved" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::actions::actions::moved::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/crates/torii/types-test/manifests/dev/abis/base/models/types_test_models_record_sibling.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_emote_message.json similarity index 82% rename from crates/torii/types-test/manifests/dev/abis/base/models/types_test_models_record_sibling.json rename to examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_emote_message.json index f72c295cf8..ead98d0724 100644 --- a/crates/torii/types-test/manifests/dev/abis/base/models/types_test_models_record_sibling.json +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_emote_message.json @@ -169,26 +169,52 @@ }, { "type": "impl", - "name": "record_siblingImpl", - "interface_name": "types_test::models::Irecord_sibling" + "name": "emote_messageImpl", + "interface_name": "dojo_examples::models::Iemote_message" + }, + { + "type": "enum", + "name": "dojo_examples::models::Emote", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Happy", + "type": "()" + }, + { + "name": "Sad", + "type": "()" + }, + { + "name": "Angry", + "type": "()" + }, + { + "name": "Love", + "type": "()" + } + ] }, { "type": "struct", - "name": "types_test::models::RecordSibling", + "name": "dojo_examples::models::EmoteMessage", "members": [ { - "name": "record_id", - "type": "core::integer::u32" + "name": "identity", + "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "random_u8", - "type": "core::integer::u8" + "name": "emote", + "type": "dojo_examples::models::Emote" } ] }, { "type": "interface", - "name": "types_test::models::Irecord_sibling", + "name": "dojo_examples::models::Iemote_message", "items": [ { "type": "function", @@ -196,7 +222,7 @@ "inputs": [ { "name": "model", - "type": "types_test::models::RecordSibling" + "type": "dojo_examples::models::EmoteMessage" } ], "outputs": [], @@ -206,7 +232,7 @@ }, { "type": "event", - "name": "types_test::models::record_sibling::Event", + "name": "dojo_examples::models::emote_message::Event", "kind": "enum", "variants": [] } diff --git a/crates/torii/types-test/manifests/dev/abis/base/models/types_test_models_record.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_moves.json similarity index 56% rename from crates/torii/types-test/manifests/dev/abis/base/models/types_test_models_record.json rename to examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_moves.json index e828f0da74..169cbc50ed 100644 --- a/crates/torii/types-test/manifests/dev/abis/base/models/types_test_models_record.json +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_moves.json @@ -169,202 +169,56 @@ }, { "type": "impl", - "name": "recordImpl", - "interface_name": "types_test::models::Irecord" + "name": "movesImpl", + "interface_name": "dojo_examples::models::Imoves" }, { "type": "enum", - "name": "types_test::models::Depth", + "name": "dojo_examples::models::Direction", "variants": [ { - "name": "Zero", + "name": "None", "type": "()" }, { - "name": "One", + "name": "Left", "type": "()" }, { - "name": "Two", + "name": "Right", "type": "()" }, { - "name": "Three", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::integer::u256", - "members": [ - { - "name": "low", - "type": "core::integer::u128" - }, - { - "name": "high", - "type": "core::integer::u128" - } - ] - }, - { - "type": "enum", - "name": "core::bool", - "variants": [ - { - "name": "False", + "name": "Up", "type": "()" }, { - "name": "True", + "name": "Down", "type": "()" } ] }, { "type": "struct", - "name": "types_test::models::NestedMost", - "members": [ - { - "name": "depth", - "type": "types_test::models::Depth" - }, - { - "name": "type_number", - "type": "core::integer::u8" - }, - { - "name": "type_string", - "type": "core::felt252" - } - ] - }, - { - "type": "struct", - "name": "types_test::models::NestedMore", - "members": [ - { - "name": "depth", - "type": "types_test::models::Depth" - }, - { - "name": "type_number", - "type": "core::integer::u8" - }, - { - "name": "type_string", - "type": "core::felt252" - }, - { - "name": "type_nested_most", - "type": "types_test::models::NestedMost" - } - ] - }, - { - "type": "struct", - "name": "types_test::models::Nested", - "members": [ - { - "name": "depth", - "type": "types_test::models::Depth" - }, - { - "name": "type_number", - "type": "core::integer::u8" - }, - { - "name": "type_string", - "type": "core::felt252" - }, - { - "name": "type_nested_more", - "type": "types_test::models::NestedMore" - } - ] - }, - { - "type": "struct", - "name": "types_test::models::Record", + "name": "dojo_examples::models::Moves", "members": [ { - "name": "record_id", - "type": "core::integer::u32" - }, - { - "name": "depth", - "type": "types_test::models::Depth" - }, - { - "name": "type_u8", - "type": "core::integer::u8" - }, - { - "name": "type_u16", - "type": "core::integer::u16" - }, - { - "name": "type_u32", - "type": "core::integer::u32" - }, - { - "name": "type_u64", - "type": "core::integer::u64" - }, - { - "name": "type_u128", - "type": "core::integer::u128" - }, - { - "name": "type_u256", - "type": "core::integer::u256" - }, - { - "name": "type_bool", - "type": "core::bool" - }, - { - "name": "type_felt", - "type": "core::felt252" - }, - { - "name": "type_class_hash", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "type_contract_address", + "name": "player", "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "type_deeply_nested", - "type": "types_test::models::Nested" - }, - { - "name": "type_nested_one", - "type": "types_test::models::NestedMost" - }, - { - "name": "type_nested_two", - "type": "types_test::models::NestedMost" - }, - { - "name": "random_u8", + "name": "remaining", "type": "core::integer::u8" }, { - "name": "random_u128", - "type": "core::integer::u128" - }, - { - "name": "composite_u256", - "type": "core::integer::u256" + "name": "last_direction", + "type": "dojo_examples::models::Direction" } ] }, { "type": "interface", - "name": "types_test::models::Irecord", + "name": "dojo_examples::models::Imoves", "items": [ { "type": "function", @@ -372,7 +226,7 @@ "inputs": [ { "name": "model", - "type": "types_test::models::Record" + "type": "dojo_examples::models::Moves" } ], "outputs": [], @@ -382,7 +236,7 @@ }, { "type": "event", - "name": "types_test::models::record::Event", + "name": "dojo_examples::models::moves::Event", "kind": "enum", "variants": [] } diff --git a/crates/torii/types-test/manifests/dev/abis/base/models/types_test_models_subrecord.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_position.json similarity index 87% rename from crates/torii/types-test/manifests/dev/abis/base/models/types_test_models_subrecord.json rename to examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_position.json index 97938e7cc3..9b6466644a 100644 --- a/crates/torii/types-test/manifests/dev/abis/base/models/types_test_models_subrecord.json +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_position.json @@ -169,34 +169,40 @@ }, { "type": "impl", - "name": "subrecordImpl", - "interface_name": "types_test::models::Isubrecord" + "name": "positionImpl", + "interface_name": "dojo_examples::models::Iposition" }, { "type": "struct", - "name": "types_test::models::Subrecord", + "name": "dojo_examples::models::Vec2", "members": [ { - "name": "record_id", + "name": "x", "type": "core::integer::u32" }, { - "name": "subrecord_id", + "name": "y", "type": "core::integer::u32" - }, + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::Position", + "members": [ { - "name": "type_u8", - "type": "core::integer::u8" + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "random_u8", - "type": "core::integer::u8" + "name": "vec", + "type": "dojo_examples::models::Vec2" } ] }, { "type": "interface", - "name": "types_test::models::Isubrecord", + "name": "dojo_examples::models::Iposition", "items": [ { "type": "function", @@ -204,7 +210,7 @@ "inputs": [ { "name": "model", - "type": "types_test::models::Subrecord" + "type": "dojo_examples::models::Position" } ], "outputs": [], @@ -214,7 +220,7 @@ }, { "type": "event", - "name": "types_test::models::subrecord::Event", + "name": "dojo_examples::models::position::Event", "kind": "enum", "variants": [] } diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml index 4047d46932..3683efb281 100644 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml +++ b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml @@ -1,6 +1,6 @@ kind = "DojoContract" -class_hash = "0x471a1a36581d24f68ae6984c714daa75d424c0a6581872a65e645eb11a8e45" -original_class_hash = "0x471a1a36581d24f68ae6984c714daa75d424c0a6581872a65e645eb11a8e45" +class_hash = "0x491920188044edfc9bb9ba1d0f989b10e9791d91089a6a98413f5dbf54579cb" +original_class_hash = "0x491920188044edfc9bb9ba1d0f989b10e9791d91089a6a98413f5dbf54579cb" base_class_hash = "0x0" abi = "manifests/dev/abis/base/contracts/dojo_examples_actions_actions.json" reads = [] diff --git a/examples/spawn-and-move/manifests/dev/base/dojo_base_base.toml b/examples/spawn-and-move/manifests/dev/base/dojo_base_base.toml index d926bca4d7..6c4b5de67e 100644 --- a/examples/spawn-and-move/manifests/dev/base/dojo_base_base.toml +++ b/examples/spawn-and-move/manifests/dev/base/dojo_base_base.toml @@ -1,4 +1,4 @@ kind = "Class" -class_hash = "0x679177a2cb757694ac4f326d01052ff0963eac0bc2a17116a2b87badcdf6f76" -original_class_hash = "0x679177a2cb757694ac4f326d01052ff0963eac0bc2a17116a2b87badcdf6f76" +class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" +original_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" name = "dojo::base::base" diff --git a/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml b/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml index 0b131a3405..d9220cfb88 100644 --- a/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml +++ b/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x5a8881181fc47d7cba049ce2861ce9327f33e04827d70233e22ce218a947ccf" -original_class_hash = "0x5a8881181fc47d7cba049ce2861ce9327f33e04827d70233e22ce218a947ccf" +class_hash = "0x301ba8a1a13cec9291b049dea531f73a600e0812908cefa26d17214da411e9c" +original_class_hash = "0x301ba8a1a13cec9291b049dea531f73a600e0812908cefa26d17214da411e9c" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml index 51827417b0..7550c92bc0 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x52659850f9939482810d9f6b468b91dc99e0b7fa42c2016cf12833ec06ce911" -original_class_hash = "0x52659850f9939482810d9f6b468b91dc99e0b7fa42c2016cf12833ec06ce911" +class_hash = "0x91e05e8691a82229a17cf2b9b01b6f339fe704550151786b65734f0a9e45f1" +original_class_hash = "0x91e05e8691a82229a17cf2b9b01b6f339fe704550151786b65734f0a9e45f1" abi = "manifests/dev/abis/base/models/dojo_examples_actions_actions_moved.json" name = "dojo_examples::actions::actions::moved" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml index 00aca3ebdc..2a19271dda 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x6d5aef0819f5267c840c57d37ff774b4e185fc7da4a10e58cb9f575aa2ed1c" -original_class_hash = "0x6d5aef0819f5267c840c57d37ff774b4e185fc7da4a10e58cb9f575aa2ed1c" +class_hash = "0x1080134c112da75344e02e4a6a9629778f5b7c0bf3f81055f1304bf75acaf75" +original_class_hash = "0x1080134c112da75344e02e4a6a9629778f5b7c0bf3f81055f1304bf75acaf75" abi = "manifests/dev/abis/base/models/dojo_examples_models_emote_message.json" name = "dojo_examples::models::emote_message" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml index 31bb7ff6cc..f1cf92b2de 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x511fbd833938f5c4b743eea1e67605a125d7ff60e8a09e8dc227ad2fb59ca54" -original_class_hash = "0x511fbd833938f5c4b743eea1e67605a125d7ff60e8a09e8dc227ad2fb59ca54" +class_hash = "0x2e9c87df132573ed64a84b5d18059ba86cabef0ae0a4ccd211ce90ecb3dfce3" +original_class_hash = "0x2e9c87df132573ed64a84b5d18059ba86cabef0ae0a4ccd211ce90ecb3dfce3" abi = "manifests/dev/abis/base/models/dojo_examples_models_moves.json" name = "dojo_examples::models::moves" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml index 8721663cef..59658d030f 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0xb33ae053213ccb2a57967ffc4411901f3efab24781ca867adcd0b90f2fece5" -original_class_hash = "0xb33ae053213ccb2a57967ffc4411901f3efab24781ca867adcd0b90f2fece5" +class_hash = "0x151d4e1655053bc12c41f2e46ff6cb740c024320f129d92331cb1d2e59e4aa3" +original_class_hash = "0x151d4e1655053bc12c41f2e46ff6cb740c024320f129d92331cb1d2e59e4aa3" abi = "manifests/dev/abis/base/models/dojo_examples_models_position.json" name = "dojo_examples::models::position" diff --git a/examples/spawn-and-move/manifests/dev/manifest.json b/examples/spawn-and-move/manifests/dev/manifest.json new file mode 100644 index 0000000000..8ae88a22e3 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/manifest.json @@ -0,0 +1,2171 @@ +{ + "world": { + "kind": "WorldContract", + "class_hash": "0x301ba8a1a13cec9291b049dea531f73a600e0812908cefa26d17214da411e9c", + "original_class_hash": "0x301ba8a1a13cec9291b049dea531f73a600e0812908cefa26d17214da411e9c", + "abi": [ + { + "type": "impl", + "name": "World", + "interface_name": "dojo::world::IWorld" + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::resource_metadata::ResourceMetadata", + "members": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "metadata_uri", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorld", + "items": [ + { + "type": "function", + "name": "metadata", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "dojo::resource_metadata::ResourceMetadata" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_metadata", + "inputs": [ + { + "name": "metadata", + "type": "dojo::resource_metadata::ResourceMetadata" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "model", + "inputs": [ + { + "name": "name", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "register_model", + "inputs": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "deploy_contract", + "inputs": [ + { + "name": "salt", + "type": "core::felt252" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_contract", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "uuid", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "emit", + "inputs": [ + { + "name": "keys", + "type": "core::array::Array::" + }, + { + "name": "values", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "core::array::Span::" + } + ], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "values", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "base", + "inputs": [], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "delete_entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "is_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "is_writer", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "system", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_writer", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "system", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_writer", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "system", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableWorld", + "interface_name": "dojo::world::IUpgradeableWorld" + }, + { + "type": "interface", + "name": "dojo::world::IUpgradeableWorld", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableState", + "interface_name": "dojo::interfaces::IUpgradeableState" + }, + { + "type": "struct", + "name": "dojo::interfaces::StorageUpdate", + "members": [ + { + "name": "key", + "type": "core::felt252" + }, + { + "name": "value", + "type": "core::felt252" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::interfaces::ProgramOutput", + "members": [ + { + "name": "prev_state_root", + "type": "core::felt252" + }, + { + "name": "new_state_root", + "type": "core::felt252" + }, + { + "name": "block_number", + "type": "core::felt252" + }, + { + "name": "block_hash", + "type": "core::felt252" + }, + { + "name": "config_hash", + "type": "core::felt252" + }, + { + "name": "world_da_hash", + "type": "core::felt252" + }, + { + "name": "message_to_starknet_segment", + "type": "core::array::Span::" + }, + { + "name": "message_to_appchain_segment", + "type": "core::array::Span::" + } + ] + }, + { + "type": "interface", + "name": "dojo::interfaces::IUpgradeableState", + "items": [ + { + "type": "function", + "name": "upgrade_state", + "inputs": [ + { + "name": "new_state", + "type": "core::array::Span::" + }, + { + "name": "program_output", + "type": "dojo::interfaces::ProgramOutput" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "ConfigImpl", + "interface_name": "dojo::config::interface::IConfig" + }, + { + "type": "interface", + "name": "dojo::config::interface::IConfig", + "items": [ + { + "type": "function", + "name": "set_program_hash", + "inputs": [ + { + "name": "program_hash", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "get_program_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_facts_registry", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "get_facts_registry", + "inputs": [], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [ + { + "name": "contract_base", + "type": "core::starknet::class_hash::ClassHash" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WorldSpawned", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "creator", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ContractDeployed", + "kind": "struct", + "members": [ + { + "name": "salt", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ContractUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WorldUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::MetadataUpdate", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "uri", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ModelRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "prev_class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "prev_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StoreSetRecord", + "kind": "struct", + "members": [ + { + "name": "table", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StoreDelRecord", + "kind": "struct", + "members": [ + { + "name": "table", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WriterUpdated", + "kind": "struct", + "members": [ + { + "name": "model", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "system", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::OwnerUpdated", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::ProgramHashUpdate", + "kind": "struct", + "members": [ + { + "name": "program_hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::FactsRegistryUpdate", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::Event", + "kind": "enum", + "variants": [ + { + "name": "ProgramHashUpdate", + "type": "dojo::config::component::Config::ProgramHashUpdate", + "kind": "nested" + }, + { + "name": "FactsRegistryUpdate", + "type": "dojo::config::component::Config::FactsRegistryUpdate", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StateUpdated", + "kind": "struct", + "members": [ + { + "name": "da_hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::Event", + "kind": "enum", + "variants": [ + { + "name": "WorldSpawned", + "type": "dojo::world::world::WorldSpawned", + "kind": "nested" + }, + { + "name": "ContractDeployed", + "type": "dojo::world::world::ContractDeployed", + "kind": "nested" + }, + { + "name": "ContractUpgraded", + "type": "dojo::world::world::ContractUpgraded", + "kind": "nested" + }, + { + "name": "WorldUpgraded", + "type": "dojo::world::world::WorldUpgraded", + "kind": "nested" + }, + { + "name": "MetadataUpdate", + "type": "dojo::world::world::MetadataUpdate", + "kind": "nested" + }, + { + "name": "ModelRegistered", + "type": "dojo::world::world::ModelRegistered", + "kind": "nested" + }, + { + "name": "StoreSetRecord", + "type": "dojo::world::world::StoreSetRecord", + "kind": "nested" + }, + { + "name": "StoreDelRecord", + "type": "dojo::world::world::StoreDelRecord", + "kind": "nested" + }, + { + "name": "WriterUpdated", + "type": "dojo::world::world::WriterUpdated", + "kind": "nested" + }, + { + "name": "OwnerUpdated", + "type": "dojo::world::world::OwnerUpdated", + "kind": "nested" + }, + { + "name": "ConfigEvent", + "type": "dojo::config::component::Config::Event", + "kind": "nested" + }, + { + "name": "StateUpdated", + "type": "dojo::world::world::StateUpdated", + "kind": "nested" + } + ] + } + ], + "address": "0x3898144a24151443f0c6501a1de46a6e9e27abd9fb5d08cdeeff5a5127d1d25", + "transaction_hash": "0x6c620a196cd78de62d766898b7a1deaf10b428471b5fb525a137d2d06e63490", + "block_number": 3, + "seed": "dojo_examples", + "metadata": { + "profile_name": "dev", + "rpc_url": "http://localhost:5050/" + }, + "name": "dojo::world::world" + }, + "base": { + "kind": "Class", + "class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", + "original_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", + "abi": null, + "name": "dojo::base::base" + }, + "contracts": [ + { + "kind": "DojoContract", + "address": "0x7361d19c9541e464a15a4cf1aa0d1d155f4982f6ec9bdf6fb6fa1d812ddda9f", + "class_hash": "0x491920188044edfc9bb9ba1d0f989b10e9791d91089a6a98413f5dbf54579cb", + "original_class_hash": "0x491920188044edfc9bb9ba1d0f989b10e9791d91089a6a98413f5dbf54579cb", + "base_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", + "abi": [ + { + "type": "impl", + "name": "DojoResourceProviderImpl", + "interface_name": "dojo::world::IDojoResourceProvider" + }, + { + "type": "interface", + "name": "dojo::world::IDojoResourceProvider", + "items": [ + { + "type": "function", + "name": "dojo_resource", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::world::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "ActionsComputedImpl", + "interface_name": "dojo_examples::actions::IActionsComputed" + }, + { + "type": "struct", + "name": "dojo_examples::models::Vec2", + "members": [ + { + "name": "x", + "type": "core::integer::u32" + }, + { + "name": "y", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::Position", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "vec", + "type": "dojo_examples::models::Vec2" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::actions::IActionsComputed", + "items": [ + { + "type": "function", + "name": "tile_terrain", + "inputs": [ + { + "name": "vec", + "type": "dojo_examples::models::Vec2" + } + ], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "quadrant", + "inputs": [ + { + "name": "pos", + "type": "dojo_examples::models::Position" + } + ], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "ActionsImpl", + "interface_name": "dojo_examples::actions::IActions" + }, + { + "type": "enum", + "name": "dojo_examples::models::Direction", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::actions::IActions", + "items": [ + { + "type": "function", + "name": "spawn", + "inputs": [], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "move", + "inputs": [ + { + "name": "direction", + "type": "dojo_examples::models::Direction" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradableImpl", + "interface_name": "dojo::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::actions::actions::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::components::upgradeable::upgradeable::Event", + "kind": "nested" + } + ] + } + ], + "reads": [], + "writes": [], + "computed": [], + "name": "dojo_examples::actions::actions" + } + ], + "models": [ + { + "kind": "DojoModel", + "members": [ + { + "name": "player", + "type": "ContractAddress", + "key": true + }, + { + "name": "direction", + "type": "Direction", + "key": false + } + ], + "class_hash": "0x91e05e8691a82229a17cf2b9b01b6f339fe704550151786b65734f0a9e45f1", + "original_class_hash": "0x91e05e8691a82229a17cf2b9b01b6f339fe704550151786b65734f0a9e45f1", + "abi": [ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IDojoModel" + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, core::array::Span::)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, core::array::Span::)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, core::array::Span::)>" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::>" + }, + { + "name": "Array", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IDojoModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "movedImpl", + "interface_name": "dojo_examples::actions::actions::Imoved" + }, + { + "type": "enum", + "name": "dojo_examples::models::Direction", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::actions::actions::Moved", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "direction", + "type": "dojo_examples::models::Direction" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::actions::actions::Imoved", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::actions::actions::Moved" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::actions::actions::moved::Event", + "kind": "enum", + "variants": [] + } + ], + "name": "dojo_examples::actions::actions::moved" + }, + { + "kind": "DojoModel", + "members": [ + { + "name": "identity", + "type": "ContractAddress", + "key": true + }, + { + "name": "emote", + "type": "Emote", + "key": false + } + ], + "class_hash": "0x1080134c112da75344e02e4a6a9629778f5b7c0bf3f81055f1304bf75acaf75", + "original_class_hash": "0x1080134c112da75344e02e4a6a9629778f5b7c0bf3f81055f1304bf75acaf75", + "abi": [ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IDojoModel" + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, core::array::Span::)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, core::array::Span::)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, core::array::Span::)>" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::>" + }, + { + "name": "Array", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IDojoModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "emote_messageImpl", + "interface_name": "dojo_examples::models::Iemote_message" + }, + { + "type": "enum", + "name": "dojo_examples::models::Emote", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Happy", + "type": "()" + }, + { + "name": "Sad", + "type": "()" + }, + { + "name": "Angry", + "type": "()" + }, + { + "name": "Love", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::EmoteMessage", + "members": [ + { + "name": "identity", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "emote", + "type": "dojo_examples::models::Emote" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::models::Iemote_message", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::models::EmoteMessage" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::models::emote_message::Event", + "kind": "enum", + "variants": [] + } + ], + "name": "dojo_examples::models::emote_message" + }, + { + "kind": "DojoModel", + "members": [ + { + "name": "player", + "type": "ContractAddress", + "key": true + }, + { + "name": "remaining", + "type": "u8", + "key": false + }, + { + "name": "last_direction", + "type": "Direction", + "key": false + } + ], + "class_hash": "0x2e9c87df132573ed64a84b5d18059ba86cabef0ae0a4ccd211ce90ecb3dfce3", + "original_class_hash": "0x2e9c87df132573ed64a84b5d18059ba86cabef0ae0a4ccd211ce90ecb3dfce3", + "abi": [ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IDojoModel" + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, core::array::Span::)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, core::array::Span::)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, core::array::Span::)>" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::>" + }, + { + "name": "Array", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IDojoModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "movesImpl", + "interface_name": "dojo_examples::models::Imoves" + }, + { + "type": "enum", + "name": "dojo_examples::models::Direction", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::Moves", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "remaining", + "type": "core::integer::u8" + }, + { + "name": "last_direction", + "type": "dojo_examples::models::Direction" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::models::Imoves", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::models::Moves" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::models::moves::Event", + "kind": "enum", + "variants": [] + } + ], + "name": "dojo_examples::models::moves" + }, + { + "kind": "DojoModel", + "members": [ + { + "name": "player", + "type": "ContractAddress", + "key": true + }, + { + "name": "vec", + "type": "Vec2", + "key": false + } + ], + "class_hash": "0x151d4e1655053bc12c41f2e46ff6cb740c024320f129d92331cb1d2e59e4aa3", + "original_class_hash": "0x151d4e1655053bc12c41f2e46ff6cb740c024320f129d92331cb1d2e59e4aa3", + "abi": [ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IDojoModel" + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, core::array::Span::)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, core::array::Span::)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, core::array::Span::)>" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::>" + }, + { + "name": "Array", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IDojoModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "positionImpl", + "interface_name": "dojo_examples::models::Iposition" + }, + { + "type": "struct", + "name": "dojo_examples::models::Vec2", + "members": [ + { + "name": "x", + "type": "core::integer::u32" + }, + { + "name": "y", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::Position", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "vec", + "type": "dojo_examples::models::Vec2" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::models::Iposition", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::models::Position" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::models::position::Event", + "kind": "enum", + "variants": [] + } + ], + "name": "dojo_examples::models::position" + } + ] +} \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/manifest.toml b/examples/spawn-and-move/manifests/dev/manifest.toml index 144ec93f18..aecefde674 100644 --- a/examples/spawn-and-move/manifests/dev/manifest.toml +++ b/examples/spawn-and-move/manifests/dev/manifest.toml @@ -1,10 +1,10 @@ [world] kind = "WorldContract" -class_hash = "0x799bc4e9da10bfb3dd88e6f223c9cfbf7745435cd14f5d69675ea448e578cd" -original_class_hash = "0x799bc4e9da10bfb3dd88e6f223c9cfbf7745435cd14f5d69675ea448e578cd" +class_hash = "0x301ba8a1a13cec9291b049dea531f73a600e0812908cefa26d17214da411e9c" +original_class_hash = "0x301ba8a1a13cec9291b049dea531f73a600e0812908cefa26d17214da411e9c" abi = "manifests/dev/abis/deployments/dojo_world_world.json" -address = "0x1385f25d20a724edc9c7b3bd9636c59af64cbaf9fcd12f33b3af96b2452f295" -transaction_hash = "0x6afefdcc49b3563a4f3657900ba71e9f9356861b15b942a73f2018f046a1048" +address = "0x3898144a24151443f0c6501a1de46a6e9e27abd9fb5d08cdeeff5a5127d1d25" +transaction_hash = "0x6c620a196cd78de62d766898b7a1deaf10b428471b5fb525a137d2d06e63490" block_number = 3 seed = "dojo_examples" name = "dojo::world::world" @@ -15,16 +15,16 @@ rpc_url = "http://localhost:5050/" [base] kind = "Class" -class_hash = "0x679177a2cb757694ac4f326d01052ff0963eac0bc2a17116a2b87badcdf6f76" -original_class_hash = "0x679177a2cb757694ac4f326d01052ff0963eac0bc2a17116a2b87badcdf6f76" +class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" +original_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" name = "dojo::base::base" [[contracts]] kind = "DojoContract" -address = "0x3539c9b89b08095ba914653fb0f20e55d4b172a415beade611bc260b346d0f7" -class_hash = "0x471a1a36581d24f68ae6984c714daa75d424c0a6581872a65e645eb11a8e45" -original_class_hash = "0x471a1a36581d24f68ae6984c714daa75d424c0a6581872a65e645eb11a8e45" -base_class_hash = "0x679177a2cb757694ac4f326d01052ff0963eac0bc2a17116a2b87badcdf6f76" +address = "0x7361d19c9541e464a15a4cf1aa0d1d155f4982f6ec9bdf6fb6fa1d812ddda9f" +class_hash = "0x491920188044edfc9bb9ba1d0f989b10e9791d91089a6a98413f5dbf54579cb" +original_class_hash = "0x491920188044edfc9bb9ba1d0f989b10e9791d91089a6a98413f5dbf54579cb" +base_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" abi = "manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json" reads = [] writes = [] @@ -33,8 +33,8 @@ name = "dojo_examples::actions::actions" [[models]] kind = "DojoModel" -class_hash = "0x52659850f9939482810d9f6b468b91dc99e0b7fa42c2016cf12833ec06ce911" -original_class_hash = "0x52659850f9939482810d9f6b468b91dc99e0b7fa42c2016cf12833ec06ce911" +class_hash = "0x91e05e8691a82229a17cf2b9b01b6f339fe704550151786b65734f0a9e45f1" +original_class_hash = "0x91e05e8691a82229a17cf2b9b01b6f339fe704550151786b65734f0a9e45f1" abi = "manifests/dev/abis/deployments/models/dojo_examples_actions_actions_moved.json" name = "dojo_examples::actions::actions::moved" @@ -50,8 +50,8 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x6d5aef0819f5267c840c57d37ff774b4e185fc7da4a10e58cb9f575aa2ed1c" -original_class_hash = "0x6d5aef0819f5267c840c57d37ff774b4e185fc7da4a10e58cb9f575aa2ed1c" +class_hash = "0x1080134c112da75344e02e4a6a9629778f5b7c0bf3f81055f1304bf75acaf75" +original_class_hash = "0x1080134c112da75344e02e4a6a9629778f5b7c0bf3f81055f1304bf75acaf75" abi = "manifests/dev/abis/deployments/models/dojo_examples_models_emote_message.json" name = "dojo_examples::models::emote_message" @@ -67,8 +67,8 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x511fbd833938f5c4b743eea1e67605a125d7ff60e8a09e8dc227ad2fb59ca54" -original_class_hash = "0x511fbd833938f5c4b743eea1e67605a125d7ff60e8a09e8dc227ad2fb59ca54" +class_hash = "0x2e9c87df132573ed64a84b5d18059ba86cabef0ae0a4ccd211ce90ecb3dfce3" +original_class_hash = "0x2e9c87df132573ed64a84b5d18059ba86cabef0ae0a4ccd211ce90ecb3dfce3" abi = "manifests/dev/abis/deployments/models/dojo_examples_models_moves.json" name = "dojo_examples::models::moves" @@ -89,8 +89,8 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0xb33ae053213ccb2a57967ffc4411901f3efab24781ca867adcd0b90f2fece5" -original_class_hash = "0xb33ae053213ccb2a57967ffc4411901f3efab24781ca867adcd0b90f2fece5" +class_hash = "0x151d4e1655053bc12c41f2e46ff6cb740c024320f129d92331cb1d2e59e4aa3" +original_class_hash = "0x151d4e1655053bc12c41f2e46ff6cb740c024320f129d92331cb1d2e59e4aa3" abi = "manifests/dev/abis/deployments/models/dojo_examples_models_position.json" name = "dojo_examples::models::position" diff --git a/examples/spawn-and-move/src/actions.cairo b/examples/spawn-and-move/src/actions.cairo index 647109738b..390317b62f 100644 --- a/examples/spawn-and-move/src/actions.cairo +++ b/examples/spawn-and-move/src/actions.cairo @@ -62,13 +62,11 @@ mod actions { fn spawn(world: IWorldDispatcher) { let player = get_caller_address(); let position = get!(world, player, (Position)); - + set!( world, ( - Moves { - player, remaining: 99, last_direction: Direction::None(()) - }, + Moves { player, remaining: 99, last_direction: Direction::None(()) }, Position { player, vec: Vec2 { x: position.vec.x + 10, y: position.vec.y + 10 } }, diff --git a/monitoring/prometheus/config.yml b/monitoring/prometheus/config.yml index 4fedc3b0c6..ae46f93b13 100644 --- a/monitoring/prometheus/config.yml +++ b/monitoring/prometheus/config.yml @@ -1,6 +1,6 @@ scrape_configs: - - job_name: katana - metrics_path: "/" - scrape_interval: 5s - static_configs: - - targets: ["localhost:9100"] + - job_name: katana + metrics_path: "/" + scrape_interval: 5s + static_configs: + - targets: ["localhost:9100"] diff --git a/scripts/cairo_fmt.sh b/scripts/cairo_fmt.sh index 99445a4f49..3c3dad52b6 100755 --- a/scripts/cairo_fmt.sh +++ b/scripts/cairo_fmt.sh @@ -1,3 +1,4 @@ #!/bin/bash -cairo-format --recursive . --check \ No newline at end of file +scarb --manifest-path examples/spawn-and-move/Scarb.toml fmt --check +scarb --manifest-path crates/dojo-core/Scarb.toml fmt --check diff --git a/scripts/clippy.sh b/scripts/clippy.sh index dc726f10b9..5453b4129e 100755 --- a/scripts/clippy.sh +++ b/scripts/clippy.sh @@ -15,4 +15,5 @@ run_clippy --all-features --workspace --exclude katana --exclude katana-executor run_clippy -p katana-executor --all run_clippy -p katana -run_clippy -p katana --no-default-features --features sir +# TODO(kariy): uncomment this line when the `sir` support Cairo 2.6.3 +# run_clippy -p katana --no-default-features --features sir diff --git a/scripts/prettier.sh b/scripts/prettier.sh new file mode 100644 index 0000000000..adada3aabd --- /dev/null +++ b/scripts/prettier.sh @@ -0,0 +1,6 @@ +#/bin/bash + +# Formats all the markdown and yaml files in the repository. + +prettier --check "**/*.md" +prettier --check "**/*.{yaml,yml}" diff --git a/scripts/rebuild_test_artifacts.sh b/scripts/rebuild_test_artifacts.sh new file mode 100644 index 0000000000..8170327125 --- /dev/null +++ b/scripts/rebuild_test_artifacts.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# When tests are run, the `build.rs` of `dojo-test-utils` is re-building the +# cairo artifacts ONLY if they don't exist. +# This script gives an easy way to remove those artifacts. + +# A Katana instance must be running on http://localhost:8000. +# cargo run --bin katana + +# Cleanup +rm -rf examples/spawn-and-move/target +rm -rf examples/spawn-and-move/manifests + +rm -rf crates/torii/types-test/target +rm -rf crates/torii/types-test/manifests + +# Fix the cairo test to re-generate the code that is expected to be tested. +CAIRO_FIX_TESTS=1 cargo test --package dojo-lang plugin && \ +CAIRO_FIX_TESTS=1 cargo test --package dojo-lang semantics + +# Re-run the minimal tests, this will re-build the projects + generate the build artifacts. +cargo run -r --bin sozo -- build --manifest-path examples/spawn-and-move/Scarb.toml +cargo run -r --bin sozo -- build --manifest-path crates/torii/types-test/Scarb.toml + +# Finally, to include all the examples manifest, you should re-deploy the examples. +cargo run -r --bin sozo -- --offline migrate apply --manifest-path examples/spawn-and-move/Scarb.toml diff --git a/scripts/teardown_test_artifacts.sh b/scripts/teardown_test_artifacts.sh deleted file mode 100644 index 8dec13caf1..0000000000 --- a/scripts/teardown_test_artifacts.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# When tests are run, the `build.rs` of `dojo-test-utils` is re-building the -# cairo artifacts ONLY if they don't exist. -# This script gives an easy way to remove those artifacts. - -rm -rf examples/spawn-and-move/target -rm -rf examples/spawn-and-move/manifests - -rm -rf crates/torii/types-test/target -rm -rf crates/torii/types-test/manifests