From 1d3318a91b34f5b8176382fcf68744390948498a Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Fri, 19 Jul 2024 03:10:09 +0800 Subject: [PATCH] Bump `blockifier` to support Cairo 2.7 (#2180) * workign bump for blockifier to ver 2.7. of cairo * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * no error * update resources log * remove commented code * clippy * fmt * restore lockfile * remove comment * remove unused dep * fmt * wip * update blockifier rev * fmt * Update crates/katana/executor/src/implementation/blockifier/state.rs Co-authored-by: glihm * Update crates/katana/executor/src/implementation/blockifier/state.rs Co-authored-by: glihm * apply suggestion * remove dbg --------- Co-authored-by: glihm --- Cargo.lock | 1003 ++++++++--------- bin/katana/src/main.rs | 2 - crates/dojo-test-utils/src/sequencer.rs | 2 - crates/katana/cairo/Cargo.toml | 17 +- crates/katana/cairo/src/lib.rs | 12 +- crates/katana/core/Cargo.toml | 1 - crates/katana/core/src/env.rs | 23 - crates/katana/executor/Cargo.toml | 4 +- crates/katana/executor/benches/execution.rs | 7 +- crates/katana/executor/benches/utils.rs | 23 - .../katana/executor/src/abstraction/error.rs | 8 +- .../src/implementation/blockifier/error.rs | 23 +- .../src/implementation/blockifier/mod.rs | 30 +- .../src/implementation/blockifier/state.rs | 149 ++- .../src/implementation/blockifier/utils.rs | 347 +++--- crates/katana/executor/src/utils.rs | 51 +- crates/katana/executor/tests/executor.rs | 2 +- crates/katana/executor/tests/fixtures/mod.rs | 23 +- .../katana/primitives/src/conversion/rpc.rs | 8 +- crates/katana/primitives/src/env.rs | 4 - crates/katana/primitives/src/genesis/json.rs | 4 +- crates/katana/primitives/src/receipt.rs | 39 +- crates/katana/primitives/src/trace.rs | 24 +- crates/katana/rpc/rpc-types/Cargo.toml | 1 + crates/katana/rpc/rpc-types/src/lib.rs | 1 + crates/katana/rpc/rpc-types/src/receipt.rs | 58 +- crates/katana/rpc/rpc-types/src/trace.rs | 45 +- crates/katana/rpc/rpc-types/src/utils.rs | 6 + crates/saya/core/Cargo.toml | 1 - crates/saya/core/src/blockchain/mod.rs | 21 - 30 files changed, 851 insertions(+), 1088 deletions(-) create mode 100644 crates/katana/rpc/rpc-types/src/utils.rs diff --git a/Cargo.lock b/Cargo.lock index 54a0ec60a7..0fccac086f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1841,8 +1841,8 @@ dependencies = [ [[package]] name = "blockifier" -version = "0.6.0-rc.2" -source = "git+https://github.com/dojoengine/blockifier?rev=57c11586#57c115864b5d2e9876efe289bd3dfbf05744a76b" +version = "0.8.0-dev.2" +source = "git+https://github.com/dojoengine/blockifier?branch=cairo-2.7#24029ba460e6a4304f5ca59dacd3cabd7bc34212" dependencies = [ "anyhow", "ark-ec", @@ -1850,12 +1850,11 @@ dependencies = [ "ark-secp256k1", "ark-secp256r1", "cached", - "cairo-felt", - "cairo-lang-casm 2.6.3", - "cairo-lang-runner 2.6.3", - "cairo-lang-starknet-classes 2.6.3", - "cairo-lang-utils 2.6.3", - "cairo-vm 0.9.2", + "cairo-lang-casm 2.7.0-rc.3", + "cairo-lang-runner 2.7.0-rc.3", + "cairo-lang-starknet-classes 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", + "cairo-vm 1.0.0-rc5", "derive_more", "indexmap 2.2.6", "itertools 0.10.5", @@ -1863,14 +1862,17 @@ dependencies = [ "log", "num-bigint", "num-integer", + "num-rational", "num-traits 0.2.19", "once_cell", "phf", + "rand", "rstest 0.17.0", "serde", "serde_json", + "sha2 0.10.8", "sha3", - "starknet-crypto 0.5.2", + "starknet-types-core", "starknet_api", "strum 0.24.1", "strum_macros 0.24.3", @@ -2254,26 +2256,12 @@ dependencies = [ "serde", ] -[[package]] -name = "cairo-lang-casm" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" -dependencies = [ - "cairo-lang-utils 2.6.3", - "indoc 2.0.5", - "num-bigint", - "num-traits 0.2.19", - "parity-scale-codec", - "serde", -] - [[package]] name = "cairo-lang-casm" version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6296d5748288d9fb97175d31aff9f68ea3f602456923895e512b078e9a2210a0" +source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ - "cairo-lang-utils 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.4", "indoc 2.0.5", "num-bigint", "num-traits 0.2.19", @@ -2283,10 +2271,11 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.6.4" -source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5abf875e93f696e783412d3f2a7c6f66e94e07c30b01559380b4d0707dc0050e" dependencies = [ - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.7.0-rc.3", "indoc 2.0.5", "num-bigint", "num-traits 0.2.19", @@ -2294,28 +2283,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cairo-lang-compiler" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" -dependencies = [ - "anyhow", - "cairo-lang-defs 2.6.3", - "cairo-lang-diagnostics 2.6.3", - "cairo-lang-filesystem 2.6.3", - "cairo-lang-lowering 2.6.3", - "cairo-lang-parser 2.6.3", - "cairo-lang-project 2.6.3", - "cairo-lang-semantic 2.6.3", - "cairo-lang-sierra 2.6.3", - "cairo-lang-sierra-generator 2.6.3", - "cairo-lang-syntax 2.6.3", - "cairo-lang-utils 2.6.3", - "salsa", - "smol_str", - "thiserror", -] - [[package]] name = "cairo-lang-compiler" version = "2.6.4" @@ -2329,10 +2296,10 @@ dependencies = [ "cairo-lang-parser 2.6.4", "cairo-lang-project 2.6.4", "cairo-lang-semantic 2.6.4", - "cairo-lang-sierra 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-sierra 2.6.4", "cairo-lang-sierra-generator 2.6.4", "cairo-lang-syntax 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", "indoc 2.0.5", "salsa", "smol_str", @@ -2340,11 +2307,27 @@ dependencies = [ ] [[package]] -name = "cairo-lang-debug" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +name = "cairo-lang-compiler" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f135e1768e199e88b04f824e34b9411ff49fc31970e77cbf5c6f448170441d18" dependencies = [ - "cairo-lang-utils 2.6.3", + "anyhow", + "cairo-lang-defs 2.7.0-rc.3", + "cairo-lang-diagnostics 2.7.0-rc.3", + "cairo-lang-filesystem 2.7.0-rc.3", + "cairo-lang-lowering 2.7.0-rc.3", + "cairo-lang-parser 2.7.0-rc.3", + "cairo-lang-project 2.7.0-rc.3", + "cairo-lang-semantic 2.7.0-rc.3", + "cairo-lang-sierra 2.7.0-rc.3", + "cairo-lang-sierra-generator 2.7.0-rc.3", + "cairo-lang-syntax 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", + "indoc 2.0.5", + "salsa", + "smol_str", + "thiserror", ] [[package]] @@ -2352,23 +2335,16 @@ name = "cairo-lang-debug" version = "2.6.4" source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", ] [[package]] -name = "cairo-lang-defs" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" -dependencies = [ - "cairo-lang-debug 2.6.3", - "cairo-lang-diagnostics 2.6.3", - "cairo-lang-filesystem 2.6.3", - "cairo-lang-parser 2.6.3", - "cairo-lang-syntax 2.6.3", - "cairo-lang-utils 2.6.3", - "itertools 0.11.0", - "salsa", - "smol_str", +name = "cairo-lang-debug" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e2bf0a6caf1e54938bc67ca082cbeb5385969784bfb1109c187ca9dc5e1806" +dependencies = [ + "cairo-lang-utils 2.7.0-rc.3", ] [[package]] @@ -2381,21 +2357,27 @@ dependencies = [ "cairo-lang-filesystem 2.6.4", "cairo-lang-parser 2.6.4", "cairo-lang-syntax 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", "itertools 0.12.1", "salsa", "smol_str", ] [[package]] -name = "cairo-lang-diagnostics" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +name = "cairo-lang-defs" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c65bb0e855afeb88d11585605f836bd0cd444375b234103e87342df2c91aba1b" dependencies = [ - "cairo-lang-debug 2.6.3", - "cairo-lang-filesystem 2.6.3", - "cairo-lang-utils 2.6.3", - "itertools 0.11.0", + "cairo-lang-debug 2.7.0-rc.3", + "cairo-lang-diagnostics 2.7.0-rc.3", + "cairo-lang-filesystem 2.7.0-rc.3", + "cairo-lang-parser 2.7.0-rc.3", + "cairo-lang-syntax 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", + "itertools 0.12.1", + "salsa", + "smol_str", ] [[package]] @@ -2405,7 +2387,19 @@ source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee dependencies = [ "cairo-lang-debug 2.6.4", "cairo-lang-filesystem 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", + "itertools 0.12.1", +] + +[[package]] +name = "cairo-lang-diagnostics" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab96083f60a077d300d0b89bd4b9c31731c95f5db355a11c4657ee25f3acc198" +dependencies = [ + "cairo-lang-debug 2.7.0-rc.3", + "cairo-lang-filesystem 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", "itertools 0.12.1", ] @@ -2415,49 +2409,40 @@ version = "2.6.4" source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ "cairo-lang-defs 2.6.4", - "cairo-lang-formatter", + "cairo-lang-formatter 2.6.4", "cairo-lang-parser 2.6.4", "cairo-lang-syntax 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", "itertools 0.12.1", "salsa", ] [[package]] name = "cairo-lang-eq-solver" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +version = "2.6.4" +source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ - "cairo-lang-utils 2.6.3", + "cairo-lang-utils 2.6.4", "good_lp", ] [[package]] name = "cairo-lang-eq-solver" -version = "2.6.4" +version = "2.7.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f95f5c8f7ea75580d164b5304251022e3d47f43fc1c778a01381b55ca9f268c" +checksum = "3bf2aaa50fa5b15070b2bf02c60a62f917f9aa1ff6dedf5a2627ecafe8e33cfa" dependencies = [ - "cairo-lang-utils 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.7.0-rc.3", "good_lp", ] [[package]] -name = "cairo-lang-eq-solver" +name = "cairo-lang-filesystem" version = "2.6.4" source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "good_lp", -] - -[[package]] -name = "cairo-lang-filesystem" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" -dependencies = [ - "cairo-lang-debug 2.6.3", - "cairo-lang-utils 2.6.3", + "cairo-lang-debug 2.6.4", + "cairo-lang-utils 2.6.4", "path-clean", "salsa", "serde", @@ -2466,11 +2451,12 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.6.4" -source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8094bcf7e44204c2fc2f10760e7e2e5769a6267cba5d8a303c0331dd480d5663" dependencies = [ - "cairo-lang-debug 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-debug 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", "path-clean", "salsa", "serde", @@ -2487,7 +2473,28 @@ dependencies = [ "cairo-lang-filesystem 2.6.4", "cairo-lang-parser 2.6.4", "cairo-lang-syntax 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", + "diffy", + "ignore", + "itertools 0.12.1", + "salsa", + "serde", + "smol_str", + "thiserror", +] + +[[package]] +name = "cairo-lang-formatter" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a1d92f1163b3b0e22e6392d22f7a275b9e64ab453f32b8b62bb1aeedbe73e04" +dependencies = [ + "anyhow", + "cairo-lang-diagnostics 2.7.0-rc.3", + "cairo-lang-filesystem 2.7.0-rc.3", + "cairo-lang-parser 2.7.0-rc.3", + "cairo-lang-syntax 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", "diffy", "ignore", "itertools 0.12.1", @@ -2508,7 +2515,7 @@ dependencies = [ "cairo-lang-diagnostics 2.6.4", "cairo-lang-doc", "cairo-lang-filesystem 2.6.4", - "cairo-lang-formatter", + "cairo-lang-formatter 2.6.4", "cairo-lang-lowering 2.6.4", "cairo-lang-parser 2.6.4", "cairo-lang-project 2.6.4", @@ -2516,7 +2523,7 @@ dependencies = [ "cairo-lang-starknet 2.6.4", "cairo-lang-syntax 2.6.4", "cairo-lang-test-plugin", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", "itertools 0.12.1", "salsa", "scarb-metadata 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2530,30 +2537,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "cairo-lang-lowering" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" -dependencies = [ - "cairo-lang-debug 2.6.3", - "cairo-lang-defs 2.6.3", - "cairo-lang-diagnostics 2.6.3", - "cairo-lang-filesystem 2.6.3", - "cairo-lang-parser 2.6.3", - "cairo-lang-proc-macros 2.6.3", - "cairo-lang-semantic 2.6.3", - "cairo-lang-syntax 2.6.3", - "cairo-lang-utils 2.6.3", - "id-arena", - "itertools 0.11.0", - "log", - "num-bigint", - "num-traits 0.2.19", - "once_cell", - "salsa", - "smol_str", -] - [[package]] name = "cairo-lang-lowering" version = "2.6.4" @@ -2567,7 +2550,32 @@ dependencies = [ "cairo-lang-proc-macros 2.6.4", "cairo-lang-semantic 2.6.4", "cairo-lang-syntax 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", + "id-arena", + "itertools 0.12.1", + "log", + "num-bigint", + "num-traits 0.2.19", + "once_cell", + "salsa", + "smol_str", +] + +[[package]] +name = "cairo-lang-lowering" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25eb629a773c07c2863717d1711fd3ecc17807c1fc094bb90cccac56061056a4" +dependencies = [ + "cairo-lang-debug 2.7.0-rc.3", + "cairo-lang-defs 2.7.0-rc.3", + "cairo-lang-diagnostics 2.7.0-rc.3", + "cairo-lang-filesystem 2.7.0-rc.3", + "cairo-lang-parser 2.7.0-rc.3", + "cairo-lang-proc-macros 2.7.0-rc.3", + "cairo-lang-semantic 2.7.0-rc.3", + "cairo-lang-syntax 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", "id-arena", "itertools 0.12.1", "log", @@ -2603,25 +2611,6 @@ name = "cairo-lang-macro-stable" version = "1.0.0" source = "git+https://github.com/software-mansion/scarb?rev=4b75f435f68248a7c096ec0fa5939ecdd92e2d79#4b75f435f68248a7c096ec0fa5939ecdd92e2d79" -[[package]] -name = "cairo-lang-parser" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" -dependencies = [ - "cairo-lang-diagnostics 2.6.3", - "cairo-lang-filesystem 2.6.3", - "cairo-lang-syntax 2.6.3", - "cairo-lang-syntax-codegen 2.6.3", - "cairo-lang-utils 2.6.3", - "colored", - "itertools 0.11.0", - "num-bigint", - "num-traits 0.2.19", - "salsa", - "smol_str", - "unescaper", -] - [[package]] name = "cairo-lang-parser" version = "2.6.4" @@ -2631,7 +2620,7 @@ dependencies = [ "cairo-lang-filesystem 2.6.4", "cairo-lang-syntax 2.6.4", "cairo-lang-syntax-codegen 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", "colored", "itertools 0.12.1", "num-bigint", @@ -2642,21 +2631,23 @@ dependencies = [ ] [[package]] -name = "cairo-lang-plugins" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" -dependencies = [ - "cairo-lang-defs 2.6.3", - "cairo-lang-diagnostics 2.6.3", - "cairo-lang-filesystem 2.6.3", - "cairo-lang-parser 2.6.3", - "cairo-lang-syntax 2.6.3", - "cairo-lang-utils 2.6.3", - "indent", - "indoc 2.0.5", - "itertools 0.11.0", +name = "cairo-lang-parser" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff7b1d7af8e1bff971b8b9bbce796650a57de93dfb092bc0c17c2f85d915de6e" +dependencies = [ + "cairo-lang-diagnostics 2.7.0-rc.3", + "cairo-lang-filesystem 2.7.0-rc.3", + "cairo-lang-syntax 2.7.0-rc.3", + "cairo-lang-syntax-codegen 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", + "colored", + "itertools 0.12.1", + "num-bigint", + "num-traits 0.2.19", "salsa", "smol_str", + "unescaper", ] [[package]] @@ -2669,7 +2660,7 @@ dependencies = [ "cairo-lang-filesystem 2.6.4", "cairo-lang-parser 2.6.4", "cairo-lang-syntax 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", "indent", "indoc 2.0.5", "itertools 0.12.1", @@ -2678,13 +2669,22 @@ dependencies = [ ] [[package]] -name = "cairo-lang-proc-macros" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +name = "cairo-lang-plugins" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eccf06d643d155a72057dc93c40cf34dabe11e8c629dbf3111c528a3d750a66" dependencies = [ - "cairo-lang-debug 2.6.3", - "quote", - "syn 2.0.68", + "cairo-lang-defs 2.7.0-rc.3", + "cairo-lang-diagnostics 2.7.0-rc.3", + "cairo-lang-filesystem 2.7.0-rc.3", + "cairo-lang-parser 2.7.0-rc.3", + "cairo-lang-syntax 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", + "indent", + "indoc 2.0.5", + "itertools 0.12.1", + "salsa", + "smol_str", ] [[package]] @@ -2698,16 +2698,14 @@ dependencies = [ ] [[package]] -name = "cairo-lang-project" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +name = "cairo-lang-proc-macros" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffa10434f9ce0828e8d77f3a13ae2f878da453345b14d54a66de3e196c0e4674" dependencies = [ - "cairo-lang-filesystem 2.6.3", - "cairo-lang-utils 2.6.3", - "serde", - "smol_str", - "thiserror", - "toml 0.8.14", + "cairo-lang-debug 2.7.0-rc.3", + "quote", + "syn 2.0.68", ] [[package]] @@ -2716,7 +2714,7 @@ version = "2.6.4" source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ "cairo-lang-filesystem 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", "serde", "smol_str", "thiserror", @@ -2724,33 +2722,17 @@ dependencies = [ ] [[package]] -name = "cairo-lang-runner" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +name = "cairo-lang-project" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4882d2263fb7c95dbab0c3b5578d8c0e2417fd680df8cc61aa50321b6a5a40d" dependencies = [ - "ark-ff 0.4.2", - "ark-secp256k1", - "ark-secp256r1", - "ark-std 0.4.0", - "cairo-felt", - "cairo-lang-casm 2.6.3", - "cairo-lang-lowering 2.6.3", - "cairo-lang-sierra 2.6.3", - "cairo-lang-sierra-ap-change 2.6.3", - "cairo-lang-sierra-generator 2.6.3", - "cairo-lang-sierra-to-casm 2.6.3", - "cairo-lang-sierra-type-size 2.6.3", - "cairo-lang-starknet 2.6.3", - "cairo-lang-utils 2.6.3", - "cairo-vm 0.9.2", - "itertools 0.11.0", - "keccak", - "num-bigint", - "num-integer", - "num-traits 0.2.19", + "cairo-lang-filesystem 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", + "serde", "smol_str", - "starknet-crypto 0.6.2", "thiserror", + "toml 0.8.14", ] [[package]] @@ -2761,16 +2743,16 @@ dependencies = [ "ark-ff 0.4.2", "ark-secp256k1", "ark-secp256r1", - "cairo-lang-casm 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-casm 2.6.4", "cairo-lang-lowering 2.6.4", - "cairo-lang-sierra 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra-ap-change 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-sierra 2.6.4", + "cairo-lang-sierra-ap-change 2.6.4", "cairo-lang-sierra-generator 2.6.4", - "cairo-lang-sierra-to-casm 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra-type-size 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-sierra-to-casm 2.6.4", + "cairo-lang-sierra-type-size 2.6.4", "cairo-lang-starknet 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-vm 1.0.0-rc3", + "cairo-lang-utils 2.6.4", + "cairo-vm 1.0.0-rc5", "itertools 0.12.1", "keccak", "num-bigint", @@ -2784,27 +2766,34 @@ dependencies = [ ] [[package]] -name = "cairo-lang-semantic" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" -dependencies = [ - "cairo-lang-debug 2.6.3", - "cairo-lang-defs 2.6.3", - "cairo-lang-diagnostics 2.6.3", - "cairo-lang-filesystem 2.6.3", - "cairo-lang-parser 2.6.3", - "cairo-lang-plugins 2.6.3", - "cairo-lang-proc-macros 2.6.3", - "cairo-lang-syntax 2.6.3", - "cairo-lang-utils 2.6.3", - "id-arena", - "indoc 2.0.5", - "itertools 0.11.0", +name = "cairo-lang-runner" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01ab7b0e0640adaed21b9d9b9b94b3edf7f7ab95514b1dd40c679317a33dabea" +dependencies = [ + "ark-ff 0.4.2", + "ark-secp256k1", + "ark-secp256r1", + "cairo-lang-casm 2.7.0-rc.3", + "cairo-lang-lowering 2.7.0-rc.3", + "cairo-lang-sierra 2.7.0-rc.3", + "cairo-lang-sierra-ap-change 2.7.0-rc.3", + "cairo-lang-sierra-generator 2.7.0-rc.3", + "cairo-lang-sierra-to-casm 2.7.0-rc.3", + "cairo-lang-sierra-type-size 2.7.0-rc.3", + "cairo-lang-starknet 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", + "cairo-vm 1.0.0-rc5", + "itertools 0.12.1", + "keccak", "num-bigint", + "num-integer", "num-traits 0.2.19", - "once_cell", - "salsa", + "rand", + "sha2 0.10.8", "smol_str", + "starknet-types-core", + "thiserror", ] [[package]] @@ -2820,8 +2809,8 @@ dependencies = [ "cairo-lang-plugins 2.6.4", "cairo-lang-proc-macros 2.6.4", "cairo-lang-syntax 2.6.4", - "cairo-lang-test-utils", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-test-utils 2.6.4", + "cairo-lang-utils 2.6.4", "id-arena", "indoc 2.0.5", "itertools 0.12.1", @@ -2834,63 +2823,67 @@ dependencies = [ ] [[package]] -name = "cairo-lang-sierra" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" -dependencies = [ - "anyhow", - "cairo-felt", - "cairo-lang-utils 2.6.3", - "const-fnv1a-hash", - "convert_case 0.6.0", - "derivative", - "itertools 0.11.0", - "lalrpop", - "lalrpop-util", +name = "cairo-lang-semantic" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba49614f98322e1ccda33265f8193f66cbd88eff23b0deb94db981aa0666650" +dependencies = [ + "cairo-lang-debug 2.7.0-rc.3", + "cairo-lang-defs 2.7.0-rc.3", + "cairo-lang-diagnostics 2.7.0-rc.3", + "cairo-lang-filesystem 2.7.0-rc.3", + "cairo-lang-parser 2.7.0-rc.3", + "cairo-lang-plugins 2.7.0-rc.3", + "cairo-lang-proc-macros 2.7.0-rc.3", + "cairo-lang-syntax 2.7.0-rc.3", + "cairo-lang-test-utils 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", + "id-arena", + "indoc 2.0.5", + "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", - "regex", + "once_cell", "salsa", - "serde", - "serde_json", - "sha3", "smol_str", - "thiserror", + "toml 0.8.14", ] [[package]] name = "cairo-lang-sierra" version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74a57492267a5a8891866b6e48cdefa508b5f05931a5f8eaf004b9de15b1ffd6" +source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ "anyhow", - "cairo-felt", - "cairo-lang-utils 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.4", "const-fnv1a-hash", "convert_case 0.6.0", "derivative", - "itertools 0.11.0", + "itertools 0.12.1", "lalrpop", "lalrpop-util", "num-bigint", + "num-integer", "num-traits 0.2.19", + "once_cell", "regex", "salsa", "serde", "serde_json", "sha3", "smol_str", + "starknet-types-core", "thiserror", ] [[package]] name = "cairo-lang-sierra" -version = "2.6.4" -source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81a41d56c6afebdbe2c5ffb4e216f60b07391c29c91fccf0a60790817f49ba68" dependencies = [ "anyhow", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.7.0-rc.3", "const-fnv1a-hash", "convert_case 0.6.0", "derivative", @@ -2913,42 +2906,44 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +version = "2.6.4" +source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ - "cairo-lang-eq-solver 2.6.3", - "cairo-lang-sierra 2.6.3", - "cairo-lang-sierra-type-size 2.6.3", - "cairo-lang-utils 2.6.3", - "itertools 0.11.0", + "cairo-lang-eq-solver 2.6.4", + "cairo-lang-sierra 2.6.4", + "cairo-lang-sierra-type-size 2.6.4", + "cairo-lang-utils 2.6.4", + "itertools 0.12.1", + "num-bigint", "num-traits 0.2.19", "thiserror", ] [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.6.4" +version = "2.7.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fdbb4bd95477123653b9200bd4e9dceae95a914f6fe85b2bed83b223e36fb5a" +checksum = "667050b93db661ebce0b33c92ce44abffebde37c5645e4761722ad3c49a1c34f" dependencies = [ - "cairo-lang-eq-solver 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-type-size 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.11.0", + "cairo-lang-eq-solver 2.7.0-rc.3", + "cairo-lang-sierra 2.7.0-rc.3", + "cairo-lang-sierra-type-size 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", + "itertools 0.12.1", + "num-bigint", "num-traits 0.2.19", "thiserror", ] [[package]] -name = "cairo-lang-sierra-ap-change" +name = "cairo-lang-sierra-gas" version = "2.6.4" source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ - "cairo-lang-eq-solver 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra-type-size 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-eq-solver 2.6.4", + "cairo-lang-sierra 2.6.4", + "cairo-lang-sierra-type-size 2.6.4", + "cairo-lang-utils 2.6.4", "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", @@ -2957,70 +2952,20 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" -dependencies = [ - "cairo-lang-eq-solver 2.6.3", - "cairo-lang-sierra 2.6.3", - "cairo-lang-sierra-type-size 2.6.3", - "cairo-lang-utils 2.6.3", - "itertools 0.11.0", - "num-traits 0.2.19", - "thiserror", -] - -[[package]] -name = "cairo-lang-sierra-gas" -version = "2.6.4" +version = "2.7.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "882cb178f1b79aabf70acce1d87b08d569d8a4b0ce8b1d8f538a02cdb36789db" -dependencies = [ - "cairo-lang-eq-solver 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-type-size 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.11.0", - "num-traits 0.2.19", - "thiserror", -] - -[[package]] -name = "cairo-lang-sierra-gas" -version = "2.6.4" -source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" +checksum = "27fcbf81e8ed4efe7e9c30bbdfa8074b9af01a5e16154999dd9527baba27f1fb" dependencies = [ - "cairo-lang-eq-solver 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra-type-size 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-eq-solver 2.7.0-rc.3", + "cairo-lang-sierra 2.7.0-rc.3", + "cairo-lang-sierra-type-size 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", "thiserror", ] -[[package]] -name = "cairo-lang-sierra-generator" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" -dependencies = [ - "cairo-lang-debug 2.6.3", - "cairo-lang-defs 2.6.3", - "cairo-lang-diagnostics 2.6.3", - "cairo-lang-filesystem 2.6.3", - "cairo-lang-lowering 2.6.3", - "cairo-lang-parser 2.6.3", - "cairo-lang-semantic 2.6.3", - "cairo-lang-sierra 2.6.3", - "cairo-lang-syntax 2.6.3", - "cairo-lang-utils 2.6.3", - "itertools 0.11.0", - "num-traits 0.2.19", - "once_cell", - "salsa", - "smol_str", -] - [[package]] name = "cairo-lang-sierra-generator" version = "2.6.4" @@ -3033,9 +2978,9 @@ dependencies = [ "cairo-lang-lowering 2.6.4", "cairo-lang-parser 2.6.4", "cairo-lang-semantic 2.6.4", - "cairo-lang-sierra 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-sierra 2.6.4", "cairo-lang-syntax 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", "itertools 0.12.1", "num-traits 0.2.19", "once_cell", @@ -3046,58 +2991,63 @@ dependencies = [ ] [[package]] -name = "cairo-lang-sierra-to-casm" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" -dependencies = [ - "assert_matches", - "cairo-felt", - "cairo-lang-casm 2.6.3", - "cairo-lang-sierra 2.6.3", - "cairo-lang-sierra-ap-change 2.6.3", - "cairo-lang-sierra-gas 2.6.3", - "cairo-lang-sierra-type-size 2.6.3", - "cairo-lang-utils 2.6.3", - "indoc 2.0.5", - "itertools 0.11.0", - "num-bigint", +name = "cairo-lang-sierra-generator" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "058c05d10913a130fb21964f0bf1a37b05eafcf2f50a73cd4aa3e11da7e4cfc7" +dependencies = [ + "cairo-lang-debug 2.7.0-rc.3", + "cairo-lang-defs 2.7.0-rc.3", + "cairo-lang-diagnostics 2.7.0-rc.3", + "cairo-lang-filesystem 2.7.0-rc.3", + "cairo-lang-lowering 2.7.0-rc.3", + "cairo-lang-parser 2.7.0-rc.3", + "cairo-lang-semantic 2.7.0-rc.3", + "cairo-lang-sierra 2.7.0-rc.3", + "cairo-lang-syntax 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", + "itertools 0.12.1", "num-traits 0.2.19", - "thiserror", + "once_cell", + "salsa", + "serde", + "serde_json", + "smol_str", ] [[package]] name = "cairo-lang-sierra-to-casm" version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ac02c90be2630ae861db6af226090da92741020519768332dd2c07e24d94c75" +source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ "assert_matches", - "cairo-felt", - "cairo-lang-casm 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-ap-change 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-gas 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-type-size 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-casm 2.6.4", + "cairo-lang-sierra 2.6.4", + "cairo-lang-sierra-ap-change 2.6.4", + "cairo-lang-sierra-gas 2.6.4", + "cairo-lang-sierra-type-size 2.6.4", + "cairo-lang-utils 2.6.4", "indoc 2.0.5", - "itertools 0.11.0", + "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", + "starknet-types-core", "thiserror", ] [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.6.4" -source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8607cc5cf16f3a930ad4b3799e986b0ca36ada2c0da1dd6bd2ef35cbb1eb9e74" dependencies = [ "assert_matches", - "cairo-lang-casm 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra-ap-change 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra-gas 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra-type-size 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-casm 2.7.0-rc.3", + "cairo-lang-sierra 2.7.0-rc.3", + "cairo-lang-sierra-ap-change 2.7.0-rc.3", + "cairo-lang-sierra-gas 2.7.0-rc.3", + "cairo-lang-sierra-type-size 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", "indoc 2.0.5", "itertools 0.12.1", "num-bigint", @@ -3106,62 +3056,23 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cairo-lang-sierra-type-size" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" -dependencies = [ - "cairo-lang-sierra 2.6.3", - "cairo-lang-utils 2.6.3", -] - [[package]] name = "cairo-lang-sierra-type-size" version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d102b10989f9637b1c916dd950cbd1bd8bb1b6a7aaa1a3035390be0683b92d85" +source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ - "cairo-lang-sierra 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra 2.6.4", + "cairo-lang-utils 2.6.4", ] [[package]] name = "cairo-lang-sierra-type-size" -version = "2.6.4" -source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224624b1e279b3eea7693680f577335e66e6dd5fbfbd2576f4a7d0b5d697f61d" dependencies = [ - "cairo-lang-sierra 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", -] - -[[package]] -name = "cairo-lang-starknet" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" -dependencies = [ - "anyhow", - "cairo-felt", - "cairo-lang-compiler 2.6.3", - "cairo-lang-defs 2.6.3", - "cairo-lang-diagnostics 2.6.3", - "cairo-lang-filesystem 2.6.3", - "cairo-lang-lowering 2.6.3", - "cairo-lang-plugins 2.6.3", - "cairo-lang-semantic 2.6.3", - "cairo-lang-sierra 2.6.3", - "cairo-lang-sierra-generator 2.6.3", - "cairo-lang-starknet-classes 2.6.3", - "cairo-lang-syntax 2.6.3", - "cairo-lang-utils 2.6.3", - "const_format", - "indent", - "indoc 2.0.5", - "itertools 0.11.0", - "once_cell", - "serde", - "serde_json", - "smol_str", - "thiserror", + "cairo-lang-sierra 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", ] [[package]] @@ -3177,11 +3088,11 @@ dependencies = [ "cairo-lang-lowering 2.6.4", "cairo-lang-plugins 2.6.4", "cairo-lang-semantic 2.6.4", - "cairo-lang-sierra 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-sierra 2.6.4", "cairo-lang-sierra-generator 2.6.4", - "cairo-lang-starknet-classes 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-starknet-classes 2.6.4", "cairo-lang-syntax 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", "const_format", "indent", "indoc 2.0.5", @@ -3195,42 +3106,47 @@ dependencies = [ ] [[package]] -name = "cairo-lang-starknet-classes" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +name = "cairo-lang-starknet" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81a54ebea4ea990a33a2158ecdf46ffb3cb1af8fff6a79c3dd310c6a9ed43e82" dependencies = [ - "cairo-felt", - "cairo-lang-casm 2.6.3", - "cairo-lang-sierra 2.6.3", - "cairo-lang-sierra-to-casm 2.6.3", - "cairo-lang-utils 2.6.3", - "convert_case 0.6.0", - "itertools 0.11.0", - "num-bigint", - "num-integer", - "num-traits 0.2.19", + "anyhow", + "cairo-lang-compiler 2.7.0-rc.3", + "cairo-lang-defs 2.7.0-rc.3", + "cairo-lang-diagnostics 2.7.0-rc.3", + "cairo-lang-filesystem 2.7.0-rc.3", + "cairo-lang-lowering 2.7.0-rc.3", + "cairo-lang-plugins 2.7.0-rc.3", + "cairo-lang-semantic 2.7.0-rc.3", + "cairo-lang-sierra 2.7.0-rc.3", + "cairo-lang-sierra-generator 2.7.0-rc.3", + "cairo-lang-starknet-classes 2.7.0-rc.3", + "cairo-lang-syntax 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", + "const_format", + "indent", + "indoc 2.0.5", + "itertools 0.12.1", "once_cell", "serde", "serde_json", - "sha3", "smol_str", - "starknet-crypto 0.6.2", + "starknet-types-core", "thiserror", ] [[package]] name = "cairo-lang-starknet-classes" version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8623b076ef3569e4262da5da270a84658b1ff242fe0c9624fbe432e7a937d101" +source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ - "cairo-felt", - "cairo-lang-casm 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-sierra-to-casm 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cairo-lang-utils 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-casm 2.6.4", + "cairo-lang-sierra 2.6.4", + "cairo-lang-sierra-to-casm 2.6.4", + "cairo-lang-utils 2.6.4", "convert_case 0.6.0", - "itertools 0.11.0", + "itertools 0.12.1", "num-bigint", "num-integer", "num-traits 0.2.19", @@ -3239,19 +3155,20 @@ dependencies = [ "serde_json", "sha3", "smol_str", - "starknet-crypto 0.6.2", + "starknet-types-core", "thiserror", ] [[package]] name = "cairo-lang-starknet-classes" -version = "2.6.4" -source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bb66ae799e1963318e1bab782848f53797787c396dfd590be539f3f12d56ac4" dependencies = [ - "cairo-lang-casm 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra-to-casm 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-casm 2.7.0-rc.3", + "cairo-lang-sierra 2.7.0-rc.3", + "cairo-lang-sierra-to-casm 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", "convert_case 0.6.0", "itertools 0.12.1", "num-bigint", @@ -3268,12 +3185,12 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +version = "2.6.4" +source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ - "cairo-lang-debug 2.6.3", - "cairo-lang-filesystem 2.6.3", - "cairo-lang-utils 2.6.3", + "cairo-lang-debug 2.6.4", + "cairo-lang-filesystem 2.6.4", + "cairo-lang-utils 2.6.4", "num-bigint", "num-traits 0.2.19", "salsa", @@ -3283,12 +3200,13 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.6.4" -source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e673dc1058a8639c094a330a701e8902cbd34defe659a3d95bcf6c3f3de249d" dependencies = [ - "cairo-lang-debug 2.6.4", - "cairo-lang-filesystem 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-debug 2.7.0-rc.3", + "cairo-lang-filesystem 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", "num-bigint", "num-traits 0.2.19", "salsa", @@ -3298,8 +3216,8 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +version = "2.6.4" +source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ "genco", "xshell", @@ -3307,8 +3225,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.6.4" -source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0dd466dbac4263573b81b83e22534285da30a4e7c15b888407fbb33d8accb9" dependencies = [ "genco", "xshell", @@ -3327,12 +3246,12 @@ dependencies = [ "cairo-lang-filesystem 2.6.4", "cairo-lang-lowering 2.6.4", "cairo-lang-semantic 2.6.4", - "cairo-lang-sierra 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-sierra 2.6.4", "cairo-lang-sierra-generator 2.6.4", "cairo-lang-starknet 2.6.4", - "cairo-lang-starknet-classes 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-starknet-classes 2.6.4", "cairo-lang-syntax 2.6.4", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", "indoc 2.0.5", "itertools 0.12.1", "num-bigint", @@ -3350,12 +3269,12 @@ dependencies = [ "cairo-lang-compiler 2.6.4", "cairo-lang-filesystem 2.6.4", "cairo-lang-runner 2.6.4", - "cairo-lang-sierra 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-sierra 2.6.4", "cairo-lang-sierra-generator 2.6.4", - "cairo-lang-sierra-to-casm 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-sierra-to-casm 2.6.4", "cairo-lang-starknet 2.6.4", "cairo-lang-test-plugin", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", "colored", "itertools 0.12.1", "num-traits 0.2.19", @@ -3368,58 +3287,57 @@ name = "cairo-lang-test-utils" version = "2.6.4" source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ - "cairo-lang-formatter", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-formatter 2.6.4", + "cairo-lang-utils 2.6.4", "colored", "log", "pretty_assertions", ] [[package]] -name = "cairo-lang-utils" -version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +name = "cairo-lang-test-utils" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09431da22acc1cf081b1802b73ff484bdc75ca1cd5ad6fa9b84fba8753b2e08f" dependencies = [ - "hashbrown 0.14.5", - "indexmap 2.2.6", - "itertools 0.11.0", - "num-bigint", - "num-traits 0.2.19", - "parity-scale-codec", - "schemars", - "serde", + "cairo-lang-formatter 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", + "colored", + "log", + "pretty_assertions", ] [[package]] name = "cairo-lang-utils" version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6f98e8769412907ceb106c21c70907cc0c87ca0a2a44c82b6229a695a6f9b48" +source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" dependencies = [ + "env_logger 0.11.3", "hashbrown 0.14.5", "indexmap 2.2.6", - "itertools 0.11.0", + "itertools 0.12.1", + "log", "num-bigint", "num-traits 0.2.19", "schemars", "serde", + "time", ] [[package]] name = "cairo-lang-utils" -version = "2.6.4" -source = "git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c#43cf361d9b6b26ec8cd5ee076dd15341bde7577c" +version = "2.7.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97498c08958be8d569c16982cac431d785adc3effdfa6d0775c65aec578dfd91" dependencies = [ - "env_logger 0.11.3", "hashbrown 0.14.5", "indexmap 2.2.6", "itertools 0.12.1", - "log", "num-bigint", "num-traits 0.2.19", + "parity-scale-codec", "schemars", "serde", - "time", ] [[package]] @@ -3443,8 +3361,9 @@ dependencies = [ [[package]] name = "cairo-vm" -version = "0.9.2" -source = "git+https://github.com/dojoengine/cairo-rs.git?rev=1031381#10313816b4ba7891e3c8ba90f6d0068a9149d682" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d90d260c5b0c0812f02fcbdc21eb0d5908fcecdca888fb779b54c3967f7f88bf" dependencies = [ "anyhow", "bincode 2.0.0-rc.3", @@ -3462,6 +3381,7 @@ dependencies = [ "num-prime", "num-traits 0.2.19", "rand", + "rust_decimal", "serde", "serde_json", "sha2 0.10.8", @@ -3473,9 +3393,9 @@ dependencies = [ [[package]] name = "cairo-vm" -version = "1.0.0-rc3" +version = "1.0.0-rc5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0fa4c74b86c0f17b58ced4fdab5c1da0a41fb12725ad7601e12bb27d8d90435" +checksum = "e09134ea1e0be6c1fbd330f0945df0512fa70944fd0b3ecc2f74a6008f01e9da" dependencies = [ "anyhow", "bincode 2.0.0-rc.3", @@ -3491,6 +3411,7 @@ dependencies = [ "num-prime", "num-traits 0.2.19", "rand", + "rust_decimal", "serde", "serde_json", "sha2 0.10.8", @@ -4812,7 +4733,7 @@ dependencies = [ "cairo-lang-defs 2.6.4", "cairo-lang-diagnostics 2.6.4", "cairo-lang-filesystem 2.6.4", - "cairo-lang-formatter", + "cairo-lang-formatter 2.6.4", "cairo-lang-lowering 2.6.4", "cairo-lang-parser 2.6.4", "cairo-lang-plugins 2.6.4", @@ -4820,11 +4741,11 @@ dependencies = [ "cairo-lang-semantic 2.6.4", "cairo-lang-sierra-generator 2.6.4", "cairo-lang-starknet 2.6.4", - "cairo-lang-starknet-classes 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-starknet-classes 2.6.4", "cairo-lang-syntax 2.6.4", "cairo-lang-test-plugin", - "cairo-lang-test-utils", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-test-utils 2.6.4", + "cairo-lang-utils 2.6.4", "camino", "convert_case 0.6.0", "directories", @@ -4946,7 +4867,7 @@ dependencies = [ "cairo-lang-filesystem 2.6.4", "cairo-lang-project 2.6.4", "cairo-lang-starknet 2.6.4", - "cairo-lang-starknet-classes 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-starknet-classes 2.6.4", "camino", "convert_case 0.6.0", "dojo-lang", @@ -4981,7 +4902,7 @@ name = "dojo-world-abigen" version = "1.0.0-alpha.1" dependencies = [ "cairo-lang-starknet 2.6.4", - "cairo-lang-starknet-classes 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-starknet-classes 2.6.4", "camino", "scarb", "scarb-ui", @@ -8125,13 +8046,14 @@ dependencies = [ name = "katana-cairo" version = "1.0.0-alpha.1" dependencies = [ - "cairo-lang-casm 2.6.3", - "cairo-lang-runner 2.6.3", - "cairo-lang-sierra 2.6.3", - "cairo-lang-starknet 2.6.3", - "cairo-lang-starknet-classes 2.6.3", - "cairo-lang-utils 2.6.3", - "cairo-vm 0.9.2", + "cairo-lang-casm 2.7.0-rc.3", + "cairo-lang-runner 2.7.0-rc.3", + "cairo-lang-sierra 2.7.0-rc.3", + "cairo-lang-sierra-to-casm 2.7.0-rc.3", + "cairo-lang-starknet 2.7.0-rc.3", + "cairo-lang-starknet-classes 2.7.0-rc.3", + "cairo-lang-utils 2.7.0-rc.3", + "cairo-vm 1.0.0-rc5", "starknet_api", ] @@ -8167,7 +8089,6 @@ dependencies = [ "anyhow", "assert_matches", "async-trait", - "cairo-vm 0.9.2", "derive_more", "dojo-metrics", "futures", @@ -8197,7 +8118,7 @@ name = "katana-db" version = "1.0.0-alpha.1" dependencies = [ "anyhow", - "cairo-vm 0.9.2", + "cairo-vm 0.9.3", "criterion", "katana-cairo", "katana-primitives", @@ -8220,7 +8141,6 @@ dependencies = [ "alloy-primitives", "anyhow", "blockifier", - "convert_case 0.6.0", "criterion", "katana-cairo", "katana-primitives", @@ -8359,6 +8279,7 @@ dependencies = [ "derive_more", "futures", "jsonrpsee 0.16.3", + "katana-cairo", "katana-core", "katana-executor", "katana-primitives", @@ -9952,6 +9873,18 @@ dependencies = [ "rand", ] +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits 0.2.19", + "serde", +] + [[package]] name = "num-traits" version = "0.1.43" @@ -11866,6 +11799,16 @@ dependencies = [ "syn 2.0.68", ] +[[package]] +name = "rust_decimal" +version = "1.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1790d1c4c0ca81211399e0e0af16333276f375209e71a37b67698a373db5b47a" +dependencies = [ + "arrayvec", + "num-traits 0.2.19", +] + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -12155,7 +12098,6 @@ dependencies = [ "bigdecimal 0.4.5", "cairo-felt", "cairo-proof-parser", - "cairo-vm 0.9.2", "celestia-rpc", "celestia-types", "dojo-world", @@ -12222,18 +12164,18 @@ dependencies = [ "cairo-lang-defs 2.6.4", "cairo-lang-diagnostics 2.6.4", "cairo-lang-filesystem 2.6.4", - "cairo-lang-formatter", + "cairo-lang-formatter 2.6.4", "cairo-lang-macro", "cairo-lang-macro-stable", "cairo-lang-parser 2.6.4", "cairo-lang-semantic 2.6.4", - "cairo-lang-sierra 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra-to-casm 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-sierra 2.6.4", + "cairo-lang-sierra-to-casm 2.6.4", "cairo-lang-starknet 2.6.4", - "cairo-lang-starknet-classes 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-starknet-classes 2.6.4", "cairo-lang-syntax 2.6.4", "cairo-lang-test-plugin", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", "camino", "clap", "convert_case 0.6.0", @@ -13053,12 +12995,12 @@ dependencies = [ "cairo-lang-filesystem 2.6.4", "cairo-lang-plugins 2.6.4", "cairo-lang-project 2.6.4", - "cairo-lang-sierra 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra-to-casm 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-sierra 2.6.4", + "cairo-lang-sierra-to-casm 2.6.4", "cairo-lang-starknet 2.6.4", "cairo-lang-test-plugin", "cairo-lang-test-runner", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", "camino", "clap", "clap-verbosity-flag", @@ -13113,12 +13055,12 @@ dependencies = [ "cairo-lang-filesystem 2.6.4", "cairo-lang-plugins 2.6.4", "cairo-lang-project 2.6.4", - "cairo-lang-sierra 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", - "cairo-lang-sierra-to-casm 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-sierra 2.6.4", + "cairo-lang-sierra-to-casm 2.6.4", "cairo-lang-starknet 2.6.4", - "cairo-lang-starknet-classes 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-starknet-classes 2.6.4", "cairo-lang-test-plugin", - "cairo-lang-utils 2.6.4 (git+https://github.com/starkware-libs/cairo?rev=43cf361d9b6b26ec8cd5ee076dd15341bde7577c)", + "cairo-lang-utils 2.6.4", "camino", "clap", "colored", @@ -13815,19 +13757,23 @@ dependencies = [ [[package]] name = "starknet_api" -version = "0.11.0" +version = "0.13.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "365ec5c0662466f299762bd012012da30e9a28319000cfade372b8787111f202" +checksum = "e0a80f50db7439ceb65de759fcbadb1695c82aec82126b2313413632e40d4eec" dependencies = [ - "cairo-lang-starknet-classes 2.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitvec", + "cairo-lang-starknet-classes 2.7.0-rc.3", "derive_more", "hex", "indexmap 2.2.6", + "itertools 0.12.1", "once_cell", "primitive-types", "serde", "serde_json", + "sha3", "starknet-crypto 0.5.2", + "starknet-types-core", "strum 0.24.1", "strum_macros 0.24.3", "thiserror", @@ -16523,3 +16469,8 @@ dependencies = [ "cc", "pkg-config", ] + +[[patch.unused]] +name = "cairo-vm" +version = "0.9.2" +source = "git+https://github.com/dojoengine/cairo-rs.git?rev=1031381#10313816b4ba7891e3c8ba90f6d0068a9149d682" diff --git a/bin/katana/src/main.rs b/bin/katana/src/main.rs index 516b7619f9..8aaccf3e44 100644 --- a/bin/katana/src/main.rs +++ b/bin/katana/src/main.rs @@ -9,7 +9,6 @@ use clap_complete::{generate, Shell}; use console::Style; use dojo_metrics::{metrics_process, prometheus_exporter}; use katana_core::constants::MAX_RECURSION_DEPTH; -use katana_core::env::get_default_vm_resource_fee_cost; use katana_core::sequencer::KatanaSequencer; use katana_executor::SimulationFlag; use katana_primitives::class::ClassHash; @@ -49,7 +48,6 @@ async fn main() -> Result<(), Box> { let cfg_env = CfgEnv { chain_id: starknet_config.env.chain_id, - vm_resource_fee_cost: get_default_vm_resource_fee_cost(), invoke_tx_max_n_steps: starknet_config.env.invoke_max_steps, validate_max_n_steps: starknet_config.env.validate_max_steps, max_recursion_depth: MAX_RECURSION_DEPTH, diff --git a/crates/dojo-test-utils/src/sequencer.rs b/crates/dojo-test-utils/src/sequencer.rs index d3225ac6b1..ea748aac3c 100644 --- a/crates/dojo-test-utils/src/sequencer.rs +++ b/crates/dojo-test-utils/src/sequencer.rs @@ -3,7 +3,6 @@ use std::sync::Arc; use jsonrpsee::core::Error; pub use katana_core::backend::config::{Environment, StarknetConfig}; use katana_core::constants::MAX_RECURSION_DEPTH; -use katana_core::env::get_default_vm_resource_fee_cost; use katana_core::sequencer::KatanaSequencer; pub use katana_core::sequencer::SequencerConfig; use katana_executor::implementation::blockifier::BlockifierFactory; @@ -40,7 +39,6 @@ impl TestSequencer { pub async fn start(config: SequencerConfig, starknet_config: StarknetConfig) -> Self { let cfg_env = CfgEnv { chain_id: starknet_config.env.chain_id, - vm_resource_fee_cost: get_default_vm_resource_fee_cost(), invoke_tx_max_n_steps: starknet_config.env.invoke_max_steps, validate_max_n_steps: starknet_config.env.validate_max_steps, max_recursion_depth: MAX_RECURSION_DEPTH, diff --git a/crates/katana/cairo/Cargo.toml b/crates/katana/cairo/Cargo.toml index 03023d508f..bffe6ce8c0 100644 --- a/crates/katana/cairo/Cargo.toml +++ b/crates/katana/cairo/Cargo.toml @@ -10,11 +10,12 @@ version.workspace = true # Use from git instead of crates.io registry so that the workspace patches aren't applied. [dependencies] -cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" } -cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" } -cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" } -cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" } -cairo-lang-starknet-classes = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" } -cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" } -cairo-vm = "0.9.2" -starknet_api = "0.11.0" +cairo-lang-casm = "2.7.0-rc.1" +cairo-lang-runner = "2.7.0-rc.1" +cairo-lang-sierra = "2.7.0-rc.1" +cairo-lang-sierra-to-casm = "2.7.0-rc.1" +cairo-lang-starknet = "2.7.0-rc.1" +cairo-lang-starknet-classes = "2.7.0-rc.1" +cairo-lang-utils = "2.7.0-rc.1" +cairo-vm = "1.0.0-rc3" +starknet_api = "0.13.0-dev.9" diff --git a/crates/katana/cairo/src/lib.rs b/crates/katana/cairo/src/lib.rs index cd07971926..84cd7d7e19 100644 --- a/crates/katana/cairo/src/lib.rs +++ b/crates/katana/cairo/src/lib.rs @@ -3,11 +3,13 @@ //! Re-export of the Cairo language crates used throughout Katana. pub mod lang { - pub use { - cairo_lang_casm as casm, cairo_lang_runner as runner, cairo_lang_sierra as sierra, - cairo_lang_starknet as starknet, cairo_lang_starknet_classes as starknet_classes, - cairo_lang_utils as utils, - }; + pub extern crate cairo_lang_casm as casm; + pub extern crate cairo_lang_runner as runner; + pub extern crate cairo_lang_sierra as sierra; + pub extern crate cairo_lang_sierra_to_casm as sierra_to_casm; + pub extern crate cairo_lang_starknet as starknet; + pub extern crate cairo_lang_starknet_classes as starknet_classes; + pub extern crate cairo_lang_utils as utils; } pub use {cairo_vm, starknet_api}; diff --git a/crates/katana/core/Cargo.toml b/crates/katana/core/Cargo.toml index 89757d8627..4a7dca623e 100644 --- a/crates/katana/core/Cargo.toml +++ b/crates/katana/core/Cargo.toml @@ -15,7 +15,6 @@ katana-tasks.workspace = true anyhow.workspace = true async-trait = { workspace = true, optional = true } -cairo-vm.workspace = true derive_more.workspace = true dojo-metrics.workspace = true futures.workspace = true diff --git a/crates/katana/core/src/env.rs b/crates/katana/core/src/env.rs index c97115bb4f..ad2075b8a6 100644 --- a/crates/katana/core/src/env.rs +++ b/crates/katana/core/src/env.rs @@ -1,28 +1,5 @@ -use std::collections::HashMap; - -use cairo_vm::vm::runners::builtin_runner::{ - BITWISE_BUILTIN_NAME, EC_OP_BUILTIN_NAME, HASH_BUILTIN_NAME, KECCAK_BUILTIN_NAME, - OUTPUT_BUILTIN_NAME, POSEIDON_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME, - SEGMENT_ARENA_BUILTIN_NAME, SIGNATURE_BUILTIN_NAME, -}; - #[derive(Debug, Default)] pub struct BlockContextGenerator { pub block_timestamp_offset: i64, pub next_block_start_time: u64, } - -pub fn get_default_vm_resource_fee_cost() -> HashMap { - HashMap::from([ - (String::from("n_steps"), 1_f64), - (HASH_BUILTIN_NAME.to_string(), 1_f64), - (RANGE_CHECK_BUILTIN_NAME.to_string(), 1_f64), - (SIGNATURE_BUILTIN_NAME.to_string(), 1_f64), - (BITWISE_BUILTIN_NAME.to_string(), 1_f64), - (POSEIDON_BUILTIN_NAME.to_string(), 1_f64), - (OUTPUT_BUILTIN_NAME.to_string(), 1_f64), - (EC_OP_BUILTIN_NAME.to_string(), 1_f64), - (KECCAK_BUILTIN_NAME.to_string(), 1_f64), - (SEGMENT_ARENA_BUILTIN_NAME.to_string(), 1_f64), - ]) -} diff --git a/crates/katana/executor/Cargo.toml b/crates/katana/executor/Cargo.toml index 462d330958..f2c66d6f33 100644 --- a/crates/katana/executor/Cargo.toml +++ b/crates/katana/executor/Cargo.toml @@ -10,14 +10,12 @@ version.workspace = true katana-primitives.workspace = true katana-provider.workspace = true -convert_case.workspace = true parking_lot.workspace = true starknet = { workspace = true, optional = true } thiserror.workspace = true tracing.workspace = true -# blockifier deps -blockifier = { git = "https://github.com/dojoengine/blockifier", rev = "57c11586", features = [ "testing" ], optional = true } +blockifier = { git = "https://github.com/dojoengine/blockifier", branch = "cairo-2.7", features = [ "testing" ], optional = true } katana-cairo = { workspace = true, optional = true } # Disable SIR for now until they support Cairo 2.6.3 diff --git a/crates/katana/executor/benches/execution.rs b/crates/katana/executor/benches/execution.rs index 8bf03bb59e..d68c6a263e 100644 --- a/crates/katana/executor/benches/execution.rs +++ b/crates/katana/executor/benches/execution.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use blockifier::state::cached_state::{CachedState, GlobalContractCache}; +use blockifier::state::cached_state::CachedState; use criterion::measurement::WallTime; use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkGroup, Criterion}; use katana_executor::{SimulationFlag, StateProviderDb}; @@ -45,10 +45,7 @@ fn blockifier( || { // setup state let state = provider.latest().expect("failed to get latest state"); - - // setup blockifier cached state - let contract_cache = GlobalContractCache::new(100); - let state = CachedState::new(StateProviderDb::from(state), contract_cache); + let state = CachedState::new(StateProviderDb::from(state)); (state, &block_context, execution_flags, tx.clone()) }, diff --git a/crates/katana/executor/benches/utils.rs b/crates/katana/executor/benches/utils.rs index 369aeb0984..6e9001e5f5 100644 --- a/crates/katana/executor/benches/utils.rs +++ b/crates/katana/executor/benches/utils.rs @@ -1,10 +1,3 @@ -use std::collections::HashMap; - -use katana_cairo::cairo_vm::vm::runners::builtin_runner::{ - BITWISE_BUILTIN_NAME, EC_OP_BUILTIN_NAME, HASH_BUILTIN_NAME, KECCAK_BUILTIN_NAME, - OUTPUT_BUILTIN_NAME, POSEIDON_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME, - SEGMENT_ARENA_BUILTIN_NAME, SIGNATURE_BUILTIN_NAME, -}; use katana_primitives::block::GasPrices; use katana_primitives::env::{BlockEnv, CfgEnv, FeeTokenAddressses}; use katana_primitives::genesis::constant::DEFAULT_FEE_TOKEN_ADDRESS; @@ -40,7 +33,6 @@ pub fn envs() -> (BlockEnv, CfgEnv) { max_recursion_depth: 100, validate_max_n_steps: 4_000_000, invoke_tx_max_n_steps: 4_000_000, - vm_resource_fee_cost: vm_resource_fee_cost(), fee_token_addresses: FeeTokenAddressses { eth: DEFAULT_FEE_TOKEN_ADDRESS, strk: DEFAULT_FEE_TOKEN_ADDRESS, @@ -50,18 +42,3 @@ pub fn envs() -> (BlockEnv, CfgEnv) { (block, cfg) } - -fn vm_resource_fee_cost() -> HashMap { - HashMap::from([ - (String::from("n_steps"), 1_f64), - (HASH_BUILTIN_NAME.to_string(), 1_f64), - (RANGE_CHECK_BUILTIN_NAME.to_string(), 1_f64), - (SIGNATURE_BUILTIN_NAME.to_string(), 1_f64), - (BITWISE_BUILTIN_NAME.to_string(), 1_f64), - (POSEIDON_BUILTIN_NAME.to_string(), 1_f64), - (OUTPUT_BUILTIN_NAME.to_string(), 1_f64), - (EC_OP_BUILTIN_NAME.to_string(), 1_f64), - (KECCAK_BUILTIN_NAME.to_string(), 1_f64), - (SEGMENT_ARENA_BUILTIN_NAME.to_string(), 1_f64), - ]) -} diff --git a/crates/katana/executor/src/abstraction/error.rs b/crates/katana/executor/src/abstraction/error.rs index e077c004dd..71da1a0783 100644 --- a/crates/katana/executor/src/abstraction/error.rs +++ b/crates/katana/executor/src/abstraction/error.rs @@ -9,8 +9,8 @@ pub enum ExecutorError {} /// Errors that can occur during the transaction execution. #[derive(Debug, Clone, thiserror::Error)] pub enum ExecutionError { - #[error("contract constructor execution error: {0}")] - ConstructorExecutionFailed(Box), + #[error("contract constructor execution error: {reason}")] + ConstructorExecutionFailed { reason: String }, #[error("class with hash {0:#x} is already declared")] ClassAlreadyDeclared(ClassHash), @@ -51,8 +51,8 @@ pub enum ExecutionError { #[error("entry point execution error: {reason}")] ExecutionFailed { reason: String }, - #[error("transaction validation error: {0}")] - TransactionValidationFailed(Box), + #[error("transaction validation error: {reason}")] + TransactionValidationFailed { reason: String }, #[error("transaction reverted: {revert_error}")] TransactionReverted { revert_error: String }, diff --git a/crates/katana/executor/src/implementation/blockifier/error.rs b/crates/katana/executor/src/implementation/blockifier/error.rs index 59586590b3..268fc18b1b 100644 --- a/crates/katana/executor/src/implementation/blockifier/error.rs +++ b/crates/katana/executor/src/implementation/blockifier/error.rs @@ -5,24 +5,24 @@ use blockifier::transaction::errors::{ TransactionExecutionError, TransactionFeeError, TransactionPreValidationError, }; -use crate::implementation::blockifier::utils::{to_address, to_felt}; +use crate::implementation::blockifier::utils::to_address; use crate::ExecutionError; impl From for ExecutionError { fn from(error: TransactionExecutionError) -> Self { match error { TransactionExecutionError::DeclareTransactionError { class_hash } => { - Self::ClassAlreadyDeclared(to_felt(class_hash.0)) + Self::ClassAlreadyDeclared(class_hash.0) } - TransactionExecutionError::ValidateTransactionError(e) => { - Self::TransactionValidationFailed(Box::new(Self::from(e))) + TransactionExecutionError::ValidateTransactionError { error, .. } => { + Self::TransactionValidationFailed { reason: error.to_string() } } TransactionExecutionError::StateError(e) => Self::from(e), TransactionExecutionError::TransactionPreValidationError(e) => Self::from(e), TransactionExecutionError::TransactionFeeError(e) => Self::from(e), - TransactionExecutionError::ExecutionError(e) => Self::from(e), + TransactionExecutionError::ExecutionError { error, .. } => Self::from(error), TransactionExecutionError::ContractConstructorExecutionFailed(e) => { - Self::ConstructorExecutionFailed(Box::new(Self::from(e))) + Self::ConstructorExecutionFailed { reason: e.to_string() } } e => Self::Other(e.to_string()), } @@ -49,9 +49,7 @@ impl From for ExecutionError { impl From for ExecutionError { fn from(error: PreExecutionError) -> Self { match error { - PreExecutionError::EntryPointNotFound(selector) => { - Self::EntryPointNotFound(to_felt(selector.0)) - } + PreExecutionError::EntryPointNotFound(selector) => Self::EntryPointNotFound(selector.0), PreExecutionError::UninitializedStorageAddress(address) => { Self::ContractNotDeployed(to_address(address)) } @@ -68,10 +66,7 @@ impl From for ExecutionError { account_nonce, incoming_tx_nonce, .. - } => Self::InvalidNonce { - actual: to_felt(incoming_tx_nonce.0), - expected: to_felt(account_nonce.0), - }, + } => Self::InvalidNonce { actual: incoming_tx_nonce.0, expected: account_nonce.0 }, TransactionPreValidationError::TransactionFeeError(e) => Self::from(e), TransactionPreValidationError::StateError(e) => Self::from(e), } @@ -96,7 +91,7 @@ impl From for ExecutionError { impl From for ExecutionError { fn from(error: StateError) -> Self { match error { - StateError::UndeclaredClassHash(hash) => Self::UndeclaredClass(to_felt(hash.0)), + StateError::UndeclaredClassHash(hash) => Self::UndeclaredClass(hash.0), e => Self::Other(e.to_string()), } } diff --git a/crates/katana/executor/src/implementation/blockifier/mod.rs b/crates/katana/executor/src/implementation/blockifier/mod.rs index a35b533396..ff25f043d0 100644 --- a/crates/katana/executor/src/implementation/blockifier/mod.rs +++ b/crates/katana/executor/src/implementation/blockifier/mod.rs @@ -4,9 +4,9 @@ pub mod utils; use std::num::NonZeroU128; -use blockifier::block::{BlockInfo, GasPrices}; +use blockifier::blockifier::block::{BlockInfo, GasPrices}; use blockifier::context::BlockContext; -use blockifier::state::cached_state::{self, GlobalContractCache, MutRefState}; +use blockifier::state::cached_state::{self, MutRefState}; use blockifier::state::state_api::StateReader; use katana_cairo::starknet_api::block::{BlockNumber, BlockTimestamp}; use katana_primitives::block::{ExecutableBlock, GasPrices as KatanaGasPrices, PartialHeader}; @@ -26,12 +26,6 @@ use crate::{ pub(crate) const LOG_TARGET: &str = "katana::executor::blockifier"; -// TODO: @kariy Which value should be considered here? I took the default -// value from the previous implementation. -// Previous: https://github.com/dojoengine/blockifier/blob/7459891173b64b148a7ce870c0b1d5907af15b8d/crates/blockifier/src/state/cached_state.rs#L731 -// New code: https://github.com/starkware-libs/blockifier/blob/a6200402ab635d8a8e175f7f135be5914c960007/crates/blockifier/src/state/global_cache.rs#L17C11-L17C46 -pub(crate) const CACHE_SIZE: usize = 100; - #[derive(Debug)] pub struct BlockifierFactory { cfg: CfgEnv, @@ -111,8 +105,8 @@ impl<'a> StarknetVMProcessor<'a> { // TODO: @kariy, not sure here if we should add some functions to alter it // instead of cloning. Or did I miss a function? // https://github.com/starkware-libs/blockifier/blob/a6200402ab635d8a8e175f7f135be5914c960007/crates/blockifier/src/context.rs#L23 - let versioned_constants = self.block_context.versioned_constants(); - let chain_info = self.block_context.chain_info(); + let versioned_constants = self.block_context.versioned_constants().clone(); + let chain_info = self.block_context.chain_info().clone(); let block_info = BlockInfo { block_number: number, block_timestamp: timestamp, @@ -127,7 +121,7 @@ impl<'a> StarknetVMProcessor<'a> { }; self.block_context = - BlockContext::new_unchecked(&block_info, chain_info, versioned_constants); + BlockContext::new(block_info, chain_info, versioned_constants, Default::default()); } fn simulate_with( @@ -140,11 +134,8 @@ impl<'a> StarknetVMProcessor<'a> { F: FnMut(&mut dyn StateReader, (TxWithHash, ExecutionResult)) -> T, { let block_context = &self.block_context; - let state = &mut self.state.0.write().inner; - let mut state = cached_state::CachedState::new( - MutRefState::new(state), - GlobalContractCache::new(CACHE_SIZE), - ); + let state = &mut self.state.0.lock().inner; + let mut state = cached_state::CachedState::new(MutRefState::new(state)); let mut results = Vec::with_capacity(transactions.len()); for exec_tx in transactions { @@ -170,7 +161,7 @@ impl<'a> BlockExecutor<'a> for StarknetVMProcessor<'a> { ) -> ExecutorResult<()> { let block_context = &self.block_context; let flags = &self.simulation_flags; - let mut state = self.state.write(); + let mut state = self.state.0.lock(); for exec_tx in transactions { // Collect class artifacts if its a declare tx @@ -187,7 +178,8 @@ impl<'a> BlockExecutor<'a> for StarknetVMProcessor<'a> { match &res { ExecutionResult::Success { receipt, trace } => { self.stats.l1_gas_used += receipt.fee().gas_consumed; - self.stats.cairo_steps_used += receipt.resources_used().steps as u128; + self.stats.cairo_steps_used += + receipt.resources_used().vm_resources.n_steps as u128; if let Some(reason) = receipt.revert_reason() { info!(target: LOG_TARGET, %reason, "Transaction reverted."); @@ -280,7 +272,7 @@ impl ExecutorExt for StarknetVMProcessor<'_> { fn call(&self, call: EntryPointCall) -> Result, ExecutionError> { let block_context = &self.block_context; - let mut state = self.state.0.write(); + let mut state = self.state.0.lock(); let state = MutRefState::new(&mut state.inner); let retdata = utils::call(call, state, block_context, 1_000_000_000)?; Ok(retdata) diff --git a/crates/katana/executor/src/implementation/blockifier/state.rs b/crates/katana/executor/src/implementation/blockifier/state.rs index 1e91423236..3258f94a72 100644 --- a/crates/katana/executor/src/implementation/blockifier/state.rs +++ b/crates/katana/executor/src/implementation/blockifier/state.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use std::sync::Arc; -use blockifier::state::cached_state::{self, GlobalContractCache}; +use blockifier::state::cached_state; use blockifier::state::errors::StateError; use blockifier::state::state_api::{StateReader, StateResult}; use katana_cairo::starknet_api::core::{ClassHash, CompiledClassHash, Nonce}; @@ -12,10 +12,9 @@ use katana_provider::error::ProviderError; use katana_provider::traits::contract::ContractClassProvider; use katana_provider::traits::state::StateProvider; use katana_provider::ProviderResult; -use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard}; +use parking_lot::Mutex; -use super::utils::{self, to_felt, to_stark_felt}; -use super::CACHE_SIZE; +use super::utils::{self}; use crate::StateProviderDb; /// A helper trait to enforce that a type must implement both [StateProvider] and [StateReader]. @@ -25,38 +24,36 @@ impl StateDb for T where T: StateProvider + StateReader {} impl<'a> StateReader for StateProviderDb<'a> { fn get_class_hash_at( - &mut self, + &self, contract_address: katana_cairo::starknet_api::core::ContractAddress, ) -> StateResult { self.0 .class_hash_of_contract(utils::to_address(contract_address)) - .map(|v| ClassHash(to_stark_felt(v.unwrap_or_default()))) + .map(|v| ClassHash(v.unwrap_or_default())) .map_err(|e| StateError::StateReadError(e.to_string())) } fn get_compiled_class_hash( - &mut self, + &self, class_hash: katana_cairo::starknet_api::core::ClassHash, ) -> StateResult { if let Some(hash) = self .0 - .compiled_class_hash_of_class_hash(to_felt(class_hash.0)) + .compiled_class_hash_of_class_hash(class_hash.0) .map_err(|e| StateError::StateReadError(e.to_string()))? { - Ok(CompiledClassHash(to_stark_felt(hash))) + Ok(CompiledClassHash(hash)) } else { Err(StateError::UndeclaredClassHash(class_hash)) } } fn get_compiled_contract_class( - &mut self, + &self, class_hash: ClassHash, ) -> StateResult { - if let Some(class) = self - .0 - .class(to_felt(class_hash.0)) - .map_err(|e| StateError::StateReadError(e.to_string()))? + if let Some(class) = + self.0.class(class_hash.0).map_err(|e| StateError::StateReadError(e.to_string()))? { let class = utils::to_class(class).map_err(|e| StateError::StateReadError(e.to_string()))?; @@ -68,29 +65,29 @@ impl<'a> StateReader for StateProviderDb<'a> { } fn get_nonce_at( - &mut self, + &self, contract_address: katana_cairo::starknet_api::core::ContractAddress, ) -> StateResult { self.0 .nonce(utils::to_address(contract_address)) - .map(|n| Nonce(to_stark_felt(n.unwrap_or_default()))) + .map(|n| Nonce(n.unwrap_or_default())) .map_err(|e| StateError::StateReadError(e.to_string())) } fn get_storage_at( - &mut self, + &self, contract_address: katana_cairo::starknet_api::core::ContractAddress, key: katana_cairo::starknet_api::state::StorageKey, - ) -> StateResult { + ) -> StateResult { self.0 - .storage(utils::to_address(contract_address), to_felt(*key.0.key())) - .map(|v| to_stark_felt(v.unwrap_or_default())) + .storage(utils::to_address(contract_address), *key.0.key()) + .map(|v| v.unwrap_or_default()) .map_err(|e| StateError::StateReadError(e.to_string())) } } #[derive(Debug)] -pub(super) struct CachedState(pub(super) Arc>>); +pub(super) struct CachedState(pub(super) Arc>>); impl Clone for CachedState { fn clone(&self) -> Self { @@ -109,18 +106,9 @@ pub(super) struct CachedStateInner { impl CachedState { pub(super) fn new(state: S) -> Self { let declared_classes = HashMap::new(); - let cached_state = - cached_state::CachedState::new(state, GlobalContractCache::new(CACHE_SIZE)); + let cached_state = cached_state::CachedState::new(state); let inner = CachedStateInner { inner: cached_state, declared_classes }; - Self(Arc::new(RwLock::new(inner))) - } - - pub(super) fn read(&self) -> RwLockReadGuard<'_, CachedStateInner> { - self.0.read() - } - - pub(super) fn write(&self) -> RwLockWriteGuard<'_, CachedStateInner> { - self.0.write() + Self(Arc::new(Mutex::new(inner))) } } @@ -129,7 +117,7 @@ impl ContractClassProvider for CachedState { &self, hash: katana_primitives::class::ClassHash, ) -> ProviderResult> { - let state = self.read(); + let state = self.0.lock(); if let Some((class, _)) = state.declared_classes.get(&hash) { Ok(Some(class.clone())) } else { @@ -141,18 +129,17 @@ impl ContractClassProvider for CachedState { &self, hash: katana_primitives::class::ClassHash, ) -> ProviderResult> { - let Ok(hash) = self.write().inner.get_compiled_class_hash(ClassHash(to_stark_felt(hash))) - else { + let Ok(hash) = self.0.lock().inner.get_compiled_class_hash(ClassHash(hash)) else { return Ok(None); }; - Ok(Some(to_felt(hash.0))) - } + if hash.0 == FieldElement::ZERO { Ok(None) } else { Ok(Some(hash.0)) } + } fn sierra_class( &self, hash: katana_primitives::class::ClassHash, ) -> ProviderResult> { - let state = self.read(); + let state = self.0.lock(); if let Some((_, sierra)) = state.declared_classes.get(&hash) { Ok(sierra.clone()) } else { @@ -166,12 +153,11 @@ impl StateProvider for CachedState { &self, address: katana_primitives::contract::ContractAddress, ) -> ProviderResult> { - let Ok(hash) = self.write().inner.get_class_hash_at(utils::to_blk_address(address)) else { + let Ok(hash) = self.0.lock().inner.get_class_hash_at(utils::to_blk_address(address)) else { return Ok(None); }; - let hash = to_felt(hash.0); - if hash == FieldElement::ZERO { Ok(None) } else { Ok(Some(hash)) } + if hash.0 == FieldElement::ZERO { Ok(None) } else { Ok(Some(hash.0)) } } fn nonce( @@ -183,8 +169,8 @@ impl StateProvider for CachedState { return Ok(None); } - match self.0.write().inner.get_nonce_at(utils::to_blk_address(address)) { - Ok(nonce) => Ok(Some(to_felt(nonce.0))), + match self.0.lock().inner.get_nonce_at(utils::to_blk_address(address)) { + Ok(nonce) => Ok(Some(nonce.0)), Err(e) => Err(ProviderError::Other(e.to_string())), } } @@ -200,14 +186,11 @@ impl StateProvider for CachedState { } let address = utils::to_blk_address(address); - let key = StorageKey( - to_stark_felt(storage_key) - .try_into() - .expect("storage key is not a valid field element"), - ); + let key = + StorageKey(storage_key.try_into().expect("storage key is not a valid field element")); - match self.write().inner.get_storage_at(address, key) { - Ok(value) => Ok(Some(to_felt(value))), + match self.0.lock().inner.get_storage_at(address, key) { + Ok(value) => Ok(Some(value)), Err(e) => Err(ProviderError::Other(e.to_string())), } } @@ -215,36 +198,36 @@ impl StateProvider for CachedState { impl StateReader for CachedState { fn get_class_hash_at( - &mut self, + &self, contract_address: katana_cairo::starknet_api::core::ContractAddress, ) -> StateResult { - self.write().inner.get_class_hash_at(contract_address) + self.0.lock().inner.get_class_hash_at(contract_address) } - fn get_compiled_class_hash(&mut self, class_hash: ClassHash) -> StateResult { - self.write().inner.get_compiled_class_hash(class_hash) + fn get_compiled_class_hash(&self, class_hash: ClassHash) -> StateResult { + self.0.lock().inner.get_compiled_class_hash(class_hash) } fn get_compiled_contract_class( - &mut self, + &self, class_hash: ClassHash, ) -> StateResult { - self.write().inner.get_compiled_contract_class(class_hash) + self.0.lock().inner.get_compiled_contract_class(class_hash) } fn get_nonce_at( - &mut self, + &self, contract_address: katana_cairo::starknet_api::core::ContractAddress, ) -> StateResult { - self.write().inner.get_nonce_at(contract_address) + self.0.lock().inner.get_nonce_at(contract_address) } fn get_storage_at( - &mut self, + &self, contract_address: katana_cairo::starknet_api::core::ContractAddress, key: StorageKey, - ) -> StateResult { - self.write().inner.get_storage_at(contract_address, key) + ) -> StateResult { + self.0.lock().inner.get_storage_at(contract_address, key) } } @@ -252,9 +235,6 @@ impl StateReader for CachedState { mod tests { use blockifier::state::state_api::{State, StateReader}; - use katana_cairo::starknet_api::core::PatriciaKey; - use katana_cairo::starknet_api::hash::StarkHash; - use katana_cairo::starknet_api::patricia_key; use katana_primitives::class::{CompiledClass, FlattenedSierraClass}; use katana_primitives::contract::ContractAddress; use katana_primitives::genesis::constant::{ @@ -306,7 +286,7 @@ mod tests { #[test] fn can_fetch_from_inner_state_provider() -> anyhow::Result<()> { let state = state_provider(); - let mut cached_state = CachedState::new(StateProviderDb(state)); + let cached_state = CachedState::new(StateProviderDb(state)); let address = ContractAddress::from(felt!("0x67")); let legacy_class_hash = felt!("0x111"); @@ -315,19 +295,17 @@ mod tests { let api_address = utils::to_blk_address(address); let actual_class_hash = cached_state.get_class_hash_at(api_address)?; let actual_nonce = cached_state.get_nonce_at(api_address)?; - let actual_storage_value = cached_state.get_storage_at( - api_address, - StorageKey(patricia_key!(utils::to_stark_felt(storage_key))), - )?; + let actual_storage_value = cached_state + .get_storage_at(api_address, StorageKey(storage_key.try_into().unwrap()))?; let actual_compiled_hash = cached_state.get_compiled_class_hash(actual_class_hash)?; let actual_class = cached_state.get_compiled_contract_class(actual_class_hash)?; - let actual_legacy_class = cached_state - .get_compiled_contract_class(ClassHash(to_stark_felt(legacy_class_hash)))?; + let actual_legacy_class = + cached_state.get_compiled_contract_class(ClassHash(legacy_class_hash))?; - assert_eq!(actual_nonce.0, to_stark_felt(felt!("0x7"))); - assert_eq!(actual_storage_value, to_stark_felt(felt!("0x2"))); - assert_eq!(actual_class_hash.0, to_stark_felt(felt!("0x123"))); - assert_eq!(actual_compiled_hash.0, to_stark_felt(felt!("0x456"))); + assert_eq!(actual_nonce.0, felt!("0x7")); + assert_eq!(actual_storage_value, felt!("0x2")); + assert_eq!(actual_class_hash.0, felt!("0x123")); + assert_eq!(actual_compiled_hash.0, felt!("0x456")); assert_eq!( actual_class, utils::to_class(DEFAULT_OZ_ACCOUNT_CONTRACT_CASM.clone()).unwrap().contract_class() @@ -383,21 +361,20 @@ mod tests { // insert some data to the cached state { - let lock = &mut cached_state.0.write(); + let lock = &mut cached_state.0.lock(); let blk_state = &mut lock.inner; let address = utils::to_blk_address(new_address); - let storage_key = StorageKey(patricia_key!(utils::to_stark_felt(new_storage_key))); - let storage_value = utils::to_stark_felt(new_storage_value); - let class_hash = ClassHash(utils::to_stark_felt(new_class_hash)); + let storage_key = StorageKey(new_storage_key.try_into().unwrap()); + let storage_value = new_storage_value; + let class_hash = ClassHash(new_class_hash); let class = utils::to_class(new_compiled_sierra_class.clone()).unwrap().contract_class(); - let compiled_hash = CompiledClassHash(utils::to_stark_felt(new_compiled_hash)); - let legacy_class_hash = ClassHash(utils::to_stark_felt(new_legacy_class_hash)); + let compiled_hash = CompiledClassHash(new_compiled_hash); + let legacy_class_hash = ClassHash(new_legacy_class_hash); let legacy_class = utils::to_class(DEFAULT_LEGACY_UDC_CASM.clone()).unwrap().contract_class(); - let legacy_compiled_hash = - CompiledClassHash(utils::to_stark_felt(new_legacy_compiled_hash)); + let legacy_compiled_hash = CompiledClassHash(new_legacy_compiled_hash); blk_state.increment_nonce(address)?; blk_state.set_class_hash_at(address, legacy_class_hash)?; @@ -495,11 +472,11 @@ mod tests { let sp = db.latest()?; - let mut cached_state = CachedState::new(StateProviderDb(sp)); + let cached_state = CachedState::new(StateProviderDb(sp)); let api_address = utils::to_blk_address(address); - let api_storage_key = StorageKey(patricia_key!(utils::to_stark_felt(storage_key))); - let api_class_hash = ClassHash(utils::to_stark_felt(class_hash)); + let api_storage_key = StorageKey(storage_key.try_into().unwrap()); + let api_class_hash = ClassHash(class_hash); let actual_nonce = cached_state.get_nonce_at(api_address).expect("should return default value"); diff --git a/crates/katana/executor/src/implementation/blockifier/utils.rs b/crates/katana/executor/src/implementation/blockifier/utils.rs index 4a6114b89d..074f9c51c7 100644 --- a/crates/katana/executor/src/implementation/blockifier/utils.rs +++ b/crates/katana/executor/src/implementation/blockifier/utils.rs @@ -2,7 +2,7 @@ use std::collections::{BTreeMap, HashMap}; use std::num::NonZeroU128; use std::sync::Arc; -use blockifier::block::{BlockInfo, GasPrices}; +use blockifier::blockifier::block::{BlockInfo, GasPrices}; use blockifier::context::{BlockContext, ChainInfo, FeeTokenAddresses, TransactionContext}; use blockifier::execution::call_info::{ CallExecution, CallInfo, OrderedEvent, OrderedL2ToL1Message, @@ -12,9 +12,9 @@ use blockifier::execution::contract_class::{ ClassInfo, ContractClass, ContractClassV0, ContractClassV1, }; use blockifier::execution::entry_point::{CallEntryPoint, CallType, EntryPointExecutionContext}; -use blockifier::fee::fee_utils::{calculate_tx_fee, calculate_tx_gas_vector}; -use blockifier::state::cached_state::{self, GlobalContractCache}; -use blockifier::state::state_api::{State, StateReader}; +use blockifier::fee::fee_utils::get_fee_by_gas_vector; +use blockifier::state::cached_state; +use blockifier::state::state_api::StateReader; use blockifier::transaction::account_transaction::AccountTransaction; use blockifier::transaction::objects::{ DeprecatedTransactionInfo, FeeType, HasRelatedFeeType, TransactionExecutionInfo, @@ -34,7 +34,6 @@ use katana_cairo::starknet_api::core::{ }; use katana_cairo::starknet_api::data_availability::DataAvailabilityMode; use katana_cairo::starknet_api::deprecated_contract_class::EntryPointType; -use katana_cairo::starknet_api::hash::StarkFelt; use katana_cairo::starknet_api::transaction::{ AccountDeploymentData, Calldata, ContractAddressSalt, DeclareTransaction as ApiDeclareTransaction, DeclareTransactionV0V1, DeclareTransactionV2, @@ -43,10 +42,11 @@ use katana_cairo::starknet_api::transaction::{ InvokeTransaction as ApiInvokeTransaction, PaymasterData, Resource, ResourceBounds, ResourceBoundsMapping, Tip, TransactionHash, TransactionSignature, TransactionVersion, }; +use katana_primitives::chain::NamedChainId; use katana_primitives::env::{BlockEnv, CfgEnv}; use katana_primitives::fee::TxFeeInfo; use katana_primitives::state::{StateUpdates, StateUpdatesWithDeclaredClasses}; -use katana_primitives::trace::TxExecInfo; +use katana_primitives::trace::{L1Gas, TxExecInfo, TxResources}; use katana_primitives::transaction::{ DeclareTx, DeployAccountTx, ExecutableTx, ExecutableTxWithHash, InvokeTx, }; @@ -56,7 +56,6 @@ use starknet::core::types::PriceUnit; use starknet::core::utils::parse_cairo_short_string; use super::state::{CachedState, StateDb}; -use super::CACHE_SIZE; use crate::abstraction::{EntryPointCall, SimulationFlag}; use crate::utils::build_receipt; use crate::{ExecutionError, ExecutionResult}; @@ -90,14 +89,17 @@ pub fn transact( // where the fee is skipped and thus not charged for the transaction (e.g. when the // `skip_fee_transfer` is explicitly set, or when the transaction `max_fee` is set to 0). In // these cases, we still want to calculate the fee. - let overall_fee = if info.actual_fee == Fee(0) { - calculate_tx_fee(&info.actual_resources, block_context, &fee_type)?.0 + let fee = if info.transaction_receipt.fee == Fee(0) { + get_fee_by_gas_vector( + block_context.block_info(), + info.transaction_receipt.gas, + &fee_type, + ) } else { - info.actual_fee.0 + info.transaction_receipt.fee }; - let consts = block_context.versioned_constants(); - let gas_consumed = calculate_tx_gas_vector(&info.actual_resources, consts)?.l1_gas; + let gas_consumed = info.transaction_receipt.gas.l1_gas; let (unit, gas_price) = match fee_type { FeeType::Eth => { @@ -108,9 +110,10 @@ pub fn transact( } }; - let fee = TxFeeInfo { gas_consumed, gas_price: gas_price.into(), unit, overall_fee }; + let fee_info = + TxFeeInfo { gas_consumed, gas_price: gas_price.into(), unit, overall_fee: fee.0 }; - Ok((info, fee)) + Ok((info, fee_info)) } match transact_inner(state, block_context, simulation_flags, to_executor_tx(tx.clone())) { @@ -132,13 +135,13 @@ pub fn call( block_context: &BlockContext, initial_gas: u128, ) -> Result, ExecutionError> { - let mut state = cached_state::CachedState::new(state, GlobalContractCache::new(CACHE_SIZE)); + let mut state = cached_state::CachedState::new(state); let call = CallEntryPoint { initial_gas: initial_gas as u64, storage_address: to_blk_address(request.contract_address), - entry_point_selector: core::EntryPointSelector(to_stark_felt(request.entry_point_selector)), - calldata: Calldata(Arc::new(request.calldata.into_iter().map(to_stark_felt).collect())), + entry_point_selector: core::EntryPointSelector(request.entry_point_selector), + calldata: Calldata(Arc::new(request.calldata)), ..Default::default() }; @@ -167,9 +170,7 @@ pub fn call( .expect("shouldn't fail"), )?; - let retdata = res.execution.retdata.0; - let retdata = retdata.into_iter().map(to_felt).collect::>(); - Ok(retdata) + Ok(res.execution.retdata.0) } fn to_executor_tx(tx: ExecutableTxWithHash) -> Transaction { @@ -178,31 +179,30 @@ fn to_executor_tx(tx: ExecutableTxWithHash) -> Transaction { match tx.transaction { ExecutableTx::Invoke(tx) => match tx { InvokeTx::V1(tx) => { - let calldata = tx.calldata.into_iter().map(to_stark_felt).collect(); - let signature = tx.signature.into_iter().map(to_stark_felt).collect(); + let calldata = tx.calldata; + let signature = tx.signature; Transaction::AccountTransaction(AccountTransaction::Invoke(InvokeTransaction { tx: ApiInvokeTransaction::V1( katana_cairo::starknet_api::transaction::InvokeTransactionV1 { max_fee: Fee(tx.max_fee), - nonce: Nonce(to_stark_felt(tx.nonce)), + nonce: Nonce(tx.nonce), sender_address: to_blk_address(tx.sender_address), signature: TransactionSignature(signature), calldata: Calldata(Arc::new(calldata)), }, ), - tx_hash: TransactionHash(to_stark_felt(hash)), + tx_hash: TransactionHash(hash), only_query: false, })) } InvokeTx::V3(tx) => { - let calldata = tx.calldata.into_iter().map(to_stark_felt).collect(); - let signature = tx.signature.into_iter().map(to_stark_felt).collect(); + let calldata = tx.calldata; + let signature = tx.signature; - let paymaster_data = tx.paymaster_data.into_iter().map(to_stark_felt).collect(); - let account_deploy_data = - tx.account_deployment_data.into_iter().map(to_stark_felt).collect(); + let paymaster_data = tx.paymaster_data; + let account_deploy_data = tx.account_deployment_data; let fee_data_availability_mode = to_api_da_mode(tx.fee_data_availability_mode); let nonce_data_availability_mode = to_api_da_mode(tx.nonce_data_availability_mode); @@ -210,7 +210,7 @@ fn to_executor_tx(tx: ExecutableTxWithHash) -> Transaction { tx: ApiInvokeTransaction::V3( katana_cairo::starknet_api::transaction::InvokeTransactionV3 { tip: Tip(tx.tip), - nonce: Nonce(to_stark_felt(tx.nonce)), + nonce: Nonce(tx.nonce), sender_address: to_blk_address(tx.sender_address), signature: TransactionSignature(signature), calldata: Calldata(Arc::new(calldata)), @@ -221,7 +221,7 @@ fn to_executor_tx(tx: ExecutableTxWithHash) -> Transaction { resource_bounds: to_api_resource_bounds(tx.resource_bounds), }, ), - tx_hash: TransactionHash(to_stark_felt(hash)), + tx_hash: TransactionHash(hash), only_query: false, })) } @@ -229,33 +229,33 @@ fn to_executor_tx(tx: ExecutableTxWithHash) -> Transaction { ExecutableTx::DeployAccount(tx) => match tx { DeployAccountTx::V1(tx) => { - let calldata = tx.constructor_calldata.into_iter().map(to_stark_felt).collect(); - let signature = tx.signature.into_iter().map(to_stark_felt).collect(); - let salt = ContractAddressSalt(to_stark_felt(tx.contract_address_salt)); + let calldata = tx.constructor_calldata; + let signature = tx.signature; + let salt = ContractAddressSalt(tx.contract_address_salt); Transaction::AccountTransaction(AccountTransaction::DeployAccount( DeployAccountTransaction { contract_address: to_blk_address(tx.contract_address), tx: ApiDeployAccountTransaction::V1(DeployAccountTransactionV1 { max_fee: Fee(tx.max_fee), - nonce: Nonce(to_stark_felt(tx.nonce)), + nonce: Nonce(tx.nonce), signature: TransactionSignature(signature), - class_hash: ClassHash(to_stark_felt(tx.class_hash)), + class_hash: ClassHash(tx.class_hash), constructor_calldata: Calldata(Arc::new(calldata)), contract_address_salt: salt, }), - tx_hash: TransactionHash(to_stark_felt(hash)), + tx_hash: TransactionHash(hash), only_query: false, }, )) } DeployAccountTx::V3(tx) => { - let calldata = tx.constructor_calldata.into_iter().map(to_stark_felt).collect(); - let signature = tx.signature.into_iter().map(to_stark_felt).collect(); - let salt = ContractAddressSalt(to_stark_felt(tx.contract_address_salt)); + let calldata = tx.constructor_calldata; + let signature = tx.signature; + let salt = ContractAddressSalt(tx.contract_address_salt); - let paymaster_data = tx.paymaster_data.into_iter().map(to_stark_felt).collect(); + let paymaster_data = tx.paymaster_data; let fee_data_availability_mode = to_api_da_mode(tx.fee_data_availability_mode); let nonce_data_availability_mode = to_api_da_mode(tx.nonce_data_availability_mode); @@ -264,9 +264,9 @@ fn to_executor_tx(tx: ExecutableTxWithHash) -> Transaction { contract_address: to_blk_address(tx.contract_address), tx: ApiDeployAccountTransaction::V3(DeployAccountTransactionV3 { tip: Tip(tx.tip), - nonce: Nonce(to_stark_felt(tx.nonce)), + nonce: Nonce(tx.nonce), signature: TransactionSignature(signature), - class_hash: ClassHash(to_stark_felt(tx.class_hash)), + class_hash: ClassHash(tx.class_hash), constructor_calldata: Calldata(Arc::new(calldata)), contract_address_salt: salt, paymaster_data: PaymasterData(paymaster_data), @@ -274,7 +274,7 @@ fn to_executor_tx(tx: ExecutableTxWithHash) -> Transaction { nonce_data_availability_mode, resource_bounds: to_api_resource_bounds(tx.resource_bounds), }), - tx_hash: TransactionHash(to_stark_felt(hash)), + tx_hash: TransactionHash(hash), only_query: false, }, )) @@ -285,53 +285,44 @@ fn to_executor_tx(tx: ExecutableTxWithHash) -> Transaction { let contract_class = tx.compiled_class; let tx = match tx.transaction { - DeclareTx::V1(tx) => { - let signature = tx.signature.into_iter().map(to_stark_felt).collect(); - - ApiDeclareTransaction::V1(DeclareTransactionV0V1 { - max_fee: Fee(tx.max_fee), - nonce: Nonce(to_stark_felt(tx.nonce)), - sender_address: to_blk_address(tx.sender_address), - signature: TransactionSignature(signature), - class_hash: ClassHash(to_stark_felt(tx.class_hash)), - }) - } + DeclareTx::V1(tx) => ApiDeclareTransaction::V1(DeclareTransactionV0V1 { + max_fee: Fee(tx.max_fee), + nonce: Nonce(tx.nonce), + sender_address: to_blk_address(tx.sender_address), + signature: TransactionSignature(tx.signature), + class_hash: ClassHash(tx.class_hash), + }), DeclareTx::V2(tx) => { - let signature = tx.signature.into_iter().map(to_stark_felt).collect(); + let signature = tx.signature; ApiDeclareTransaction::V2(DeclareTransactionV2 { max_fee: Fee(tx.max_fee), - nonce: Nonce(to_stark_felt(tx.nonce)), + nonce: Nonce(tx.nonce), sender_address: to_blk_address(tx.sender_address), signature: TransactionSignature(signature), - class_hash: ClassHash(to_stark_felt(tx.class_hash)), - compiled_class_hash: CompiledClassHash(to_stark_felt( - tx.compiled_class_hash, - )), + class_hash: ClassHash(tx.class_hash), + compiled_class_hash: CompiledClassHash(tx.compiled_class_hash), }) } DeclareTx::V3(tx) => { - let signature = tx.signature.into_iter().map(to_stark_felt).collect(); + let signature = tx.signature; - let paymaster_data = tx.paymaster_data.into_iter().map(to_stark_felt).collect(); + let paymaster_data = tx.paymaster_data; let fee_data_availability_mode = to_api_da_mode(tx.fee_data_availability_mode); let nonce_data_availability_mode = to_api_da_mode(tx.nonce_data_availability_mode); - let account_deploy_data = - tx.account_deployment_data.into_iter().map(to_stark_felt).collect(); + let account_deploy_data = tx.account_deployment_data; ApiDeclareTransaction::V3(DeclareTransactionV3 { tip: Tip(tx.tip), - nonce: Nonce(to_stark_felt(tx.nonce)), + nonce: Nonce(tx.nonce), sender_address: to_blk_address(tx.sender_address), signature: TransactionSignature(signature), - class_hash: ClassHash(to_stark_felt(tx.class_hash)), + class_hash: ClassHash(tx.class_hash), account_deployment_data: AccountDeploymentData(account_deploy_data), - compiled_class_hash: CompiledClassHash(to_stark_felt( - tx.compiled_class_hash, - )), + compiled_class_hash: CompiledClassHash(tx.compiled_class_hash), paymaster_data: PaymasterData(paymaster_data), fee_data_availability_mode, nonce_data_availability_mode, @@ -340,28 +331,23 @@ fn to_executor_tx(tx: ExecutableTxWithHash) -> Transaction { } }; - let hash = TransactionHash(to_stark_felt(hash)); + let hash = TransactionHash(hash); let class = to_class(contract_class).unwrap(); let tx = DeclareTransaction::new(tx, hash, class).expect("class mismatch"); Transaction::AccountTransaction(AccountTransaction::Declare(tx)) } - ExecutableTx::L1Handler(tx) => { - let calldata = tx.calldata.into_iter().map(to_stark_felt).collect(); - Transaction::L1HandlerTransaction(L1HandlerTransaction { - paid_fee_on_l1: Fee(tx.paid_fee_on_l1), - tx: katana_cairo::starknet_api::transaction::L1HandlerTransaction { - nonce: core::Nonce(to_stark_felt(tx.nonce)), - calldata: Calldata(Arc::new(calldata)), - version: TransactionVersion(1u128.into()), - contract_address: to_blk_address(tx.contract_address), - entry_point_selector: core::EntryPointSelector(to_stark_felt( - tx.entry_point_selector, - )), - }, - tx_hash: TransactionHash(to_stark_felt(hash)), - }) - } + ExecutableTx::L1Handler(tx) => Transaction::L1HandlerTransaction(L1HandlerTransaction { + paid_fee_on_l1: Fee(tx.paid_fee_on_l1), + tx: katana_cairo::starknet_api::transaction::L1HandlerTransaction { + nonce: core::Nonce(tx.nonce), + calldata: Calldata(Arc::new(tx.calldata)), + version: TransactionVersion(1u128.into()), + contract_address: to_blk_address(tx.contract_address), + entry_point_selector: core::EntryPointSelector(tx.entry_point_selector), + }, + tx_hash: TransactionHash(hash), + }), } } @@ -399,9 +385,8 @@ pub fn block_context_from_envs(block_env: &BlockEnv, cfg_env: &CfgEnv) -> BlockC versioned_constants.max_recursion_depth = cfg_env.max_recursion_depth; versioned_constants.validate_max_n_steps = cfg_env.validate_max_n_steps; versioned_constants.invoke_tx_max_n_steps = cfg_env.invoke_tx_max_n_steps; - versioned_constants.vm_resource_fee_cost = cfg_env.vm_resource_fee_cost.clone().into(); - BlockContext::new_unchecked(&block_info, &chain_info, &versioned_constants) + BlockContext::new(block_info, chain_info, versioned_constants, Default::default()) } pub(super) fn state_update_from_cached_state( @@ -409,7 +394,7 @@ pub(super) fn state_update_from_cached_state( ) -> StateUpdatesWithDeclaredClasses { use katana_primitives::class::{CompiledClass, FlattenedSierraClass}; - let state_diff = state.0.write().inner.to_state_diff(); + let state_diff = state.0.lock().inner.to_state_diff().unwrap(); let mut declared_compiled_classes: HashMap = HashMap::new(); @@ -418,8 +403,8 @@ pub(super) fn state_update_from_cached_state( FlattenedSierraClass, > = HashMap::new(); - for (class_hash, _) in &state_diff.class_hash_to_compiled_class_hash { - let hash = to_felt(class_hash.0); + for class_hash in state_diff.compiled_class_hashes.keys() { + let hash = class_hash.0; let class = state.class(hash).unwrap().expect("must exist if declared"); if let CompiledClass::Class(_) = class { @@ -432,35 +417,29 @@ pub(super) fn state_update_from_cached_state( let nonce_updates = state_diff - .address_to_nonce + .nonces .into_iter() - .map(|(key, value)| (to_address(key), to_felt(value.0))) + .map(|(key, value)| (to_address(key), value.0)) .collect::>(); - let storage_updates = state_diff - .storage_updates - .into_iter() - .map(|(addr, entries)| { - let entries = entries - .into_iter() - .map(|(k, v)| (to_felt(*k.0.key()), to_felt(v))) - .collect::>(); - - (to_address(addr), entries) - }) - .collect::>(); + > = storage.entry(to_address(addr)).or_default(); + entry.insert(*key.0.key(), value); + storage + }); let contract_updates = state_diff - .address_to_class_hash + .class_hashes .into_iter() - .map(|(key, value)| (to_address(key), to_felt(value.0))) + .map(|(key, value)| (to_address(key), value.0)) .collect::( let declared_classes = state_diff - .class_hash_to_compiled_class_hash + .compiled_class_hashes .into_iter() - .map(|(key, value)| (to_felt(key.0), to_felt(value.0))) + .map(|(key, value)| (key.0, value.0)) .collect:: FeeType { } pub fn to_blk_address(address: katana_primitives::contract::ContractAddress) -> ContractAddress { - to_stark_felt(address.0).try_into().expect("valid address") + address.0.try_into().expect("valid address") } pub fn to_address(address: ContractAddress) -> katana_primitives::contract::ContractAddress { - katana_primitives::contract::ContractAddress(to_felt(*address.0.key())) + katana_primitives::contract::ContractAddress(*address.0.key()) } pub fn to_blk_chain_id(chain_id: katana_primitives::chain::ChainId) -> ChainId { match chain_id { - katana_primitives::chain::ChainId::Named(named) => ChainId(named.name().to_string()), + katana_primitives::chain::ChainId::Named(NamedChainId::Mainnet) => ChainId::Mainnet, + katana_primitives::chain::ChainId::Named(NamedChainId::Sepolia) => ChainId::Sepolia, + katana_primitives::chain::ChainId::Named(named) => ChainId::Other(named.to_string()), katana_primitives::chain::ChainId::Id(id) => { let id = parse_cairo_short_string(&id).expect("valid cairo string"); - ChainId(id) + ChainId::Other(id) } } } @@ -568,9 +549,7 @@ fn starknet_api_ethaddr_to_felt( let mut bytes = [0u8; 32]; // Padding H160 with zeros to 32 bytes (big endian) bytes[12..32].copy_from_slice(value.0.as_bytes()); - let stark_felt = katana_cairo::starknet_api::hash::StarkFelt::new(bytes) - .expect("valid slice for stark felt"); - to_felt(stark_felt) + FieldElement::from_bytes_be(&bytes) } pub fn to_exec_info(exec_info: TransactionExecutionInfo) -> TxExecInfo { @@ -578,14 +557,20 @@ pub fn to_exec_info(exec_info: TransactionExecutionInfo) -> TxExecInfo { validate_call_info: exec_info.validate_call_info.map(to_call_info), execute_call_info: exec_info.execute_call_info.map(to_call_info), fee_transfer_call_info: exec_info.fee_transfer_call_info.map(to_call_info), - actual_fee: exec_info.actual_fee.0, - actual_resources: exec_info - .actual_resources - .0 - .into_iter() - .map(|(k, v)| (k, v as u64)) - .collect(), + actual_fee: exec_info.transaction_receipt.fee.0, revert_error: exec_info.revert_error.clone(), + actual_resources: TxResources { + vm_resources: exec_info.transaction_receipt.resources.vm_resources, + n_reverted_steps: exec_info.transaction_receipt.resources.n_reverted_steps, + data_availability: L1Gas { + l1_gas: exec_info.transaction_receipt.da_gas.l1_data_gas, + l1_data_gas: exec_info.transaction_receipt.da_gas.l1_data_gas, + }, + total_gas_consumed: L1Gas { + l1_gas: exec_info.transaction_receipt.gas.l1_data_gas, + l1_data_gas: exec_info.transaction_receipt.gas.l1_data_gas, + }, + }, } } @@ -593,17 +578,10 @@ fn to_call_info(call: CallInfo) -> trace::CallInfo { let contract_address = to_address(call.call.storage_address); let caller_address = to_address(call.call.caller_address); let code_address = call.call.code_address.map(to_address); - let class_hash = call.call.class_hash.map(|a| to_felt(a.0)); - let entry_point_selector = to_felt(call.call.entry_point_selector.0); - let calldata = call.call.calldata.0.iter().map(|f| to_felt(*f)).collect(); - let retdata = call.execution.retdata.0.into_iter().map(to_felt).collect(); - - let builtin_counter = call.resources.builtin_instance_counter; - let execution_resources = trace::ExecutionResources { - n_steps: call.resources.n_steps as u64, - n_memory_holes: call.resources.n_memory_holes as u64, - builtin_instance_counter: builtin_counter.into_iter().map(|(k, v)| (k, v as u64)).collect(), - }; + let class_hash = call.call.class_hash.map(|a| a.0); + let entry_point_selector = call.call.entry_point_selector.0; + let calldata = call.call.calldata.0.as_ref().clone(); + let retdata = call.execution.retdata.0; let CallExecution { events, l2_to_l1_messages, .. } = call.execution; @@ -622,8 +600,8 @@ fn to_call_info(call: CallInfo) -> trace::CallInfo { EntryPointType::Constructor => trace::EntryPointType::Constructor, }; - let storage_read_values = call.storage_read_values.into_iter().map(to_felt).collect(); - let storg_keys = call.accessed_storage_keys.into_iter().map(|k| to_felt(*k.0.key())).collect(); + let storage_read_values = call.storage_read_values; + let storg_keys = call.accessed_storage_keys.into_iter().map(|k| *k.0.key()).collect(); let inner_calls = call.inner_calls.into_iter().map(to_call_info).collect(); trace::CallInfo { @@ -636,7 +614,7 @@ fn to_call_info(call: CallInfo) -> trace::CallInfo { entry_point_type, calldata, retdata, - execution_resources, + execution_resources: call.resources, events, l2_to_l1_messages: l1_msg, storage_read_values, @@ -650,8 +628,8 @@ fn to_call_info(call: CallInfo) -> trace::CallInfo { fn to_ordered_event(e: OrderedEvent) -> event::OrderedEvent { event::OrderedEvent { order: e.order as u64, - keys: e.event.keys.iter().map(|f| to_felt(f.0)).collect(), - data: e.event.data.0.into_iter().map(to_felt).collect(), + data: e.event.data.0, + keys: e.event.keys.iter().map(|f| f.0).collect(), } } @@ -660,66 +638,35 @@ fn to_l2_l1_messages( from_address: katana_primitives::contract::ContractAddress, ) -> message::OrderedL2ToL1Message { let order = m.order as u64; + let payload = m.message.payload.0; let to_address = starknet_api_ethaddr_to_felt(m.message.to_address); - let payload = m.message.payload.0.into_iter().map(to_felt).collect(); message::OrderedL2ToL1Message { order, from_address, to_address, payload } } -pub fn to_stark_felt(value: FieldElement) -> StarkFelt { - StarkFelt::new(value.to_bytes_be()).expect("can convert from field element") -} - -pub fn to_felt(value: StarkFelt) -> FieldElement { - FieldElement::from_bytes_be_slice(value.bytes()) -} - #[cfg(test)] mod tests { use std::collections::HashSet; + use katana_cairo::cairo_vm::types::builtin_name::BuiltinName; use katana_cairo::cairo_vm::vm::runners::cairo_runner::ExecutionResources; use katana_cairo::starknet_api::core::EntryPointSelector; - use katana_cairo::starknet_api::hash::StarkFelt; - use katana_cairo::starknet_api::stark_felt; + use katana_cairo::starknet_api::felt; use katana_cairo::starknet_api::transaction::{EventContent, EventData, EventKey}; - use katana_primitives::chain::{ChainId, NamedChainId}; + use katana_primitives::chain::NamedChainId; use katana_primitives::felt::FieldElement; use super::*; - use crate::implementation::blockifier::utils; - - #[test] - fn test_to_stark_felt() { - let field_element = FieldElement::from_hex("0x1234567890abcdef").unwrap(); - let stark_felt = to_stark_felt(field_element); - assert_eq!(stark_felt, StarkFelt::try_from("0x1234567890abcdef").unwrap()); - } - - #[test] - fn test_to_felt() { - let stark_felt = StarkFelt::try_from("0xabcdef1234567890").unwrap(); - let field_element = to_felt(stark_felt); - assert_eq!(field_element, FieldElement::from_hex("0xabcdef1234567890").unwrap()); - } - - #[test] - fn test_roundtrip_felt_conversion() { - let original_felt = FieldElement::from_hex("0x123456789abcdef0").unwrap(); - let stark_felt = to_stark_felt(original_felt); - let roundtrip_felt = to_felt(stark_felt); - assert_eq!(original_felt, roundtrip_felt); - } #[test] fn convert_chain_id() { - let mainnet = to_blk_chain_id(ChainId::Named(NamedChainId::Mainnet)); - let goerli = to_blk_chain_id(ChainId::Named(NamedChainId::Goerli)); - let sepolia = to_blk_chain_id(ChainId::Named(NamedChainId::Sepolia)); + let mainnet = + to_blk_chain_id(katana_primitives::chain::ChainId::Named(NamedChainId::Mainnet)); + let sepolia = + to_blk_chain_id(katana_primitives::chain::ChainId::Named(NamedChainId::Sepolia)); - assert_eq!(mainnet.0, parse_cairo_short_string(&NamedChainId::Mainnet.id()).unwrap()); - assert_eq!(goerli.0, parse_cairo_short_string(&NamedChainId::Goerli.id()).unwrap()); - assert_eq!(sepolia.0, parse_cairo_short_string(&NamedChainId::Sepolia.id()).unwrap()); + assert_eq!(mainnet, ChainId::Mainnet); + assert_eq!(sepolia, ChainId::Sepolia); } fn create_blockifier_call_info() -> CallInfo { @@ -761,8 +708,8 @@ mod tests { storage_address: 100u128.into(), code_address: Some(100u128.into()), entry_point_type: EntryPointType::External, - calldata: Calldata(Arc::new(vec![stark_felt!(1_u8)])), - entry_point_selector: EntryPointSelector(stark_felt!(999_u32)), + calldata: Calldata(Arc::new(vec![felt!(1_u8)])), + entry_point_selector: EntryPointSelector(felt!(999_u32)), }, execution: CallExecution { failed: true, @@ -770,14 +717,14 @@ mod tests { events: top_events, ..Default::default() }, - storage_read_values: vec![stark_felt!(1_u8), stark_felt!(2_u8)], + storage_read_values: vec![felt!(1_u8), felt!(2_u8)], accessed_storage_keys: HashSet::from([3u128.into(), 4u128.into(), 5u128.into()]), resources: ExecutionResources { n_steps: 1_000_000, n_memory_holes: 9_000, builtin_instance_counter: HashMap::from([ - ("ecdsa_builtin".into(), 50), - ("pedersen_builtin".into(), 9), + (BuiltinName::ecdsa, 50), + (BuiltinName::pedersen, 9), ]), }, inner_calls: vec![nested_call], @@ -792,22 +739,10 @@ mod tests { let expected_contract_address = to_address(call.call.storage_address); let expected_caller_address = to_address(call.call.caller_address); let expected_code_address = call.call.code_address.map(to_address); - let expected_class_hash = call.call.class_hash.map(|c| to_felt(c.0)); - let expected_entry_point_selector = to_felt(call.call.entry_point_selector.0); - let expected_calldata: Vec = - call.call.calldata.0.iter().map(|f| to_felt(*f)).collect(); - let expected_retdata: Vec = - call.execution.retdata.0.iter().map(|f| to_felt(*f)).collect(); - - let builtin_counter = call.resources.builtin_instance_counter.clone(); - let expected_execution_resources = trace::ExecutionResources { - n_steps: call.resources.n_steps as u64, - n_memory_holes: call.resources.n_memory_holes as u64, - builtin_instance_counter: builtin_counter - .into_iter() - .map(|(k, v)| (k, v as u64)) - .collect(), - }; + let expected_class_hash = call.call.class_hash.map(|c| c.0); + let expected_entry_point_selector = call.call.entry_point_selector.0; + let expected_calldata = call.call.calldata.0.as_ref().clone(); + let expected_retdata = call.execution.retdata.0.clone(); let CallExecution { events, l2_to_l1_messages, .. } = call.execution.clone(); let expected_events: Vec<_> = events.into_iter().map(to_ordered_event).collect(); @@ -827,10 +762,9 @@ mod tests { EntryPointType::Constructor => trace::EntryPointType::Constructor, }; - let expected_storage_read_values: Vec = - call.storage_read_values.iter().map(|v| utils::to_felt(*v)).collect(); + let expected_storage_read_values = call.storage_read_values.clone(); let expected_storage_keys: HashSet = - call.accessed_storage_keys.iter().map(|k| utils::to_felt(*k.0.key())).collect(); + call.accessed_storage_keys.iter().map(|v| *v.key()).collect(); let expected_inner_calls: Vec<_> = call.inner_calls.clone().into_iter().map(to_call_info).collect(); @@ -848,7 +782,6 @@ mod tests { assert_eq!(call.entry_point_selector, expected_entry_point_selector); assert_eq!(call.calldata, expected_calldata); assert_eq!(call.retdata, expected_retdata); - assert_eq!(call.execution_resources, expected_execution_resources); assert_eq!(call.events, expected_events); assert_eq!(call.l2_to_l1_messages, expected_l2_to_l1_msg); assert_eq!(call.call_type, expected_call_type); diff --git a/crates/katana/executor/src/utils.rs b/crates/katana/executor/src/utils.rs index 5cc8ef8307..fd44386026 100644 --- a/crates/katana/executor/src/utils.rs +++ b/crates/katana/executor/src/utils.rs @@ -1,39 +1,25 @@ -use std::collections::HashMap; - -use convert_case::{Case, Casing}; use katana_primitives::fee::TxFeeInfo; use katana_primitives::receipt::{ DeclareTxReceipt, DeployAccountTxReceipt, Event, InvokeTxReceipt, L1HandlerTxReceipt, - MessageToL1, Receipt, TxExecutionResources, + MessageToL1, Receipt, }; -use katana_primitives::trace::{CallInfo, TxExecInfo}; +use katana_primitives::trace::{CallInfo, TxExecInfo, TxResources}; use katana_primitives::transaction::TxRef; use tracing::trace; pub(crate) const LOG_TARGET: &str = "executor"; -pub fn log_resources(resources: &HashMap) { - let mut mapped_strings = resources - .iter() - .filter_map(|(k, v)| match k.as_str() { - "n_steps" => None, - "ecdsa_builtin" => Some(format!("ECDSA: {v}")), - "l1_gas_usage" => Some(format!("L1 Gas: {v}")), - "keccak_builtin" => Some(format!("Keccak: {v}")), - "bitwise_builtin" => Some(format!("Bitwise: {v}")), - "pedersen_builtin" => Some(format!("Pedersen: {v}")), - "range_check_builtin" => Some(format!("Range Checks: {v}")), - _ => Some(format!("{}: {}", k.to_case(Case::Title), v)), - }) - .collect::>(); +pub fn log_resources(resources: &TxResources) { + let mut mapped_strings = Vec::new(); + + for (builtin, count) in &resources.vm_resources.builtin_instance_counter { + mapped_strings.push(format!("{builtin}: {count}")); + } // Sort the strings alphabetically mapped_strings.sort(); - - // Prepend "Steps" if it exists, so it is always first - if let Some(steps) = resources.get("n_steps") { - mapped_strings.insert(0, format!("Steps: {}", steps)); - } + mapped_strings.insert(0, format!("steps: {}", resources.vm_resources.n_steps)); + mapped_strings.insert(1, format!("memory holes: {}", resources.vm_resources.n_memory_holes)); trace!(target: LOG_TARGET, usage = mapped_strings.join(" | "), "Transaction resource usage."); } @@ -52,7 +38,7 @@ pub(crate) fn build_receipt(tx: TxRef<'_>, fee: TxFeeInfo, info: &TxExecInfo) -> let events = events_from_exec_info(info); let revert_error = info.revert_error.clone(); let messages_sent = l2_to_l1_messages_from_exec_info(info); - let actual_resources = parse_actual_resources(&info.actual_resources); + let actual_resources = info.actual_resources.clone(); match tx { TxRef::Invoke(_) => Receipt::Invoke(InvokeTxReceipt { @@ -127,21 +113,6 @@ pub fn l2_to_l1_messages_from_exec_info(info: &TxExecInfo) -> Vec { messages } -pub fn parse_actual_resources(resources: &HashMap) -> TxExecutionResources { - TxExecutionResources { - steps: resources.get("n_steps").copied().unwrap_or_default(), - memory_holes: resources.get("memory_holes").copied(), - ec_op_builtin: resources.get("ec_op_builtin").copied(), - ecdsa_builtin: resources.get("ecdsa_builtin").copied(), - keccak_builtin: resources.get("keccak_builtin").copied(), - bitwise_builtin: resources.get("bitwise_builtin").copied(), - pedersen_builtin: resources.get("pedersen_builtin").copied(), - poseidon_builtin: resources.get("poseidon_builtin").copied(), - range_check_builtin: resources.get("range_check_builtin").copied(), - segment_arena_builtin: resources.get("segment_arena_builtin").copied(), - } -} - fn get_events_recur(info: &CallInfo) -> Vec { let mut events: Vec = vec![]; diff --git a/crates/katana/executor/tests/executor.rs b/crates/katana/executor/tests/executor.rs index a0de300f90..9c97ffe6c9 100644 --- a/crates/katana/executor/tests/executor.rs +++ b/crates/katana/executor/tests/executor.rs @@ -272,7 +272,7 @@ fn test_executor_with_valid_blocks_impl( actual_total_gas += fee.gas_consumed; } if let Some(rec) = res.receipt() { - actual_total_steps += rec.resources_used().steps as u128; + actual_total_steps += rec.resources_used().vm_resources.n_steps as u128; } tx.clone() }) diff --git a/crates/katana/executor/tests/fixtures/mod.rs b/crates/katana/executor/tests/fixtures/mod.rs index bae80c0613..8adb5493a1 100644 --- a/crates/katana/executor/tests/fixtures/mod.rs +++ b/crates/katana/executor/tests/fixtures/mod.rs @@ -1,13 +1,6 @@ pub mod transaction; -use std::collections::HashMap; - use alloy_primitives::U256; -use katana_cairo::cairo_vm::vm::runners::builtin_runner::{ - BITWISE_BUILTIN_NAME, EC_OP_BUILTIN_NAME, HASH_BUILTIN_NAME, KECCAK_BUILTIN_NAME, - OUTPUT_BUILTIN_NAME, POSEIDON_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME, - SEGMENT_ARENA_BUILTIN_NAME, SIGNATURE_BUILTIN_NAME, -}; use katana_executor::implementation::noop::NoopExecutorFactory; use katana_executor::{ExecutorFactory, SimulationFlag}; use katana_primitives::block::{ @@ -137,7 +130,7 @@ pub fn valid_blocks() -> [ExecutableBlock; 3] { sierra_class: Some(sierra), transaction: DeclareTx::V2(DeclareTxV2 { nonce: FieldElement::ONE, - max_fee: 1503400000000000, + max_fee: 27092100000000000, chain_id, signature: vec![], sender_address, @@ -227,22 +220,8 @@ pub fn cfg() -> CfgEnv { let fee_token_addresses = FeeTokenAddressses { eth: DEFAULT_FEE_TOKEN_ADDRESS, strk: ContractAddress(222u64.into()) }; - let vm_resource_fee_cost = HashMap::from([ - (String::from("n_steps"), 1_f64), - (HASH_BUILTIN_NAME.to_string(), 1_f64), - (RANGE_CHECK_BUILTIN_NAME.to_string(), 1_f64), - (SIGNATURE_BUILTIN_NAME.to_string(), 1_f64), - (BITWISE_BUILTIN_NAME.to_string(), 1_f64), - (POSEIDON_BUILTIN_NAME.to_string(), 1_f64), - (OUTPUT_BUILTIN_NAME.to_string(), 1_f64), - (EC_OP_BUILTIN_NAME.to_string(), 1_f64), - (KECCAK_BUILTIN_NAME.to_string(), 1_f64), - (SEGMENT_ARENA_BUILTIN_NAME.to_string(), 1_f64), - ]); - CfgEnv { fee_token_addresses, - vm_resource_fee_cost, max_recursion_depth: 100, validate_max_n_steps: 1_000_000, invoke_tx_max_n_steps: 1_000_000, diff --git a/crates/katana/primitives/src/conversion/rpc.rs b/crates/katana/primitives/src/conversion/rpc.rs index f2d1ca7e81..d0015e4adc 100644 --- a/crates/katana/primitives/src/conversion/rpc.rs +++ b/crates/katana/primitives/src/conversion/rpc.rs @@ -47,7 +47,7 @@ pub fn legacy_inner_to_rpc_class( .iter() .map(|e| LegacyContractEntryPoint { offset: e.offset.0 as u64, - selector: FieldElement::from_bytes_be_slice(e.selector.0.bytes()), + selector: e.selector.0, }) .collect::>()) } @@ -104,9 +104,9 @@ pub fn legacy_inner_to_rpc_class( .members .into_iter() .map(|m| LegacyStructMember { - name: m.param.name, + name: m.name, offset: m.offset as u64, - r#type: m.param.r#type, + r#type: m.r#type, }) .collect(), }) @@ -149,7 +149,7 @@ pub fn flattened_sierra_to_compiled_class( let sierra = SierraProgram { program, entry_points_by_type }; let casm = CasmContractClass::from_contract_class(class, true, usize::MAX)?; - let compiled_hash = FieldElement::from_bytes_be(&casm.compiled_class_hash().to_be_bytes()); + let compiled_hash = casm.compiled_class_hash(); let class = crate::class::CompiledClass::Class(SierraCompiledClass { casm, sierra }); Ok((class_hash, compiled_hash, class)) diff --git a/crates/katana/primitives/src/env.rs b/crates/katana/primitives/src/env.rs index 3c87d7707b..14709ed5af 100644 --- a/crates/katana/primitives/src/env.rs +++ b/crates/katana/primitives/src/env.rs @@ -1,5 +1,3 @@ -use std::collections::HashMap; - use crate::block::{BlockNumber, GasPrices}; use crate::chain::ChainId; use crate::contract::ContractAddress; @@ -24,8 +22,6 @@ pub struct CfgEnv { pub chain_id: ChainId, /// The contract addresses of the fee tokens. pub fee_token_addresses: FeeTokenAddressses, - /// The fee cost of the VM resources. - pub vm_resource_fee_cost: HashMap, /// The maximum number of steps allowed for an invoke transaction. pub invoke_tx_max_n_steps: u32, /// The maximum number of steps allowed for transaction validation. diff --git a/crates/katana/primitives/src/genesis/json.rs b/crates/katana/primitives/src/genesis/json.rs index eef85a0d7a..986080ba34 100644 --- a/crates/katana/primitives/src/genesis/json.rs +++ b/crates/katana/primitives/src/genesis/json.rs @@ -355,11 +355,11 @@ impl TryFrom for Genesis { // check if the class hash is provided, otherwise compute it from the // artifacts let class_hash = class_hash.unwrap_or(sierra.class_hash()?); - let compiled_hash = class.casm.compiled_class_hash().to_be_bytes(); + let compiled_hash = class.casm.compiled_class_hash(); ( class_hash, - FieldElement::from_bytes_be(&compiled_hash), + compiled_hash, Some(Arc::new(sierra.flatten()?)), Arc::new(CompiledClass::Class(class)), ) diff --git a/crates/katana/primitives/src/receipt.rs b/crates/katana/primitives/src/receipt.rs index 9cf85d5830..1f508dc04e 100644 --- a/crates/katana/primitives/src/receipt.rs +++ b/crates/katana/primitives/src/receipt.rs @@ -2,6 +2,7 @@ use alloy_primitives::B256; use crate::contract::ContractAddress; use crate::fee::TxFeeInfo; +use crate::trace::TxResources; use crate::FieldElement; #[derive(Debug, Clone, PartialEq, Eq)] @@ -40,7 +41,7 @@ pub struct InvokeTxReceipt { /// Revert error message if the transaction execution failed. pub revert_error: Option, /// The execution resources used by the transaction. - pub execution_resources: TxExecutionResources, + pub execution_resources: TxResources, } /// Receipt for a `Declare` transaction. @@ -56,7 +57,7 @@ pub struct DeclareTxReceipt { /// Revert error message if the transaction execution failed. pub revert_error: Option, /// The execution resources used by the transaction. - pub execution_resources: TxExecutionResources, + pub execution_resources: TxResources, } /// Receipt for a `L1Handler` transaction. @@ -74,7 +75,7 @@ pub struct L1HandlerTxReceipt { /// Revert error message if the transaction execution failed. pub revert_error: Option, /// The execution resources used by the transaction. - pub execution_resources: TxExecutionResources, + pub execution_resources: TxResources, } /// Receipt for a `DeployAccount` transaction. @@ -90,7 +91,7 @@ pub struct DeployAccountTxReceipt { /// Revert error message if the transaction execution failed. pub revert_error: Option, /// The execution resources used by the transaction. - pub execution_resources: TxExecutionResources, + pub execution_resources: TxResources, /// Contract address of the deployed account contract. pub contract_address: ContractAddress, } @@ -144,7 +145,7 @@ impl Receipt { } /// Returns the execution resources used. - pub fn resources_used(&self) -> &TxExecutionResources { + pub fn resources_used(&self) -> &TxResources { match self { Receipt::Invoke(rct) => &rct.execution_resources, Receipt::Declare(rct) => &rct.execution_resources, @@ -162,31 +163,3 @@ impl Receipt { } } } - -/// Transaction execution resources. -/// -/// The resources consumed by a transaction during its execution. -#[derive(Debug, Default, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TxExecutionResources { - /// The number of cairo steps used - pub steps: u64, - /// The number of unused memory cells (each cell is roughly equivalent to a step) - pub memory_holes: Option, - /// The number of range_check builtin instances - pub range_check_builtin: Option, - /// The number of pedersen builtin instances - pub pedersen_builtin: Option, - /// The number of poseidon builtin instances - pub poseidon_builtin: Option, - /// The number of ec_op builtin instances - pub ec_op_builtin: Option, - /// The number of ecdsa builtin instances - pub ecdsa_builtin: Option, - /// The number of bitwise builtin instances - pub bitwise_builtin: Option, - /// The number of keccak builtin instances - pub keccak_builtin: Option, - - pub segment_arena_builtin: Option, -} diff --git a/crates/katana/primitives/src/trace.rs b/crates/katana/primitives/src/trace.rs index b7502680e0..f72c92b3bf 100644 --- a/crates/katana/primitives/src/trace.rs +++ b/crates/katana/primitives/src/trace.rs @@ -1,4 +1,6 @@ -use std::collections::{HashMap, HashSet}; +use std::collections::HashSet; + +use katana_cairo::cairo_vm::vm; use crate::class::ClassHash; use crate::contract::ContractAddress; @@ -6,6 +8,8 @@ use crate::event::OrderedEvent; use crate::message::OrderedL2ToL1Message; use crate::FieldElement; +pub type ExecutionResources = vm::runners::cairo_runner::ExecutionResources; + #[derive(Debug, Clone, PartialEq, Eq, Default)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TxExecInfo { @@ -19,17 +23,25 @@ pub struct TxExecInfo { pub actual_fee: u128, /// Actual execution resources the transaction is charged for, /// including L1 gas and additional OS resources estimation. - pub actual_resources: HashMap, + pub actual_resources: TxResources, /// Error string for reverted transactions; [None] if transaction execution was successful. pub revert_error: Option, } #[derive(Debug, Clone, PartialEq, Eq, Default)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ExecutionResources { - pub n_steps: u64, - pub n_memory_holes: u64, - pub builtin_instance_counter: HashMap, +pub struct TxResources { + pub n_reverted_steps: usize, + pub vm_resources: ExecutionResources, + pub data_availability: L1Gas, + pub total_gas_consumed: L1Gas, +} + +#[derive(Debug, Clone, PartialEq, Eq, Default)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct L1Gas { + pub l1_gas: u128, + pub l1_data_gas: u128, } /// The call type. diff --git a/crates/katana/rpc/rpc-types/Cargo.toml b/crates/katana/rpc/rpc-types/Cargo.toml index d792d682ef..5a89d5c0b0 100644 --- a/crates/katana/rpc/rpc-types/Cargo.toml +++ b/crates/katana/rpc/rpc-types/Cargo.toml @@ -7,6 +7,7 @@ version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +katana-cairo.workspace = true katana-core.workspace = true katana-executor.workspace = true katana-primitives.workspace = true diff --git a/crates/katana/rpc/rpc-types/src/lib.rs b/crates/katana/rpc/rpc-types/src/lib.rs index 7b230146a0..61535c59de 100644 --- a/crates/katana/rpc/rpc-types/src/lib.rs +++ b/crates/katana/rpc/rpc-types/src/lib.rs @@ -12,6 +12,7 @@ pub mod receipt; pub mod state_update; pub mod trace; pub mod transaction; +mod utils; use std::ops::Deref; diff --git a/crates/katana/rpc/rpc-types/src/receipt.rs b/crates/katana/rpc/rpc-types/src/receipt.rs index 970f7f40fb..fa1487927e 100644 --- a/crates/katana/rpc/rpc-types/src/receipt.rs +++ b/crates/katana/rpc/rpc-types/src/receipt.rs @@ -1,6 +1,7 @@ +use katana_cairo::cairo_vm::types::builtin_name::BuiltinName; use katana_primitives::block::FinalityStatus; use katana_primitives::fee::TxFeeInfo; -use katana_primitives::receipt::{MessageToL1, Receipt, TxExecutionResources}; +use katana_primitives::receipt::{MessageToL1, Receipt}; use katana_primitives::transaction::TxHash; use serde::{Deserialize, Serialize}; pub use starknet::core::types::ReceiptBlock; @@ -11,6 +12,8 @@ use starknet::core::types::{ TransactionReceipt, TransactionReceiptWithBlockInfo, }; +use crate::utils::get_builtin_instance_count; + #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(transparent)] pub struct TxReceipt(pub(crate) starknet::core::types::TransactionReceipt); @@ -156,23 +159,50 @@ impl From for Event { struct ExecutionResources(starknet::core::types::ExecutionResources); -impl From for ExecutionResources { - fn from(value: TxExecutionResources) -> Self { +impl From for ExecutionResources { + fn from(value: katana_primitives::trace::TxResources) -> Self { ExecutionResources(starknet::core::types::ExecutionResources { computation_resources: ComputationResources { - steps: value.steps, - memory_holes: value.memory_holes, - ec_op_builtin_applications: value.ec_op_builtin, - ecdsa_builtin_applications: value.ecdsa_builtin, - keccak_builtin_applications: value.keccak_builtin, - bitwise_builtin_applications: value.bitwise_builtin, - pedersen_builtin_applications: value.pedersen_builtin, - poseidon_builtin_applications: value.poseidon_builtin, - range_check_builtin_applications: value.range_check_builtin, - segment_arena_builtin: value.segment_arena_builtin, + steps: value.vm_resources.n_steps as u64, + memory_holes: Some(value.vm_resources.n_memory_holes as u64), + ec_op_builtin_applications: get_builtin_instance_count( + &value.vm_resources, + BuiltinName::ec_op, + ), + ecdsa_builtin_applications: get_builtin_instance_count( + &value.vm_resources, + BuiltinName::ecdsa, + ), + keccak_builtin_applications: get_builtin_instance_count( + &value.vm_resources, + BuiltinName::keccak, + ), + bitwise_builtin_applications: get_builtin_instance_count( + &value.vm_resources, + BuiltinName::bitwise, + ), + pedersen_builtin_applications: get_builtin_instance_count( + &value.vm_resources, + BuiltinName::pedersen, + ), + poseidon_builtin_applications: get_builtin_instance_count( + &value.vm_resources, + BuiltinName::poseidon, + ), + range_check_builtin_applications: get_builtin_instance_count( + &value.vm_resources, + BuiltinName::range_check, + ), + segment_arena_builtin: get_builtin_instance_count( + &value.vm_resources, + BuiltinName::segment_arena, + ), }, data_resources: DataResources { - data_availability: DataAvailabilityResources { l1_data_gas: 0, l1_gas: 0 }, + data_availability: DataAvailabilityResources { + l1_gas: value.data_availability.l1_gas as u64, + l1_data_gas: value.data_availability.l1_data_gas as u64, + }, }, }) } diff --git a/crates/katana/rpc/rpc-types/src/trace.rs b/crates/katana/rpc/rpc-types/src/trace.rs index f071eb5f89..e0040d1ae9 100644 --- a/crates/katana/rpc/rpc-types/src/trace.rs +++ b/crates/katana/rpc/rpc-types/src/trace.rs @@ -1,3 +1,4 @@ +use katana_cairo::cairo_vm::types::builtin_name::BuiltinName; use katana_primitives::trace::{CallInfo, TxExecInfo}; use katana_primitives::transaction::TxHash; use serde::{Deserialize, Serialize}; @@ -5,6 +6,8 @@ use starknet::core::types::{ CallType, ComputationResources, EntryPointType, OrderedEvent, OrderedMessage, }; +use crate::utils::get_builtin_instance_count; + #[derive(Debug)] pub struct FunctionInvocation(pub starknet::core::types::FunctionInvocation); @@ -40,21 +43,39 @@ impl From for FunctionInvocation { }) .collect(); - let vm_resources = info.execution_resources; - let get_vm_resource = |name: &str| vm_resources.builtin_instance_counter.get(name).copied(); + let resources = info.execution_resources; + // TODO: replace execution resources type in primitive CallInfo with an already defined // `TxExecutionResources` let execution_resources = ComputationResources { - steps: vm_resources.n_steps, - memory_holes: Some(vm_resources.n_memory_holes), - range_check_builtin_applications: get_vm_resource("range_check_builtin"), - pedersen_builtin_applications: get_vm_resource("pedersen_builtin"), - poseidon_builtin_applications: get_vm_resource("poseidon_builtin"), - ec_op_builtin_applications: get_vm_resource("ec_op_builtin"), - ecdsa_builtin_applications: get_vm_resource("ecdsa_builtin"), - bitwise_builtin_applications: get_vm_resource("bitwise_builtin"), - keccak_builtin_applications: get_vm_resource("keccak_builtin"), - segment_arena_builtin: get_vm_resource("segment_arena_builtin"), + steps: resources.n_steps as u64, + memory_holes: Some(resources.n_memory_holes as u64), + range_check_builtin_applications: get_builtin_instance_count( + &resources, + BuiltinName::range_check, + ), + pedersen_builtin_applications: get_builtin_instance_count( + &resources, + BuiltinName::pedersen, + ), + poseidon_builtin_applications: get_builtin_instance_count( + &resources, + BuiltinName::poseidon, + ), + ec_op_builtin_applications: get_builtin_instance_count(&resources, BuiltinName::ec_op), + ecdsa_builtin_applications: get_builtin_instance_count(&resources, BuiltinName::ecdsa), + bitwise_builtin_applications: get_builtin_instance_count( + &resources, + BuiltinName::bitwise, + ), + keccak_builtin_applications: get_builtin_instance_count( + &resources, + BuiltinName::keccak, + ), + segment_arena_builtin: get_builtin_instance_count( + &resources, + BuiltinName::segment_arena, + ), }; Self(starknet::core::types::FunctionInvocation { diff --git a/crates/katana/rpc/rpc-types/src/utils.rs b/crates/katana/rpc/rpc-types/src/utils.rs new file mode 100644 index 0000000000..f654e4b012 --- /dev/null +++ b/crates/katana/rpc/rpc-types/src/utils.rs @@ -0,0 +1,6 @@ +use katana_cairo::cairo_vm::types::builtin_name::BuiltinName; +use katana_primitives::trace::ExecutionResources; + +pub fn get_builtin_instance_count(value: &ExecutionResources, name: BuiltinName) -> Option { + value.builtin_instance_counter.get(&name).map(|&v| v as u64) +} diff --git a/crates/saya/core/Cargo.toml b/crates/saya/core/Cargo.toml index 2e716f6577..5a7466e3b4 100644 --- a/crates/saya/core/Cargo.toml +++ b/crates/saya/core/Cargo.toml @@ -16,7 +16,6 @@ anyhow.workspace = true async-trait.workspace = true bigdecimal.workspace = true cairo-proof-parser.workspace = true -cairo-vm.workspace = true dojo-world = { workspace = true, features = [ "contracts", "manifest", "metadata", "migration" ] } futures.workspace = true itertools.workspace = true diff --git a/crates/saya/core/src/blockchain/mod.rs b/crates/saya/core/src/blockchain/mod.rs index a225b3c64a..189c9f6dfa 100644 --- a/crates/saya/core/src/blockchain/mod.rs +++ b/crates/saya/core/src/blockchain/mod.rs @@ -1,11 +1,5 @@ //! Blockchain fetched from Katana. -use std::collections::HashMap; -use cairo_vm::vm::runners::builtin_runner::{ - BITWISE_BUILTIN_NAME, EC_OP_BUILTIN_NAME, HASH_BUILTIN_NAME, KECCAK_BUILTIN_NAME, - OUTPUT_BUILTIN_NAME, POSEIDON_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME, - SEGMENT_ARENA_BUILTIN_NAME, SIGNATURE_BUILTIN_NAME, -}; use katana_primitives::block::{BlockHashOrNumber, BlockIdOrTag, BlockTag, SealedBlockWithStatus}; use katana_primitives::state::StateUpdatesWithDeclaredClasses; use katana_provider::providers::in_memory::InMemoryProvider; @@ -136,18 +130,3 @@ impl Blockchain { Ok(provider.insert_block_with_states_and_receipts(block, states, receipts, vec![])?) } } - -fn _get_default_vm_resource_fee_cost() -> HashMap { - HashMap::from([ - (String::from("n_steps"), 1_f64), - (HASH_BUILTIN_NAME.to_string(), 1_f64), - (RANGE_CHECK_BUILTIN_NAME.to_string(), 1_f64), - (SIGNATURE_BUILTIN_NAME.to_string(), 1_f64), - (BITWISE_BUILTIN_NAME.to_string(), 1_f64), - (POSEIDON_BUILTIN_NAME.to_string(), 1_f64), - (OUTPUT_BUILTIN_NAME.to_string(), 1_f64), - (EC_OP_BUILTIN_NAME.to_string(), 1_f64), - (KECCAK_BUILTIN_NAME.to_string(), 1_f64), - (SEGMENT_ARENA_BUILTIN_NAME.to_string(), 1_f64), - ]) -}