From 98ef22350b9415a7e56b677ed60237a6c1361984 Mon Sep 17 00:00:00 2001 From: apoorvsadana <95699312+apoorvsadana@users.noreply.github.com> Date: Mon, 21 Aug 2023 13:19:52 +0530 Subject: [PATCH] fix: rebase fixes and adaptations (#993) Signed-off-by: apoorvsadana <95699312+apoorvsadana@users.noreply.github.com> --- CHANGELOG.md | 1 + Cargo.lock | 307 +++++++++++------- Cargo.toml | 14 +- .../starknet/src/blockifier_state_adapter.rs | 13 +- crates/pallets/starknet/src/lib.rs | 13 +- crates/pallets/starknet/src/tests/block.rs | 4 +- .../starknet/src/tests/mock/setup_mock.rs | 2 + .../primitives/starknet/src/block/header.rs | 4 +- crates/primitives/starknet/src/constants.rs | 2 +- .../src/execution/call_entrypoint_wrapper.rs | 8 +- crates/primitives/starknet/src/fees/mod.rs | 19 +- crates/primitives/starknet/src/state/mod.rs | 2 +- .../starknet/src/tests/execution.rs | 73 ++++- .../starknet/src/tests/transaction.rs | 8 +- crates/primitives/starknet/src/tests/utils.rs | 5 +- .../starknet/src/transaction/mod.rs | 222 +++++++------ .../starknet/src/transaction/utils.rs | 8 + crates/runtime/src/pallets.rs | 2 + madara-infra | 2 +- 19 files changed, 442 insertions(+), 267 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a198db2c60..715322a58f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - ci: disable benchmark for pushes and pr's - ci: fix docker and binaries build - ci: don't enforce changelog on PR's with label `dependencies` +- feat: rebase of core deps and 0.12.1 ## v0.1.0 diff --git a/Cargo.lock b/Cargo.lock index d4be45ef36..a3cf847683 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,6 +279,23 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools", + "num-traits 0.2.16", + "zeroize", +] + [[package]] name = "ark-ff" version = "0.4.2" @@ -288,7 +305,7 @@ dependencies = [ "ark-ff-asm", "ark-ff-macros", "ark-serialize", - "ark-std 0.4.0", + "ark-std", "derivative", "digest 0.10.7", "itertools", @@ -322,25 +339,51 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-secp256k1" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c02e954eaeb4ddb29613fee20840c2bbc85ca4396d53e33837e11905363c5f2" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-std", +] + [[package]] name = "ark-serialize" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ - "ark-std 0.4.0", + "ark-serialize-derive", + "ark-std", "digest 0.10.7", "num-bigint", ] [[package]] -name = "ark-std" -version = "0.3.0" +name = "ark-serialize-derive" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" dependencies = [ - "num-traits 0.2.16", - "rand 0.8.5", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -655,8 +698,8 @@ dependencies = [ [[package]] name = "bincode" -version = "2.0.0-rc.2" -source = "git+https://github.com/bincode-org/bincode.git?tag=v2.0.0-rc.2#6c219e9214bda2bdce1327db6ed7f66d2fa4bf02" +version = "2.0.0-rc.3" +source = "git+https://github.com/bincode-org/bincode.git?tag=v2.0.0-rc.3#aada4bb4cb457677a4b8e47572ae7ca8dd44927c" dependencies = [ "serde", ] @@ -822,9 +865,12 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "blockifier" -version = "0.1.0" -source = "git+https://github.com/keep-starknet-strange/blockifier?branch=no_std-support#15c81976e72f76ab7b5b19e68b597f9ae583dcd8" +version = "0.1.0-rc2" +source = "git+https://github.com/keep-starknet-strange/blockifier?branch=no_std-support-7578442#1042c076ce2b669cad9a20aad2e727b3a94713ac" dependencies = [ + "ark-ff", + "ark-secp256k1", + "cached", "cairo-felt", "cairo-lang-casm", "cairo-lang-casm-contract-class", @@ -832,9 +878,10 @@ dependencies = [ "cairo-lang-vm-utils", "cairo-vm", "derive_more", - "hashbrown 0.13.2", + "hashbrown 0.14.0", "indexmap 2.0.0-pre", "itertools", + "keccak", "lazy_static", "libm 0.2.7", "log", @@ -847,6 +894,7 @@ dependencies = [ "serde", "serde_json", "sha3", + "spin 0.9.8", "starknet-crypto 0.5.1", "starknet_api", "strum", @@ -938,10 +986,22 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "cached" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b195e4fbc4b6862bbd065b991a34750399c119797efff72492f28a5864de8700" +dependencies = [ + "hashbrown 0.13.2", + "instant", + "once_cell", + "thiserror", +] + [[package]] name = "cairo-felt" -version = "0.6.0" -source = "git+https://github.com/keep-starknet-strange/cairo-rs?branch=no_std-support-with-cairo-1#754c1bb974995471bd410f04ded2a90021ca32fd" +version = "0.8.5" +source = "git+https://github.com/keep-starknet-strange/cairo-rs?branch=no_std-support-21eff70#b68cc5fb723bc68ed65b16656bdb7bffb92d3b9a" dependencies = [ "lazy_static", "num-bigint", @@ -953,8 +1013,8 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-utils", "hashbrown 0.14.0", @@ -968,19 +1028,21 @@ dependencies = [ [[package]] name = "cairo-lang-casm-contract-class" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-casm", "cairo-lang-utils", + "itertools", "num-bigint", "serde", + "thiserror-no-std", ] [[package]] name = "cairo-lang-compiler" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "anyhow", "cairo-lang-defs", @@ -995,24 +1057,25 @@ dependencies = [ "cairo-lang-sierra-generator", "cairo-lang-syntax", "cairo-lang-utils", + "itertools", "log", "salsa", "smol_str", - "thiserror", + "thiserror-no-std", ] [[package]] name = "cairo-lang-debug" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -1020,7 +1083,7 @@ dependencies = [ "cairo-lang-parser", "cairo-lang-syntax", "cairo-lang-utils", - "indexmap 2.0.0", + "indexmap 2.0.0-pre", "itertools", "salsa", "smol_str", @@ -1028,9 +1091,10 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ + "cairo-lang-debug", "cairo-lang-filesystem", "cairo-lang-utils", "itertools", @@ -1039,19 +1103,19 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-utils", "good_lp", - "indexmap 2.0.0", + "indexmap 2.0.0-pre", "itertools", ] [[package]] name = "cairo-lang-filesystem" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -1063,8 +1127,8 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1076,19 +1140,20 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "id-arena", - "indexmap 2.0.0", + "indexmap 2.0.0-pre", "itertools", "log", "num-bigint", "num-traits 0.2.16", + "once_cell", "salsa", "smol_str", ] [[package]] name = "cairo-lang-parser" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -1107,8 +1172,8 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -1117,6 +1182,7 @@ dependencies = [ "cairo-lang-semantic", "cairo-lang-syntax", "cairo-lang-utils", + "indent", "indoc", "itertools", "num-bigint", @@ -1126,31 +1192,31 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-debug", "quote", - "syn 1.0.109", + "syn 2.0.28", ] [[package]] name = "cairo-lang-project" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", "serde", "smol_str", - "thiserror", - "toml 0.4.10", + "thiserror-no-std", + "toml 0.7.6", ] [[package]] name = "cairo-lang-semantic" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1165,14 +1231,15 @@ dependencies = [ "log", "num-bigint", "num-traits 0.2.16", + "once_cell", "salsa", "smol_str", ] [[package]] name = "cairo-lang-sierra" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-utils", "const-fnv1a-hash", @@ -1193,34 +1260,34 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", "cairo-lang-sierra-type-size", "cairo-lang-utils", "itertools", - "thiserror", + "thiserror-no-std", ] [[package]] name = "cairo-lang-sierra-gas" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", "cairo-lang-sierra-type-size", "cairo-lang-utils", "itertools", - "thiserror", + "thiserror-no-std", ] [[package]] name = "cairo-lang-sierra-generator" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1235,17 +1302,18 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "id-arena", - "indexmap 2.0.0", + "indexmap 2.0.0-pre", "itertools", "num-bigint", + "once_cell", "salsa", "smol_str", ] [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "assert_matches", "cairo-felt", @@ -1260,13 +1328,13 @@ dependencies = [ "log", "num-bigint", "num-traits 0.2.16", - "thiserror", + "thiserror-no-std", ] [[package]] name = "cairo-lang-sierra-type-size" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -1274,8 +1342,8 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "anyhow", "cairo-felt", @@ -1298,6 +1366,7 @@ dependencies = [ "cairo-lang-utils", "convert_case", "genco", + "indent", "indoc", "itertools", "log", @@ -1309,13 +1378,13 @@ dependencies = [ "serde_json", "sha3", "smol_str", - "thiserror", + "thiserror-no-std", ] [[package]] name = "cairo-lang-syntax" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1324,14 +1393,14 @@ dependencies = [ "num-traits 0.2.16", "salsa", "smol_str", - "thiserror", + "thiserror-no-std", "unescaper", ] [[package]] name = "cairo-lang-syntax-codegen" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "genco", "xshell", @@ -1339,12 +1408,12 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "cairo-felt", "hashbrown 0.14.0", - "indexmap 2.0.0", + "indexmap 2.0.0-pre", "itertools", "num-bigint", "num-integer", @@ -1355,11 +1424,11 @@ dependencies = [ [[package]] name = "cairo-lang-vm-utils" -version = "2.0.0-rc2" -source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support#64ef5864c5b92ee40b46ecb0b6fd854bd790938d" +version = "2.1.0" +source = "git+https://github.com/keep-starknet-strange/cairo.git?branch=no_std-support-8bbf530#0e591510d73be8d737b0832dc9215ff409e0ed15" dependencies = [ "ark-ff", - "ark-std 0.3.0", + "ark-std", "cairo-felt", "cairo-lang-casm", "cairo-lang-utils", @@ -1373,27 +1442,27 @@ dependencies = [ [[package]] name = "cairo-take_until_unbalanced" version = "0.29.0" -source = "git+https://github.com/keep-starknet-strange/cairo-rs?branch=no_std-support-with-cairo-1#754c1bb974995471bd410f04ded2a90021ca32fd" +source = "git+https://github.com/keep-starknet-strange/cairo-rs?branch=no_std-support-21eff70#b68cc5fb723bc68ed65b16656bdb7bffb92d3b9a" dependencies = [ "nom", ] [[package]] name = "cairo-vm" -version = "0.6.0" -source = "git+https://github.com/keep-starknet-strange/cairo-rs?branch=no_std-support-with-cairo-1#754c1bb974995471bd410f04ded2a90021ca32fd" +version = "0.8.5" +source = "git+https://github.com/keep-starknet-strange/cairo-rs?branch=no_std-support-21eff70#b68cc5fb723bc68ed65b16656bdb7bffb92d3b9a" dependencies = [ "anyhow", "ark-ff", - "ark-std 0.3.0", - "bincode 2.0.0-rc.2", + "ark-std", + "bincode 2.0.0-rc.3", "bitvec", "cairo-felt", "cairo-lang-casm", "cairo-lang-casm-contract-class", "cairo-take_until_unbalanced", "generic-array 0.14.7", - "hashbrown 0.13.2", + "hashbrown 0.14.0", "hex", "keccak", "lazy_static", @@ -1404,14 +1473,11 @@ dependencies = [ "num-traits 0.2.16", "parity-scale-codec", "rand 0.8.5", - "rand_core 0.6.4", "serde", - "serde_bytes", "serde_json", "sha2 0.10.7", "sha3", "starknet-crypto 0.5.1", - "thiserror", "thiserror-no-std", ] @@ -3477,7 +3543,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ "ahash 0.8.3", - "serde", ] [[package]] @@ -3807,6 +3872,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "indent" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9f1a0777d972970f204fdf8ef319f1f4f8459131636d7e3c96c5d59570d0fa6" + [[package]] name = "indexmap" version = "1.9.3" @@ -3835,7 +3906,6 @@ checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ "equivalent", "hashbrown 0.14.0", - "serde", ] [[package]] @@ -4183,9 +4253,9 @@ dependencies = [ [[package]] name = "lalrpop" -version = "0.19.12" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a1cbf952127589f2851ab2046af368fd20645491bb4b376f04b7f94d7a9837b" +checksum = "da4081d44f4611b66c6dd725e6de3169f9f63905421e8626fcb86b6a898998b8" dependencies = [ "ascii-canvas", "bit-set", @@ -4195,8 +4265,9 @@ dependencies = [ "itertools", "lalrpop-util", "petgraph", + "pico-args", "regex", - "regex-syntax 0.6.29", + "regex-syntax 0.7.4", "string_cache", "term", "tiny-keccak", @@ -4205,9 +4276,9 @@ dependencies = [ [[package]] name = "lalrpop-util" -version = "0.19.12" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3c48237b9604c5a4702de6b824e02006c3214327564636aef27c1028a8fa0ed" +checksum = "3f35c735096c0293d313e8f2a641627472b83d01b937177fe76e5e2708d31e0d" dependencies = [ "regex", ] @@ -4218,7 +4289,7 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" dependencies = [ - "spin", + "spin 0.5.2", ] [[package]] @@ -6252,9 +6323,9 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "path-clean" -version = "0.1.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecba01bf2678719532c5e3059e0b5f0811273d94b397088b82e3bd0a78c78fdd" +checksum = "17359afc20d7ab31fdb42bb844c8b3bb1dabd7dcf7e68428492da7f16966fcef" [[package]] name = "pbkdf2" @@ -6409,6 +6480,12 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pico-args" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" + [[package]] name = "pin-project" version = "1.1.2" @@ -7176,7 +7253,7 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", + "spin 0.5.2", "untrusted", "web-sys", "winapi", @@ -8712,15 +8789,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde_bytes" -version = "0.11.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab33ec92f677585af6d88c65593ae2375adde54efdbf16d597f2cbc7a6d368ff" -dependencies = [ - "serde", -] - [[package]] name = "serde_derive" version = "1.0.180" @@ -9725,6 +9793,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "spinners" version = "4.1.0" @@ -9891,12 +9965,12 @@ dependencies = [ [[package]] name = "starknet_api" -version = "0.1.0" -source = "git+https://github.com/keep-starknet-strange/starknet-api?branch=no_std-support#6a48e7c8636685b80515c6ab666c1ae9d01278a2" +version = "0.4.1" +source = "git+https://github.com/keep-starknet-strange/starknet-api?branch=no_std-support-dc83f05#a3f77466db1ce72cddf635c4a5cc02ce74da8a38" dependencies = [ "cairo-lang-casm-contract-class", "derive_more", - "hashbrown 0.13.2", + "hashbrown 0.14.0", "hex", "indexmap 2.0.0-pre", "once_cell", @@ -10591,15 +10665,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "toml" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -dependencies = [ - "serde", -] - [[package]] name = "toml" version = "0.5.11" @@ -10916,7 +10981,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", - "rand 0.8.5", + "rand 0.7.3", "static_assertions", ] diff --git a/Cargo.toml b/Cargo.toml index cc4d11b552..9aa2b1435a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -127,7 +127,7 @@ madara-runtime = { path = "crates/runtime" } # Starknet dependencies # Cairo Virtual Machine -cairo-vm = { git = "https://github.com/keep-starknet-strange/cairo-rs", branch = "no_std-support-with-cairo-1", default-features = false, features = [ +cairo-vm = { git = "https://github.com/keep-starknet-strange/cairo-rs", branch = "no_std-support-21eff70", default-features = false, features = [ "cairo-1-hints", "parity-scale-codec", ] } @@ -135,19 +135,19 @@ starknet-crypto = { version = "0.6.0", default-features = false } starknet-core = { version = "0.5.0", default-features = false } starknet-ff = { version = "0.3.4", default-features = false } -blockifier = { git = "https://github.com/keep-starknet-strange/blockifier", branch = "no_std-support", default-features = false, features = [ +blockifier = { git = "https://github.com/keep-starknet-strange/blockifier", branch = "no_std-support-7578442", default-features = false, features = [ "parity-scale-codec", ] } -starknet_api = { git = "https://github.com/keep-starknet-strange/starknet-api", branch = "no_std-support", features = [ +starknet_api = { git = "https://github.com/keep-starknet-strange/starknet-api", branch = "no_std-support-dc83f05", features = [ "testing", "parity-scale-codec", ], default-features = false } # Cairo lang -cairo-lang-starknet = { git = "https://github.com/keep-starknet-strange/cairo.git", branch = "no_std-support", default-features = false } -cairo-lang-casm-contract-class = { git = "https://github.com/keep-starknet-strange/cairo.git", branch = "no_std-support", default-features = false } -cairo-lang-casm = { git = "https://github.com/keep-starknet-strange/cairo.git", branch = "no_std-support", default-features = false } -cairo-lang-utils = { git = "https://github.com/keep-starknet-strange/cairo.git", branch = "no_std-support", default-features = false } +cairo-lang-starknet = { git = "https://github.com/keep-starknet-strange/cairo.git", branch = "no_std-support-8bbf530", default-features = false } +cairo-lang-casm-contract-class = { git = "https://github.com/keep-starknet-strange/cairo.git", branch = "no_std-support-8bbf530", default-features = false } +cairo-lang-casm = { git = "https://github.com/keep-starknet-strange/cairo.git", branch = "no_std-support-8bbf530", default-features = false } +cairo-lang-utils = { git = "https://github.com/keep-starknet-strange/cairo.git", branch = "no_std-support-8bbf530", default-features = false } # Other third party dependencies anyhow = "1.0.71" diff --git a/crates/pallets/starknet/src/blockifier_state_adapter.rs b/crates/pallets/starknet/src/blockifier_state_adapter.rs index c422b746fa..610bd14e81 100644 --- a/crates/pallets/starknet/src/blockifier_state_adapter.rs +++ b/crates/pallets/starknet/src/blockifier_state_adapter.rs @@ -28,6 +28,7 @@ use crate::{Config, Pallet}; pub struct BlockifierStateAdapter { storage_update: BTreeMap, class_hash_update: usize, + compiled_class_hash_update: usize, _phantom: PhantomData, } @@ -35,10 +36,10 @@ impl StateChanges for BlockifierStateAdapter where T: Config, { - fn count_state_changes(&self) -> (usize, usize, usize) { + fn count_state_changes(&self) -> (usize, usize, usize, usize) { let keys = self.storage_update.keys(); let n_contract_updated = BTreeSet::from_iter(keys.clone().map(|&(contract_address, _)| contract_address)).len(); - (n_contract_updated, keys.len(), self.class_hash_update) + (n_contract_updated, keys.len(), self.class_hash_update, self.compiled_class_hash_update) } } @@ -53,7 +54,12 @@ where impl Default for BlockifierStateAdapter { fn default() -> Self { - Self { storage_update: BTreeMap::default(), class_hash_update: usize::default(), _phantom: PhantomData } + Self { + storage_update: BTreeMap::default(), + class_hash_update: usize::default(), + compiled_class_hash_update: usize::default(), + _phantom: PhantomData, + } } } @@ -191,6 +197,7 @@ impl State for BlockifierStateAdapter { class_hash: ClassHash, compiled_class_hash: CompiledClassHash, ) -> StateResult<()> { + self.compiled_class_hash_update += 1; // FIXME 708 let class_hash: ClassHashWrapper = class_hash.0.into(); let compiled_class_hash: CompiledClassHashWrapper = compiled_class_hash.0.into(); diff --git a/crates/pallets/starknet/src/lib.rs b/crates/pallets/starknet/src/lib.rs index efcba84202..f2a5c24601 100644 --- a/crates/pallets/starknet/src/lib.rs +++ b/crates/pallets/starknet/src/lib.rs @@ -98,7 +98,6 @@ use sp_std::result; use starknet_api::api_core::{ChainId, ContractAddress}; use starknet_api::block::{BlockNumber, BlockTimestamp}; use starknet_api::hash::StarkFelt; -use starknet_api::stdlib::collections::HashMap; use starknet_api::transaction::EventContent; use starknet_crypto::FieldElement; @@ -174,6 +173,8 @@ pub mod pallet { type ProtocolVersion: Get; #[pallet::constant] type ChainId: Get; + #[pallet::constant] + type MaxRecursionDepth: Get; } /// The Starknet pallet hooks. @@ -525,7 +526,6 @@ pub mod pallet { &block_context, TxType::Invoke, T::DisableNonceValidation::get(), - None, ); let receipt = match call_info { Ok(TransactionExecutionInfoWrapper { @@ -579,7 +579,7 @@ pub mod pallet { let transaction: Transaction = transaction.from_declare(chain_id); // Check that contract class is not None - let contract_class = transaction.contract_class.clone().ok_or(Error::::ContractClassMustBeSpecified)?; + transaction.contract_class.clone().ok_or(Error::::ContractClassMustBeSpecified)?; // Check that the class hash is not None let class_hash = transaction.call_entrypoint.class_hash.ok_or(Error::::ClassHashMustBeSpecified)?; @@ -599,7 +599,6 @@ pub mod pallet { &block_context, TxType::Declare, T::DisableNonceValidation::get(), - Some(contract_class), ); let receipt = match call_info { Ok(TransactionExecutionInfoWrapper { @@ -671,7 +670,6 @@ pub mod pallet { &block_context, TxType::DeployAccount, T::DisableNonceValidation::get(), - None, ); let receipt = match call_info { Ok(TransactionExecutionInfoWrapper { @@ -735,7 +733,6 @@ pub mod pallet { &block_context, TxType::L1Handler, true, - None, ) { Ok(v) => { log!(debug, "Successfully consumed a message from L1: {:?}", v); @@ -900,7 +897,7 @@ impl Pallet { let chain_id = Self::chain_id_str(); - let vm_resource_fee_cost = HashMap::default(); + let vm_resource_fee_cost = Default::default(); // FIXME: https://github.com/keep-starknet-strange/madara/issues/329 let gas_price = 10; BlockContext { @@ -913,6 +910,7 @@ impl Pallet { invoke_tx_max_n_steps: T::InvokeTxMaxNSteps::get(), validate_max_n_steps: T::ValidateMaxNSteps::get(), gas_price, + max_recursion_depth: T::MaxRecursionDepth::get() as usize, } } @@ -1156,7 +1154,6 @@ impl Pallet { &Self::get_block_context(), transaction.tx_type.clone(), T::DisableNonceValidation::get(), - transaction.contract_class.clone(), ) { Ok(v) => { log!(debug, "Successfully estimated fee: {:?}", v); diff --git a/crates/pallets/starknet/src/tests/block.rs b/crates/pallets/starknet/src/tests/block.rs index 986bcf818f..ec1e22bdeb 100644 --- a/crates/pallets/starknet/src/tests/block.rs +++ b/crates/pallets/starknet/src/tests/block.rs @@ -1,3 +1,4 @@ +use alloc::sync::Arc; use std::collections::HashMap; use frame_support::assert_ok; @@ -121,7 +122,8 @@ fn get_block_context_works() { block_context.fee_token_address ); // correct vm_resource_fee_cost - assert_eq!(HashMap::::new(), block_context.vm_resource_fee_cost); + let vm_resoursce_fee_cost: Arc> = Default::default(); + assert_eq!(vm_resoursce_fee_cost, block_context.vm_resource_fee_cost); // correct invoke_tx_max_n_steps: T::InvokeTxMaxNSteps::get(), assert_eq!(InvokeTxMaxNSteps::get(), block_context.invoke_tx_max_n_steps); // correct validate_max_n_steps: T::ValidateMaxNSteps::get(), diff --git a/crates/pallets/starknet/src/tests/mock/setup_mock.rs b/crates/pallets/starknet/src/tests/mock/setup_mock.rs index ddb448e029..c585a1342b 100644 --- a/crates/pallets/starknet/src/tests/mock/setup_mock.rs +++ b/crates/pallets/starknet/src/tests/mock/setup_mock.rs @@ -79,6 +79,7 @@ macro_rules! mock_runtime { pub const DisableNonceValidation: bool = $disable_nonce_validation; pub const ProtocolVersion: u8 = 0; pub const ChainId: Felt252Wrapper = SN_GOERLI_CHAIN_ID; + pub const MaxRecursionDepth: u32 = 50; } impl pallet_starknet::Config for MockRuntime { @@ -94,6 +95,7 @@ macro_rules! mock_runtime { type DisableNonceValidation = DisableNonceValidation; type ProtocolVersion = ProtocolVersion; type ChainId = ChainId; + type MaxRecursionDepth = MaxRecursionDepth; } /// Run to block n. diff --git a/crates/primitives/starknet/src/block/header.rs b/crates/primitives/starknet/src/block/header.rs index c93c9a23b3..ba940cb787 100644 --- a/crates/primitives/starknet/src/block/header.rs +++ b/crates/primitives/starknet/src/block/header.rs @@ -3,7 +3,6 @@ use sp_core::U256; use starknet_api::api_core::{ChainId, ContractAddress}; use starknet_api::block::{BlockNumber, BlockTimestamp}; use starknet_api::hash::StarkFelt; -use starknet_api::stdlib::collections::HashMap; use crate::execution::types::{ContractAddressWrapper, Felt252Wrapper}; use crate::traits::hash::HasherT; @@ -91,12 +90,13 @@ impl Header { block_number: BlockNumber(self.block_number), block_timestamp: BlockTimestamp(self.block_timestamp), sequencer_address, - vm_resource_fee_cost: HashMap::default(), + vm_resource_fee_cost: Default::default(), fee_token_address, invoke_tx_max_n_steps: 1000000, validate_max_n_steps: 1000000, // FIXME: https://github.com/keep-starknet-strange/madara/issues/329 gas_price: 10, + max_recursion_depth: 50, } } diff --git a/crates/primitives/starknet/src/constants.rs b/crates/primitives/starknet/src/constants.rs index 1c4a79b84a..cfc54f4a38 100644 --- a/crates/primitives/starknet/src/constants.rs +++ b/crates/primitives/starknet/src/constants.rs @@ -3,7 +3,7 @@ use starknet_ff::FieldElement; use crate::execution::felt252_wrapper::Felt252Wrapper; /// Initial gas for a transaction -pub const INITIAL_GAS: u128 = u128::MAX; +pub const INITIAL_GAS: u64 = u64::MAX; // Need to use `from_mont` because this needs to be a constant function call /// ChainId for Starknet Goerli testnet diff --git a/crates/primitives/starknet/src/execution/call_entrypoint_wrapper.rs b/crates/primitives/starknet/src/execution/call_entrypoint_wrapper.rs index f6898b9235..5eb260749d 100644 --- a/crates/primitives/starknet/src/execution/call_entrypoint_wrapper.rs +++ b/crates/primitives/starknet/src/execution/call_entrypoint_wrapper.rs @@ -106,7 +106,7 @@ impl CallEntryPointWrapper { let execution_resources = &mut ExecutionResources::default(); let account_context = AccountTransactionContext::default(); let max_steps = block_context.invoke_tx_max_n_steps; - let context = &mut EntryPointExecutionContext::new(block_context, account_context, max_steps); + let context = &mut EntryPointExecutionContext::new(block_context, account_context, max_steps as usize); call_entry_point .execute(state, execution_resources, context) @@ -161,7 +161,11 @@ impl TryInto for CallEntryPointWrapper { // starknet-lib is constantly breaking it's api // I hope it's nothing important ¯\_(ツ)_/¯ code_address: None, - initial_gas: self.initial_gas.into(), + // initial_gas should come from the RPC call + // and should be a u64. If it's not, the error must + // be caught on the client side, hence it's safe to + // unwrap over here + initial_gas: self.initial_gas.try_into().unwrap(), }; Ok(entrypoint) diff --git a/crates/primitives/starknet/src/fees/mod.rs b/crates/primitives/starknet/src/fees/mod.rs index 95f0191103..3d8250982a 100644 --- a/crates/primitives/starknet/src/fees/mod.rs +++ b/crates/primitives/starknet/src/fees/mod.rs @@ -10,6 +10,7 @@ use blockifier::execution::entry_point::{ }; use blockifier::fee::gas_usage::calculate_tx_gas_usage; use blockifier::fee::os_usage::get_additional_os_resources; +use blockifier::state::cached_state::StateChangesCount; use blockifier::state::state_api::State; use blockifier::transaction::objects::AccountTransactionContext; use starknet_api::api_core::EntryPointSelector; @@ -51,7 +52,8 @@ pub fn get_transaction_resources( execution_resources: &mut ExecutionResources, tx_type: TxType, ) -> Result, TransactionExecutionErrorWrapper> { - let (n_modified_contracts, n_modified_keys, n_class_updates) = state.count_state_changes(); + let (n_modified_contracts, n_modified_keys, n_class_hash_updates, n_compiled_class_hash_updates) = + state.count_state_changes(); let non_optional_call_infos: Vec<&CallInfo> = vec![execute_call_info, validate_call_info].into_iter().flatten().collect(); let mut l2_to_l1_payloads_length = vec![]; @@ -64,14 +66,17 @@ pub fn get_transaction_resources( } let l1_gas_usage = calculate_tx_gas_usage( &l2_to_l1_payloads_length, - n_modified_contracts, - n_modified_keys + usize::from(FEE_TRANSFER_N_STORAGE_CHANGES_TO_CHARGE), + StateChangesCount { + n_modified_contracts, + n_storage_updates: n_modified_keys + usize::from(FEE_TRANSFER_N_STORAGE_CHANGES_TO_CHARGE), + n_class_hash_updates, + n_compiled_class_hash_updates, + }, None, - n_class_updates, ); // Add additional Cairo resources needed for the OS to run the transaction. let total_vm_usage = &execution_resources.vm_resources - + &get_additional_os_resources(execution_resources.syscall_counter.clone(), tx_type.into()) + + &get_additional_os_resources(&execution_resources.syscall_counter.clone(), tx_type.into()) .map_err(|_| TransactionExecutionErrorWrapper::FeeComputationError)?; let total_vm_usage = total_vm_usage.filter_unused_builtins(); let mut tx_resources = BTreeMap::from([ @@ -141,7 +146,7 @@ fn execute_fee_transfer( let msb_amount = StarkFelt::from(0_u64); // The fee-token contract is a Cairo 0 contract, hence the initial gas is irrelevant. - let initial_gas = super::constants::INITIAL_GAS.into(); + let initial_gas = super::constants::INITIAL_GAS; let storage_address = block_context.fee_token_address; let fee_transfer_call = CallEntryPoint { @@ -168,7 +173,7 @@ fn execute_fee_transfer( }; let max_steps = block_context.invoke_tx_max_n_steps; - let mut context = EntryPointExecutionContext::new(block_context.clone(), account_tx_context, max_steps); + let mut context = EntryPointExecutionContext::new(block_context.clone(), account_tx_context, max_steps as usize); fee_transfer_call .execute(state, &mut ExecutionResources::default(), &mut context) diff --git a/crates/primitives/starknet/src/state/mod.rs b/crates/primitives/starknet/src/state/mod.rs index d7aaca75c9..57aa9214cb 100644 --- a/crates/primitives/starknet/src/state/mod.rs +++ b/crates/primitives/starknet/src/state/mod.rs @@ -20,7 +20,7 @@ pub trait StateChanges { /// * `usize` - The number of modified contracts in the transaction. /// * `usize` - The number of modified storage vars in the transaction. /// * `usize` - The number of newly declared classes. - fn count_state_changes(&self) -> (usize, usize, usize); + fn count_state_changes(&self) -> (usize, usize, usize, usize); } /// This trait allows to get the fee config for the pallet and accordingly charge the fees diff --git a/crates/primitives/starknet/src/tests/execution.rs b/crates/primitives/starknet/src/tests/execution.rs index 0dc87a74a2..dc3e1dff1e 100644 --- a/crates/primitives/starknet/src/tests/execution.rs +++ b/crates/primitives/starknet/src/tests/execution.rs @@ -1,9 +1,12 @@ use alloc::sync::Arc; -use std::collections::HashMap; use blockifier::abi::abi_utils::selector_from_name; use blockifier::block_context::BlockContext; use blockifier::execution::entry_point::{CallEntryPoint, CallType}; +use blockifier::execution::errors::{EntryPointExecutionError, VirtualMachineExecutionError}; +use cairo_vm::vm::errors::cairo_run_errors::CairoRunError; +use cairo_vm::vm::errors::vm_errors::VirtualMachineError; +use cairo_vm::vm::errors::vm_exception::VmException; use frame_support::{assert_ok, bounded_vec}; use starknet_api::api_core::{ChainId, ClassHash, ContractAddress, EntryPointSelector, PatriciaKey}; use starknet_api::block::{BlockNumber, BlockTimestamp}; @@ -14,7 +17,7 @@ use starknet_api::{patricia_key, stark_felt}; use crate::constants::INITIAL_GAS; use crate::execution::call_entrypoint_wrapper::CallEntryPointWrapper; -use crate::execution::entrypoint_wrapper::EntryPointTypeWrapper; +use crate::execution::entrypoint_wrapper::{EntryPointExecutionErrorWrapper, EntryPointTypeWrapper}; use crate::execution::types::{ContractAddressWrapper, Felt252Wrapper}; use crate::tests::utils::{create_test_state, TEST_CLASS_HASH, TEST_CONTRACT_ADDRESS}; @@ -44,15 +47,70 @@ fn test_call_entry_point_execute_works() { block_timestamp: BlockTimestamp(0), sequencer_address: ContractAddress::default(), fee_token_address: ContractAddress::default(), - vm_resource_fee_cost: HashMap::default(), + vm_resource_fee_cost: Default::default(), gas_price: 0, - invoke_tx_max_n_steps: 0, - validate_max_n_steps: 0, + invoke_tx_max_n_steps: 1000000, + validate_max_n_steps: 1000000, + max_recursion_depth: 50, }; assert_ok!(entrypoint.execute(&mut test_state, block_context)); } +#[test] +fn test_call_entry_point_fails_insufficient_steps() { + let mut test_state = create_test_state(); + + let class_hash = Felt252Wrapper::from_hex_be(TEST_CLASS_HASH).unwrap(); + let address = Felt252Wrapper::from_hex_be(TEST_CONTRACT_ADDRESS).unwrap(); + let selector = selector_from_name("return_result").0.into(); + let calldata = bounded_vec![42_u128.into()]; + + let entrypoint = CallEntryPointWrapper::new( + Some(class_hash), + EntryPointTypeWrapper::External, + Some(selector), + calldata, + address, + ContractAddressWrapper::default(), + Felt252Wrapper::default(), + None, + ); + + let block_context = BlockContext { + chain_id: ChainId("0x1".to_string()), + block_number: BlockNumber(0), + block_timestamp: BlockTimestamp(0), + sequencer_address: ContractAddress::default(), + fee_token_address: ContractAddress::default(), + vm_resource_fee_cost: Default::default(), + gas_price: 0, + invoke_tx_max_n_steps: 0, + validate_max_n_steps: 1000000, + max_recursion_depth: 50, + }; + + match entrypoint.execute(&mut test_state, block_context) { + Ok(_) => panic!("Expected an error"), + Err(EntryPointExecutionErrorWrapper::EntryPointExecution( + EntryPointExecutionError::VirtualMachineExecutionErrorWithTrace { + trace: _, + source: + VirtualMachineExecutionError::CairoRunError(CairoRunError::VmException(VmException { + pc: _, + inst_location: _, + inner_exc, + error_attr_value: _, + traceback: _, + })), + }, + )) => { + assert!(matches!(inner_exc, VirtualMachineError::UnfinishedExecution)); + } + _ => panic!("Unexpected error type"), + } +} + #[test] fn test_call_entry_point_execute_fails_undeclared_class_hash() { let mut test_state = create_test_state(); @@ -78,10 +136,11 @@ fn test_call_entry_point_execute_fails_undeclared_class_hash() { block_timestamp: BlockTimestamp(0), sequencer_address: ContractAddress::default(), fee_token_address: ContractAddress::default(), - vm_resource_fee_cost: HashMap::default(), + vm_resource_fee_cost: Default::default(), gas_price: 0, invoke_tx_max_n_steps: 0, validate_max_n_steps: 0, + max_recursion_depth: 0, }; assert!(entrypoint.execute(&mut test_state, block_context).is_err()); @@ -116,7 +175,7 @@ fn test_try_into_entrypoint_works() { code_address: None, entry_point_selector: EntryPointSelector(stark_felt!(0_u8)), entry_point_type: EntryPointType::External, - initial_gas: INITIAL_GAS.into(), + initial_gas: INITIAL_GAS, }; pretty_assertions::assert_eq!(entrypoint, expected_entrypoint); diff --git a/crates/primitives/starknet/src/tests/transaction.rs b/crates/primitives/starknet/src/tests/transaction.rs index 8ec924f445..e052cb2509 100644 --- a/crates/primitives/starknet/src/tests/transaction.rs +++ b/crates/primitives/starknet/src/tests/transaction.rs @@ -1,6 +1,7 @@ use core::str::FromStr; use blockifier::abi::abi_utils::selector_from_name; +use blockifier::execution::contract_class::ContractClassV0; use frame_support::{bounded_vec, BoundedVec}; use sp_core::{TypedGet, U256}; use starknet_api::api_core::{ContractAddress, PatriciaKey}; @@ -8,8 +9,8 @@ use starknet_api::block::{BlockHash, BlockNumber}; use starknet_api::hash::{StarkFelt, StarkHash}; use starknet_api::patricia_key; use starknet_api::transaction::{ - Event, EventContent, EventData, EventKey, Fee, InvokeTransactionOutput, TransactionHash, TransactionOutput, - TransactionReceipt, + Event, EventContent, EventData, EventKey, Fee, InvokeTransactionOutput, TransactionExecutionStatus, + TransactionHash, TransactionOutput, TransactionReceipt, }; use starknet_core::types::{ BroadcastedDeployAccountTransaction, BroadcastedInvokeTransaction, BroadcastedInvokeTransactionV0, @@ -96,6 +97,7 @@ fn test_validate_entrypoint_calldata_declare() { class_hash: Some(get_test_class_hash()), ..CallEntryPointWrapper::default() }, + contract_class: Some(blockifier::execution::contract_class::ContractClass::V0(ContractClassV0::default())), ..Transaction::default() }; @@ -231,6 +233,7 @@ fn test_try_into_transaction_receipt_wrapper() { actual_fee: Fee(0), messages_sent: vec![], events: vec![event1.clone(), event2.clone()], + execution_status: TransactionExecutionStatus::Succeeded, }), block_hash: BlockHash(StarkFelt::new([0; 32]).unwrap()), block_number: BlockNumber(0), @@ -290,6 +293,7 @@ fn test_try_into_transaction_receipt_wrapper_with_too_many_events() { actual_fee: Fee(0), messages_sent: vec![], events, + execution_status: TransactionExecutionStatus::Succeeded, }), block_hash: BlockHash(StarkFelt::new([0; 32]).unwrap()), block_number: BlockNumber(0), diff --git a/crates/primitives/starknet/src/tests/utils.rs b/crates/primitives/starknet/src/tests/utils.rs index d31e4aa6eb..00319c8395 100644 --- a/crates/primitives/starknet/src/tests/utils.rs +++ b/crates/primitives/starknet/src/tests/utils.rs @@ -57,7 +57,10 @@ pub fn create_test_state() -> CachedState { ), ]); - CachedState::new(DictStateReader { class_hash_to_class, address_to_class_hash, ..Default::default() }) + CachedState::new( + DictStateReader { class_hash_to_class, address_to_class_hash, ..Default::default() }, + Default::default(), + ) } pub fn get_contract_class(contract_path: &str, version: u8) -> ContractClass { diff --git a/crates/primitives/starknet/src/transaction/mod.rs b/crates/primitives/starknet/src/transaction/mod.rs index 559630f504..6142d38c73 100644 --- a/crates/primitives/starknet/src/transaction/mod.rs +++ b/crates/primitives/starknet/src/transaction/mod.rs @@ -15,26 +15,22 @@ use blockifier::execution::entry_point::{ CallEntryPoint, CallInfo, CallType, EntryPointExecutionContext, ExecutionResources, }; use blockifier::execution::errors::EntryPointExecutionError; -use blockifier::state::errors::StateError; use blockifier::state::state_api::State; use blockifier::transaction::errors::TransactionExecutionError; use blockifier::transaction::objects::AccountTransactionContext; use blockifier::transaction::transaction_utils::{update_remaining_gas, verify_no_calls_to_other_contracts}; use blockifier::transaction::transactions::{ - DeclareTransaction as StarknetDeclareTransaction, Executable, L1HandlerTransaction as StarknetL1HandlerTransaction, + DeclareTransaction, DeployAccountTransaction, Executable, InvokeTransaction, L1HandlerTransaction, }; -use cairo_vm::felt::Felt252; use frame_support::BoundedVec; use sp_core::U256; -use starknet_api::api_core::{ - ClassHash, CompiledClassHash, ContractAddress as StarknetContractAddress, EntryPointSelector, Nonce, -}; +use starknet_api::api_core::{CompiledClassHash, ContractAddress as StarknetContractAddress, EntryPointSelector}; use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::hash::{StarkFelt, StarkHash}; use starknet_api::transaction::{ - Calldata, ContractAddressSalt, DeclareTransaction, DeclareTransactionV0V1, DeclareTransactionV2, - DeployAccountTransaction, EventContent, Fee, InvokeTransaction, InvokeTransactionV1, L1HandlerTransaction, - TransactionHash, TransactionOutput, TransactionReceipt, TransactionSignature, TransactionVersion, + Calldata, ContractAddressSalt, DeclareTransactionV0V1, DeclareTransactionV2, EventContent, Fee, + InvokeTransactionV1, TransactionHash, TransactionOutput, TransactionReceipt, TransactionSignature, + TransactionVersion, }; use starknet_api::{calldata, StarknetApiError}; @@ -43,7 +39,7 @@ use self::types::{ TransactionExecutionInfoWrapper, TransactionExecutionResultWrapper, TransactionReceiptWrapper, TransactionValidationErrorWrapper, TransactionValidationResultWrapper, TxType, }; -use self::utils::{calculate_transaction_version, calculate_transaction_version_from_u8}; +use self::utils::{calculate_transaction_version, calculate_transaction_version_from_u8, felt_to_nonce}; use crate::execution::types::{CallEntryPointWrapper, ContractAddressWrapper, Felt252Wrapper}; use crate::fees::{self, charge_fee}; use crate::state::{FeeConfig, StateChanges}; @@ -197,19 +193,21 @@ impl TryInto for &Transaction { let entrypoint: CallEntryPoint = self.call_entrypoint.clone().try_into()?; Ok(DeployAccountTransaction { - transaction_hash: TransactionHash(StarkFelt::new(self.hash.into())?), - max_fee: Fee(self.max_fee.try_into().unwrap()), - version: TransactionVersion(StarkFelt::new(U256::from(self.version).into())?), - signature: TransactionSignature( - self.signature.clone().into_inner().iter().map(|x| StarkFelt::new((*x).into()).unwrap()).collect(), - ), - nonce: Nonce(StarkFelt::new(self.nonce.into())?), + tx_hash: TransactionHash(StarkFelt::new(self.hash.into())?), + tx: starknet_api::transaction::DeployAccountTransaction { + max_fee: Fee(self.max_fee.try_into().unwrap()), + version: TransactionVersion(StarkFelt::new(U256::from(self.version).into())?), + signature: TransactionSignature( + self.signature.clone().into_inner().iter().map(|x| StarkFelt::new((*x).into()).unwrap()).collect(), + ), + nonce: felt_to_nonce(self.nonce)?, + class_hash: entrypoint.class_hash.unwrap_or_default(), + constructor_calldata: entrypoint.calldata, + contract_address_salt: ContractAddressSalt(StarkFelt::new( + self.contract_address_salt.unwrap_or_default().into(), + )?), + }, contract_address: StarknetContractAddress::try_from(StarkFelt::new(self.sender_address.into())?)?, - class_hash: entrypoint.class_hash.unwrap_or_default(), - constructor_calldata: entrypoint.calldata, - contract_address_salt: ContractAddressSalt(StarkFelt::new( - self.contract_address_salt.unwrap_or_default().into(), - )?), }) } } @@ -222,14 +220,18 @@ impl TryInto for &Transaction { let entrypoint: CallEntryPoint = self.call_entrypoint.clone().try_into()?; Ok(L1HandlerTransaction { - transaction_hash: TransactionHash(StarkFelt::new(self.hash.into())?), - version: TransactionVersion(StarkFelt::new(U256::from(self.version).into())?), - nonce: Nonce(StarkFelt::new(self.nonce.into())?), - contract_address: StarknetContractAddress::try_from(StarkFelt::new(self.sender_address.into())?)?, - calldata: entrypoint.calldata, - entry_point_selector: EntryPointSelector(StarkHash::new(<[u8; 32]>::from( - self.call_entrypoint.entrypoint_selector.unwrap_or_default(), - ))?), + tx_hash: TransactionHash(StarkFelt::new(self.hash.into())?), + tx: starknet_api::transaction::L1HandlerTransaction { + version: TransactionVersion(StarkFelt::new(U256::from(self.version).into())?), + nonce: felt_to_nonce(self.nonce)?, + contract_address: StarknetContractAddress::try_from(StarkFelt::new(self.sender_address.into())?)?, + calldata: entrypoint.calldata, + entry_point_selector: EntryPointSelector(StarkHash::new(<[u8; 32]>::from( + self.call_entrypoint.entrypoint_selector.unwrap_or_default(), + ))?), + }, + // FIXME 712 + paid_fee_on_l1: Default::default(), }) } } @@ -241,16 +243,18 @@ impl TryInto for &Transaction { fn try_into(self) -> Result { let entrypoint: CallEntryPoint = self.call_entrypoint.clone().try_into()?; - Ok(InvokeTransaction::V1(InvokeTransactionV1 { - transaction_hash: TransactionHash(StarkFelt::new(self.hash.into())?), - max_fee: Fee(self.max_fee.try_into().unwrap()), - signature: TransactionSignature( - self.signature.clone().into_inner().iter().map(|x| StarkFelt::new((*x).into()).unwrap()).collect(), - ), - nonce: Nonce(StarkFelt::new(self.nonce.into())?), - sender_address: StarknetContractAddress::try_from(StarkFelt::new(self.sender_address.into())?)?, - calldata: entrypoint.calldata, - })) + Ok(InvokeTransaction { + tx: starknet_api::transaction::InvokeTransaction::V1(InvokeTransactionV1 { + max_fee: Fee(self.max_fee.try_into().unwrap()), + signature: TransactionSignature( + self.signature.clone().into_inner().iter().map(|x| StarkFelt::new((*x).into()).unwrap()).collect(), + ), + nonce: felt_to_nonce(self.nonce)?, + sender_address: StarknetContractAddress::try_from(StarkFelt::new(self.sender_address.into())?)?, + calldata: entrypoint.calldata, + }), + tx_hash: TransactionHash(StarkFelt::new(self.hash.into())?), + }) } } @@ -265,31 +269,41 @@ impl TryInto for &Transaction { let signature = TransactionSignature( self.signature.clone().into_inner().iter().map(|x| StarkFelt::new((*x).into()).unwrap()).collect(), ); - let nonce = Nonce(StarkFelt::new(self.nonce.into())?); + let nonce = felt_to_nonce(self.nonce)?; let sender_address = StarknetContractAddress::try_from(StarkFelt::new(self.sender_address.into())?)?; let class_hash = entrypoint.class_hash.unwrap_or_default(); - if self.version <= 1_u8 { - let tx = DeclareTransactionV0V1 { transaction_hash, max_fee, signature, nonce, sender_address, class_hash }; - if self.version == 0_u8 { - return Ok(DeclareTransaction::V0(tx)); - } else { - return Ok(DeclareTransaction::V1(tx)); + let tx = match self.version { + 0_u8 | 1_u8 => { + let tx = DeclareTransactionV0V1 { max_fee, signature, nonce, sender_address, class_hash }; + if self.version == 0_u8 { + starknet_api::transaction::DeclareTransaction::V0(tx) + } else { + starknet_api::transaction::DeclareTransaction::V1(tx) + } } - } else if self.version == 2_u8 { - let tx = DeclareTransactionV2 { - transaction_hash, - max_fee, - signature, - nonce, - sender_address, - class_hash, - // FIXME: https://github.com/keep-starknet-strange/madara/issues/796 - compiled_class_hash: CompiledClassHash(entrypoint.class_hash.unwrap().0), - }; - return Ok(DeclareTransaction::V2(tx)); - } - unimplemented!("DeclareTransaction version {} is not supported", self.version) + 2_u8 => { + let tx = DeclareTransactionV2 { + max_fee, + signature, + nonce, + sender_address, + class_hash, + // FIXME: + compiled_class_hash: CompiledClassHash(entrypoint.class_hash.unwrap().0), + }; + starknet_api::transaction::DeclareTransaction::V2(tx) + } + _ => unimplemented!("DeclareTransaction version {} is not supported", self.version), + }; + + // FIXME: handle the error case and don't unwrap directly + Ok(DeclareTransaction::new( + tx, + transaction_hash, + self.contract_class.clone().ok_or("ContractClass is missing").unwrap(), + ) + .unwrap()) } } @@ -359,8 +373,8 @@ impl Transaction { let deploy_account_tx: DeployAccountTransaction = self.try_into().map_err(TransactionValidationErrorWrapper::CalldataError)?; let validate_calldata = vec![ - vec![deploy_account_tx.class_hash.0, deploy_account_tx.contract_address_salt.0], - (*deploy_account_tx.constructor_calldata.0).clone(), + vec![deploy_account_tx.class_hash().0, deploy_account_tx.contract_address_salt().0], + (*deploy_account_tx.constructor_calldata().0).clone(), ] .concat(); Ok(Calldata(validate_calldata.into())) @@ -414,7 +428,8 @@ impl Transaction { } }; - let mut initial_gas = super::constants::INITIAL_GAS.into(); + // FIXME 710 + let mut initial_gas = super::constants::INITIAL_GAS; self.validate_tx(state, execution_resources, block_context, &account_context, tx_type, &mut initial_gas) } @@ -436,12 +451,12 @@ impl Transaction { block_context: &BlockContext, account_tx_context: &AccountTransactionContext, tx_type: &TxType, - remaining_gas: &mut Felt252, + remaining_gas: &mut u64, ) -> TransactionValidationResultWrapper> { let mut context = EntryPointExecutionContext::new( block_context.clone(), account_tx_context.clone(), - block_context.validate_max_n_steps, + block_context.validate_max_n_steps as usize, ); if context.account_tx_context.is_v0() { return Ok(None); @@ -456,7 +471,7 @@ impl Transaction { storage_address: account_tx_context.sender_address, caller_address: StarknetContractAddress::default(), call_type: CallType::Call, - initial_gas: remaining_gas.clone(), + initial_gas: *remaining_gas, }; let validate_call_info = validate_call @@ -533,7 +548,6 @@ impl Transaction { block_context: &BlockContext, tx_type: TxType, disable_nonce_validation: bool, - contract_class: Option, ) -> TransactionExecutionResultWrapper { // Initialize the execution resources. let execution_resources = &mut ExecutionResources::default(); @@ -542,7 +556,7 @@ impl Transaction { self.verify_tx_version(&tx_type)?; // FIXME 710 - let mut initial_gas: Felt252 = super::constants::INITIAL_GAS.into(); + let mut initial_gas = super::constants::INITIAL_GAS; // Going one lower level gives us more flexibility like not validating the tx as we could do // it before the tx lands in the mempool. @@ -556,7 +570,7 @@ impl Transaction { let mut context = EntryPointExecutionContext::new( block_context.clone(), account_context.clone(), - block_context.invoke_tx_max_n_steps, + block_context.invoke_tx_max_n_steps as usize, ); // Update nonce @@ -585,14 +599,12 @@ impl Transaction { TxType::L1Handler => { let tx = self.try_into().map_err(TransactionExecutionErrorWrapper::StarknetApi)?; let account_context = self.get_l1_handler_transaction_context(&tx); - // FIXME 712 - let tx = StarknetL1HandlerTransaction { tx, paid_fee_on_l1: Fee::default() }; // Create the context. let mut context = EntryPointExecutionContext::new( block_context.clone(), account_context.clone(), - block_context.invoke_tx_max_n_steps, + block_context.invoke_tx_max_n_steps as usize, ); ( tx.run_execute(state, execution_resources, &mut context, &mut initial_gas) @@ -604,15 +616,12 @@ impl Transaction { TxType::Declare => { let tx = self.try_into().map_err(TransactionExecutionErrorWrapper::StarknetApi)?; let account_context = self.get_declare_transaction_context(&tx); - let contract_class = - contract_class.ok_or_else(|| StateError::UndeclaredClassHash(ClassHash::default()))?; - let tx = StarknetDeclareTransaction::new(tx, contract_class)?; // Create the context. let mut context = EntryPointExecutionContext::new( block_context.clone(), account_context.clone(), - block_context.invoke_tx_max_n_steps, + block_context.invoke_tx_max_n_steps as usize, ); // Update nonce @@ -646,7 +655,7 @@ impl Transaction { let mut context = EntryPointExecutionContext::new( block_context.clone(), account_context.clone(), - block_context.invoke_tx_max_n_steps, + block_context.invoke_tx_max_n_steps as usize, ); // Update nonce @@ -746,14 +755,14 @@ impl Transaction { /// # Returns /// /// * `AccountTransactionContext` - The context of the transaction - fn get_l1_handler_transaction_context(&self, tx: &L1HandlerTransaction) -> AccountTransactionContext { + fn get_l1_handler_transaction_context(&self, transaction: &L1HandlerTransaction) -> AccountTransactionContext { AccountTransactionContext { - transaction_hash: tx.transaction_hash, + transaction_hash: transaction.tx_hash, max_fee: Fee::default(), - version: calculate_transaction_version(self.is_query, tx.version), + version: calculate_transaction_version(self.is_query, transaction.tx.version), signature: TransactionSignature::default(), - nonce: tx.nonce, - sender_address: tx.contract_address, + nonce: transaction.tx.nonce, + sender_address: transaction.tx.contract_address, } } @@ -767,14 +776,18 @@ impl Transaction { /// # Returns /// /// * `AccountTransactionContext` - The context of the transaction - fn get_invoke_transaction_context(&self, tx: &InvokeTransaction) -> AccountTransactionContext { + fn get_invoke_transaction_context(&self, transaction: &InvokeTransaction) -> AccountTransactionContext { + let invoke_tx = match transaction.tx.clone() { + starknet_api::transaction::InvokeTransaction::V1(tx) => tx, + _ => unimplemented!("Unsupported invoke transaction version"), + }; AccountTransactionContext { - transaction_hash: tx.transaction_hash(), - max_fee: tx.max_fee(), + transaction_hash: transaction.tx_hash, + max_fee: invoke_tx.max_fee, version: calculate_transaction_version_from_u8(self.is_query, 1_u8), - signature: tx.signature(), - nonce: tx.nonce(), - sender_address: tx.sender_address(), + signature: invoke_tx.signature, + nonce: invoke_tx.nonce, + sender_address: invoke_tx.sender_address, } } @@ -788,14 +801,17 @@ impl Transaction { /// # Returns /// /// * `AccountTransactionContext` - The context of the transaction - fn get_deploy_account_transaction_context(&self, tx: &DeployAccountTransaction) -> AccountTransactionContext { + fn get_deploy_account_transaction_context( + &self, + transaction: &DeployAccountTransaction, + ) -> AccountTransactionContext { AccountTransactionContext { - transaction_hash: tx.transaction_hash, - max_fee: tx.max_fee, - version: calculate_transaction_version(self.is_query, tx.version), - signature: tx.signature.clone(), - nonce: tx.nonce, - sender_address: tx.contract_address, + transaction_hash: transaction.tx_hash, + max_fee: transaction.tx.max_fee, + version: calculate_transaction_version(self.is_query, transaction.tx.version), + signature: transaction.tx.signature.clone(), + nonce: transaction.tx.nonce, + sender_address: transaction.contract_address, } } @@ -809,14 +825,14 @@ impl Transaction { /// # Returns /// /// * `AccountTransactionContext` - The context of the transaction - fn get_declare_transaction_context(&self, tx: &DeclareTransaction) -> AccountTransactionContext { + fn get_declare_transaction_context(&self, transaction: &DeclareTransaction) -> AccountTransactionContext { AccountTransactionContext { - transaction_hash: tx.transaction_hash(), - max_fee: tx.max_fee(), - version: calculate_transaction_version(self.is_query, tx.version()), - signature: tx.signature(), - nonce: tx.nonce(), - sender_address: tx.sender_address(), + transaction_hash: transaction.tx_hash(), + max_fee: transaction.tx().max_fee(), + version: calculate_transaction_version(self.is_query, transaction.tx().version()), + signature: transaction.tx().signature(), + nonce: transaction.tx().nonce(), + sender_address: transaction.tx().sender_address(), } } } diff --git a/crates/primitives/starknet/src/transaction/utils.rs b/crates/primitives/starknet/src/transaction/utils.rs index 555814a1fd..9b63cd5faa 100644 --- a/crates/primitives/starknet/src/transaction/utils.rs +++ b/crates/primitives/starknet/src/transaction/utils.rs @@ -1,9 +1,12 @@ use alloc::vec::Vec; +use starknet_api::api_core::Nonce; use starknet_api::hash::StarkFelt; use starknet_api::transaction::TransactionVersion; +use starknet_api::StarknetApiError; use starknet_ff::FieldElement; +use crate::execution::felt252_wrapper::Felt252Wrapper; use crate::execution::types::{EntryPointTypeWrapper, EntryPointWrapper}; const QUERY_VERSION_OFFSET: FieldElement = @@ -26,6 +29,11 @@ pub fn calculate_transaction_version_from_u8(is_query: bool, version: u8) -> Tra calculate_transaction_version(is_query, TransactionVersion(StarkFelt::from(version))) } +/// converts [Felt252Wrapper] to [Nonce] +pub fn felt_to_nonce(nonce: Felt252Wrapper) -> Result { + Ok(Nonce(StarkFelt::new(nonce.into())?)) +} + #[cfg(feature = "std")] mod reexport_std_types { use std::collections::HashMap; diff --git a/crates/runtime/src/pallets.rs b/crates/runtime/src/pallets.rs index 9c329a2203..9d612b0b6a 100644 --- a/crates/runtime/src/pallets.rs +++ b/crates/runtime/src/pallets.rs @@ -50,6 +50,7 @@ impl pallet_starknet::Config for Runtime { type ValidateMaxNSteps = ValidateMaxNSteps; type ProtocolVersion = ProtocolVersion; type ChainId = ChainId; + type MaxRecursionDepth = MaxRecursionDepth; } /// -------------------------------------- @@ -162,6 +163,7 @@ parameter_types! { pub const ValidateMaxNSteps: u32 = 1_000_000; pub const ProtocolVersion: u8 = 0; pub const ChainId: Felt252Wrapper = SN_GOERLI_CHAIN_ID; + pub const MaxRecursionDepth: u32 = 50; } /// Implement the OnTimestampSet trait to override the default Aura. diff --git a/madara-infra b/madara-infra index f95ec194ac..22fd284b7f 160000 --- a/madara-infra +++ b/madara-infra @@ -1 +1 @@ -Subproject commit f95ec194acc51a8592798f4e6c781ee1c11580b0 +Subproject commit 22fd284b7fd45df9694dcaa3f5175c7bd10410b1