From 9e9028b16c37ee4719f040617cddf763908d2c9c Mon Sep 17 00:00:00 2001 From: enitrat Date: Fri, 20 Sep 2024 18:50:24 +0200 Subject: [PATCH] wip: cairo native --- Cargo.lock | 430 +++++- Cargo.toml | 6 +- blockchain-tests-skip.yml | 179 +-- crates/ef-testing/Cargo.toml | 1 + crates/ef-testing/program.sierra | 1226 +++++++++++++++++ .../ef-testing/src/evm_sequencer/constants.rs | 26 + .../src/evm_sequencer/sequencer/mod.rs | 27 +- crates/sequencer/Cargo.toml | 7 + crates/sequencer/src/lib.rs | 1 + crates/sequencer/src/native.rs | 194 +++ crates/sequencer/src/state.rs | 14 +- 11 files changed, 1913 insertions(+), 198 deletions(-) mode change 100644 => 120000 blockchain-tests-skip.yml create mode 100644 crates/ef-testing/program.sierra create mode 100644 crates/sequencer/src/native.rs diff --git a/Cargo.lock b/Cargo.lock index 2f360728..5070fa11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1013,12 +1013,15 @@ dependencies = [ "itertools 0.12.1", "lazy_static", "lazycell", + "log", + "prettyplease", "proc-macro2", "quote", "regex", "rustc-hash 1.1.0", "shlex", "syn 2.0.77", + "which", ] [[package]] @@ -1095,23 +1098,26 @@ dependencies = [ [[package]] name = "blockifier" version = "0.0.0" -source = "git+https://github.com/kkrt-labs/sequencer.git?rev=d1f32e2#d1f32e241e4a9a404d8b2c292921685f39ee0211" dependencies = [ "anyhow", "ark-ec", "ark-ff 0.4.2", "ark-secp256k1", "ark-secp256r1", - "cached", + "cached 0.44.0", "cairo-lang-casm", "cairo-lang-runner", + "cairo-lang-sierra", "cairo-lang-starknet-classes", "cairo-lang-utils", + "cairo-native", "cairo-vm", "derive_more 0.99.18", + "educe", "indexmap 2.5.0", - "itertools 0.12.1", + "itertools 0.10.5", "keccak", + "lazy_static", "log", "num-bigint", "num-integer", @@ -1258,7 +1264,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b195e4fbc4b6862bbd065b991a34750399c119797efff72492f28a5864de8700" dependencies = [ "async-trait", - "cached_proc_macro", + "cached_proc_macro 0.17.0", "cached_proc_macro_types", "futures", "hashbrown 0.13.2", @@ -1268,6 +1274,21 @@ dependencies = [ "tokio", ] +[[package]] +name = "cached" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4d73155ae6b28cf5de4cfc29aeb02b8a1c6dab883cb015d15cd514e42766846" +dependencies = [ + "ahash", + "cached_proc_macro 0.23.0", + "cached_proc_macro_types", + "hashbrown 0.14.5", + "once_cell", + "thiserror", + "web-time", +] + [[package]] name = "cached_proc_macro" version = "0.17.0" @@ -1281,6 +1302,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "cached_proc_macro" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f42a145ed2d10dce2191e1dcf30cfccfea9026660e143662ba5eec4017d5daa" +dependencies = [ + "darling 0.20.10", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "cached_proc_macro_types" version = "0.1.1" @@ -1749,6 +1782,33 @@ dependencies = [ "xshell", ] +[[package]] +name = "cairo-lang-test-plugin" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74f1597b8229a3649183ff33b19f0aeca5d86505253ebbbce377b271d1732835" +dependencies = [ + "anyhow", + "cairo-lang-compiler", + "cairo-lang-debug", + "cairo-lang-defs", + "cairo-lang-filesystem", + "cairo-lang-lowering", + "cairo-lang-semantic", + "cairo-lang-sierra", + "cairo-lang-sierra-generator", + "cairo-lang-starknet", + "cairo-lang-starknet-classes", + "cairo-lang-syntax", + "cairo-lang-utils", + "indoc", + "itertools 0.12.1", + "num-bigint", + "num-traits 0.2.19", + "serde", + "starknet-types-core", +] + [[package]] name = "cairo-lang-test-utils" version = "2.8.2" @@ -1778,6 +1838,69 @@ dependencies = [ "serde", ] +[[package]] +name = "cairo-native" +version = "0.2.0" +dependencies = [ + "anyhow", + "aquamarine", + "bumpalo", + "cairo-lang-compiler", + "cairo-lang-defs", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-runner", + "cairo-lang-semantic", + "cairo-lang-sierra", + "cairo-lang-sierra-ap-change", + "cairo-lang-sierra-gas", + "cairo-lang-sierra-generator", + "cairo-lang-starknet", + "cairo-lang-starknet-classes", + "cairo-lang-test-plugin", + "cairo-lang-utils", + "cairo-native-runtime", + "cc", + "clap", + "colored", + "educe", + "itertools 0.13.0", + "k256", + "keccak", + "lazy_static", + "libc", + "libloading", + "llvm-sys", + "melior", + "mlir-sys", + "num-bigint", + "num-traits 0.2.19", + "p256", + "sec1", + "serde", + "serde_json", + "sha2 0.10.8", + "starknet-types-core", + "stats_alloc", + "tempfile", + "thiserror", + "tracing", + "tracing-subscriber", + "utf8_iter", +] + +[[package]] +name = "cairo-native-runtime" +version = "0.2.0" +dependencies = [ + "cairo-lang-sierra-gas", + "lazy_static", + "libc", + "rand", + "starknet-curve 0.5.1", + "starknet-types-core", +] + [[package]] name = "cairo-vm" version = "1.0.1" @@ -1785,7 +1908,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58363ad8065ed891e3b14a8191b707677c7c7cb5b9d10030822506786d8d8108" dependencies = [ "anyhow", - "arbitrary", "bincode 2.0.0-rc.3", "bitvec", "generic-array", @@ -1848,6 +1970,16 @@ dependencies = [ "thiserror", ] +[[package]] +name = "caseless" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808dab3318747be122cb31d36de18d4d1c81277a76f8332a02b81a3d73463d7f" +dependencies = [ + "regex", + "unicode-normalization", +] + [[package]] name = "cc" version = "1.1.21" @@ -1982,6 +2114,23 @@ dependencies = [ "memchr", ] +[[package]] +name = "comrak" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d061c6d53fe98c25efda0d91b7f6b4b4020a51dad78a3eac5028710aa26f8e7" +dependencies = [ + "caseless", + "derive_builder", + "entities", + "memchr", + "once_cell", + "regex", + "slug", + "typed-arena", + "unicode_categories", +] + [[package]] name = "concat-kdf" version = "0.1.0" @@ -2374,6 +2523,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", + "pem-rfc7468", "zeroize", ] @@ -2409,6 +2559,37 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "derive_builder" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd33f37ee6a119146a1781d3356a7c26028f83d779b2e04ecd45fdc75c76877b" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7431fa049613920234f22c47fdc33e6cf3ee83067091ea4277a3f8c4587aae38" +dependencies = [ + "darling 0.20.10", + "proc-macro2", + "quote", + "syn 2.0.77", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc" +dependencies = [ + "derive_builder_core", + "syn 2.0.77", +] + [[package]] name = "derive_more" version = "0.99.18" @@ -2444,6 +2625,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "deunicode" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00" + [[package]] name = "diff" version = "0.1.13" @@ -2623,6 +2810,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "educe" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4bd92664bf78c4d3dba9b7cdafce6fa15b13ed3ed16175218196942e99168a8" +dependencies = [ + "enum-ordinalize", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "ef-testing" version = "0.1.0" @@ -2708,6 +2907,7 @@ dependencies = [ "ff", "generic-array", "group", + "pem-rfc7468", "pkcs8", "rand_core", "sec1", @@ -2753,6 +2953,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "entities" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca" + [[package]] name = "enum-as-inner" version = "0.6.1" @@ -2765,6 +2971,26 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "enum-ordinalize" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea0dcfa4e54eeb516fe454635a95753ddd39acda650ce703031c6973e315dd5" +dependencies = [ + "enum-ordinalize-derive", +] + +[[package]] +name = "enum-ordinalize-derive" +version = "4.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "enumn" version = "0.1.14" @@ -3373,6 +3599,15 @@ dependencies = [ "hmac 0.8.1", ] +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "hostname" version = "0.3.1" @@ -4362,6 +4597,20 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "llvm-sys" +version = "181.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320f9d2723c97d4b78f9190a61ed25cc7cfbe456668c08e6e7dd8e50ceb8500" +dependencies = [ + "anyhow", + "cc", + "lazy_static", + "libc", + "regex-lite", + "semver 1.0.23", +] + [[package]] name = "lock_api" version = "0.4.12" @@ -4448,6 +4697,35 @@ dependencies = [ "rawpointer", ] +[[package]] +name = "melior" +version = "0.18.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3085c0169aa3b735d8e7df582baee23c2aeb280ea62cc7f71effda28d8e281" +dependencies = [ + "dashmap", + "melior-macro", + "mlir-sys", + "once_cell", +] + +[[package]] +name = "melior-macro" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d58c356ebaa7855da67aad1306a0d032b68919d3c65b0b5dcecf10d9bdf6a9" +dependencies = [ + "comrak", + "convert_case 0.6.0", + "once_cell", + "proc-macro2", + "quote", + "regex", + "syn 2.0.77", + "tblgen-alt", + "unindent", +] + [[package]] name = "memchr" version = "2.7.4" @@ -4528,6 +4806,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "mlir-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1b5806a63bc959cd5c4e5db8cadd20e40045d41969d325132748db8af11b7f" +dependencies = [ + "bindgen", +] + [[package]] name = "modular-bitfield" version = "0.11.2" @@ -5025,6 +5312,18 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2 0.10.8", +] + [[package]] name = "page_size" version = "0.6.0" @@ -5038,10 +5337,9 @@ dependencies = [ [[package]] name = "papyrus_config" version = "0.0.0" -source = "git+https://github.com/kkrt-labs/sequencer.git?rev=d1f32e2#d1f32e241e4a9a404d8b2c292921685f39ee0211" dependencies = [ "clap", - "itertools 0.12.1", + "itertools 0.10.5", "serde", "serde_json", "strum_macros 0.25.3", @@ -5179,6 +5477,15 @@ dependencies = [ "serde", ] +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -5369,6 +5676,25 @@ dependencies = [ "yansi", ] +[[package]] +name = "prettyplease" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" +dependencies = [ + "proc-macro2", + "syn 2.0.77", +] + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + [[package]] name = "primitive-types" version = "0.12.2" @@ -5643,6 +5969,12 @@ dependencies = [ "regex-syntax 0.8.4", ] +[[package]] +name = "regex-lite" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" + [[package]] name = "regex-syntax" version = "0.6.29" @@ -7865,9 +8197,15 @@ name = "sequencer" version = "0.1.0" dependencies = [ "blockifier", + "cached 0.53.1", + "cairo-lang-sierra", + "cairo-lang-starknet-classes", + "cairo-native", "eyre", "hashbrown 0.14.5", "lazy_static", + "libloading", + "once_cell", "serde", "serde_json", "starknet", @@ -8166,6 +8504,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slug" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "882a80f72ee45de3cc9a5afeb2da0331d58df69e4e7d8eeb5d3c7784ae67e724" +dependencies = [ + "deunicode", + "wasm-bindgen", +] + [[package]] name = "smallvec" version = "1.13.2" @@ -8480,7 +8828,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce6bacf0ba19bc721e518bc4bf389ff13daa8a7c5db5fd320600473b8aa9fcbd" dependencies = [ - "arbitrary", "lambdaworks-crypto", "lambdaworks-math", "lazy_static", @@ -8493,14 +8840,13 @@ dependencies = [ [[package]] name = "starknet_api" version = "0.0.0" -source = "git+https://github.com/kkrt-labs/sequencer.git?rev=d1f32e2#d1f32e241e4a9a404d8b2c292921685f39ee0211" dependencies = [ "bitvec", "cairo-lang-starknet-classes", "derive_more 0.99.18", "hex", "indexmap 2.5.0", - "itertools 0.12.1", + "itertools 0.10.5", "primitive-types", "serde", "serde_json", @@ -8518,6 +8864,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "stats_alloc" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c0e04424e733e69714ca1bbb9204c1a57f09f5493439520f9f68c132ad25eec" + [[package]] name = "string_cache" version = "0.8.7" @@ -8714,6 +9066,18 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "tblgen-alt" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ae726d43658a13a9cd479de814be1311fea69236cd821e931a4fb9ca4d70e50" +dependencies = [ + "bindgen", + "cc", + "paste", + "thiserror", +] + [[package]] name = "tempfile" version = "3.12.0" @@ -9195,6 +9559,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + [[package]] name = "typenum" version = "1.17.0" @@ -9267,6 +9637,18 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + +[[package]] +name = "unindent" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" + [[package]] name = "universal-hash" version = "0.5.1" @@ -9306,6 +9688,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -9504,6 +9892,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki-roots" version = "0.25.4" @@ -9519,6 +9917,18 @@ dependencies = [ "rustls-pki-types", ] +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "widestring" version = "1.1.0" diff --git a/Cargo.toml b/Cargo.toml index 90028df5..ec74d66e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,13 +41,15 @@ cairo-lang-casm = "2.8.0" cairo-lang-starknet = "2.8.0" cairo-lang-utils = "2.8.0" cairo-lang-starknet-classes = "2.8.0" +cairo-lang-sierra = "2.8.0" +cairo-native = {path = "/Users/msaug/deps/cairo_native"} cairo-vm = "1.0.1" -blockifier = { package = "blockifier", git = "https://github.com/kkrt-labs/sequencer.git", rev = "d1f32e2", default-features = false, features = [ +blockifier = { package = "blockifier", path = "../../deps/sequencer/crates/blockifier", default-features = false, features = [ "testing", ] } starknet = "0.11.0" starknet-crypto = "0.7.1" -starknet_api = { package = "starknet_api", git = "https://github.com/kkrt-labs/sequencer.git", rev = "d1f32e2" } +starknet_api = { package = "starknet_api", path = "../../deps/sequencer/crates/starknet_api" } # Other async-trait = "0.1" diff --git a/blockchain-tests-skip.yml b/blockchain-tests-skip.yml deleted file mode 100644 index 4cedddf6..00000000 --- a/blockchain-tests-skip.yml +++ /dev/null @@ -1,178 +0,0 @@ -# List of test names and test names regex to be skipped. -# The first level corresponds to the directory, the second to the list of file names regex to ignore. -# In the ef-tests repo, we skip all tests but the vmArithmeticTest. - -directories: - - Pyspecs - - Cancun - -filename: - None: - - None - -testname: - vmArithmeticTest: - - addmod_d10g0v0_Cancun - - addmod_d11g0v0_Cancun - - addmod_d8g0v0_Cancun - - addmod_d9g0v0_Cancun - - divByZero_d63g0v0_Cancun - - divByZero_d64g0v0_Cancun - - divByZero_d65g0v0_Cancun - - divByZero_d66g0v0_Cancun - - divByZero_d67g0v0_Cancun - - divByZero_d68g0v0_Cancun - - divByZero_d69g0v0_Cancun - - divByZero_d70g0v0_Cancun - - divByZero_d71g0v0_Cancun - - divByZero_d72g0v0_Cancun - - divByZero_d73g0v0_Cancun - - divByZero_d74g0v0_Cancun - - divByZero_d75g0v0_Cancun - - divByZero_d76g0v0_Cancun - - divByZero_d77g0v0_Cancun - - divByZero_d78g0v0_Cancun - - divByZero_d79g0v0_Cancun - - divByZero_d80g0v0_Cancun - - divByZero_d81g0v0_Cancun - - divByZero_d82g0v0_Cancun - - divByZero_d83g0v0_Cancun - - divByZero_d84g0v0_Cancun - - divByZero_d85g0v0_Cancun - - divByZero_d86g0v0_Cancun - - divByZero_d87g0v0_Cancun - - divByZero_d88g0v0_Cancun - - divByZero_d89g0v0_Cancun - - divByZero_d90g0v0_Cancun - - divByZero_d91g0v0_Cancun - - divByZero_d92g0v0_Cancun - - divByZero_d93g0v0_Cancun - - divByZero_d94g0v0_Cancun - - divByZero_d95g0v0_Cancun - - divByZero_d96g0v0_Cancun - - divByZero_d97g0v0_Cancun - - expPower256Of256_d0g0v0_Cancun - - exp_d1g0v0_Cancun - - exp_d3g0v0_Cancun - - exp_d8g0v0_Cancun - - exp_d9g0v0_Cancun - - expPower256_d0g0v0_Cancun - - mulmod_d12g0v0_Cancun - - mulmod_d13g0v0_Cancun - - mulmod_d14g0v0_Cancun - - mulmod_d15g0v0_Cancun - - twoOps_d0g0v0_Cancun - -regex: - stArgsZeroOneBalance: - - .* - stAttackTest: - - .* - stBadOpcode: - - .* - stBugs: - - .* - stCallCodes: - - .* - stCallCreateCallCodeTest: - - .* - stCallDelegateCodesCallCodeHomestead: - - .* - stCallDelegateCodesHomestead: - - .* - stChainId: - - .* - stCodeSizeLimit: - - .* - stCreateTest: - - .* - stCreate2: - - .* - stDelegatecallTestHomestead: - - .* - stEIP150Specific: - - .* - stEIP150singleCodeGasPrices: - - .* - stEIP1559: - - .* - stEIP158Specific: - - .* - stEIP2930: - - .* - stExample: - - .* - stExtCodeHash: - - .* - stInitCodeTest: - - .* - stLogTests: - - .* - stMemExpandingEIP150Calls: - - .* - stMemoryStressTest: - - .* - stMemoryTest: - - .* - stNonZeroCallsTest: - - .* - stPreCompiledContracts: - - .* - stPreCompiledContracts2: - - .* - stQuadraticComplexityTest: - - .* - stRandom: - - .* - stRandom2: - - .* - stRecursiveCreate: - - .* - stRefundTest: - - .* - stReturnDataTest: - - .* - stRevertTest: - - .* - stSLoadTest: - - .* - stSStoreTest: - - .* - stSelfBalance: - - .* - stShift: - - .* - stSolidityTest: - - .* - stSpecialTest: - - .* - stStackTests: - - .* - stStaticCall: - - .* - stStaticFlagEnabled: - - .* - stSystemOperationsTest: - - .* - stTimeConsuming: - - .* - stTransactionTest: - - .* - stTransitionTest: - - .* - stWalletTest: - - .* - stZeroCallsRevert: - - .* - stZeroKnowledge: - - .* - stZeroKnowledge2: - - .* - vmIOandFlowOperations: - - .* - vmLogTest: - - .* - vmPerformance: - - .* - vmTests: - - .* diff --git a/blockchain-tests-skip.yml b/blockchain-tests-skip.yml new file mode 120000 index 00000000..7428ce91 --- /dev/null +++ b/blockchain-tests-skip.yml @@ -0,0 +1 @@ +../kakarot-ssj/blockchain-tests-skip.yml \ No newline at end of file diff --git a/crates/ef-testing/Cargo.toml b/crates/ef-testing/Cargo.toml index d992bd00..6b33f421 100644 --- a/crates/ef-testing/Cargo.toml +++ b/crates/ef-testing/Cargo.toml @@ -59,6 +59,7 @@ zip = { workspace = true, optional = true } [features] v0 = [] v1 = [] +native = [] ci = [] [build-dependencies] diff --git a/crates/ef-testing/program.sierra b/crates/ef-testing/program.sierra new file mode 100644 index 00000000..9adaee04 --- /dev/null +++ b/crates/ef-testing/program.sierra @@ -0,0 +1,1226 @@ +type RangeCheck = RangeCheck [storable: true, drop: false, dup: false, zero_sized: false]; +type Const = Const [storable: false, drop: false, dup: false, zero_sized: false]; +type Const = Const [storable: false, drop: false, dup: false, zero_sized: false]; +type Const = Const [storable: false, drop: false, dup: false, zero_sized: false]; +type Const = Const [storable: false, drop: false, dup: false, zero_sized: false]; +type ClassHash = ClassHash [storable: true, drop: true, dup: true, zero_sized: false]; +type Const = Const [storable: false, drop: false, dup: false, zero_sized: false]; +type Const = Const [storable: false, drop: false, dup: false, zero_sized: false]; +type ContractAddress = ContractAddress [storable: true, drop: true, dup: true, zero_sized: false]; +type contracts::components::ownable::ownable_component::OwnershipTransferred = Struct [storable: true, drop: true, dup: true, zero_sized: false]; +type contracts::components::ownable::ownable_component::Event = Enum [storable: true, drop: true, dup: true, zero_sized: false]; +type contracts::uninitialized_account::UninitializedAccount::Event = Enum [storable: true, drop: true, dup: true, zero_sized: false]; +type StorageBaseAddress = StorageBaseAddress [storable: true, drop: true, dup: true, zero_sized: false]; +type core::starknet::storage::StoragePointer0Offset::> = Struct [storable: true, drop: true, dup: true, zero_sized: false]; +type Const = Const [storable: false, drop: false, dup: false, zero_sized: false]; +type Const = Const [storable: false, drop: false, dup: false, zero_sized: false]; +type Box = Box [storable: true, drop: true, dup: true, zero_sized: false]; +type Box = Box [storable: true, drop: true, dup: true, zero_sized: false]; +type felt252 = felt252 [storable: true, drop: true, dup: true, zero_sized: false]; +type u128 = u128 [storable: true, drop: true, dup: true, zero_sized: false]; +type Array = Array [storable: true, drop: true, dup: false, zero_sized: false]; +type Snapshot> = Snapshot> [storable: true, drop: true, dup: true, zero_sized: false]; +type core::array::Span:: = Struct>> [storable: true, drop: true, dup: true, zero_sized: false]; +type Array = Array [storable: true, drop: true, dup: false, zero_sized: false]; +type Snapshot> = Snapshot> [storable: true, drop: true, dup: true, zero_sized: false]; +type core::array::Span:: = Struct>> [storable: true, drop: true, dup: true, zero_sized: false]; +type u32 = u32 [storable: true, drop: true, dup: true, zero_sized: false]; +type core::starknet::info::v2::TxInfo = Struct, felt252, felt252, felt252, core::array::Span::, u128, core::array::Span::, u32, u32, core::array::Span::> [storable: true, drop: true, dup: true, zero_sized: false]; +type u64 = u64 [storable: true, drop: true, dup: true, zero_sized: false]; +type core::starknet::info::BlockInfo = Struct [storable: true, drop: true, dup: true, zero_sized: false]; +type core::starknet::info::v2::ResourceBounds = Struct [storable: true, drop: true, dup: true, zero_sized: false]; +type core::starknet::info::v2::ExecutionInfo = Struct, Box, ContractAddress, ContractAddress, felt252> [storable: true, drop: true, dup: true, zero_sized: false]; +type Box = Box [storable: true, drop: true, dup: true, zero_sized: false]; +type contracts::components::ownable::ownable_component::ComponentState:: = Struct [storable: true, drop: true, dup: true, zero_sized: true]; +type contracts::uninitialized_account::UninitializedAccount::ContractState = Struct> [storable: true, drop: true, dup: true, zero_sized: true]; +type Unit = Struct [storable: true, drop: true, dup: true, zero_sized: true]; +type Tuple = Struct [storable: true, drop: true, dup: true, zero_sized: true]; +type core::panics::Panic = Struct [storable: true, drop: true, dup: true, zero_sized: true]; +type Tuple> = Struct> [storable: true, drop: true, dup: false, zero_sized: false]; +type core::panics::PanicResult::<(contracts::uninitialized_account::UninitializedAccount::ContractState, ())> = Enum, Tuple>> [storable: true, drop: true, dup: false, zero_sized: false]; +type core::option::Option::> = Enum, Unit> [storable: true, drop: true, dup: false, zero_sized: false]; +type Tuple, core::option::Option::>> = Struct, core::option::Option::>> [storable: true, drop: true, dup: false, zero_sized: false]; +type core::panics::PanicResult::<(core::array::Span::, core::option::Option::>)> = Enum, core::option::Option::>>, Tuple>> [storable: true, drop: true, dup: false, zero_sized: false]; +type Box = Box [storable: true, drop: true, dup: true, zero_sized: false]; +type core::option::Option::> = Enum, Unit> [storable: true, drop: true, dup: true, zero_sized: false]; +type Const = Const [storable: false, drop: false, dup: false, zero_sized: false]; +type Tuple, Unit> = Struct, Unit> [storable: true, drop: true, dup: true, zero_sized: true]; +type core::panics::PanicResult::<(contracts::components::ownable::ownable_component::ComponentState::, ())> = Enum, Unit>, Tuple>> [storable: true, drop: true, dup: false, zero_sized: false]; +type Tuple = Struct [storable: true, drop: true, dup: true, zero_sized: true]; +type core::panics::PanicResult::<((),)> = Enum, Tuple>> [storable: true, drop: true, dup: false, zero_sized: false]; +type Const = Const [storable: false, drop: false, dup: false, zero_sized: false]; +type NonZero = NonZero [storable: true, drop: true, dup: true, zero_sized: false]; +type core::option::Option:: = Enum [storable: true, drop: true, dup: true, zero_sized: false]; +type Const = Const [storable: false, drop: false, dup: false, zero_sized: false]; +type Const = Const [storable: false, drop: false, dup: false, zero_sized: false]; +type Tuple> = Struct> [storable: true, drop: true, dup: true, zero_sized: false]; +type Const = Const [storable: false, drop: false, dup: false, zero_sized: false]; +type StorageAddress = StorageAddress [storable: true, drop: true, dup: true, zero_sized: false]; +type core::starknet::storage::StoragePointer0Offset:: = Struct [storable: true, drop: true, dup: true, zero_sized: false]; +type BuiltinCosts = BuiltinCosts [storable: true, drop: true, dup: true, zero_sized: false]; +type System = System [storable: true, drop: false, dup: false, zero_sized: false]; +type core::panics::PanicResult::<(core::array::Span::,)> = Enum>, Tuple>> [storable: true, drop: true, dup: false, zero_sized: false]; +type Const = Const [storable: false, drop: false, dup: false, zero_sized: false]; +type GasBuiltin = GasBuiltin [storable: true, drop: false, dup: false, zero_sized: false]; + +libfunc revoke_ap_tracking = revoke_ap_tracking; +libfunc withdraw_gas = withdraw_gas; +libfunc branch_align = branch_align; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc store_temp = store_temp; +libfunc array_snapshot_pop_front = array_snapshot_pop_front; +libfunc drop>> = drop>>; +libfunc drop> = drop>; +libfunc array_new = array_new; +libfunc const_as_immediate> = const_as_immediate>; +libfunc store_temp = store_temp; +libfunc array_append = array_append; +libfunc struct_construct = struct_construct; +libfunc struct_construct>> = struct_construct>>; +libfunc enum_init,)>, 1> = enum_init,)>, 1>; +libfunc store_temp = store_temp; +libfunc store_temp = store_temp; +libfunc store_temp,)>> = store_temp,)>>; +libfunc get_builtin_costs = get_builtin_costs; +libfunc store_temp = store_temp; +libfunc withdraw_gas_all = withdraw_gas_all; +libfunc storage_base_address_const<1239149872729906871793169171313897310809028090219849129902089947133222824240> = storage_base_address_const<1239149872729906871793169171313897310809028090219849129902089947133222824240>; +libfunc struct_construct> = struct_construct>; +libfunc snapshot_take> = snapshot_take>; +libfunc drop> = drop>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc rename = rename; +libfunc storage_address_from_base = storage_address_from_base; +libfunc const_as_immediate> = const_as_immediate>; +libfunc store_temp = store_temp; +libfunc store_temp = store_temp; +libfunc storage_read_syscall = storage_read_syscall; +libfunc contract_address_try_from_felt252 = contract_address_try_from_felt252; +libfunc contract_address_to_felt252 = contract_address_to_felt252; +libfunc snapshot_take> = snapshot_take>; +libfunc drop> = drop>; +libfunc struct_construct> = struct_construct>; +libfunc struct_construct>> = struct_construct>>; +libfunc enum_init,)>, 0> = enum_init,)>, 0>; +libfunc const_as_immediate> = const_as_immediate>; +libfunc store_temp> = store_temp>; +libfunc jump = jump; +libfunc const_as_immediate> = const_as_immediate>; +libfunc drop> = drop>; +libfunc enable_ap_tracking = enable_ap_tracking; +libfunc unbox = unbox; +libfunc rename = rename; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp>> = store_temp>>; +libfunc store_temp> = store_temp>; +libfunc struct_construct = struct_construct; +libfunc enum_init, 1> = enum_init, 1>; +libfunc enum_match> = enum_match>; +libfunc disable_ap_tracking = disable_ap_tracking; +libfunc drop = drop; +libfunc dup = dup; +libfunc felt252_is_zero = felt252_is_zero; +libfunc const_as_immediate> = const_as_immediate>; +libfunc drop> = drop>; +libfunc struct_construct> = struct_construct>; +libfunc snapshot_take> = snapshot_take>; +libfunc function_call::assert_only_owner> = function_call::assert_only_owner>; +libfunc enum_match> = enum_match>; +libfunc drop> = drop>; +libfunc store_temp = store_temp; +libfunc function_call::_transfer_ownership> = function_call::_transfer_ownership>; +libfunc enum_match, ())>> = enum_match, ())>>; +libfunc drop, Unit>> = drop, Unit>>; +libfunc struct_deconstruct>> = struct_deconstruct>>; +libfunc drop = drop; +libfunc drop> = drop>; +libfunc drop = drop; +libfunc const_as_immediate> = const_as_immediate>; +libfunc contract_address_const<0> = contract_address_const<0>; +libfunc store_temp>> = store_temp>>; +libfunc enum_init>, 0> = enum_init>, 0>; +libfunc store_temp>> = store_temp>>; +libfunc enum_init>, 1> = enum_init>, 1>; +libfunc enum_match>> = enum_match>>; +libfunc store_temp> = store_temp>; +libfunc function_call> = function_call>; +libfunc enum_match, core::option::Option::>)>> = enum_match, core::option::Option::>)>>; +libfunc struct_deconstruct, core::option::Option::>>> = struct_deconstruct, core::option::Option::>>>; +libfunc store_temp>> = store_temp>>; +libfunc enum_init>, 1> = enum_init>, 1>; +libfunc enum_match>> = enum_match>>; +libfunc struct_construct = struct_construct; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc drop> = drop>; +libfunc get_execution_info_v2_syscall = get_execution_info_v2_syscall; +libfunc store_temp> = store_temp>; +libfunc unbox = unbox; +libfunc struct_deconstruct = struct_deconstruct; +libfunc drop> = drop>; +libfunc drop> = drop>; +libfunc drop = drop; +libfunc const_as_immediate> = const_as_immediate>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc store_temp> = store_temp>; +libfunc felt252_sub = felt252_sub; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc const_as_immediate> = const_as_immediate>; +libfunc struct_construct>> = struct_construct>>; +libfunc snapshot_take>> = snapshot_take>>; +libfunc drop>> = drop>>; +libfunc struct_deconstruct>> = struct_deconstruct>>; +libfunc storage_write_syscall = storage_write_syscall; +libfunc struct_construct = struct_construct; +libfunc enum_init = enum_init; +libfunc enum_init = enum_init; +libfunc store_temp = store_temp; +libfunc function_call>> = function_call>>; +libfunc struct_construct, Unit>> = struct_construct, Unit>>; +libfunc enum_init, ())>, 0> = enum_init, ())>, 0>; +libfunc store_temp, ())>> = store_temp, ())>>; +libfunc enum_init, ())>, 1> = enum_init, ())>, 1>; +libfunc dup = dup; +libfunc enum_init>, 0> = enum_init>, 0>; +libfunc struct_construct, core::option::Option::>>> = struct_construct, core::option::Option::>>>; +libfunc enum_init, core::option::Option::>)>, 0> = enum_init, core::option::Option::>)>, 0>; +libfunc store_temp, core::option::Option::>)>> = store_temp, core::option::Option::>)>>; +libfunc const_as_immediate> = const_as_immediate>; +libfunc enum_init, core::option::Option::>)>, 1> = enum_init, core::option::Option::>)>, 1>; +libfunc struct_deconstruct = struct_deconstruct; +libfunc const_as_immediate> = const_as_immediate>; +libfunc call_contract_syscall = call_contract_syscall; +libfunc class_hash_try_from_felt252 = class_hash_try_from_felt252; +libfunc dup = dup; +libfunc class_hash_to_felt252 = class_hash_to_felt252; +libfunc const_as_immediate> = const_as_immediate>; +libfunc library_call_syscall = library_call_syscall; +libfunc replace_class_syscall = replace_class_syscall; +libfunc struct_deconstruct, Unit>> = struct_deconstruct, Unit>>; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc drop = drop; +libfunc const_as_immediate> = const_as_immediate>; +libfunc drop = drop; +libfunc snapshot_take = snapshot_take; +libfunc drop = drop; +libfunc enum_match = enum_match; +libfunc const_as_immediate> = const_as_immediate>; +libfunc enum_match = enum_match; +libfunc const_as_immediate> = const_as_immediate>; +libfunc dup = dup; +libfunc struct_deconstruct = struct_deconstruct; +libfunc rename = rename; +libfunc emit_event_syscall = emit_event_syscall; + +revoke_ap_tracking() -> (); // 0 +withdraw_gas([0], [1]) { fallthrough([4], [5]) 94([6], [7]) }; // 1 +branch_align() -> (); // 2 +struct_deconstruct>([3]) -> ([8]); // 3 +store_temp([4]) -> ([4]); // 4 +array_snapshot_pop_front([8]) { fallthrough([9], [10]) 21([11]) }; // 5 +branch_align() -> (); // 6 +drop>>([9]) -> (); // 7 +drop>([10]) -> (); // 8 +array_new() -> ([12]); // 9 +const_as_immediate>() -> ([13]); // 10 +store_temp([13]) -> ([13]); // 11 +array_append([12], [13]) -> ([14]); // 12 +struct_construct() -> ([15]); // 13 +struct_construct>>([15], [14]) -> ([16]); // 14 +enum_init,)>, 1>([16]) -> ([17]); // 15 +store_temp([4]) -> ([4]); // 16 +store_temp([5]) -> ([5]); // 17 +store_temp([2]) -> ([2]); // 18 +store_temp,)>>([17]) -> ([17]); // 19 +return([4], [5], [2], [17]); // 20 +branch_align() -> (); // 21 +drop>>([11]) -> (); // 22 +get_builtin_costs() -> ([18]); // 23 +store_temp([18]) -> ([18]); // 24 +withdraw_gas_all([4], [5], [18]) { fallthrough([19], [20]) 81([21], [22]) }; // 25 +branch_align() -> (); // 26 +storage_base_address_const<1239149872729906871793169171313897310809028090219849129902089947133222824240>() -> ([23]); // 27 +struct_construct>([23]) -> ([24]); // 28 +snapshot_take>([24]) -> ([25], [26]); // 29 +drop>([25]) -> (); // 30 +struct_deconstruct>([26]) -> ([27]); // 31 +rename([27]) -> ([28]); // 32 +storage_address_from_base([28]) -> ([29]); // 33 +const_as_immediate>() -> ([30]); // 34 +store_temp([30]) -> ([30]); // 35 +store_temp([29]) -> ([29]); // 36 +store_temp([19]) -> ([19]); // 37 +storage_read_syscall([20], [2], [30], [29]) { fallthrough([31], [32], [33]) 68([34], [35], [36]) }; // 38 +branch_align() -> (); // 39 +store_temp([33]) -> ([33]); // 40 +store_temp([31]) -> ([31]); // 41 +store_temp([32]) -> ([32]); // 42 +contract_address_try_from_felt252([19], [33]) { fallthrough([37], [38]) 58([39]) }; // 43 +branch_align() -> (); // 44 +array_new() -> ([40]); // 45 +contract_address_to_felt252([38]) -> ([41]); // 46 +array_append([40], [41]) -> ([42]); // 47 +snapshot_take>([42]) -> ([43], [44]); // 48 +drop>([43]) -> (); // 49 +struct_construct>([44]) -> ([45]); // 50 +struct_construct>>([45]) -> ([46]); // 51 +enum_init,)>, 0>([46]) -> ([47]); // 52 +store_temp([37]) -> ([37]); // 53 +store_temp([31]) -> ([31]); // 54 +store_temp([32]) -> ([32]); // 55 +store_temp,)>>([47]) -> ([47]); // 56 +return([37], [31], [32], [47]); // 57 +branch_align() -> (); // 58 +array_new() -> ([48]); // 59 +const_as_immediate>() -> ([49]); // 60 +store_temp([49]) -> ([49]); // 61 +array_append([48], [49]) -> ([50]); // 62 +store_temp([39]) -> ([51]); // 63 +store_temp([31]) -> ([52]); // 64 +store_temp([32]) -> ([53]); // 65 +store_temp>([50]) -> ([54]); // 66 +jump() { 73() }; // 67 +branch_align() -> (); // 68 +store_temp([19]) -> ([51]); // 69 +store_temp([34]) -> ([52]); // 70 +store_temp([35]) -> ([53]); // 71 +store_temp>([36]) -> ([54]); // 72 +struct_construct() -> ([55]); // 73 +struct_construct>>([55], [54]) -> ([56]); // 74 +enum_init,)>, 1>([56]) -> ([57]); // 75 +store_temp([51]) -> ([51]); // 76 +store_temp([52]) -> ([52]); // 77 +store_temp([53]) -> ([53]); // 78 +store_temp,)>>([57]) -> ([57]); // 79 +return([51], [52], [53], [57]); // 80 +branch_align() -> (); // 81 +array_new() -> ([58]); // 82 +const_as_immediate>() -> ([59]); // 83 +store_temp([59]) -> ([59]); // 84 +array_append([58], [59]) -> ([60]); // 85 +struct_construct() -> ([61]); // 86 +struct_construct>>([61], [60]) -> ([62]); // 87 +enum_init,)>, 1>([62]) -> ([63]); // 88 +store_temp([21]) -> ([21]); // 89 +store_temp([22]) -> ([22]); // 90 +store_temp([2]) -> ([2]); // 91 +store_temp,)>>([63]) -> ([63]); // 92 +return([21], [22], [2], [63]); // 93 +branch_align() -> (); // 94 +drop>([3]) -> (); // 95 +array_new() -> ([64]); // 96 +const_as_immediate>() -> ([65]); // 97 +store_temp([65]) -> ([65]); // 98 +array_append([64], [65]) -> ([66]); // 99 +struct_construct() -> ([67]); // 100 +struct_construct>>([67], [66]) -> ([68]); // 101 +enum_init,)>, 1>([68]) -> ([69]); // 102 +store_temp([6]) -> ([6]); // 103 +store_temp([7]) -> ([7]); // 104 +store_temp([2]) -> ([2]); // 105 +store_temp,)>>([69]) -> ([69]); // 106 +return([6], [7], [2], [69]); // 107 +revoke_ap_tracking() -> (); // 108 +withdraw_gas([0], [1]) { fallthrough([4], [5]) 262([6], [7]) }; // 109 +branch_align() -> (); // 110 +struct_deconstruct>([3]) -> ([8]); // 111 +enable_ap_tracking() -> (); // 112 +store_temp([4]) -> ([4]); // 113 +array_snapshot_pop_front([8]) { fallthrough([9], [10]) 122([11]) }; // 114 +branch_align() -> (); // 115 +unbox([10]) -> ([12]); // 116 +rename([12]) -> ([13]); // 117 +enum_init, 0>([13]) -> ([14]); // 118 +store_temp>>([9]) -> ([15]); // 119 +store_temp>([14]) -> ([16]); // 120 +jump() { 127() }; // 121 +branch_align() -> (); // 122 +struct_construct() -> ([17]); // 123 +enum_init, 1>([17]) -> ([18]); // 124 +store_temp>>([11]) -> ([15]); // 125 +store_temp>([18]) -> ([16]); // 126 +enum_match>([16]) { fallthrough([19]) 245([20]) }; // 127 +branch_align() -> (); // 128 +contract_address_try_from_felt252([4], [19]) { fallthrough([21], [22]) 241([23]) }; // 129 +branch_align() -> (); // 130 +store_temp([21]) -> ([21]); // 131 +array_snapshot_pop_front([15]) { fallthrough([24], [25]) 150([26]) }; // 132 +branch_align() -> (); // 133 +disable_ap_tracking() -> (); // 134 +drop>>([24]) -> (); // 135 +drop>([25]) -> (); // 136 +drop([22]) -> (); // 137 +array_new() -> ([27]); // 138 +const_as_immediate>() -> ([28]); // 139 +store_temp([28]) -> ([28]); // 140 +array_append([27], [28]) -> ([29]); // 141 +struct_construct() -> ([30]); // 142 +struct_construct>>([30], [29]) -> ([31]); // 143 +enum_init,)>, 1>([31]) -> ([32]); // 144 +store_temp([21]) -> ([21]); // 145 +store_temp([5]) -> ([5]); // 146 +store_temp([2]) -> ([2]); // 147 +store_temp,)>>([32]) -> ([32]); // 148 +return([21], [5], [2], [32]); // 149 +branch_align() -> (); // 150 +disable_ap_tracking() -> (); // 151 +drop>>([26]) -> (); // 152 +get_builtin_costs() -> ([33]); // 153 +store_temp([33]) -> ([33]); // 154 +withdraw_gas_all([21], [5], [33]) { fallthrough([34], [35]) 227([36], [37]) }; // 155 +branch_align() -> (); // 156 +dup([22]) -> ([22], [38]); // 157 +contract_address_to_felt252([38]) -> ([39]); // 158 +store_temp([34]) -> ([34]); // 159 +felt252_is_zero([39]) { fallthrough() 172([40]) }; // 160 +branch_align() -> (); // 161 +drop([22]) -> (); // 162 +array_new() -> ([41]); // 163 +const_as_immediate>() -> ([42]); // 164 +store_temp([42]) -> ([42]); // 165 +array_append([41], [42]) -> ([43]); // 166 +store_temp([34]) -> ([44]); // 167 +store_temp([35]) -> ([45]); // 168 +store_temp([2]) -> ([46]); // 169 +store_temp>([43]) -> ([47]); // 170 +jump() { 219() }; // 171 +branch_align() -> (); // 172 +drop>([40]) -> (); // 173 +struct_construct>() -> ([48]); // 174 +snapshot_take>([48]) -> ([49], [50]); // 175 +store_temp([34]) -> ([34]); // 176 +store_temp([35]) -> ([35]); // 177 +store_temp([2]) -> ([2]); // 178 +function_call::assert_only_owner>([34], [35], [2], [50]) -> ([51], [52], [53], [54]); // 179 +enum_match>([54]) { fallthrough([55]) 210([56]) }; // 180 +branch_align() -> (); // 181 +drop>([55]) -> (); // 182 +store_temp([51]) -> ([51]); // 183 +store_temp([52]) -> ([52]); // 184 +store_temp([53]) -> ([53]); // 185 +store_temp([22]) -> ([22]); // 186 +function_call::_transfer_ownership>([51], [52], [53], [49], [22]) -> ([57], [58], [59], [60]); // 187 +enum_match, ())>>([60]) { fallthrough([61]) 202([62]) }; // 188 +branch_align() -> (); // 189 +drop, Unit>>([61]) -> (); // 190 +array_new() -> ([63]); // 191 +snapshot_take>([63]) -> ([64], [65]); // 192 +drop>([64]) -> (); // 193 +struct_construct>([65]) -> ([66]); // 194 +struct_construct>>([66]) -> ([67]); // 195 +enum_init,)>, 0>([67]) -> ([68]); // 196 +store_temp([57]) -> ([57]); // 197 +store_temp([58]) -> ([58]); // 198 +store_temp([59]) -> ([59]); // 199 +store_temp,)>>([68]) -> ([68]); // 200 +return([57], [58], [59], [68]); // 201 +branch_align() -> (); // 202 +struct_deconstruct>>([62]) -> ([69], [70]); // 203 +drop([69]) -> (); // 204 +store_temp([57]) -> ([44]); // 205 +store_temp([58]) -> ([45]); // 206 +store_temp([59]) -> ([46]); // 207 +store_temp>([70]) -> ([47]); // 208 +jump() { 219() }; // 209 +branch_align() -> (); // 210 +drop([22]) -> (); // 211 +drop>([49]) -> (); // 212 +struct_deconstruct>>([56]) -> ([71], [72]); // 213 +drop([71]) -> (); // 214 +store_temp([51]) -> ([44]); // 215 +store_temp([52]) -> ([45]); // 216 +store_temp([53]) -> ([46]); // 217 +store_temp>([72]) -> ([47]); // 218 +struct_construct() -> ([73]); // 219 +struct_construct>>([73], [47]) -> ([74]); // 220 +enum_init,)>, 1>([74]) -> ([75]); // 221 +store_temp([44]) -> ([44]); // 222 +store_temp([45]) -> ([45]); // 223 +store_temp([46]) -> ([46]); // 224 +store_temp,)>>([75]) -> ([75]); // 225 +return([44], [45], [46], [75]); // 226 +branch_align() -> (); // 227 +drop([22]) -> (); // 228 +array_new() -> ([76]); // 229 +const_as_immediate>() -> ([77]); // 230 +store_temp([77]) -> ([77]); // 231 +array_append([76], [77]) -> ([78]); // 232 +struct_construct() -> ([79]); // 233 +struct_construct>>([79], [78]) -> ([80]); // 234 +enum_init,)>, 1>([80]) -> ([81]); // 235 +store_temp([36]) -> ([36]); // 236 +store_temp([37]) -> ([37]); // 237 +store_temp([2]) -> ([2]); // 238 +store_temp,)>>([81]) -> ([81]); // 239 +return([36], [37], [2], [81]); // 240 +branch_align() -> (); // 241 +drop>>([15]) -> (); // 242 +store_temp([23]) -> ([82]); // 243 +jump() { 249() }; // 244 +branch_align() -> (); // 245 +drop([20]) -> (); // 246 +drop>>([15]) -> (); // 247 +store_temp([4]) -> ([82]); // 248 +disable_ap_tracking() -> (); // 249 +array_new() -> ([83]); // 250 +const_as_immediate>() -> ([84]); // 251 +store_temp([84]) -> ([84]); // 252 +array_append([83], [84]) -> ([85]); // 253 +struct_construct() -> ([86]); // 254 +struct_construct>>([86], [85]) -> ([87]); // 255 +enum_init,)>, 1>([87]) -> ([88]); // 256 +store_temp([82]) -> ([82]); // 257 +store_temp([5]) -> ([5]); // 258 +store_temp([2]) -> ([2]); // 259 +store_temp,)>>([88]) -> ([88]); // 260 +return([82], [5], [2], [88]); // 261 +branch_align() -> (); // 262 +drop>([3]) -> (); // 263 +array_new() -> ([89]); // 264 +const_as_immediate>() -> ([90]); // 265 +store_temp([90]) -> ([90]); // 266 +array_append([89], [90]) -> ([91]); // 267 +struct_construct() -> ([92]); // 268 +struct_construct>>([92], [91]) -> ([93]); // 269 +enum_init,)>, 1>([93]) -> ([94]); // 270 +store_temp([6]) -> ([6]); // 271 +store_temp([7]) -> ([7]); // 272 +store_temp([2]) -> ([2]); // 273 +store_temp,)>>([94]) -> ([94]); // 274 +return([6], [7], [2], [94]); // 275 +revoke_ap_tracking() -> (); // 276 +withdraw_gas([0], [1]) { fallthrough([4], [5]) 363([6], [7]) }; // 277 +branch_align() -> (); // 278 +struct_deconstruct>([3]) -> ([8]); // 279 +store_temp([4]) -> ([4]); // 280 +array_snapshot_pop_front([8]) { fallthrough([9], [10]) 297([11]) }; // 281 +branch_align() -> (); // 282 +drop>>([9]) -> (); // 283 +drop>([10]) -> (); // 284 +array_new() -> ([12]); // 285 +const_as_immediate>() -> ([13]); // 286 +store_temp([13]) -> ([13]); // 287 +array_append([12], [13]) -> ([14]); // 288 +struct_construct() -> ([15]); // 289 +struct_construct>>([15], [14]) -> ([16]); // 290 +enum_init,)>, 1>([16]) -> ([17]); // 291 +store_temp([4]) -> ([4]); // 292 +store_temp([5]) -> ([5]); // 293 +store_temp([2]) -> ([2]); // 294 +store_temp,)>>([17]) -> ([17]); // 295 +return([4], [5], [2], [17]); // 296 +branch_align() -> (); // 297 +drop>>([11]) -> (); // 298 +get_builtin_costs() -> ([18]); // 299 +store_temp([18]) -> ([18]); // 300 +withdraw_gas_all([4], [5], [18]) { fallthrough([19], [20]) 350([21], [22]) }; // 301 +branch_align() -> (); // 302 +struct_construct>() -> ([23]); // 303 +snapshot_take>([23]) -> ([24], [25]); // 304 +store_temp([19]) -> ([19]); // 305 +store_temp([20]) -> ([20]); // 306 +store_temp([2]) -> ([2]); // 307 +function_call::assert_only_owner>([19], [20], [2], [25]) -> ([26], [27], [28], [29]); // 308 +enum_match>([29]) { fallthrough([30]) 338([31]) }; // 309 +branch_align() -> (); // 310 +drop>([30]) -> (); // 311 +contract_address_const<0>() -> ([32]); // 312 +store_temp([26]) -> ([26]); // 313 +store_temp([27]) -> ([27]); // 314 +store_temp([28]) -> ([28]); // 315 +store_temp([32]) -> ([32]); // 316 +function_call::_transfer_ownership>([26], [27], [28], [24], [32]) -> ([33], [34], [35], [36]); // 317 +enum_match, ())>>([36]) { fallthrough([37]) 332([38]) }; // 318 +branch_align() -> (); // 319 +drop, Unit>>([37]) -> (); // 320 +array_new() -> ([39]); // 321 +snapshot_take>([39]) -> ([40], [41]); // 322 +drop>([40]) -> (); // 323 +struct_construct>([41]) -> ([42]); // 324 +struct_construct>>([42]) -> ([43]); // 325 +enum_init,)>, 0>([43]) -> ([44]); // 326 +store_temp([33]) -> ([33]); // 327 +store_temp([34]) -> ([34]); // 328 +store_temp([35]) -> ([35]); // 329 +store_temp,)>>([44]) -> ([44]); // 330 +return([33], [34], [35], [44]); // 331 +branch_align() -> (); // 332 +store_temp([33]) -> ([45]); // 333 +store_temp([34]) -> ([46]); // 334 +store_temp([35]) -> ([47]); // 335 +store_temp>>([38]) -> ([48]); // 336 +jump() { 344() }; // 337 +branch_align() -> (); // 338 +drop>([24]) -> (); // 339 +store_temp([26]) -> ([45]); // 340 +store_temp([27]) -> ([46]); // 341 +store_temp([28]) -> ([47]); // 342 +store_temp>>([31]) -> ([48]); // 343 +enum_init,)>, 1>([48]) -> ([49]); // 344 +store_temp([45]) -> ([45]); // 345 +store_temp([46]) -> ([46]); // 346 +store_temp([47]) -> ([47]); // 347 +store_temp,)>>([49]) -> ([49]); // 348 +return([45], [46], [47], [49]); // 349 +branch_align() -> (); // 350 +array_new() -> ([50]); // 351 +const_as_immediate>() -> ([51]); // 352 +store_temp([51]) -> ([51]); // 353 +array_append([50], [51]) -> ([52]); // 354 +struct_construct() -> ([53]); // 355 +struct_construct>>([53], [52]) -> ([54]); // 356 +enum_init,)>, 1>([54]) -> ([55]); // 357 +store_temp([21]) -> ([21]); // 358 +store_temp([22]) -> ([22]); // 359 +store_temp([2]) -> ([2]); // 360 +store_temp,)>>([55]) -> ([55]); // 361 +return([21], [22], [2], [55]); // 362 +branch_align() -> (); // 363 +drop>([3]) -> (); // 364 +array_new() -> ([56]); // 365 +const_as_immediate>() -> ([57]); // 366 +store_temp([57]) -> ([57]); // 367 +array_append([56], [57]) -> ([58]); // 368 +struct_construct() -> ([59]); // 369 +struct_construct>>([59], [58]) -> ([60]); // 370 +enum_init,)>, 1>([60]) -> ([61]); // 371 +store_temp([6]) -> ([6]); // 372 +store_temp([7]) -> ([7]); // 373 +store_temp([2]) -> ([2]); // 374 +store_temp,)>>([61]) -> ([61]); // 375 +return([6], [7], [2], [61]); // 376 +revoke_ap_tracking() -> (); // 377 +withdraw_gas([0], [1]) { fallthrough([4], [5]) 514([6], [7]) }; // 378 +branch_align() -> (); // 379 +struct_deconstruct>([3]) -> ([8]); // 380 +enable_ap_tracking() -> (); // 381 +store_temp([4]) -> ([4]); // 382 +array_snapshot_pop_front([8]) { fallthrough([9], [10]) 389([11]) }; // 383 +branch_align() -> (); // 384 +enum_init>, 0>([10]) -> ([12]); // 385 +store_temp>>([9]) -> ([13]); // 386 +store_temp>>([12]) -> ([14]); // 387 +jump() { 394() }; // 388 +branch_align() -> (); // 389 +struct_construct() -> ([15]); // 390 +enum_init>, 1>([15]) -> ([16]); // 391 +store_temp>>([11]) -> ([13]); // 392 +store_temp>>([16]) -> ([14]); // 393 +enum_match>>([14]) { fallthrough([17]) 423([18]) }; // 394 +branch_align() -> (); // 395 +disable_ap_tracking() -> (); // 396 +unbox([17]) -> ([19]); // 397 +array_new() -> ([20]); // 398 +struct_construct>([13]) -> ([21]); // 399 +rename([19]) -> ([22]); // 400 +store_temp([4]) -> ([4]); // 401 +store_temp([5]) -> ([5]); // 402 +store_temp>([21]) -> ([21]); // 403 +store_temp>([20]) -> ([20]); // 404 +store_temp([22]) -> ([22]); // 405 +function_call>([4], [5], [21], [20], [22]) -> ([23], [24], [25]); // 406 +enum_match, core::option::Option::>)>>([25]) { fallthrough([26]) 416([27]) }; // 407 +branch_align() -> (); // 408 +struct_deconstruct, core::option::Option::>>>([26]) -> ([28], [29]); // 409 +struct_deconstruct>([28]) -> ([30]); // 410 +store_temp([23]) -> ([31]); // 411 +store_temp([24]) -> ([32]); // 412 +store_temp>>([30]) -> ([33]); // 413 +store_temp>>([29]) -> ([34]); // 414 +jump() { 432() }; // 415 +branch_align() -> (); // 416 +enum_init,)>, 1>([27]) -> ([35]); // 417 +store_temp([23]) -> ([23]); // 418 +store_temp([24]) -> ([24]); // 419 +store_temp([2]) -> ([2]); // 420 +store_temp,)>>([35]) -> ([35]); // 421 +return([23], [24], [2], [35]); // 422 +branch_align() -> (); // 423 +disable_ap_tracking() -> (); // 424 +drop([18]) -> (); // 425 +struct_construct() -> ([36]); // 426 +enum_init>, 1>([36]) -> ([37]); // 427 +store_temp([4]) -> ([31]); // 428 +store_temp([5]) -> ([32]); // 429 +store_temp>>([13]) -> ([33]); // 430 +store_temp>>([37]) -> ([34]); // 431 +enum_match>>([34]) { fallthrough([38]) 499([39]) }; // 432 +branch_align() -> (); // 433 +array_snapshot_pop_front([33]) { fallthrough([40], [41]) 451([42]) }; // 434 +branch_align() -> (); // 435 +drop>>([40]) -> (); // 436 +drop>([41]) -> (); // 437 +drop>([38]) -> (); // 438 +array_new() -> ([43]); // 439 +const_as_immediate>() -> ([44]); // 440 +store_temp([44]) -> ([44]); // 441 +array_append([43], [44]) -> ([45]); // 442 +struct_construct() -> ([46]); // 443 +struct_construct>>([46], [45]) -> ([47]); // 444 +enum_init,)>, 1>([47]) -> ([48]); // 445 +store_temp([31]) -> ([31]); // 446 +store_temp([32]) -> ([32]); // 447 +store_temp([2]) -> ([2]); // 448 +store_temp,)>>([48]) -> ([48]); // 449 +return([31], [32], [2], [48]); // 450 +branch_align() -> (); // 451 +drop>>([42]) -> (); // 452 +get_builtin_costs() -> ([49]); // 453 +store_temp([49]) -> ([49]); // 454 +withdraw_gas_all([31], [32], [49]) { fallthrough([50], [51]) 485([52], [53]) }; // 455 +branch_align() -> (); // 456 +struct_construct>() -> ([54]); // 457 +struct_construct([54]) -> ([55]); // 458 +store_temp([50]) -> ([50]); // 459 +store_temp([51]) -> ([51]); // 460 +store_temp([2]) -> ([2]); // 461 +store_temp>([38]) -> ([38]); // 462 +function_call([50], [51], [2], [55], [38]) -> ([56], [57], [58], [59]); // 463 +enum_match>([59]) { fallthrough([60]) 478([61]) }; // 464 +branch_align() -> (); // 465 +drop>([60]) -> (); // 466 +array_new() -> ([62]); // 467 +snapshot_take>([62]) -> ([63], [64]); // 468 +drop>([63]) -> (); // 469 +struct_construct>([64]) -> ([65]); // 470 +struct_construct>>([65]) -> ([66]); // 471 +enum_init,)>, 0>([66]) -> ([67]); // 472 +store_temp([56]) -> ([56]); // 473 +store_temp([57]) -> ([57]); // 474 +store_temp([58]) -> ([58]); // 475 +store_temp,)>>([67]) -> ([67]); // 476 +return([56], [57], [58], [67]); // 477 +branch_align() -> (); // 478 +enum_init,)>, 1>([61]) -> ([68]); // 479 +store_temp([56]) -> ([56]); // 480 +store_temp([57]) -> ([57]); // 481 +store_temp([58]) -> ([58]); // 482 +store_temp,)>>([68]) -> ([68]); // 483 +return([56], [57], [58], [68]); // 484 +branch_align() -> (); // 485 +drop>([38]) -> (); // 486 +array_new() -> ([69]); // 487 +const_as_immediate>() -> ([70]); // 488 +store_temp([70]) -> ([70]); // 489 +array_append([69], [70]) -> ([71]); // 490 +struct_construct() -> ([72]); // 491 +struct_construct>>([72], [71]) -> ([73]); // 492 +enum_init,)>, 1>([73]) -> ([74]); // 493 +store_temp([52]) -> ([52]); // 494 +store_temp([53]) -> ([53]); // 495 +store_temp([2]) -> ([2]); // 496 +store_temp,)>>([74]) -> ([74]); // 497 +return([52], [53], [2], [74]); // 498 +branch_align() -> (); // 499 +drop([39]) -> (); // 500 +drop>>([33]) -> (); // 501 +array_new() -> ([75]); // 502 +const_as_immediate>() -> ([76]); // 503 +store_temp([76]) -> ([76]); // 504 +array_append([75], [76]) -> ([77]); // 505 +struct_construct() -> ([78]); // 506 +struct_construct>>([78], [77]) -> ([79]); // 507 +enum_init,)>, 1>([79]) -> ([80]); // 508 +store_temp([31]) -> ([31]); // 509 +store_temp([32]) -> ([32]); // 510 +store_temp([2]) -> ([2]); // 511 +store_temp,)>>([80]) -> ([80]); // 512 +return([31], [32], [2], [80]); // 513 +branch_align() -> (); // 514 +drop>([3]) -> (); // 515 +array_new() -> ([81]); // 516 +const_as_immediate>() -> ([82]); // 517 +store_temp([82]) -> ([82]); // 518 +array_append([81], [82]) -> ([83]); // 519 +struct_construct() -> ([84]); // 520 +struct_construct>>([84], [83]) -> ([85]); // 521 +enum_init,)>, 1>([85]) -> ([86]); // 522 +store_temp([6]) -> ([6]); // 523 +store_temp([7]) -> ([7]); // 524 +store_temp([2]) -> ([2]); // 525 +store_temp,)>>([86]) -> ([86]); // 526 +return([6], [7], [2], [86]); // 527 +drop>([3]) -> (); // 528 +storage_base_address_const<1239149872729906871793169171313897310809028090219849129902089947133222824240>() -> ([4]); // 529 +struct_construct>([4]) -> ([5]); // 530 +snapshot_take>([5]) -> ([6], [7]); // 531 +drop>([6]) -> (); // 532 +struct_deconstruct>([7]) -> ([8]); // 533 +rename([8]) -> ([9]); // 534 +storage_address_from_base([9]) -> ([10]); // 535 +const_as_immediate>() -> ([11]); // 536 +store_temp([11]) -> ([11]); // 537 +store_temp([10]) -> ([10]); // 538 +storage_read_syscall([1], [2], [11], [10]) { fallthrough([12], [13], [14]) 627([15], [16], [17]) }; // 539 +branch_align() -> (); // 540 +store_temp([14]) -> ([14]); // 541 +store_temp([12]) -> ([12]); // 542 +store_temp([13]) -> ([13]); // 543 +contract_address_try_from_felt252([0], [14]) { fallthrough([18], [19]) 617([20]) }; // 544 +branch_align() -> (); // 545 +store_temp([18]) -> ([18]); // 546 +get_execution_info_v2_syscall([12], [13]) { fallthrough([21], [22], [23]) 607([24], [25], [26]) }; // 547 +branch_align() -> (); // 548 +store_temp>([23]) -> ([23]); // 549 +unbox([23]) -> ([27]); // 550 +struct_deconstruct([27]) -> ([28], [29], [30], [31], [32]); // 551 +drop>([28]) -> (); // 552 +drop>([29]) -> (); // 553 +drop([31]) -> (); // 554 +drop([32]) -> (); // 555 +store_temp([30]) -> ([30]); // 556 +dup([30]) -> ([30], [33]); // 557 +contract_address_to_felt252([33]) -> ([34]); // 558 +store_temp([21]) -> ([21]); // 559 +store_temp([22]) -> ([22]); // 560 +felt252_is_zero([34]) { fallthrough() 577([35]) }; // 561 +branch_align() -> (); // 562 +drop([19]) -> (); // 563 +drop([30]) -> (); // 564 +array_new() -> ([36]); // 565 +const_as_immediate>() -> ([37]); // 566 +store_temp([37]) -> ([37]); // 567 +array_append([36], [37]) -> ([38]); // 568 +struct_construct() -> ([39]); // 569 +struct_construct>>([39], [38]) -> ([40]); // 570 +enum_init, 1>([40]) -> ([41]); // 571 +store_temp([18]) -> ([18]); // 572 +store_temp([21]) -> ([21]); // 573 +store_temp([22]) -> ([22]); // 574 +store_temp>([41]) -> ([41]); // 575 +return([18], [21], [22], [41]); // 576 +branch_align() -> (); // 577 +drop>([35]) -> (); // 578 +contract_address_to_felt252([30]) -> ([42]); // 579 +contract_address_to_felt252([19]) -> ([43]); // 580 +felt252_sub([42], [43]) -> ([44]); // 581 +store_temp([44]) -> ([44]); // 582 +felt252_is_zero([44]) { fallthrough() 593([45]) }; // 583 +branch_align() -> (); // 584 +struct_construct() -> ([46]); // 585 +struct_construct>([46]) -> ([47]); // 586 +enum_init, 0>([47]) -> ([48]); // 587 +store_temp([18]) -> ([18]); // 588 +store_temp([21]) -> ([21]); // 589 +store_temp([22]) -> ([22]); // 590 +store_temp>([48]) -> ([48]); // 591 +return([18], [21], [22], [48]); // 592 +branch_align() -> (); // 593 +drop>([45]) -> (); // 594 +array_new() -> ([49]); // 595 +const_as_immediate>() -> ([50]); // 596 +store_temp([50]) -> ([50]); // 597 +array_append([49], [50]) -> ([51]); // 598 +struct_construct() -> ([52]); // 599 +struct_construct>>([52], [51]) -> ([53]); // 600 +enum_init, 1>([53]) -> ([54]); // 601 +store_temp([18]) -> ([18]); // 602 +store_temp([21]) -> ([21]); // 603 +store_temp([22]) -> ([22]); // 604 +store_temp>([54]) -> ([54]); // 605 +return([18], [21], [22], [54]); // 606 +branch_align() -> (); // 607 +drop([19]) -> (); // 608 +struct_construct() -> ([55]); // 609 +struct_construct>>([55], [26]) -> ([56]); // 610 +enum_init, 1>([56]) -> ([57]); // 611 +store_temp([18]) -> ([18]); // 612 +store_temp([24]) -> ([24]); // 613 +store_temp([25]) -> ([25]); // 614 +store_temp>([57]) -> ([57]); // 615 +return([18], [24], [25], [57]); // 616 +branch_align() -> (); // 617 +array_new() -> ([58]); // 618 +const_as_immediate>() -> ([59]); // 619 +store_temp([59]) -> ([59]); // 620 +array_append([58], [59]) -> ([60]); // 621 +store_temp([20]) -> ([61]); // 622 +store_temp([12]) -> ([62]); // 623 +store_temp([13]) -> ([63]); // 624 +store_temp>([60]) -> ([64]); // 625 +jump() { 632() }; // 626 +branch_align() -> (); // 627 +store_temp([0]) -> ([61]); // 628 +store_temp([15]) -> ([62]); // 629 +store_temp([16]) -> ([63]); // 630 +store_temp>([17]) -> ([64]); // 631 +struct_construct() -> ([65]); // 632 +struct_construct>>([65], [64]) -> ([66]); // 633 +enum_init, 1>([66]) -> ([67]); // 634 +store_temp([61]) -> ([61]); // 635 +store_temp([62]) -> ([62]); // 636 +store_temp([63]) -> ([63]); // 637 +store_temp>([67]) -> ([67]); // 638 +return([61], [62], [63], [67]); // 639 +storage_base_address_const<1239149872729906871793169171313897310809028090219849129902089947133222824240>() -> ([5]); // 640 +struct_construct>>([5]) -> ([6]); // 641 +snapshot_take>>([6]) -> ([7], [8]); // 642 +drop>>([7]) -> (); // 643 +struct_deconstruct>>([8]) -> ([9]); // 644 +rename([9]) -> ([10]); // 645 +storage_address_from_base([10]) -> ([11]); // 646 +const_as_immediate>() -> ([12]); // 647 +store_temp([12]) -> ([12]); // 648 +store_temp([11]) -> ([11]); // 649 +storage_read_syscall([1], [2], [12], [11]) { fallthrough([13], [14], [15]) 719([16], [17], [18]) }; // 650 +branch_align() -> (); // 651 +store_temp([15]) -> ([15]); // 652 +store_temp([13]) -> ([13]); // 653 +store_temp([14]) -> ([14]); // 654 +contract_address_try_from_felt252([0], [15]) { fallthrough([19], [20]) 707([21]) }; // 655 +branch_align() -> (); // 656 +storage_base_address_const<1239149872729906871793169171313897310809028090219849129902089947133222824240>() -> ([22]); // 657 +dup([4]) -> ([4], [23]); // 658 +contract_address_to_felt252([23]) -> ([24]); // 659 +storage_address_from_base([22]) -> ([25]); // 660 +const_as_immediate>() -> ([26]); // 661 +store_temp([26]) -> ([26]); // 662 +store_temp([25]) -> ([25]); // 663 +store_temp([19]) -> ([19]); // 664 +storage_write_syscall([13], [14], [26], [25], [24]) { fallthrough([27], [28]) 695([29], [30], [31]) }; // 665 +branch_align() -> (); // 666 +struct_construct([20], [4]) -> ([32]); // 667 +enum_init([32]) -> ([33]); // 668 +enum_init([33]) -> ([34]); // 669 +struct_construct>() -> ([35]); // 670 +struct_construct([35]) -> ([36]); // 671 +store_temp([27]) -> ([27]); // 672 +store_temp([28]) -> ([28]); // 673 +store_temp([34]) -> ([34]); // 674 +function_call>>([27], [28], [36], [34]) -> ([37], [38], [39]); // 675 +enum_match>([39]) { fallthrough([40]) 687([41]) }; // 676 +branch_align() -> (); // 677 +drop>([40]) -> (); // 678 +struct_construct() -> ([42]); // 679 +struct_construct, Unit>>([3], [42]) -> ([43]); // 680 +enum_init, ())>, 0>([43]) -> ([44]); // 681 +store_temp([19]) -> ([19]); // 682 +store_temp([37]) -> ([37]); // 683 +store_temp([38]) -> ([38]); // 684 +store_temp, ())>>([44]) -> ([44]); // 685 +return([19], [37], [38], [44]); // 686 +branch_align() -> (); // 687 +drop>([3]) -> (); // 688 +enum_init, ())>, 1>([41]) -> ([45]); // 689 +store_temp([19]) -> ([19]); // 690 +store_temp([37]) -> ([37]); // 691 +store_temp([38]) -> ([38]); // 692 +store_temp, ())>>([45]) -> ([45]); // 693 +return([19], [37], [38], [45]); // 694 +branch_align() -> (); // 695 +drop>([3]) -> (); // 696 +drop([4]) -> (); // 697 +drop([20]) -> (); // 698 +struct_construct() -> ([46]); // 699 +struct_construct>>([46], [31]) -> ([47]); // 700 +enum_init, ())>, 1>([47]) -> ([48]); // 701 +store_temp([19]) -> ([19]); // 702 +store_temp([29]) -> ([29]); // 703 +store_temp([30]) -> ([30]); // 704 +store_temp, ())>>([48]) -> ([48]); // 705 +return([19], [29], [30], [48]); // 706 +branch_align() -> (); // 707 +drop>([3]) -> (); // 708 +drop([4]) -> (); // 709 +array_new() -> ([49]); // 710 +const_as_immediate>() -> ([50]); // 711 +store_temp([50]) -> ([50]); // 712 +array_append([49], [50]) -> ([51]); // 713 +store_temp([21]) -> ([52]); // 714 +store_temp([13]) -> ([53]); // 715 +store_temp([14]) -> ([54]); // 716 +store_temp>([51]) -> ([55]); // 717 +jump() { 726() }; // 718 +branch_align() -> (); // 719 +drop>([3]) -> (); // 720 +drop([4]) -> (); // 721 +store_temp([0]) -> ([52]); // 722 +store_temp([16]) -> ([53]); // 723 +store_temp([17]) -> ([54]); // 724 +store_temp>([18]) -> ([55]); // 725 +struct_construct() -> ([56]); // 726 +struct_construct>>([56], [55]) -> ([57]); // 727 +enum_init, ())>, 1>([57]) -> ([58]); // 728 +store_temp([52]) -> ([52]); // 729 +store_temp([53]) -> ([53]); // 730 +store_temp([54]) -> ([54]); // 731 +store_temp, ())>>([58]) -> ([58]); // 732 +return([52], [53], [54], [58]); // 733 +disable_ap_tracking() -> (); // 734 +withdraw_gas([0], [1]) { fallthrough([5], [6]) 791([7], [8]) }; // 735 +branch_align() -> (); // 736 +dup([4]) -> ([4], [9]); // 737 +store_temp([5]) -> ([5]); // 738 +felt252_is_zero([9]) { fallthrough() 749([10]) }; // 739 +branch_align() -> (); // 740 +drop([4]) -> (); // 741 +enum_init>, 0>([3]) -> ([11]); // 742 +struct_construct, core::option::Option::>>>([2], [11]) -> ([12]); // 743 +enum_init, core::option::Option::>)>, 0>([12]) -> ([13]); // 744 +store_temp([5]) -> ([5]); // 745 +store_temp([6]) -> ([6]); // 746 +store_temp, core::option::Option::>)>>([13]) -> ([13]); // 747 +return([5], [6], [13]); // 748 +branch_align() -> (); // 749 +drop>([10]) -> (); // 750 +struct_deconstruct>([2]) -> ([14]); // 751 +enable_ap_tracking() -> (); // 752 +array_snapshot_pop_front([14]) { fallthrough([15], [16]) 761([17]) }; // 753 +branch_align() -> (); // 754 +unbox([16]) -> ([18]); // 755 +rename([18]) -> ([19]); // 756 +enum_init, 0>([19]) -> ([20]); // 757 +store_temp>>([15]) -> ([21]); // 758 +store_temp>([20]) -> ([22]); // 759 +jump() { 766() }; // 760 +branch_align() -> (); // 761 +struct_construct() -> ([23]); // 762 +enum_init, 1>([23]) -> ([24]); // 763 +store_temp>>([17]) -> ([21]); // 764 +store_temp>([24]) -> ([22]); // 765 +struct_construct>([21]) -> ([25]); // 766 +enum_match>([22]) { fallthrough([26]) 780([27]) }; // 767 +branch_align() -> (); // 768 +disable_ap_tracking() -> (); // 769 +array_append([3], [26]) -> ([28]); // 770 +const_as_immediate>() -> ([29]); // 771 +felt252_sub([4], [29]) -> ([30]); // 772 +store_temp([5]) -> ([5]); // 773 +store_temp([6]) -> ([6]); // 774 +store_temp>([25]) -> ([25]); // 775 +store_temp>([28]) -> ([28]); // 776 +store_temp([30]) -> ([30]); // 777 +function_call>([5], [6], [25], [28], [30]) -> ([31], [32], [33]); // 778 +return([31], [32], [33]); // 779 +branch_align() -> (); // 780 +disable_ap_tracking() -> (); // 781 +drop([4]) -> (); // 782 +drop>([3]) -> (); // 783 +enum_init>, 1>([27]) -> ([34]); // 784 +struct_construct, core::option::Option::>>>([25], [34]) -> ([35]); // 785 +enum_init, core::option::Option::>)>, 0>([35]) -> ([36]); // 786 +store_temp([5]) -> ([5]); // 787 +store_temp([6]) -> ([6]); // 788 +store_temp, core::option::Option::>)>>([36]) -> ([36]); // 789 +return([5], [6], [36]); // 790 +branch_align() -> (); // 791 +drop([4]) -> (); // 792 +drop>([3]) -> (); // 793 +drop>([2]) -> (); // 794 +array_new() -> ([37]); // 795 +const_as_immediate>() -> ([38]); // 796 +store_temp([38]) -> ([38]); // 797 +array_append([37], [38]) -> ([39]); // 798 +struct_construct() -> ([40]); // 799 +struct_construct>>([40], [39]) -> ([41]); // 800 +enum_init, core::option::Option::>)>, 1>([41]) -> ([42]); // 801 +store_temp([7]) -> ([7]); // 802 +store_temp([8]) -> ([8]); // 803 +store_temp, core::option::Option::>)>>([42]) -> ([42]); // 804 +return([7], [8], [42]); // 805 +get_execution_info_v2_syscall([1], [2]) { fallthrough([5], [6], [7]) 936([8], [9], [10]) }; // 806 +branch_align() -> (); // 807 +store_temp>([7]) -> ([7]); // 808 +unbox([7]) -> ([11]); // 809 +struct_deconstruct([11]) -> ([12], [13], [14], [15], [16]); // 810 +drop>([12]) -> (); // 811 +drop>([13]) -> (); // 812 +drop([15]) -> (); // 813 +drop([16]) -> (); // 814 +struct_deconstruct([3]) -> ([17]); // 815 +store_temp([0]) -> ([0]); // 816 +store_temp([5]) -> ([5]); // 817 +store_temp([6]) -> ([6]); // 818 +store_temp([14]) -> ([18]); // 819 +dup([18]) -> ([18], [14]); // 820 +function_call::_transfer_ownership>([0], [5], [6], [17], [18]) -> ([19], [20], [21], [22]); // 821 +enum_match, ())>>([22]) { fallthrough([23]) 927([24]) }; // 822 +branch_align() -> (); // 823 +array_new() -> ([25]); // 824 +const_as_immediate>() -> ([26]); // 825 +snapshot_take>([25]) -> ([27], [28]); // 826 +drop>([27]) -> (); // 827 +struct_construct>([28]) -> ([29]); // 828 +store_temp([26]) -> ([26]); // 829 +call_contract_syscall([20], [21], [14], [26], [29]) { fallthrough([30], [31], [32]) 912([33], [34], [35]) }; // 830 +branch_align() -> (); // 831 +struct_deconstruct>([32]) -> ([36]); // 832 +store_temp>>([36]) -> ([36]); // 833 +store_temp([30]) -> ([30]); // 834 +store_temp([31]) -> ([31]); // 835 +array_snapshot_pop_front([36]) { fallthrough([37], [38]) 898([39]) }; // 836 +branch_align() -> (); // 837 +drop>>([37]) -> (); // 838 +unbox([38]) -> ([40]); // 839 +rename([40]) -> ([41]); // 840 +store_temp([41]) -> ([41]); // 841 +class_hash_try_from_felt252([19], [41]) { fallthrough([42], [43]) 893([44]) }; // 842 +branch_align() -> (); // 843 +dup([43]) -> ([43], [45]); // 844 +class_hash_to_felt252([45]) -> ([46]); // 845 +array_append([4], [46]) -> ([47]); // 846 +const_as_immediate>() -> ([48]); // 847 +snapshot_take>([47]) -> ([49], [50]); // 848 +drop>([49]) -> (); // 849 +struct_construct>([50]) -> ([51]); // 850 +dup([43]) -> ([43], [52]); // 851 +store_temp([48]) -> ([48]); // 852 +store_temp>([51]) -> ([51]); // 853 +store_temp([42]) -> ([42]); // 854 +library_call_syscall([30], [31], [52], [48], [51]) { fallthrough([53], [54], [55]) 882([56], [57], [58]) }; // 855 +branch_align() -> (); // 856 +drop>([55]) -> (); // 857 +store_temp([53]) -> ([53]); // 858 +replace_class_syscall([53], [54], [43]) { fallthrough([59], [60]) 872([61], [62], [63]) }; // 859 +branch_align() -> (); // 860 +struct_deconstruct, Unit>>([23]) -> ([64], [65]); // 861 +drop([65]) -> (); // 862 +struct_construct([64]) -> ([66]); // 863 +struct_construct() -> ([67]); // 864 +struct_construct>([66], [67]) -> ([68]); // 865 +enum_init, 0>([68]) -> ([69]); // 866 +store_temp([42]) -> ([42]); // 867 +store_temp([59]) -> ([59]); // 868 +store_temp([60]) -> ([60]); // 869 +store_temp>([69]) -> ([69]); // 870 +return([42], [59], [60], [69]); // 871 +branch_align() -> (); // 872 +drop, Unit>>([23]) -> (); // 873 +struct_construct() -> ([70]); // 874 +struct_construct>>([70], [63]) -> ([71]); // 875 +enum_init, 1>([71]) -> ([72]); // 876 +store_temp([42]) -> ([42]); // 877 +store_temp([61]) -> ([61]); // 878 +store_temp([62]) -> ([62]); // 879 +store_temp>([72]) -> ([72]); // 880 +return([42], [61], [62], [72]); // 881 +branch_align() -> (); // 882 +drop, Unit>>([23]) -> (); // 883 +drop([43]) -> (); // 884 +struct_construct() -> ([73]); // 885 +struct_construct>>([73], [58]) -> ([74]); // 886 +enum_init, 1>([74]) -> ([75]); // 887 +store_temp([42]) -> ([42]); // 888 +store_temp([56]) -> ([56]); // 889 +store_temp([57]) -> ([57]); // 890 +store_temp>([75]) -> ([75]); // 891 +return([42], [56], [57], [75]); // 892 +branch_align() -> (); // 893 +drop>([4]) -> (); // 894 +drop, Unit>>([23]) -> (); // 895 +store_temp([44]) -> ([76]); // 896 +jump() { 903() }; // 897 +branch_align() -> (); // 898 +drop>>([39]) -> (); // 899 +drop>([4]) -> (); // 900 +drop, Unit>>([23]) -> (); // 901 +store_temp([19]) -> ([76]); // 902 +array_new() -> ([77]); // 903 +const_as_immediate>() -> ([78]); // 904 +store_temp([78]) -> ([78]); // 905 +array_append([77], [78]) -> ([79]); // 906 +store_temp([76]) -> ([80]); // 907 +store_temp([30]) -> ([81]); // 908 +store_temp([31]) -> ([82]); // 909 +store_temp>([79]) -> ([83]); // 910 +jump() { 919() }; // 911 +branch_align() -> (); // 912 +drop>([4]) -> (); // 913 +drop, Unit>>([23]) -> (); // 914 +store_temp([19]) -> ([80]); // 915 +store_temp([33]) -> ([81]); // 916 +store_temp([34]) -> ([82]); // 917 +store_temp>([35]) -> ([83]); // 918 +struct_construct() -> ([84]); // 919 +struct_construct>>([84], [83]) -> ([85]); // 920 +enum_init, 1>([85]) -> ([86]); // 921 +store_temp([80]) -> ([80]); // 922 +store_temp([81]) -> ([81]); // 923 +store_temp([82]) -> ([82]); // 924 +store_temp>([86]) -> ([86]); // 925 +return([80], [81], [82], [86]); // 926 +branch_align() -> (); // 927 +drop>([4]) -> (); // 928 +drop([14]) -> (); // 929 +enum_init, 1>([24]) -> ([87]); // 930 +store_temp([19]) -> ([19]); // 931 +store_temp([20]) -> ([20]); // 932 +store_temp([21]) -> ([21]); // 933 +store_temp>([87]) -> ([87]); // 934 +return([19], [20], [21], [87]); // 935 +branch_align() -> (); // 936 +drop>([4]) -> (); // 937 +drop([3]) -> (); // 938 +struct_construct() -> ([88]); // 939 +struct_construct>>([88], [10]) -> ([89]); // 940 +enum_init, 1>([89]) -> ([90]); // 941 +store_temp([0]) -> ([0]); // 942 +store_temp([8]) -> ([8]); // 943 +store_temp([9]) -> ([9]); // 944 +store_temp>([90]) -> ([90]); // 945 +return([0], [8], [9], [90]); // 946 +array_new() -> ([4]); // 947 +array_new() -> ([5]); // 948 +snapshot_take([3]) -> ([6], [7]); // 949 +drop([6]) -> (); // 950 +enum_match([7]) -> ([8]); // 951 +branch_align() -> (); // 952 +const_as_immediate>() -> ([9]); // 953 +store_temp([9]) -> ([9]); // 954 +array_append([4], [9]) -> ([10]); // 955 +enum_match([8]) -> ([11]); // 956 +branch_align() -> (); // 957 +const_as_immediate>() -> ([12]); // 958 +store_temp([12]) -> ([12]); // 959 +array_append([10], [12]) -> ([13]); // 960 +dup([11]) -> ([11], [14]); // 961 +struct_deconstruct([14]) -> ([15], [16]); // 962 +drop([16]) -> (); // 963 +rename([15]) -> ([17]); // 964 +contract_address_to_felt252([17]) -> ([18]); // 965 +array_append([5], [18]) -> ([19]); // 966 +struct_deconstruct([11]) -> ([20], [21]); // 967 +drop([20]) -> (); // 968 +rename([21]) -> ([22]); // 969 +contract_address_to_felt252([22]) -> ([23]); // 970 +array_append([19], [23]) -> ([24]); // 971 +snapshot_take>([13]) -> ([25], [26]); // 972 +drop>([25]) -> (); // 973 +snapshot_take>([24]) -> ([27], [28]); // 974 +drop>([27]) -> (); // 975 +struct_construct>([26]) -> ([29]); // 976 +struct_construct>([28]) -> ([30]); // 977 +store_temp>([29]) -> ([29]); // 978 +store_temp>([30]) -> ([30]); // 979 +emit_event_syscall([0], [1], [29], [30]) { fallthrough([31], [32]) 989([33], [34], [35]) }; // 980 +branch_align() -> (); // 981 +struct_construct() -> ([36]); // 982 +struct_construct>([2], [36]) -> ([37]); // 983 +enum_init, 0>([37]) -> ([38]); // 984 +store_temp([31]) -> ([31]); // 985 +store_temp([32]) -> ([32]); // 986 +store_temp>([38]) -> ([38]); // 987 +return([31], [32], [38]); // 988 +branch_align() -> (); // 989 +drop([2]) -> (); // 990 +struct_construct() -> ([39]); // 991 +struct_construct>>([39], [35]) -> ([40]); // 992 +enum_init, 1>([40]) -> ([41]); // 993 +store_temp([33]) -> ([33]); // 994 +store_temp([34]) -> ([34]); // 995 +store_temp>([41]) -> ([41]); // 996 +return([33], [34], [41]); // 997 + +contracts::components::ownable::ownable_component::__wrapper__Ownable__owner::@0([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +contracts::components::ownable::ownable_component::__wrapper__Ownable__transfer_ownership::@108([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +contracts::components::ownable::ownable_component::__wrapper__Ownable__renounce_ownership::@276([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +contracts::uninitialized_account::UninitializedAccount::__wrapper__constructor@377([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +contracts::components::ownable::ownable_component::InternalImpl::::assert_only_owner@528([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: contracts::components::ownable::ownable_component::ComponentState::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<((),)>); +contracts::components::ownable::ownable_component::InternalImpl::::_transfer_ownership@640([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: contracts::components::ownable::ownable_component::ComponentState::, [4]: ContractAddress) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(contracts::components::ownable::ownable_component::ComponentState::, ())>); +core::array::deserialize_array_helper::@734([0]: RangeCheck, [1]: GasBuiltin, [2]: core::array::Span::, [3]: Array, [4]: felt252) -> (RangeCheck, GasBuiltin, core::panics::PanicResult::<(core::array::Span::, core::option::Option::>)>); +contracts::uninitialized_account::UninitializedAccount::constructor@806([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: contracts::uninitialized_account::UninitializedAccount::ContractState, [4]: Array) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(contracts::uninitialized_account::UninitializedAccount::ContractState, ())>); +contracts::uninitialized_account::UninitializedAccount::ContractStateEventEmitter::emit::>@947([0]: GasBuiltin, [1]: System, [2]: contracts::uninitialized_account::UninitializedAccount::ContractState, [3]: contracts::uninitialized_account::UninitializedAccount::Event) -> (GasBuiltin, System, core::panics::PanicResult::<(contracts::uninitialized_account::UninitializedAccount::ContractState, ())>); diff --git a/crates/ef-testing/src/evm_sequencer/constants.rs b/crates/ef-testing/src/evm_sequencer/constants.rs index 753cf37b..ee48ce5f 100644 --- a/crates/ef-testing/src/evm_sequencer/constants.rs +++ b/crates/ef-testing/src/evm_sequencer/constants.rs @@ -1,4 +1,5 @@ use std::collections::HashMap; +use std::fs; use lazy_static::lazy_static; use reth_primitives::alloy_primitives::{address, Address}; @@ -21,6 +22,13 @@ where serde_json::from_str::(&std::fs::read_to_string(path)?).map_err(eyre::Error::from) } + +pub fn get_raw_contract_class(contract_path: &str) -> String { + println!("path: {:?}", contract_path); + fs::read_to_string(contract_path).unwrap() +} + + // Chain params pub const CHAIN_ID: u64 = 0x4b4b5254; @@ -89,11 +97,23 @@ lazy_static! { pub static ref ACCOUNT_CONTRACT_CLASS: CompiledClass = load_contract_class("../../build/v1/contracts_AccountContract.compiled_contract_class.json").expect("Failed to load ContractAccount contract class"); pub static ref UNINITIALIZED_ACCOUNT_CLASS: CompiledClass = load_contract_class("../../build/v1/contracts_UninitializedAccount.compiled_contract_class.json").expect("Failed to load uninitialized account contract class"); + pub static ref KAKAROT_JSON_CLASS: String = get_raw_contract_class("../../build/v1/contracts_KakarotCore.contract_class.json"); + pub static ref ACCOUNT_CONTRACT_JSON_CLASS: String = get_raw_contract_class("../../build/v1/contracts_AccountContract.contract_class.json"); + pub static ref UNINITIALIZED_ACCOUNT_JSON_CLASS: String = get_raw_contract_class("../../build/v1/contracts_UninitializedAccount.contract_class.json"); + // Main class hashes pub static ref KAKAROT_CLASS_HASH: ClassHash = ClassHash(KAKAROT_CLASS.class_hash().unwrap()); pub static ref ACCOUNT_CONTRACT_CLASS_HASH: ClassHash = ClassHash(ACCOUNT_CONTRACT_CLASS.class_hash().unwrap()); pub static ref UNINITIALIZED_ACCOUNT_CLASS_HASH: ClassHash = ClassHash(UNINITIALIZED_ACCOUNT_CLASS.class_hash().unwrap()); pub static ref PROXY_CLASS_HASH: ClassHash = *UNINITIALIZED_ACCOUNT_CLASS_HASH; + + pub static ref CLASS_HASH_TO_JSON_CLASS: HashMap = { + let mut map = HashMap::new(); + map.insert(*KAKAROT_CLASS_HASH, KAKAROT_JSON_CLASS.clone()); + map.insert(*ACCOUNT_CONTRACT_CLASS_HASH, ACCOUNT_CONTRACT_JSON_CLASS.clone()); + map.insert(*UNINITIALIZED_ACCOUNT_CLASS_HASH, UNINITIALIZED_ACCOUNT_JSON_CLASS.clone()); + map + }; } #[cfg(not(any(feature = "v0", feature = "v1")))] @@ -114,6 +134,12 @@ lazy_static! { panic!("Kakarot class hash not defined, use features flag \"v0\" or \"v1\""); pub static ref UNINITIALIZED_ACCOUNT_CLASS: LegacyContractClass = panic!("Uninitialized account class not defined, use features flag \"v0\" or \"v1\""); + + pub static ref KAKAROT_JSON_CLASS: String = panic!("Kakarot json class not defined, use features flag \"v0\" or \"v1\""); + pub static ref ACCOUNT_CONTRACT_JSON_CLASS: String = panic!("Account contract json class not defined, use features flag \"v0\" or \"v1\""); + pub static ref UNINITIALIZED_ACCOUNT_JSON_CLASS: String = panic!("Uninitialized account json class not defined, use features flag \"v0\" or \"v1\""); + + pub static ref CLASS_HASH_TO_JSON_CLASS: HashMap = HashMap::new(); } pub mod storage_variables { diff --git a/crates/ef-testing/src/evm_sequencer/sequencer/mod.rs b/crates/ef-testing/src/evm_sequencer/sequencer/mod.rs index d1a88874..21322ff6 100644 --- a/crates/ef-testing/src/evm_sequencer/sequencer/mod.rs +++ b/crates/ef-testing/src/evm_sequencer/sequencer/mod.rs @@ -1,4 +1,4 @@ -use blockifier::bouncer::BouncerConfig; +use blockifier::{bouncer::BouncerConfig, execution::contract_class::NativeContractClassV1}; use starknet::core::types::Felt; use std::ops::{Deref, DerefMut}; @@ -13,7 +13,7 @@ use crate::evm_sequencer::{ ETH_FEE_TOKEN_ADDRESS, FEE_TOKEN_CLASS, FEE_TOKEN_CLASS_HASH, KAKAROT_ADDRESS, KAKAROT_CLASS, KAKAROT_CLASS_HASH, KAKAROT_OWNER_ADDRESS, OPENZEPPELIN_ACCOUNT_CLASS, OPENZEPPELIN_ACCOUNT_CLASS_HASH, RELAYER_ADDRESS, RELAYER_BALANCE, RELAYER_VERIFYING_KEY, - STRK_FEE_TOKEN_ADDRESS, UNINITIALIZED_ACCOUNT_CLASS, UNINITIALIZED_ACCOUNT_CLASS_HASH, + STRK_FEE_TOKEN_ADDRESS, UNINITIALIZED_ACCOUNT_CLASS, UNINITIALIZED_ACCOUNT_CLASS_HASH, CLASS_HASH_TO_JSON_CLASS }, types::contract_class::CasmContractClassWrapper, utils::compute_starknet_address, @@ -29,7 +29,7 @@ use blockifier::{ use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use cairo_vm::types::errors::program_errors::ProgramError; use reth_primitives::Address; -use sequencer::{sequencer::Sequencer, state::State}; +use sequencer::{native::{class_from_json_str}, sequencer::Sequencer, state::State}; use starknet::core::types::contract::{legacy::LegacyContractClass, CompiledClass}; use starknet_api::{ block::{BlockNumber, BlockTimestamp}, @@ -231,13 +231,31 @@ lazy_static! { convert_contract_class_v0(&UNINITIALIZED_ACCOUNT_CLASS).expect("failed to convert uninitialized class") ) } + #[cfg(feature = "v1")] { + #[cfg(feature = "native")] + { + let account_json = CLASS_HASH_TO_JSON_CLASS.get(&ACCOUNT_CONTRACT_CLASS_HASH).unwrap(); + let kakarot_json = CLASS_HASH_TO_JSON_CLASS.get(&KAKAROT_CLASS_HASH).unwrap(); + let uninitialized_json = CLASS_HASH_TO_JSON_CLASS.get(&UNINITIALIZED_ACCOUNT_CLASS_HASH).unwrap(); + println!("Got account's json of length {}", account_json.len()); + println!("Got kakarot's json of length {}", kakarot_json.len()); + println!("Got uninitialized's json of length {}", uninitialized_json.len()); + let account_class= class_from_json_str(account_json, *ACCOUNT_CONTRACT_CLASS_HASH).unwrap(); + let kakarot_class= class_from_json_str(kakarot_json, *KAKAROT_CLASS_HASH).unwrap(); + let uninitialized_class= class_from_json_str(uninitialized_json, *UNINITIALIZED_ACCOUNT_CLASS_HASH).unwrap(); + println!("Got class"); + (account_class, kakarot_class, uninitialized_class) + } + #[cfg(not(feature = "native"))] + { ( convert_contract_class_v1(&KAKAROT_CLASS).expect("failed to convert kakarot class"), convert_contract_class_v1(&ACCOUNT_CONTRACT_CLASS).expect("failed to convert account class"), convert_contract_class_v1(&UNINITIALIZED_ACCOUNT_CLASS).expect("failed to convert uninitialized class") ) + } } }; @@ -249,8 +267,7 @@ lazy_static! { // Write contract account, uninitialized_account and erc20 classes and class hashes. (&mut state).set_contract_class( *ACCOUNT_CONTRACT_CLASS_HASH, - converted_account_class, - ).expect("failed to set contract account class"); + converted_account_class).expect("failed to set contract account class"); (&mut state) .set_contract_class(*UNINITIALIZED_ACCOUNT_CLASS_HASH, converted_uninitialized_class).expect("failed to set eoa contract class"); diff --git a/crates/sequencer/Cargo.toml b/crates/sequencer/Cargo.toml index b03c846e..2a1003ed 100644 --- a/crates/sequencer/Cargo.toml +++ b/crates/sequencer/Cargo.toml @@ -16,12 +16,19 @@ serde = { workspace = true } serde_json = { workspace = true } starknet_api = { workspace = true } starknet = { workspace = true } +cairo-lang-sierra = { workspace = true } +cairo-native = { workspace = true } +cairo-lang-starknet-classes = { workspace = true } # Other eyre = { workspace = true } tracing = { workspace = true } thiserror = { workspace = true } hashbrown = { workspace = true } +cached = "0.53.1" +once_cell = "1.19.0" +libloading = "0.8.5" +lazy_static.workspace = true [dev-dependencies] lazy_static = { workspace = true } diff --git a/crates/sequencer/src/lib.rs b/crates/sequencer/src/lib.rs index 0731f789..11ee62b9 100644 --- a/crates/sequencer/src/lib.rs +++ b/crates/sequencer/src/lib.rs @@ -5,3 +5,4 @@ pub mod sequencer; pub mod serde; pub mod state; pub mod transaction; +pub mod native; diff --git a/crates/sequencer/src/native.rs b/crates/sequencer/src/native.rs new file mode 100644 index 00000000..d64f99ed --- /dev/null +++ b/crates/sequencer/src/native.rs @@ -0,0 +1,194 @@ +use blockifier::execution::contract_class::NativeContractClassV1; +use blockifier::{ + execution::contract_class::{ContractClass, ContractClassV0, ContractClassV1}, + state::state_api::StateResult, +}; +use blockifier::{ + execution::contract_class::{ + ClassInfo as BlockifierClassInfo}, +}; +use cairo_lang_starknet_classes::abi::Contract; +use cairo_native::{ + context::NativeContext, error::Error as NativeError, executor::AotNativeExecutor, + metadata::gas::GasMetadata, module::NativeModule, +}; +use cairo_lang_starknet_classes::contract_class::ContractClass as SierraContractClass; +use libloading::Library; +use starknet_api::core::ClassHash; +use serde::{Deserialize, Serialize}; + +use std::{ + ffi::{c_char, c_uchar, c_void, CStr}, + fs, + path::PathBuf, + slice, + sync::Mutex, +}; +use cached::{Cached, SizedCache}; +use once_cell::sync::Lazy; +use lazy_static::lazy_static; + +use cairo_lang_sierra::{program::Program, program_registry::ProgramRegistry}; +use hashbrown::HashMap; + +lazy_static! { + static ref NATIVE_CACHE_DIR: PathBuf = setup_native_cache_dir(); +} + +fn generate_library_path(class_hash: ClassHash) -> PathBuf { + let mut path = NATIVE_CACHE_DIR.clone(); + path.push(class_hash.to_string().trim_start_matches("0x")); + path +} + +/// Compiles and load contract +/// +/// Modelled after [AotNativeExecutor::from_native_module]. +/// Needs a sierra_program to workaround limitations of NativeModule +fn persist_from_native_module( + mut native_module: NativeModule, + sierra_program: &Program, + library_output_path: &PathBuf, +) -> Result> { + let object_data = cairo_native::module_to_object(native_module.module(), Default::default()) + .map_err(|err| NativeError::LLVMCompileError(err.to_string()))?; // cairo native didn't include a from instance + + cairo_native::object_to_shared_lib(&object_data, library_output_path)?; + + let gas_metadata = native_module + .remove_metadata() + .expect("native_module should have set gas_metadata"); + + // Recreate the program registry as it can't be moved out of native module. + let program_registry = ProgramRegistry::new(sierra_program)?; + + let library = unsafe { Library::new(library_output_path)? }; + + Ok(AotNativeExecutor::new( + library, + program_registry, + gas_metadata, + )) +} + +fn setup_native_cache_dir() -> PathBuf { + let mut path: PathBuf = match std::env::var("NATIVE_CACHE_DIR") { + Ok(path) => path.into(), + Err(_err) => { + let mut path = std::env::current_dir().unwrap(); + path.push("native_cache"); + path + } + }; + let _ = fs::create_dir_all(&path); + path +} + + +/// Load a contract that is already compiled. +/// +/// Returns None if the contract does not exist at the output_path. +/// +/// To compile and load a contract use [persist_from_native_module] instead. +fn load_compiled_contract( + sierra_program: &Program, + library_output_path: &PathBuf, +) -> Option>> { + fn load( + sierra_program: &Program, + library_output_path: &PathBuf, + ) -> Result> { + let has_gas_builtin = sierra_program + .type_declarations + .iter() + .any(|decl| decl.long_id.generic_id.0.as_str() == "GasBuiltin"); + let config = has_gas_builtin.then_some(Default::default()); + let gas_metadata = GasMetadata::new(sierra_program, config)?; + let program_registry = ProgramRegistry::new(sierra_program)?; + let library = unsafe { Library::new(library_output_path)? }; + Ok(AotNativeExecutor::new( + library, + program_registry, + gas_metadata, + )) + } + + library_output_path + .is_file() + .then_some(load(sierra_program, library_output_path)) +} + +/// Compiled Native contracts + +/// Load a compiled native contract into memory +/// +/// Tries to load the compiled contract class from library_output_path if it +/// exists, otherwise it will compile the raw_contract_class, load it into memory +/// and save the compilation artifact to library_output_path. +fn native_try_from_json_string( + raw_contract_class: &str, + library_output_path: &PathBuf, +) -> Result> { + fn compile_and_load( + sierra_program: Program, + library_output_path: &PathBuf, + ) -> Result> { + println!("Compiling native contract"); + let native_context = NativeContext::new(); + // Ignore the debug names, that might cause conflicts when retrieving entrypoints upon execution of blockifier. + let native_module = native_context.compile(&sierra_program, false)?; + + persist_from_native_module(native_module, &sierra_program, library_output_path) + } + + let sierra_contract_class: cairo_lang_starknet_classes::contract_class::ContractClass = + serde_json::from_str(raw_contract_class)?; + + // todo(rodro): we are having two instances of a sierra program, one it's object form + // and another in its felt encoded form. This can be avoided by either: + // 1. Having access to the encoding/decoding functions + // 2. Refactoring the code on the Cairo mono-repo + + let sierra_program = sierra_contract_class.extract_sierra_program()?; + + // todo(xrvdg) lift this match out of the function once we do not need sierra_program anymore + let executor = match load_compiled_contract(&sierra_program, library_output_path) { + Some(executor) => { + println!("Loaded cached compiled contract from {:?}", library_output_path); + executor.or_else(|_err| compile_and_load(sierra_program, library_output_path)) + } + None => { + compile_and_load(sierra_program, library_output_path) + }, + }?; + + Ok(NativeContractClassV1::new(executor, sierra_contract_class)?) +} + + +pub fn class_from_json_str( + raw_json: &str, + class_hash: ClassHash, +) -> Result { + println!("raw json length {}", raw_json.len()); + let class_def = raw_json.to_string(); + println!("class def parsed"); + + let class: ContractClass =if let Ok(class) = ContractClassV0::try_from_json_string(class_def.as_str()) { + class.into() + } else if let Ok(class) = ContractClassV1::try_from_json_string(class_def.as_str()) { + println!("v1 contract"); + class.into() + } else if let Ok(class) = { + println!("native contract"); + let library_output_path = generate_library_path(class_hash); + native_try_from_json_string(class_def.as_str(), &library_output_path) + } { + class.into() + } else { + return Err("not a valid contract class".to_string()); + }; + + Ok(class) + + } diff --git a/crates/sequencer/src/state.rs b/crates/sequencer/src/state.rs index 4065ae7c..cea4bf99 100644 --- a/crates/sequencer/src/state.rs +++ b/crates/sequencer/src/state.rs @@ -1,6 +1,6 @@ use crate::commit::Committer; use crate::serde::SerializableState; -use blockifier::execution::contract_class::ContractClass; +use blockifier::execution::contract_class::{ContractClass, NativeContractClassV1}; use blockifier::state::errors::StateError; use blockifier::state::state_api::{ State as BlockifierState, StateReader as BlockifierStateReader, StateResult, @@ -113,6 +113,11 @@ impl BlockifierState for &mut State { class_hash: ClassHash, contract_class: ContractClass, ) -> StateResult<()> { + match &contract_class { + &ContractClass::V0(_) => println!("Setting V0 contract class"), + &ContractClass::V1(_) => println!("Setting V1 contract class"), + &ContractClass::V1Native(_) => println!("Setting V1Native contract class"), + }; self.classes.insert(class_hash, contract_class); Ok(()) } @@ -165,10 +170,11 @@ impl BlockifierStateReader for &mut State { /// /// If the compiled class is not declared. fn get_compiled_contract_class(&self, class_hash: ClassHash) -> StateResult { - self.classes + let res = self.classes .get(&class_hash) .cloned() - .ok_or_else(|| StateError::UndeclaredClassHash(class_hash)) + .ok_or_else(|| StateError::UndeclaredClassHash(class_hash))?; + Ok(res) } /// # Errors @@ -182,6 +188,8 @@ impl BlockifierStateReader for &mut State { } } + + #[cfg(test)] mod tests { use blockifier::execution::contract_class::ContractClassV0;