diff --git a/Cargo.lock b/Cargo.lock index e44656455..09f85fcf0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,7 +65,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -198,7 +198,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -513,7 +513,7 @@ checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -643,7 +643,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.39", + "syn 2.0.48", "which", ] @@ -666,7 +666,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.39", + "syn 2.0.48", "which", ] @@ -860,9 +860,9 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24abd6752c41f3d2276fba63fa0434875ccf6e7cbcdebfebc790db1201eb0892" +checksum = "40058b275150a66c15f39aa09f2a79be7acd089e526beca79ded7a29aafd0ae9" dependencies = [ "cairo-lang-utils", "indoc", @@ -877,9 +877,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5699f44b183ddc2982976efdd72bbdfafc13a64f9593b44eb86f8a335f3b90da" +checksum = "dd38cbddb149d5417b3b9a655489de356f29b15be2637e4270c95ea5fcc51e87" dependencies = [ "anyhow", "cairo-lang-defs", @@ -900,18 +900,18 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a52b381fab22b723818692fa93aafc2e1490a79a4c8bd856e8996f1253f16a8" +checksum = "22ea67db5af077ca6817d1db5020ab450f28aff2d3ffbc55b6d3a5132e9bc0e1" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d436dcaa5a3ea69f60b990036d23dc3e54adc623c14cff824cb1230f974ce44" +checksum = "ed0f8ddae7bebbec634f6b0a7040a1c58003ec13be541e00e5e7ded04788c6d2" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -926,9 +926,9 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07771c7268044b6a7be828a4f4938bb823944efe6668a974bf5e52a6801ef366" +checksum = "64269b3fd33c17920cb6b300257439a885b1251bddab78cfcfea02031ad10eb6" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -938,9 +938,9 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fc8c224c0aaadc01c961fac234e8d8d3563a8fbb8544186a69969765a0c2a5" +checksum = "15f57f448a8ccd1ff77f663941bd8310e3ce4e30fdcfd6ea4ee7d897df0fab04" dependencies = [ "cairo-lang-utils", "good_lp", @@ -948,9 +948,9 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d62a519bd68f158cd1b5ee2f1f1dc2aa916a8dcb14914444846d39ff8fb33789" +checksum = "439a6506fb2f749964aac614f5295aa4fa1e18123aea0d1e09a03ea0311b3847" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -962,9 +962,9 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "989744e09f351ff24a0bc076dba8e3420ab957b99edc46acde58a484ebb09ed9" +checksum = "5c38232c57885ef108395e784aa0fc8d9e23a5a2b0f985484f10d6d9ef85c83e" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -988,9 +988,9 @@ dependencies = [ [[package]] name = "cairo-lang-parser" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7be5b262ae2d11b4d5783a8b66d8e31cbeab45bb4e14d6ddb13ba280e9c41824" +checksum = "1bcaec01565917823193ea2db9f239c5d496987a006f7be894fd757216d64d94" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -1008,9 +1008,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebcfe1e269ab2027bad187d9c61c7e1e324374c722b75f3a7d7fba77c977f8ca" +checksum = "428c7ce26429eaf08afe7831aab3e61c5858e88250227cdabfec8307cd25bea2" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -1027,20 +1027,20 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9bc4f93f28bda29d879acb9b9e26b32108591225a507ffb5aff9bbf58524c4f" +checksum = "97efc9847766adc92e0c6f21dfaab26960c66579978f5767c5995950b40b73c6" dependencies = [ "cairo-lang-debug", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] name = "cairo-lang-project" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d490a3d00dd45228c1691c390f177449b45a907a2cb4b3ad8f305faea82a0c" +checksum = "93b3ff44aee12e08955d2c107eb087cf3b238db8f3d306bdd2e3be95bb149880" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -1079,9 +1079,9 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcc25adf813972129dcac6c7d87026d47644f3d4e975c042d27e1166a2a0489" +checksum = "a6cd57e7e6d437419643e075297532d98789f75d12824ee02ec4144278870bfc" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1104,9 +1104,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cc9571dbb143e33979fc02d38bbb4d7b608d6f53cde585b08551bbedfb0c217" +checksum = "68a035e4b4b961df135fc3ef81c4b1d5e1efa19a6a3245862860a11856af46bc" dependencies = [ "anyhow", "cairo-lang-utils", @@ -1129,9 +1129,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16894bfe0072f82b549e4b2be42c7dc8f0611ac5049dfb069b95b10c51ec7cb5" +checksum = "f68b38763f995b27b2fb824a90e43b5671af17e015af8dfeb13eabad8149eba2" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1143,9 +1143,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71fbc8baef18b3c315d3fb7a0cf59f0ee14df5cefc7dd147598248cdb7b2252d" +checksum = "19187cf2ef439fa1abcc65dac87e408482ae8a124748558e2d760ab7ce5b7333" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1157,9 +1157,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75700bf5fd1c1cdd8ca29af338c65de8b03c905472f9bdce22b3034f3f3755d9" +checksum = "210fcedd39d513d4fdcd727156de179dc640ee27dca8e5bba076aa514cb70fe4" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1181,9 +1181,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0bc8edaf95bdb9577c6b801c36b24538ec08042e1d74b98fc08d50621427061" +checksum = "fdea72b0699e040c1a56ed89878904d44184fc66208ce3da77dc78d4e34c33f9" dependencies = [ "assert_matches", "cairo-felt", @@ -1202,9 +1202,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50b028f3e06e150005e82b07500d4ea509ee8350f841d5645fbcf00bb49c4537" +checksum = "a70bd365647251e18669bb7e702a3e48455ba4d5712959ca11d16ddead65580b" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -1212,9 +1212,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f55ffe2cbd277b6f3040e23bde028ae0b68e8e4910a9dd1c2f78ed668974d2a" +checksum = "b95bc3c2dd33256fe168706189f58d34214ab2b970b038dd27de38b2b2670a05" dependencies = [ "anyhow", "cairo-felt", @@ -1249,9 +1249,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6d745c72ac1cef893239d36bc749742d2622136ffc1434a2c70b07096d02de0" +checksum = "23fe738fde316bc47a663adb0b6aabe4b8b43a2bcaee4824f220ac32c496672d" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1265,9 +1265,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.4.3" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c9f119185b736b5318325e7a0fc1378b706116c1c558e1ced1bdf55367813b" +checksum = "caa5e57952da2c330df7e63181d57b80e639096e061dff2c30730b7f7a124dda" dependencies = [ "genco", "xshell", @@ -1275,9 +1275,9 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.4.3" +version = "2.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343ac08a5b9d34c9f4bbac7249453a31edad4cf4ff54487197cc344f8293dc4f" +checksum = "f12291945d9230ce82f6e658537fbc5cc34920b19283dfff8e814154edd378eb" dependencies = [ "indexmap 2.1.0", "itertools 0.11.0", @@ -1291,7 +1291,7 @@ dependencies = [ [[package]] name = "cairo-native" version = "0.1.0" -source = "git+https://github.com/lambdaclass/cairo_native?rev=5e003699e53003c03b848e3001f1d4ec0d7007ed#5e003699e53003c03b848e3001f1d4ec0d7007ed" +source = "git+https://github.com/lambdaclass/cairo_native?rev=a2e6d118af9a54295ef1ca4d693b98e54ffc3b0f#a2e6d118af9a54295ef1ca4d693b98e54ffc3b0f" dependencies = [ "bumpalo", "cairo-lang-compiler", @@ -1319,6 +1319,7 @@ dependencies = [ "mlir-sys", "num-bigint", "num-traits 0.2.17", + "serde", "starknet-types-core", "tempfile", "thiserror", @@ -1329,7 +1330,7 @@ dependencies = [ [[package]] name = "cairo-native-runtime" version = "0.1.0" -source = "git+https://github.com/lambdaclass/cairo_native?rev=5e003699e53003c03b848e3001f1d4ec0d7007ed#5e003699e53003c03b848e3001f1d4ec0d7007ed" +source = "git+https://github.com/lambdaclass/cairo_native?rev=a2e6d118af9a54295ef1ca4d693b98e54ffc3b0f#a2e6d118af9a54295ef1ca4d693b98e54ffc3b0f" dependencies = [ "cairo-lang-runner", "lazy_static", @@ -1350,7 +1351,7 @@ dependencies = [ "bitvec", "cairo-felt", "generic-array", - "hashbrown 0.14.3", + "hashbrown 0.14.2", "hex", "keccak", "lazy_static", @@ -1382,7 +1383,7 @@ dependencies = [ "cairo-lang-casm", "cairo-lang-starknet", "generic-array", - "hashbrown 0.14.3", + "hashbrown 0.14.2", "hex", "keccak", "lazy_static", @@ -1463,9 +1464,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.10" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fffed7514f420abec6d183b1d3acfd9099c79c3a10a06ade4f8203f1411272" +checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" dependencies = [ "clap_builder", "clap_derive", @@ -1473,9 +1474,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.9" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63361bae7eef3771745f02d8d892bec2fee5f6e34af316ba556e7f97a7069ff1" +checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" dependencies = [ "anstream", "anstyle", @@ -1493,7 +1494,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -1654,14 +1655,20 @@ dependencies = [ ] [[package]] -name = "crossbeam-utils" -version = "0.8.16" +name = "crossbeam-channel" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b" dependencies = [ - "cfg-if", + "crossbeam-utils", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + [[package]] name = "crunchy" version = "0.2.2" @@ -1696,7 +1703,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37e366bff8cd32dd8754b0991fb66b279dc48f598c3a18914852a6673deef583" dependencies = [ "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -1753,7 +1760,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -1775,7 +1782,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -1797,7 +1804,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown 0.14.3", + "hashbrown 0.14.2", "lock_api", "once_cell", "parking_lot_core 0.9.9", @@ -1933,7 +1940,7 @@ dependencies = [ "enum-ordinalize", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -1989,7 +1996,7 @@ checksum = "05aa0010e0e391b9a82dc87bfc4dbee3cb8260eec12ad9d83c12788299fa9093" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2000,12 +2007,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.48.0", ] [[package]] @@ -2027,7 +2034,7 @@ dependencies = [ "sha2", "sha3", "thiserror", - "uuid", + "uuid 0.8.2", ] [[package]] @@ -2109,9 +2116,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -2215,7 +2222,7 @@ checksum = "d4cf186fea4af17825116f72932fe52cce9a13bae39ff63b4dc0cfdb3fb4bde1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2255,9 +2262,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "glob" @@ -2314,9 +2321,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ "ahash 0.8.6", "allocator-api2", @@ -2498,9 +2505,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -2574,7 +2581,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.2", "serde", ] @@ -2615,6 +2622,26 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "ipc-channel" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ab3a34c91b7e84a72643bd75d1bac3afd241f78f9859fe0b5e5b2a6a75732c2" +dependencies = [ + "bincode 1.3.3", + "crossbeam-channel", + "fnv", + "lazy_static", + "libc", + "mio", + "rand", + "sc", + "serde", + "tempfile", + "uuid 1.7.0", + "windows", +] + [[package]] name = "ipnet" version = "2.9.0" @@ -2676,9 +2703,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" dependencies = [ "wasm-bindgen", ] @@ -2881,7 +2908,7 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.2", ] [[package]] @@ -2926,7 +2953,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.39", + "syn 2.0.48", "tblgen", "unindent", ] @@ -3291,9 +3318,9 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "percent-encoding" -version = "2.3.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "petgraph" @@ -3335,7 +3362,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -3445,7 +3472,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -3496,9 +3523,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -3514,9 +3541,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -3901,6 +3928,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "sc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "010e18bd3bfd1d45a7e666b236c78720df0d9a7698ebaa9c1c559961eb60a38b" + [[package]] name = "schemars" version = "0.8.16" @@ -3962,22 +3995,22 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -4076,7 +4109,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -4088,7 +4121,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -4364,7 +4397,7 @@ checksum = "af6527b845423542c8a16e060ea1bc43f67229848e7cd4c4d80be994a84220ce" dependencies = [ "starknet-curve 0.4.0", "starknet-ff", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -4407,7 +4440,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f66fe05edab7ee6752a0aff3e14508001191083f3c6d0b6fa14f7008a96839b0" dependencies = [ "starknet-core 0.7.2", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -4516,6 +4549,7 @@ dependencies = [ "flate2", "getset", "hex", + "ipc-channel", "keccak", "lazy_static", "lru 0.11.1", @@ -4534,7 +4568,9 @@ dependencies = [ "starknet_api", "thiserror", "tracing", + "tracing-appender", "tracing-subscriber", + "uuid 1.7.0", ] [[package]] @@ -4600,9 +4636,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.39" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -4722,7 +4758,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -4733,7 +4769,7 @@ checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", "test-case-core", ] @@ -4754,7 +4790,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -4866,7 +4902,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -4956,6 +4992,18 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-appender" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" +dependencies = [ + "crossbeam-channel", + "thiserror", + "time", + "tracing-subscriber", +] + [[package]] name = "tracing-attributes" version = "0.1.27" @@ -4964,7 +5012,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -5038,9 +5086,9 @@ dependencies = [ [[package]] name = "unescaper" -version = "0.1.3" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8f0f68e58d297ba8b22b8b5a96a87b863ba6bb46aaf51e19a4b02c5a6dd5b7f" +checksum = "a96a44ae11e25afb520af4534fd7b0bd8cd613e35a78def813b8cf41631fa3c8" dependencies = [ "thiserror", ] @@ -5104,9 +5152,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "2.9.1" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cdd25c339e200129fe4de81451814e5228c9b771d57378817d6117cc2b3f97" +checksum = "7830e33f6e25723d41a63f77e434159dad02919f18f55a512b5f16f3b1d77138" dependencies = [ "base64 0.21.5", "flate2", @@ -5122,9 +5170,9 @@ dependencies = [ [[package]] name = "url" -version = "2.5.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", @@ -5153,6 +5201,16 @@ dependencies = [ "serde", ] +[[package]] +name = "uuid" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +dependencies = [ + "getrandom", + "serde", +] + [[package]] name = "valuable" version = "0.1.0" @@ -5192,9 +5250,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -5202,24 +5260,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.39" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" dependencies = [ "cfg-if", "js-sys", @@ -5229,9 +5287,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -5239,28 +5297,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "web-sys" -version = "0.3.66" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" dependencies = [ "js-sys", "wasm-bindgen", @@ -5268,9 +5326,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.3" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" [[package]] name = "which" @@ -5315,6 +5373,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-core" version = "0.51.1" @@ -5342,15 +5409,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.0", -] - [[package]] name = "windows-targets" version = "0.42.2" @@ -5381,21 +5439,6 @@ dependencies = [ "windows_x86_64_msvc 0.48.5", ] -[[package]] -name = "windows-targets" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" -dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", -] - [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -5408,12 +5451,6 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" - [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -5426,12 +5463,6 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" - [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -5444,12 +5475,6 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" -[[package]] -name = "windows_i686_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" - [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -5462,12 +5487,6 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" -[[package]] -name = "windows_i686_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" - [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -5480,12 +5499,6 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" - [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -5498,12 +5511,6 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" - [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -5516,12 +5523,6 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" - [[package]] name = "winnow" version = "0.5.19" @@ -5603,7 +5604,7 @@ checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -5623,7 +5624,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index edeec0b6d..51a0244c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ metrics = [] # Disclaimer: This feature enables state modifications being applied on reverted and failings txs, and also disables address availability check when deploying contracts. # Only use for benchmarking using the replay binary replay_benchmark = [] +cairo-native = ["dep:ipc-channel", "dep:tracing-appender", "dep:cairo-native", "dep:uuid"] [workspace] members = [ @@ -43,8 +44,10 @@ cairo-lang-runner = { workspace = true } cairo-lang-sierra = { workspace = true } cairo-lang-starknet = { workspace = true } cairo-lang-utils = { workspace = true } -cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "5e003699e53003c03b848e3001f1d4ec0d7007ed", optional = true } - +cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "a2e6d118af9a54295ef1ca4d693b98e54ffc3b0f", features = ["with-serde"], optional = true } +ipc-channel = { version = "0.18.0", features = ["memfd"], optional = true } +tracing-appender = { version = "0.2.3", optional = true} +uuid = { version = "1.6.1", features = ["serde", "v4"], optional = true } cairo-vm = { workspace = true } flate2 = "1.0.25" @@ -70,6 +73,7 @@ starknet_api = { workspace = true } starknet-crypto = "0.6.1" thiserror = { workspace = true } tracing = "0.1.37" +tracing-subscriber = "0.3.17" [dev-dependencies] assert_matches = "1.5.0" @@ -88,6 +92,11 @@ path = "src/bin/native_bench.rs" name = "cairo_native" required-features = ["cairo-native"] +[[bin]] +path = "src/bin/native_executor.rs" +name = "cairo_native_executor" +required-features = ["cairo-native"] + [[bench]] path = "bench/yas.rs" name = "yas" diff --git a/bench/internals.rs b/bench/internals.rs index 440c986d8..d474bbb2e 100644 --- a/bench/internals.rs +++ b/bench/internals.rs @@ -116,6 +116,8 @@ pub fn deploy_account( block_context, #[cfg(feature = "cairo-native")] Some(program_cache.clone()), + #[cfg(feature = "cairo-native")] + None, ) }) .unwrap(); @@ -158,6 +160,8 @@ pub fn declare( block_context, #[cfg(feature = "cairo-native")] Some(program_cache.clone()), + #[cfg(feature = "cairo-native")] + None, ) }) .unwrap(); @@ -207,6 +211,8 @@ pub fn deploy( block_context, #[cfg(feature = "cairo-native")] Some(program_cache.clone()), + #[cfg(feature = "cairo-native")] + None, ) }) .unwrap(); @@ -254,6 +260,8 @@ pub fn invoke( block_context, #[cfg(feature = "cairo-native")] Some(program_cache.clone()), + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -282,6 +290,8 @@ pub fn invoke( 2_000_000, #[cfg(feature = "cairo-native")] Some(program_cache.clone()), + #[cfg(feature = "cairo-native")] + None, ) }) .unwrap(); diff --git a/bench/yas.rs b/bench/yas.rs index f18de935d..3b4ed81a4 100644 --- a/bench/yas.rs +++ b/bench/yas.rs @@ -385,6 +385,8 @@ where &BlockContext::default(), #[cfg(feature = "cairo-native")] Some(program_cache), + #[cfg(feature = "cairo-native")] + None, )?; // Ensure the execution was successful. @@ -426,6 +428,8 @@ where &BlockContext::default(), #[cfg(feature = "cairo-native")] Some(program_cache), + #[cfg(feature = "cairo-native")] + None, )?; // Ensure the execution was successful. @@ -467,6 +471,8 @@ where &BlockContext::default(), #[cfg(feature = "cairo-native")] Some(program_cache), + #[cfg(feature = "cairo-native")] + None, )?; // Ensure the execution was successful. @@ -508,6 +514,8 @@ where &BlockContext::default(), #[cfg(feature = "cairo-native")] Some(program_cache), + #[cfg(feature = "cairo-native")] + None, )?; // Ensure the execution was successful. @@ -560,6 +568,8 @@ where u64::MAX.into(), #[cfg(feature = "cairo-native")] Some(program_cache), + #[cfg(feature = "cairo-native")] + None, )?; // Ensure the execution was successful. @@ -607,6 +617,8 @@ where u64::MAX.into(), #[cfg(feature = "cairo-native")] Some(program_cache), + #[cfg(feature = "cairo-native")] + None, )?; // Ensure the execution was successful. @@ -646,6 +658,8 @@ where u64::MAX.into(), #[cfg(feature = "cairo-native")] Some(program_cache), + #[cfg(feature = "cairo-native")] + None, )?; // Ensure the execution was successful. @@ -701,6 +715,8 @@ where u64::MAX.into(), #[cfg(feature = "cairo-native")] Some(program_cache), + #[cfg(feature = "cairo-native")] + None, )?; // Ensure the execution was successful. @@ -752,6 +768,8 @@ where u64::MAX.into(), #[cfg(feature = "cairo-native")] Some(program_cache), + #[cfg(feature = "cairo-native")] + None, )?; // Ensure the execution was successful. @@ -801,6 +819,8 @@ where u64::MAX.into(), #[cfg(feature = "cairo-native")] Some(program_cache), + #[cfg(feature = "cairo-native")] + None, )?; // Ensure the execution was successful. @@ -859,6 +879,8 @@ where u64::MAX.into(), #[cfg(feature = "cairo-native")] Some(program_cache), + #[cfg(feature = "cairo-native")] + None, )?; // Ensure the execution was successful. @@ -919,6 +941,8 @@ where u64::MAX.into(), #[cfg(feature = "cairo-native")] Some(program_cache), + #[cfg(feature = "cairo-native")] + None, )?; // Ensure the execution was successful. @@ -967,6 +991,8 @@ where u64::MAX.into(), #[cfg(feature = "cairo-native")] Some(program_cache), + #[cfg(feature = "cairo-native")] + None, )?; // Ensure the execution was successful. diff --git a/cli/src/main.rs b/cli/src/main.rs index cc35950f4..76b72b69a 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -207,6 +207,8 @@ fn invoke_parser( 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, )?; cached_state.apply_state_update(&StateDiff::from_cached_state(transactional_state.cache())?)?; @@ -274,6 +276,8 @@ fn call_parser( block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, )?; let call_info = call_info.ok_or(TransactionError::CallInfoIsNone)?; diff --git a/examples/contract_execution/src/main.rs b/examples/contract_execution/src/main.rs index c118376b9..7901d47e1 100644 --- a/examples/contract_execution/src/main.rs +++ b/examples/contract_execution/src/main.rs @@ -138,6 +138,8 @@ fn test_contract( &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .expect("Account Deploy Failed") .call_info @@ -179,6 +181,8 @@ fn test_contract( &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .expect("could not declare the contract class"); @@ -205,6 +209,8 @@ fn test_contract( 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .expect("could not deploy contract") .call_info @@ -254,6 +260,8 @@ fn test_contract( 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); diff --git a/examples/lru_cache/main.rs b/examples/lru_cache/main.rs index 7d3810fe4..42addf50f 100644 --- a/examples/lru_cache/main.rs +++ b/examples/lru_cache/main.rs @@ -70,6 +70,8 @@ fn run_contract( &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -88,6 +90,8 @@ fn run_contract( &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -113,6 +117,8 @@ fn run_contract( 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); diff --git a/fuzzer/src/main.rs b/fuzzer/src/main.rs index d2985ab0f..edae4a9e7 100644 --- a/fuzzer/src/main.rs +++ b/fuzzer/src/main.rs @@ -195,6 +195,8 @@ fn main() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!(call_info.unwrap(), expected_call_info); diff --git a/rpc_state_reader/src/sir_state_reader.rs b/rpc_state_reader/src/sir_state_reader.rs index 1c6adb7d5..70070bed4 100644 --- a/rpc_state_reader/src/sir_state_reader.rs +++ b/rpc_state_reader/src/sir_state_reader.rs @@ -310,7 +310,7 @@ pub fn execute_tx_configurable_with_state( #[cfg(not(feature = "cairo-native"))] let sir_execution = tx.execute(state, &block_context, u128::MAX)?; #[cfg(feature = "cairo-native")] - let sir_execution = tx.execute(state, &block_context, u128::MAX, None)?; + let sir_execution = tx.execute(state, &block_context, u128::MAX, None, None)?; Ok(sir_execution) } diff --git a/src/bin/deploy.rs b/src/bin/deploy.rs index 0a9d62428..04b04355b 100644 --- a/src/bin/deploy.rs +++ b/src/bin/deploy.rs @@ -61,6 +61,8 @@ fn main() { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); } diff --git a/src/bin/deploy_invoke.rs b/src/bin/deploy_invoke.rs index ba6a2b4a1..eeb3d7248 100644 --- a/src/bin/deploy_invoke.rs +++ b/src/bin/deploy_invoke.rs @@ -78,6 +78,8 @@ fn main() { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -112,6 +114,8 @@ fn main() { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -135,6 +139,8 @@ fn main() { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); diff --git a/src/bin/fibonacci.rs b/src/bin/fibonacci.rs index 22d7b10d9..e6d92846c 100644 --- a/src/bin/fibonacci.rs +++ b/src/bin/fibonacci.rs @@ -132,6 +132,8 @@ fn main() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); diff --git a/src/bin/invoke.rs b/src/bin/invoke.rs index 20d8222f7..51fce3cca 100644 --- a/src/bin/invoke.rs +++ b/src/bin/invoke.rs @@ -94,6 +94,8 @@ fn main() { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -117,6 +119,8 @@ fn main() { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); diff --git a/src/bin/invoke_with_cachedstate.rs b/src/bin/invoke_with_cachedstate.rs index 093366d73..90c69c4a2 100644 --- a/src/bin/invoke_with_cachedstate.rs +++ b/src/bin/invoke_with_cachedstate.rs @@ -71,6 +71,8 @@ fn main() { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -91,6 +93,8 @@ fn main() { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); diff --git a/src/bin/native_bench.rs b/src/bin/native_bench.rs index 82d9dcac8..44ec6a2ac 100644 --- a/src/bin/native_bench.rs +++ b/src/bin/native_bench.rs @@ -380,6 +380,8 @@ fn bench_erc20(executions: usize, bench_type: BenchType) { false, block_context.invoke_tx_max_n_steps(), Some(program_cache.clone()), + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -461,6 +463,8 @@ fn bench_erc20(executions: usize, bench_type: BenchType) { false, block_context.invoke_tx_max_n_steps(), Some(program_cache.clone()), + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -528,7 +532,12 @@ fn bench_erc20(executions: usize, bench_type: BenchType) { // this will create the account and after that, // we can extract its address. let account1_address = account1_deploy_tx - .execute(&mut state, &Default::default(), Some(program_cache.clone())) + .execute( + &mut state, + &Default::default(), + Some(program_cache.clone()), + None, + ) .expect("failed to execute the deployment of account 1") .validate_info .expect("validate_info missing") @@ -558,7 +567,12 @@ fn bench_erc20(executions: usize, bench_type: BenchType) { // execute the deploy_account transaction and retrieve the deployed account address. let _account2_address = account2_deploy_tx - .execute(&mut state, &Default::default(), Some(program_cache.clone())) + .execute( + &mut state, + &Default::default(), + Some(program_cache.clone()), + None, + ) .expect("failed to execute the deployment of account 2") .validate_info .expect("validate_info missing") @@ -631,6 +645,7 @@ fn execute( false, block_context.invoke_tx_max_n_steps(), Some(program_cache), + None, ) .unwrap() .call_info diff --git a/src/bin/native_executor.rs b/src/bin/native_executor.rs new file mode 100644 index 000000000..c34d0f466 --- /dev/null +++ b/src/bin/native_executor.rs @@ -0,0 +1,682 @@ +use std::{cell::RefCell, path::PathBuf, rc::Rc}; + +use cairo_lang_utils::ResultHelper; +use cairo_native::{ + context::NativeContext, + executor::JitNativeExecutor, + metadata::syscall_handler::SyscallHandlerMeta, + starknet::{StarkNetSyscallHandler, SyscallResult}, + utils::find_entry_point_by_idx, +}; +use cairo_vm::Felt252 as Felt; +use ipc_channel::ipc::{IpcOneShotServer, IpcReceiver, IpcSender}; +use starknet_in_rust::sandboxing::{Message, SyscallAnswer, SyscallRequest, WrappedMessage}; +use tracing::instrument; + +#[derive(Debug)] +struct SyscallHandler { + sender: IpcSender, + receiver: Rc>>, +} + +impl StarkNetSyscallHandler for SyscallHandler { + #[instrument(skip(self))] + fn get_block_hash(&mut self, block_number: u64, gas: &mut u128) -> SyscallResult { + self.sender + .send( + Message::SyscallRequest(SyscallRequest::GetBlockHash { + block_number, + gas: *gas, + }) + .wrap() + .unwrap(), + ) + .expect("failed to send"); + let result = self + .receiver + .borrow() + .recv() + .on_err(|e| tracing::error!("error receiving: {:?}", e)) + .unwrap() + .to_msg() + .unwrap(); + + if let Message::SyscallAnswer(SyscallAnswer::GetBlockHash { + result, + remaining_gas, + }) = result + { + *gas = remaining_gas; + result + } else { + tracing::error!("wrong message received: {:#?}", result); + panic!(); + } + } + + #[instrument(skip(self))] + fn get_execution_info( + &mut self, + gas: &mut u128, + ) -> SyscallResult { + self.sender + .send( + Message::SyscallRequest(SyscallRequest::GetExecutionInfo { gas: *gas }) + .wrap() + .unwrap(), + ) + .expect("failed to send"); + let result = self + .receiver + .borrow() + .recv() + .on_err(|e| tracing::error!("error receiving: {:?}", e)) + .unwrap() + .to_msg() + .unwrap(); + + if let Message::SyscallAnswer(SyscallAnswer::GetExecutionInfo { + result, + remaining_gas, + }) = result + { + *gas = remaining_gas; + result + } else { + tracing::error!("wrong message received: {:#?}", result); + panic!(); + } + } + + fn deploy( + &mut self, + class_hash: Felt, + contract_address_salt: Felt, + calldata: &[Felt], + deploy_from_zero: bool, + gas: &mut u128, + ) -> SyscallResult<(Felt, Vec)> { + self.sender + .send( + Message::SyscallRequest(SyscallRequest::Deploy { + class_hash, + contract_address_salt, + calldata: calldata.to_vec(), + deploy_from_zero, + gas: *gas, + }) + .wrap() + .unwrap(), + ) + .expect("failed to send"); + let result = self + .receiver + .borrow() + .recv() + .on_err(|e| tracing::error!("error receiving: {:?}", e)) + .unwrap() + .to_msg() + .unwrap(); + + if let Message::SyscallAnswer(SyscallAnswer::Deploy { + result, + remaining_gas, + }) = result + { + *gas = remaining_gas; + result + } else { + tracing::error!("wrong message received: {:#?}", result); + panic!(); + } + } + + fn replace_class(&mut self, class_hash: Felt, gas: &mut u128) -> SyscallResult<()> { + self.sender + .send( + Message::SyscallRequest(SyscallRequest::ReplaceClass { + class_hash, + gas: *gas, + }) + .wrap() + .unwrap(), + ) + .expect("failed to send"); + let result = self + .receiver + .borrow() + .recv() + .on_err(|e| tracing::error!("error receiving: {:?}", e)) + .unwrap() + .to_msg() + .unwrap(); + + if let Message::SyscallAnswer(SyscallAnswer::ReplaceClass { + result, + remaining_gas, + }) = result + { + *gas = remaining_gas; + result + } else { + tracing::error!("wrong message received: {:#?}", result); + panic!(); + } + } + + fn library_call( + &mut self, + class_hash: Felt, + function_selector: Felt, + calldata: &[Felt], + gas: &mut u128, + ) -> SyscallResult> { + self.sender + .send( + Message::SyscallRequest(SyscallRequest::LibraryCall { + class_hash, + function_selector, + calldata: calldata.to_vec(), + gas: *gas, + }) + .wrap() + .unwrap(), + ) + .expect("failed to send"); + let result = self + .receiver + .borrow() + .recv() + .on_err(|e| tracing::error!("error receiving: {:?}", e)) + .unwrap() + .to_msg() + .unwrap(); + + if let Message::SyscallAnswer(SyscallAnswer::LibraryCall { + result, + remaining_gas, + }) = result + { + *gas = remaining_gas; + result + } else { + tracing::error!("wrong message received: {:#?}", result); + panic!(); + } + } + + fn call_contract( + &mut self, + address: Felt, + entry_point_selector: Felt, + calldata: &[Felt], + gas: &mut u128, + ) -> SyscallResult> { + self.sender + .send( + Message::SyscallRequest(SyscallRequest::CallContract { + address, + entry_point_selector, + calldata: calldata.to_vec(), + gas: *gas, + }) + .wrap() + .unwrap(), + ) + .expect("failed to send"); + let result = self + .receiver + .borrow() + .recv() + .on_err(|e| tracing::error!("error receiving: {:?}", e)) + .unwrap() + .to_msg() + .unwrap(); + + if let Message::SyscallAnswer(SyscallAnswer::CallContract { + result, + remaining_gas, + }) = result + { + *gas = remaining_gas; + result + } else { + tracing::error!("wrong message received: {:#?}", result); + panic!(); + } + } + + fn storage_read( + &mut self, + address_domain: u32, + address: Felt, + gas: &mut u128, + ) -> SyscallResult { + self.sender + .send( + Message::SyscallRequest(SyscallRequest::StorageRead { + address_domain, + address, + gas: *gas, + }) + .wrap() + .unwrap(), + ) + .expect("failed to send"); + let result = self + .receiver + .borrow() + .recv() + .on_err(|e| tracing::error!("error receiving: {:?}", e)) + .unwrap() + .to_msg() + .unwrap(); + + if let Message::SyscallAnswer(SyscallAnswer::StorageRead { + result, + remaining_gas, + }) = result + { + *gas = remaining_gas; + result + } else { + tracing::error!("wrong message received: {:#?}", result); + panic!(); + } + } + + fn storage_write( + &mut self, + address_domain: u32, + address: Felt, + value: Felt, + gas: &mut u128, + ) -> SyscallResult<()> { + self.sender + .send( + Message::SyscallRequest(SyscallRequest::StorageWrite { + address_domain, + address, + value, + gas: *gas, + }) + .wrap() + .unwrap(), + ) + .expect("failed to send"); + let result = self + .receiver + .borrow() + .recv() + .on_err(|e| tracing::error!("error receiving: {:?}", e)) + .unwrap() + .to_msg() + .unwrap(); + + if let Message::SyscallAnswer(SyscallAnswer::StorageWrite { + result, + remaining_gas, + }) = result + { + *gas = remaining_gas; + result + } else { + tracing::error!("wrong message received: {:#?}", result); + panic!(); + } + } + + fn emit_event(&mut self, keys: &[Felt], data: &[Felt], gas: &mut u128) -> SyscallResult<()> { + self.sender + .send( + Message::SyscallRequest(SyscallRequest::EmitEvent { + keys: keys.to_vec(), + data: data.to_vec(), + gas: *gas, + }) + .wrap() + .unwrap(), + ) + .expect("failed to send"); + let result = self + .receiver + .borrow() + .recv() + .on_err(|e| tracing::error!("error receiving: {:?}", e)) + .unwrap() + .to_msg() + .unwrap(); + + if let Message::SyscallAnswer(SyscallAnswer::EmitEvent { + result, + remaining_gas, + }) = result + { + *gas = remaining_gas; + result + } else { + tracing::error!("wrong message received: {:#?}", result); + panic!(); + } + } + + fn send_message_to_l1( + &mut self, + to_address: Felt, + payload: &[Felt], + gas: &mut u128, + ) -> SyscallResult<()> { + self.sender + .send( + Message::SyscallRequest(SyscallRequest::SendMessageToL1 { + to_address, + payload: payload.to_vec(), + gas: *gas, + }) + .wrap() + .unwrap(), + ) + .expect("failed to send"); + let result = self + .receiver + .borrow() + .recv() + .on_err(|e| tracing::error!("error receiving: {:?}", e)) + .unwrap() + .to_msg() + .unwrap(); + + if let Message::SyscallAnswer(SyscallAnswer::SendMessageToL1 { + result, + remaining_gas, + }) = result + { + *gas = remaining_gas; + result + } else { + tracing::error!("wrong message received: {:#?}", result); + panic!(); + } + } + + fn keccak( + &mut self, + input: &[u64], + gas: &mut u128, + ) -> SyscallResult { + self.sender + .send( + Message::SyscallRequest(SyscallRequest::Keccak { + input: input.to_vec(), + gas: *gas, + }) + .wrap() + .unwrap(), + ) + .expect("failed to send"); + let result = self + .receiver + .borrow() + .recv() + .on_err(|e| tracing::error!("error receiving: {:?}", e)) + .unwrap() + .to_msg() + .unwrap(); + + if let Message::SyscallAnswer(SyscallAnswer::Keccak { + result, + remaining_gas, + }) = result + { + *gas = remaining_gas; + result + } else { + tracing::error!("wrong message received: {:#?}", result); + panic!(); + } + } + + fn secp256k1_add( + &mut self, + _p0: cairo_native::starknet::Secp256k1Point, + _p1: cairo_native::starknet::Secp256k1Point, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256k1_get_point_from_x( + &self, + _x: cairo_native::starknet::U256, + _y_parity: bool, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256k1_get_xy( + &self, + _p: cairo_native::starknet::Secp256k1Point, + _gas: &mut u128, + ) -> SyscallResult<(cairo_native::starknet::U256, cairo_native::starknet::U256)> { + todo!() + } + + fn secp256k1_mul( + &self, + _p: cairo_native::starknet::Secp256k1Point, + _m: cairo_native::starknet::U256, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256k1_new( + &self, + _x: cairo_native::starknet::U256, + _y: cairo_native::starknet::U256, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256r1_add( + &self, + _p0: cairo_native::starknet::Secp256k1Point, + _p1: cairo_native::starknet::Secp256k1Point, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256r1_get_point_from_x( + &self, + _x: cairo_native::starknet::U256, + _y_parity: bool, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256r1_get_xy( + &self, + _p: cairo_native::starknet::Secp256k1Point, + _gas: &mut u128, + ) -> SyscallResult<(cairo_native::starknet::U256, cairo_native::starknet::U256)> { + todo!() + } + + fn secp256r1_mul( + &self, + _p: cairo_native::starknet::Secp256k1Point, + _m: cairo_native::starknet::U256, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256r1_new( + &mut self, + _x: cairo_native::starknet::U256, + _y: cairo_native::starknet::U256, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn pop_log(&mut self) { + todo!() + } + + fn set_account_contract_address(&mut self, _contract_address: Felt) { + todo!() + } + + fn set_block_number(&mut self, _block_number: u64) { + todo!() + } + + fn set_block_timestamp(&mut self, _block_timestamp: u64) { + todo!() + } + + fn set_caller_address(&mut self, _address: Felt) { + todo!() + } + + fn set_chain_id(&mut self, _chain_id: Felt) { + todo!() + } + + fn set_contract_address(&mut self, _address: Felt) { + todo!() + } + + fn set_max_fee(&mut self, _max_fee: u128) { + todo!() + } + + fn set_nonce(&mut self, _nonce: Felt) { + todo!() + } + + fn set_sequencer_address(&mut self, _address: Felt) { + todo!() + } + + fn set_signature(&mut self, _signature: &[Felt]) { + todo!() + } + + fn set_transaction_hash(&mut self, _transaction_hash: Felt) { + todo!() + } + + fn set_version(&mut self, _version: Felt) { + todo!() + } + + fn get_execution_info_v2( + &mut self, + _remaining_gas: &mut u128, + ) -> SyscallResult { + todo!() + } +} + +pub fn main() -> Result<(), Box> { + let mut args = std::env::args(); + + let pid = std::process::id(); + + let log_dir = PathBuf::from( + std::env::var("CAIRO_EXECUTOR_LOGDIR").unwrap_or("executor_logs/".to_string()), + ); + let file_appender = + tracing_appender::rolling::daily(log_dir, format!("cairo-executor.{pid}.log")); + + tracing_subscriber::fmt() + .with_writer(file_appender) + .with_ansi(false) + .init(); + + if args.len() < 2 { + tracing::error!("missing server ipc name"); + std::process::exit(1); + } + + let server = args.nth(1).unwrap(); + let (sv, name) = IpcOneShotServer::::new()?; + println!("{name}"); // print to let know + let sender = IpcSender::connect(server.clone())?; + sender.send(Message::Ping.wrap()?)?; + tracing::info!("connected to {server:?}"); + let (receiver, msg) = sv.accept()?; + let receiver = Rc::new(RefCell::new(receiver)); + tracing::info!("accepted {receiver:?}"); + assert_eq!(msg, Message::Ping.wrap()?); + + let native_context = NativeContext::new(); + tracing::info!("initialized native context"); + + let mut syscall_handler = SyscallHandler { + sender: sender.clone(), + receiver: receiver.clone(), + }; + + loop { + tracing::info!("waiting for message"); + + let message: Message = receiver.borrow().recv()?.to_msg()?; + + match message { + Message::ExecuteJIT { + id, + program, + inputs, + function_idx, + gas, + } => { + tracing::info!("Message: ExecuteJIT"); + sender.send(Message::Ack(id).wrap()?)?; + tracing::info!("sent ack: {:?}", id); + let program = program.into_v1()?.program; + let native_program = native_context.compile(&program)?; + + let entry_point_fn = find_entry_point_by_idx(&program, function_idx).unwrap(); + + let fn_id = &entry_point_fn.id; + + let native_executor = + JitNativeExecutor::from_native_module(native_program, Default::default()); + + let result = native_executor.invoke_contract_dynamic( + fn_id, + &inputs, + gas, + Some(&SyscallHandlerMeta::new(&mut syscall_handler)), + )?; + + tracing::info!("invoked with result: {:?}", result); + + sender.send(Message::ExecutionResult { id, result }.wrap()?)?; + + tracing::info!("sent result msg"); + } + Message::ExecutionResult { .. } => {} + Message::Ack(_) => {} + Message::Ping => { + tracing::info!("Message: Ping"); + sender.send(Message::Ping.wrap()?)?; + } + Message::Kill => { + tracing::info!("Message: KILL"); + break; + } + Message::SyscallRequest(_) => todo!(), + Message::SyscallAnswer(_) => todo!(), + } + } + + Ok(()) +} diff --git a/src/execution/execution_entry_point.rs b/src/execution/execution_entry_point.rs index 1d5edafdb..6ef5f630a 100644 --- a/src/execution/execution_entry_point.rs +++ b/src/execution/execution_entry_point.rs @@ -46,6 +46,7 @@ use cairo_vm::{ use std::sync::Arc; #[cfg(feature = "cairo-native")] use { + crate::sandboxing::IsolatedExecutor, crate::state::StateDiff, cairo_native::cache::{JitProgramCache, ProgramCache}, cairo_native::OptLevel, @@ -116,6 +117,7 @@ impl ExecutionEntryPoint { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&IsolatedExecutor>, ) -> Result where T: StateReader, @@ -174,6 +176,7 @@ impl ExecutionEntryPoint { block_context, &class_hash, program_cache, + sandbox, ) { Ok(call_info) => { state.apply_state_update(&StateDiff::from_cached_state( @@ -684,6 +687,7 @@ impl ExecutionEntryPoint { block_context: &BlockContext, class_hash: &ClassHash, program_cache: Rc>>, + sandbox: Option<&IsolatedExecutor>, ) -> Result { use cairo_native::{ executor::NativeExecutor, metadata::syscall_handler::SyscallHandlerMeta, @@ -753,6 +757,7 @@ impl ExecutionEntryPoint { block_context: block_context.clone(), program_cache: program_cache.clone(), resources_manager: Default::default(), + sandbox, }; let syscall_meta = SyscallHandlerMeta::new(&mut syscall_handler); diff --git a/src/lib.rs b/src/lib.rs index ecd36d287..3dc254e3a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,6 +46,8 @@ pub mod execution; pub mod hash_utils; pub mod parser_errors; pub mod runner; +#[cfg(feature = "cairo-native")] +pub mod sandboxing; pub mod serde_structs; pub mod services; pub mod state; @@ -68,6 +70,7 @@ pub fn simulate_transaction( #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result, TransactionError> { let mut cache_state = CachedState::new(Arc::new(state), contract_class_cache); let mut result = Vec::with_capacity(transactions.len()); @@ -85,6 +88,8 @@ pub fn simulate_transaction( remaining_gas, #[cfg(feature = "cairo-native")] program_cache.clone(), + #[cfg(feature = "cairo-native")] + sandbox, )?; result.push(tx_result); } @@ -100,6 +105,7 @@ pub fn estimate_fee( #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result, TransactionError> where T: StateReader, @@ -120,6 +126,8 @@ where 100_000_000, #[cfg(feature = "cairo-native")] program_cache.clone(), + #[cfg(feature = "cairo-native")] + sandbox, )?; if let Some(gas_usage) = transaction_result.actual_resources.get("l1_gas_usage") { result.push((transaction_result.actual_fee, *gas_usage)); @@ -133,6 +141,7 @@ where Ok(result) } +#[allow(clippy::too_many_arguments)] pub fn call_contract( contract_address: Felt252, entrypoint_selector: Felt252, @@ -143,6 +152,7 @@ pub fn call_contract( #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result, TransactionError> { let contract_address = Address(contract_address); let class_hash = state.get_class_hash_at(&contract_address)?; @@ -185,6 +195,8 @@ pub fn call_contract( block_context.invoke_tx_max_n_steps, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; let call_info = call_info.ok_or(TransactionError::CallInfoIsNone)?; @@ -199,6 +211,7 @@ pub fn estimate_message_fee( #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result<(u128, usize), TransactionError> where T: StateReader, @@ -214,6 +227,8 @@ where 1_000_000, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; let tx_fee = calculate_tx_fee( &transaction_result.actual_resources, @@ -235,6 +250,7 @@ pub fn execute_transaction( #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { tx.execute( state, @@ -242,6 +258,8 @@ pub fn execute_transaction( remaining_gas, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) } @@ -337,6 +355,8 @@ mod test { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!(estimated_fee[0], (2483, 2448)); @@ -387,6 +407,8 @@ mod test { Address(0.into()), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -446,6 +468,8 @@ mod test { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!(estimated_fee, (18485, 18471)); @@ -514,6 +538,8 @@ mod test { 1000000, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -642,6 +668,8 @@ mod test { false, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -751,6 +779,8 @@ mod test { false, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -804,6 +834,8 @@ mod test { false, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); } @@ -847,6 +879,8 @@ mod test { false, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); } @@ -888,6 +922,8 @@ mod test { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -921,6 +957,8 @@ mod test { false, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); } @@ -970,6 +1008,8 @@ mod test { false, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); } @@ -1018,6 +1058,8 @@ mod test { false, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); } @@ -1087,6 +1129,8 @@ mod test { false, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); } @@ -1147,6 +1191,8 @@ mod test { false, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -1157,6 +1203,8 @@ mod test { block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(), [(0, 1836), (0, 2448)] @@ -1179,6 +1227,8 @@ mod test { INITIAL_GAS_COST, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap_err(); @@ -1289,6 +1339,8 @@ mod test { false, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap()[0] .actual_fee; @@ -1306,6 +1358,8 @@ mod test { false, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap()[0] .actual_fee; diff --git a/src/sandboxing/mod.rs b/src/sandboxing/mod.rs new file mode 100644 index 000000000..721184d89 --- /dev/null +++ b/src/sandboxing/mod.rs @@ -0,0 +1,425 @@ +use std::{ + io::{BufRead, BufReader}, + path::Path, + process::{Child, Stdio}, +}; + +use cairo_lang_sierra::program::{Program, VersionedProgram}; +use cairo_vm::Felt252 as Felt; +use ipc_channel::ipc::{IpcOneShotServer, IpcReceiver, IpcSender}; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +use cairo_native::{ + execution_result::ContractExecutionResult, + starknet::{ExecutionInfo, StarkNetSyscallHandler, SyscallResult}, +}; + +#[allow(clippy::large_enum_variant)] +#[derive(Debug, Clone, Serialize, Deserialize)] +pub enum Message { + ExecuteJIT { + id: Uuid, + program: VersionedProgram, + inputs: Vec, + function_idx: usize, + gas: Option, + }, + ExecutionResult { + id: Uuid, + result: ContractExecutionResult, + }, + Ack(Uuid), + Ping, + Kill, + SyscallRequest(SyscallRequest), + SyscallAnswer(SyscallAnswer), +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub enum SyscallRequest { + GetBlockHash { + block_number: u64, + gas: u128, + }, + GetExecutionInfo { + gas: u128, + }, + Deploy { + class_hash: Felt, + contract_address_salt: Felt, + calldata: Vec, + deploy_from_zero: bool, + gas: u128, + }, + ReplaceClass { + class_hash: Felt, + gas: u128, + }, + LibraryCall { + class_hash: Felt, + function_selector: Felt, + calldata: Vec, + gas: u128, + }, + CallContract { + address: Felt, + entry_point_selector: Felt, + calldata: Vec, + gas: u128, + }, + EmitEvent { + keys: Vec, + data: Vec, + gas: u128, + }, + SendMessageToL1 { + to_address: Felt, + payload: Vec, + gas: u128, + }, + Keccak { + input: Vec, + gas: u128, + }, + StorageRead { + address_domain: u32, + address: Felt, + gas: u128, + }, + StorageWrite { + address_domain: u32, + address: Felt, + value: Felt, + gas: u128, + }, +} + +#[allow(clippy::large_enum_variant)] +#[derive(Debug, Clone, Serialize, Deserialize)] +pub enum SyscallAnswer { + GetBlockHash { + result: SyscallResult, + remaining_gas: u128, + }, + GetExecutionInfo { + result: SyscallResult, + remaining_gas: u128, + }, + Deploy { + result: SyscallResult<(Felt, Vec)>, + remaining_gas: u128, + }, + ReplaceClass { + result: SyscallResult<()>, + remaining_gas: u128, + }, + LibraryCall { + result: SyscallResult>, + remaining_gas: u128, + }, + CallContract { + result: SyscallResult>, + remaining_gas: u128, + }, + StorageRead { + result: SyscallResult, + remaining_gas: u128, + }, + StorageWrite { + result: SyscallResult<()>, + remaining_gas: u128, + }, + EmitEvent { + result: SyscallResult<()>, + remaining_gas: u128, + }, + SendMessageToL1 { + result: SyscallResult<()>, + remaining_gas: u128, + }, + Keccak { + result: SyscallResult, + remaining_gas: u128, + }, +} + +impl Message { + pub fn serialize(&self) -> Result { + serde_json::to_string(self) + } + + pub fn deserialize(value: &str) -> Result { + serde_json::from_str(value) + } + + pub fn wrap(&self) -> Result { + Ok(WrappedMessage::Message(self.serialize()?)) + } +} + +#[derive(Debug, Serialize, Deserialize, PartialEq)] +pub enum WrappedMessage { + Message(String), // ipc-channel uses bincode and doesnt support serializing Vecs +} + +impl WrappedMessage { + pub fn to_msg(self) -> Result { + match self { + WrappedMessage::Message(msg) => Message::deserialize(&msg), + } + } +} + +#[derive(Debug)] +pub struct IsolatedExecutor { + proc: Child, + sender: IpcSender, + receiver: IpcReceiver, +} + +impl IsolatedExecutor { + // "target/debug/cairo-executor" + pub fn new(executor_path: &Path) -> Result { + let (server, server_name) = IpcOneShotServer::new().unwrap(); + tracing::debug!("creating executor with: {:?}", executor_path); + + let mut cmd = std::process::Command::new(executor_path); + cmd.stdout(Stdio::piped()); + let mut proc = cmd.arg(server_name).spawn()?; + let stdout = proc.stdout.take().unwrap(); + let mut stdout = BufReader::new(stdout); + let mut client_name = String::new(); + stdout.read_line(&mut client_name)?; + + // first we accept the connection + let (receiver, msg) = server.accept().expect("failed to accept receiver"); + tracing::debug!("accepted receiver {receiver:?} with msg {msg:?}"); + // then we connect + tracing::debug!("connecting to {client_name}"); + let sender = IpcSender::connect(client_name.trim().to_string()).expect("failed to connect"); + sender.send(Message::Ping.wrap()?).unwrap(); + + Ok(Self { + proc, + sender, + receiver, + }) + } + + pub fn run_program( + &self, + program: Program, + inputs: Vec, + gas: Option, + function_idx: usize, + handler: &mut impl StarkNetSyscallHandler, + ) -> Result> { + tracing::debug!("running program"); + let id = Uuid::new_v4(); + + let msg = Message::ExecuteJIT { + id, + program: program.into_artifact(), + inputs, + gas, + function_idx, + }; + self.sender.send(msg.wrap()?)?; + + loop { + let msg = self.receiver.recv()?.to_msg()?; + match msg { + Message::ExecuteJIT { .. } => unreachable!(), + Message::ExecutionResult { + id: recv_id, + result, + } => { + assert_eq!(recv_id, id, "id mismatch"); + return Ok(result); + } + Message::Ack(recv_id) => { + assert_eq!(recv_id, id, "id mismatch"); + } + Message::Ping => unreachable!(), + Message::Kill => todo!(), + Message::SyscallRequest(request) => match request { + SyscallRequest::GetBlockHash { + block_number, + mut gas, + } => { + let result = handler.get_block_hash(block_number, &mut gas); + self.sender.send( + Message::SyscallAnswer(SyscallAnswer::GetBlockHash { + result, + remaining_gas: gas, + }) + .wrap()?, + )?; + } + SyscallRequest::GetExecutionInfo { mut gas } => { + let result = handler.get_execution_info(&mut gas); + self.sender.send( + Message::SyscallAnswer(SyscallAnswer::GetExecutionInfo { + result, + remaining_gas: gas, + }) + .wrap()?, + )?; + } + SyscallRequest::StorageRead { + address_domain, + address, + mut gas, + } => { + let result = handler.storage_read(address_domain, address, &mut gas); + self.sender.send( + Message::SyscallAnswer(SyscallAnswer::StorageRead { + result, + remaining_gas: gas, + }) + .wrap()?, + )?; + } + SyscallRequest::StorageWrite { + address_domain, + address, + value, + mut gas, + } => { + let result = + handler.storage_write(address_domain, address, value, &mut gas); + self.sender.send( + Message::SyscallAnswer(SyscallAnswer::StorageWrite { + result, + remaining_gas: gas, + }) + .wrap()?, + )?; + } + SyscallRequest::Deploy { + class_hash, + contract_address_salt, + calldata, + deploy_from_zero, + mut gas, + } => { + let result = handler.deploy( + class_hash, + contract_address_salt, + &calldata, + deploy_from_zero, + &mut gas, + ); + self.sender.send( + Message::SyscallAnswer(SyscallAnswer::Deploy { + result, + remaining_gas: gas, + }) + .wrap()?, + )?; + } + SyscallRequest::ReplaceClass { + class_hash, + mut gas, + } => { + let result = handler.replace_class(class_hash, &mut gas); + self.sender.send( + Message::SyscallAnswer(SyscallAnswer::ReplaceClass { + result, + remaining_gas: gas, + }) + .wrap()?, + )?; + } + SyscallRequest::LibraryCall { + class_hash, + function_selector, + calldata, + mut gas, + } => { + let result = handler.library_call( + class_hash, + function_selector, + &calldata, + &mut gas, + ); + self.sender.send( + Message::SyscallAnswer(SyscallAnswer::LibraryCall { + result, + remaining_gas: gas, + }) + .wrap()?, + )?; + } + SyscallRequest::CallContract { + address, + entry_point_selector, + calldata, + mut gas, + } => { + let result = handler.call_contract( + address, + entry_point_selector, + &calldata, + &mut gas, + ); + self.sender.send( + Message::SyscallAnswer(SyscallAnswer::CallContract { + result, + remaining_gas: gas, + }) + .wrap()?, + )?; + } + SyscallRequest::EmitEvent { + keys, + data, + mut gas, + } => { + let result = handler.emit_event(&keys, &data, &mut gas); + self.sender.send( + Message::SyscallAnswer(SyscallAnswer::EmitEvent { + result, + remaining_gas: gas, + }) + .wrap()?, + )?; + } + SyscallRequest::SendMessageToL1 { + to_address, + payload, + mut gas, + } => { + let result = handler.send_message_to_l1(to_address, &payload, &mut gas); + self.sender.send( + Message::SyscallAnswer(SyscallAnswer::SendMessageToL1 { + result, + remaining_gas: gas, + }) + .wrap()?, + )?; + } + SyscallRequest::Keccak { input, mut gas } => { + let result = handler.keccak(&input, &mut gas); + self.sender.send( + Message::SyscallAnswer(SyscallAnswer::Keccak { + result, + remaining_gas: gas, + }) + .wrap()?, + )?; + } + }, + Message::SyscallAnswer(_) => unreachable!(), + } + } + } +} + +impl Drop for IsolatedExecutor { + fn drop(&mut self) { + let _ = self.sender.send(Message::Kill.wrap().unwrap()); + let _ = self.proc.kill(); + } +} diff --git a/src/syscalls/business_logic_syscall_handler.rs b/src/syscalls/business_logic_syscall_handler.rs index 3680d8126..041784051 100644 --- a/src/syscalls/business_logic_syscall_handler.rs +++ b/src/syscalls/business_logic_syscall_handler.rs @@ -281,6 +281,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { let ExecutionResult { call_info, @@ -296,6 +297,8 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, self.block_context.invoke_tx_max_n_steps, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) .map_err(|err| SyscallHandlerError::ExecutionError(err.to_string()))?; @@ -368,6 +371,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { let compiled_class = if let Ok(compiled_class) = self .starknet_storage_state @@ -423,6 +427,8 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, self.block_context.invoke_tx_max_n_steps, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) .map_err(|_| StateError::ExecutionEntryPoint)?; @@ -448,6 +454,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result<(), SyscallHandlerError> { let selector = get_big_int(vm, syscall_ptr)?; let syscall_name = self.selector_to_syscall.get(&selector).ok_or( @@ -495,6 +502,8 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, vm, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )? }; @@ -516,6 +525,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { match request { SyscallRequest::LibraryCall(req) => self.library_call( @@ -524,6 +534,8 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, remaining_gas, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ), SyscallRequest::CallContract(req) => self.call_contract( vm, @@ -531,6 +543,8 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, remaining_gas, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ), SyscallRequest::Deploy(req) => self.deploy( vm, @@ -538,6 +552,8 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, remaining_gas, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ), SyscallRequest::StorageRead(req) => self.storage_read(vm, req, remaining_gas), SyscallRequest::StorageWrite(req) => self.storage_write(vm, req, remaining_gas), @@ -796,6 +812,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { let calldata = get_felt_range(vm, request.calldata_start, request.calldata_end)?; let execution_entry_point = ExecutionEntryPoint::new( @@ -815,6 +832,8 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, execution_entry_point, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) } @@ -858,6 +877,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result<(Address, CallResult), SyscallHandlerError> { if !(request.deploy_from_zero.is_zero() || request.deploy_from_zero.is_one()) { return Err(SyscallHandlerError::DeployFromZero( @@ -910,6 +930,8 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, remaining_gas, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; Ok((contract_address, result)) @@ -924,6 +946,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { let (contract_address, result) = self.syscall_deploy( vm, @@ -931,6 +954,8 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, remaining_gas, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; remaining_gas -= result.gas_consumed; @@ -1049,6 +1074,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { let calldata = get_felt_range(vm, request.calldata_start, request.calldata_end)?; let class_hash = ClassHash::from(request.class_hash); @@ -1069,6 +1095,8 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, execution_entry_point, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) } diff --git a/src/syscalls/deprecated_business_logic_syscall_handler.rs b/src/syscalls/deprecated_business_logic_syscall_handler.rs index 1582d974b..31693777a 100644 --- a/src/syscalls/deprecated_business_logic_syscall_handler.rs +++ b/src/syscalls/deprecated_business_logic_syscall_handler.rs @@ -238,6 +238,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result<(), StateError> { let contract_class = self .starknet_storage_state @@ -282,6 +283,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S self.block_context.invoke_tx_max_n_steps, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) .map_err(|_| StateError::ExecutionEntryPoint)?; @@ -341,6 +344,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { let request = match self.read_and_validate_syscall_request("deploy", vm, syscall_ptr)? { DeprecatedSyscallRequest::Deploy(request) => request, @@ -395,6 +399,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S constructor_calldata, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; Ok(deploy_contract_address) } @@ -408,6 +414,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result, SyscallHandlerError> { let request = self.read_and_validate_syscall_request(syscall_name, vm, syscall_ptr)?; @@ -510,6 +517,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S self.block_context.invoke_tx_max_n_steps, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) .map_err(|e| SyscallHandlerError::ExecutionError(e.to_string()))?; @@ -555,6 +564,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result<(), SyscallHandlerError> { self.call_contract_and_write_response( "delegate_l1_handler", @@ -562,6 +572,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S syscall_ptr, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) } @@ -694,12 +706,15 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result<(), SyscallHandlerError> { let contract_address = self.syscall_deploy( vm, syscall_ptr, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; let response = DeprecatedDeployResponse::new( @@ -724,6 +739,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result<(), SyscallHandlerError> { let retdata = self.syscall_call_contract( syscall_name, @@ -731,6 +747,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S syscall_ptr, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; let retdata_maybe_reloc = retdata @@ -885,6 +903,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result<(), SyscallHandlerError> { self.call_contract_and_write_response( "library_call", @@ -892,6 +911,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S syscall_ptr, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) } @@ -903,6 +924,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result<(), SyscallHandlerError> { self.call_contract_and_write_response( "library_call_l1_handler", @@ -910,6 +932,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S syscall_ptr, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) } @@ -921,6 +945,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result<(), SyscallHandlerError> { self.call_contract_and_write_response( "call_contract", @@ -928,6 +953,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S syscall_ptr, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) } @@ -939,6 +966,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result<(), SyscallHandlerError> { self.call_contract_and_write_response( "delegate_call", @@ -946,6 +974,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S syscall_ptr, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) } @@ -1138,6 +1168,8 @@ mod tests { relocatable!(1, 0), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None ), Err(SyscallHandlerError::DeployFromZero(4)) ) diff --git a/src/syscalls/deprecated_syscall_handler.rs b/src/syscalls/deprecated_syscall_handler.rs index 85cb7c688..e4db752ba 100644 --- a/src/syscalls/deprecated_syscall_handler.rs +++ b/src/syscalls/deprecated_syscall_handler.rs @@ -88,6 +88,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedSyscallHintProcessor<' // TODO: Get the program_cache somehow. #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) } EMIT_EVENT_CODE => { @@ -118,6 +120,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedSyscallHintProcessor<' // TODO: Get the program_cache somehow. #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) } LIBRARY_CALL_L1_HANDLER => { @@ -128,6 +132,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedSyscallHintProcessor<' // TODO: Get the program_cache somehow. #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) } CALL_CONTRACT => { @@ -138,6 +144,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedSyscallHintProcessor<' // TODO: Get the program_cache somehow. #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) } STORAGE_READ => { @@ -172,6 +180,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedSyscallHintProcessor<' // TODO: Get the program_cache somehow. #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) } DELEGATE_L1_HANDLER => { @@ -182,6 +192,8 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedSyscallHintProcessor<' // TODO: Get the program_cache somehow. #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) } REPLACE_CLASS => { @@ -1251,6 +1263,8 @@ mod tests { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); diff --git a/src/syscalls/native_syscall_handler.rs b/src/syscalls/native_syscall_handler.rs index d7c825d1b..09fd915cd 100644 --- a/src/syscalls/native_syscall_handler.rs +++ b/src/syscalls/native_syscall_handler.rs @@ -7,6 +7,7 @@ use crate::{ TransactionExecutionContext, }, hash_utils::calculate_contract_address, + sandboxing::IsolatedExecutor, services::api::{ contract_class_errors::ContractClassError, contract_classes::compiled_class::CompiledClass, }, @@ -48,6 +49,7 @@ where pub(crate) block_context: BlockContext, pub(crate) internal_calls: Vec, pub(crate) program_cache: Rc>>, + pub(crate) sandbox: Option<&'a IsolatedExecutor>, } impl<'a, 'cache, S: StateReader, C: ContractClassCache> NativeSyscallHandler<'a, 'cache, S, C> { @@ -133,6 +135,13 @@ impl<'a, 'cache, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler }) } + fn get_execution_info_v2( + &mut self, + _remaining_gas: &mut u128, + ) -> SyscallResult { + todo!() + } + fn deploy( &mut self, class_hash: Felt252, @@ -253,6 +262,7 @@ impl<'a, 'cache, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler false, self.block_context.invoke_tx_max_n_steps, Some(self.program_cache.clone()), + self.sandbox, )?; let call_info = call_info.ok_or(SyscallHandlerError::ExecutionError( @@ -317,6 +327,7 @@ impl<'a, 'cache, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler false, self.block_context.invoke_tx_max_n_steps, Some(self.program_cache.clone()), + self.sandbox, ) .unwrap(); @@ -662,6 +673,7 @@ where false, u64::MAX, Some(self.program_cache.clone()), + self.sandbox, ) .map_err(|_| StateError::ExecutionEntryPoint)?; diff --git a/src/syscalls/syscall_handler.rs b/src/syscalls/syscall_handler.rs index bb769bdfa..9818b9933 100644 --- a/src/syscalls/syscall_handler.rs +++ b/src/syscalls/syscall_handler.rs @@ -78,6 +78,8 @@ impl<'a, S: StateReader, C: ContractClassCache> HintProcessorLogic // TODO: Get the program_cache somehow. #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .map_err(|err| { HintError::CustomHint( diff --git a/src/transaction/declare.rs b/src/transaction/declare.rs index 9bf6d828f..21931c2b2 100644 --- a/src/transaction/declare.rs +++ b/src/transaction/declare.rs @@ -194,6 +194,7 @@ impl Declare { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { // validate transaction let mut resources_manager = ExecutionResourcesManager::default(); @@ -206,6 +207,8 @@ impl Declare { &mut resources_manager, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )? }; let changes = state.count_actual_state_changes(Some(( @@ -257,6 +260,7 @@ impl Declare { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result, TransactionError> { if self.version.is_zero() { return Ok(None); @@ -284,6 +288,8 @@ impl Declare { block_context.validate_max_n_steps, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; let call_info = call_info.ok_or(TransactionError::CallInfoIsNone)?; @@ -365,7 +371,7 @@ impl Declare { /// Calculates actual fee used by the transaction using the execution /// info returned by apply(), then updates the transaction execution info with the data of the fee. - #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context, program_cache), fields( + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context, program_cache, sandbox), fields( tx_type = ?TransactionType::Declare, self.version = ?self.version, self.class_hash = ?self.class_hash, @@ -380,6 +386,7 @@ impl Declare { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { if self.version != Felt252::ONE && self.version != Felt252::ZERO { return Err(TransactionError::UnsupportedTxVersion( @@ -399,6 +406,8 @@ impl Declare { block_context, #[cfg(feature = "cairo-native")] program_cache.clone(), + #[cfg(feature = "cairo-native")] + sandbox, )?; let mut tx_execution_context = @@ -412,6 +421,8 @@ impl Declare { self.skip_fee_transfer, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; state.set_contract_class( @@ -590,6 +601,8 @@ mod tests { &BlockContext::default(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(), transaction_exec_info @@ -669,6 +682,8 @@ mod tests { &BlockContext::default(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -680,6 +695,8 @@ mod tests { &BlockContext::default(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -748,6 +765,8 @@ mod tests { &BlockContext::default(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -756,6 +775,8 @@ mod tests { &BlockContext::default(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); // --------------------- @@ -801,6 +822,8 @@ mod tests { &BlockContext::default(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert!(internal_declare_error.is_err()); @@ -873,6 +896,8 @@ mod tests { &BlockContext::default(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ), Err(TransactionError::MaxFeeExceedsBalance(_, _, _)) ); @@ -976,6 +1001,8 @@ mod tests { &bock_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap() .actual_fee @@ -986,6 +1013,8 @@ mod tests { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap() .actual_fee, @@ -1015,6 +1044,8 @@ mod tests { &BlockContext::default(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert_matches!( diff --git a/src/transaction/declare_v2.rs b/src/transaction/declare_v2.rs index 8b38cccf0..19ff04ea6 100644 --- a/src/transaction/declare_v2.rs +++ b/src/transaction/declare_v2.rs @@ -349,7 +349,7 @@ impl DeclareV2 { /// ## Parameter: /// - state: An state that implements the State and StateReader traits. /// - block_context: The block that contains the execution context - #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context, program_cache), fields( + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context, program_cache, sandbox), fields( tx_type = ?TransactionType::Declare, self.version = ?self.version, self.sierra_class_hash = ?self.sierra_class_hash, @@ -365,6 +365,7 @@ impl DeclareV2 { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { if self.version != 2.into() { return Err(TransactionError::UnsupportedTxVersion( @@ -392,6 +393,8 @@ impl DeclareV2 { INITIAL_GAS_COST, #[cfg(feature = "cairo-native")] program_cache.clone(), + #[cfg(feature = "cairo-native")] + sandbox, )? }; self.compile_and_store_casm_class(state)?; @@ -421,6 +424,8 @@ impl DeclareV2 { self.skip_fee_transfer, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; let mut tx_exec_info = TransactionExecutionInfo::new_without_fee_info( @@ -494,6 +499,7 @@ impl DeclareV2 { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { let calldata = [self.compiled_class_hash].to_vec(); @@ -524,6 +530,8 @@ impl DeclareV2 { block_context.validate_max_n_steps, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )? }; @@ -988,6 +996,8 @@ mod tests { &BlockContext::default(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert_matches!( diff --git a/src/transaction/deploy.rs b/src/transaction/deploy.rs index 7848d2940..6727a3d17 100644 --- a/src/transaction/deploy.rs +++ b/src/transaction/deploy.rs @@ -162,6 +162,7 @@ impl Deploy { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { state.set_contract_class(&self.contract_hash, &self.contract_class)?; state.deploy_contract(self.contract_address.clone(), self.contract_hash)?; @@ -175,6 +176,8 @@ impl Deploy { block_context, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) } } @@ -229,6 +232,7 @@ impl Deploy { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { let call = ExecutionEntryPoint::new( self.contract_address.clone(), @@ -265,6 +269,8 @@ impl Deploy { block_context.validate_max_n_steps, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; let changes = state.count_actual_state_changes(None)?; @@ -291,7 +297,7 @@ impl Deploy { /// ## Parameters /// - state: A state that implements the [`State`] and [`StateReader`] traits. /// - block_context: The block's execution context. - #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context, program_cache), fields( + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context, program_cache, sandbox), fields( tx_type = ?TransactionType::Deploy, self.version = ?self.version, self.contract_hash = ?self.contract_hash, @@ -306,12 +312,15 @@ impl Deploy { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { let mut tx_exec_info = self.apply( state, block_context, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; let (fee_transfer_info, actual_fee) = (None, 0); tx_exec_info.set_fee_info(actual_fee, fee_transfer_info); @@ -385,6 +394,8 @@ mod tests { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -442,6 +453,8 @@ mod tests { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert_matches!(result.unwrap_err(), TransactionError::CairoRunner(..)) } @@ -484,6 +497,8 @@ mod tests { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert_matches!( result.unwrap_err(), diff --git a/src/transaction/deploy_account.rs b/src/transaction/deploy_account.rs index 2bb93e31a..d08186aa6 100644 --- a/src/transaction/deploy_account.rs +++ b/src/transaction/deploy_account.rs @@ -177,7 +177,7 @@ impl DeployAccount { } } - #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context, program_cache), fields( + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context, program_cache, sandbox), fields( tx_type = ?TransactionType::DeployAccount, self.version = ?self.version, self.class_hash = ?self.class_hash, @@ -193,6 +193,7 @@ impl DeployAccount { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { if self.version != Felt252::ONE { return Err(TransactionError::UnsupportedTxVersion( @@ -214,6 +215,8 @@ impl DeployAccount { block_context, #[cfg(feature = "cairo-native")] program_cache.clone(), + #[cfg(feature = "cairo-native")] + sandbox, ); #[cfg(feature = "replay_benchmark")] // Add initial values to cache despite tx outcome @@ -269,6 +272,8 @@ impl DeployAccount { self.skip_fee_transfer, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; tx_exec_info.set_fee_info(actual_fee, fee_transfer_info); @@ -301,6 +306,7 @@ impl DeployAccount { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { let contract_class = state.get_contract_class(&self.class_hash)?; @@ -314,6 +320,8 @@ impl DeployAccount { &mut resources_manager, #[cfg(feature = "cairo-native")] program_cache.clone(), + #[cfg(feature = "cairo-native")] + sandbox, )?; let validate_info = if self.skip_validate { @@ -325,6 +333,8 @@ impl DeployAccount { &mut resources_manager, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )? }; @@ -360,6 +370,7 @@ impl DeployAccount { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { if self.constructor_entry_points_empty(contract_class)? { if !self.constructor_calldata.is_empty() { @@ -378,6 +389,8 @@ impl DeployAccount { resources_manager, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) } } @@ -457,6 +470,7 @@ impl DeployAccount { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { let entry_point = ExecutionEntryPoint::new( self.contract_address.clone(), @@ -481,6 +495,8 @@ impl DeployAccount { block_context.validate_max_n_steps, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )? }; @@ -509,6 +525,7 @@ impl DeployAccount { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result, TransactionError> { let call = ExecutionEntryPoint::new( self.contract_address.clone(), @@ -539,6 +556,8 @@ impl DeployAccount { block_context.validate_max_n_steps, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )? }; @@ -786,6 +805,8 @@ mod tests { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_matches!( @@ -795,6 +816,8 @@ mod tests { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap_err(), TransactionError::State(StateError::ContractAddressUnavailable(..)) @@ -839,6 +862,8 @@ mod tests { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); } @@ -864,6 +889,8 @@ mod tests { &BlockContext::default(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert_matches!( diff --git a/src/transaction/fee.rs b/src/transaction/fee.rs index 5eb3c99f8..7dcf38016 100644 --- a/src/transaction/fee.rs +++ b/src/transaction/fee.rs @@ -38,6 +38,7 @@ pub(crate) fn execute_fee_transfer( #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { if actual_fee > tx_execution_context.max_fee { return Err(TransactionError::ActualFeeExceedsMaxFee( @@ -77,6 +78,8 @@ pub(crate) fn execute_fee_transfer( block_context.invoke_tx_max_n_steps, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) .map_err(|e| TransactionError::FeeTransferError(Box::new(e)))?; @@ -148,6 +151,7 @@ fn max_of_keys(cairo_rsc: &HashMap, weights: &HashMap( state: &mut CachedState, resources: &HashMap, @@ -158,6 +162,7 @@ pub fn charge_fee( #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { if max_fee.is_zero() { return Ok((None, 0)); @@ -192,6 +197,8 @@ pub fn charge_fee( actual_fee, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?) }; @@ -238,6 +245,8 @@ mod tests { skip_fee_transfer, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -274,6 +283,8 @@ mod tests { skip_fee_transfer, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); diff --git a/src/transaction/invoke_function.rs b/src/transaction/invoke_function.rs index 4504440db..bbe334e26 100644 --- a/src/transaction/invoke_function.rs +++ b/src/transaction/invoke_function.rs @@ -186,6 +186,7 @@ impl InvokeFunction { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result, TransactionError> { if self.version.is_zero() || self.skip_validation { return Ok(None); @@ -211,6 +212,8 @@ impl InvokeFunction { block_context.validate_max_n_steps, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; // Validate the return data @@ -253,6 +256,7 @@ impl InvokeFunction { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { let call = ExecutionEntryPoint::new( self.contract_address.clone(), @@ -273,6 +277,8 @@ impl InvokeFunction { block_context.invoke_tx_max_n_steps, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ) } @@ -290,6 +296,7 @@ impl InvokeFunction { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { let mut resources_manager = ExecutionResourcesManager::default(); let validate_info = if self.skip_validation { @@ -302,6 +309,8 @@ impl InvokeFunction { remaining_gas, #[cfg(feature = "cairo-native")] program_cache.clone(), + #[cfg(feature = "cairo-native")] + sandbox, )? }; @@ -324,6 +333,8 @@ impl InvokeFunction { remaining_gas, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )? }; let changes = state.count_actual_state_changes(Some(( @@ -354,7 +365,7 @@ impl InvokeFunction { /// - state: A state that implements the [`State`] and [`StateReader`] traits. /// - block_context: The block's execution context. /// - remaining_gas: The amount of gas that the transaction disposes. - #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context, program_cache), fields( + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context, program_cache, sandbox), fields( tx_type = ?TransactionType::InvokeFunction, self.version = ?self.version, self.hash_value = ?self.hash_value, @@ -370,6 +381,7 @@ impl InvokeFunction { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { if self.version != Felt252::ONE && self.version != Felt252::ZERO { return Err(TransactionError::UnsupportedTxVersion( @@ -393,6 +405,8 @@ impl InvokeFunction { remaining_gas, #[cfg(feature = "cairo-native")] program_cache.clone(), + #[cfg(feature = "cairo-native")] + sandbox, ); #[cfg(feature = "replay_benchmark")] // Add initial values to cache despite tx outcome @@ -461,6 +475,8 @@ impl InvokeFunction { self.skip_fee_transfer, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )?; tx_exec_info.set_fee_info(actual_fee, fee_transfer_info); @@ -842,6 +858,8 @@ mod tests { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); state @@ -922,6 +940,8 @@ mod tests { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -996,6 +1016,8 @@ mod tests { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert!(expected_error.is_err()); @@ -1065,6 +1087,8 @@ mod tests { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); state @@ -1143,6 +1167,8 @@ mod tests { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert!(expected_error.is_err()); @@ -1211,6 +1237,8 @@ mod tests { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert!(result.is_err()); assert_matches!( @@ -1279,6 +1307,8 @@ mod tests { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); let expected_actual_fee = 1258; @@ -1349,6 +1379,8 @@ mod tests { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -1358,6 +1390,8 @@ mod tests { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert!(expected_error.is_err()); @@ -1424,6 +1458,8 @@ mod tests { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert!(expected_error.is_err()); @@ -1567,6 +1603,8 @@ mod tests { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -1619,6 +1657,8 @@ mod tests { u128::MAX, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert_matches!( diff --git a/src/transaction/l1_handler.rs b/src/transaction/l1_handler.rs index 351a34a04..10f079395 100644 --- a/src/transaction/l1_handler.rs +++ b/src/transaction/l1_handler.rs @@ -103,7 +103,7 @@ impl L1Handler { } /// Applies self to 'state' by executing the L1-handler entry point. - #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context, program_cache), fields( + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context, program_cache, sandbox), fields( tx_type = ?TransactionType::L1Handler, self.hash_value = ?self.hash_value, self.contract_address = ?self.contract_address, @@ -118,6 +118,7 @@ impl L1Handler { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { let mut resources_manager = ExecutionResourcesManager::default(); let entrypoint = ExecutionEntryPoint::new( @@ -147,6 +148,8 @@ impl L1Handler { block_context.invoke_tx_max_n_steps, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, )? }; @@ -326,6 +329,8 @@ mod test { 100000, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); diff --git a/src/transaction/mod.rs b/src/transaction/mod.rs index 9303d78fe..9574bc7f3 100644 --- a/src/transaction/mod.rs +++ b/src/transaction/mod.rs @@ -83,6 +83,7 @@ impl Transaction { #[cfg(feature = "cairo-native")] program_cache: Option< Rc>>, >, + #[cfg(feature = "cairo-native")] sandbox: Option<&crate::sandboxing::IsolatedExecutor>, ) -> Result { match self { Transaction::Declare(tx) => tx.execute( @@ -90,24 +91,32 @@ impl Transaction { block_context, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ), Transaction::DeclareV2(tx) => tx.execute( state, block_context, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ), Transaction::Deploy(tx) => tx.execute( state, block_context, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ), Transaction::DeployAccount(tx) => tx.execute( state, block_context, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ), Transaction::InvokeFunction(tx) => tx.execute( state, @@ -115,6 +124,8 @@ impl Transaction { remaining_gas, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ), Transaction::L1Handler(tx) => tx.execute( state, @@ -122,6 +133,8 @@ impl Transaction { remaining_gas, #[cfg(feature = "cairo-native")] program_cache, + #[cfg(feature = "cairo-native")] + sandbox, ), } } diff --git a/tests/account_panic.rs b/tests/account_panic.rs index 506bf179e..3903bc4bf 100644 --- a/tests/account_panic.rs +++ b/tests/account_panic.rs @@ -119,6 +119,8 @@ fn account_panic() { u128::MAX, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .expect("failed to invoke"); let call_info = exec_info.call_info.as_ref().unwrap(); diff --git a/tests/cairo_1_syscalls.rs b/tests/cairo_1_syscalls.rs index e1c97a9ee..41f7bd80a 100644 --- a/tests/cairo_1_syscalls.rs +++ b/tests/cairo_1_syscalls.rs @@ -125,6 +125,8 @@ fn storage_write_read() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -150,6 +152,8 @@ fn storage_write_read() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!(call_info.call_info.unwrap().retdata, [25.into()]); @@ -176,6 +180,8 @@ fn storage_write_read() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -201,6 +207,8 @@ fn storage_write_read() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!(call_info.call_info.unwrap().retdata, [125.into()]) @@ -367,6 +375,8 @@ fn library_call() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap() .call_info @@ -503,6 +513,8 @@ fn call_contract_storage_write_read() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -528,6 +540,8 @@ fn call_contract_storage_write_read() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!(call_info.call_info.unwrap().retdata, [25.into()]); @@ -554,6 +568,8 @@ fn call_contract_storage_write_read() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -579,6 +595,8 @@ fn call_contract_storage_write_read() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!(call_info.call_info.unwrap().retdata, [125.into()]) @@ -658,6 +676,8 @@ fn emit_event() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!( @@ -787,6 +807,8 @@ fn deploy_cairo1_from_cairo1() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert!(call_info.is_ok()); @@ -898,6 +920,8 @@ fn deploy_cairo0_from_cairo1_without_constructor() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert!(call_info.is_ok()); @@ -1008,6 +1032,8 @@ fn deploy_cairo0_from_cairo1_with_constructor() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert!(call_info.is_ok()); @@ -1120,6 +1146,8 @@ fn deploy_cairo0_and_invoke() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert!(call_info.is_ok()); @@ -1168,6 +1196,8 @@ fn deploy_cairo0_and_invoke() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -1248,6 +1278,8 @@ fn test_send_message_to_l1_syscall() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -1359,6 +1391,8 @@ fn test_get_execution_info() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -1495,6 +1529,8 @@ fn replace_class_internal() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); // Check that the class was indeed replaced in storage @@ -1640,6 +1676,8 @@ fn replace_class_contract_call() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!(result.call_info.unwrap().retdata, vec![25.into()]); @@ -1669,6 +1707,8 @@ fn replace_class_contract_call() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -1697,6 +1737,8 @@ fn replace_class_contract_call() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!(result.call_info.clone().unwrap().retdata, vec![17.into()]); @@ -1831,6 +1873,8 @@ fn replace_class_contract_call_same_transaction() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!( @@ -1962,6 +2006,8 @@ fn call_contract_upgrade_cairo_0_to_cairo_1_same_transaction() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!( @@ -2091,6 +2137,8 @@ fn call_contract_downgrade_cairo_1_to_cairo_0_same_transaction() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!( @@ -2213,6 +2261,8 @@ fn call_contract_replace_class_cairo_0() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!( @@ -2296,6 +2346,8 @@ fn test_out_of_gas_failure() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); let call_info = call_info.call_info.unwrap(); @@ -2380,6 +2432,8 @@ fn deploy_syscall_failure_uninitialized_class_hash() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!( @@ -2479,6 +2533,8 @@ fn deploy_syscall_failure_in_constructor() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); // Check that we get the error from the constructor @@ -2562,6 +2618,8 @@ fn storage_read_no_value() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); // As the value doesn't exist in storage, it's value will be 0 @@ -2641,6 +2699,8 @@ fn storage_read_unavailable_address_domain() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -2723,6 +2783,8 @@ fn storage_write_unavailable_address_domain() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -2838,6 +2900,8 @@ fn library_call_failure() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -2956,6 +3020,8 @@ fn send_messages_to_l1_different_contract_calls() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); let l1_to_l2_messages = call_info @@ -3084,6 +3150,8 @@ fn send_messages_to_l1_different_contract_calls_cairo1_to_cairo0() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); let l1_to_l2_messages = call_info @@ -3210,6 +3278,8 @@ fn send_messages_to_l1_different_contract_calls_cairo0_to_cairo1() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); let l1_to_l2_messages = call_info @@ -3308,6 +3378,8 @@ fn keccak_syscall() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -3433,6 +3505,8 @@ fn library_call_recursive_50_calls() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap() .call_info @@ -3593,6 +3667,8 @@ fn call_contract_storage_write_read_recursive_50_calls() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -3618,6 +3694,8 @@ fn call_contract_storage_write_read_recursive_50_calls() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!(call_info.call_info.unwrap().retdata, [25.into()]); @@ -3644,6 +3722,8 @@ fn call_contract_storage_write_read_recursive_50_calls() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap() .call_info @@ -3674,6 +3754,8 @@ fn call_contract_storage_write_read_recursive_50_calls() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!(call_info.call_info.unwrap().retdata, [75.into()]) @@ -3808,6 +3890,8 @@ fn call_contract_storage_write_read_recursive_100_calls() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -3833,6 +3917,8 @@ fn call_contract_storage_write_read_recursive_100_calls() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!(call_info.call_info.unwrap().retdata, [25.into()]); @@ -3859,6 +3945,8 @@ fn call_contract_storage_write_read_recursive_100_calls() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap() .call_info @@ -3889,6 +3977,8 @@ fn call_contract_storage_write_read_recursive_100_calls() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); assert_eq!(call_info.call_info.unwrap().retdata, [125.into()]) diff --git a/tests/cairo_native.rs b/tests/cairo_native.rs index 8de0f49bb..db380734c 100644 --- a/tests/cairo_native.rs +++ b/tests/cairo_native.rs @@ -979,6 +979,8 @@ impl TestState { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, )?; // Overwrite the execution result's execution_resources as native doesn't output it if let Some(callinfo) = execution_result_vm.call_info.as_mut() { @@ -1015,6 +1017,8 @@ impl TestState { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, )?; Ok((execution_result_vm, execution_result_native)) diff --git a/tests/complex_contracts/erc20.rs b/tests/complex_contracts/erc20.rs index b9e0a4e8e..04a07e9aa 100644 --- a/tests/complex_contracts/erc20.rs +++ b/tests/complex_contracts/erc20.rs @@ -122,6 +122,8 @@ fn test_erc20_cairo2() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); let erc20_address = *call_info.call_info.unwrap().retdata.get(0).unwrap(); @@ -180,6 +182,8 @@ fn test_erc20_cairo2() { &Default::default(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .expect("failed to execute internal_deploy_account") .validate_info @@ -237,6 +241,8 @@ fn test_erc20_cairo2() { &Default::default(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap() .validate_info @@ -256,6 +262,8 @@ fn test_erc20_cairo2() { account_address_1.clone(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -272,6 +280,8 @@ fn test_erc20_cairo2() { account_address_1.clone(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -288,6 +298,8 @@ fn test_erc20_cairo2() { account_address_1, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); diff --git a/tests/complex_contracts/utils.rs b/tests/complex_contracts/utils.rs index 6c185f8da..d06cc8ed8 100644 --- a/tests/complex_contracts/utils.rs +++ b/tests/complex_contracts/utils.rs @@ -137,6 +137,8 @@ pub fn execute_entry_point( call_config.block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, )?; Ok(call_info.unwrap()) @@ -178,6 +180,8 @@ pub fn deploy( block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, )?; let call_info = tx_execution_info.call_info.unwrap(); diff --git a/tests/delegate_call.rs b/tests/delegate_call.rs index a43e170bc..4899ac93a 100644 --- a/tests/delegate_call.rs +++ b/tests/delegate_call.rs @@ -129,6 +129,8 @@ fn delegate_call() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .is_ok()); } diff --git a/tests/delegate_l1_handler.rs b/tests/delegate_l1_handler.rs index a82fe8ef1..b95439609 100644 --- a/tests/delegate_l1_handler.rs +++ b/tests/delegate_l1_handler.rs @@ -124,6 +124,8 @@ fn delegate_l1_handler() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .is_ok()); } diff --git a/tests/deploy_account.rs b/tests/deploy_account.rs index 25d2988e3..861f911a6 100644 --- a/tests/deploy_account.rs +++ b/tests/deploy_account.rs @@ -81,6 +81,8 @@ fn internal_deploy_account() { &Default::default(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -196,6 +198,8 @@ fn internal_deploy_account_cairo1() { &Default::default(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); diff --git a/tests/fibonacci.rs b/tests/fibonacci.rs index f890363a6..dd4541a9f 100644 --- a/tests/fibonacci.rs +++ b/tests/fibonacci.rs @@ -135,6 +135,8 @@ fn integration_test() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap() .call_info @@ -239,6 +241,8 @@ fn integration_test_cairo1() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap() .call_info diff --git a/tests/increase_balance.rs b/tests/increase_balance.rs index 2268e6bf7..e94b019e5 100644 --- a/tests/increase_balance.rs +++ b/tests/increase_balance.rs @@ -142,6 +142,8 @@ fn hello_starknet_increase_balance() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap() .call_info diff --git a/tests/internal_calls.rs b/tests/internal_calls.rs index cd82e4650..2c5b7d304 100644 --- a/tests/internal_calls.rs +++ b/tests/internal_calls.rs @@ -86,6 +86,8 @@ fn test_internal_calls() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .expect("Could not execute contract"); diff --git a/tests/internals.rs b/tests/internals.rs index 437649cf2..48376bce5 100644 --- a/tests/internals.rs +++ b/tests/internals.rs @@ -1043,6 +1043,8 @@ fn test_declare_tx() { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); // Check ContractClass is set after the declare_tx @@ -1140,6 +1142,8 @@ fn test_declarev2_tx() { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); // Check ContractClass is set after the declare_tx @@ -1428,6 +1432,8 @@ fn test_invoke_tx() { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); let expected_execution_info = expected_transaction_execution_info(block_context); @@ -1458,6 +1464,8 @@ fn test_invoke_tx_exceeded_max_fee() { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); let mut expected_result = expected_transaction_execution_info(block_context).to_revert_error( @@ -1552,6 +1560,8 @@ fn test_invoke_tx_state() { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -1627,6 +1637,8 @@ fn test_invoke_with_declarev2_tx() { block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -1638,6 +1650,8 @@ fn test_invoke_with_declarev2_tx() { block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -1660,6 +1674,8 @@ fn test_invoke_with_declarev2_tx() { expected_gas_consumed, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -1716,6 +1732,8 @@ fn test_deploy_account() { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -1842,6 +1860,8 @@ fn test_deploy_account_revert() { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -2142,6 +2162,8 @@ fn test_state_for_declare_tx() { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .is_ok()); assert_eq!( @@ -2330,6 +2352,8 @@ fn test_invoke_tx_wrong_call_data() { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); // Assert error @@ -2375,6 +2399,8 @@ fn test_invoke_tx_wrong_entrypoint() { 0, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); // Assert error @@ -2408,6 +2434,8 @@ fn test_deploy_undeclared_account() { &block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); // Execute transaction @@ -2429,6 +2457,8 @@ fn test_library_call_with_declare_v2() { block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -2440,6 +2470,8 @@ fn test_library_call_with_declare_v2() { block_context, #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -2541,6 +2573,8 @@ fn test_library_call_with_declare_v2() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); diff --git a/tests/multi_syscall_test.rs b/tests/multi_syscall_test.rs index 996baff13..e7e4d7440 100644 --- a/tests/multi_syscall_test.rs +++ b/tests/multi_syscall_test.rs @@ -260,6 +260,8 @@ fn test_syscall( block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap() .call_info diff --git a/tests/storage.rs b/tests/storage.rs index c0e972876..94eb4eec4 100644 --- a/tests/storage.rs +++ b/tests/storage.rs @@ -140,6 +140,8 @@ fn integration_storage_test() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap() .call_info diff --git a/tests/syscalls.rs b/tests/syscalls.rs index c5bdd49da..261457090 100644 --- a/tests/syscalls.rs +++ b/tests/syscalls.rs @@ -155,6 +155,8 @@ fn test_contract<'a>( block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .expect("Could not execute contract") .call_info @@ -1212,6 +1214,8 @@ fn deploy_cairo1_from_cairo0_with_constructor() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert!(call_info.is_ok()); @@ -1323,6 +1327,8 @@ fn deploy_cairo1_from_cairo0_without_constructor() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap(); @@ -1434,6 +1440,8 @@ fn deploy_cairo1_and_invoke() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert!(call_info.is_ok()); @@ -1478,6 +1486,8 @@ fn deploy_cairo1_and_invoke() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap() .call_info @@ -1579,6 +1589,8 @@ fn send_messages_to_l1_different_contract_calls() { block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ) .unwrap() .call_info diff --git a/tests/syscalls_errors.rs b/tests/syscalls_errors.rs index bb07667b5..349359725 100644 --- a/tests/syscalls_errors.rs +++ b/tests/syscalls_errors.rs @@ -133,6 +133,8 @@ fn test_contract<'a>( block_context.invoke_tx_max_n_steps(), #[cfg(feature = "cairo-native")] None, + #[cfg(feature = "cairo-native")] + None, ); assert_matches!(result, Err(e) if e.to_string().contains(error_msg)); diff --git a/tests/yas_bench_test.rs b/tests/yas_bench_test.rs index 6a0ce6bbf..08ea96877 100644 --- a/tests/yas_bench_test.rs +++ b/tests/yas_bench_test.rs @@ -326,7 +326,7 @@ where vec![], nonce, )? - .execute(state, &BlockContext::default(), program_cache)?; + .execute(state, &BlockContext::default(), program_cache, None)?; // Ensure the execution was successful. let validate_info = tx_execution_info.validate_info.unwrap(); @@ -362,7 +362,7 @@ where vec![], nonce, )? - .execute(state, &BlockContext::default(), program_cache)?; + .execute(state, &BlockContext::default(), program_cache, None)?; // Ensure the execution was successful. let validate_info = tx_execution_info.validate_info.unwrap(); @@ -398,7 +398,7 @@ where vec![], nonce, )? - .execute(state, &BlockContext::default(), program_cache)?; + .execute(state, &BlockContext::default(), program_cache, None)?; // Ensure the execution was successful. let validate_info = tx_execution_info.validate_info.unwrap(); @@ -434,7 +434,7 @@ where vec![], nonce, )? - .execute(state, &BlockContext::default(), program_cache)?; + .execute(state, &BlockContext::default(), program_cache, None)?; // Ensure the execution was successful. let validate_info = tx_execution_info.validate_info.unwrap(); @@ -485,6 +485,7 @@ where &BlockContext::default(), u64::MAX.into(), program_cache, + None, )?; // Ensure the execution was successful. @@ -531,6 +532,7 @@ where &BlockContext::default(), u64::MAX.into(), program_cache, + None, )?; // Ensure the execution was successful. @@ -569,6 +571,7 @@ where &BlockContext::default(), u64::MAX.into(), program_cache, + None, )?; // Ensure the execution was successful. @@ -623,6 +626,7 @@ where &BlockContext::default(), u64::MAX.into(), program_cache, + None, )?; // Ensure the execution was successful. @@ -673,6 +677,7 @@ where &BlockContext::default(), u64::MAX.into(), program_cache, + None, )?; // Ensure the execution was successful. @@ -721,6 +726,7 @@ where &BlockContext::default(), u64::MAX.into(), program_cache, + None, )?; // Ensure the execution was successful. @@ -778,6 +784,7 @@ where &BlockContext::default(), u64::MAX.into(), program_cache, + None, )?; // Ensure the execution was successful. @@ -837,6 +844,7 @@ where &BlockContext::default(), u64::MAX.into(), program_cache, + None, )?; // Ensure the execution was successful. @@ -884,6 +892,7 @@ where &BlockContext::default(), u64::MAX.into(), program_cache, + None, )?; // Ensure the execution was successful.