From 6d017f9e7e0e6e6209578833268b3d61cbe331d1 Mon Sep 17 00:00:00 2001 From: Mathieu <60658558+enitrat@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:56:38 +0800 Subject: [PATCH] feat: update to latest sequencer with Native support (#768) * wip: cairo native * use contract executor * update cargo * unskip eip1559 for repro * update to llvm 19 * update remote * bump gas limits * restore skipfile * make tests not quiet * update used rev * fix rev * reduce max steps * nocapture to have more logs in CI * bump native * downgrade native to main * bump native * bump native * latest native main * remove blockchain-skipped tests * bump native * bump native * fix build * bump native * bump cairo * bump native * idk * bump native * bump native * bump native * bump cargo * bump native * fix sequencer build * debug ram only on macos targets * bump native * bump native * bump cairo * custom macro to track long tests * update to latest sequencer * update on main * fix ef-testing crate * restore native feature * bump sequencer to get proper versioned constant parsing * add required dependencies for native build * checkout before using composite actions * make llvm deps in path * fix workflow * install LLVM in action instead of sh script * bump sequencer dep for proper support of serde * fix trunk * remove old llvm in ci * set LLVM_CONFIG var to llvm-19 * add llvm bin to path * apply suggestions --- .cargo/config.toml | 20 + .github/workflows/ci.yml | 88 ++- .github/workflows/test.yml | 55 -- .github/workflows/trunk-check.yml | 29 - .gitignore | 2 + Cargo.lock | 713 +++++++++++++++--- Cargo.toml | 15 +- Makefile | 4 + crates/build-utils/src/converter.rs | 5 +- crates/ef-testing/Cargo.toml | 2 + .../src/evm_sequencer/account/mod.rs | 8 +- .../ef-testing/src/evm_sequencer/constants.rs | 28 +- .../src/evm_sequencer/evm_state/mod.rs | 16 +- .../src/evm_sequencer/sequencer/mod.rs | 54 +- .../resources/versioned_constants.json | 197 +++-- crates/ef-testing/src/models/result.rs | 63 +- crates/ef-testing/src/test_utils/mod.rs | 76 ++ crates/sequencer/Cargo.toml | 7 + crates/sequencer/src/commit.rs | 8 +- crates/sequencer/src/lib.rs | 1 + crates/sequencer/src/native.rs | 105 +++ .../src/resources/versioned_constants.json | 197 +++-- crates/sequencer/src/sequencer.rs | 106 ++- crates/sequencer/src/serde.rs | 10 +- crates/sequencer/src/state.rs | 33 +- crates/sequencer/src/transaction.rs | 58 +- rust-toolchain | 2 +- scripts/dependencies.sh | 60 ++ 28 files changed, 1429 insertions(+), 533 deletions(-) create mode 100644 .cargo/config.toml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/trunk-check.yml create mode 100644 crates/sequencer/src/native.rs create mode 100644 scripts/dependencies.sh diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..c06c6e3e --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,20 @@ +# Required to have the proper environment variables set to +# build the starkware-libs/sequencer dependencies with Native mode. + +[env] +CAIRO_NATIVE_RUNTIME_LIBRARY = "./libcairo_native_runtime.a" + +# Use `lld` for linking instead of `ld`, since we run out of memory while linking with `ld` on +# 16-cores linux machines, see: +# https://nnethercote.github.io/perf-book/build-configuration.html#linking. +# TODO: remove this once `rust` stabilizes `lld` as the default linker, currently only on nightly: +# https://github.com/rust-lang/rust/issues/39915#issuecomment-618726211 +[target.x86_64-unknown-linux-gnu] +rustflags = ["-Clink-arg=-fuse-ld=lld"] +env = { "MLIR_SYS_190_PREFIX" = "/usr/lib/llvm-19", "LLVM_SYS_191_PREFIX" = "/usr/lib/llvm-19", "TABLEGEN_190_PREFIX" = "/usr/lib/llvm-19", "CAIRO_NATIVE_RUNTIME_LIBRARY" = "./libcairo_native_runtime.a" } + +[target.x86_64-apple-darwin] +env = { "LIBRARY_PATH" = "/opt/homebrew/lib", "MLIR_SYS_190_PREFIX" = "/opt/homebrew/opt/llvm@19", "LLVM_SYS_191_PREFIX" = "/opt/homebrew/opt/llvm@19", "TABLEGEN_190_PREFIX" = "/opt/homebrew/opt/llvm@19", "CAIRO_NATIVE_RUNTIME_LIBRARY" = "./libcairo_native_runtime.a" } + +[target.aarch64-apple-darwin] +env = { "LIBRARY_PATH" = "/opt/homebrew/lib", "MLIR_SYS_190_PREFIX" = "/opt/homebrew/opt/llvm@19", "LLVM_SYS_191_PREFIX" = "/opt/homebrew/opt/llvm@19", "TABLEGEN_190_PREFIX" = "/opt/homebrew/opt/llvm@19", "CAIRO_NATIVE_RUNTIME_LIBRARY" = "./libcairo_native_runtime.a" } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 376dd07e..a71cc072 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,8 @@ --- name: Workflow - CI +# trunk-ignore-all(checkov/CKV2_GHA_1) + on: push: branches: [main] @@ -8,16 +10,86 @@ on: branches: - main -permissions: read-all - jobs: trunk: - name: Trunk - uses: ./.github/workflows/trunk-check.yml - permissions: - checks: write - contents: read + runs-on: ubuntu-24.04 + env: + MLIR_SYS_190_PREFIX: /usr/lib/llvm-19/ + LLVM_SYS_191_PREFIX: /usr/lib/llvm-19/ + TABLEGEN_190_PREFIX: /usr/lib/llvm-19/ + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.82.0 + with: + components: clippy, rustfmt + - uses: Swatinem/rust-cache@v2 + - name: add llvm deb repository + uses: myci-actions/add-deb-repo@11 + with: + repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main + repo-name: llvm-repo + keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key + - name: Update and upgrade APT + shell: bash + run: sudo apt-get update && sudo apt-get upgrade -y + - name: Install LLVM + run: + sudo apt-get install llvm-19 llvm-19-dev llvm-19-runtime clang-19 + clang-tools-19 lld-19 libpolly-19-dev libmlir-19-dev mlir-19-tools + libgmp3-dev libzstd-dev lld libssl-dev zstd + - name: Add llvm bin to PATH + run: echo "/usr/lib/llvm-19/bin" >> $GITHUB_PATH + - name: Trunk Check + uses: trunk-io/trunk-action@v1.1.19 tests: name: Rust tests - uses: ./.github/workflows/test.yml + runs-on: ubuntu-latest-16-cores + env: + MLIR_SYS_190_PREFIX: /usr/lib/llvm-19/ + LLVM_SYS_191_PREFIX: /usr/lib/llvm-19/ + TABLEGEN_190_PREFIX: /usr/lib/llvm-19/ + timeout-minutes: 45 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.82.0 + - uses: Swatinem/rust-cache@v2 + - name: add llvm deb repository + uses: myci-actions/add-deb-repo@11 + with: + repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main + repo-name: llvm-repo + keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key + - name: Install LLVM + run: + sudo apt-get install llvm-19 llvm-19-dev llvm-19-runtime clang-19 + clang-tools-19 lld-19 libpolly-19-dev libmlir-19-dev mlir-19-tools + libgmp3-dev libzstd-dev lld libssl-dev zstd + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.x + - name: fetch ef tests + run: make setup + - name: fetch Kakarot + run: make setup-kakarot + env: + GITHUB_TOKEN: ${{ github.token }} + - name: run tests v0 + run: | + set -o pipefail + make vm-tests-v0-ci | tee test_v0.out + - name: run tests v1 + run: | + make vm-tests-v1-ci | tee test_v1.out + set +o pipefail + - name: Retrieve ef-tests execution resources + run: python scripts/compute_resources.py + env: + KAKAROT_VERSION: v0,v1 + # upload artifacts + - name: upload resources + uses: actions/upload-artifact@v3 + with: + path: ./resources/ + name: resources-usage diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index b182b631..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: test - -on: - workflow_call: {} - -permissions: read-all - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-test - cancel-in-progress: true - -jobs: - test: - # trunk-ignore(actionlint/runner-label) - runs-on: ubuntu-latest-16-cores - timeout-minutes: 45 - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: 3.x - - name: Setup rust env - uses: actions-rs/toolchain@v1 - with: - profile: minimal - components: llvm-tools-preview - override: true - toolchain: 1.82.0 - - name: Retrieve cached dependencies - uses: Swatinem/rust-cache@v2 - - name: fetch ef tests - run: make setup - - name: fetch Kakarot - run: make setup-kakarot - env: - GITHUB_TOKEN: ${{ github.token }} - - name: run tests v0 - run: | - set -o pipefail - make vm-tests-v0-ci | tee test_v0.out - - name: run tests v1 - run: | - make vm-tests-v1-ci | tee test_v1.out - set +o pipefail - - name: Retrieve ef-tests execution resources - run: python scripts/compute_resources.py - env: - KAKAROT_VERSION: v0,v1 - # upload artifacts - - name: upload resources - uses: actions/upload-artifact@v3 - with: - path: ./resources/ - name: resources-usage diff --git a/.github/workflows/trunk-check.yml b/.github/workflows/trunk-check.yml deleted file mode 100644 index 6e104c86..00000000 --- a/.github/workflows/trunk-check.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Trunk - -on: - workflow_call: {} - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-trunk - cancel-in-progress: true - -jobs: - trunk_check: - name: Trunk Check Runner - runs-on: ubuntu-latest - # trunk-ignore(checkov/CKV2_GHA_1) - permissions: - checks: write # For trunk to post annotations - contents: read # For repo checkout - - steps: - - name: Checkout - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.82.0 - override: true - components: clippy - - uses: Swatinem/rust-cache@v2 - - name: Trunk Check - uses: trunk-io/trunk-action@v1 diff --git a/.gitignore b/.gitignore index 6b863e65..43451617 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,8 @@ tmp* # Ignore the generated tests /crates/ef-testing/tests/* +/crates/ef-testing/native_cache/* + # Ignore the launch file launch.json diff --git a/Cargo.lock b/Cargo.lock index f646fd10..d2b34db4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -285,7 +285,7 @@ checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -420,7 +420,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -436,7 +436,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", "syn-solidity", "tiny-keccak", ] @@ -452,7 +452,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", "syn-solidity", ] @@ -569,6 +569,20 @@ version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +[[package]] +name = "aquamarine" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21cc1548309245035eb18aa7f0967da6bc65587005170c56e6ef2788a4cf3f4e" +dependencies = [ + "include_dir", + "itertools 0.10.5", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "aquamarine" version = "0.6.0" @@ -580,7 +594,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -837,7 +851,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -864,7 +878,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -942,6 +956,29 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.69.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +dependencies = [ + "bitflags 2.6.0", + "cexpr", + "clang-sys", + "itertools 0.12.1", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash 1.1.0", + "shlex", + "syn 2.0.90", + "which", +] + [[package]] name = "bindgen" version = "0.70.1" @@ -952,12 +989,14 @@ dependencies = [ "cexpr", "clang-sys", "itertools 0.13.0", + "log", + "prettyplease", "proc-macro2", "quote", "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -1034,18 +1073,19 @@ dependencies = [ [[package]] name = "blockifier" version = "0.0.0" -source = "git+https://github.com/kkrt-labs/sequencer.git?rev=d1f32e2#d1f32e241e4a9a404d8b2c292921685f39ee0211" +source = "git+https://github.com/kkrt-labs/sequencer.git?rev=a0177488b87c28427b223598b3e04cbe9f5a8e6c#a0177488b87c28427b223598b3e04cbe9f5a8e6c" dependencies = [ "anyhow", "ark-ec", "ark-ff 0.4.2", "ark-secp256k1", "ark-secp256r1", - "cached", + "cached 0.44.0", "cairo-lang-casm", "cairo-lang-runner", "cairo-lang-starknet-classes", "cairo-lang-utils", + "cairo-native", "cairo-vm", "derive_more 0.99.18", "indexmap 2.6.0", @@ -1061,12 +1101,13 @@ dependencies = [ "phf", "rand", "rstest", + "semver 1.0.23", "serde", "serde_json", "sha2 0.10.8", - "sha3", "starknet-types-core", "starknet_api", + "starknet_sierra_compile", "strum 0.25.0", "strum_macros 0.25.3", "tempfile", @@ -1086,6 +1127,31 @@ dependencies = [ "zeroize", ] +[[package]] +name = "bon" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9276fe602371cd8a7f70fe68c4db55b2d3e92c570627d6ed0427646edfa5cf47" +dependencies = [ + "bon-macros", + "rustversion", +] + +[[package]] +name = "bon-macros" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94828b84b32b4f3ac3865f692fcdbc46c7d0dd87b29658a391d58a244e1ce45a" +dependencies = [ + "darling 0.20.10", + "ident_case", + "prettyplease", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.90", +] + [[package]] name = "bs58" version = "0.5.1" @@ -1198,7 +1264,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b195e4fbc4b6862bbd065b991a34750399c119797efff72492f28a5864de8700" dependencies = [ "async-trait", - "cached_proc_macro", + "cached_proc_macro 0.17.0", "cached_proc_macro_types", "futures", "hashbrown 0.13.2", @@ -1208,6 +1274,21 @@ dependencies = [ "tokio", ] +[[package]] +name = "cached" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4d73155ae6b28cf5de4cfc29aeb02b8a1c6dab883cb015d15cd514e42766846" +dependencies = [ + "ahash", + "cached_proc_macro 0.23.0", + "cached_proc_macro_types", + "hashbrown 0.14.5", + "once_cell", + "thiserror", + "web-time", +] + [[package]] name = "cached_proc_macro" version = "0.17.0" @@ -1221,6 +1302,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "cached_proc_macro" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f42a145ed2d10dce2191e1dcf30cfccfea9026660e143662ba5eec4017d5daa" +dependencies = [ + "darling 0.20.10", + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "cached_proc_macro_types" version = "0.1.1" @@ -1229,9 +1322,9 @@ checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" [[package]] name = "cairo-lang-casm" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd4d6659539ace9649c8e8a7434e51b0c50a7a700111d0a2b967dde220ddff49" +checksum = "e1e0dcdb6358bb639dd729546611bd99bada94c86e3f262c3637855abea9a972" dependencies = [ "cairo-lang-utils", "indoc", @@ -1243,9 +1336,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2016966ed29f3a44487fd1bbdb05320fb6ea8ec46201c04c6b222ccb5264e0a" +checksum = "b8657f5a5611f341a85e80ba0b21848fc34bfdf391bfd93df0baf4516c3e4159" dependencies = [ "anyhow", "cairo-lang-defs", @@ -1269,18 +1362,18 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c804649297ca417206435ee3e8041d2100cc31ebf4a95bc4b92ed02dc63469" +checksum = "0635aa554d297acefe6a35b495aba2795d0af5b7f97c4ab63829c7d62291ef41" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fbda467ac36f73bb1879e1f741898fc719d6f9239a01cc422e6a023281319b" +checksum = "86b356e1c09898e8b8cfdd9731579d89365a13d8b4f7e717962e0cc7d125b83c" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -1295,9 +1388,9 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c843ef4715e3d21de5388d02206db2506e2d2ec0e80e2629e0ae9900a08b8674" +checksum = "2dfe7c6ff96182da29012b707a3554e34a50f19cc96013ee45b0eb36dd396ec8" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1307,9 +1400,9 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33a416c5871960fb4823160ebef2abc51e0c1b86fef1e97a1ebb2e5f3c3795d3" +checksum = "723d244465309d5409e297b5486d62cbec06f2c47b05044414bb640e3f14caab" dependencies = [ "cairo-lang-utils", "good_lp", @@ -1317,9 +1410,9 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47189e0cb84b21defd201af4cf24a94c6b0d09f48706cf659c9ffa0def8a7a43" +checksum = "237030772ae5368f19a9247e1f63f753f8ad8de963477166e402f4825c0a141d" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -1328,13 +1421,14 @@ dependencies = [ "semver 1.0.23", "serde", "smol_str", + "toml", ] [[package]] name = "cairo-lang-formatter" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6409ff1f4a93ce7c0968d9d857d2a8c03657617a827159d33f978110b718b31d" +checksum = "5b71f0eb3a36a6cb5f7f07843926783c4c17e44c9516b53171727a108782f3eb" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -1347,15 +1441,14 @@ dependencies = [ "itertools 0.12.1", "rust-analyzer-salsa", "serde", - "smol_str", "thiserror", ] [[package]] name = "cairo-lang-lowering" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e224e006c82ef21bd9e243390992de2be25ae6fbbdaa8544067b3f0c31977f1" +checksum = "7d095d78e2f1de499429c95655d6135a3d24c384b36d8de9f84e0aa4e07ee152" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1370,6 +1463,7 @@ dependencies = [ "itertools 0.12.1", "log", "num-bigint", + "num-integer", "num-traits 0.2.19", "rust-analyzer-salsa", "smol_str", @@ -1377,9 +1471,9 @@ dependencies = [ [[package]] name = "cairo-lang-parser" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb260ba349c2b699639e56f9b64deb969ff01179a0253087e2c8ceec7e32157" +checksum = "bb828af7f948a3ef7fa65de14e3f639daedefb046dfefcad6e3116d2cb0f89a0" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -1397,9 +1491,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05a2e500dc8ddea4d25a866d8a839158b0e4c41a6c023f21911e2da252bd91b3" +checksum = "135a600043bf7030eacc6ebf2a609c2364d6ffeb04e1f3c809a2738f6b02c829" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -1416,20 +1510,20 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d72f17373740f242d6995e896b9195c2cedff7e8b14e496afdd16b405039d1fb" +checksum = "ac857ec4b564712f3e16e3314e23cc0787ab1c05cdfee83f1c8f9989a6eee40f" dependencies = [ "cairo-lang-debug", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] name = "cairo-lang-project" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13294f08d2013fcd6e815e7235935680963dec3390e5baf454f33da866fc44b6" +checksum = "23cc37b7f8889cdea631aeea3bcc70d5c86ac8fb1d98aabc83f16283d60f1643" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -1441,9 +1535,9 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b9e6a21d92255b92f64c60658b4224dd7d290cde8beea783fadc10fbfcd8c" +checksum = "7474375528ffa7f47e343983d32051898e4e7b05ac0bdc48ee84b1325d8b562a" dependencies = [ "ark-ff 0.4.2", "ark-secp256k1", @@ -1472,9 +1566,9 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6936215bca75c23e71873998420a3d46c322507a09917ce676c8d39f8c1bd6fe" +checksum = "c560cf4b4a89325d3a9594f490fffee38cf30e0990e808bb927619de9d0c973a" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1498,9 +1592,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "424f55450494e959c1ae26c52a71075767a90f76e3ecca6e81056dd7517e8ba0" +checksum = "8118f55ca7d567bfc60960b445d388564d04bf48335c983b1595cb35f67a01c5" dependencies = [ "anyhow", "cairo-lang-utils", @@ -1525,9 +1619,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053dd520e0b9d1c1078d93ea69045f6f334c3d41b4b75db183ab33e32cfd8570" +checksum = "2716ef8d4ce0fb700f83ed3281f3656436570e60249d41c65c79dc1ca27be002" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1541,9 +1635,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a73227867377efc62ebb893cddaa88df3940bf2be5dbdc2f0b00f9edf69288e" +checksum = "24a44da87a35845470c4f4c648225232a15e0875fe809045b6088464491f838b" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1557,9 +1651,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3752cacd475ea089d9a536357804150e693a124e703fcc33a55566d568094b3" +checksum = "15bc5cf9f3965a7030a114dfe3d31d183287fbfbfbf904deaaa2468cadb936aa" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1581,9 +1675,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7162fb3c93960dfc6d8005b65064e518e3f1ed6102e8981b42ea41879c331184" +checksum = "18b7616f1a3c41c4646094b5abf774e558428e9c1eda5d78d7b0638ec5c264e5" dependencies = [ "assert_matches", "cairo-lang-casm", @@ -1602,9 +1696,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a51b80c117e2b05a6d300f2e2247892cc99e42e950e79f6085e6ed6cbcb44d12" +checksum = "871077dbc08df5d134dc3975538171c14b266ba405d1298085afdb227216f0a3" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -1612,9 +1706,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafaabc43f78dfa2f45d935993ba21c05c164bbb3bf277d348847a51e5939a9f" +checksum = "9f21804eb8931d41e258e7a393afc8ee8858308e95b3ed2e9b6b469ef68a6a50" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -1642,9 +1736,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet-classes" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "832fd9072ddf4204ca6d227c0238929349f10146bd066a98025d51ac15d27fad" +checksum = "b2496bccd68fa0286b35b72c98439316a3a872ef7ec6d881f0dac90b17997490" dependencies = [ "cairo-lang-casm", "cairo-lang-sierra", @@ -1665,9 +1759,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cebe67c0d68f9acf8709d170c1308ca57a778d22f70da38a57f74ae250eee28a" +checksum = "8d77ea2e35d3610098ff13e373fc519aedc6a5096ed8547081aacfc104ef4422" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1681,19 +1775,46 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.8.4" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31cef5b4347626e61bad8f070495cd35d637a5cb6744c34d20dd382c7431aff8" +checksum = "80bede54808f2e5d26a8702711009eefe4a12e5a8f3a427ba9b081073c8e9d36" dependencies = [ "genco", "xshell", ] +[[package]] +name = "cairo-lang-test-plugin" +version = "2.9.0-dev.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f83e082c8ebf81295156f13399f880037c749a9f1fc3f55b1be7e49fe124c6" +dependencies = [ + "anyhow", + "cairo-lang-compiler", + "cairo-lang-debug", + "cairo-lang-defs", + "cairo-lang-filesystem", + "cairo-lang-lowering", + "cairo-lang-semantic", + "cairo-lang-sierra", + "cairo-lang-sierra-generator", + "cairo-lang-starknet", + "cairo-lang-starknet-classes", + "cairo-lang-syntax", + "cairo-lang-utils", + "indoc", + "itertools 0.12.1", + "num-bigint", + "num-traits 0.2.19", + "serde", + "starknet-types-core", +] + [[package]] name = "cairo-lang-test-utils" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "060c61ac4a3ae0428771244ff8db903105f127392b7d725d919fe3fb1ec4132f" +checksum = "eb143a22f5a3510df8c4dec76e17c1e36bbcbddcd7915601f6a51a72418c454f" dependencies = [ "cairo-lang-formatter", "cairo-lang-utils", @@ -1704,9 +1825,9 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bfc6372538143afad658c853a35bdc9f5210c5cb54e0c8f04ab78e268139466" +checksum = "35df943ebcf8e1db11ee9f4f46f843dde5b71639ca79ea0d8caa7973f91d8b12" dependencies = [ "hashbrown 0.14.5", "indexmap 2.6.0", @@ -1718,6 +1839,75 @@ dependencies = [ "serde", ] +[[package]] +name = "cairo-native" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bdebc70c3d563bc30078985ae3e975aa7dc4fa233631b5e0462a924c26c0dd9" +dependencies = [ + "anyhow", + "aquamarine 0.5.0", + "ark-ec", + "ark-ff 0.4.2", + "ark-secp256k1", + "ark-secp256r1", + "bumpalo", + "cairo-lang-compiler", + "cairo-lang-defs", + "cairo-lang-filesystem", + "cairo-lang-runner", + "cairo-lang-semantic", + "cairo-lang-sierra", + "cairo-lang-sierra-ap-change", + "cairo-lang-sierra-gas", + "cairo-lang-sierra-generator", + "cairo-lang-starknet", + "cairo-lang-starknet-classes", + "cairo-lang-test-plugin", + "cairo-lang-utils", + "cairo-native-runtime", + "cc", + "clap", + "colored", + "educe", + "itertools 0.13.0", + "keccak", + "lazy_static", + "libc", + "libloading", + "llvm-sys", + "melior", + "mlir-sys", + "num-bigint", + "num-integer", + "num-traits 0.2.19", + "serde", + "serde_json", + "sha2 0.10.8", + "starknet-types-core", + "stats_alloc", + "tempfile", + "thiserror", + "tracing", + "tracing-subscriber", + "utf8_iter", +] + +[[package]] +name = "cairo-native-runtime" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf997252c402d6844f41357660cde3c11825ac5b3feafd0fb99b9dcdfb58aa3" +dependencies = [ + "cairo-lang-sierra-gas", + "itertools 0.13.0", + "lazy_static", + "num-traits 0.2.19", + "rand", + "starknet-curve 0.5.1", + "starknet-types-core", +] + [[package]] name = "cairo-vm" version = "1.0.1" @@ -1788,6 +1978,16 @@ dependencies = [ "thiserror", ] +[[package]] +name = "caseless" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808dab3318747be122cb31d36de18d4d1c81277a76f8332a02b81a3d73463d7f" +dependencies = [ + "regex", + "unicode-normalization", +] + [[package]] name = "cc" version = "1.1.28" @@ -1881,7 +2081,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -1906,6 +2106,23 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "comrak" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453dcb42e33f7b474d7e0db12e0b8d82802c88f35cf5a1d8c297d0dfcecb154f" +dependencies = [ + "bon", + "caseless", + "entities", + "memchr", + "once_cell", + "regex", + "slug", + "typed-arena", + "unicode_categories", +] + [[package]] name = "concat-kdf" version = "0.1.0" @@ -2132,7 +2349,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -2168,7 +2385,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -2216,7 +2433,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -2238,7 +2455,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core 0.20.10", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -2338,7 +2555,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -2351,7 +2568,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.1", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -2372,10 +2589,16 @@ dependencies = [ "convert_case 0.6.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", "unicode-xid", ] +[[package]] +name = "deunicode" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00" + [[package]] name = "diff" version = "0.1.13" @@ -2495,7 +2718,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -2555,6 +2778,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "educe" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4bd92664bf78c4d3dba9b7cdafce6fa15b13ed3ed16175218196942e99168a8" +dependencies = [ + "enum-ordinalize", + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "ef-testing" version = "0.1.0" @@ -2580,6 +2815,7 @@ dependencies = [ "ef-tests", "eyre", "lazy_static", + "libc", "log", "num-bigint", "num-integer", @@ -2690,6 +2926,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "entities" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca" + [[package]] name = "enum-as-inner" version = "0.6.1" @@ -2699,7 +2941,27 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", +] + +[[package]] +name = "enum-ordinalize" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea0dcfa4e54eeb516fe454635a95753ddd39acda650ce703031c6973e315dd5" +dependencies = [ + "enum-ordinalize-derive", +] + +[[package]] +name = "enum-ordinalize-derive" +version = "4.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", ] [[package]] @@ -2710,7 +2972,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -2816,7 +3078,7 @@ dependencies = [ "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -3009,7 +3271,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -3073,7 +3335,7 @@ checksum = "553630feadf7b76442b0849fd25fdf89b860d933623aec9693fed19af0400c78" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -3320,6 +3582,15 @@ dependencies = [ "hmac 0.8.1", ] +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "hostname" version = "0.3.1" @@ -3721,6 +3992,15 @@ version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" +[[package]] +name = "infra_utils" +version = "0.0.0" +source = "git+https://github.com/kkrt-labs/sequencer.git?rev=a0177488b87c28427b223598b3e04cbe9f5a8e6c#a0177488b87c28427b223598b3e04cbe9f5a8e6c" +dependencies = [ + "tokio", + "tracing", +] + [[package]] name = "inotify" version = "0.9.6" @@ -4015,6 +4295,12 @@ dependencies = [ "spin", ] +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.159" @@ -4137,6 +4423,20 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "llvm-sys" +version = "191.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "893cddf1adf0354b93411e413553dd4daf5c43195d73f1acfa1e394bdd371456" +dependencies = [ + "anyhow", + "cc", + "lazy_static", + "libc", + "regex-lite", + "semver 1.0.23", +] + [[package]] name = "lock_api" version = "0.4.12" @@ -4224,6 +4524,32 @@ dependencies = [ "rawpointer", ] +[[package]] +name = "melior" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee088ab94ababfb7843fbf3c6239a535f371ea23b57c75f26707c14096527874" +dependencies = [ + "melior-macro", + "mlir-sys", +] + +[[package]] +name = "melior-macro" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "575063f5ab34758980f9441a3978b4ad8c46e8eaeb5c6cb0e73b985f056d8490" +dependencies = [ + "comrak", + "convert_case 0.6.0", + "proc-macro2", + "quote", + "regex", + "syn 2.0.90", + "tblgen-alt", + "unindent", +] + [[package]] name = "memchr" version = "2.7.4" @@ -4258,7 +4584,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -4316,6 +4642,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "mlir-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fae0a14b0940736a243fef4a4d96d8cdf8a253272031b63c5e4b1bea207c82b0" +dependencies = [ + "bindgen 0.70.1", +] + [[package]] name = "modular-bitfield" version = "0.11.2" @@ -4623,7 +4958,7 @@ checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -4789,7 +5124,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -4835,9 +5170,10 @@ dependencies = [ [[package]] name = "papyrus_config" version = "0.0.0" -source = "git+https://github.com/kkrt-labs/sequencer.git?rev=d1f32e2#d1f32e241e4a9a404d8b2c292921685f39ee0211" +source = "git+https://github.com/kkrt-labs/sequencer.git?rev=a0177488b87c28427b223598b3e04cbe9f5a8e6c#a0177488b87c28427b223598b3e04cbe9f5a8e6c" dependencies = [ "clap", + "infra_utils", "itertools 0.12.1", "serde", "serde_json", @@ -4846,6 +5182,16 @@ dependencies = [ "validator", ] +[[package]] +name = "papyrus_proc_macros" +version = "0.0.0" +source = "git+https://github.com/kkrt-labs/sequencer.git?rev=a0177488b87c28427b223598b3e04cbe9f5a8e6c#a0177488b87c28427b223598b3e04cbe9f5a8e6c" +dependencies = [ + "quote", + "syn 2.0.90", + "tracing", +] + [[package]] name = "parity-scale-codec" version = "3.6.12" @@ -5009,7 +5355,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -5053,7 +5399,7 @@ checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -5142,6 +5488,16 @@ dependencies = [ "yansi", ] +[[package]] +name = "prettyplease" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" +dependencies = [ + "proc-macro2", + "syn 2.0.90", +] + [[package]] name = "primitive-types" version = "0.12.2" @@ -5207,14 +5563,14 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -5257,7 +5613,7 @@ checksum = "6ff7ff745a347b87471d859a377a9a404361e7efc2a971d73424a6d183c0fc77" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -5378,9 +5734,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -5408,6 +5764,12 @@ dependencies = [ "regex-syntax 0.8.5", ] +[[package]] +name = "regex-lite" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" + [[package]] name = "regex-syntax" version = "0.6.29" @@ -5664,7 +6026,7 @@ dependencies = [ "convert_case 0.6.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -6177,7 +6539,7 @@ name = "reth-mdbx-sys" version = "1.1.1" source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.1.1#15c230bac20e2b1b3532c8b0d470e815fbc0cc22" dependencies = [ - "bindgen", + "bindgen 0.70.1", "cc", ] @@ -6223,7 +6585,7 @@ dependencies = [ "alloy-eips", "alloy-primitives", "alloy-rlp", - "aquamarine", + "aquamarine 0.6.0", "auto_impl", "derive_more 1.0.0", "discv5", @@ -6768,7 +7130,7 @@ version = "1.1.1" source = "git+https://github.com/paradigmxyz/reth.git?tag=v1.1.1#15c230bac20e2b1b3532c8b0d470e815fbc0cc22" dependencies = [ "alloy-primitives", - "aquamarine", + "aquamarine 0.6.0", "auto_impl", "futures-util", "metrics", @@ -6915,7 +7277,7 @@ dependencies = [ "alloy-eips", "alloy-primitives", "alloy-rlp", - "aquamarine", + "aquamarine 0.6.0", "auto_impl", "bitflags 2.6.0", "futures-util", @@ -7262,7 +7624,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -7476,7 +7838,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -7607,9 +7969,15 @@ name = "sequencer" version = "0.1.0" dependencies = [ "blockifier", + "cached 0.53.1", + "cairo-lang-sierra", + "cairo-lang-starknet-classes", + "cairo-native", "eyre", "hashbrown 0.14.5", "lazy_static", + "libloading", + "once_cell", "serde", "serde_json", "starknet", @@ -7636,7 +8004,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -7647,7 +8015,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -7682,7 +8050,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -7733,7 +8101,7 @@ dependencies = [ "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -7880,6 +8248,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slug" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "882a80f72ee45de3cc9a5afeb2da0331d58df69e4e7d8eeb5d3c7784ae67e724" +dependencies = [ + "deunicode", + "wasm-bindgen", +] + [[package]] name = "smallvec" version = "1.13.2" @@ -8062,7 +8440,7 @@ checksum = "bbc159a1934c7be9761c237333a57febe060ace2bc9e3b337a59a37af206d19f" dependencies = [ "starknet-curve 0.4.2", "starknet-ff", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -8102,7 +8480,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8986a940af916fc0a034f4e42c6ba76d94f1e97216d75447693dfd7aefaf3ef2" dependencies = [ "starknet-core", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -8162,14 +8540,18 @@ dependencies = [ [[package]] name = "starknet_api" version = "0.0.0" -source = "git+https://github.com/kkrt-labs/sequencer.git?rev=d1f32e2#d1f32e241e4a9a404d8b2c292921685f39ee0211" +source = "git+https://github.com/kkrt-labs/sequencer.git?rev=a0177488b87c28427b223598b3e04cbe9f5a8e6c#a0177488b87c28427b223598b3e04cbe9f5a8e6c" dependencies = [ "bitvec", + "cairo-lang-runner", "cairo-lang-starknet-classes", "derive_more 0.99.18", "hex", "indexmap 2.6.0", "itertools 0.12.1", + "num-bigint", + "papyrus_proc_macros", + "pretty_assertions", "primitive-types", "serde", "serde_json", @@ -8181,12 +8563,37 @@ dependencies = [ "thiserror", ] +[[package]] +name = "starknet_sierra_compile" +version = "0.0.0" +source = "git+https://github.com/kkrt-labs/sequencer.git?rev=a0177488b87c28427b223598b3e04cbe9f5a8e6c#a0177488b87c28427b223598b3e04cbe9f5a8e6c" +dependencies = [ + "cairo-lang-sierra", + "cairo-lang-starknet-classes", + "cairo-lang-utils", + "cairo-native", + "papyrus_config", + "serde", + "serde_json", + "starknet-types-core", + "starknet_api", + "tempfile", + "thiserror", + "validator", +] + [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "stats_alloc" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c0e04424e733e69714ca1bbb9204c1a57f09f5493439520f9f68c132ad25eec" + [[package]] name = "string_cache" version = "0.8.7" @@ -8237,7 +8644,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -8250,7 +8657,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -8285,9 +8692,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -8303,7 +8710,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -8382,6 +8789,18 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "tblgen-alt" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ecbc9175dd38627cd01d546e7b41c9a115e5773f4c98f64e2185c81ec5f45ab" +dependencies = [ + "bindgen 0.69.5", + "cc", + "paste", + "thiserror", +] + [[package]] name = "tempfile" version = "3.13.0" @@ -8423,7 +8842,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -8548,7 +8967,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -8680,7 +9099,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -8841,6 +9260,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + [[package]] name = "typenum" version = "1.17.0" @@ -8925,6 +9350,18 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + +[[package]] +name = "unindent" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" + [[package]] name = "universal-hash" version = "0.5.1" @@ -8970,6 +9407,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -9065,7 +9508,7 @@ checksum = "d674d135b4a8c1d7e813e2f8d1c9a58308aee4a680323066025e53132218bd91" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -9124,7 +9567,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", "wasm-bindgen-shared", ] @@ -9158,7 +9601,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9179,12 +9622,34 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki-roots" version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "widestring" version = "1.1.0" @@ -9261,7 +9726,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -9272,7 +9737,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -9529,7 +9994,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] @@ -9549,7 +10014,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.90", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index df8821e9..c55ea502 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,17 +40,20 @@ revm-interpreter = { version = "13.0", default-features = false } revm-primitives = { version = "13.0", default-features = false } # Starknet deps -cairo-lang-casm = "2.8.0" -cairo-lang-starknet = "2.8.0" -cairo-lang-utils = "2.8.0" -cairo-lang-starknet-classes = "2.8.0" +cairo-lang-casm = "=2.9.0-dev.0" +cairo-lang-starknet = "=2.9.0-dev.0" +cairo-lang-utils = "=2.9.0-dev.0" +cairo-lang-starknet-classes = "=2.9.0-dev.0" +cairo-lang-sierra = "=2.9.0-dev.0" +cairo-native = "0.2.4" cairo-vm = "1.0.1" -blockifier = { package = "blockifier", git = "https://github.com/kkrt-labs/sequencer.git", rev = "d1f32e2", default-features = false, features = [ +blockifier = { package = "blockifier", git = "https://github.com/kkrt-labs/sequencer.git", rev = "a0177488b87c28427b223598b3e04cbe9f5a8e6c", default-features = false, features = [ "testing", + "cairo_native", ] } starknet = "0.12" starknet-crypto = "0.7" -starknet_api = { package = "starknet_api", git = "https://github.com/kkrt-labs/sequencer.git", rev = "d1f32e2" } +starknet_api = { package = "starknet_api", git = "https://github.com/kkrt-labs/sequencer.git", rev = "a0177488b87c28427b223598b3e04cbe9f5a8e6c" } # Other async-trait = "0.1" diff --git a/Makefile b/Makefile index 21614568..bb5445d5 100644 --- a/Makefile +++ b/Makefile @@ -82,6 +82,10 @@ ef-test-v0: build ef-test-v1: build cargo test --test tests --no-fail-fast --quiet --features "v1,ci" +# Runs ef-tests with cairo-native mode +ef-test-v1-native: build + cargo test --test tests --no-fail-fast --features "v1,native,ci" -- --nocapture + # Build the rust crates build: cargo build --release diff --git a/crates/build-utils/src/converter.rs b/crates/build-utils/src/converter.rs index 0e1eb26f..30fd9199 100644 --- a/crates/build-utils/src/converter.rs +++ b/crates/build-utils/src/converter.rs @@ -121,7 +121,8 @@ impl<'a> EfTests<'a> { use std::{str::FromStr}; use ef_testing::models::case::BlockchainTestCase; - use ef_testing::test_utils::setup; + use ef_testing::test_utils::{setup, TestMonitor}; + use ef_testing::monitor_test; use ef_testing::traits::Case; use ef_tests::models::{Block, Account, State}; use alloy_primitives::{Address, B256}; @@ -161,7 +162,9 @@ impl<'a> EfTests<'a> { #[test] {test_header} fn test_{test_name}() {{ + monitor_test!("{test_name}", &[120, 300, 600, 900, 1200, 2000, 3000, 4000, 5000], || {{ {test_content} + }}); }}"#, )) } diff --git a/crates/ef-testing/Cargo.toml b/crates/ef-testing/Cargo.toml index 7a83ae2f..5937ac2d 100644 --- a/crates/ef-testing/Cargo.toml +++ b/crates/ef-testing/Cargo.toml @@ -9,6 +9,7 @@ build = "build.rs" [dependencies] bytes = { workspace = true } +libc = "0.2.159" # Eth deps alloy-rlp = { workspace = true } @@ -62,6 +63,7 @@ zip = { workspace = true, optional = true } [features] v0 = [] v1 = [] +native = [] ci = [] [build-dependencies] diff --git a/crates/ef-testing/src/evm_sequencer/account/mod.rs b/crates/ef-testing/src/evm_sequencer/account/mod.rs index d7e81728..7d5b09c4 100644 --- a/crates/ef-testing/src/evm_sequencer/account/mod.rs +++ b/crates/ef-testing/src/evm_sequencer/account/mod.rs @@ -7,11 +7,11 @@ use crate::starknet_storage; use alloy_consensus::constants::KECCAK_EMPTY; use alloy_primitives::keccak256; use alloy_primitives::{Address, U256}; -use blockifier::abi::{abi_utils::get_storage_var_address, sierra_types::next_storage_key}; use ef_tests::models::Account; use revm_interpreter::analysis::to_analysed; use revm_primitives::Bytecode; use starknet::core::utils::cairo_short_string_to_felt; +use starknet_api::abi::abi_utils::get_storage_var_address; use starknet_api::StarknetApiError; use starknet_api::{core::Nonce, state::StorageKey}; use starknet_crypto::{poseidon_permute_comp, Felt}; @@ -105,7 +105,7 @@ impl KakarotAccount { let code_hash_values = split_u256(code_hash); let code_hash_low_key = get_storage_var_address(ACCOUNT_CODE_HASH, &[]); - let code_hash_high_key = next_storage_key(&code_hash_low_key)?; + let code_hash_high_key = code_hash_low_key.next_storage_key()?; storage.extend([ (code_hash_low_key, Felt::from(code_hash_values[0])), (code_hash_high_key, Felt::from(code_hash_values[1])), @@ -143,7 +143,7 @@ impl KakarotAccount { let keys = split_u256(*k).map(Into::into); let values = split_u256(*v).map(Into::::into); let low_key = get_storage_var_address(ACCOUNT_STORAGE, &keys); - let high_key = next_storage_key(&low_key).unwrap(); // can fail only if low is the max key + let high_key = low_key.next_storage_key().unwrap(); // can fail only if low is the max key vec![(low_key, values[0]), (high_key, values[1])] }) .collect(); @@ -188,7 +188,7 @@ mod tests { use super::*; use alloy_primitives::Bytes; - use blockifier::abi::abi_utils::get_storage_var_address; + use starknet_api::abi::abi_utils::get_storage_var_address; #[test] fn test_pack_byte_array_to_starkfelt_array() { diff --git a/crates/ef-testing/src/evm_sequencer/constants.rs b/crates/ef-testing/src/evm_sequencer/constants.rs index 6cfc0ae3..b2ec9a71 100644 --- a/crates/ef-testing/src/evm_sequencer/constants.rs +++ b/crates/ef-testing/src/evm_sequencer/constants.rs @@ -1,4 +1,5 @@ use std::collections::HashMap; +use std::fs; use alloy_primitives::{address, Address}; use lazy_static::lazy_static; @@ -6,11 +7,9 @@ use serde::de::DeserializeOwned; use starknet::core::types::contract::CompiledClass; use starknet::signers::VerifyingKey; use starknet::{core::types::contract::legacy::LegacyContractClass, signers::SigningKey}; -use starknet_api::felt; use starknet_api::{ contract_address, - core::{ClassHash, ContractAddress, PatriciaKey}, - patricia_key, + core::{ClassHash, ContractAddress}, }; use starknet_crypto::Felt; @@ -21,6 +20,10 @@ where serde_json::from_str::(&std::fs::read_to_string(path)?).map_err(eyre::Error::from) } +pub fn get_raw_contract_class(contract_path: &str) -> String { + fs::read_to_string(contract_path).unwrap() +} + // Chain params pub const CHAIN_ID: u64 = 0x1; @@ -89,11 +92,23 @@ lazy_static! { pub static ref ACCOUNT_CONTRACT_CLASS: CompiledClass = load_contract_class("../../build/v1/contracts_AccountContract.compiled_contract_class.json").expect("Failed to load ContractAccount contract class"); pub static ref UNINITIALIZED_ACCOUNT_CLASS: CompiledClass = load_contract_class("../../build/v1/contracts_UninitializedAccount.compiled_contract_class.json").expect("Failed to load uninitialized account contract class"); + pub static ref KAKAROT_JSON_CLASS: String = get_raw_contract_class("../../build/v1/contracts_KakarotCore.contract_class.json"); + pub static ref ACCOUNT_CONTRACT_JSON_CLASS: String = get_raw_contract_class("../../build/v1/contracts_AccountContract.contract_class.json"); + pub static ref UNINITIALIZED_ACCOUNT_JSON_CLASS: String = get_raw_contract_class("../../build/v1/contracts_UninitializedAccount.contract_class.json"); + // Main class hashes pub static ref KAKAROT_CLASS_HASH: ClassHash = ClassHash(KAKAROT_CLASS.class_hash().unwrap()); pub static ref ACCOUNT_CONTRACT_CLASS_HASH: ClassHash = ClassHash(ACCOUNT_CONTRACT_CLASS.class_hash().unwrap()); pub static ref UNINITIALIZED_ACCOUNT_CLASS_HASH: ClassHash = ClassHash(UNINITIALIZED_ACCOUNT_CLASS.class_hash().unwrap()); pub static ref PROXY_CLASS_HASH: ClassHash = *UNINITIALIZED_ACCOUNT_CLASS_HASH; + + pub static ref CLASS_HASH_TO_JSON_CLASS: HashMap = { + let mut map = HashMap::new(); + map.insert(*KAKAROT_CLASS_HASH, KAKAROT_JSON_CLASS.clone()); + map.insert(*ACCOUNT_CONTRACT_CLASS_HASH, ACCOUNT_CONTRACT_JSON_CLASS.clone()); + map.insert(*UNINITIALIZED_ACCOUNT_CLASS_HASH, UNINITIALIZED_ACCOUNT_JSON_CLASS.clone()); + map + }; } #[cfg(not(any(feature = "v0", feature = "v1")))] @@ -114,6 +129,13 @@ lazy_static! { panic!("Kakarot class hash not defined, use features flag \"v0\" or \"v1\""); pub static ref UNINITIALIZED_ACCOUNT_CLASS: LegacyContractClass = panic!("Uninitialized account class not defined, use features flag \"v0\" or \"v1\""); + pub static ref KAKAROT_JSON_CLASS: String = + panic!("Kakarot json class not defined, use features flag \"v0\" or \"v1\""); + pub static ref ACCOUNT_CONTRACT_JSON_CLASS: String = + panic!("Account contract json class not defined, use features flag \"v0\" or \"v1\""); + pub static ref UNINITIALIZED_ACCOUNT_JSON_CLASS: String = + panic!("Uninitialized account json class not defined, use features flag \"v0\" or \"v1\""); + pub static ref CLASS_HASH_TO_JSON_CLASS: HashMap = HashMap::new(); } pub mod storage_variables { diff --git a/crates/ef-testing/src/evm_sequencer/evm_state/mod.rs b/crates/ef-testing/src/evm_sequencer/evm_state/mod.rs index 567dd669..8564d5a4 100644 --- a/crates/ef-testing/src/evm_sequencer/evm_state/mod.rs +++ b/crates/ef-testing/src/evm_sequencer/evm_state/mod.rs @@ -21,10 +21,6 @@ use alloy_primitives::Address; use alloy_primitives::Bytes; use alloy_primitives::U256; use blockifier::{ - abi::{ - abi_utils::{get_fee_token_var_address, get_storage_var_address}, - sierra_types::next_storage_key, - }, execution::errors::EntryPointExecutionError, state::state_api::{State as _, StateReader as _, StateResult}, transaction::{ @@ -35,6 +31,7 @@ use blockifier::{ use reth_primitives::TransactionSigned; use sequencer::{execution::Execution as _, transaction::BroadcastedTransactionWrapper}; use starknet::core::types::BroadcastedTransaction; +use starknet_api::abi::abi_utils::{get_fee_token_var_address, get_storage_var_address}; use starknet_api::state::StorageKey; use starknet_crypto::Felt; @@ -106,13 +103,12 @@ impl Evm for KakarotSequencer { // Set the base fee at index 'current_block' let [low_fee, high_fee] = split_u256(base_fee); let key = Felt::from_bytes_be_slice(b"current_block"); - println!("key: {:?}", key); let basefee_address = get_storage_var_address(KAKAROT_BASE_FEE, &[key]); self.state_mut() .set_storage_at(kakarot_address, basefee_address, low_fee.into())?; self.state_mut().set_storage_at( kakarot_address, - next_storage_key(&basefee_address)?, + basefee_address.next_storage_key()?, high_fee.into(), )?; @@ -126,7 +122,7 @@ impl Evm for KakarotSequencer { )?; self.state_mut().set_storage_at( kakarot_address, - next_storage_key(&prev_randao_address)?, + prev_randao_address.next_storage_key()?, high_prev_randao.into(), )?; @@ -187,7 +183,7 @@ impl Evm for KakarotSequencer { // Initialize the balance storage var. let balance_key_low = get_fee_token_var_address(starknet_address); - let balance_key_high = next_storage_key(&balance_key_low)?; + let balance_key_high = balance_key_low.next_storage_key()?; storage.append(&mut vec![ (balance_key_low, balance_values[0].into()), (balance_key_high, balance_values[1].into()), @@ -198,7 +194,7 @@ impl Evm for KakarotSequencer { "ERC20_allowances", &[*starknet_address.0.key(), *KAKAROT_ADDRESS.0.key()], ); - let allowance_key_high = next_storage_key(&allowance_key_low)?; + let allowance_key_high = allowance_key_low.next_storage_key()?; storage.append(&mut vec![ (allowance_key_low, u128::MAX.into()), (allowance_key_high, u128::MAX.into()), @@ -216,7 +212,7 @@ impl Evm for KakarotSequencer { fn storage_at(&mut self, evm_address: &Address, key: U256) -> StateResult { let keys = split_u256(key).map(Into::into); let key_low = get_storage_var_address(ACCOUNT_STORAGE, &keys); - let key_high = next_storage_key(&key_low)?; + let key_high = key_low.next_storage_key()?; let starknet_address = self.compute_starknet_address(evm_address)?; diff --git a/crates/ef-testing/src/evm_sequencer/sequencer/mod.rs b/crates/ef-testing/src/evm_sequencer/sequencer/mod.rs index bea39759..047ae6e6 100644 --- a/crates/ef-testing/src/evm_sequencer/sequencer/mod.rs +++ b/crates/ef-testing/src/evm_sequencer/sequencer/mod.rs @@ -19,36 +19,35 @@ use crate::evm_sequencer::{ utils::compute_starknet_address, }; use alloy_primitives::Address; -use blockifier::blockifier::block::{BlockInfo, GasPrices}; use blockifier::context::ChainInfo; use blockifier::context::{BlockContext, FeeTokenAddresses}; use blockifier::versioned_constants::VersionedConstants; use blockifier::{ - execution::contract_class::{ContractClass, ContractClassV0, ContractClassV1}, + execution::contract_class::{CompiledClassV0, CompiledClassV1, RunnableCompiledClass}, state::state_api::StateResult, }; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use cairo_vm::types::errors::program_errors::ProgramError; use sequencer::{sequencer::Sequencer, state::State}; use starknet::core::types::contract::{legacy::LegacyContractClass, CompiledClass}; +use starknet_api::block::BlockInfo; use starknet_api::{ block::{BlockNumber, BlockTimestamp}, core::{ChainId, ClassHash, ContractAddress}, }; -use std::num::NonZeroU128; #[cfg(feature = "v0")] use crate::evm_sequencer::constants::{ storage_variables::KAKAROT_CAIRO1_HELPERS_CLASS_HASH, CAIRO1_HELPERS_CLASS, CAIRO1_HELPERS_CLASS_HASH, }; -use blockifier::abi::abi_utils::get_storage_var_address; #[allow(unused_imports)] use blockifier::state::state_api::{ State as BlockifierState, StateReader as BlockifierStateReader, }; use lazy_static::lazy_static; use sequencer::state::State as SequencerState; +use starknet_api::abi::abi_utils::get_storage_var_address; /// Kakarot wrapper around a sequencer. #[derive(Clone)] @@ -110,14 +109,7 @@ impl KakarotSequencer { ) .try_into() .expect("Failed to convert to ContractAddress"), - gas_prices: GasPrices::new( - NonZeroU128::new(1).unwrap(), - NonZeroU128::new(1).unwrap(), - NonZeroU128::new(1).unwrap(), - NonZeroU128::new(1).unwrap(), - NonZeroU128::new(1).unwrap(), - NonZeroU128::new(1).unwrap(), - ), + gas_prices: Default::default(), use_kzg_da: false, }; @@ -181,20 +173,19 @@ impl DerefMut for KakarotSequencer { pub fn convert_contract_class_v0( class: &LegacyContractClass, -) -> Result { - Result::::Ok(ContractClass::V0( - ContractClassV0::try_from_json_string( - &serde_json::to_string(class).map_err(ProgramError::Parse)?, - )?, - )) +) -> Result { + Ok(CompiledClassV0::try_from_json_string( + &serde_json::to_string(class).map_err(ProgramError::Parse)?, + )? + .into()) } -pub fn convert_contract_class_v1(class: &CompiledClass) -> Result { +pub fn convert_contract_class_v1( + class: &CompiledClass, +) -> Result { let casm_contract_class = CasmContractClassWrapper::try_from(class)?; let casm_contract_class: CasmContractClass = casm_contract_class.into(); - Ok(ContractClass::V1(ContractClassV1::try_from( - casm_contract_class, - )?)) + Ok(CompiledClassV1::try_from(casm_contract_class)?.into()) } lazy_static! { @@ -232,13 +223,29 @@ lazy_static! { convert_contract_class_v0(&UNINITIALIZED_ACCOUNT_CLASS).expect("failed to convert uninitialized class") ) } + #[cfg(feature = "v1")] { + #[cfg(feature = "native")] + { + use sequencer::native::class_from_json_str; + use crate::evm_sequencer::constants::CLASS_HASH_TO_JSON_CLASS; + let kakarot_json = CLASS_HASH_TO_JSON_CLASS.get(&KAKAROT_CLASS_HASH).unwrap(); + let account_json = CLASS_HASH_TO_JSON_CLASS.get(&ACCOUNT_CONTRACT_CLASS_HASH).unwrap(); + let uninitialized_json = CLASS_HASH_TO_JSON_CLASS.get(&UNINITIALIZED_ACCOUNT_CLASS_HASH).unwrap(); + let account_class = class_from_json_str(account_json, *ACCOUNT_CONTRACT_CLASS_HASH).unwrap_or_else(|err| panic!("{}", err)); + let uninitialized_class = class_from_json_str(uninitialized_json, *UNINITIALIZED_ACCOUNT_CLASS_HASH).unwrap_or_else(|err| panic!("{}", err)); + let kakarot_class = class_from_json_str(kakarot_json, *KAKAROT_CLASS_HASH).unwrap_or_else(|err| panic!("{}", err)); + (kakarot_class, account_class, uninitialized_class) + } + #[cfg(not(feature = "native"))] + { ( convert_contract_class_v1(&KAKAROT_CLASS).expect("failed to convert kakarot class"), convert_contract_class_v1(&ACCOUNT_CONTRACT_CLASS).expect("failed to convert account class"), convert_contract_class_v1(&UNINITIALIZED_ACCOUNT_CLASS).expect("failed to convert uninitialized class") ) + } } }; @@ -250,8 +257,7 @@ lazy_static! { // Write contract account, uninitialized_account and erc20 classes and class hashes. (&mut state).set_contract_class( *ACCOUNT_CONTRACT_CLASS_HASH, - converted_account_class, - ).expect("failed to set contract account class"); + converted_account_class).expect("failed to set contract account class"); (&mut state) .set_contract_class(*UNINITIALIZED_ACCOUNT_CLASS_HASH, converted_uninitialized_class).expect("failed to set eoa contract class"); diff --git a/crates/ef-testing/src/evm_sequencer/sequencer/resources/versioned_constants.json b/crates/ef-testing/src/evm_sequencer/sequencer/resources/versioned_constants.json index 33579709..78c0ed90 100644 --- a/crates/ef-testing/src/evm_sequencer/sequencer/resources/versioned_constants.json +++ b/crates/ef-testing/src/evm_sequencer/sequencer/resources/versioned_constants.json @@ -9,31 +9,52 @@ "max_contract_bytecode_size": 81920 }, "invoke_tx_max_n_steps": 50000000, - "l2_resource_gas_costs": { + "execute_max_sierra_gas": 1000000000, + "deprecated_l2_resource_gas_costs": { "gas_per_data_felt": [128, 1000], "event_key_factor": [2, 1], - "gas_per_code_byte": [875, 1000] + "gas_per_code_byte": [32, 1000] + }, + "archival_data_gas_costs": { + "gas_per_data_felt": [5120, 1], + "event_key_factor": [2, 1], + "gas_per_code_byte": [1280, 1] }, "disable_cairo0_redeclaration": true, + "enable_stateful_compression": true, + "allocation_cost": { + "blob_cost": { + "l1_gas": 0, + "l1_data_gas": 32, + "l2_gas": 0 + }, + "gas_cost": { + "l1_gas": 551, + "l1_data_gas": 0, + "l2_gas": 0 + } + }, + "ignore_inner_event_resources": false, + "enable_reverts": true, "max_recursion_depth": 50, "segment_arena_cells": false, "os_constants": { - "block_hash_contract_address": 1, "call_contract_gas_cost": { "entry_point_gas_cost": 1, - "step_gas_cost": 10, - "syscall_base_gas_cost": 1 + "step_gas_cost": 860, + "range_check_gas_cost": 15 }, "constructor_entry_point_selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194", "default_entry_point_selector": 0, "deploy_gas_cost": { "entry_point_gas_cost": 1, - "step_gas_cost": 200, - "syscall_base_gas_cost": 1 + "step_gas_cost": 1128, + "range_check_gas_cost": 18, + "pedersen_gas_cost": 7 }, "emit_event_gas_cost": { - "step_gas_cost": 10, - "syscall_base_gas_cost": 1 + "step_gas_cost": 100, + "range_check_gas_cost": 1 }, "entry_point_gas_cost": { "entry_point_initial_budget": 1, @@ -49,20 +70,18 @@ "error_invalid_input_len": "Invalid input length", "error_invalid_argument": "Invalid argument", "error_out_of_gas": "Out of gas", + "error_entry_point_failed": "ENTRYPOINT_FAILED", + "error_entry_point_not_found": "ENTRYPOINT_NOT_FOUND", "execute_entry_point_selector": "0x15d40a3d6ca2ac30f4031e42be28da9b056fef9bb7357ac5e85627ee876e5ad", - "fee_transfer_gas_cost": { - "entry_point_gas_cost": 1, - "step_gas_cost": 100 - }, "get_block_hash_gas_cost": { - "step_gas_cost": 50, - "syscall_base_gas_cost": 1 + "step_gas_cost": 104, + "range_check_gas_cost": 2 }, "get_execution_info_gas_cost": { - "step_gas_cost": 10, - "syscall_base_gas_cost": 1 + "step_gas_cost": 100, + "range_check_gas_cost": 1 }, - "initial_gas_cost": { + "default_initial_gas_cost": { "step_gas_cost": 500000000 }, "keccak_gas_cost": { @@ -73,99 +92,113 @@ "l1_gas_index": 0, "l1_handler_version": 0, "l2_gas": "L2_GAS", + "l1_data_gas": "L1_DATA", + "l1_data_gas_index": 2, "l2_gas_index": 1, "library_call_gas_cost": { - "call_contract_gas_cost": 1 + "entry_point_gas_cost": 1, + "step_gas_cost": 836, + "range_check_gas_cost": 15 }, "sha256_process_block_gas_cost": { - "step_gas_cost": 1852, + "step_gas_cost": 1855, "range_check_gas_cost": 65, "bitwise_builtin_gas_cost": 1115, "syscall_base_gas_cost": 1 }, "memory_hole_gas_cost": 10, "nop_entry_point_offset": -1, + "os_contract_addresses": { + "block_hash_contract_address": 1, + "alias_contract_address": 2, + "reserved_contract_address": 3 + }, "range_check_gas_cost": 70, - "pedersen_gas_cost": 0, - "bitwise_builtin_gas_cost": 594, - "ecop_gas_cost": 0, - "poseidon_gas_cost": 0, - "add_mod_gas_cost": 0, - "mul_mod_gas_cost": 0, + "pedersen_gas_cost": 4050, + "bitwise_builtin_gas_cost": 583, + "ecop_gas_cost": 4085, + "poseidon_gas_cost": 491, + "add_mod_gas_cost": 230, + "mul_mod_gas_cost": 604, "replace_class_gas_cost": { - "step_gas_cost": 50, - "syscall_base_gas_cost": 1 + "step_gas_cost": 104, + "range_check_gas_cost": 1 }, "secp256k1_add_gas_cost": { "range_check_gas_cost": 29, - "step_gas_cost": 406 + "step_gas_cost": 410 }, "secp256k1_get_point_from_x_gas_cost": { "memory_hole_gas_cost": 20, "range_check_gas_cost": 30, - "step_gas_cost": 391 + "step_gas_cost": 395 }, "secp256k1_get_xy_gas_cost": { "memory_hole_gas_cost": 40, "range_check_gas_cost": 11, - "step_gas_cost": 239 + "step_gas_cost": 207 }, "secp256k1_mul_gas_cost": { "memory_hole_gas_cost": 2, "range_check_gas_cost": 7045, - "step_gas_cost": 76501 + "step_gas_cost": 76505 }, "secp256k1_new_gas_cost": { "memory_hole_gas_cost": 40, "range_check_gas_cost": 35, - "step_gas_cost": 475 + "step_gas_cost": 461 }, "secp256r1_add_gas_cost": { "range_check_gas_cost": 57, - "step_gas_cost": 589 + "step_gas_cost": 593 }, "secp256r1_get_point_from_x_gas_cost": { "memory_hole_gas_cost": 20, "range_check_gas_cost": 44, - "step_gas_cost": 510 + "step_gas_cost": 514 }, "secp256r1_get_xy_gas_cost": { "memory_hole_gas_cost": 40, "range_check_gas_cost": 11, - "step_gas_cost": 241 + "step_gas_cost": 209 }, "secp256r1_mul_gas_cost": { "memory_hole_gas_cost": 2, "range_check_gas_cost": 13961, - "step_gas_cost": 125340 + "step_gas_cost": 125344 }, "secp256r1_new_gas_cost": { "memory_hole_gas_cost": 40, "range_check_gas_cost": 49, - "step_gas_cost": 594 + "step_gas_cost": 580 }, "send_message_to_l1_gas_cost": { - "step_gas_cost": 50, - "syscall_base_gas_cost": 1 + "step_gas_cost": 141, + "range_check_gas_cost": 1 }, "sierra_array_len_bound": 4294967296, "step_gas_cost": 100, "storage_read_gas_cost": { - "step_gas_cost": 50, - "syscall_base_gas_cost": 1 + "step_gas_cost": 100, + "range_check_gas_cost": 1 }, "storage_write_gas_cost": { - "step_gas_cost": 50, - "syscall_base_gas_cost": 1 + "step_gas_cost": 100, + "range_check_gas_cost": 1 + }, + "get_class_hash_at_gas_cost": { + "step_gas_cost": 100, + "range_check_gas_cost": 1 }, "stored_block_hash_buffer": 10, "syscall_base_gas_cost": { "step_gas_cost": 100 }, "transaction_gas_cost": { - "entry_point_gas_cost": 2, - "fee_transfer_gas_cost": 1, - "step_gas_cost": 100 + "step_gas_cost": 4098, + "pedersen_gas_cost": 4, + "range_check_gas_cost": 77, + "poseidon_gas_cost": 11 }, "transfer_entry_point_selector": "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e", "validate_declare_entry_point_selector": "0x289da278a8dc833409cabfdad1581e8e7d40e42dcaed693fa4008dcdb4963b3", @@ -180,7 +213,7 @@ "os_resources": { "execute_syscalls": { "CallContract": { - "n_steps": 827, + "n_steps": 866, "builtin_instance_counter": { "range_check_builtin": 15 }, @@ -201,7 +234,7 @@ "n_memory_holes": 0 }, "Deploy": { - "n_steps": 1097, + "n_steps": 1132, "builtin_instance_counter": { "pedersen_builtin": 7, "range_check_builtin": 18 @@ -280,7 +313,7 @@ "n_memory_holes": 0 }, "LibraryCall": { - "n_steps": 818, + "n_steps": 842, "builtin_instance_counter": { "range_check_builtin": 15 }, @@ -294,7 +327,7 @@ "n_memory_holes": 0 }, "ReplaceClass": { - "n_steps": 98, + "n_steps": 104, "builtin_instance_counter": { "range_check_builtin": 1 }, @@ -378,7 +411,7 @@ "n_memory_holes": 0 }, "Sha256ProcessBlock": { - "n_steps": 1855, + "n_steps": 1865, "builtin_instance_counter": { "range_check_builtin": 65, "bitwise_builtin": 1115 @@ -393,6 +426,13 @@ "n_memory_holes": 0 }, "StorageWrite": { + "n_steps": 93, + "builtin_instance_counter": { + "range_check_builtin": 1 + }, + "n_memory_holes": 0 + }, + "GetClassHashAt": { "n_steps": 89, "builtin_instance_counter": { "range_check_builtin": 1 @@ -404,10 +444,11 @@ "Declare": { "deprecated_resources": { "constant": { - "n_steps": 2973, + "n_steps": 3203, "builtin_instance_counter": { "pedersen_builtin": 16, - "range_check_builtin": 53 + "range_check_builtin": 56, + "poseidon_builtin": 4 }, "n_memory_holes": 0 }, @@ -419,11 +460,11 @@ }, "resources": { "constant": { - "n_steps": 3079, + "n_steps": 3346, "builtin_instance_counter": { "pedersen_builtin": 4, - "range_check_builtin": 58, - "poseidon_builtin": 10 + "range_check_builtin": 64, + "poseidon_builtin": 14 }, "n_memory_holes": 0 }, @@ -437,7 +478,7 @@ "DeployAccount": { "deprecated_resources": { "constant": { - "n_steps": 4015, + "n_steps": 4161, "builtin_instance_counter": { "pedersen_builtin": 23, "range_check_builtin": 72 @@ -454,10 +495,10 @@ }, "resources": { "constant": { - "n_steps": 4137, + "n_steps": 4321, "builtin_instance_counter": { "pedersen_builtin": 11, - "range_check_builtin": 77, + "range_check_builtin": 80, "poseidon_builtin": 10 }, "n_memory_holes": 0 @@ -474,7 +515,7 @@ "InvokeFunction": { "deprecated_resources": { "constant": { - "n_steps": 3763, + "n_steps": 3918, "builtin_instance_counter": { "pedersen_builtin": 14, "range_check_builtin": 69 @@ -491,10 +532,10 @@ }, "resources": { "constant": { - "n_steps": 3904, + "n_steps": 4102, "builtin_instance_counter": { "pedersen_builtin": 4, - "range_check_builtin": 74, + "range_check_builtin": 77, "poseidon_builtin": 11 }, "n_memory_holes": 0 @@ -511,7 +552,7 @@ "L1Handler": { "deprecated_resources": { "constant": { - "n_steps": 1233, + "n_steps": 1279, "builtin_instance_counter": { "pedersen_builtin": 11, "range_check_builtin": 16 @@ -551,18 +592,22 @@ } }, "validate_max_n_steps": 1000000, + "validate_max_sierra_gas": 100000000, + "min_compiler_version_for_sierra_gas": "2.8.0", "vm_resource_fee_cost": { - "add_mod_builtin": [4, 100], - "bitwise_builtin": [16, 100], - "ec_op_builtin": [256, 100], - "ecdsa_builtin": [512, 100], - "keccak_builtin": [512, 100], - "mul_mod_builtin": [4, 100], - "n_steps": [25, 10000], - "output_builtin": [0, 1], - "pedersen_builtin": [8, 100], - "poseidon_builtin": [8, 100], - "range_check_builtin": [4, 100], - "range_check96_builtin": [4, 100] + "builtins": { + "add_mod_builtin": [4, 100], + "bitwise_builtin": [16, 100], + "ec_op_builtin": [256, 100], + "ecdsa_builtin": [512, 100], + "keccak_builtin": [512, 100], + "mul_mod_builtin": [4, 100], + "output_builtin": [0, 1], + "pedersen_builtin": [8, 100], + "poseidon_builtin": [8, 100], + "range_check_builtin": [4, 100], + "range_check96_builtin": [4, 100] + }, + "n_steps": [25, 10000] } } diff --git a/crates/ef-testing/src/models/result.rs b/crates/ef-testing/src/models/result.rs index d97f3185..85a1aab4 100644 --- a/crates/ef-testing/src/models/result.rs +++ b/crates/ef-testing/src/models/result.rs @@ -78,6 +78,62 @@ impl TryFrom<&EventData> for EVMOutput { } } +#[cfg(target_os = "macos")] +mod debug_ram { + use std::mem; + + #[link(name = "c")] + extern "C" { + fn mach_task_self() -> libc::c_uint; + fn task_info( + task: libc::c_uint, + flavor: libc::c_uint, + task_info: *mut libc::c_void, + inout_count: *mut libc::c_uint, + ) -> libc::c_int; + } + + const MACH_TASK_BASIC_INFO: libc::c_uint = 20; + + #[repr(C)] + struct MachTaskBasicInfo { + virtual_size: u64, + resident_size: u64, + resident_size_max: u64, + user_time: u64, + system_time: u64, + policy: i32, + suspend_count: i32, + } + + pub fn debug_ram() -> Result { + unsafe { + let mut info = MachTaskBasicInfo { + virtual_size: 0, + resident_size: 0, + resident_size_max: 0, + user_time: 0, + system_time: 0, + policy: 0, + suspend_count: 0, + }; + let mut count = mem::size_of::() as libc::c_uint + / mem::size_of::() as libc::c_uint; + let kr = task_info( + mach_task_self(), + MACH_TASK_BASIC_INFO, + &mut info as *mut _ as *mut libc::c_void, + &mut count, + ); + if kr == 0 { + Ok(info.resident_size as usize) + } else { + Err(format!("Failed to get task info. Error code: {}", kr)) + } + } + } +} + #[allow(clippy::cognitive_complexity)] pub(crate) fn extract_output_and_log_execution_result( result: &TransactionExecutionResult, @@ -87,13 +143,16 @@ pub(crate) fn extract_output_and_log_execution_result( let case = format!("{}::{}", case_category, case_name); match result { TransactionExecutionResult::Ok(info) => { - /* trunk-ignore(clippy/option_if_let_else) */ if let Some(err) = info.revert_error.as_ref() { - warn!("{} reverted:\n{}", case, err.replace("\\n", "\n")); + warn!("{} reverted:\n{}", case, err.to_string()); return None; } info!("{} passed: {:?}", case, info.receipt.resources); + #[cfg(target_os = "macos")] + { + println!("Current memory usage: {:?} bytes", debug_ram::debug_ram()); + } if let Some(call) = info.execute_call_info.as_ref() { use starknet::core::types::Felt; let events = kakarot_execution_events(call); diff --git a/crates/ef-testing/src/test_utils/mod.rs b/crates/ef-testing/src/test_utils/mod.rs index 4424346c..518d082d 100644 --- a/crates/ef-testing/src/test_utils/mod.rs +++ b/crates/ef-testing/src/test_utils/mod.rs @@ -1,4 +1,8 @@ +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; use std::sync::Once; +use std::thread; +use std::time::{Duration, Instant}; use tracing_subscriber::{filter, FmtSubscriber}; @@ -16,3 +20,75 @@ pub fn setup() { .expect("setting tracing default failed"); }) } + +pub struct TestMonitor { + /// thresholds in seconds + thresholds: Vec, +} + +impl TestMonitor { + pub const fn new(thresholds: Vec) -> Self { + Self { thresholds } + } + + pub fn run(&mut self, test_name: &str, test_fn: F) -> T + where + F: FnOnce() -> T, + { + let start_time = Instant::now(); + let is_running = Arc::new(AtomicBool::new(true)); + let is_running_clone = is_running.clone(); + + // Spawn monitoring thread + let test_name = test_name.to_string(); + let test_name_clone = test_name.clone(); + let thresholds = self.thresholds.clone(); + let monitor_thread = thread::spawn(move || { + while is_running_clone.load(Ordering::SeqCst) { + let duration = start_time.elapsed().as_secs(); + + // Check each threshold + for &threshold in &thresholds { + if duration > threshold { + println!( + "\nWARNING: Test '{}' has been running for over {} seconds\n\ + Current duration: {:.1}s", + test_name, threshold, duration as f64 + ); + // Sleep longer for higher thresholds to reduce noise + thread::sleep(Duration::from_secs(std::cmp::min(threshold / 2, 30))); + break; + } + } + thread::sleep(Duration::from_secs(1)); + } + }); + + // Run the actual test + let result = test_fn(); + + // Stop the monitoring thread + is_running.store(false, Ordering::SeqCst); + let _ = monitor_thread.join(); + + // Print final duration for slow tests + let final_duration = start_time.elapsed().as_secs(); + if final_duration > self.thresholds[0] { + println!( + "\nTest '{}' completed in {:.1} seconds", + test_name_clone, final_duration as f64 + ); + } + + result + } +} + +// Helper macro to make it easier to use +#[macro_export] +macro_rules! monitor_test { + ($name:expr, $thresholds:expr, $test:expr) => {{ + let mut monitor = TestMonitor::new($thresholds.to_vec()); + monitor.run($name, $test) + }}; +} diff --git a/crates/sequencer/Cargo.toml b/crates/sequencer/Cargo.toml index b03c846e..2a1003ed 100644 --- a/crates/sequencer/Cargo.toml +++ b/crates/sequencer/Cargo.toml @@ -16,12 +16,19 @@ serde = { workspace = true } serde_json = { workspace = true } starknet_api = { workspace = true } starknet = { workspace = true } +cairo-lang-sierra = { workspace = true } +cairo-native = { workspace = true } +cairo-lang-starknet-classes = { workspace = true } # Other eyre = { workspace = true } tracing = { workspace = true } thiserror = { workspace = true } hashbrown = { workspace = true } +cached = "0.53.1" +once_cell = "1.19.0" +libloading = "0.8.5" +lazy_static.workspace = true [dev-dependencies] lazy_static = { workspace = true } diff --git a/crates/sequencer/src/commit.rs b/crates/sequencer/src/commit.rs index 21f4124b..cee8d451 100644 --- a/crates/sequencer/src/commit.rs +++ b/crates/sequencer/src/commit.rs @@ -12,18 +12,18 @@ where { fn commit(cached_state: &mut CachedState<&mut S>) -> StateResult<()> { let diff = cached_state.to_state_diff()?; - for (address, class_hash) in diff.class_hashes { + for (address, class_hash) in diff.state_maps.class_hashes { cached_state.state.set_class_hash_at(address, class_hash)?; } - for (address, _) in diff.nonces { + for (address, _) in diff.state_maps.nonces { cached_state.state.increment_nonce(address)?; } - for ((address, storage_key), value) in &diff.storage { + for ((address, storage_key), value) in &diff.state_maps.storage { cached_state .state .set_storage_at(*address, *storage_key, *value)?; } - for (class_hash, compiled_class_hash) in diff.compiled_class_hashes { + for (class_hash, compiled_class_hash) in diff.state_maps.compiled_class_hashes { cached_state .state .set_compiled_class_hash(class_hash, compiled_class_hash)?; diff --git a/crates/sequencer/src/lib.rs b/crates/sequencer/src/lib.rs index 0731f789..ae4a953d 100644 --- a/crates/sequencer/src/lib.rs +++ b/crates/sequencer/src/lib.rs @@ -1,6 +1,7 @@ pub mod commit; pub mod constants; pub mod execution; +pub mod native; pub mod sequencer; pub mod serde; pub mod state; diff --git a/crates/sequencer/src/native.rs b/crates/sequencer/src/native.rs new file mode 100644 index 00000000..ae6f9125 --- /dev/null +++ b/crates/sequencer/src/native.rs @@ -0,0 +1,105 @@ +use blockifier::execution::contract_class::{ + CompiledClassV0, CompiledClassV1, RunnableCompiledClass, +}; +use blockifier::execution::native::contract_class::NativeCompiledClassV1; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::contract_class::ContractClass as SierraContractClass; +use cairo_native::executor::AotContractExecutor; +use starknet_api::core::ClassHash; + +use lazy_static::lazy_static; +use std::{fs, path::PathBuf}; + +lazy_static! { + static ref NATIVE_CACHE_DIR: PathBuf = setup_native_cache_dir(); +} + +fn generate_library_path(class_hash: ClassHash) -> PathBuf { + NATIVE_CACHE_DIR.join(class_hash.to_string().trim_start_matches("0x")) +} + +fn setup_native_cache_dir() -> PathBuf { + let path = std::env::var("NATIVE_CACHE_DIR") + .map(PathBuf::from) + .unwrap_or_else(|_| std::env::current_dir().unwrap().join("native_cache")); + fs::create_dir_all(&path).ok(); + path +} + +/// Load a compiled native contract into memory +/// +/// Tries to load the compiled contract class from library_output_path if it +/// exists, otherwise it will compile the raw_sierra_class, load it into memory +/// and save the compilation artifact to library_output_path. +fn native_try_from_json_string( + raw_sierra_class: &str, + library_output_path: &PathBuf, +) -> Result> { + let maybe_cached_executor = AotContractExecutor::load(library_output_path); + + // see blockifier/src/test_utils/struct_impls.rs + let sierra_contract_class: SierraContractClass = + serde_json::from_str(raw_sierra_class).unwrap(); + + let sierra_program = sierra_contract_class + .extract_sierra_program() + .expect("Cannot extract sierra program from sierra contract class"); + + // Compile the sierra contract class into casm + let casm_contract_class = + CasmContractClass::from_contract_class(sierra_contract_class.clone(), false, usize::MAX) + .expect("Cannot compile sierra contract class into casm contract class"); + let casm = CompiledClassV1::try_from(casm_contract_class) + .expect("Cannot get CompiledClassV1 from CasmContractClass"); + + if let Ok(executor) = maybe_cached_executor { + println!("Loading cached executor"); + let native_class = NativeCompiledClassV1::new(executor, casm); + return Ok(native_class); + } + + println!("Creating new executor"); + let start_time = std::time::Instant::now(); + let mut executor = AotContractExecutor::new( + &sierra_program, + &sierra_contract_class.entry_points_by_type, + cairo_native::OptLevel::Default, + ) + .expect("Cannot compile sierra into native"); + let duration = start_time.elapsed(); + executor.save(library_output_path)?; + println!("Created and saved AoTExecutor in {:.2?}", duration); + + let native_class = NativeCompiledClassV1::new(executor, casm); + Ok(native_class) +} + +pub fn class_from_json_str( + raw_sierra: &str, + class_hash: ClassHash, +) -> Result { + let class_def = raw_sierra.to_string(); + let class: RunnableCompiledClass = + if let Ok(class) = CompiledClassV0::try_from_json_string(class_def.as_str()) { + class.into() + } else if let Ok(class) = CompiledClassV1::try_from_json_string(class_def.as_str()) { + class.into() + } else if let Ok(class) = { + let library_output_path = generate_library_path(class_hash); + let maybe_class = native_try_from_json_string(class_def.as_str(), &library_output_path); + + maybe_class.map_or_else( + |err| { + println!("Native contract failed with error {:?}", err); + Err(()) + }, + Ok, + ) + } { + class.into() + } else { + return Err("not a valid contract class".to_string()); + }; + + Ok(class) +} diff --git a/crates/sequencer/src/resources/versioned_constants.json b/crates/sequencer/src/resources/versioned_constants.json index 33579709..78c0ed90 100644 --- a/crates/sequencer/src/resources/versioned_constants.json +++ b/crates/sequencer/src/resources/versioned_constants.json @@ -9,31 +9,52 @@ "max_contract_bytecode_size": 81920 }, "invoke_tx_max_n_steps": 50000000, - "l2_resource_gas_costs": { + "execute_max_sierra_gas": 1000000000, + "deprecated_l2_resource_gas_costs": { "gas_per_data_felt": [128, 1000], "event_key_factor": [2, 1], - "gas_per_code_byte": [875, 1000] + "gas_per_code_byte": [32, 1000] + }, + "archival_data_gas_costs": { + "gas_per_data_felt": [5120, 1], + "event_key_factor": [2, 1], + "gas_per_code_byte": [1280, 1] }, "disable_cairo0_redeclaration": true, + "enable_stateful_compression": true, + "allocation_cost": { + "blob_cost": { + "l1_gas": 0, + "l1_data_gas": 32, + "l2_gas": 0 + }, + "gas_cost": { + "l1_gas": 551, + "l1_data_gas": 0, + "l2_gas": 0 + } + }, + "ignore_inner_event_resources": false, + "enable_reverts": true, "max_recursion_depth": 50, "segment_arena_cells": false, "os_constants": { - "block_hash_contract_address": 1, "call_contract_gas_cost": { "entry_point_gas_cost": 1, - "step_gas_cost": 10, - "syscall_base_gas_cost": 1 + "step_gas_cost": 860, + "range_check_gas_cost": 15 }, "constructor_entry_point_selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194", "default_entry_point_selector": 0, "deploy_gas_cost": { "entry_point_gas_cost": 1, - "step_gas_cost": 200, - "syscall_base_gas_cost": 1 + "step_gas_cost": 1128, + "range_check_gas_cost": 18, + "pedersen_gas_cost": 7 }, "emit_event_gas_cost": { - "step_gas_cost": 10, - "syscall_base_gas_cost": 1 + "step_gas_cost": 100, + "range_check_gas_cost": 1 }, "entry_point_gas_cost": { "entry_point_initial_budget": 1, @@ -49,20 +70,18 @@ "error_invalid_input_len": "Invalid input length", "error_invalid_argument": "Invalid argument", "error_out_of_gas": "Out of gas", + "error_entry_point_failed": "ENTRYPOINT_FAILED", + "error_entry_point_not_found": "ENTRYPOINT_NOT_FOUND", "execute_entry_point_selector": "0x15d40a3d6ca2ac30f4031e42be28da9b056fef9bb7357ac5e85627ee876e5ad", - "fee_transfer_gas_cost": { - "entry_point_gas_cost": 1, - "step_gas_cost": 100 - }, "get_block_hash_gas_cost": { - "step_gas_cost": 50, - "syscall_base_gas_cost": 1 + "step_gas_cost": 104, + "range_check_gas_cost": 2 }, "get_execution_info_gas_cost": { - "step_gas_cost": 10, - "syscall_base_gas_cost": 1 + "step_gas_cost": 100, + "range_check_gas_cost": 1 }, - "initial_gas_cost": { + "default_initial_gas_cost": { "step_gas_cost": 500000000 }, "keccak_gas_cost": { @@ -73,99 +92,113 @@ "l1_gas_index": 0, "l1_handler_version": 0, "l2_gas": "L2_GAS", + "l1_data_gas": "L1_DATA", + "l1_data_gas_index": 2, "l2_gas_index": 1, "library_call_gas_cost": { - "call_contract_gas_cost": 1 + "entry_point_gas_cost": 1, + "step_gas_cost": 836, + "range_check_gas_cost": 15 }, "sha256_process_block_gas_cost": { - "step_gas_cost": 1852, + "step_gas_cost": 1855, "range_check_gas_cost": 65, "bitwise_builtin_gas_cost": 1115, "syscall_base_gas_cost": 1 }, "memory_hole_gas_cost": 10, "nop_entry_point_offset": -1, + "os_contract_addresses": { + "block_hash_contract_address": 1, + "alias_contract_address": 2, + "reserved_contract_address": 3 + }, "range_check_gas_cost": 70, - "pedersen_gas_cost": 0, - "bitwise_builtin_gas_cost": 594, - "ecop_gas_cost": 0, - "poseidon_gas_cost": 0, - "add_mod_gas_cost": 0, - "mul_mod_gas_cost": 0, + "pedersen_gas_cost": 4050, + "bitwise_builtin_gas_cost": 583, + "ecop_gas_cost": 4085, + "poseidon_gas_cost": 491, + "add_mod_gas_cost": 230, + "mul_mod_gas_cost": 604, "replace_class_gas_cost": { - "step_gas_cost": 50, - "syscall_base_gas_cost": 1 + "step_gas_cost": 104, + "range_check_gas_cost": 1 }, "secp256k1_add_gas_cost": { "range_check_gas_cost": 29, - "step_gas_cost": 406 + "step_gas_cost": 410 }, "secp256k1_get_point_from_x_gas_cost": { "memory_hole_gas_cost": 20, "range_check_gas_cost": 30, - "step_gas_cost": 391 + "step_gas_cost": 395 }, "secp256k1_get_xy_gas_cost": { "memory_hole_gas_cost": 40, "range_check_gas_cost": 11, - "step_gas_cost": 239 + "step_gas_cost": 207 }, "secp256k1_mul_gas_cost": { "memory_hole_gas_cost": 2, "range_check_gas_cost": 7045, - "step_gas_cost": 76501 + "step_gas_cost": 76505 }, "secp256k1_new_gas_cost": { "memory_hole_gas_cost": 40, "range_check_gas_cost": 35, - "step_gas_cost": 475 + "step_gas_cost": 461 }, "secp256r1_add_gas_cost": { "range_check_gas_cost": 57, - "step_gas_cost": 589 + "step_gas_cost": 593 }, "secp256r1_get_point_from_x_gas_cost": { "memory_hole_gas_cost": 20, "range_check_gas_cost": 44, - "step_gas_cost": 510 + "step_gas_cost": 514 }, "secp256r1_get_xy_gas_cost": { "memory_hole_gas_cost": 40, "range_check_gas_cost": 11, - "step_gas_cost": 241 + "step_gas_cost": 209 }, "secp256r1_mul_gas_cost": { "memory_hole_gas_cost": 2, "range_check_gas_cost": 13961, - "step_gas_cost": 125340 + "step_gas_cost": 125344 }, "secp256r1_new_gas_cost": { "memory_hole_gas_cost": 40, "range_check_gas_cost": 49, - "step_gas_cost": 594 + "step_gas_cost": 580 }, "send_message_to_l1_gas_cost": { - "step_gas_cost": 50, - "syscall_base_gas_cost": 1 + "step_gas_cost": 141, + "range_check_gas_cost": 1 }, "sierra_array_len_bound": 4294967296, "step_gas_cost": 100, "storage_read_gas_cost": { - "step_gas_cost": 50, - "syscall_base_gas_cost": 1 + "step_gas_cost": 100, + "range_check_gas_cost": 1 }, "storage_write_gas_cost": { - "step_gas_cost": 50, - "syscall_base_gas_cost": 1 + "step_gas_cost": 100, + "range_check_gas_cost": 1 + }, + "get_class_hash_at_gas_cost": { + "step_gas_cost": 100, + "range_check_gas_cost": 1 }, "stored_block_hash_buffer": 10, "syscall_base_gas_cost": { "step_gas_cost": 100 }, "transaction_gas_cost": { - "entry_point_gas_cost": 2, - "fee_transfer_gas_cost": 1, - "step_gas_cost": 100 + "step_gas_cost": 4098, + "pedersen_gas_cost": 4, + "range_check_gas_cost": 77, + "poseidon_gas_cost": 11 }, "transfer_entry_point_selector": "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e", "validate_declare_entry_point_selector": "0x289da278a8dc833409cabfdad1581e8e7d40e42dcaed693fa4008dcdb4963b3", @@ -180,7 +213,7 @@ "os_resources": { "execute_syscalls": { "CallContract": { - "n_steps": 827, + "n_steps": 866, "builtin_instance_counter": { "range_check_builtin": 15 }, @@ -201,7 +234,7 @@ "n_memory_holes": 0 }, "Deploy": { - "n_steps": 1097, + "n_steps": 1132, "builtin_instance_counter": { "pedersen_builtin": 7, "range_check_builtin": 18 @@ -280,7 +313,7 @@ "n_memory_holes": 0 }, "LibraryCall": { - "n_steps": 818, + "n_steps": 842, "builtin_instance_counter": { "range_check_builtin": 15 }, @@ -294,7 +327,7 @@ "n_memory_holes": 0 }, "ReplaceClass": { - "n_steps": 98, + "n_steps": 104, "builtin_instance_counter": { "range_check_builtin": 1 }, @@ -378,7 +411,7 @@ "n_memory_holes": 0 }, "Sha256ProcessBlock": { - "n_steps": 1855, + "n_steps": 1865, "builtin_instance_counter": { "range_check_builtin": 65, "bitwise_builtin": 1115 @@ -393,6 +426,13 @@ "n_memory_holes": 0 }, "StorageWrite": { + "n_steps": 93, + "builtin_instance_counter": { + "range_check_builtin": 1 + }, + "n_memory_holes": 0 + }, + "GetClassHashAt": { "n_steps": 89, "builtin_instance_counter": { "range_check_builtin": 1 @@ -404,10 +444,11 @@ "Declare": { "deprecated_resources": { "constant": { - "n_steps": 2973, + "n_steps": 3203, "builtin_instance_counter": { "pedersen_builtin": 16, - "range_check_builtin": 53 + "range_check_builtin": 56, + "poseidon_builtin": 4 }, "n_memory_holes": 0 }, @@ -419,11 +460,11 @@ }, "resources": { "constant": { - "n_steps": 3079, + "n_steps": 3346, "builtin_instance_counter": { "pedersen_builtin": 4, - "range_check_builtin": 58, - "poseidon_builtin": 10 + "range_check_builtin": 64, + "poseidon_builtin": 14 }, "n_memory_holes": 0 }, @@ -437,7 +478,7 @@ "DeployAccount": { "deprecated_resources": { "constant": { - "n_steps": 4015, + "n_steps": 4161, "builtin_instance_counter": { "pedersen_builtin": 23, "range_check_builtin": 72 @@ -454,10 +495,10 @@ }, "resources": { "constant": { - "n_steps": 4137, + "n_steps": 4321, "builtin_instance_counter": { "pedersen_builtin": 11, - "range_check_builtin": 77, + "range_check_builtin": 80, "poseidon_builtin": 10 }, "n_memory_holes": 0 @@ -474,7 +515,7 @@ "InvokeFunction": { "deprecated_resources": { "constant": { - "n_steps": 3763, + "n_steps": 3918, "builtin_instance_counter": { "pedersen_builtin": 14, "range_check_builtin": 69 @@ -491,10 +532,10 @@ }, "resources": { "constant": { - "n_steps": 3904, + "n_steps": 4102, "builtin_instance_counter": { "pedersen_builtin": 4, - "range_check_builtin": 74, + "range_check_builtin": 77, "poseidon_builtin": 11 }, "n_memory_holes": 0 @@ -511,7 +552,7 @@ "L1Handler": { "deprecated_resources": { "constant": { - "n_steps": 1233, + "n_steps": 1279, "builtin_instance_counter": { "pedersen_builtin": 11, "range_check_builtin": 16 @@ -551,18 +592,22 @@ } }, "validate_max_n_steps": 1000000, + "validate_max_sierra_gas": 100000000, + "min_compiler_version_for_sierra_gas": "2.8.0", "vm_resource_fee_cost": { - "add_mod_builtin": [4, 100], - "bitwise_builtin": [16, 100], - "ec_op_builtin": [256, 100], - "ecdsa_builtin": [512, 100], - "keccak_builtin": [512, 100], - "mul_mod_builtin": [4, 100], - "n_steps": [25, 10000], - "output_builtin": [0, 1], - "pedersen_builtin": [8, 100], - "poseidon_builtin": [8, 100], - "range_check_builtin": [4, 100], - "range_check96_builtin": [4, 100] + "builtins": { + "add_mod_builtin": [4, 100], + "bitwise_builtin": [16, 100], + "ec_op_builtin": [256, 100], + "ecdsa_builtin": [512, 100], + "keccak_builtin": [512, 100], + "mul_mod_builtin": [4, 100], + "output_builtin": [0, 1], + "pedersen_builtin": [8, 100], + "poseidon_builtin": [8, 100], + "range_check_builtin": [4, 100], + "range_check96_builtin": [4, 100] + }, + "n_steps": [25, 10000] } } diff --git a/crates/sequencer/src/sequencer.rs b/crates/sequencer/src/sequencer.rs index a3964e21..b3c69ac2 100644 --- a/crates/sequencer/src/sequencer.rs +++ b/crates/sequencer/src/sequencer.rs @@ -12,6 +12,7 @@ use blockifier::{ }, }; use starknet_api::core::ContractAddress; +use starknet_api::executable_transaction::AccountTransaction; /// Sequencer is the main struct of the sequencer crate. #[derive(Clone)] @@ -72,18 +73,15 @@ where transaction: Transaction, ) -> TransactionExecutionResult { let sender_address = match &transaction { - Transaction::AccountTransaction(tx) => match tx { - blockifier::transaction::account_transaction::AccountTransaction::Invoke(tx) => { - tx.tx.sender_address() + Transaction::Account(account_tx) => { + let tx = &account_tx.tx; + match tx { + AccountTransaction::Invoke(tx) => tx.sender_address(), + AccountTransaction::Declare(tx) => tx.sender_address(), + AccountTransaction::DeployAccount(tx) => tx.contract_address(), } - blockifier::transaction::account_transaction::AccountTransaction::Declare(tx) => { - tx.tx().sender_address() - } - blockifier::transaction::account_transaction::AccountTransaction::DeployAccount( - tx, - ) => tx.contract_address(), - }, - Transaction::L1HandlerTransaction(_) => ContractAddress::from(0u8), + } + Transaction::L1Handler(_) => ContractAddress::from(0u8), }; let mut cached_state = CachedState::new(&mut self.state); @@ -115,25 +113,29 @@ where mod tests { use std::fmt::Display; use std::fs::File; - use std::num::NonZeroU128; - use blockifier::abi::abi_utils::get_storage_var_address; - use blockifier::blockifier::block::{BlockInfo, GasPrices}; use blockifier::bouncer::BouncerConfig; use blockifier::context::ChainInfo; use blockifier::context::{BlockContext, FeeTokenAddresses}; - use blockifier::execution::contract_class::{ContractClass, ContractClassV0, ContractClassV1}; + use blockifier::execution::contract_class::{ + CompiledClassV0, CompiledClassV1, RunnableCompiledClass, + }; use blockifier::state::state_api::State as BlockifierState; use blockifier::transaction::account_transaction::AccountTransaction; - use blockifier::transaction::transactions::InvokeTransaction as BlockifierInvokeTransaction; + use blockifier::transaction::transaction_execution::Transaction as ExecutionTransaction; use blockifier::versioned_constants::VersionedConstants; use starknet::core::types::Felt; use starknet::macros::selector; + use starknet_api::abi::abi_utils::get_storage_var_address; + use starknet_api::block::BlockInfo; use starknet_api::block::{BlockNumber, BlockTimestamp}; - use starknet_api::core::{ChainId, ClassHash, ContractAddress, Nonce}; - use starknet_api::executable_transaction::InvokeTransaction; + use starknet_api::core::{ChainId, ClassHash, ContractAddress}; + use starknet_api::executable_transaction::{ + AccountTransaction as AccountTransactionEnum, InvokeTransaction, + }; + use starknet_api::transaction::fields::{Calldata, Fee}; use starknet_api::transaction::{ - Calldata, Fee, InvokeTransactionV1, TransactionHash, TransactionSignature, + InvokeTransaction as InvokeTransactionTypes, InvokeTransactionV1, }; use crate::constants::test_constants::{ @@ -158,19 +160,19 @@ mod tests { } } - fn read_contract_class_v0(path: &str) -> ContractClass { + fn read_contract_class_v0(path: &str) -> RunnableCompiledClass { let reader = File::open(path).unwrap(); - let contract_class: ContractClassV0 = serde_json::from_reader(reader).unwrap(); + let contract_class: CompiledClassV0 = serde_json::from_reader(reader).unwrap(); - ContractClass::V0(contract_class) + RunnableCompiledClass::V0(contract_class) } - fn read_contract_class_v1(path: &str) -> ContractClass { + fn read_contract_class_v1(path: &str) -> RunnableCompiledClass { let raw_contract_class = std::fs::read_to_string(path).unwrap(); - let contract_class: ContractClassV1 = - ContractClassV1::try_from_json_string(&raw_contract_class).unwrap(); + let contract_class: CompiledClassV1 = + CompiledClassV1::try_from_json_string(&raw_contract_class).unwrap(); - ContractClass::V1(contract_class) + RunnableCompiledClass::V1(contract_class) } fn declare_and_deploy_contract( @@ -253,14 +255,7 @@ mod tests { block_number: BlockNumber(1), block_timestamp: BlockTimestamp(1), sequencer_address: *SEQUENCER_ADDRESS, - gas_prices: GasPrices::new( - NonZeroU128::new(1).unwrap(), - NonZeroU128::new(1).unwrap(), - NonZeroU128::new(1).unwrap(), - NonZeroU128::new(1).unwrap(), - NonZeroU128::new(1).unwrap(), - NonZeroU128::new(1).unwrap(), - ), + gas_prices: Default::default(), use_kzg_da: false, }; @@ -281,27 +276,30 @@ mod tests { BlockContext::new(block_info, chain_info, versioned_constants, bouncer_config) } - fn test_transaction() -> Transaction { - Transaction::AccountTransaction(AccountTransaction::Invoke(BlockifierInvokeTransaction { - tx: InvokeTransaction { - tx: starknet_api::transaction::InvokeTransaction::V1(InvokeTransactionV1 { - sender_address: *TEST_ACCOUNT, - calldata: Calldata( - vec![ - *TEST_CONTRACT.0.key(), // destination - selector!("inc"), - Felt::ZERO, // no data - ] - .into(), - ), - max_fee: Fee(1_000_000), - signature: TransactionSignature(vec![]), - nonce: Nonce(Felt::ZERO), - }), - tx_hash: TransactionHash(Felt::ZERO), - }, + fn test_transaction() -> ExecutionTransaction { + let invoke_tx = InvokeTransactionV1 { + sender_address: *TEST_ACCOUNT, + calldata: Calldata( + vec![ + *TEST_CONTRACT.0.key(), // destination + selector!("inc"), + Felt::ZERO, // no data + ] + .into(), + ), + max_fee: Fee(1_000_000), + ..Default::default() + }; + let transaction = InvokeTransaction::create( + InvokeTransactionTypes::V1(invoke_tx), + &ChainId::Other("KKRT".into()), + ) + .unwrap(); + + ExecutionTransaction::Account(AccountTransaction { + tx: AccountTransactionEnum::Invoke(transaction), only_query: false, - })) + }) } sequencer_test!(CairoVersion::V0, test_sequencer_cairo_0); diff --git a/crates/sequencer/src/serde.rs b/crates/sequencer/src/serde.rs index 1539f8e6..6945a735 100644 --- a/crates/sequencer/src/serde.rs +++ b/crates/sequencer/src/serde.rs @@ -1,6 +1,6 @@ use std::{fs, io, path::Path}; -use blockifier::execution::contract_class::ContractClass; +use blockifier::execution::contract_class::RunnableCompiledClass; use hashbrown::HashMap; use serde::{Deserialize, Serialize}; use starknet::core::types::Felt; @@ -48,7 +48,7 @@ pub enum SerializationError { #[derive(Clone, Debug, Serialize, Deserialize, Default)] pub struct SerializableState { - pub classes: HashMap, + pub classes: HashMap, pub compiled_classes_hash: HashMap, pub contracts: HashMap, #[serde(with = "serialize_contract_storage")] @@ -135,7 +135,7 @@ mod serialize_contract_storage { mod tests { use super::*; use blockifier::{ - execution::contract_class::{ContractClass, ContractClassV0}, + execution::contract_class::{CompiledClassV0, RunnableCompiledClass}, state::state_api::State as _, }; @@ -151,8 +151,8 @@ mod tests { // setting up entry for state.classes let class_hash = ClassHash(Felt::ONE); let contract_class = include_str!("./test_data/cairo_0/compiled_classes/counter.json"); - let contract_class: ContractClassV0 = serde_json::from_str(contract_class).expect("failed to deserialize ContractClass from ./crates/sequencer/test_data/cairo_1/compiled_classes/account.json"); - let contract_class = ContractClass::V0(contract_class); + let contract_class: CompiledClassV0 = serde_json::from_str(contract_class).expect("failed to deserialize RunnableCompiledClass from ./crates/sequencer/test_data/cairo_1/compiled_classes/account.json"); + let contract_class = RunnableCompiledClass::V0(contract_class); let compiled_class_hash = CompiledClassHash(Felt::ONE); let contract_address = *TEST_CONTRACT; diff --git a/crates/sequencer/src/state.rs b/crates/sequencer/src/state.rs index f4581440..12c58fb9 100644 --- a/crates/sequencer/src/state.rs +++ b/crates/sequencer/src/state.rs @@ -1,6 +1,6 @@ use crate::commit::Committer; use crate::serde::SerializableState; -use blockifier::execution::contract_class::ContractClass; +use blockifier::execution::contract_class::RunnableCompiledClass; use blockifier::state::errors::StateError; use blockifier::state::state_api::{ State as BlockifierState, StateReader as BlockifierStateReader, StateResult, @@ -19,7 +19,7 @@ pub type ContractStorageKey = (ContractAddress, StorageKey); /// See [Performance](https://github.com/rust-lang/hashbrown?tab=readme-ov-file#performance) #[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct State { - classes: HashMap, + classes: HashMap, compiled_class_hashes: HashMap, contracts: HashMap, storage: HashMap, @@ -111,7 +111,7 @@ impl BlockifierState for &mut State { fn set_contract_class( &mut self, class_hash: ClassHash, - contract_class: ContractClass, + contract_class: RunnableCompiledClass, ) -> StateResult<()> { self.classes.insert(class_hash, contract_class); Ok(()) @@ -164,11 +164,13 @@ impl BlockifierStateReader for &mut State { /// # Errors /// /// If the compiled class is not declared. - fn get_compiled_contract_class(&self, class_hash: ClassHash) -> StateResult { - self.classes + fn get_compiled_class(&self, class_hash: ClassHash) -> StateResult { + let res = self + .classes .get(&class_hash) .cloned() - .ok_or_else(|| StateError::UndeclaredClassHash(class_hash)) + .ok_or(StateError::UndeclaredClassHash(class_hash))?; + Ok(res) } /// # Errors @@ -178,13 +180,13 @@ impl BlockifierStateReader for &mut State { self.compiled_class_hashes .get(&class_hash) .copied() - .ok_or_else(|| StateError::UndeclaredClassHash(class_hash)) + .ok_or(StateError::UndeclaredClassHash(class_hash)) } } #[cfg(test)] mod tests { - use blockifier::execution::contract_class::ContractClassV0; + use blockifier::execution::contract_class::CompiledClassV0; use crate::constants::test_constants::{ONE_PATRICIA, TEST_CONTRACT}; @@ -245,17 +247,12 @@ mod tests { // When state - .set_contract_class( - ClassHash(Felt::ONE), - ContractClass::V0(ContractClassV0::default()), - ) + .set_contract_class(ClassHash(Felt::ONE), CompiledClassV0::default().into()) .unwrap(); // Then - let expected = ContractClass::V0(ContractClassV0::default()); - let actual = state - .get_compiled_contract_class(ClassHash(Felt::ONE)) - .unwrap(); + let expected = RunnableCompiledClass::V0(CompiledClassV0::default()); + let actual = state.get_compiled_class(ClassHash(Felt::ONE)).unwrap(); assert_eq!(expected, actual); } @@ -266,9 +263,7 @@ mod tests { let state = &mut State::default(); // When - state - .get_compiled_contract_class(ClassHash(Felt::ONE)) - .unwrap(); + state.get_compiled_class(ClassHash(Felt::ONE)).unwrap(); } #[test] diff --git a/crates/sequencer/src/transaction.rs b/crates/sequencer/src/transaction.rs index 907802b3..e0114206 100644 --- a/crates/sequencer/src/transaction.rs +++ b/crates/sequencer/src/transaction.rs @@ -1,6 +1,5 @@ use std::sync::Arc; -use blockifier::transaction::transactions::InvokeTransaction as BlockifierInvokeTransaction; use blockifier::transaction::{ account_transaction::AccountTransaction, transaction_execution::Transaction as ExecutionTransaction, @@ -8,10 +7,11 @@ use blockifier::transaction::{ use starknet::core::crypto::compute_hash_on_elements; use starknet::core::types::{BroadcastedInvokeTransaction, BroadcastedTransaction, Felt}; use starknet_api::core::Nonce; -use starknet_api::executable_transaction::InvokeTransaction; -use starknet_api::transaction::{ - Calldata, Fee, InvokeTransactionV1, TransactionHash, TransactionSignature, +use starknet_api::executable_transaction::{ + AccountTransaction as AccountTransactionEnum, InvokeTransaction, }; +use starknet_api::transaction::fields::{Calldata, Fee, TransactionSignature}; +use starknet_api::transaction::{InvokeTransactionV1, TransactionHash}; /// Wrapper around a Starknet-rs transaction. /// Allows for conversion from a Starknet-rs @@ -34,35 +34,29 @@ impl BroadcastedTransactionWrapper { match self.0 { BroadcastedTransaction::Invoke(invoke) => match invoke { BroadcastedInvokeTransaction::V1(invoke_v1) => { - Ok(ExecutionTransaction::AccountTransaction( - AccountTransaction::Invoke(BlockifierInvokeTransaction { - tx: InvokeTransaction { - tx: starknet_api::transaction::InvokeTransaction::V1( - InvokeTransactionV1 { - max_fee: Fee(invoke_v1.max_fee.to_biguint().try_into()?), - signature: TransactionSignature( - invoke_v1 - .signature - .into_iter() - .map(Into::into) - .collect(), - ), - nonce: Nonce(invoke_v1.nonce), - sender_address: invoke_v1.sender_address.try_into()?, - calldata: Calldata(Arc::new(invoke_v1.calldata.to_vec())), - }, - ), - tx_hash: TransactionHash(compute_transaction_hash( - invoke_v1.sender_address, - &invoke_v1.calldata, - invoke_v1.max_fee, - chain_id, - invoke_v1.nonce, - )), - }, - only_query: false, + Ok(ExecutionTransaction::Account(AccountTransaction { + tx: AccountTransactionEnum::Invoke(InvokeTransaction { + tx: starknet_api::transaction::InvokeTransaction::V1( + InvokeTransactionV1 { + max_fee: Fee(invoke_v1.max_fee.to_biguint().try_into()?), + signature: TransactionSignature( + invoke_v1.signature.into_iter().map(Into::into).collect(), + ), + nonce: Nonce(invoke_v1.nonce), + sender_address: invoke_v1.sender_address.try_into()?, + calldata: Calldata(Arc::new(invoke_v1.calldata.to_vec())), + }, + ), + tx_hash: TransactionHash(compute_transaction_hash( + invoke_v1.sender_address, + &invoke_v1.calldata, + invoke_v1.max_fee, + chain_id, + invoke_v1.nonce, + )), }), - )) + only_query: false, + })) } BroadcastedInvokeTransaction::V3(_) => { Err(eyre::eyre!("Unsupported InvokeTransaction version V3")) diff --git a/rust-toolchain b/rust-toolchain index 2e2b8c85..5d56faf9 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,2 +1,2 @@ [toolchain] -channel = "1.82.0" +channel = "nightly" diff --git a/scripts/dependencies.sh b/scripts/dependencies.sh new file mode 100644 index 00000000..5dac7648 --- /dev/null +++ b/scripts/dependencies.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +set -e + +[[ ${UID} == "0" ]] || SUDO="sudo" + +function install_essential_deps_linux() { + $SUDO bash -c ' + apt update && apt install -y \ + ca-certificates \ + curl \ + git \ + gnupg \ + jq \ + libssl-dev \ + lsb-release \ + pkg-config \ + ripgrep \ + software-properties-common \ + zstd \ + wget \ + lld + ' +} + +function setup_llvm_deps() { + case "$(uname)" in + Darwin) + brew update + brew install llvm@19 + ;; + Linux) + $SUDO bash -c 'apt update && apt-get install -y \ + libgmp3-dev \ + llvm-19 \ + libmlir-19-dev \ + libpolly-19-dev \ + libzstd-dev \ + mlir-19-tools + ' + # Add LLVM to PATH by creating a file in profile.d + echo 'export PATH=/usr/lib/llvm-19/bin:$PATH' | $SUDO tee /etc/profile.d/llvm19.sh + $SUDO chmod +x /etc/profile.d/llvm19.sh + # Source the file immediately + source /etc/profile.d/llvm19.sh + ;; + *) + echo "Error: Unsupported operating system" + exit 1 + ;; + esac +} + +function main() { + [ "$(uname)" = "Linux" ] && install_essential_deps_linux + setup_llvm_deps + echo "LLVM dependencies installed successfully." +} + +main "$@"