diff --git a/Cargo.lock b/Cargo.lock index a02e239e3e..33de27b5f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -975,7 +975,7 @@ dependencies = [ "serde", "serde_json", "sozo", - "starknet", + "starknet 0.8.0", "tokio", ] @@ -1009,6 +1009,29 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.66.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" +dependencies = [ + "bitflags 2.4.2", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease 0.2.16", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.49", + "which 4.4.2", +] + [[package]] name = "bindgen" version = "0.68.1" @@ -1020,13 +1043,16 @@ dependencies = [ "clang-sys", "lazy_static", "lazycell", + "log", "peeking_take_while", + "prettyplease 0.2.16", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", "syn 2.0.49", + "which 4.4.2", ] [[package]] @@ -1122,7 +1148,7 @@ dependencies = [ "cairo-lang-runner", "cairo-lang-starknet", "cairo-lang-utils", - "cairo-vm", + "cairo-vm 0.9.2", "ctor", "derive_more", "indexmap 2.2.3", @@ -1340,7 +1366,7 @@ dependencies = [ "convert_case 0.6.0", "serde", "serde_json", - "starknet", + "starknet 0.8.0", "thiserror", "tokio", "tracing", @@ -1365,7 +1391,7 @@ dependencies = [ "convert_case 0.6.0", "serde", "serde_json", - "starknet", + "starknet 0.8.0", "thiserror", "tracing", "tracing-subscriber", @@ -1377,7 +1403,7 @@ name = "cainome-cairo-serde" version = "0.1.0" source = "git+https://github.com/cartridge-gg/cainome?tag=v0.2.2#46c9fa734b396632cb5f986294d05532ada80f9a" dependencies = [ - "starknet", + "starknet 0.8.0", "thiserror", ] @@ -1386,7 +1412,7 @@ name = "cainome-cairo-serde" version = "0.1.0" source = "git+https://github.com/cartridge-gg/cainome?tag=v0.2.4#a30cc79838ca0d68e24a53a2fdaffa181c849a28" dependencies = [ - "starknet", + "starknet 0.8.0", "thiserror", ] @@ -1397,7 +1423,7 @@ source = "git+https://github.com/cartridge-gg/cainome?tag=v0.2.2#46c9fa734b39663 dependencies = [ "quote", "serde_json", - "starknet", + "starknet 0.8.0", "syn 2.0.49", "thiserror", ] @@ -1410,7 +1436,7 @@ dependencies = [ "convert_case 0.6.0", "quote", "serde_json", - "starknet", + "starknet 0.8.0", "syn 2.0.49", "thiserror", ] @@ -1426,7 +1452,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "starknet", + "starknet 0.8.0", "syn 2.0.49", "thiserror", ] @@ -1442,7 +1468,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "starknet", + "starknet 0.8.0", "syn 2.0.49", "thiserror", ] @@ -1459,7 +1485,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "starknet", + "starknet 0.8.0", "syn 2.0.49", "thiserror", ] @@ -1478,9 +1504,9 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ceb71a4cbf5b474bd671c79b2c05e8168a97199bfea1c01ef63b1bdaac3db03" +checksum = "dc54b38b6784e2a050c725802d4b5a5634bad32119f8a0a67fccf98e8d5a9f7b" dependencies = [ "cairo-lang-utils", "indoc 2.0.4", @@ -1492,9 +1518,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95c1aab3213462c5b7c21508f1a4330bdf0766c90e6dd4ed79b0002c2b96a715" +checksum = "816a6e69bcb48f40513592cebfe5ee80472c93d3dfd4793eaa09d8e2c4dd5489" dependencies = [ "anyhow", "cairo-lang-defs", @@ -1514,18 +1540,18 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03623ba892200c6b3c55fab260d4aa0bff833d6bcecdb1fb022565ac00d5a683" +checksum = "bee329295640812932a5ca71552d97cfe2057e2d2ef23a6328393c312c7f5367" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09131755b08a485322656e061ad05602215a198dd4a2daf3897e64dc76e7544e" +checksum = "f08a77ba3c274593f4cfe375b7ecde1353c8489fd8257daf2df85a459126c59a" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -1540,9 +1566,9 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b8185cc9472c648ac9db970ce558595c71259eebd55d25a502fe569cb871448" +checksum = "0d9db9eff39d5a91ec1d681d6e52012e5374270120ee55c222211440508e2234" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1552,9 +1578,9 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae71750096b64d4dd54dd2c39ef50651bb4aff4bc829e3d07549a5035620e0a" +checksum = "674eb82142b08aea2bca9d711393baea265b64c8a8cbe3a5ae570d84882a4b31" dependencies = [ "cairo-lang-utils", "good_lp", @@ -1562,9 +1588,9 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1819ef5a5396df695dcec993500c46bc44c309590b503da26965c873dfe8a84a" +checksum = "cb697f1d097eeb18ea28fc576c32ad867beade0b47ac2f95ca84026cec025808" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -1576,9 +1602,9 @@ dependencies = [ [[package]] name = "cairo-lang-formatter" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4cfea8cf064ff275b469e2f92c7dfd1e296f00013f4fb59d852299d3c872f65" +checksum = "e257bb5b687e33a6cd19d6106342e9c37fafca701c7cb9d7173c35ad81db8cc6" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -1597,9 +1623,9 @@ dependencies = [ [[package]] name = "cairo-lang-language-server" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0bdb1a3f19668c0a50ab5c4e197130d356b392370d45d4a0c2e2d6f55855a48" +checksum = "50bb402d0685765f845d0bc5abeaf6659dec0f70f5df4f22f71ea79d7ab1313b" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -1626,9 +1652,9 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0968f0da6117dca1a70d6ac7d2e252d8b1710f333458c54ce08dbef1c0323881" +checksum = "8306cb070322918f9cc18163eb9a847b437cfb2dbf37da5a04dbd41f26f9347e" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1651,9 +1677,9 @@ dependencies = [ [[package]] name = "cairo-lang-parser" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae556e49c0a90d30e52f068b0fb5ed4d419766661d3713a1644f3894a9255a5a" +checksum = "813b3fcfb3db7c137150fb135dc5fb5e8b2b0fcf1343c911e8f282ef6be4896c" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -1671,9 +1697,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d319f3e84ff679159f97e3baa1d918d369ba9e3ade5ad490e0a9e4eca19591" +checksum = "e2e301ea0102f57dd6df3365b44b28397efb68aba069cd218de4e0944bd9a5ff" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -1690,9 +1716,9 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fef002aac874d76492eb9577dab663f9a84fe4584b4215c7ebfda7d025fcadae" +checksum = "85aa42c1206b5848bb9ea7e77885ab5196bddcabe55332cc584ced6af9dd459e" dependencies = [ "cairo-lang-debug", "quote", @@ -1701,9 +1727,9 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f384c26e6907de9c94b44051e386498159e8c9e1567b9b1eae9c22e16ff17e5" +checksum = "15cc3bfe213c0fd569e7ba2a82200d1d49b1c9677fd4f9426967070bb83489a0" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -1715,9 +1741,9 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ccd9dce6f931508a21ac4d29965dadcaf7c22bbf2a237239763128b8647a53" +checksum = "6fa31a3ecabb2ecf900c4337e26e3d534ff4f0170183d96be3f72fcfb679ac3e" dependencies = [ "ark-ff 0.4.2", "ark-secp256k1", @@ -1732,7 +1758,7 @@ dependencies = [ "cairo-lang-sierra-type-size", "cairo-lang-starknet", "cairo-lang-utils", - "cairo-vm", + "cairo-vm 0.9.2", "itertools 0.11.0", "keccak", "num-bigint", @@ -1745,9 +1771,9 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "311434caae9542b7c442ac69a04e3c8eaa477654f215abe0bd7dfd3c0de70669" +checksum = "926f9fa06acd2fceb74f5471ca9c0954acd15c74eaf7f162722748013de0aa7e" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1771,9 +1797,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52c00c34fcaf97bbc4111d1631af8c65838841a38b3502b5bbc04355b7d46982" +checksum = "f3af31e751df35f8be2be2d692ac027c9d08e91a0aa2c2aff702480535643ef7" dependencies = [ "anyhow", "cairo-felt", @@ -1797,9 +1823,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c99a0be021b359c51383cce4372cb1061f7d53438d80f208c56af2154583c98e" +checksum = "7e5d3e18db52e0c2d104bce9d4888c9bb5a0fc5cd87673151941219aaad2d9ce" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1812,9 +1838,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f273d4de9d30e556e72ebe2751f9ed6bf3d84a70f6c76f52b178c24cddb12e43" +checksum = "4bc79b2bf4bd56b273ea64125f45dca5dc8583d56bbf8fd4741551f611d4dc7f" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1827,9 +1853,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "734f72e9e8b1ec7a96208aa8dfba87ca1614188e3646ae67c519afe707569490" +checksum = "4d9ac96139db603c6f351f84a9473e49b6b8bd4036a5fd9179fe8ebcee98a886" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1850,9 +1876,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "842ae37ee3f1cd06b926aceb480fd70b84300aae82e9606b876678d30c21649a" +checksum = "1952c5738d20715d11716ce63ce3e022fdf8563548e4fa84c8dd0379860ca675" dependencies = [ "assert_matches", "cairo-felt", @@ -1871,9 +1897,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f969cbaf81f3beb1dc693674fc792a815bf8fc13471227020a5faf309d5faf80" +checksum = "a404f3acbca36d70ac380098f738c217ef768b4089a5aaa1d3d9fa4e3ef0dfca" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -1881,9 +1907,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cd2d120f39369c7bd7d124dee638c250495054030d01d4e1d1b88f0063bd80" +checksum = "9e7a618278918fc83da465ea6c85028009dc386b91ce8ccdcd08c3045255b7ae" dependencies = [ "anyhow", "cairo-felt", @@ -1919,9 +1945,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552d3438fec55832976bc7c7d7490100e8ce7385d3f3f1539f9a46fffa2197c6" +checksum = "e08063b53ae8bc5c2d30b2a32a1abf807ffc082fe5f297a61370e4e540857d1a" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1945,9 +1971,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-plugin" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5e416a932754f190de2de011f3b3eb20dcb8093fb073cad15a8e70be833c3d" +checksum = "889e2324b7969757e512e09f44eaecb94d9b3cc5892cd2b5649d81de9d750493" dependencies = [ "anyhow", "cairo-felt", @@ -1972,9 +1998,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-runner" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26f97227443ce0393183be841cd3364e79446e79dddb098a5c05801463308d1" +checksum = "987cd7b124ef3adb30467c96c39365ef4b95736c6315e55e6abaa3c5596acf48" dependencies = [ "anyhow", "cairo-felt", @@ -1994,9 +2020,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-utils" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ab221aa0119b6e613992127687a1352a896d30a2e55a9295c52eb9598bcc78" +checksum = "2a906cee5ee9ae2c0143f97106d1c6e0ad1516db318cacc73b7e03f80b31e554" dependencies = [ "cairo-lang-utils", "colored", @@ -2006,9 +2032,9 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.5.4" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12d0939f42d40fb1d975cae073d7d4f82d83de4ba2149293115525245425f909" +checksum = "80f3de16afa605c6cc491661bc2dab71da10b379af0fdb7176f4f27e08d6286e" dependencies = [ "env_logger", "hashbrown 0.14.3", @@ -2022,6 +2048,58 @@ dependencies = [ "time", ] +[[package]] +name = "cairo-native" +version = "0.1.0" +source = "git+https://github.com/lambdaclass/cairo_native?rev=96ea3a37180a194ba14c3b21788b09e76bb634fd#96ea3a37180a194ba14c3b21788b09e76bb634fd" +dependencies = [ + "bumpalo", + "cairo-lang-compiler", + "cairo-lang-defs", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-lowering", + "cairo-lang-semantic", + "cairo-lang-sierra", + "cairo-lang-sierra-ap-change", + "cairo-lang-sierra-gas", + "cairo-lang-sierra-generator", + "cairo-lang-starknet", + "cairo-lang-utils", + "cairo-native-runtime", + "cc", + "clap", + "educe", + "id-arena", + "itertools 0.12.1", + "lazy_static", + "libc", + "libloading", + "llvm-sys", + "melior", + "mlir-sys", + "num-bigint", + "num-traits 0.2.18", + "starknet-types-core", + "tempfile", + "thiserror", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "cairo-native-runtime" +version = "0.1.0" +source = "git+https://github.com/lambdaclass/cairo_native?rev=96ea3a37180a194ba14c3b21788b09e76bb634fd#96ea3a37180a194ba14c3b21788b09e76bb634fd" +dependencies = [ + "cairo-lang-runner", + "lazy_static", + "libc", + "starknet-crypto 0.6.1", + "starknet-curve 0.4.1", + "starknet-types-core", +] + [[package]] name = "cairo-vm" version = "0.9.2" @@ -2052,6 +2130,40 @@ dependencies = [ "thiserror-no-std", ] +[[package]] +name = "cairo-vm" +version = "1.0.0-rc0" +source = "git+https://github.com/lambdaclass/cairo-vm?rev=1f98feff566dd2da016e439f5e8db912c6e39872#1f98feff566dd2da016e439f5e8db912c6e39872" +dependencies = [ + "anyhow", + "ark-ff 0.4.2", + "ark-std 0.4.0", + "bincode 2.0.0-rc.3", + "bitvec", + "cairo-lang-casm", + "cairo-lang-starknet", + "generic-array", + "hashbrown 0.14.3", + "hex", + "keccak", + "lazy_static", + "mimalloc", + "nom", + "num-bigint", + "num-integer", + "num-prime", + "num-traits 0.2.18", + "rand", + "serde", + "serde_json", + "sha2 0.10.8", + "sha3", + "starknet-crypto 0.6.1", + "starknet-types-core", + "thiserror-no-std", + "zip", +] + [[package]] name = "camino" version = "1.1.6" @@ -2369,6 +2481,7 @@ dependencies = [ "anstyle", "clap_lex", "strsim 0.11.0", + "terminal_size", ] [[package]] @@ -2503,6 +2616,26 @@ dependencies = [ "thiserror", ] +[[package]] +name = "comrak" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6751998a48e2327773c95f6f8e03c6e77c0156ce539d74c17d2199ff3d05e197" +dependencies = [ + "clap", + "derive_builder 0.12.0", + "entities", + "memchr", + "once_cell", + "regex", + "shell-words", + "slug", + "syntect", + "typed-arena", + "unicode_categories", + "xdg", +] + [[package]] name = "concurrent-queue" version = "2.4.0" @@ -3033,13 +3166,34 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_builder" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8" +dependencies = [ + "derive_builder_macro 0.12.0", +] + [[package]] name = "derive_builder" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0350b5cb0331628a5916d6c5c0b72e97393b8b6b03b47a9284f4e7f5a405ffd7" dependencies = [ - "derive_builder_macro", + "derive_builder_macro 0.20.0", +] + +[[package]] +name = "derive_builder_core" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" +dependencies = [ + "darling 0.14.4", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -3054,13 +3208,23 @@ dependencies = [ "syn 2.0.49", ] +[[package]] +name = "derive_builder_macro" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e" +dependencies = [ + "derive_builder_core 0.12.0", + "syn 1.0.109", +] + [[package]] name = "derive_builder_macro" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ - "derive_builder_core", + "derive_builder_core 0.20.0", "syn 2.0.49", ] @@ -3077,6 +3241,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "deunicode" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6e854126756c496b8c81dec88f9a706b15b875c5849d4097a3854476b9fdf94" + [[package]] name = "diff" version = "0.1.13" @@ -3218,7 +3388,7 @@ dependencies = [ "convert_case 0.6.0", "serde", "serde_json", - "starknet", + "starknet 0.8.0", "thiserror", ] @@ -3272,7 +3442,7 @@ dependencies = [ "serde_json", "serde_with", "smol_str", - "starknet", + "starknet 0.8.0", "test-log", "thiserror", "tracing", @@ -3327,7 +3497,7 @@ dependencies = [ "serde_json", "serde_with", "smol_str", - "starknet", + "starknet 0.8.0", "thiserror", "tokio", "toml 0.7.8", @@ -3344,7 +3514,7 @@ dependencies = [ "itertools 0.10.5", "serde", "serde_json", - "starknet", + "starknet 0.8.0", "strum 0.25.0", "strum_macros 0.25.3", "thiserror", @@ -3374,7 +3544,7 @@ dependencies = [ "serde_json", "serde_with", "smol_str", - "starknet", + "starknet 0.8.0", "starknet-crypto 0.6.1", "thiserror", "tokio", @@ -3471,6 +3641,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "educe" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4bd92664bf78c4d3dba9b7cdafce6fa15b13ed3ed16175218196942e99168a8" +dependencies = [ + "enum-ordinalize", + "proc-macro2", + "quote", + "syn 2.0.49", +] + [[package]] name = "either" version = "1.10.0" @@ -3555,6 +3737,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "entities" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca" + [[package]] name = "enum-as-inner" version = "0.6.0" @@ -3567,6 +3755,26 @@ dependencies = [ "syn 2.0.49", ] +[[package]] +name = "enum-ordinalize" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea0dcfa4e54eeb516fe454635a95753ddd39acda650ce703031c6973e315dd5" +dependencies = [ + "enum-ordinalize-derive", +] + +[[package]] +name = "enum-ordinalize-derive" +version = "4.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.49", +] + [[package]] name = "enum_dispatch" version = "0.3.12" @@ -4004,6 +4212,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "fancy-regex" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" +dependencies = [ + "bit-set", + "regex", +] + [[package]] name = "fast_chemail" version = "0.9.6" @@ -4438,6 +4656,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "getset" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e45727250e75cc04ff2846a66397da8ef2b3db8e40e0cef4df67950a07621eb9" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "ghash" version = "0.5.0" @@ -6548,6 +6778,7 @@ version = "0.6.0-alpha.0" dependencies = [ "anyhow", "assert_matches", + "cfg-if", "clap", "clap_complete", "common", @@ -6596,7 +6827,7 @@ dependencies = [ "blockifier", "cairo-lang-casm", "cairo-lang-starknet", - "cairo-vm", + "cairo-vm 0.9.2", "convert_case 0.6.0", "derive_more", "ethers", @@ -6615,7 +6846,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "starknet", + "starknet 0.8.0", "starknet_api", "tempfile", "thiserror", @@ -6630,7 +6861,7 @@ version = "0.6.0-alpha.0" dependencies = [ "anyhow", "cairo-lang-starknet", - "cairo-vm", + "cairo-vm 0.9.2", "criterion", "katana-primitives", "page_size", @@ -6639,7 +6870,7 @@ dependencies = [ "reth-libmdbx", "serde", "serde_json", - "starknet", + "starknet 0.8.0", "starknet_api", "tempfile", "thiserror", @@ -6650,7 +6881,8 @@ name = "katana-executor" version = "0.6.0-alpha.0" dependencies = [ "blockifier", - "cairo-vm", + "cairo-lang-sierra", + "cairo-vm 0.9.2", "convert_case 0.6.0", "katana-primitives", "katana-provider", @@ -6658,7 +6890,9 @@ dependencies = [ "rstest", "serde_json", "similar-asserts", + "starknet-types-core", "starknet_api", + "starknet_in_rust", "thiserror", "tracing", ] @@ -6672,7 +6906,7 @@ dependencies = [ "blockifier", "cairo-lang-sierra", "cairo-lang-starknet", - "cairo-vm", + "cairo-vm 0.9.2", "derive_more", "ethers", "flate2", @@ -6682,7 +6916,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "starknet", + "starknet 0.8.0", "starknet_api", "strum 0.25.0", "strum_macros 0.25.3", @@ -6706,7 +6940,7 @@ dependencies = [ "rstest", "rstest_reuse", "serde_json", - "starknet", + "starknet 0.8.0", "tempfile", "thiserror", "tokio", @@ -6738,7 +6972,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "starknet", + "starknet 0.8.0", "starknet_api", "thiserror", "tokio", @@ -6756,7 +6990,7 @@ dependencies = [ "katana-core", "katana-primitives", "katana-rpc-types", - "starknet", + "starknet 0.8.0", ] [[package]] @@ -6773,7 +7007,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "starknet", + "starknet 0.8.0", "thiserror", ] @@ -6786,7 +7020,7 @@ dependencies = [ "katana-primitives", "katana-provider", "katana-rpc-types", - "starknet", + "starknet 0.8.0", ] [[package]] @@ -6803,7 +7037,7 @@ dependencies = [ "serde", "serde_json", "sozo", - "starknet", + "starknet 0.8.0", "tokio", "url", ] @@ -6897,6 +7131,15 @@ dependencies = [ "regex", ] +[[package]] +name = "lambdaworks-math" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c6c4d0ddd1fcd235be5196b1bcc404f89ad3e911f4c190fa01459e05dbf40f8" +dependencies = [ + "thiserror", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -7495,7 +7738,7 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "229004ebba9d1d5caf41623f1523b6d52abb47d9f6ab87f7e6fc992e3b854aef" dependencies = [ - "bindgen", + "bindgen 0.68.1", "errno", "libc", ] @@ -7522,6 +7765,15 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "line-wrap" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" +dependencies = [ + "safemem", +] + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -7540,6 +7792,20 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +[[package]] +name = "llvm-sys" +version = "170.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eed90f72df5504c0af2e3a08ee7762a4a3e42ec2605811fc19f64879de40c50a" +dependencies = [ + "anyhow", + "cc", + "lazy_static", + "libc", + "regex-lite", + "semver 1.0.22", +] + [[package]] name = "lock_api" version = "0.4.11" @@ -7648,6 +7914,35 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "melior" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eecfff3838ac49bdc71179c27950f231fc7cdf289ac741ebc5f5ec462a9410cf" +dependencies = [ + "dashmap", + "melior-macro", + "mlir-sys", + "once_cell", +] + +[[package]] +name = "melior-macro" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "944e2ba4856e5057e54408196c8e795f835b16a2aff75efd8832c8be96f84339" +dependencies = [ + "comrak", + "convert_case 0.6.0", + "once_cell", + "proc-macro2", + "quote", + "regex", + "syn 2.0.49", + "tblgen", + "unindent", +] + [[package]] name = "memchr" version = "2.7.1" @@ -7835,6 +8130,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mlir-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5e19a5391ed2759fd9060f538330b9b89191e7b13503d7499a4f9580af6699a" +dependencies = [ + "bindgen 0.68.1", +] + [[package]] name = "monch" version = "0.5.0" @@ -8387,6 +8691,28 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "onig" +version = "6.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" +dependencies = [ + "bitflags 1.3.2", + "libc", + "once_cell", + "onig_sys", +] + +[[package]] +name = "onig_sys" +version = "69.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7" +dependencies = [ + "cc", + "pkg-config", +] + [[package]] name = "oorandom" version = "11.1.3" @@ -8929,6 +9255,20 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" +[[package]] +name = "plist" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5699cc8a63d1aa2b1ee8e12b9ad70ac790d65788cd36101fa37f87ea46c4cef" +dependencies = [ + "base64 0.21.7", + "indexmap 2.2.3", + "line-wrap", + "quick-xml", + "serde", + "time", +] + [[package]] name = "plotters" version = "0.3.5" @@ -9417,6 +9757,15 @@ dependencies = [ "unsigned-varint 0.8.0", ] +[[package]] +name = "quick-xml" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +dependencies = [ + "memchr", +] + [[package]] name = "quinn" version = "0.10.2" @@ -9647,6 +9996,12 @@ dependencies = [ "regex-syntax 0.8.2", ] +[[package]] +name = "regex-lite" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b661b2f27137bdbc16f00eda72866a92bb28af1753ffbd56744fb6e2e9cd8e" + [[package]] name = "regex-syntax" version = "0.6.29" @@ -9749,7 +10104,7 @@ name = "reth-mdbx-sys" version = "0.1.0-alpha.13" source = "git+https://github.com/paradigmxyz/reth.git?rev=b34b0d3#b34b0d3c8de2598b2976f7ee2fc1a166c50b1b94" dependencies = [ - "bindgen", + "bindgen 0.68.1", "cc", "libc", ] @@ -10144,6 +10499,12 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + [[package]] name = "salsa" version = "0.16.1" @@ -10232,7 +10593,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "starknet", + "starknet 0.8.0", "starknet_api", "thiserror", "tokio", @@ -10288,7 +10649,7 @@ dependencies = [ "create-output-dir", "data-encoding", "deno_task_shell", - "derive_builder", + "derive_builder 0.20.0", "directories", "dunce", "fs4", @@ -10349,7 +10710,7 @@ version = "1.10.0" source = "git+https://github.com/software-mansion/scarb?tag=v2.5.0#c531a6e509dbb8b43f1c2d37f9d74a7b1bf7243d" dependencies = [ "camino", - "derive_builder", + "derive_builder 0.20.0", "semver 1.0.22", "serde", "serde_json", @@ -10896,6 +11257,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slug" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd94acec9c8da640005f8e135a39fc0372e74535e6b368b7a04b875f784c8c4" +dependencies = [ + "deunicode", + "wasm-bindgen", +] + [[package]] name = "smallvec" version = "1.13.1" @@ -11038,7 +11409,7 @@ dependencies = [ "serde_json", "smol_str", "snapbox", - "starknet", + "starknet 0.8.0", "starknet-crypto 0.6.1", "thiserror", "tokio", @@ -11052,7 +11423,7 @@ name = "sozo-signers" version = "0.6.0-alpha.0" dependencies = [ "anyhow", - "starknet", + "starknet 0.8.0", ] [[package]] @@ -11311,20 +11682,49 @@ dependencies = [ "uuid 1.7.0", ] +[[package]] +name = "starknet" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fcb61961b91757a9bc2d11549067445b2f921bd957f53710db35449767a1ba3" +dependencies = [ + "starknet-accounts 0.4.0", + "starknet-contract 0.4.0", + "starknet-core 0.5.1", + "starknet-crypto 0.6.1", + "starknet-ff", + "starknet-macros", + "starknet-providers 0.5.0", + "starknet-signers 0.3.0", +] + [[package]] name = "starknet" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5eb139c5e6f6c6da627080e33cc00b3fc1c9733403034ca1ee9c42a95c337c7f" dependencies = [ - "starknet-accounts", - "starknet-contract", + "starknet-accounts 0.7.0", + "starknet-contract 0.7.0", "starknet-core 0.8.1", "starknet-crypto 0.6.1", "starknet-ff", "starknet-macros", - "starknet-providers", - "starknet-signers", + "starknet-providers 0.8.0", + "starknet-signers 0.6.0", +] + +[[package]] +name = "starknet-accounts" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "111ed887e4db14f0df1f909905e7737e4730770c8ed70997b58a71d5d940daac" +dependencies = [ + "async-trait", + "starknet-core 0.5.1", + "starknet-providers 0.5.0", + "starknet-signers 0.3.0", + "thiserror", ] [[package]] @@ -11336,8 +11736,23 @@ dependencies = [ "async-trait", "auto_impl", "starknet-core 0.8.1", - "starknet-providers", - "starknet-signers", + "starknet-providers 0.8.0", + "starknet-signers 0.6.0", + "thiserror", +] + +[[package]] +name = "starknet-contract" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d6f81a647694b2cb669ab60e77954b57bf5fbc757f5fcaf0a791c3bd341f04" +dependencies = [ + "serde", + "serde_json", + "serde_with", + "starknet-accounts 0.4.0", + "starknet-core 0.5.1", + "starknet-providers 0.5.0", "thiserror", ] @@ -11350,12 +11765,30 @@ dependencies = [ "serde", "serde_json", "serde_with", - "starknet-accounts", + "starknet-accounts 0.7.0", "starknet-core 0.8.1", - "starknet-providers", + "starknet-providers 0.8.0", "thiserror", ] +[[package]] +name = "starknet-core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91f89c79b641618de8aa9668d74c6b6634659ceca311c6318a35c025f9d4d969" +dependencies = [ + "base64 0.21.7", + "flate2", + "hex", + "serde", + "serde_json", + "serde_json_pythonic", + "serde_with", + "sha3", + "starknet-crypto 0.6.1", + "starknet-ff", +] + [[package]] name = "starknet-core" version = "0.8.1" @@ -11486,6 +11919,26 @@ dependencies = [ "syn 2.0.49", ] +[[package]] +name = "starknet-providers" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbbfccb46a8969fb3ac803718d9d8270cff4eed5b7f6b9ba234875ad2cc997c5" +dependencies = [ + "async-trait", + "auto_impl", + "ethereum-types", + "flate2", + "log", + "reqwest", + "serde", + "serde_json", + "serde_with", + "starknet-core 0.5.1", + "thiserror", + "url", +] + [[package]] name = "starknet-providers" version = "0.8.0" @@ -11506,6 +11959,22 @@ dependencies = [ "url", ] +[[package]] +name = "starknet-signers" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5313524cc79344015ef2a8618947332ab17012b5c50600c7f84c60989bdec980" +dependencies = [ + "async-trait", + "auto_impl", + "crypto-bigint", + "eth-keystore", + "rand", + "starknet-core 0.5.1", + "starknet-crypto 0.6.1", + "thiserror", +] + [[package]] name = "starknet-signers" version = "0.6.0" @@ -11522,6 +11991,21 @@ dependencies = [ "thiserror", ] +[[package]] +name = "starknet-types-core" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b6b868f545d43b474c2c00e9349c489fdeb7ff17eb00cdf339744ac4cae0930" +dependencies = [ + "bitvec", + "lambdaworks-math", + "lazy_static", + "num-bigint", + "num-integer", + "num-traits 0.2.18", + "serde", +] + [[package]] name = "starknet_api" version = "0.7.0-dev.0" @@ -11544,6 +12028,44 @@ dependencies = [ "thiserror", ] +[[package]] +name = "starknet_in_rust" +version = "0.4.0" +source = "git+https://github.com/dojoengine/starknet_in_rust.git?rev=8a95b3f#8a95b3faacdecf27399184d36fb884815d9113d5" +dependencies = [ + "anyhow", + "auto_impl", + "base64 0.21.7", + "cairo-lang-casm", + "cairo-lang-sierra", + "cairo-lang-starknet", + "cairo-lang-utils", + "cairo-native", + "cairo-vm 1.0.0-rc0", + "flate2", + "getset", + "hex", + "k256", + "keccak", + "lazy_static", + "mimalloc", + "num-bigint", + "num-integer", + "num-traits 0.2.18", + "once_cell", + "p256", + "sec1", + "serde", + "serde_json", + "serde_json_pythonic", + "sha3", + "starknet 0.5.0", + "starknet-crypto 0.6.1", + "starknet_api", + "thiserror", + "tracing", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -11736,6 +12258,29 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "syntect" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1" +dependencies = [ + "bincode 1.3.3", + "bitflags 1.3.2", + "fancy-regex", + "flate2", + "fnv", + "once_cell", + "onig", + "plist", + "regex-syntax 0.8.2", + "serde", + "serde_derive", + "serde_json", + "thiserror", + "walkdir", + "yaml-rust", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -11774,6 +12319,18 @@ dependencies = [ "xattr", ] +[[package]] +name = "tblgen" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d19c09266feb8b16718d1183044d14703a0b4b59e55ce8beb4d6e21dd066b1b" +dependencies = [ + "bindgen 0.66.1", + "cc", + "paste", + "thiserror", +] + [[package]] name = "tempfile" version = "3.10.0" @@ -11806,6 +12363,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix 0.38.31", + "windows-sys 0.48.0", +] + [[package]] name = "termtree" version = "0.4.1" @@ -12304,7 +12871,7 @@ dependencies = [ "serde", "serde_json", "sqlx", - "starknet", + "starknet 0.8.0", "starknet-crypto 0.6.1", "tokio", "tokio-stream", @@ -12338,7 +12905,7 @@ dependencies = [ "prost 0.12.3", "serde", "serde_json", - "starknet", + "starknet 0.8.0", "starknet-crypto 0.6.1", "thiserror", "tokio", @@ -12376,7 +12943,7 @@ dependencies = [ "slab", "sozo", "sqlx", - "starknet", + "starknet 0.8.0", "starknet-crypto 0.6.1", "thiserror", "tokio", @@ -12409,7 +12976,7 @@ dependencies = [ "serial_test", "sozo", "sqlx", - "starknet", + "starknet 0.8.0", "starknet-crypto 0.6.1", "strum 0.25.0", "strum_macros 0.25.3", @@ -12443,7 +13010,7 @@ dependencies = [ "serde", "serde_json", "sqlx", - "starknet", + "starknet 0.8.0", "starknet-crypto 0.6.1", "strum 0.25.0", "strum_macros 0.25.3", @@ -12515,7 +13082,7 @@ dependencies = [ "serde", "serde_json", "sqlx", - "starknet", + "starknet 0.8.0", "starknet-crypto 0.6.1", "tokio", "tokio-stream", @@ -12779,6 +13346,12 @@ dependencies = [ "webrtc-util", ] +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + [[package]] name = "typed-builder" version = "0.18.1" @@ -12911,6 +13484,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" +[[package]] +name = "unindent" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" + [[package]] name = "universal-hash" version = "0.5.1" @@ -13803,6 +14382,12 @@ dependencies = [ "rustix 0.38.31", ] +[[package]] +name = "xdg" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" + [[package]] name = "xml-rs" version = "0.8.19" @@ -13839,6 +14424,15 @@ version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "927da81e25be1e1a2901d59b81b37dd2efd1fc9c9345a55007f09bf5a2d3ee03" +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "yamux" version = "0.12.1" diff --git a/Cargo.toml b/Cargo.toml index 0c7ad19bcf..1a72001bd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -186,9 +186,15 @@ wasm-prost = { version = "0.11.9", package = "prost" } wasm-tonic = { version = "0.9.2", default-features = false, features = [ "codegen", "gzip", "prost" ], package = "tonic" } wasm-tonic-build = { version = "0.9.2", default-features = false, features = [ "prost" ], package = "tonic-build" } +sir = { package = "starknet_in_rust", git = "https://github.com/lambdaclass/starknet_in_rust.git", rev = "2e7bcc1" } +starknet-types-core = "0.0.6" + [patch."https://github.com/starkware-libs/blockifier"] blockifier = { git = "https://github.com/dojoengine/blockifier", rev = "8860946" } +[patch."https://github.com/lambdaclass/starknet_in_rust.git"] +sir = { package = "starknet_in_rust", git = "https://github.com/dojoengine/starknet_in_rust.git", rev = "8a95b3f" } + [patch.crates-io] cairo-felt = { git = "https://github.com/dojoengine/cairo-rs.git", rev = "1031381" } cairo-vm = { git = "https://github.com/dojoengine/cairo-rs.git", rev = "1031381" } diff --git a/bin/katana/Cargo.toml b/bin/katana/Cargo.toml index b208bb03d5..774a438211 100644 --- a/bin/katana/Cargo.toml +++ b/bin/katana/Cargo.toml @@ -8,6 +8,7 @@ version.workspace = true [dependencies] anyhow.workspace = true +cfg-if = "1.0.0" clap.workspace = true clap_complete.workspace = true common.workspace = true @@ -31,7 +32,11 @@ url.workspace = true assert_matches = "1.5.0" [features] -default = [ "jemalloc", "messaging" ] +default = [ "blockifier", "jemalloc", "messaging" ] + +blockifier = [ "katana-executor/blockifier" ] +sir = [ "katana-executor/sir" ] + jemalloc = [ "metrics/jemalloc" ] messaging = [ "katana-core/messaging" ] starknet-messaging = [ "katana-core/starknet-messaging", "messaging" ] diff --git a/bin/katana/src/main.rs b/bin/katana/src/main.rs index 1c20a4c0f2..0c62ce949a 100644 --- a/bin/katana/src/main.rs +++ b/bin/katana/src/main.rs @@ -61,8 +61,19 @@ async fn main() -> Result<(), Box> { ..Default::default() }; - use katana_executor::implementation::blockifier::BlockifierFactory; - let executor_factory = BlockifierFactory::new(cfg_env, simulation_flags); + cfg_if::cfg_if! { + if #[cfg(all(feature = "blockifier", feature = "sir"))] { + compile_error!("Cannot enable both `blockifier` and `sir` features at the same time"); + } else if #[cfg(feature = "blockifier")] { + use katana_executor::implementation::blockifier::BlockifierFactory; + let executor_factory = BlockifierFactory::new(cfg_env, simulation_flags); + } else if #[cfg(feature = "sir")] { + use katana_executor::implementation::sir::NativeExecutorFactory; + let executor_factory = NativeExecutorFactory::new(cfg_env, simulation_flags); + } else { + compile_error!("At least one of the following features must be enabled: blockifier, sir"); + } + } let sequencer = Arc::new(KatanaSequencer::new(executor_factory, sequencer_config, starknet_config).await?); diff --git a/crates/katana/executor/.env.cairo-native b/crates/katana/executor/.env.cairo-native new file mode 100644 index 0000000000..2fc3d8595e --- /dev/null +++ b/crates/katana/executor/.env.cairo-native @@ -0,0 +1,3 @@ +export MLIR_SYS_170_PREFIX=/opt/homebrew/opt/llvm@17 +export LLVM_SYS_170_PREFIX=/opt/homebrew/opt/llvm@17 +export TABLEGEN_170_PREFIX=/opt/homebrew/opt/llvm@17 \ No newline at end of file diff --git a/crates/katana/executor/Cargo.toml b/crates/katana/executor/Cargo.toml index 00fed1cab4..f3fb6c19b2 100644 --- a/crates/katana/executor/Cargo.toml +++ b/crates/katana/executor/Cargo.toml @@ -20,6 +20,11 @@ tracing.workspace = true # blockifier deps blockifier = { workspace = true, optional = true } +# starknet_in_rust deps +cairo-lang-sierra = { workspace = true, optional = true } +sir = { workspace = true, optional = true } +starknet-types-core = { workspace = true, optional = true } + [dev-dependencies] cairo-vm.workspace = true katana-provider.workspace = true @@ -28,6 +33,8 @@ serde_json.workspace = true similar-asserts.workspace = true [features] -default = [ "blockifier" ] +default = [ "blockifier", "sir" ] blockifier = [ "dep:blockifier", "katana-primitives/blockifier" ] +native = [ "sir", "sir/cairo-native" ] +sir = [ "dep:sir", "dep:starknet-types-core" ] diff --git a/crates/katana/executor/src/implementation/sir/mod.rs b/crates/katana/executor/src/implementation/sir/mod.rs new file mode 100644 index 0000000000..934a177722 --- /dev/null +++ b/crates/katana/executor/src/implementation/sir/mod.rs @@ -0,0 +1,295 @@ +mod output; +mod state; +mod utils; + +use std::collections::HashMap; +use std::sync::Arc; + +use katana_primitives::block::{ExecutableBlock, PartialHeader}; +use katana_primitives::class::{ClassHash, CompiledClassHash}; +use katana_primitives::contract::{ContractAddress, StorageKey, StorageValue}; +use katana_primitives::env::{BlockEnv, CfgEnv}; +use katana_primitives::receipt::Receipt; +use katana_primitives::state::{StateUpdates, StateUpdatesWithDeclaredClasses}; +use katana_primitives::transaction::{ExecutableTx, ExecutableTxWithHash, TxWithHash}; +use katana_primitives::FieldElement; +use katana_provider::traits::state::StateProvider; +use sir::definitions::block_context::{ + BlockContext, FeeTokenAddresses, GasPrices, StarknetOsConfig, +}; +use sir::state::contract_class_cache::PermanentContractClassCache; +use sir::state::{cached_state, BlockInfo}; + +use self::state::CachedState; +pub use self::utils::Error; +use crate::abstraction::{ + BlockExecutor, ExecutionOutput, ExecutorFactory, ExecutorResult, SimulationFlag, + StateProviderDb, TransactionExecutionOutput, TransactionExecutor, +}; +use crate::EntryPointCall; + +/// A factory for creating [StarknetVMProcessor] instances. +#[derive(Debug)] +pub struct NativeExecutorFactory { + cfg: CfgEnv, + flags: SimulationFlag, +} + +impl NativeExecutorFactory { + /// Create a new factory with the given configuration and simulation flags. + pub fn new(cfg: CfgEnv, flags: SimulationFlag) -> Self { + Self { cfg, flags } + } +} + +impl ExecutorFactory for NativeExecutorFactory { + fn with_state<'a, P>(&self, state: P) -> Box + 'a> + where + P: StateProvider + 'a, + { + self.with_state_and_block_env(state, BlockEnv::default()) + } + + fn with_state_and_block_env<'a, P>( + &self, + state: P, + block_env: BlockEnv, + ) -> Box + 'a> + where + P: StateProvider + 'a, + { + let cfg_env = self.cfg.clone(); + let simulation_flags = self.flags.clone(); + Box::new(StarknetVMProcessor::new(Box::new(state), block_env, cfg_env, simulation_flags)) + } + + fn cfg(&self) -> &CfgEnv { + &self.cfg + } +} + +pub struct StarknetVMProcessor<'a> { + block_context: BlockContext, + state: Arc, PermanentContractClassCache>>, + transactions: Vec<(TxWithHash, Option)>, + simulation_flags: SimulationFlag, +} + +impl<'a> StarknetVMProcessor<'a> { + pub fn new( + state: Box, + block_env: BlockEnv, + cfg_env: CfgEnv, + simulation_flags: SimulationFlag, + ) -> Self { + let chain_id = utils::to_sir_felt(&cfg_env.chain_id.id()); + let fee_token_addreses = FeeTokenAddresses::new( + utils::to_sir_address(&cfg_env.fee_token_addresses.eth), + utils::to_sir_address(&cfg_env.fee_token_addresses.strk), + ); + + let block_info = BlockInfo { + block_number: block_env.number, + block_timestamp: block_env.timestamp, + sequencer_address: utils::to_sir_address(&block_env.sequencer_address), + gas_price: GasPrices { + eth_l1_gas_price: block_env.l1_gas_prices.eth as u128, + strk_l1_gas_price: block_env.l1_gas_prices.strk as u128, + }, + }; + + let block_context = BlockContext::new( + StarknetOsConfig::new(chain_id, fee_token_addreses, GasPrices::default()), + Default::default(), + Default::default(), + cfg_env.vm_resource_fee_cost.clone(), + cfg_env.invoke_tx_max_n_steps as u64, + cfg_env.validate_max_n_steps as u64, + block_info, + Default::default(), + false, + ); + + let contract_class_cache = PermanentContractClassCache::default(); + let state = Arc::new(CachedState::new(StateProviderDb(state), contract_class_cache)); + let executed_txs = Vec::new(); + + Self { block_context, state, transactions: executed_txs, simulation_flags } + } + + fn fill_block_env_from_header(&mut self, header: &PartialHeader) { + let number = header.number; + let timestamp = header.timestamp; + let sequencer_address = utils::to_sir_address(&header.sequencer_address); + let eth_l1_gas_price = header.gas_prices.eth as u128; + let strk_l1_gas_price = header.gas_prices.strk as u128; + + self.block_context.block_info_mut().block_number = number; + self.block_context.block_info_mut().block_timestamp = timestamp; + self.block_context.block_info_mut().sequencer_address = sequencer_address; + self.block_context.block_info_mut().gas_price.eth_l1_gas_price = eth_l1_gas_price; + self.block_context.block_info_mut().gas_price.strk_l1_gas_price = strk_l1_gas_price; + } +} + +impl<'a> TransactionExecutor for StarknetVMProcessor<'a> { + fn execute( + &mut self, + tx: ExecutableTxWithHash, + ) -> ExecutorResult> { + let state = &self.state; + let block_context = &self.block_context; + let flags = &self.simulation_flags; + + let class_declaration_artifacts = if let ExecutableTx::Declare(tx) = tx.as_ref() { + let class_hash = tx.class_hash(); + Some((class_hash, tx.compiled_class.clone(), tx.sierra_class.clone())) + } else { + None + }; + + let tx_ = TxWithHash::from(&tx); + + let gas = 0; + let res = utils::transact(tx, &mut state.0.write().inner, block_context, gas, flags)?; + + let receipt = res.receipt(tx_.as_ref()); + self.transactions.push((tx_, Some(receipt))); + + if let Some((class_hash, compiled_class, sierra_class)) = class_declaration_artifacts { + state.0.write().declared_classes.insert(class_hash, (compiled_class, sierra_class)); + } + + Ok(Box::new(res)) + } + + fn simulate( + &self, + tx: ExecutableTxWithHash, + flags: SimulationFlag, + ) -> ExecutorResult> { + let state = &self.state.0.read().inner; + + let state_reader = Arc::new(state); + let contract_classes = Arc::new(PermanentContractClassCache::default()); + let mut state = cached_state::CachedState::new(state_reader, contract_classes); + + let block_context = &self.block_context; + + let gas = 0; + let res = utils::transact(tx, &mut state, block_context, gas, &flags)?; + + Ok(Box::new(res)) + } + + fn call(&self, call: EntryPointCall, initial_gas: u128) -> ExecutorResult> { + let block_context = &self.block_context; + + let state_reader = Arc::clone(&self.state); + let contract_classes = Arc::new(PermanentContractClassCache::default()); + let mut state = cached_state::CachedState::new(state_reader, contract_classes); + + let res = utils::call(call, &mut state, block_context, initial_gas)?; + + let info = res.call_info.expect("should exist in call result"); + let retdata = info.retdata.iter().map(utils::to_felt).collect(); + + Ok(retdata) + } +} + +impl<'a> BlockExecutor<'a> for StarknetVMProcessor<'a> { + fn execute_block(&mut self, block: ExecutableBlock) -> ExecutorResult<()> { + self.fill_block_env_from_header(&block.header); + + for tx in block.body { + let _ = self.execute(tx)?; + } + + Ok(()) + } + + fn take_execution_output(&mut self) -> ExecutorResult { + let transactions = std::mem::take(&mut self.transactions); + let state = &mut self.state.0.write(); + + let state_changes = std::mem::take(state.inner.cache_mut()); + let state_diffs = utils::state_diff_from_state_cache(state_changes); + let compiled_classes = std::mem::take(&mut state.declared_classes); + + let nonce_updates: HashMap = state_diffs + .address_to_nonce() + .iter() + .map(|(k, v)| (utils::to_address(k), utils::to_felt(v))) + .collect(); + + let declared_classes: HashMap = state_diffs + .class_hash_to_compiled_class() + .iter() + .map(|(k, v)| (utils::to_class_hash(k), utils::to_class_hash(v))) + .collect(); + + let contract_updates: HashMap = state_diffs + .address_to_class_hash() + .iter() + .map(|(k, v)| (utils::to_address(k), utils::to_class_hash(v))) + .collect(); + + let storage_updates: HashMap> = + state_diffs + .storage_updates() + .iter() + .map(|(k, v)| { + let k = utils::to_address(k); + let v = v.iter().map(|(k, v)| (utils::to_felt(k), utils::to_felt(v))).collect(); + (k, v) + }) + .collect(); + + let total_classes = declared_classes.len(); + let mut declared_compiled_classes = HashMap::with_capacity(total_classes); + let mut declared_sierra_classes = HashMap::with_capacity(total_classes); + + for (hash, (compiled, sierra)) in compiled_classes { + declared_compiled_classes.insert(hash, compiled); + if let Some(sierra) = sierra { + declared_sierra_classes.insert(hash, sierra); + } + } + + let state_updates = StateUpdatesWithDeclaredClasses { + declared_sierra_classes, + declared_compiled_classes, + state_updates: StateUpdates { + nonce_updates, + storage_updates, + contract_updates, + declared_classes, + }, + }; + + Ok(ExecutionOutput { states: state_updates, transactions }) + } + + fn state(&self) -> Box { + Box::new(self.state.clone()) + } + + fn transactions(&self) -> &[(TxWithHash, Option)] { + &self.transactions + } + + fn block_env(&self) -> BlockEnv { + BlockEnv { + number: self.block_context.block_info().block_number, + timestamp: self.block_context.block_info().block_timestamp, + sequencer_address: utils::to_address( + &self.block_context.block_info().sequencer_address, + ), + l1_gas_prices: katana_primitives::block::GasPrices { + eth: self.block_context.block_info().gas_price.eth_l1_gas_price as u64, + strk: self.block_context.block_info().gas_price.strk_l1_gas_price as u64, + }, + } + } +} diff --git a/crates/katana/executor/src/implementation/sir/output.rs b/crates/katana/executor/src/implementation/sir/output.rs new file mode 100644 index 0000000000..52be98d700 --- /dev/null +++ b/crates/katana/executor/src/implementation/sir/output.rs @@ -0,0 +1,167 @@ +use std::collections::HashMap; + +use katana_primitives::receipt::{ + DeclareTxReceipt, DeployAccountTxReceipt, Event, InvokeTxReceipt, L1HandlerTxReceipt, + MessageToL1, Receipt, TxExecutionResources, +}; +use katana_primitives::transaction::Tx; +use sir::execution::CallInfo; + +use super::utils; +use crate::abstraction::TransactionExecutionOutput; + +#[derive(Debug, Default)] +pub struct TransactionExecutionInfo { + pub gas_used: u128, + pub(super) inner: sir::execution::TransactionExecutionInfo, +} + +impl TransactionExecutionOutput for TransactionExecutionInfo { + fn receipt(&self, tx: &Tx) -> Receipt { + let actual_fee = self.inner.actual_fee; + let revert_error = self.inner.revert_error.clone(); + + let events = events_from_exec_info(self); + let messages_sent = l2_to_l1_messages_from_exec_info(self); + let execution_resources = parse_actual_resources(&self.inner.actual_resources); + + match tx { + Tx::Invoke(_) => Receipt::Invoke(InvokeTxReceipt { + events, + actual_fee, + revert_error, + messages_sent, + execution_resources, + }), + + Tx::Declare(_) => Receipt::Declare(DeclareTxReceipt { + events, + actual_fee, + revert_error, + messages_sent, + execution_resources, + }), + + Tx::L1Handler(tx) => Receipt::L1Handler(L1HandlerTxReceipt { + events, + actual_fee, + revert_error, + messages_sent, + execution_resources, + message_hash: tx.message_hash, + }), + + Tx::DeployAccount(tx) => Receipt::DeployAccount(DeployAccountTxReceipt { + events, + actual_fee, + revert_error, + messages_sent, + execution_resources, + contract_address: tx.contract_address, + }), + } + } + + fn actual_fee(&self) -> u128 { + self.inner.actual_fee + } + + fn gas_used(&self) -> u128 { + self.gas_used + } + + fn revert_error(&self) -> Option<&str> { + self.inner.revert_error.as_deref() + } +} + +fn events_from_exec_info(info: &TransactionExecutionInfo) -> Vec { + let mut events: Vec = vec![]; + + fn get_events_recursively(call_info: &CallInfo) -> Vec { + let mut events: Vec = vec![]; + + events.extend(call_info.events.iter().map(|e| Event { + from_address: utils::to_address(&call_info.contract_address), + data: e.data.iter().map(utils::to_felt).collect(), + keys: e.keys.iter().map(utils::to_felt).collect(), + })); + + call_info.internal_calls.iter().for_each(|call| { + events.extend(get_events_recursively(call)); + }); + + events + } + + if let Some(ref call) = info.inner.validate_info { + events.extend(get_events_recursively(call)); + } + + if let Some(ref call) = info.inner.call_info { + events.extend(get_events_recursively(call)); + } + + if let Some(ref call) = info.inner.fee_transfer_info { + events.extend(get_events_recursively(call)); + } + + events +} + +fn l2_to_l1_messages_from_exec_info(info: &TransactionExecutionInfo) -> Vec { + let mut messages = vec![]; + + fn get_messages_recursively(info: &CallInfo) -> Vec { + let mut messages = vec![]; + + // By default, `from_address` must correspond to the contract address that + // is sending the message. In the case of library calls, `code_address` is `None`, + // we then use the `caller_address` instead (which can also be an account). + let from_address = if let Some(ref code_address) = info.code_address { + utils::to_address(code_address) + } else { + utils::to_address(&info.caller_address) + }; + + messages.extend(info.l2_to_l1_messages.iter().map(|m| MessageToL1 { + from_address, + to_address: utils::to_felt(&m.to_address.0), + payload: m.payload.iter().map(utils::to_felt).collect(), + })); + + info.internal_calls.iter().for_each(|call| { + messages.extend(get_messages_recursively(call)); + }); + + messages + } + + if let Some(ref info) = info.inner.validate_info { + messages.extend(get_messages_recursively(info)); + } + + if let Some(ref info) = info.inner.call_info { + messages.extend(get_messages_recursively(info)); + } + + if let Some(ref info) = info.inner.fee_transfer_info { + messages.extend(get_messages_recursively(info)); + } + + messages +} + +fn parse_actual_resources(resources: &HashMap) -> TxExecutionResources { + TxExecutionResources { + steps: resources.get("n_steps").copied().unwrap_or_default() as u64, + memory_holes: resources.get("memory_holes").map(|x| *x as u64), + ec_op_builtin: resources.get("ec_op_builtin").map(|x| *x as u64), + ecdsa_builtin: resources.get("ecdsa_builtin").map(|x| *x as u64), + keccak_builtin: resources.get("keccak_builtin").map(|x| *x as u64), + bitwise_builtin: resources.get("bitwise_builtin").map(|x| *x as u64), + pedersen_builtin: resources.get("pedersen_builtin").map(|x| *x as u64), + poseidon_builtin: resources.get("poseidon_builtin").map(|x| *x as u64), + range_check_builtin: resources.get("range_check_builtin").map(|x| *x as u64), + } +} diff --git a/crates/katana/executor/src/implementation/sir/state.rs b/crates/katana/executor/src/implementation/sir/state.rs new file mode 100644 index 0000000000..ff13183b11 --- /dev/null +++ b/crates/katana/executor/src/implementation/sir/state.rs @@ -0,0 +1,248 @@ +use std::collections::HashMap; +use std::sync::Arc; + +use katana_primitives::class::{CompiledClass, FlattenedSierraClass}; +use katana_primitives::contract::{ContractAddress, Nonce, StorageKey, StorageValue}; +use katana_primitives::FieldElement; +use katana_provider::error::ProviderError; +use katana_provider::traits::contract::ContractClassProvider; +use katana_provider::traits::state::StateProvider; +use katana_provider::ProviderResult; +use parking_lot::RwLock; +use sir::core::errors::state_errors::StateError; +use sir::state::cached_state; +use sir::state::contract_class_cache::ContractClassCache; +use sir::state::state_api::StateReader; +use sir::state::state_cache::StorageEntry; +use sir::transaction::{Address, ClassHash, CompiledClassHash}; + +use super::utils; +use crate::abstraction::StateProviderDb; + +/// A helper trait to enforce that a type must implement both [StateProvider] and [StateReader]. +pub(super) trait StateDb: StateProvider + StateReader {} +impl StateDb for T where T: StateProvider + StateReader {} + +impl<'a> StateReader for StateProviderDb<'a> { + fn get_class_hash_at(&self, contract_address: &Address) -> Result { + match self.0.class_hash_of_contract(utils::to_address(contract_address)) { + Ok(Some(value)) => Ok(utils::to_sir_class_hash(&value)), + + Ok(None) => Err(StateError::NoneClassHash(contract_address.clone())), + Err(e) => Err(StateError::CustomError(e.to_string())), + } + } + + fn get_compiled_class_hash( + &self, + class_hash: &ClassHash, + ) -> Result { + match self.0.compiled_class_hash_of_class_hash(utils::to_class_hash(class_hash)) { + Ok(Some(value)) => Ok(utils::to_sir_class_hash(&value)), + + Ok(None) => Err(StateError::NoneCompiledHash(*class_hash)), + Err(e) => Err(StateError::CustomError(e.to_string())), + } + } + + fn get_contract_class( + &self, + class_hash: &ClassHash, + ) -> Result + { + match self.0.class(utils::to_class_hash(class_hash)) { + Ok(Some(value)) => Ok(utils::to_sir_compiled_class(value)), + + Ok(None) => Err(StateError::NoneCompiledClass(*class_hash)), + Err(e) => Err(StateError::CustomError(e.to_string())), + } + } + + fn get_nonce_at(&self, contract_address: &Address) -> Result { + match self.0.nonce(utils::to_address(contract_address)) { + Ok(Some(value)) => Ok(utils::to_sir_felt(&value)), + + Ok(None) => Err(StateError::NoneNonce(contract_address.clone())), + Err(e) => Err(StateError::CustomError(e.to_string())), + } + } + + fn get_storage_at(&self, storage_entry: &StorageEntry) -> Result { + let address = utils::to_address(&storage_entry.0); + let key = FieldElement::from_bytes_be(&storage_entry.1).unwrap(); + + match self.0.storage(address, key) { + Ok(Some(value)) => Ok(utils::to_sir_felt(&value)), + + Ok(None) => Err(StateError::NoneStorage(storage_entry.clone())), + Err(e) => Err(StateError::CustomError(e.to_string())), + } + } +} + +type DeclaredClass = (CompiledClass, Option); + +#[derive(Debug, Default)] +pub(super) struct CachedState(pub(super) Arc>>) +where + S: StateDb + Send + Sync, + C: ContractClassCache + Send + Sync; + +impl Clone for CachedState +where + S: StateDb + Send + Sync, + C: ContractClassCache + Send + Sync, +{ + fn clone(&self) -> Self { + Self(Arc::clone(&self.0)) + } +} + +#[derive(Debug, Default)] +pub(super) struct CachedStateInner +where + S: StateDb + Send + Sync, + C: ContractClassCache + Send + Sync, +{ + pub(super) inner: cached_state::CachedState, + pub(super) declared_classes: HashMap, +} + +impl CachedState +where + S: StateDb + Send + Sync, + C: ContractClassCache + Send + Sync, +{ + pub(super) fn new(state: S, classes_cache: C) -> Self { + let declared_classes = HashMap::new(); + let cached_state = cached_state::CachedState::new(Arc::new(state), Arc::new(classes_cache)); + let inner = CachedStateInner { inner: cached_state, declared_classes }; + Self(Arc::new(RwLock::new(inner))) + } +} + +impl ContractClassProvider for CachedState +where + S: StateDb + Send + Sync, + C: ContractClassCache + Send + Sync, +{ + fn class( + &self, + hash: katana_primitives::class::ClassHash, + ) -> ProviderResult> { + let inner = self.0.read(); + let class = inner.declared_classes.get(&hash).map(|(class, _)| class.clone()); + Ok(class) + } + + fn compiled_class_hash_of_class_hash( + &self, + hash: katana_primitives::class::ClassHash, + ) -> ProviderResult> { + let state = self.0.read(); + let hash = utils::to_sir_class_hash(&hash); + + match state.inner.get_compiled_class_hash(&hash) { + Ok(value) => Ok(Some(utils::to_class_hash(&value))), + + Err(StateError::NoneCompiledHash(_)) => Ok(None), + Err(e) => Err(ProviderError::Other(e.to_string())), + } + } + + fn sierra_class( + &self, + hash: katana_primitives::class::ClassHash, + ) -> ProviderResult> { + let state = self.0.read(); + if let Some((_, sierra)) = state.declared_classes.get(&hash) { + Ok(sierra.clone()) + } else { + state.inner.state_reader.sierra_class(hash) + } + } +} + +impl StateProvider for CachedState +where + S: StateDb + Send + Sync, + C: ContractClassCache + Send + Sync, +{ + fn class_hash_of_contract( + &self, + address: ContractAddress, + ) -> ProviderResult> { + let state = self.0.read(); + let address = utils::to_sir_address(&address); + + match state.inner.get_class_hash_at(&address) { + Ok(value) => Ok(Some(utils::to_class_hash(&value))), + + Err(StateError::NoneClassHash(_)) => Ok(None), + Err(e) => Err(ProviderError::Other(e.to_string())), + } + } + + fn nonce(&self, address: ContractAddress) -> ProviderResult> { + let state = self.0.read(); + let address = utils::to_sir_address(&address); + + match state.inner.get_nonce_at(&address) { + Ok(value) => Ok(Some(utils::to_felt(&value))), + + Err(StateError::NoneNonce(_)) => Ok(None), + Err(e) => Err(ProviderError::Other(e.to_string())), + } + } + + fn storage( + &self, + address: ContractAddress, + storage_key: StorageKey, + ) -> ProviderResult> { + let state = self.0.read(); + + let address = utils::to_sir_address(&address); + let key = utils::to_sir_felt(&storage_key); + + match state.inner.get_storage_at(&(address, key.to_bytes_be())) { + Ok(value) => Ok(Some(utils::to_felt(&value))), + + Err(StateError::NoneStorage(_)) => Ok(None), + Err(e) => Err(ProviderError::Other(e.to_string())), + } + } +} + +impl StateReader for CachedState +where + S: StateDb + Send + Sync, + C: ContractClassCache + Send + Sync, +{ + fn get_class_hash_at(&self, contract_address: &Address) -> Result { + self.0.read().inner.get_class_hash_at(contract_address) + } + + fn get_compiled_class_hash( + &self, + class_hash: &ClassHash, + ) -> Result { + self.0.read().inner.get_compiled_class_hash(class_hash) + } + + fn get_contract_class( + &self, + class_hash: &ClassHash, + ) -> Result + { + self.0.read().inner.get_contract_class(class_hash) + } + + fn get_nonce_at(&self, contract_address: &Address) -> Result { + self.0.read().inner.get_nonce_at(contract_address) + } + + fn get_storage_at(&self, storage_entry: &StorageEntry) -> Result { + self.0.read().inner.get_storage_at(storage_entry) + } +} diff --git a/crates/katana/executor/src/implementation/sir/utils.rs b/crates/katana/executor/src/implementation/sir/utils.rs new file mode 100644 index 0000000000..98619b9243 --- /dev/null +++ b/crates/katana/executor/src/implementation/sir/utils.rs @@ -0,0 +1,384 @@ +use std::str::FromStr; +use std::sync::Arc; + +use katana_primitives::class::{CompiledClass, DeprecatedCompiledClass}; +use katana_primitives::contract::ContractAddress; +use katana_primitives::transaction::{ExecutableTx, ExecutableTxWithHash}; +use katana_primitives::FieldElement; +use sir::definitions::block_context::BlockContext; +use sir::definitions::constants::TRANSACTION_VERSION; +use sir::execution::execution_entry_point::{ExecutionEntryPoint, ExecutionResult}; +use sir::execution::{CallType, TransactionExecutionContext}; +use sir::services::api::contract_classes::compiled_class::CompiledClass as SirCompiledClass; +use sir::services::api::contract_classes::deprecated_contract_class::ContractClass as SirDeprecatedContractClass; +use sir::state::contract_class_cache::ContractClassCache; +use sir::state::state_api::StateReader; +use sir::state::state_cache::StateCache; +use sir::state::{cached_state, ExecutionResourcesManager, StateDiff}; +use sir::transaction::error::TransactionError; +use sir::transaction::fee::calculate_tx_l1_gas_usage; +use sir::transaction::{ + Address, ClassHash, Declare, DeclareDeprecated, DeployAccount, InvokeFunction, L1Handler, + Transaction, VersionSpecificAccountTxFields, +}; +use sir::utils::calculate_sn_keccak; +use sir::EntryPointType; +use starknet_types_core::felt::Felt; + +use super::output::TransactionExecutionInfo; +use super::state::StateDb; +use super::SimulationFlag; +use crate::EntryPointCall; + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error("failed to execute transaction: {0}")] + TransactionError(#[from] sir::transaction::error::TransactionError), +} + +pub(super) fn transact( + tx: ExecutableTxWithHash, + state: &mut cached_state::CachedState, + block_context: &BlockContext, + remaining_gas: u128, + simulation_flag: &SimulationFlag, +) -> Result +where + S: StateReader, + C: ContractClassCache, +{ + let tx = to_executor_tx(tx, simulation_flag)?; + let res = match tx { + Transaction::InvokeFunction(tx) => tx.execute( + state, + block_context, + remaining_gas, + #[cfg(feature = "native")] + None, + ), + + Transaction::DeployAccount(tx) => tx.execute( + state, + block_context, + #[cfg(feature = "native")] + None, + ), + + Transaction::DeclareDeprecated(tx) => tx.execute( + state, + block_context, + #[cfg(feature = "native")] + None, + ), + + Transaction::Deploy(tx) => tx.execute( + state, + block_context, + #[cfg(feature = "native")] + None, + ), + + Transaction::L1Handler(tx) => tx.execute( + state, + block_context, + remaining_gas, + #[cfg(feature = "native")] + None, + ), + + Transaction::Declare(tx) => tx.execute( + state, + block_context, + #[cfg(feature = "native")] + None, + ), + }?; + + let gas_used = calculate_tx_l1_gas_usage(&res.actual_resources, block_context)?; + Ok(TransactionExecutionInfo { inner: res, gas_used }) +} + +pub(super) fn call( + params: EntryPointCall, + state: &mut cached_state::CachedState, + block_context: &BlockContext, + initial_gas: u128, +) -> Result +where + S: StateDb + Send + Sync, + C: ContractClassCache + Send + Sync, +{ + // let state_reader = Arc::new(state); + // let contract_classes = Arc::new(PermanentContractClassCache::default()); + // let mut state = cached_state::CachedState::new(state_reader, contract_classes); + + let contract_address = to_sir_address(¶ms.contract_address); + let entry_point_selector = to_sir_felt(¶ms.entry_point_selector); + let calldata = params.calldata.iter().map(to_sir_felt).collect::>(); + let call_type = Some(CallType::Call); + let caller_address = Address::default(); + let entry_point_type = EntryPointType::External; + + let call = ExecutionEntryPoint::new( + contract_address, + calldata, + entry_point_selector, + caller_address, + entry_point_type, + call_type, + None, + initial_gas, + ); + + let max_steps = block_context.invoke_tx_max_n_steps(); + let mut resources_manager = ExecutionResourcesManager::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address::default(), + Felt::default(), + Vec::new(), + Default::default(), + Felt::default(), + block_context.invoke_tx_max_n_steps(), + *TRANSACTION_VERSION, + ); + + let result = call.execute( + state, + block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + max_steps, + #[cfg(feature = "native")] + None, + )?; + + Ok(result) +} + +fn to_executor_tx( + katana_tx: ExecutableTxWithHash, + simulation_flag: &SimulationFlag, +) -> Result { + match katana_tx.transaction { + ExecutableTx::Invoke(tx) => { + let contract_address = to_sir_address(&tx.sender_address); + let entry_point = Felt::from_bytes_be(&calculate_sn_keccak(b"__execute__")); + let ver_specifc_fields = VersionSpecificAccountTxFields::Deprecated(tx.max_fee); + let version = to_sir_felt(&tx.version); + let calldata = tx.calldata.iter().map(to_sir_felt).collect::>(); + let signature = tx.signature.iter().map(to_sir_felt).collect::>(); + let nonce = Some(to_sir_felt(&tx.nonce)); + let tx_hash = to_sir_felt(&katana_tx.hash); + + let tx = InvokeFunction::new_with_tx_hash( + contract_address, + entry_point, + ver_specifc_fields, + version, + calldata, + signature, + nonce, + tx_hash, + )?; + + let tx = tx.create_for_simulation( + simulation_flag.skip_validate, + simulation_flag.skip_execute, + simulation_flag.skip_fee_transfer, + simulation_flag.ignore_max_fee, + simulation_flag.skip_nonce_check, + ); + + Ok(tx) + } + + ExecutableTx::DeployAccount(tx) => { + let class_hash = to_sir_class_hash(&tx.class_hash); + let ver_specifc_fields = VersionSpecificAccountTxFields::Deprecated(tx.max_fee); + let version = to_sir_felt(&tx.version); + let calldata = tx.constructor_calldata.iter().map(to_sir_felt).collect(); + let signature = tx.signature.iter().map(to_sir_felt).collect::>(); + let nonce = to_sir_felt(&tx.nonce); + let tx_hash = to_sir_felt(&katana_tx.hash); + + let tx = DeployAccount::new_with_tx_hash( + class_hash, + ver_specifc_fields, + version, + nonce, + calldata, + signature, + nonce, + tx_hash, + )?; + + let tx = tx.create_for_simulation( + simulation_flag.skip_validate, + simulation_flag.skip_execute, + simulation_flag.skip_fee_transfer, + simulation_flag.ignore_max_fee, + simulation_flag.skip_nonce_check, + ); + + Ok(tx) + } + + ExecutableTx::Declare(declare) => match declare.transaction { + katana_primitives::transaction::DeclareTx::V1(tx) => { + let sender_address = to_sir_address(&tx.sender_address); + let max_fee = tx.max_fee; + let version = Felt::ONE; + let signature = tx.signature.iter().map(to_sir_felt).collect::>(); + let nonce = to_sir_felt(&tx.nonce); + let tx_hash = to_sir_felt(&katana_tx.hash); + let class_hash = to_sir_class_hash(&tx.class_hash); + + let CompiledClass::Deprecated(class) = declare.compiled_class else { panic!() }; + let contract_class = to_sir_deprecated_class(class.clone()); + + let tx = DeclareDeprecated::new_with_tx_and_class_hash( + contract_class, + sender_address, + max_fee, + version, + signature, + nonce, + tx_hash, + class_hash, + )?; + + let tx = tx.create_for_simulation( + simulation_flag.skip_validate, + simulation_flag.skip_execute, + simulation_flag.skip_fee_transfer, + simulation_flag.ignore_max_fee, + simulation_flag.skip_nonce_check, + ); + + Ok(tx) + } + + katana_primitives::transaction::DeclareTx::V2(tx) => { + let sierra_contract_class = None; + let sierra_class_hash = to_sir_felt(&tx.class_hash); + let compiled_class_hash = to_sir_felt(&tx.compiled_class_hash); + let sender_address = to_sir_address(&tx.sender_address); + let account_tx_fields = VersionSpecificAccountTxFields::Deprecated(tx.max_fee); + let version = Felt::TWO; + let signature = tx.signature.iter().map(to_sir_felt).collect::>(); + let nonce = to_sir_felt(&tx.nonce); + let tx_hash = to_sir_felt(&katana_tx.hash); + + let CompiledClass::Class(class) = declare.compiled_class else { panic!() }; + let casm_contract_class = Some(class.casm.clone()); + + let tx = Declare::new_with_sierra_class_hash_and_tx_hash( + sierra_contract_class, + sierra_class_hash, + casm_contract_class, + compiled_class_hash, + sender_address, + account_tx_fields, + version, + signature, + nonce, + tx_hash, + )?; + + let tx = tx.create_for_simulation( + simulation_flag.skip_validate, + simulation_flag.skip_execute, + simulation_flag.skip_fee_transfer, + simulation_flag.ignore_max_fee, + simulation_flag.skip_nonce_check, + ); + + Ok(tx) + } + }, + + ExecutableTx::L1Handler(tx) => { + let contract_address = to_sir_address(&tx.contract_address); + let entry_point = to_sir_felt(&tx.entry_point_selector); + let calldata = tx.calldata.iter().map(to_sir_felt).collect::>(); + let nonce = to_sir_felt(&tx.nonce); + let paid_fee_on_l1 = Some(Felt::from(tx.paid_fee_on_l1)); + let tx_hash = to_sir_felt(&katana_tx.hash); + + let tx = L1Handler::new_with_tx_hash( + contract_address, + entry_point, + calldata, + nonce, + paid_fee_on_l1, + tx_hash, + )?; + + let tx = tx + .create_for_simulation(simulation_flag.skip_validate, simulation_flag.skip_execute); + + Ok(tx) + } + } +} + +pub(super) fn state_diff_from_state_cache(mut cache: StateCache) -> StateDiff { + let address_to_class_hash = std::mem::take(cache.class_hash_writes_mut()); + let address_to_nonce = std::mem::take(cache.nonce_writes_mut()); + let class_hash_to_compiled_class = std::mem::take(cache.compiled_class_hash_writes_mut()); + let storage_updates = sir::utils::to_state_diff_storage_mapping(cache.storage_writes()); + + StateDiff::new( + address_to_class_hash, + address_to_nonce, + class_hash_to_compiled_class, + storage_updates, + ) +} + +pub(super) fn to_felt(value: &Felt) -> FieldElement { + FieldElement::from_bytes_be(&value.to_bytes_be()).unwrap() +} + +pub(super) fn to_sir_felt(value: &FieldElement) -> Felt { + Felt::from_bytes_be(&value.to_bytes_be()) +} + +pub(super) fn to_address(value: &Address) -> ContractAddress { + ContractAddress::new(FieldElement::from_bytes_be(&value.0.to_bytes_be()).unwrap()) +} + +pub(super) fn to_sir_address(value: &ContractAddress) -> Address { + Address(to_sir_felt(&value.0)) +} + +pub(super) fn to_class_hash(value: &ClassHash) -> katana_primitives::class::ClassHash { + FieldElement::from_bytes_be(&value.0).unwrap() +} + +pub(super) fn to_sir_class_hash(value: &katana_primitives::class::ClassHash) -> ClassHash { + ClassHash(value.to_bytes_be()) +} + +pub(super) fn to_sir_compiled_class(class: CompiledClass) -> SirCompiledClass { + match class { + CompiledClass::Class(class) => { + let casm = Arc::new(class.casm); + let sierra = Some(Arc::new((class.sierra.program, class.sierra.entry_points_by_type))); + SirCompiledClass::Casm { casm, sierra } + } + + CompiledClass::Deprecated(class) => { + let class = Arc::new(to_sir_deprecated_class(class)); + SirCompiledClass::Deprecated(class) + } + } +} + +pub(super) fn to_sir_deprecated_class( + class: DeprecatedCompiledClass, +) -> SirDeprecatedContractClass { + let json = serde_json::to_string(&class).unwrap(); + SirDeprecatedContractClass::from_str(&json).unwrap() +} diff --git a/scripts/clippy.sh b/scripts/clippy.sh index 8c01e87ecb..5c15593ae6 100755 --- a/scripts/clippy.sh +++ b/scripts/clippy.sh @@ -1,7 +1,7 @@ #!/bin/bash run_clippy() { - cargo clippy --all-targets --all-features "$@" -- -D warnings -D future-incompatible -D nonstandard-style -D rust-2018-idioms -D unused + cargo clippy --all-targets "$@" -- -D warnings -D future-incompatible -D nonstandard-style -D rust-2018-idioms -D unused } -run_clippy +run_clippy --all-features --workspace --exclude katana && run_clippy -p katana