diff --git a/Cargo.lock b/Cargo.lock index 84770707a4..434806a76d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] @@ -87,9 +87,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" [[package]] name = "android-tzdata" @@ -114,9 +114,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -129,43 +129,43 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "aquamarine" @@ -200,7 +200,7 @@ dependencies = [ "derivative", "hashbrown 0.13.2", "itertools 0.10.5", - "num-traits 0.2.19", + "num-traits", "zeroize", ] @@ -218,7 +218,7 @@ dependencies = [ "digest 0.10.7", "itertools 0.10.5", "num-bigint 0.4.6", - "num-traits 0.2.19", + "num-traits", "paste", "rustc_version", "zeroize", @@ -241,7 +241,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ "num-bigint 0.4.6", - "num-traits 0.2.19", + "num-traits", "proc-macro2", "quote", "syn 1.0.109", @@ -311,7 +311,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ - "num-traits 0.2.19", + "num-traits", "rand 0.8.5", ] @@ -346,9 +346,9 @@ dependencies = [ "asn1-rs-impl", "displaydoc", "nom", - "num-traits 0.2.19", + "num-traits", "rusticata-macros", - "thiserror 1.0.64", + "thiserror 1.0.69", "time", ] @@ -416,9 +416,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.13" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e614738943d3f68c628ae3dbce7c3daffb196665f82f8c8ea6b65de73c79429" +checksum = "0cb8f1d480b0ea3783ab015936d2a55c87e219676f0c0b7dec61494043f21857" dependencies = [ "flate2", "futures-core", @@ -435,8 +435,8 @@ checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec" dependencies = [ "async-task", "concurrent-queue", - "fastrand 2.1.1", - "futures-lite 2.3.0", + "fastrand 2.2.0", + "futures-lite 2.5.0", "slab", ] @@ -460,10 +460,10 @@ checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" dependencies = [ "async-channel 2.3.1", "async-executor", - "async-io 2.3.4", + "async-io 2.4.0", "async-lock 3.4.0", "blocking", - "futures-lite 2.3.0", + "futures-lite 2.5.0", "once_cell", ] @@ -489,17 +489,17 @@ dependencies = [ [[package]] name = "async-io" -version = "2.3.4" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444b0228950ee6501b3568d3c93bf1176a1fdbc3b758dcd9475046d30f4dc7e8" +checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" dependencies = [ "async-lock 3.4.0", "cfg-if", "concurrent-queue", "futures-io", - "futures-lite 2.3.0", + "futures-lite 2.5.0", "parking", - "polling 3.7.3", + "polling 3.7.4", "rustix 0.38.40", "slab", "tracing", @@ -571,7 +571,7 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3" dependencies = [ - "async-io 2.3.4", + "async-io 2.4.0", "async-lock 3.4.0", "atomic-waker", "cfg-if", @@ -591,13 +591,13 @@ checksum = "c634475f29802fde2b8f0b505b1bd00dfe4df7d4a000f0b36f7671197d5c3615" dependencies = [ "async-channel 1.9.0", "async-global-executor", - "async-io 2.3.4", + "async-io 2.4.0", "async-lock 3.4.0", "crossbeam-utils", "futures-channel", "futures-core", "futures-io", - "futures-lite 2.3.0", + "futures-lite 2.5.0", "gloo-timers 0.3.0", "kv-log-macro", "log", @@ -741,7 +741,7 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.30", + "hyper 0.14.31", "itoa", "matchit", "memchr", @@ -851,7 +851,7 @@ checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" dependencies = [ "num-bigint 0.4.6", "num-integer", - "num-traits 0.2.19", + "num-traits", "serde", ] @@ -895,9 +895,9 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.69.4" +version = "0.69.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" dependencies = [ "bitflags 2.6.0", "cexpr", @@ -1021,7 +1021,7 @@ dependencies = [ "cairo-native", "cairo-vm", "criterion", - "derive_more", + "derive_more 0.99.18", "glob", "indexmap 2.6.0", "itertools 0.10.5", @@ -1030,7 +1030,7 @@ dependencies = [ "num-bigint 0.4.6", "num-integer", "num-rational 0.4.2", - "num-traits 0.2.19", + "num-traits", "papyrus_config", "paste", "phf", @@ -1049,7 +1049,7 @@ dependencies = [ "strum_macros 0.25.3", "tempfile", "test-case", - "thiserror 1.0.64", + "thiserror 1.0.69", "tikv-jemallocator", "toml", "tracing", @@ -1064,7 +1064,7 @@ dependencies = [ "async-channel 2.3.1", "async-task", "futures-io", - "futures-lite 2.3.0", + "futures-lite 2.5.0", "piper", ] @@ -1080,9 +1080,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22" dependencies = [ "memchr", "serde", @@ -1114,9 +1114,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" dependencies = [ "serde", ] @@ -1155,7 +1155,7 @@ dependencies = [ "hashbrown 0.13.2", "instant", "once_cell", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", ] @@ -1180,14 +1180,14 @@ checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" [[package]] name = "cairo-lang-casm" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd4d6659539ace9649c8e8a7434e51b0c50a7a700111d0a2b967dde220ddff49" +checksum = "e1e0dcdb6358bb639dd729546611bd99bada94c86e3f262c3637855abea9a972" dependencies = [ "cairo-lang-utils", "indoc 2.0.5", "num-bigint 0.4.6", - "num-traits 0.2.19", + "num-traits", "parity-scale-codec", "schemars", "serde", @@ -1195,9 +1195,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2016966ed29f3a44487fd1bbdb05320fb6ea8ec46201c04c6b222ccb5264e0a" +checksum = "b8657f5a5611f341a85e80ba0b21848fc34bfdf391bfd93df0baf4516c3e4159" dependencies = [ "anyhow", "cairo-lang-defs", @@ -1216,23 +1216,23 @@ dependencies = [ "rust-analyzer-salsa", "semver", "smol_str", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] name = "cairo-lang-debug" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c804649297ca417206435ee3e8041d2100cc31ebf4a95bc4b92ed02dc63469" +checksum = "0635aa554d297acefe6a35b495aba2795d0af5b7f97c4ab63829c7d62291ef41" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fbda467ac36f73bb1879e1f741898fc719d6f9239a01cc422e6a023281319b" +checksum = "86b356e1c09898e8b8cfdd9731579d89365a13d8b4f7e717962e0cc7d125b83c" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -1247,9 +1247,9 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c843ef4715e3d21de5388d02206db2506e2d2ec0e80e2629e0ae9900a08b8674" +checksum = "2dfe7c6ff96182da29012b707a3554e34a50f19cc96013ee45b0eb36dd396ec8" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1259,9 +1259,9 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33a416c5871960fb4823160ebef2abc51e0c1b86fef1e97a1ebb2e5f3c3795d3" +checksum = "723d244465309d5409e297b5486d62cbec06f2c47b05044414bb640e3f14caab" dependencies = [ "cairo-lang-utils", "good_lp", @@ -1269,9 +1269,9 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47189e0cb84b21defd201af4cf24a94c6b0d09f48706cf659c9ffa0def8a7a43" +checksum = "237030772ae5368f19a9247e1f63f753f8ad8de963477166e402f4825c0a141d" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -1280,13 +1280,14 @@ dependencies = [ "semver", "serde", "smol_str", + "toml", ] [[package]] name = "cairo-lang-formatter" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6409ff1f4a93ce7c0968d9d857d2a8c03657617a827159d33f978110b718b31d" +checksum = "5b71f0eb3a36a6cb5f7f07843926783c4c17e44c9516b53171727a108782f3eb" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -1299,15 +1300,14 @@ dependencies = [ "itertools 0.12.1", "rust-analyzer-salsa", "serde", - "smol_str", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] name = "cairo-lang-lowering" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e224e006c82ef21bd9e243390992de2be25ae6fbbdaa8544067b3f0c31977f1" +checksum = "7d095d78e2f1de499429c95655d6135a3d24c384b36d8de9f84e0aa4e07ee152" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1322,16 +1322,17 @@ dependencies = [ "itertools 0.12.1", "log", "num-bigint 0.4.6", - "num-traits 0.2.19", + "num-integer", + "num-traits", "rust-analyzer-salsa", "smol_str", ] [[package]] name = "cairo-lang-parser" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb260ba349c2b699639e56f9b64deb969ff01179a0253087e2c8ceec7e32157" +checksum = "bb828af7f948a3ef7fa65de14e3f639daedefb046dfefcad6e3116d2cb0f89a0" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -1341,7 +1342,7 @@ dependencies = [ "colored", "itertools 0.12.1", "num-bigint 0.4.6", - "num-traits 0.2.19", + "num-traits", "rust-analyzer-salsa", "smol_str", "unescaper", @@ -1349,9 +1350,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05a2e500dc8ddea4d25a866d8a839158b0e4c41a6c023f21911e2da252bd91b3" +checksum = "135a600043bf7030eacc6ebf2a609c2364d6ffeb04e1f3c809a2738f6b02c829" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -1368,9 +1369,9 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d72f17373740f242d6995e896b9195c2cedff7e8b14e496afdd16b405039d1fb" +checksum = "ac857ec4b564712f3e16e3314e23cc0787ab1c05cdfee83f1c8f9989a6eee40f" dependencies = [ "cairo-lang-debug", "quote", @@ -1379,23 +1380,23 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13294f08d2013fcd6e815e7235935680963dec3390e5baf454f33da866fc44b6" +checksum = "23cc37b7f8889cdea631aeea3bcc70d5c86ac8fb1d98aabc83f16283d60f1643" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", "serde", "smol_str", - "thiserror 1.0.64", + "thiserror 1.0.69", "toml", ] [[package]] name = "cairo-lang-runner" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b9e6a21d92255b92f64c60658b4224dd7d290cde8beea783fadc10fbfcd8c" +checksum = "7474375528ffa7f47e343983d32051898e4e7b05ac0bdc48ee84b1325d8b562a" dependencies = [ "ark-ff", "ark-secp256k1", @@ -1414,19 +1415,19 @@ dependencies = [ "keccak", "num-bigint 0.4.6", "num-integer", - "num-traits 0.2.19", + "num-traits", "rand 0.8.5", "sha2", "smol_str", "starknet-types-core", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] name = "cairo-lang-semantic" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6936215bca75c23e71873998420a3d46c322507a09917ce676c8d39f8c1bd6fe" +checksum = "c560cf4b4a89325d3a9594f490fffee38cf30e0990e808bb927619de9d0c973a" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1442,7 +1443,7 @@ dependencies = [ "indoc 2.0.5", "itertools 0.12.1", "num-bigint 0.4.6", - "num-traits 0.2.19", + "num-traits", "rust-analyzer-salsa", "smol_str", "toml", @@ -1450,9 +1451,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "424f55450494e959c1ae26c52a71075767a90f76e3ecca6e81056dd7517e8ba0" +checksum = "8118f55ca7d567bfc60960b445d388564d04bf48335c983b1595cb35f67a01c5" dependencies = [ "anyhow", "cairo-lang-utils", @@ -1464,7 +1465,7 @@ dependencies = [ "lalrpop-util", "num-bigint 0.4.6", "num-integer", - "num-traits 0.2.19", + "num-traits", "regex", "rust-analyzer-salsa", "serde", @@ -1472,14 +1473,14 @@ dependencies = [ "sha3", "smol_str", "starknet-types-core", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053dd520e0b9d1c1078d93ea69045f6f334c3d41b4b75db183ab33e32cfd8570" +checksum = "2716ef8d4ce0fb700f83ed3281f3656436570e60249d41c65c79dc1ca27be002" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1487,15 +1488,15 @@ dependencies = [ "cairo-lang-utils", "itertools 0.12.1", "num-bigint 0.4.6", - "num-traits 0.2.19", - "thiserror 1.0.64", + "num-traits", + "thiserror 1.0.69", ] [[package]] name = "cairo-lang-sierra-gas" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a73227867377efc62ebb893cddaa88df3940bf2be5dbdc2f0b00f9edf69288e" +checksum = "24a44da87a35845470c4f4c648225232a15e0875fe809045b6088464491f838b" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1503,15 +1504,15 @@ dependencies = [ "cairo-lang-utils", "itertools 0.12.1", "num-bigint 0.4.6", - "num-traits 0.2.19", - "thiserror 1.0.64", + "num-traits", + "thiserror 1.0.69", ] [[package]] name = "cairo-lang-sierra-generator" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3752cacd475ea089d9a536357804150e693a124e703fcc33a55566d568094b3" +checksum = "15bc5cf9f3965a7030a114dfe3d31d183287fbfbfbf904deaaa2468cadb936aa" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1524,7 +1525,7 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "itertools 0.12.1", - "num-traits 0.2.19", + "num-traits", "rust-analyzer-salsa", "serde", "serde_json", @@ -1533,9 +1534,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7162fb3c93960dfc6d8005b65064e518e3f1ed6102e8981b42ea41879c331184" +checksum = "18b7616f1a3c41c4646094b5abf774e558428e9c1eda5d78d7b0638ec5c264e5" dependencies = [ "assert_matches", "cairo-lang-casm", @@ -1547,16 +1548,16 @@ dependencies = [ "indoc 2.0.5", "itertools 0.12.1", "num-bigint 0.4.6", - "num-traits 0.2.19", + "num-traits", "starknet-types-core", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] name = "cairo-lang-sierra-type-size" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a51b80c117e2b05a6d300f2e2247892cc99e42e950e79f6085e6ed6cbcb44d12" +checksum = "871077dbc08df5d134dc3975538171c14b266ba405d1298085afdb227216f0a3" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -1564,9 +1565,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafaabc43f78dfa2f45d935993ba21c05c164bbb3bf277d348847a51e5939a9f" +checksum = "9f21804eb8931d41e258e7a393afc8ee8858308e95b3ed2e9b6b469ef68a6a50" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -1589,14 +1590,14 @@ dependencies = [ "serde_json", "smol_str", "starknet-types-core", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] name = "cairo-lang-starknet-classes" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "832fd9072ddf4204ca6d227c0238929349f10146bd066a98025d51ac15d27fad" +checksum = "b2496bccd68fa0286b35b72c98439316a3a872ef7ec6d881f0dac90b17997490" dependencies = [ "cairo-lang-casm", "cairo-lang-sierra", @@ -1606,26 +1607,26 @@ dependencies = [ "itertools 0.12.1", "num-bigint 0.4.6", "num-integer", - "num-traits 0.2.19", + "num-traits", "serde", "serde_json", "sha3", "smol_str", "starknet-types-core", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] name = "cairo-lang-syntax" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cebe67c0d68f9acf8709d170c1308ca57a778d22f70da38a57f74ae250eee28a" +checksum = "8d77ea2e35d3610098ff13e373fc519aedc6a5096ed8547081aacfc104ef4422" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", "cairo-lang-utils", "num-bigint 0.4.6", - "num-traits 0.2.19", + "num-traits", "rust-analyzer-salsa", "smol_str", "unescaper", @@ -1633,9 +1634,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31cef5b4347626e61bad8f070495cd35d637a5cb6744c34d20dd382c7431aff8" +checksum = "6b01d505ab26ca9ce829faf3a8dd097f5d7962d2eb8f136017a260694a6a72e8" dependencies = [ "genco", "xshell", @@ -1643,9 +1644,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-plugin" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5f036132e07b7829cb1d61b1ecc02789a70c7d16b2733722a2aca992492bc3" +checksum = "05f83e082c8ebf81295156f13399f880037c749a9f1fc3f55b1be7e49fe124c6" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -1663,16 +1664,16 @@ dependencies = [ "indoc 2.0.5", "itertools 0.12.1", "num-bigint 0.4.6", - "num-traits 0.2.19", + "num-traits", "serde", "starknet-types-core", ] [[package]] name = "cairo-lang-test-utils" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "060c61ac4a3ae0428771244ff8db903105f127392b7d725d919fe3fb1ec4132f" +checksum = "eb143a22f5a3510df8c4dec76e17c1e36bbcbddcd7915601f6a51a72418c454f" dependencies = [ "cairo-lang-formatter", "cairo-lang-utils", @@ -1683,15 +1684,15 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.8.4" +version = "2.9.0-dev.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bfc6372538143afad658c853a35bdc9f5210c5cb54e0c8f04ab78e268139466" +checksum = "35df943ebcf8e1db11ee9f4f46f843dde5b71639ca79ea0d8caa7973f91d8b12" dependencies = [ "hashbrown 0.14.5", "indexmap 2.6.0", "itertools 0.12.1", "num-bigint 0.4.6", - "num-traits 0.2.19", + "num-traits", "parity-scale-codec", "schemars", "serde", @@ -1699,8 +1700,8 @@ dependencies = [ [[package]] name = "cairo-native" -version = "0.2.0-alpha.4" -source = "git+https://github.com/lambdaclass/cairo_native?rev=ebfa9a116d03618e90fc52773e73958b179dd775#ebfa9a116d03618e90fc52773e73958b179dd775" +version = "0.2.3" +source = "git+https://github.com/lambdaclass/cairo_native?rev=5e60089288c461eca98bf3dbe03cc882778ff677#5e60089288c461eca98bf3dbe03cc882778ff677" dependencies = [ "anyhow", "aquamarine", @@ -1737,14 +1738,14 @@ dependencies = [ "mlir-sys", "num-bigint 0.4.6", "num-integer", - "num-traits 0.2.19", + "num-traits", "serde", "serde_json", "sha2", "starknet-types-core", "stats_alloc", "tempfile", - "thiserror 1.0.64", + "thiserror 1.0.69", "tracing", "tracing-subscriber", "utf8_iter", @@ -1752,13 +1753,13 @@ dependencies = [ [[package]] name = "cairo-native-runtime" -version = "0.2.0-alpha.4" -source = "git+https://github.com/lambdaclass/cairo_native?rev=ebfa9a116d03618e90fc52773e73958b179dd775#ebfa9a116d03618e90fc52773e73958b179dd775" +version = "0.2.3" +source = "git+https://github.com/lambdaclass/cairo_native?rev=5e60089288c461eca98bf3dbe03cc882778ff677#5e60089288c461eca98bf3dbe03cc882778ff677" dependencies = [ "cairo-lang-sierra-gas", "itertools 0.13.0", "lazy_static", - "num-traits 0.2.19", + "num-traits", "rand 0.8.5", "starknet-curve 0.5.1", "starknet-types-core", @@ -1782,7 +1783,7 @@ dependencies = [ "num-bigint 0.4.6", "num-integer", "num-prime", - "num-traits 0.2.19", + "num-traits", "rand 0.8.5", "rust_decimal", "serde", @@ -1830,7 +1831,7 @@ dependencies = [ "semver", "serde", "serde_json", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -1914,7 +1915,7 @@ dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", - "num-traits 0.2.19", + "num-traits", "serde", "wasm-bindgen", "windows-targets 0.52.6", @@ -2005,9 +2006,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "cloudabi" @@ -2031,7 +2032,7 @@ dependencies = [ "k256", "serde", "sha2", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -2047,7 +2048,7 @@ dependencies = [ "pbkdf2 0.12.2", "rand 0.8.5", "sha2", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -2067,14 +2068,14 @@ dependencies = [ "serde_derive", "sha2", "sha3", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] name = "colorchoice" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "colored" @@ -2092,7 +2093,7 @@ version = "0.0.0" dependencies = [ "clap", "criterion", - "derive_more", + "derive_more 0.99.18", "ethnum", "futures", "indexmap 2.6.0", @@ -2109,7 +2110,7 @@ dependencies = [ "strum 0.25.0", "strum_macros 0.25.3", "tempfile", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tracing", "tracing-subscriber", @@ -2274,9 +2275,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" dependencies = [ "libc", ] @@ -2303,7 +2304,7 @@ dependencies = [ "criterion-plot", "is-terminal", "itertools 0.10.5", - "num-traits 0.2.19", + "num-traits", "once_cell", "oorandom", "plotters", @@ -2582,7 +2583,7 @@ dependencies = [ "displaydoc", "nom", "num-bigint 0.4.6", - "num-traits 0.2.19", + "num-traits", "rusticata-macros", ] @@ -2608,18 +2609,18 @@ dependencies = [ [[package]] name = "derive_builder" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd33f37ee6a119146a1781d3356a7c26028f83d779b2e04ecd45fdc75c76877b" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" dependencies = [ "derive_builder_macro", ] [[package]] name = "derive_builder_core" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7431fa049613920234f22c47fdc33e6cf3ee83067091ea4277a3f8c4587aae38" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" dependencies = [ "darling 0.20.10", "proc-macro2", @@ -2629,9 +2630,9 @@ dependencies = [ [[package]] name = "derive_builder_macro" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", "syn 2.0.87", @@ -2650,6 +2651,26 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "deunicode" version = "1.6.0" @@ -2869,9 +2890,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.34" +version = "0.8.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" dependencies = [ "cfg-if", ] @@ -3018,7 +3039,7 @@ dependencies = [ "serde_json", "sha2", "sha3", - "thiserror 1.0.64", + "thiserror 1.0.69", "uuid 0.8.2", ] @@ -3035,7 +3056,7 @@ dependencies = [ "serde", "serde_json", "sha3", - "thiserror 1.0.64", + "thiserror 1.0.69", "uint", ] @@ -3114,7 +3135,7 @@ dependencies = [ "pin-project", "serde", "serde_json", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -3182,7 +3203,7 @@ dependencies = [ "strum 0.26.3", "syn 2.0.87", "tempfile", - "thiserror 1.0.64", + "thiserror 1.0.69", "tiny-keccak", "unicode-xid", ] @@ -3199,7 +3220,7 @@ dependencies = [ "semver", "serde", "serde_json", - "thiserror 1.0.64", + "thiserror 1.0.69", "tracing", ] @@ -3223,7 +3244,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tracing", "tracing-futures", @@ -3255,7 +3276,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tokio-tungstenite", "tracing", @@ -3282,7 +3303,7 @@ dependencies = [ "ethers-core", "rand 0.8.5", "sha2", - "thiserror 1.0.64", + "thiserror 1.0.69", "tracing", ] @@ -3310,7 +3331,7 @@ dependencies = [ "serde_json", "solang-parser", "svm-rs", - "thiserror 1.0.64", + "thiserror 1.0.69", "tiny-keccak", "tokio", "tracing", @@ -3393,9 +3414,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "ff" @@ -3445,9 +3466,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "miniz_oxide", @@ -3455,9 +3476,9 @@ dependencies = [ [[package]] name = "flume" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" dependencies = [ "futures-core", "futures-sink", @@ -3471,6 +3492,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + [[package]] name = "foreign-types" version = "0.3.2" @@ -3535,9 +3562,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -3560,9 +3587,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -3570,15 +3597,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -3588,9 +3615,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" @@ -3609,11 +3636,11 @@ dependencies = [ [[package]] name = "futures-lite" -version = "2.3.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" +checksum = "cef40d21ae2c515b51041df9ed313ed21e572df340ea58a922a0aefe7e8891a1" dependencies = [ - "fastrand 2.1.1", + "fastrand 2.2.0", "futures-core", "futures-io", "parking", @@ -3632,9 +3659,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", @@ -3648,21 +3675,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" dependencies = [ "futures-io", - "rustls 0.23.13", + "rustls 0.23.16", "rustls-pki-types", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-ticker" @@ -3687,9 +3714,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -3714,9 +3741,9 @@ dependencies = [ [[package]] name = "genco" -version = "0.17.9" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afac3cbb14db69ac9fef9cdb60d8a87e39a7a527f85a81a923436efa40ad42c6" +checksum = "a35958104272e516c2a5f66a9d82fba4784d2b585fc1e2358b8f96e15d342995" dependencies = [ "genco-macros", "relative-path", @@ -3725,9 +3752,9 @@ dependencies = [ [[package]] name = "genco-macros" -version = "0.17.9" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "553630feadf7b76442b0849fd25fdf89b860d933623aec9693fed19af0400c78" +checksum = "43eaff6bbc0b3a878361aced5ec6a2818ee7c541c5b33b5880dfa9a86c23e9e7" dependencies = [ "proc-macro2", "quote", @@ -3770,9 +3797,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "glob" @@ -3789,7 +3816,7 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "regex-syntax 0.8.5", ] @@ -3808,7 +3835,7 @@ dependencies = [ "pin-project", "serde", "serde_json", - "thiserror 1.0.64", + "thiserror 1.0.69", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -3853,12 +3880,12 @@ dependencies = [ [[package]] name = "good_lp" -version = "1.8.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3198bd13dea84c76a64621d6ee8ee26a4960a9a0d538eca95ca8f1320a469ac9" +checksum = "97630e1e456d7081c524488a87d8f8f7ed0fd3100ba10c55e3cfa7add5ce05c6" dependencies = [ "fnv", - "minilp", + "microlp", ] [[package]] @@ -4000,9 +4027,14 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] [[package]] name = "hashers" @@ -4020,7 +4052,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "765c9198f173dd59ce26ff9f95ef0aafd0a0fe01fb9d72841bc5066a4c06511d" dependencies = [ "byteorder", - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -4077,7 +4109,7 @@ dependencies = [ "once_cell", "rand 0.8.5", "socket2 0.5.7", - "thiserror 1.0.64", + "thiserror 1.0.69", "tinyvec", "tokio", "tracing", @@ -4100,7 +4132,7 @@ dependencies = [ "rand 0.8.5", "resolv-conf", "smallvec", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tracing", ] @@ -4219,9 +4251,9 @@ checksum = "91f255a4535024abf7640cb288260811fc14794f62b063652ed349f9a6c2348e" [[package]] name = "hyper" -version = "0.14.30" +version = "0.14.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", @@ -4243,9 +4275,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ "bytes", "futures-channel", @@ -4269,7 +4301,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.31", "log", "rustls 0.21.12", "rustls-native-certs", @@ -4284,7 +4316,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper 0.14.30", + "hyper 0.14.31", "native-tls", "tokio", "tokio-native-tls", @@ -4292,15 +4324,15 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" dependencies = [ "bytes", "futures-util", "http 1.1.0", "http-body 1.0.1", - "hyper 1.4.1", + "hyper 1.5.0", "pin-project-lite", "tokio", ] @@ -4328,6 +4360,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "id-arena" version = "2.2.1" @@ -4373,12 +4523,23 @@ dependencies = [ [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] @@ -4397,7 +4558,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6b0422c86d7ce0e97169cc42e04ae643caf278874a7a3c87b8150a220dc7e1e" dependencies = [ - "async-io 2.3.4", + "async-io 2.4.0", "core-foundation", "fnv", "futures", @@ -4428,7 +4589,7 @@ dependencies = [ "bytes", "futures", "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.31", "log", "rand 0.8.5", "tokio", @@ -4446,7 +4607,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "same-file", "walkdir", "winapi-util", @@ -4539,7 +4700,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.1", "serde", ] @@ -4566,9 +4727,9 @@ dependencies = [ [[package]] name = "insta" -version = "1.40.0" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6593a41c7a73841868772495db7dc1e8ecab43bb5c0b6da2059246c4b506ab60" +checksum = "7e9ffc4d4892617c50a928c52b2961cb5174b6fc6ebf252b2fac9d21955c48b8" dependencies = [ "console", "lazy_static", @@ -4617,9 +4778,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.10.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "is-terminal" @@ -4700,9 +4861,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -4739,7 +4900,7 @@ dependencies = [ "pin-project", "rustls-native-certs", "soketto", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tokio-rustls", "tokio-util", @@ -4760,7 +4921,7 @@ dependencies = [ "beef", "futures-timer", "futures-util", - "hyper 0.14.30", + "hyper 0.14.31", "jsonrpsee-types", "parking_lot", "rand 0.8.5", @@ -4768,7 +4929,7 @@ dependencies = [ "serde", "serde_json", "soketto", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tracing", "wasm-bindgen-futures", @@ -4781,13 +4942,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c7b9f95208927653e7965a98525e7fc641781cab89f0e27c43fa2974405683" dependencies = [ "async-trait", - "hyper 0.14.30", + "hyper 0.14.31", "hyper-rustls", "jsonrpsee-core", "jsonrpsee-types", "serde", "serde_json", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tower", "tracing", @@ -4815,14 +4976,14 @@ checksum = "a482bc4e25eebd0adb61a3468c722763c381225bd3ec46e926f709df8a8eb548" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.30", + "hyper 0.14.31", "jsonrpsee-core", "jsonrpsee-types", "route-recognizer", "serde", "serde_json", "soketto", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tokio-stream", "tokio-util", @@ -4840,7 +5001,7 @@ dependencies = [ "beef", "serde", "serde_json", - "thiserror 1.0.64", + "thiserror 1.0.69", "tracing", ] @@ -4895,7 +5056,7 @@ dependencies = [ "serde_json", "time", "url", - "uuid 1.10.0", + "uuid 1.11.0", ] [[package]] @@ -4972,7 +5133,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" dependencies = [ - "regex-automata 0.4.8", + "regex-automata 0.4.9", ] [[package]] @@ -5030,9 +5191,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "libmdbx" @@ -5042,13 +5203,13 @@ checksum = "3f0bee397dc9a7003e7bd34fffc1dc2d4c4fdc96530a0c439a5f98c9402bc7bf" dependencies = [ "bitflags 2.6.0", "byteorder", - "derive_more", + "derive_more 0.99.18", "indexmap 1.9.3", "libc", "lifetimed-bytes", "mdbx-sys", "parking_lot", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -5082,7 +5243,7 @@ dependencies = [ "multiaddr", "pin-project", "rw-stream-sink", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -5131,7 +5292,7 @@ dependencies = [ "rw-stream-sink", "serde", "smallvec", - "thiserror 1.0.64", + "thiserror 1.0.69", "tracing", "unsigned-varint 0.8.0", "void", @@ -5204,7 +5365,7 @@ dependencies = [ "quick-protobuf", "quick-protobuf-codec 0.3.1", "smallvec", - "thiserror 1.0.64", + "thiserror 1.0.69", "tracing", "void", ] @@ -5223,7 +5384,7 @@ dependencies = [ "rand 0.8.5", "serde", "sha2", - "thiserror 1.0.64", + "thiserror 1.0.69", "tracing", "zeroize", ] @@ -5252,7 +5413,7 @@ dependencies = [ "serde", "sha2", "smallvec", - "thiserror 1.0.64", + "thiserror 1.0.69", "tracing", "uint", "void", @@ -5317,7 +5478,7 @@ dependencies = [ "sha2", "snow", "static_assertions", - "thiserror 1.0.64", + "thiserror 1.0.69", "tracing", "x25519-dalek", "zeroize", @@ -5356,9 +5517,9 @@ dependencies = [ "quinn", "rand 0.8.5", "ring 0.17.8", - "rustls 0.23.13", + "rustls 0.23.16", "socket2 0.5.7", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tracing", ] @@ -5449,9 +5610,9 @@ dependencies = [ "libp2p-identity", "rcgen", "ring 0.17.8", - "rustls 0.23.13", + "rustls 0.23.16", "rustls-webpki 0.101.7", - "thiserror 1.0.64", + "thiserror 1.0.69", "x509-parser", "yasna", ] @@ -5481,7 +5642,7 @@ dependencies = [ "either", "futures", "libp2p-core", - "thiserror 1.0.64", + "thiserror 1.0.69", "tracing", "yamux 0.12.1", "yamux 0.13.3", @@ -5489,11 +5650,11 @@ dependencies = [ [[package]] name = "libproc" -version = "0.14.8" +version = "0.14.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9ea4b75e1a81675429dafe43441df1caea70081e82246a8cccf514884a88bb" +checksum = "e78a09b56be5adbcad5aa1197371688dc6bb249a26da3bca2011ee2fb987ebfb" dependencies = [ - "bindgen 0.69.4", + "bindgen 0.70.1", "errno", "libc", ] @@ -5536,6 +5697,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "llvm-sys" version = "191.0.0" @@ -5571,11 +5738,11 @@ dependencies = [ [[package]] name = "lru" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" +checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.14.5", + "hashbrown 0.15.1", ] [[package]] @@ -5625,10 +5792,11 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "matrixmultiply" -version = "0.2.4" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "916806ba0031cd542105d916a97c8572e1fa6dd79c9c51e7eb43a09ec2dd84c1" +checksum = "9380b911e3e96d10c1f415da0876389aaf1b56759054eeb0de7df940c456ba1a" dependencies = [ + "autocfg 1.4.0", "rawpointer", ] @@ -5744,13 +5912,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d4fa7ce7c4862db464a37b0b31d89bca874562f034bd7993895572783d02950" dependencies = [ "base64 0.21.7", - "hyper 0.14.30", + "hyper 0.14.31", "indexmap 1.9.3", "ipnet", "metrics 0.21.1", "metrics-util", "quanta", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tracing", ] @@ -5797,21 +5965,21 @@ dependencies = [ ] [[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "minilp" -version = "0.2.2" +name = "microlp" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82a7750a9e5076c660b7bec5e6457b4dbff402b9863c8d112891434e18fd5385" +checksum = "4190b5ca62abfbc95a81d57f4a8e3e3872289d656f3eeea5820b3046a1f81d4b" dependencies = [ "log", "sprs", ] +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -5895,9 +6063,9 @@ dependencies = [ [[package]] name = "mockito" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b34bd91b9e5c5b06338d392463e1318d683cf82ec3d3af4014609be6e2108d" +checksum = "652cd6d169a36eaf9d1e6bce1a221130439a966d7f27858af66a33a66e9c4ee2" dependencies = [ "assert-json-diff", "bytes", @@ -5906,7 +6074,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.4.1", + "hyper 1.5.0", "hyper-util", "log", "rand 0.8.5", @@ -5949,13 +6117,13 @@ dependencies = [ [[package]] name = "multihash" -version = "0.19.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076d548d76a0e2a0d4ab471d0b1c36c577786dfc4471242035d97a12a735c492" +checksum = "cc41f430805af9d1cf4adae4ed2149c759b877b01d909a1f40256188d09345d2" dependencies = [ "core2", "serde", - "unsigned-varint 0.7.2", + "unsigned-varint 0.8.0", ] [[package]] @@ -6024,19 +6192,21 @@ dependencies = [ "starknet-types-core", "starknet_api", "tempfile", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] name = "ndarray" -version = "0.13.1" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac06db03ec2f46ee0ecdca1a1c34a99c0d188a0d83439b84bf0cb4b386e4ab09" +checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841" dependencies = [ "matrixmultiply", - "num-complex 0.2.4", + "num-complex 0.4.6", "num-integer", - "num-traits 0.2.19", + "num-traits", + "portable-atomic", + "portable-atomic-util", "rawpointer", ] @@ -6075,7 +6245,7 @@ dependencies = [ "anyhow", "byteorder", "paste", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -6089,7 +6259,7 @@ dependencies = [ "log", "netlink-packet-core", "netlink-sys", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", ] @@ -6173,7 +6343,7 @@ dependencies = [ "num-integer", "num-iter", "num-rational 0.2.4", - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -6187,7 +6357,7 @@ dependencies = [ "num-integer", "num-iter", "num-rational 0.4.2", - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -6198,7 +6368,7 @@ checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ "autocfg 1.4.0", "num-integer", - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -6208,7 +6378,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", - "num-traits 0.2.19", + "num-traits", "rand 0.8.5", "serde", ] @@ -6226,7 +6396,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" dependencies = [ "autocfg 1.4.0", - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -6235,7 +6405,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -6260,7 +6430,7 @@ version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -6271,7 +6441,7 @@ checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg 1.4.0", "num-integer", - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -6282,7 +6452,7 @@ checksum = "64a5fe11d4135c3bcdf3a95b18b194afa9608a5f6ff034f5d857bc9a27fb0119" dependencies = [ "num-bigint 0.4.6", "num-integer", - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -6297,7 +6467,7 @@ dependencies = [ "num-bigint 0.4.6", "num-integer", "num-modular", - "num-traits 0.2.19", + "num-traits", "rand 0.8.5", ] @@ -6310,7 +6480,7 @@ dependencies = [ "autocfg 1.4.0", "num-bigint 0.2.6", "num-integer", - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -6321,19 +6491,10 @@ checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ "num-bigint 0.4.6", "num-integer", - "num-traits 0.2.19", + "num-traits", "serde", ] -[[package]] -name = "num-traits" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" -dependencies = [ - "num-traits 0.2.19", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -6386,9 +6547,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.4" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] @@ -6404,12 +6565,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.1" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" -dependencies = [ - "portable-atomic", -] +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "oorandom" @@ -6450,9 +6608,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.66" +version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -6482,9 +6640,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.103" +version = "0.9.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", @@ -6554,7 +6712,7 @@ dependencies = [ "tar", "tempfile", "test-with", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "url", ] @@ -6567,7 +6725,7 @@ dependencies = [ "papyrus_test_utils", "pretty_assertions", "starknet_api", - "thiserror 1.0.64", + "thiserror 1.0.69", "tracing", ] @@ -6589,7 +6747,7 @@ dependencies = [ "sha3", "starknet-types-core", "starknet_api", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -6605,7 +6763,7 @@ dependencies = [ "serde_json", "strum_macros 0.25.3", "tempfile", - "thiserror 1.0.64", + "thiserror 1.0.69", "validator", ] @@ -6629,7 +6787,7 @@ dependencies = [ "starknet-types-core", "starknet_api", "test-case", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tracing", ] @@ -6659,7 +6817,7 @@ dependencies = [ "serde_json", "starknet-types-core", "starknet_api", - "thiserror 1.0.64", + "thiserror 1.0.69", "tracing", ] @@ -6686,7 +6844,7 @@ version = "0.0.0" dependencies = [ "axum", "http-body 0.4.6", - "hyper 0.14.30", + "hyper 0.14.31", "metrics 0.21.1", "metrics-exporter-prometheus", "metrics-process", @@ -6697,7 +6855,7 @@ dependencies = [ "serde", "serde_json", "starknet_client", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tower", "tracing", @@ -6713,7 +6871,7 @@ dependencies = [ "bytes", "deadqueue", "defaultmap", - "derive_more", + "derive_more 0.99.18", "futures", "lazy_static", "libp2p", @@ -6726,7 +6884,7 @@ dependencies = [ "replace_with", "serde", "starknet_api", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tokio-retry", "tokio-stream", @@ -6803,7 +6961,7 @@ dependencies = [ "starknet-types-core", "starknet_api", "static_assertions", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tokio-stream", "tracing", @@ -6838,7 +6996,7 @@ dependencies = [ "rand_chacha 0.3.1", "starknet-types-core", "starknet_api", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -6852,13 +7010,13 @@ dependencies = [ "cairo-lang-casm", "cairo-lang-starknet-classes", "camelpaste", - "derive_more", + "derive_more 0.99.18", "enum-iterator", "ethers", "flate2", "futures-util", "hex", - "hyper 0.14.30", + "hyper 0.14.31", "indexmap 2.6.0", "insta", "itertools 0.10.5", @@ -6915,7 +7073,7 @@ dependencies = [ "metrics 0.21.1", "metrics-exporter-prometheus", "num-bigint 0.4.6", - "num-traits 0.2.19", + "num-traits", "page_size", "papyrus_common", "papyrus_config", @@ -6938,7 +7096,7 @@ dependencies = [ "tempfile", "test-case", "test-log", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tracing", "validator", @@ -6974,7 +7132,7 @@ dependencies = [ "starknet-types-core", "starknet_api", "starknet_client", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tokio-stream", "tracing", @@ -7226,18 +7384,18 @@ checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" [[package]] name = "pin-project" -version = "1.1.5" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.5" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", @@ -7246,9 +7404,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -7263,7 +7421,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" dependencies = [ "atomic-waker", - "fastrand 2.1.1", + "fastrand 2.2.0", "futures-io", ] @@ -7289,7 +7447,7 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ - "num-traits 0.2.19", + "num-traits", "plotters-backend", "plotters-svg", "wasm-bindgen", @@ -7329,9 +7487,9 @@ dependencies = [ [[package]] name = "polling" -version = "3.7.3" +version = "3.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511" +checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" dependencies = [ "cfg-if", "concurrent-queue", @@ -7371,6 +7529,15 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" +[[package]] +name = "portable-atomic-util" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90a7d5beecc52a491b54d6dd05c7a45ba1801666a5baad9fdbfc6fef8d2d206c" +dependencies = [ + "portable-atomic", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -7430,9 +7597,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.22" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" +checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", "syn 2.0.87", @@ -7506,9 +7673,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -7579,7 +7746,7 @@ checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ "bitflags 2.6.0", "lazy_static", - "num-traits 0.2.19", + "num-traits", "rand 0.8.5", "rand_chacha 0.3.1", "rand_xorshift 0.3.0", @@ -7648,11 +7815,11 @@ checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac" [[package]] name = "publicsuffix" -version = "2.2.3" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96a8c1bda5ae1af7f99a2962e49df150414a43d62404644d98dd5c3a93d07457" +checksum = "6f42ea446cab60335f76979ec15e12619a2165b5ae2c12166bef27d283a9fadf" dependencies = [ - "idna 0.3.0", + "idna 1.0.3", "psl-types", ] @@ -7769,7 +7936,7 @@ dependencies = [ "asynchronous-codec 0.6.2", "bytes", "quick-protobuf", - "thiserror 1.0.64", + "thiserror 1.0.69", "unsigned-varint 0.7.2", ] @@ -7782,15 +7949,15 @@ dependencies = [ "asynchronous-codec 0.7.0", "bytes", "quick-protobuf", - "thiserror 1.0.64", + "thiserror 1.0.69", "unsigned-varint 0.8.0", ] [[package]] name = "quinn" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" +checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef" dependencies = [ "bytes", "futures-io", @@ -7798,36 +7965,40 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash 2.0.0", - "rustls 0.23.13", + "rustls 0.23.16", "socket2 0.5.7", - "thiserror 1.0.64", + "thiserror 2.0.3", "tokio", "tracing", ] [[package]] name = "quinn-proto" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" +checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" dependencies = [ "bytes", + "getrandom", "rand 0.8.5", "ring 0.17.8", "rustc-hash 2.0.0", - "rustls 0.23.13", + "rustls 0.23.16", + "rustls-pki-types", "slab", - "thiserror 1.0.64", + "thiserror 2.0.3", "tinyvec", "tracing", + "web-time", ] [[package]] name = "quinn-udp" -version = "0.5.5" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" +checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da" dependencies = [ + "cfg_aliases", "libc", "once_cell", "socket2 0.5.7", @@ -7930,7 +8101,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" dependencies = [ - "num-traits 0.2.19", + "num-traits", "rand 0.8.5", ] @@ -8078,18 +8249,18 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "regex-syntax 0.8.5", ] @@ -8104,9 +8275,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -8160,7 +8331,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.30", + "hyper 0.14.31", "hyper-rustls", "hyper-tls", "ipnet", @@ -8325,7 +8496,7 @@ dependencies = [ "netlink-packet-route", "netlink-proto", "nix 0.24.3", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", ] @@ -8365,7 +8536,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555" dependencies = [ "arrayvec", - "num-traits 0.2.19", + "num-traits", ] [[package]] @@ -8451,9 +8622,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.13" +version = "0.23.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" +checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" dependencies = [ "once_cell", "ring 0.17.8", @@ -8486,9 +8657,12 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +dependencies = [ + "web-time", +] [[package]] name = "rustls-webpki" @@ -8513,9 +8687,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" [[package]] name = "rw-stream-sink" @@ -8554,33 +8728,33 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.3" +version = "2.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" +checksum = "1aa7ffc1c0ef49b0452c6e2986abf2b07743320641ffd5fc63d552458e3b779b" dependencies = [ "cfg-if", - "derive_more", + "derive_more 1.0.0", "parity-scale-codec", "scale-info-derive", ] [[package]] name = "scale-info-derive" -version = "2.11.3" +version = "2.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" +checksum = "46385cc24172cf615450267463f937c10072516359b3ff1cb24228a4a08bf951" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.87", ] [[package]] name = "schannel" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ "windows-sys 0.59.0", ] @@ -8667,9 +8841,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.0" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" dependencies = [ "core-foundation-sys", "libc", @@ -8882,7 +9056,7 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "sierra-emu" version = "0.1.0" -source = "git+https://github.com/lambdaclass/sierra-emu.git?rev=0b11466033d7f070fcdd13cb81681b0fd9aaaa00#0b11466033d7f070fcdd13cb81681b0fd9aaaa00" +source = "git+https://github.com/lambdaclass/sierra-emu.git?rev=369a3eaebc0ab189f06dfc3662e270479a8ad17a#369a3eaebc0ab189f06dfc3662e270479a8ad17a" dependencies = [ "cairo-lang-compiler", "cairo-lang-filesystem", @@ -8894,7 +9068,7 @@ dependencies = [ "k256", "keccak", "num-bigint 0.4.6", - "num-traits 0.2.19", + "num-traits", "p256", "rand 0.8.5", "sec1", @@ -8943,8 +9117,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" dependencies = [ "num-bigint 0.4.6", - "num-traits 0.2.19", - "thiserror 1.0.64", + "num-traits", + "thiserror 1.0.69", "time", ] @@ -9097,7 +9271,7 @@ dependencies = [ "lalrpop", "lalrpop-util", "phf", - "thiserror 1.0.64", + "thiserror 1.0.69", "unicode-xid", ] @@ -9128,13 +9302,14 @@ dependencies = [ [[package]] name = "sprs" -version = "0.7.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec63571489873d4506683915840eeb1bb16b3198ee4894cc6f2fe3013d505e56" +checksum = "704ef26d974e8a452313ed629828cd9d4e4fa34667ca1ad9d6b1fffa43c6e166" dependencies = [ "ndarray", - "num-complex 0.2.4", - "num-traits 0.1.43", + "num-complex 0.4.6", + "num-traits", + "smallvec", ] [[package]] @@ -9172,7 +9347,7 @@ dependencies = [ "hmac", "num-bigint 0.4.6", "num-integer", - "num-traits 0.2.19", + "num-traits", "rfc6979", "sha2", "starknet-crypto-codegen", @@ -9192,7 +9367,7 @@ dependencies = [ "hmac", "num-bigint 0.4.6", "num-integer", - "num-traits 0.2.19", + "num-traits", "rfc6979", "sha2", "starknet-crypto-codegen", @@ -9212,7 +9387,7 @@ dependencies = [ "hmac", "num-bigint 0.4.6", "num-integer", - "num-traits 0.2.19", + "num-traits", "rfc6979", "sha2", "starknet-curve 0.5.1", @@ -9283,7 +9458,7 @@ dependencies = [ "lazy_static", "num-bigint 0.4.6", "num-integer", - "num-traits 0.2.19", + "num-traits", "serde", ] @@ -9294,7 +9469,7 @@ dependencies = [ "assert_matches", "bitvec", "cairo-lang-starknet-classes", - "derive_more", + "derive_more 0.99.18", "hex", "indexmap 2.6.0", "itertools 0.12.1", @@ -9307,7 +9482,7 @@ dependencies = [ "starknet-types-core", "strum 0.24.1", "strum_macros 0.24.3", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -9323,7 +9498,7 @@ dependencies = [ "starknet_batcher_types", "starknet_mempool_infra", "starknet_mempool_types", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tracing", "validator", @@ -9338,7 +9513,7 @@ dependencies = [ "papyrus_proc_macros", "serde", "starknet_mempool_infra", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -9369,7 +9544,7 @@ dependencies = [ "starknet_api", "strum 0.25.0", "strum_macros 0.25.3", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tokio-retry", "tracing", @@ -9386,7 +9561,7 @@ dependencies = [ "serde_json", "starknet-types-core", "starknet_patricia", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tracing", ] @@ -9414,7 +9589,7 @@ dependencies = [ "papyrus_proc_macros", "serde", "starknet_mempool_infra", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -9428,10 +9603,10 @@ dependencies = [ "cairo-lang-sierra-to-casm", "cairo-lang-starknet-classes", "enum-assoc", - "hyper 0.14.30", + "hyper 0.14.31", "mempool_test_utils", "mockall", - "mockito 1.5.0", + "mockito 1.6.1", "num-bigint 0.4.6", "papyrus_config", "papyrus_rpc", @@ -9446,7 +9621,7 @@ dependencies = [ "starknet_mempool_infra", "starknet_mempool_types", "starknet_sierra_compile", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tracing", "tracing-test", @@ -9459,7 +9634,7 @@ version = "0.0.0" dependencies = [ "assert_matches", "async-trait", - "derive_more", + "derive_more 0.99.18", "itertools 0.10.5", "mempool_test_utils", "pretty_assertions", @@ -9478,12 +9653,12 @@ dependencies = [ "assert_matches", "async-trait", "bincode 1.3.3", - "hyper 0.14.30", + "hyper 0.14.31", "papyrus_config", "pretty_assertions", "rstest", "serde", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tracing", "tracing-subscriber", @@ -9561,7 +9736,7 @@ dependencies = [ "serde", "starknet_api", "starknet_mempool_infra", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -9569,7 +9744,7 @@ name = "starknet_patricia" version = "0.0.0" dependencies = [ "async-recursion", - "derive_more", + "derive_more 0.99.18", "ethnum", "hex", "pretty_assertions", @@ -9580,7 +9755,7 @@ dependencies = [ "starknet-types-core", "strum 0.25.0", "strum_macros 0.25.3", - "thiserror 1.0.64", + "thiserror 1.0.69", "tokio", "tracing", ] @@ -9600,7 +9775,7 @@ dependencies = [ "serde_json", "starknet-types-core", "starknet_api", - "thiserror 1.0.64", + "thiserror 1.0.69", "validator", ] @@ -9742,7 +9917,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "thiserror 1.0.64", + "thiserror 1.0.69", "url", "zip", ] @@ -9815,9 +9990,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tar" -version = "0.4.42" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ff6c40d3aedb5e06b57c6f669ad17ab063dd1e63d977c6a88e7f4dfa4f04020" +checksum = "c65998313f8e17d0d553d28f91a0df93e4dbbbf770279c7bc21ca0f09ea1a1f6" dependencies = [ "filetime", "libc", @@ -9836,10 +10011,10 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ecbc9175dd38627cd01d546e7b41c9a115e5773f4c98f64e2185c81ec5f45ab" dependencies = [ - "bindgen 0.69.4", + "bindgen 0.69.5", "cc", "paste", - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -9849,7 +10024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", - "fastrand 2.1.1", + "fastrand 2.2.0", "once_cell", "rustix 0.38.40", "windows-sys 0.59.0", @@ -9952,11 +10127,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.64" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl 1.0.64", + "thiserror-impl 1.0.69", ] [[package]] @@ -9970,9 +10145,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "1.0.64" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", @@ -10082,6 +10257,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -10109,9 +10294,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes", @@ -10406,9 +10591,9 @@ dependencies = [ [[package]] name = "triomphe" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6631e42e10b40c0690bf92f404ebcfe6e1fdb480391d15f17cc8e96eeed5369" +checksum = "ef8f7726da4807b58ea5c96fdc122f80702030edc33b35aff9190a51148ccc85" dependencies = [ "serde", "stable_deref_trait", @@ -10435,7 +10620,7 @@ dependencies = [ "rand 0.8.5", "rustls 0.21.12", "sha1", - "thiserror 1.0.64", + "thiserror 1.0.69", "url", "utf-8", ] @@ -10476,7 +10661,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c878a167baa8afd137494101a688ef8c67125089ff2249284bd2b5f9bfedb815" dependencies = [ - "thiserror 1.0.64", + "thiserror 1.0.69", ] [[package]] @@ -10570,12 +10755,12 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", - "idna 0.5.0", + "idna 1.0.3", "percent-encoding", ] @@ -10585,6 +10770,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + [[package]] name = "utf8_iter" version = "1.0.4" @@ -10609,9 +10800,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" [[package]] name = "validator" @@ -10660,9 +10851,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "value-bag" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a84c137d37ab0142f0f2ddfe332651fdbf252e7b7dbb4e67b6c1f1b2e925101" +checksum = "3ef4c4aa54d5d05a279399bfa921ec387b7aba77caf7a682ae8d86785b8fdad2" [[package]] name = "vcpkg" @@ -10715,9 +10906,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -10726,9 +10917,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", @@ -10741,9 +10932,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -10753,9 +10944,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -10763,9 +10954,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", @@ -10776,15 +10967,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", @@ -11096,6 +11287,18 @@ dependencies = [ "toml", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "ws_stream_wasm" version = "0.7.4" @@ -11109,7 +11312,7 @@ dependencies = [ "pharos", "rustc_version", "send_wrapper 0.6.0", - "thiserror 1.0.64", + "thiserror 1.0.69", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -11149,7 +11352,7 @@ dependencies = [ "nom", "oid-registry", "rusticata-macros", - "thiserror 1.0.64", + "thiserror 1.0.69", "time", ] @@ -11166,9 +11369,9 @@ dependencies = [ [[package]] name = "xml-rs" -version = "0.8.22" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4e2e2f7cba5a093896c1e150fbfe177d1883e7448200efb81d40b9d339ef26" +checksum = "af310deaae937e48a26602b730250b4949e125f468f11e6990be3e5304ddd96f" [[package]] name = "xmltree" @@ -11246,6 +11449,30 @@ dependencies = [ "time", ] +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -11267,6 +11494,27 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + [[package]] name = "zeroize" version = "1.8.1" @@ -11287,6 +11535,28 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "zip" version = "0.6.6" diff --git a/Cargo.toml b/Cargo.toml index 9bd70dbbfd..e7891175aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,7 @@ license-file = "LICENSE" # TODO: Remove this once udeps is fixed. anyhow = "1.0.44" ark-ec = "0.4.2" -ark-ff = "0.4.0-alpha.7" +ark-ff = "0.4.2" ark-secp256k1 = "0.4.0" ark-secp256r1 = "0.4.0" assert-json-diff = "2.0.2" @@ -74,14 +74,14 @@ byteorder = "1.4.3" bytes = "1" cached = "0.44.0" cairo-felt = "0.9.1" -cairo-lang-casm = "2.8.4" -cairo-lang-runner = "2.8.4" -cairo-lang-sierra = "2.8.4" -cairo-lang-sierra-to-casm = "2.8.4" -cairo-lang-starknet-classes = "2.8.4" -cairo-lang-utils = "2.8.4" +cairo-lang-casm = "2.9.0-dev.0" +cairo-lang-runner = "2.9.0-dev.0" +cairo-lang-sierra = "2.9.0-dev.0" +cairo-lang-sierra-to-casm = "2.9.0-dev.0" +cairo-lang-starknet-classes = "2.9.0-dev.0" +cairo-lang-utils = "2.9.0-dev.0" # This is a temporary dependency, will be removed once the new version of cairo-native is released to main. -cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "ebfa9a116d03618e90fc52773e73958b179dd775" } +cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "5e60089288c461eca98bf3dbe03cc882778ff677" } cairo-vm = "1.0.1" camelpaste = "0.1.0" chrono = "0.4.26" @@ -171,7 +171,7 @@ serde_repr = "0.1.19" serde_yaml = "0.9.16" sha2 = "0.10.8" sha3 = "0.10.8" -sierra-emu = { git = "https://github.com/lambdaclass/sierra-emu.git", rev = "0b11466033d7f070fcdd13cb81681b0fd9aaaa00" } +sierra-emu = { git = "https://github.com/lambdaclass/sierra-emu.git", rev = "369a3eaebc0ab189f06dfc3662e270479a8ad17a"} simple_logger = "4.0.0" starknet-core = "0.6.0" starknet-crypto = "0.5.1" diff --git a/crates/batcher/src/config.rs b/crates/batcher/src/config.rs index fb227657d8..bd290b2cef 100644 --- a/crates/batcher/src/config.rs +++ b/crates/batcher/src/config.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; -use papyrus_config::dumping::{ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::Validate; diff --git a/crates/batcher/src/proposals_manager.rs b/crates/batcher/src/proposals_manager.rs index 6198ab959a..10950c321e 100644 --- a/crates/batcher/src/proposals_manager.rs +++ b/crates/batcher/src/proposals_manager.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use std::sync::Arc; -use papyrus_config::dumping::{ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use starknet_api::block::BlockNumber; diff --git a/crates/blockifier/bench/blockifier_bench.rs b/crates/blockifier/bench/blockifier_bench.rs index 2097bb1cec..b4246ec587 100644 --- a/crates/blockifier/bench/blockifier_bench.rs +++ b/crates/blockifier/bench/blockifier_bench.rs @@ -12,7 +12,7 @@ use blockifier::test_utils::transfers_generator::{ TransfersGenerator, TransfersGeneratorConfig, }; -use criterion::{criterion_group, criterion_main, Criterion}; +use criterion::{Criterion, criterion_group, criterion_main}; pub fn transfers_benchmark(c: &mut Criterion) { let transfers_generator_config = TransfersGeneratorConfig { diff --git a/crates/blockifier/src/abi/abi_utils.rs b/crates/blockifier/src/abi/abi_utils.rs index eea1dc8ef3..6eb68d4796 100644 --- a/crates/blockifier/src/abi/abi_utils.rs +++ b/crates/blockifier/src/abi/abi_utils.rs @@ -2,8 +2,8 @@ use sha3::{Digest, Keccak256}; use starknet_api::core::{ ContractAddress, EntryPointSelector, - PatriciaKey, L2_ADDRESS_UPPER_BOUND, + PatriciaKey, }; use starknet_api::state::StorageKey; use starknet_types_core::felt::{Felt, NonZeroFelt}; diff --git a/crates/blockifier/src/abi/sierra_types.rs b/crates/blockifier/src/abi/sierra_types.rs index 1def7724f1..eca47e87b7 100644 --- a/crates/blockifier/src/abi/sierra_types.rs +++ b/crates/blockifier/src/abi/sierra_types.rs @@ -4,9 +4,9 @@ use cairo_vm::vm::errors::memory_errors::MemoryError; use cairo_vm::vm::vm_core::VirtualMachine; use num_bigint::{BigUint, ToBigUint}; use num_traits::ToPrimitive; +use starknet_api::StarknetApiError; use starknet_api::core::{ContractAddress, PatriciaKey}; use starknet_api::state::StorageKey; -use starknet_api::StarknetApiError; use starknet_types_core::felt::Felt; use thiserror::Error; diff --git a/crates/blockifier/src/blockifier/block_test.rs b/crates/blockifier/src/blockifier/block_test.rs index 1f2447f8aa..e8eae70201 100644 --- a/crates/blockifier/src/blockifier/block_test.rs +++ b/crates/blockifier/src/blockifier/block_test.rs @@ -4,12 +4,12 @@ use starknet_api::felt; use starknet_api::state::StorageKey; use crate::abi::constants; -use crate::blockifier::block::{pre_process_block, BlockNumberHashPair}; +use crate::blockifier::block::{BlockNumberHashPair, pre_process_block}; use crate::context::ChainInfo; use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion}; #[test] fn test_pre_process_block() { diff --git a/crates/blockifier/src/blockifier/stateful_validator.rs b/crates/blockifier/src/blockifier/stateful_validator.rs index 3c6a8606dd..c3422826ed 100644 --- a/crates/blockifier/src/blockifier/stateful_validator.rs +++ b/crates/blockifier/src/blockifier/stateful_validator.rs @@ -6,9 +6,9 @@ use thiserror::Error; use crate::blockifier::config::TransactionExecutorConfig; use crate::blockifier::transaction_executor::{ + BLOCK_STATE_ACCESS_ERR, TransactionExecutor, TransactionExecutorError, - BLOCK_STATE_ACCESS_ERR, }; use crate::context::{BlockContext, TransactionContext}; use crate::execution::call_info::CallInfo; diff --git a/crates/blockifier/src/blockifier/stateful_validator_test.rs b/crates/blockifier/src/blockifier/stateful_validator_test.rs index f9d66bb235..6cbdf9b147 100644 --- a/crates/blockifier/src/blockifier/stateful_validator_test.rs +++ b/crates/blockifier/src/blockifier/stateful_validator_test.rs @@ -6,15 +6,15 @@ use crate::blockifier::stateful_validator::StatefulValidator; use crate::context::BlockContext; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::{fund_account, test_state}; -use crate::test_utils::{CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion}; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::test_utils::{ - block_context, - create_account_tx_for_validate_test_nonce_0, - max_resource_bounds, FaultyAccountTxCreatorArgs, INVALID, VALID, + block_context, + create_account_tx_for_validate_test_nonce_0, + max_resource_bounds, }; use crate::transaction::transaction_types::TransactionType; diff --git a/crates/blockifier/src/blockifier/transaction_executor.rs b/crates/blockifier/src/blockifier/transaction_executor.rs index 14c13ed932..fce2a9e3e9 100644 --- a/crates/blockifier/src/blockifier/transaction_executor.rs +++ b/crates/blockifier/src/blockifier/transaction_executor.rs @@ -1,7 +1,7 @@ #[cfg(feature = "concurrency")] use std::collections::{HashMap, HashSet}; #[cfg(feature = "concurrency")] -use std::panic::{self, catch_unwind, AssertUnwindSafe}; +use std::panic::{self, AssertUnwindSafe, catch_unwind}; #[cfg(feature = "concurrency")] use std::sync::Arc; #[cfg(feature = "concurrency")] diff --git a/crates/blockifier/src/blockifier/transaction_executor_test.rs b/crates/blockifier/src/blockifier/transaction_executor_test.rs index b3f649d5c4..162373267f 100644 --- a/crates/blockifier/src/blockifier/transaction_executor_test.rs +++ b/crates/blockifier/src/blockifier/transaction_executor_test.rs @@ -7,9 +7,9 @@ use starknet_types_core::felt::Felt; use crate::blockifier::config::TransactionExecutorConfig; use crate::blockifier::transaction_executor::{ + BLOCK_STATE_ACCESS_ERR, TransactionExecutor, TransactionExecutorError, - BLOCK_STATE_ACCESS_ERR, }; use crate::bouncer::{Bouncer, BouncerWeights}; use crate::context::BlockContext; @@ -20,22 +20,22 @@ use crate::test_utils::declare::declare_tx; use crate::test_utils::deploy_account::deploy_account_tx; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - create_calldata, - CairoVersion, - NonceManager, BALANCE, + CairoVersion, DEFAULT_STRK_L1_GAS_PRICE, + NonceManager, + create_calldata, }; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::errors::TransactionExecutionError; use crate::transaction::test_utils::{ + TestInitData, account_invoke_tx, block_context, calculate_class_info_for_testing, create_test_init_data, emit_n_events_tx, l1_resource_bounds, - TestInitData, }; use crate::transaction::transaction_execution::Transaction; use crate::transaction::transactions::L1HandlerTransaction; @@ -201,11 +201,10 @@ fn test_invoke( ) { let test_contract = FeatureContract::TestContract(cairo_version); let account_contract = FeatureContract::AccountWithoutValidations(cairo_version); - let state = test_state( - &block_context.chain_info, - BALANCE, - &[(test_contract, 1), (account_contract, 1)], - ); + let state = test_state(&block_context.chain_info, BALANCE, &[ + (test_contract, 1), + (account_contract, 1), + ]); let calldata = create_calldata(test_contract.get_instance_address(0), entry_point_name, &entry_point_args); diff --git a/crates/blockifier/src/bouncer_test.rs b/crates/blockifier/src/bouncer_test.rs index dc1c2e9736..f422ab453d 100644 --- a/crates/blockifier/src/bouncer_test.rs +++ b/crates/blockifier/src/bouncer_test.rs @@ -10,7 +10,7 @@ use crate::blockifier::transaction_executor::{ TransactionExecutorError, TransactionExecutorResult, }; -use crate::bouncer::{verify_tx_weights_in_bounds, Bouncer, BouncerWeights, BuiltinCount}; +use crate::bouncer::{Bouncer, BouncerWeights, BuiltinCount, verify_tx_weights_in_bounds}; use crate::context::BlockContext; use crate::execution::call_info::ExecutionSummary; use crate::state::cached_state::{StateChangesKeys, TransactionalState}; diff --git a/crates/blockifier/src/concurrency/fee_utils_test.rs b/crates/blockifier/src/concurrency/fee_utils_test.rs index dba9053156..ef71b45e19 100644 --- a/crates/blockifier/src/concurrency/fee_utils_test.rs +++ b/crates/blockifier/src/concurrency/fee_utils_test.rs @@ -12,7 +12,7 @@ use crate::invoke_tx_args; use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::{fund_account, test_state, test_state_inner}; -use crate::test_utils::{create_trivial_calldata, CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion, create_trivial_calldata}; use crate::transaction::objects::FeeType; use crate::transaction::test_utils::{account_invoke_tx, block_context, max_resource_bounds}; diff --git a/crates/blockifier/src/concurrency/flow_test.rs b/crates/blockifier/src/concurrency/flow_test.rs index c89644940b..6e6fbc032f 100644 --- a/crates/blockifier/src/concurrency/flow_test.rs +++ b/crates/blockifier/src/concurrency/flow_test.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use std::sync::atomic::Ordering; use std::sync::Arc; +use std::sync::atomic::Ordering; use rstest::rstest; use starknet_api::core::{ContractAddress, PatriciaKey}; @@ -8,7 +8,7 @@ use starknet_api::{contract_address, felt, patricia_key}; use crate::abi::sierra_types::{SierraType, SierraU128}; use crate::concurrency::scheduler::{Scheduler, Task, TransactionStatus}; -use crate::concurrency::test_utils::{safe_versioned_state_for_testing, DEFAULT_CHUNK_SIZE}; +use crate::concurrency::test_utils::{DEFAULT_CHUNK_SIZE, safe_versioned_state_for_testing}; use crate::concurrency::versioned_state::ThreadSafeVersionedState; use crate::state::cached_state::{CachedState, ContractClassMapping, StateMaps}; use crate::state::state_api::UpdatableState; diff --git a/crates/blockifier/src/concurrency/scheduler.rs b/crates/blockifier/src/concurrency/scheduler.rs index b8301d2e59..21bd76da1d 100644 --- a/crates/blockifier/src/concurrency/scheduler.rs +++ b/crates/blockifier/src/concurrency/scheduler.rs @@ -2,8 +2,8 @@ use std::cmp::min; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::{Mutex, MutexGuard, TryLockError}; -use crate::concurrency::utils::lock_mutex_in_array; use crate::concurrency::TxIndex; +use crate::concurrency::utils::lock_mutex_in_array; #[cfg(test)] #[path = "scheduler_test.rs"] diff --git a/crates/blockifier/src/concurrency/scheduler_test.rs b/crates/blockifier/src/concurrency/scheduler_test.rs index d2cf9b440e..b43be19660 100644 --- a/crates/blockifier/src/concurrency/scheduler_test.rs +++ b/crates/blockifier/src/concurrency/scheduler_test.rs @@ -1,13 +1,13 @@ use std::cmp::min; -use std::sync::atomic::Ordering; use std::sync::Arc; +use std::sync::atomic::Ordering; use pretty_assertions::assert_eq; use rstest::rstest; +use crate::concurrency::TxIndex; use crate::concurrency::scheduler::{Scheduler, Task, TransactionStatus}; use crate::concurrency::test_utils::DEFAULT_CHUNK_SIZE; -use crate::concurrency::TxIndex; use crate::default_scheduler; #[rstest] diff --git a/crates/blockifier/src/concurrency/versioned_state.rs b/crates/blockifier/src/concurrency/versioned_state.rs index a6edb590ee..a083379fd0 100644 --- a/crates/blockifier/src/concurrency/versioned_state.rs +++ b/crates/blockifier/src/concurrency/versioned_state.rs @@ -5,8 +5,8 @@ use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::state::StorageKey; use starknet_types_core::felt::Felt; -use crate::concurrency::versioned_storage::VersionedStorage; use crate::concurrency::TxIndex; +use crate::concurrency::versioned_storage::VersionedStorage; use crate::execution::contract_class::ContractClass; use crate::state::cached_state::{ContractClassMapping, StateMaps}; use crate::state::errors::StateError; diff --git a/crates/blockifier/src/concurrency/versioned_state_test.rs b/crates/blockifier/src/concurrency/versioned_state_test.rs index 71a6c460e1..80b29b5298 100644 --- a/crates/blockifier/src/concurrency/versioned_state_test.rs +++ b/crates/blockifier/src/concurrency/versioned_state_test.rs @@ -5,16 +5,17 @@ use std::thread; use assert_matches::assert_matches; use rstest::{fixture, rstest}; use starknet_api::core::{ - calculate_contract_address, ClassHash, ContractAddress, Nonce, PatriciaKey, + calculate_contract_address, }; use starknet_api::transaction::{Calldata, ContractAddressSalt, DeprecatedResourceBoundsMapping}; use starknet_api::{calldata, class_hash, contract_address, felt, patricia_key}; use crate::abi::abi_utils::{get_fee_token_var_address, get_storage_var_address}; +use crate::concurrency::TxIndex; use crate::concurrency::test_utils::{ class_hash, contract_address, @@ -25,7 +26,6 @@ use crate::concurrency::versioned_state::{ VersionedState, VersionedStateProxy, }; -use crate::concurrency::TxIndex; use crate::context::BlockContext; use crate::state::cached_state::{ CachedState, @@ -39,7 +39,7 @@ use crate::test_utils::contracts::FeatureContract; use crate::test_utils::deploy_account::deploy_account_tx; use crate::test_utils::dict_state_reader::DictStateReader; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{CairoVersion, NonceManager, BALANCE, DEFAULT_STRK_L1_GAS_PRICE}; +use crate::test_utils::{BALANCE, CairoVersion, DEFAULT_STRK_L1_GAS_PRICE, NonceManager}; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::objects::{HasRelatedFeeType, TransactionInfoCreator}; use crate::transaction::test_utils::{l1_resource_bounds, max_resource_bounds}; @@ -212,11 +212,11 @@ fn test_run_parallel_txs(max_resource_bounds: DeprecatedResourceBoundsMapping) { FeatureContract::AccountWithoutValidations(CairoVersion::Cairo0); // Initiate States - let versioned_state = Arc::new(Mutex::new(VersionedState::new(test_state( - chain_info, - BALANCE, - &[(account_without_validation, 1), (grindy_account, 1)], - )))); + let versioned_state = + Arc::new(Mutex::new(VersionedState::new(test_state(chain_info, BALANCE, &[ + (account_without_validation, 1), + (grindy_account, 1), + ])))); let safe_versioned_state = ThreadSafeVersionedState(Arc::clone(&versioned_state)); let mut versioned_state_proxy_1 = safe_versioned_state.pin_version(1); diff --git a/crates/blockifier/src/concurrency/versioned_storage_test.rs b/crates/blockifier/src/concurrency/versioned_storage_test.rs index 2f65fd71e3..693feca4c6 100644 --- a/crates/blockifier/src/concurrency/versioned_storage_test.rs +++ b/crates/blockifier/src/concurrency/versioned_storage_test.rs @@ -4,9 +4,9 @@ use pretty_assertions::assert_eq; use rstest::rstest; use starknet_api::core::{ClassHash, ContractAddress}; +use crate::concurrency::TxIndex; use crate::concurrency::test_utils::{class_hash, contract_address}; use crate::concurrency::versioned_storage::VersionedStorage; -use crate::concurrency::TxIndex; // TODO(barak, 01/07/2024): Split into test_read() and test_write(). #[test] diff --git a/crates/blockifier/src/concurrency/worker_logic.rs b/crates/blockifier/src/concurrency/worker_logic.rs index 3029236f6f..860e09817e 100644 --- a/crates/blockifier/src/concurrency/worker_logic.rs +++ b/crates/blockifier/src/concurrency/worker_logic.rs @@ -9,11 +9,11 @@ use starknet_api::core::ClassHash; use super::versioned_state::VersionedState; use crate::blockifier::transaction_executor::TransactionExecutorError; use crate::bouncer::Bouncer; +use crate::concurrency::TxIndex; use crate::concurrency::fee_utils::complete_fee_transfer_flow; use crate::concurrency::scheduler::{Scheduler, Task}; use crate::concurrency::utils::lock_mutex_in_array; use crate::concurrency::versioned_state::ThreadSafeVersionedState; -use crate::concurrency::TxIndex; use crate::context::BlockContext; use crate::state::cached_state::{ ContractClassMapping, diff --git a/crates/blockifier/src/concurrency/worker_logic_test.rs b/crates/blockifier/src/concurrency/worker_logic_test.rs index 0833734a66..55c8b248b4 100644 --- a/crates/blockifier/src/concurrency/worker_logic_test.rs +++ b/crates/blockifier/src/concurrency/worker_logic_test.rs @@ -29,12 +29,12 @@ use crate::test_utils::contracts::FeatureContract; use crate::test_utils::declare::declare_tx; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - create_calldata, - create_trivial_calldata, + BALANCE, CairoVersion, NonceManager, - BALANCE, TEST_ERC20_CONTRACT_ADDRESS2, + create_calldata, + create_trivial_calldata, }; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::constants::DEPLOY_CONTRACT_FUNCTION_ENTRY_POINT_NAME; diff --git a/crates/blockifier/src/context.rs b/crates/blockifier/src/context.rs index 13b356ea6d..24e36b43ac 100644 --- a/crates/blockifier/src/context.rs +++ b/crates/blockifier/src/context.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; -use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, append_sub_config_name, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use starknet_api::core::{ChainId, ContractAddress}; diff --git a/crates/blockifier/src/execution/contract_address_test.rs b/crates/blockifier/src/execution/contract_address_test.rs index 405360da1e..a28eedba5b 100644 --- a/crates/blockifier/src/execution/contract_address_test.rs +++ b/crates/blockifier/src/execution/contract_address_test.rs @@ -1,5 +1,5 @@ use rstest::rstest; -use starknet_api::core::{calculate_contract_address, ClassHash, ContractAddress}; +use starknet_api::core::{ClassHash, ContractAddress, calculate_contract_address}; use starknet_api::transaction::{Calldata, ContractAddressSalt}; use starknet_api::{calldata, felt}; @@ -12,7 +12,7 @@ use crate::state::cached_state::CachedState; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::dict_state_reader::DictStateReader; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion}; use crate::versioned_constants::VersionedConstants; #[rstest] diff --git a/crates/blockifier/src/execution/contract_class.rs b/crates/blockifier/src/execution/contract_class.rs index 7727735034..d153aa6056 100644 --- a/crates/blockifier/src/execution/contract_class.rs +++ b/crates/blockifier/src/execution/contract_class.rs @@ -5,13 +5,13 @@ use std::sync::Arc; use cairo_lang_casm; use cairo_lang_casm::hints::Hint; use cairo_lang_sierra::ids::FunctionId; +use cairo_lang_starknet_classes::NestedIntList; use cairo_lang_starknet_classes::casm_contract_class::{CasmContractClass, CasmContractEntryPoint}; use cairo_lang_starknet_classes::contract_class::{ ContractClass as SierraContractClass, ContractEntryPoint, ContractEntryPoints as SierraContractEntryPoints, }; -use cairo_lang_starknet_classes::NestedIntList; use cairo_lang_utils::bigint::BigUintAsHex; use cairo_native::executor::AotContractExecutor; use cairo_vm::serde::deserialize_program::{ @@ -636,7 +636,7 @@ pub struct NativeContractClassV1Inner { pub program: cairo_lang_sierra::program::Program, // for sierra emu // Used for PartialEq sierra_program_hash: starknet_api::hash::StarkHash, - sierra_raw_program: Vec + sierra_raw_program: Vec, } impl std::fmt::Debug for NativeContractClassV1Inner { @@ -678,7 +678,7 @@ impl NativeContractClassV1Inner { sierra_program_hash: calculate_sierra_program_hash( sierra_contract_class.sierra_program, ), - sierra_raw_program: bytecode + sierra_raw_program: bytecode, }) } } diff --git a/crates/blockifier/src/execution/deprecated_entry_point_execution.rs b/crates/blockifier/src/execution/deprecated_entry_point_execution.rs index fb1ab36c6a..bad53352dd 100644 --- a/crates/blockifier/src/execution/deprecated_entry_point_execution.rs +++ b/crates/blockifier/src/execution/deprecated_entry_point_execution.rs @@ -21,7 +21,7 @@ use crate::execution::entry_point::{ EntryPointExecutionResult, }; use crate::execution::errors::{PostExecutionError, PreExecutionError}; -use crate::execution::execution_utils::{read_execution_retdata, Args, ReadOnlySegments}; +use crate::execution::execution_utils::{Args, ReadOnlySegments, read_execution_retdata}; use crate::state::state_api::State; pub struct VmExecutionContext<'a> { diff --git a/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs b/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs index 53722c921f..16c51b8281 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs @@ -5,7 +5,7 @@ use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use num_traits::Pow; use pretty_assertions::assert_eq; use rstest::rstest; -use starknet_api::core::{calculate_contract_address, ChainId, PatriciaKey}; +use starknet_api::core::{ChainId, PatriciaKey, calculate_contract_address}; use starknet_api::state::StorageKey; use starknet_api::transaction::{ Calldata, @@ -33,16 +33,16 @@ use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - calldata_for_deploy_test, - get_syscall_resources, - trivial_external_entry_point_new, - CairoVersion, CHAIN_ID_NAME, CURRENT_BLOCK_NUMBER, CURRENT_BLOCK_NUMBER_FOR_VALIDATE, CURRENT_BLOCK_TIMESTAMP, CURRENT_BLOCK_TIMESTAMP_FOR_VALIDATE, + CairoVersion, TEST_SEQUENCER_ADDRESS, + calldata_for_deploy_test, + get_syscall_resources, + trivial_external_entry_point_new, }; use crate::transaction::constants::QUERY_VERSION_BASE_BIT; use crate::transaction::objects::{ @@ -509,14 +509,11 @@ fn test_emit_event() { keys: keys.clone().into_iter().map(EventKey).collect(), data: EventData(data.clone()), }; - assert_eq!( - call_info.execution, - CallExecution { - events: vec![OrderedEvent { order: 0, event }], - gas_consumed: 0, // TODO why? - ..Default::default() - } - ); + assert_eq!(call_info.execution, CallExecution { + events: vec![OrderedEvent { order: 0, event }], + gas_consumed: 0, // TODO why? + ..Default::default() + }); // Negative flow, the data length exceeds the limit. let max_event_data_length = versioned_constants.tx_event_limits.max_data_length; diff --git a/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs b/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs index d11ba19302..761eac1a85 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs @@ -17,11 +17,11 @@ use cairo_vm::vm::errors::vm_errors::VirtualMachineError; use cairo_vm::vm::runners::cairo_runner::{ExecutionResources, ResourceTracker, RunResources}; use cairo_vm::vm::vm_core::VirtualMachine; use num_bigint::{BigUint, TryFromBigIntError}; +use starknet_api::StarknetApiError; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector}; use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::state::StorageKey; use starknet_api::transaction::Calldata; -use starknet_api::StarknetApiError; use starknet_types_core::felt::{Felt, FromStrError}; use thiserror::Error; @@ -29,11 +29,17 @@ use crate::blockifier::block::BlockInfo; use crate::context::TransactionContext; use crate::execution::call_info::{CallInfo, OrderedEvent, OrderedL2ToL1Message}; use crate::execution::common_hints::{ - extended_builtin_hint_processor, ExecutionMode, HintExecutionResult, + extended_builtin_hint_processor, }; use crate::execution::deprecated_syscalls::{ + DeprecatedSyscallResult, + DeprecatedSyscallSelector, + StorageReadResponse, + StorageWriteResponse, + SyscallRequest, + SyscallResponse, call_contract, delegate_call, delegate_l1_handler, @@ -52,21 +58,15 @@ use crate::execution::deprecated_syscalls::{ send_message_to_l1, storage_read, storage_write, - DeprecatedSyscallResult, - DeprecatedSyscallSelector, - StorageReadResponse, - StorageWriteResponse, - SyscallRequest, - SyscallResponse, }; use crate::execution::entry_point::{CallEntryPoint, CallType, EntryPointExecutionContext}; use crate::execution::errors::{ConstructorEntryPointExecutionError, EntryPointExecutionError}; use crate::execution::execution_utils::{ + ReadOnlySegment, + ReadOnlySegments, felt_from_ptr, felt_range_from_ptr, max_fee_for_execution_info, - ReadOnlySegment, - ReadOnlySegments, }; use crate::execution::hint_code; use crate::execution::syscalls::hint_processor::EmitEventError; diff --git a/crates/blockifier/src/execution/deprecated_syscalls/mod.rs b/crates/blockifier/src/execution/deprecated_syscalls/mod.rs index 9e75f5be6b..8cbde9fa2a 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/mod.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/mod.rs @@ -3,11 +3,11 @@ use cairo_vm::vm::vm_core::VirtualMachine; use serde::Deserialize; use starknet_api::block::{BlockNumber, BlockTimestamp}; use starknet_api::core::{ - calculate_contract_address, ClassHash, ContractAddress, EntryPointSelector, EthAddress, + calculate_contract_address, }; use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::state::StorageKey; @@ -23,25 +23,25 @@ use starknet_types_core::felt::Felt; use strum_macros::EnumIter; use self::hint_processor::{ + DeprecatedSyscallExecutionError, + DeprecatedSyscallHintProcessor, execute_inner_call, execute_library_call, felt_to_bool, read_call_params, read_calldata, read_felt_array, - DeprecatedSyscallExecutionError, - DeprecatedSyscallHintProcessor, }; use super::syscalls::exceeds_event_size_limit; use crate::execution::call_info::{MessageToL1, OrderedEvent, OrderedL2ToL1Message}; use crate::execution::common_hints::ExecutionMode; use crate::execution::entry_point::{CallEntryPoint, CallType, ConstructorContext}; use crate::execution::execution_utils::{ + ReadOnlySegment, execute_deployment, felt_from_ptr, write_felt, write_maybe_relocatable, - ReadOnlySegment, }; #[cfg(test)] diff --git a/crates/blockifier/src/execution/entry_point_execution.rs b/crates/blockifier/src/execution/entry_point_execution.rs index b3735a0468..17b34edecd 100644 --- a/crates/blockifier/src/execution/entry_point_execution.rs +++ b/crates/blockifier/src/execution/entry_point_execution.rs @@ -23,12 +23,12 @@ use crate::execution::entry_point::{ }; use crate::execution::errors::{EntryPointExecutionError, PostExecutionError, PreExecutionError}; use crate::execution::execution_utils::{ - read_execution_retdata, - write_felt, - write_maybe_relocatable, Args, ReadOnlySegments, SEGMENT_ARENA_BUILTIN_SIZE, + read_execution_retdata, + write_felt, + write_maybe_relocatable, }; use crate::execution::syscalls::hint_processor::SyscallHintProcessor; use crate::state::state_api::State; diff --git a/crates/blockifier/src/execution/entry_point_test.rs b/crates/blockifier/src/execution/entry_point_test.rs index 07abce7eb9..295cd86e7d 100644 --- a/crates/blockifier/src/execution/entry_point_test.rs +++ b/crates/blockifier/src/execution/entry_point_test.rs @@ -15,7 +15,7 @@ use crate::state::cached_state::CachedState; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::dict_state_reader::DictStateReader; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion, trivial_external_entry_point_new}; use crate::versioned_constants::VersionedConstants; use crate::{retdata, storage_key}; @@ -50,10 +50,9 @@ fn test_call_info_iteration() { for (i, call_info) in root.iter().enumerate() { // TODO(Ori, 1/2/2024): Write an indicative expect message explaining why the conversion // works. - assert_eq!( - call_info.call.calldata, - calldata![felt!(u64::try_from(i).expect("Failed to convert usize to u64."))] - ); + assert_eq!(call_info.call.calldata, calldata![felt!( + u64::try_from(i).expect("Failed to convert usize to u64.") + )]); } } diff --git a/crates/blockifier/src/execution/execution_utils.rs b/crates/blockifier/src/execution/execution_utils.rs index 4373557198..df2613ab2b 100644 --- a/crates/blockifier/src/execution/execution_utils.rs +++ b/crates/blockifier/src/execution/execution_utils.rs @@ -2,11 +2,11 @@ use std::collections::HashMap; use cairo_lang_runner::casm_run::format_next_item; use cairo_vm::serde::deserialize_program::{ - deserialize_array_of_bigint_hex, Attribute, HintParams, Identifier, ReferenceManager, + deserialize_array_of_bigint_hex, }; use cairo_vm::types::builtin_name::BuiltinName; use cairo_vm::types::errors::program_errors::ProgramError; @@ -27,11 +27,11 @@ use super::errors::ConstructorEntryPointExecutionError; use crate::execution::call_info::{CallInfo, Retdata}; use crate::execution::contract_class::ContractClass; use crate::execution::entry_point::{ - execute_constructor_entry_point, CallEntryPoint, ConstructorContext, EntryPointExecutionContext, EntryPointExecutionResult, + execute_constructor_entry_point, }; use crate::execution::errors::PostExecutionError; use crate::execution::native::entry_point_execution as native_entry_point_execution; diff --git a/crates/blockifier/src/execution/native/entry_point_execution.rs b/crates/blockifier/src/execution/native/entry_point_execution.rs index b3b6a6fd11..ad32524fbb 100644 --- a/crates/blockifier/src/execution/native/entry_point_execution.rs +++ b/crates/blockifier/src/execution/native/entry_point_execution.rs @@ -47,7 +47,12 @@ pub fn execute_entry_point_call( ); run_sierra_emu_executor(vm, function_id, call.clone()) } else { - run_native_executor(&contract_class.executor, call.entry_point_selector.0, call, syscall_handler) + run_native_executor( + &contract_class.executor, + call.entry_point_selector.0, + call, + syscall_handler, + ) }; let execution_time = pre_execution_instant.elapsed().as_nanos(); tracing::info!(time = execution_time, "native contract execution finished"); diff --git a/crates/blockifier/src/execution/native/syscall_handler.rs b/crates/blockifier/src/execution/native/syscall_handler.rs index a0e95ac741..34f41e2a83 100644 --- a/crates/blockifier/src/execution/native/syscall_handler.rs +++ b/crates/blockifier/src/execution/native/syscall_handler.rs @@ -5,65 +5,38 @@ use std::sync::Arc; use ark_ec::short_weierstrass::{Affine, Projective, SWCurveConfig}; use cairo_native::starknet::{ - BlockInfo, - ExecutionInfo, - ExecutionInfoV2, - Secp256k1Point, - Secp256r1Point, - StarknetSyscallHandler, - SyscallResult, - TxInfo, - TxV2Info, - U256, + BlockInfo, ExecutionInfo, ExecutionInfoV2, Secp256k1Point, Secp256r1Point, + StarknetSyscallHandler, SyscallResult, TxInfo, TxV2Info, U256, }; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use num_traits::{ToPrimitive, Zero}; use starknet_api::core::{ - calculate_contract_address, - ClassHash, - ContractAddress, - EntryPointSelector, - EthAddress, + calculate_contract_address, ClassHash, ContractAddress, EntryPointSelector, EthAddress, PatriciaKey, }; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::state::StorageKey; use starknet_api::transaction::{ - Calldata, - ContractAddressSalt, - EventContent, - EventData, - EventKey, - L2ToL1Payload, + Calldata, ContractAddressSalt, EventContent, EventData, EventKey, L2ToL1Payload, }; use starknet_types_core::felt::Felt; use super::utils::{ - big4int_to_u256, - calculate_resource_bounds, - contract_address_to_native_felt, - default_tx_v2_info, - encode_str_as_felts, - u256_to_biguint, + big4int_to_u256, calculate_resource_bounds, contract_address_to_native_felt, + default_tx_v2_info, encode_str_as_felts, u256_to_biguint, }; use crate::abi::constants; use crate::execution::call_info::{CallInfo, MessageToL1, OrderedEvent, OrderedL2ToL1Message}; use crate::execution::common_hints::ExecutionMode; use crate::execution::contract_class::ContractClass; use crate::execution::entry_point::{ - CallEntryPoint, - CallType, - ConstructorContext, - EntryPointExecutionContext, + CallEntryPoint, CallType, ConstructorContext, EntryPointExecutionContext, }; use crate::execution::execution_utils::{execute_deployment, max_fee_for_execution_info}; use crate::execution::syscalls::hint_processor::{ - SyscallCounter, - SyscallExecutionError, - BLOCK_NUMBER_OUT_OF_RANGE_ERROR, - INVALID_INPUT_LENGTH_ERROR, - OUT_OF_GAS_ERROR, + SyscallCounter, SyscallExecutionError, BLOCK_NUMBER_OUT_OF_RANGE_ERROR, + INVALID_INPUT_LENGTH_ERROR, OUT_OF_GAS_ERROR, }; use crate::execution::syscalls::{exceeds_event_size_limit, SyscallSelector}; use crate::state::state_api::State; @@ -131,18 +104,13 @@ impl<'state> NativeSyscallHandler<'state> { return Err(retdata); } - self.update_remaining_gas(remaining_gas, &call_info); + update_remaining_gas(remaining_gas, &call_info); self.inner_calls.push(call_info.clone()); Ok(call_info) } - pub fn update_remaining_gas(&mut self, remaining_gas: &mut u64, call_info: &CallInfo) { - // pass the reference to the function - update_remaining_gas(remaining_gas, call_info); - } - pub fn increment_syscall_count_by(&mut self, selector: &SyscallSelector, n: usize) { let syscall_count = self.syscall_counter.entry(*selector).or_default(); *syscall_count += n; @@ -168,7 +136,8 @@ impl<'state> NativeSyscallHandler<'state> { } // Refund `SYSCALL_BASE_GAS_COST` as it was pre-charged. - let required_gas = syscall_gas_cost - self.execution_context.gas_costs().syscall_base_gas_cost; + let required_gas = + syscall_gas_cost - self.execution_context.gas_costs().syscall_base_gas_cost; if *remaining_gas < required_gas { // Out of gas failure. @@ -295,10 +264,7 @@ impl<'state> StarknetSyscallHandler for &mut NativeSyscallHandler<'state> { }) } - fn get_execution_info_v2( - &mut self, - remaining_gas: &mut u64, - ) -> SyscallResult { + fn get_execution_info_v2(&mut self, remaining_gas: &mut u64) -> SyscallResult { self.pre_execute_syscall( remaining_gas, SyscallSelector::GetExecutionInfo, @@ -439,7 +405,7 @@ impl<'state> StarknetSyscallHandler for &mut NativeSyscallHandler<'state> { ) .map_err(|error| encode_str_as_felts(&error.to_string()))?; - self.update_remaining_gas(remaining_gas, &call_info); + update_remaining_gas(remaining_gas, &call_info); let return_data = call_info.execution.retdata.0[..].to_vec(); let contract_address_felt = Felt::from(calculated_contract_address); @@ -689,7 +655,8 @@ impl<'state> StarknetSyscallHandler for &mut NativeSyscallHandler<'state> { // TODO(Ori, 1/2/2024): Write an indicative expect message explaining why the conversion // works. let n_rounds_as_u64 = u64::try_from(n_rounds).expect("Failed to convert usize to u64."); - let gas_cost = n_rounds_as_u64 * self.execution_context.gas_costs().keccak_round_cost_gas_cost; + let gas_cost = + n_rounds_as_u64 * self.execution_context.gas_costs().keccak_round_cost_gas_cost; if gas_cost > *remaining_gas { // In VM this error is wrapped into `SyscallExecutionError::SyscallError` @@ -885,6 +852,14 @@ impl<'state> StarknetSyscallHandler for &mut NativeSyscallHandler<'state> { sha2::compress256(prev_state, &[data_as_bytes]); Ok(()) } + + fn get_class_hash_at( + &mut self, + _contract_address: Felt, + _remaining_gas: &mut u64, + ) -> SyscallResult { + todo!() + } } pub mod sierra_emu_impl { @@ -892,35 +867,18 @@ pub mod sierra_emu_impl { use num_traits::ToPrimitive; use sierra_emu::starknet::{ - BlockInfo, - ExecutionInfo, - ExecutionInfoV2, - ResourceBounds, - Secp256k1Point, - Secp256r1Point, - SyscallResult, - TxInfo, - TxV2Info, - U256, + BlockInfo, ExecutionInfo, ExecutionInfoV2, ResourceBounds, Secp256k1Point, Secp256r1Point, + SyscallResult, TxInfo, TxV2Info, U256, }; use starknet_api::core::{ - calculate_contract_address, - ClassHash, - ContractAddress, - EntryPointSelector, - EthAddress, + calculate_contract_address, ClassHash, ContractAddress, EntryPointSelector, EthAddress, PatriciaKey, }; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::state::StorageKey; use starknet_api::transaction::{ - Calldata, - ContractAddressSalt, - EventContent, - EventData, - EventKey, - L2ToL1Payload, + Calldata, ContractAddressSalt, EventContent, EventData, EventKey, L2ToL1Payload, }; use starknet_types_core::felt::Felt; @@ -932,19 +890,16 @@ pub mod sierra_emu_impl { use crate::execution::entry_point::{CallEntryPoint, CallType, ConstructorContext}; use crate::execution::execution_utils::{execute_deployment, max_fee_for_execution_info}; use crate::execution::native::utils::{ - calculate_resource_bounds, - contract_address_to_native_felt, - default_tx_v2_info_sierra_emu, + calculate_resource_bounds, contract_address_to_native_felt, default_tx_v2_info_sierra_emu, encode_str_as_felts, }; use crate::execution::syscalls::hint_processor::{ - SyscallExecutionError, - BLOCK_NUMBER_OUT_OF_RANGE_ERROR, - INVALID_INPUT_LENGTH_ERROR, + SyscallExecutionError, BLOCK_NUMBER_OUT_OF_RANGE_ERROR, INVALID_INPUT_LENGTH_ERROR, OUT_OF_GAS_ERROR, }; use crate::execution::syscalls::{exceeds_event_size_limit, SyscallSelector}; use crate::transaction::objects::TransactionInfo; + use crate::transaction::transaction_utils::update_remaining_gas; impl<'state> sierra_emu::starknet::StarknetSyscallHandler for &mut NativeSyscallHandler<'state> { fn get_block_hash( @@ -1131,7 +1086,7 @@ pub mod sierra_emu_impl { .map(|x| ResourceBounds { resource: x.resource, max_amount: x.max_amount, - max_price_per_unit: x.max_price_per_unit, + max_price_per_unit: x.max_price_per_unit.try_into().unwrap(), }) .collect(), tip: context.tip.0.into(), @@ -1215,7 +1170,7 @@ pub mod sierra_emu_impl { ) .map_err(|error| encode_str_as_felts(&error.to_string()))?; - self.update_remaining_gas(remaining_gas, &call_info); + update_remaining_gas(remaining_gas, &call_info); let return_data = call_info.execution.retdata.0[..].to_vec(); let contract_address_felt = Felt::from(calculated_contract_address); @@ -1469,7 +1424,8 @@ pub mod sierra_emu_impl { // TODO(Ori, 1/2/2024): Write an indicative expect message explaining why the conversion // works. let n_rounds_as_u64 = u64::try_from(n_rounds).expect("Failed to convert usize to u64."); - let gas_cost = n_rounds_as_u64 * self.execution_context.gas_costs().keccak_round_cost_gas_cost; + let gas_cost = + n_rounds_as_u64 * self.execution_context.gas_costs().keccak_round_cost_gas_cost; if gas_cost > *remaining_gas { // In VM this error is wrapped into `SyscallExecutionError::SyscallError` diff --git a/crates/blockifier/src/execution/native/utils.rs b/crates/blockifier/src/execution/native/utils.rs index 648efddbd1..1b82176830 100644 --- a/crates/blockifier/src/execution/native/utils.rs +++ b/crates/blockifier/src/execution/native/utils.rs @@ -129,9 +129,7 @@ fn create_callinfo( run_result: ContractExecutionResult, syscall_handler: NativeSyscallHandler<'_>, ) -> Result { - let gas_consumed = { - call.initial_gas - run_result.remaining_gas - }; + let gas_consumed = { call.initial_gas - run_result.remaining_gas }; Ok(CallInfo { call, @@ -162,9 +160,7 @@ pub fn create_callinfo_emu( storage_read_values: Vec, accessed_storage_keys: HashSet, ) -> Result { - let gas_consumed = { - call.initial_gas - run_result.remaining_gas - }; + let gas_consumed = { call.initial_gas - run_result.remaining_gas }; Ok(CallInfo { call, diff --git a/crates/blockifier/src/execution/stack_trace_test.rs b/crates/blockifier/src/execution/stack_trace_test.rs index 6651a5d9cc..fb583b0abb 100644 --- a/crates/blockifier/src/execution/stack_trace_test.rs +++ b/crates/blockifier/src/execution/stack_trace_test.rs @@ -1,7 +1,7 @@ use pretty_assertions::assert_eq; use regex::Regex; use rstest::rstest; -use starknet_api::core::{calculate_contract_address, Nonce}; +use starknet_api::core::{Nonce, calculate_contract_address}; use starknet_api::transaction::{ Calldata, ContractAddressSalt, @@ -18,7 +18,7 @@ use crate::context::{BlockContext, ChainInfo}; use crate::invoke_tx_args; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::{fund_account, test_state}; -use crate::test_utils::{create_calldata, CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion, create_calldata}; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::constants::{ DEPLOY_CONTRACT_FUNCTION_ENTRY_POINT_NAME, @@ -29,13 +29,13 @@ use crate::transaction::constants::{ VALIDATE_ENTRY_POINT_NAME, }; use crate::transaction::test_utils::{ + FaultyAccountTxCreatorArgs, + INVALID, account_invoke_tx, block_context, create_account_tx_for_validate_test_nonce_0, max_resource_bounds, run_invoke_tx, - FaultyAccountTxCreatorArgs, - INVALID, }; use crate::transaction::transaction_types::TransactionType; use crate::transaction::transactions::ExecutableTransaction; @@ -73,15 +73,11 @@ fn test_stack_trace( ], ); - let tx_execution_error = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - sender_address: account_address, - calldata, - version: TransactionVersion::ZERO, - }, - ) + let tx_execution_error = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + sender_address: account_address, + calldata, + version: TransactionVersion::ZERO, + }) .unwrap_err(); // Fetch PC locations from the compiled contract to compute the expected PC locations in the @@ -195,15 +191,11 @@ fn test_trace_callchain_ends_with_regular_call( ], ); - let tx_execution_error = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - sender_address: account_address, - calldata, - version: TransactionVersion::ZERO, - }, - ) + let tx_execution_error = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + sender_address: account_address, + calldata, + version: TransactionVersion::ZERO, + }) .unwrap_err(); let account_entry_point_offset = @@ -342,15 +334,11 @@ fn test_trace_call_chain_with_syscalls( &raw_calldata, ); - let tx_execution_error = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - sender_address: account_address, - calldata, - version: TransactionVersion::ZERO, - }, - ) + let tx_execution_error = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + sender_address: account_address, + calldata, + version: TransactionVersion::ZERO, + }) .unwrap_err(); let account_entry_point_offset = diff --git a/crates/blockifier/src/execution/syscalls/hint_processor.rs b/crates/blockifier/src/execution/syscalls/hint_processor.rs index d99bb7938a..3623d013f4 100644 --- a/crates/blockifier/src/execution/syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/syscalls/hint_processor.rs @@ -14,11 +14,11 @@ use cairo_vm::vm::errors::memory_errors::MemoryError; use cairo_vm::vm::errors::vm_errors::VirtualMachineError; use cairo_vm::vm::runners::cairo_runner::{ExecutionResources, ResourceTracker, RunResources}; use cairo_vm::vm::vm_core::VirtualMachine; +use starknet_api::StarknetApiError; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector}; use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::state::StorageKey; use starknet_api::transaction::{Calldata, Resource}; -use starknet_api::StarknetApiError; use starknet_types_core::felt::{Felt, FromStrError}; use thiserror::Error; @@ -28,14 +28,15 @@ use crate::execution::common_hints::{ExecutionMode, HintExecutionResult}; use crate::execution::entry_point::{CallEntryPoint, CallType, EntryPointExecutionContext}; use crate::execution::errors::{ConstructorEntryPointExecutionError, EntryPointExecutionError}; use crate::execution::execution_utils::{ + ReadOnlySegment, + ReadOnlySegments, felt_from_ptr, felt_range_from_ptr, max_fee_for_execution_info, write_maybe_relocatable, - ReadOnlySegment, - ReadOnlySegments, }; use crate::execution::syscalls::secp::{ + SecpHintProcessor, secp256k1_add, secp256k1_get_point_from_x, secp256k1_get_xy, @@ -46,9 +47,16 @@ use crate::execution::syscalls::secp::{ secp256r1_get_xy, secp256r1_mul, secp256r1_new, - SecpHintProcessor, }; use crate::execution::syscalls::{ + StorageReadResponse, + StorageWriteResponse, + SyscallRequest, + SyscallRequestWrapper, + SyscallResponse, + SyscallResponseWrapper, + SyscallResult, + SyscallSelector, call_contract, deploy, emit_event, @@ -62,14 +70,6 @@ use crate::execution::syscalls::{ sha_256_process_block, storage_read, storage_write, - StorageReadResponse, - StorageWriteResponse, - SyscallRequest, - SyscallRequestWrapper, - SyscallResponse, - SyscallResponseWrapper, - SyscallResult, - SyscallSelector, }; use crate::state::errors::StateError; use crate::state::state_api::State; diff --git a/crates/blockifier/src/execution/syscalls/mod.rs b/crates/blockifier/src/execution/syscalls/mod.rs index 75e0efb389..e7a0f90af2 100644 --- a/crates/blockifier/src/execution/syscalls/mod.rs +++ b/crates/blockifier/src/execution/syscalls/mod.rs @@ -3,11 +3,11 @@ use cairo_vm::vm::vm_core::VirtualMachine; use num_traits::ToPrimitive; use starknet_api::block::{BlockHash, BlockNumber}; use starknet_api::core::{ - calculate_contract_address, ClassHash, ContractAddress, EntryPointSelector, EthAddress, + calculate_contract_address, }; use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::state::StorageKey; @@ -22,6 +22,10 @@ use starknet_api::transaction::{ use starknet_types_core::felt::Felt; use self::hint_processor::{ + BLOCK_NUMBER_OUT_OF_RANGE_ERROR, + EmitEventError, + SyscallExecutionError, + SyscallHintProcessor, create_retdata_segment, execute_inner_call, execute_library_call, @@ -30,10 +34,6 @@ use self::hint_processor::{ read_calldata, read_felt_array, write_segment, - EmitEventError, - SyscallExecutionError, - SyscallHintProcessor, - BLOCK_NUMBER_OUT_OF_RANGE_ERROR, }; use crate::abi::constants; use crate::execution::call_info::{MessageToL1, OrderedEvent, OrderedL2ToL1Message}; @@ -41,11 +41,11 @@ use crate::execution::contract_class::ContractClass; use crate::execution::deprecated_syscalls::DeprecatedSyscallSelector; use crate::execution::entry_point::{CallEntryPoint, CallType, ConstructorContext}; use crate::execution::execution_utils::{ + ReadOnlySegment, execute_deployment, felt_from_ptr, write_felt, write_maybe_relocatable, - ReadOnlySegment, }; use crate::execution::syscalls::hint_processor::{INVALID_INPUT_LENGTH_ERROR, OUT_OF_GAS_ERROR}; use crate::transaction::transaction_utils::update_remaining_gas; diff --git a/crates/blockifier/src/execution/syscalls/secp.rs b/crates/blockifier/src/execution/syscalls/secp.rs index d23bbd15dc..872d497137 100644 --- a/crates/blockifier/src/execution/syscalls/secp.rs +++ b/crates/blockifier/src/execution/syscalls/secp.rs @@ -10,9 +10,9 @@ use starknet_types_core::felt::Felt; use crate::abi::sierra_types::{SierraType, SierraU256}; use crate::execution::execution_utils::{felt_from_ptr, write_maybe_relocatable, write_u256}; use crate::execution::syscalls::hint_processor::{ - felt_to_bool, - SyscallHintProcessor, INVALID_ARGUMENT, + SyscallHintProcessor, + felt_to_bool, }; use crate::execution::syscalls::{ SyscallExecutionError, diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs index ff260cd93a..78920faaa0 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs @@ -10,7 +10,7 @@ use crate::execution::entry_point::CallEntryPoint; use crate::retdata; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{create_calldata, trivial_external_entry_point_new, CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion, create_calldata, trivial_external_entry_point_new}; #[test_case( FeatureContract::TestContract(CairoVersion::Native), @@ -45,26 +45,20 @@ fn test_call_contract( let mut state = test_state(chain_info, BALANCE, &[(outer_contract, 1), (inner_contract, 1)]); let outer_entry_point_selector = selector_from_name("test_call_contract"); - let calldata = create_calldata( - inner_contract.get_instance_address(0), - "test_storage_read_write", - &[ + let calldata = + create_calldata(inner_contract.get_instance_address(0), "test_storage_read_write", &[ felt!(405_u16), // Calldata: address. felt!(48_u8), // Calldata: value. - ], - ); + ]); let entry_point_call = CallEntryPoint { entry_point_selector: outer_entry_point_selector, calldata, ..trivial_external_entry_point_new(outer_contract) }; - assert_eq!( - entry_point_call.execute_directly(&mut state).unwrap().execution, - CallExecution { - retdata: retdata![felt!(48_u8)], - gas_consumed: expected_gas, - ..CallExecution::default() - } - ); + assert_eq!(entry_point_call.execute_directly(&mut state).unwrap().execution, CallExecution { + retdata: retdata![felt!(48_u8)], + gas_consumed: expected_gas, + ..CallExecution::default() + }); } diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs index da014f353f..6e0a273d4c 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs @@ -12,7 +12,7 @@ use crate::retdata; use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{calldata_for_deploy_test, trivial_external_entry_point_new, CairoVersion}; +use crate::test_utils::{CairoVersion, calldata_for_deploy_test, trivial_external_entry_point_new}; // TODO add all combinations of Native and Vm deployer and deployee #[test_case(FeatureContract::TestContract(CairoVersion::Native);"Native")] @@ -23,11 +23,10 @@ fn no_constructor(deployer_contract: FeatureContract) { let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1); let class_hash = empty_contract.get_class_hash(); - let mut state = test_state( - &ChainInfo::create_for_testing(), - 0, - &[(deployer_contract, 1), (empty_contract, 0)], - ); + let mut state = test_state(&ChainInfo::create_for_testing(), 0, &[ + (deployer_contract, 1), + (empty_contract, 0), + ]); let calldata = calldata_for_deploy_test(class_hash, &[], true); let entry_point_call = CallEntryPoint { @@ -46,10 +45,11 @@ fn no_constructor(deployer_contract: FeatureContract) { let deploy_call = &entry_point_call.execute_directly(&mut state).unwrap().inner_calls[0]; assert_eq!(deploy_call.call.storage_address, deployed_contract_address); - assert_eq!( - deploy_call.execution, - CallExecution { retdata: retdata![], gas_consumed: 0, ..CallExecution::default() } - ); + assert_eq!(deploy_call.execution, CallExecution { + retdata: retdata![], + gas_consumed: 0, + ..CallExecution::default() + }); assert_eq!(state.get_class_hash_at(deployed_contract_address).unwrap(), class_hash); } @@ -59,11 +59,10 @@ fn no_constructor_nonempty_calldata(deployer_contract: FeatureContract) { let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1); let class_hash = empty_contract.get_class_hash(); - let mut state = test_state( - &ChainInfo::create_for_testing(), - 0, - &[(deployer_contract, 1), (empty_contract, 0)], - ); + let mut state = test_state(&ChainInfo::create_for_testing(), 0, &[ + (deployer_contract, 1), + (empty_contract, 0), + ]); let calldata = calldata_for_deploy_test(class_hash, &[felt!(1_u8), felt!(1_u8)], true); @@ -84,11 +83,10 @@ fn no_constructor_nonempty_calldata(deployer_contract: FeatureContract) { #[test_case(FeatureContract::TestContract(CairoVersion::Cairo1), 5210;"VM")] fn with_constructor(deployer_contract: FeatureContract, expected_gas: u64) { let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1); - let mut state = test_state( - &ChainInfo::create_for_testing(), - 0, - &[(deployer_contract, 1), (empty_contract, 0)], - ); + let mut state = test_state(&ChainInfo::create_for_testing(), 0, &[ + (deployer_contract, 1), + (empty_contract, 0), + ]); let class_hash = deployer_contract.get_class_hash(); let constructor_calldata = vec![ @@ -115,14 +113,11 @@ fn with_constructor(deployer_contract: FeatureContract, expected_gas: u64) { let deploy_call = &entry_point_call.execute_directly(&mut state).unwrap().inner_calls[0]; assert_eq!(deploy_call.call.storage_address, contract_address); - assert_eq!( - deploy_call.execution, - CallExecution { - retdata: retdata![constructor_calldata[0]], - gas_consumed: expected_gas, - ..CallExecution::default() - } - ); + assert_eq!(deploy_call.execution, CallExecution { + retdata: retdata![constructor_calldata[0]], + gas_consumed: expected_gas, + ..CallExecution::default() + }); assert_eq!(state.get_class_hash_at(contract_address).unwrap(), class_hash); } @@ -130,11 +125,10 @@ fn with_constructor(deployer_contract: FeatureContract, expected_gas: u64) { #[test_case(FeatureContract::TestContract(CairoVersion::Native);"Native")] fn to_unavailable_address(deployer_contract: FeatureContract) { let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1); - let mut state = test_state( - &ChainInfo::create_for_testing(), - 0, - &[(deployer_contract, 1), (empty_contract, 0)], - ); + let mut state = test_state(&ChainInfo::create_for_testing(), 0, &[ + (deployer_contract, 1), + (empty_contract, 0), + ]); let class_hash = deployer_contract.get_class_hash(); let constructor_calldata = vec![ diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs index b96a446886..102351d620 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs @@ -13,7 +13,7 @@ use crate::execution::errors::EntryPointExecutionError; use crate::execution::syscalls::hint_processor::EmitEventError; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion, trivial_external_entry_point_new}; use crate::versioned_constants::VersionedConstants; const KEYS: [Felt; 2] = [Felt::from_hex_unchecked("0x2019"), Felt::from_hex_unchecked("0x2020")]; @@ -35,14 +35,11 @@ fn positive_flow(test_contract: FeatureContract, expected_gas: u64) { data: EventData(DATA.to_vec()), }; - assert_eq!( - call_info.execution, - CallExecution { - events: vec![OrderedEvent { order: 0, event }], - gas_consumed: expected_gas, - ..Default::default() - } - ); + assert_eq!(call_info.execution, CallExecution { + events: vec![OrderedEvent { order: 0, event }], + gas_consumed: expected_gas, + ..Default::default() + }); } #[test_case(FeatureContract::TestContract(CairoVersion::Native); "Native")] diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs index c6a6d81ed2..2491d24177 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs @@ -18,10 +18,10 @@ use crate::test_utils::contracts::FeatureContract; use crate::test_utils::dict_state_reader::DictStateReader; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - trivial_external_entry_point_new, - CairoVersion, BALANCE, CURRENT_BLOCK_NUMBER, + CairoVersion, + trivial_external_entry_point_new, }; fn initialize_state(test_contract: FeatureContract) -> (CachedState, Felt, Felt) { diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs index ace0d33b47..93c7a186f1 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs @@ -29,15 +29,15 @@ use crate::nonce; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - trivial_external_entry_point_with_address, - CairoVersion, BALANCE, CHAIN_ID_NAME, CURRENT_BLOCK_NUMBER, CURRENT_BLOCK_NUMBER_FOR_VALIDATE, CURRENT_BLOCK_TIMESTAMP, CURRENT_BLOCK_TIMESTAMP_FOR_VALIDATE, + CairoVersion, TEST_SEQUENCER_ADDRESS, + trivial_external_entry_point_with_address, }; use crate::transaction::constants::QUERY_VERSION_BASE_BIT; use crate::transaction::objects::{ diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/keccak.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/keccak.rs index cdbae9686a..c3e26c1b11 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/keccak.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/keccak.rs @@ -8,7 +8,7 @@ use crate::execution::entry_point::CallEntryPoint; use crate::retdata; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion, trivial_external_entry_point_new}; #[test_case(FeatureContract::TestContract(CairoVersion::Native), 263740; "Native")] #[test_case(FeatureContract::TestContract(CairoVersion::Cairo1), 255110; "VM")] @@ -23,8 +23,8 @@ fn test_keccak(test_contract: FeatureContract, expected_gas: u64) { ..trivial_external_entry_point_new(test_contract) }; - assert_eq!( - entry_point_call.execute_directly(&mut state).unwrap().execution, - CallExecution { gas_consumed: expected_gas, ..CallExecution::from_retdata(retdata![]) } - ); + assert_eq!(entry_point_call.execute_directly(&mut state).unwrap().execution, CallExecution { + gas_consumed: expected_gas, + ..CallExecution::from_retdata(retdata![]) + }); } diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs index e5d921c5a5..df307f1089 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs @@ -13,19 +13,19 @@ use crate::abi::abi_utils::selector_from_name; use crate::context::ChainInfo; use crate::execution::call_info::{CallExecution, CallInfo, Retdata}; use crate::execution::entry_point::{CallEntryPoint, CallType}; +use crate::execution::syscalls::SyscallSelector; use crate::execution::syscalls::syscall_tests::constants::{ REQUIRED_GAS_LIBRARY_CALL_TEST, REQUIRED_GAS_STORAGE_READ_WRITE_TEST, }; -use crate::execution::syscalls::SyscallSelector; use crate::retdata; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ + BALANCE, + CairoVersion, get_syscall_resources, trivial_external_entry_point_new, - CairoVersion, - BALANCE, }; #[test_case(FeatureContract::TestContract(CairoVersion::Native), 184810; "Native" @@ -52,14 +52,11 @@ fn test_library_call(test_contract: FeatureContract, expected_gas: u64) { ..trivial_external_entry_point_new(test_contract) }; - assert_eq!( - entry_point_call.execute_directly(&mut state).unwrap().execution, - CallExecution { - retdata: retdata![felt!(91_u16)], - gas_consumed: expected_gas, - ..Default::default() - } - ); + assert_eq!(entry_point_call.execute_directly(&mut state).unwrap().execution, CallExecution { + retdata: retdata![felt!(91_u16)], + gas_consumed: expected_gas, + ..Default::default() + }); } #[test_case(FeatureContract::TestContract(CairoVersion::Native); "Native")] diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/out_of_gas.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/out_of_gas.rs index d5a5849303..0e5402a093 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/out_of_gas.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/out_of_gas.rs @@ -8,7 +8,7 @@ use crate::execution::entry_point::CallEntryPoint; use crate::execution::syscalls::syscall_tests::constants::REQUIRED_GAS_STORAGE_READ_WRITE_TEST; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion, trivial_external_entry_point_new}; #[test_case(FeatureContract::TestContract(CairoVersion::Cairo1); "VM")] #[test_case(FeatureContract::TestContract(CairoVersion::Native); "Native")] diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/replace_class.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/replace_class.rs index 25a4deaf23..7c9e82cc52 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/replace_class.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/replace_class.rs @@ -9,7 +9,7 @@ use crate::execution::entry_point::CallEntryPoint; use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion, trivial_external_entry_point_new}; #[test_case(FeatureContract::TestContract(CairoVersion::Native); "Native")] #[test_case(FeatureContract::TestContract(CairoVersion::Cairo1); "VM")] @@ -29,11 +29,10 @@ fn undeclared_class_hash(test_contract: FeatureContract) { #[test_case(FeatureContract::TestContract(CairoVersion::Cairo1); "VM")] fn cairo0_class_hash(test_contract: FeatureContract) { let empty_contract_cairo0 = FeatureContract::Empty(CairoVersion::Cairo0); - let mut state = test_state( - &ChainInfo::create_for_testing(), - BALANCE, - &[(test_contract, 1), (empty_contract_cairo0, 0)], - ); + let mut state = test_state(&ChainInfo::create_for_testing(), BALANCE, &[ + (test_contract, 1), + (empty_contract_cairo0, 0), + ]); // Replace with Cairo 0 class hash. let v0_class_hash = empty_contract_cairo0.get_class_hash(); @@ -52,11 +51,11 @@ fn cairo0_class_hash(test_contract: FeatureContract) { fn positive_flow(test_contract: FeatureContract, gas_consumed: u64) { let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1); let empty_contract_cairo0 = FeatureContract::Empty(CairoVersion::Cairo0); - let mut state = test_state( - &ChainInfo::create_for_testing(), - BALANCE, - &[(test_contract, 1), (empty_contract, 0), (empty_contract_cairo0, 0)], - ); + let mut state = test_state(&ChainInfo::create_for_testing(), BALANCE, &[ + (test_contract, 1), + (empty_contract, 0), + (empty_contract_cairo0, 0), + ]); let contract_address = test_contract.get_instance_address(0); let old_class_hash = test_contract.get_class_hash(); @@ -67,9 +66,9 @@ fn positive_flow(test_contract: FeatureContract, gas_consumed: u64) { entry_point_selector: selector_from_name("test_replace_class"), ..trivial_external_entry_point_new(test_contract) }; - assert_eq!( - entry_point_call.execute_directly(&mut state).unwrap().execution, - CallExecution { gas_consumed, ..Default::default() } - ); + assert_eq!(entry_point_call.execute_directly(&mut state).unwrap().execution, CallExecution { + gas_consumed, + ..Default::default() + }); assert_eq!(state.get_class_hash_at(contract_address).unwrap(), new_class_hash); } diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/secp.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/secp.rs index 53b2026867..07fa8ea2dd 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/secp.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/secp.rs @@ -7,7 +7,7 @@ use crate::execution::call_info::CallExecution; use crate::execution::entry_point::CallEntryPoint; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion, trivial_external_entry_point_new}; #[test_case(FeatureContract::TestContract(CairoVersion::Native), 17049456; "Native")] #[test_case(FeatureContract::TestContract(CairoVersion::Cairo1), 17022270; "VM")] diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs index 6306fb8e90..4fb47fd0f5 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs @@ -10,7 +10,7 @@ use crate::execution::call_info::{CallExecution, MessageToL1, OrderedL2ToL1Messa use crate::execution::entry_point::CallEntryPoint; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion, trivial_external_entry_point_new}; #[test_case(FeatureContract::TestContract(CairoVersion::Native), 30680; "Native")] #[test_case(FeatureContract::TestContract(CairoVersion::Cairo1), 22160; "VM")] diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/sha256.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/sha256.rs index c0f1a14145..63bf69827b 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/sha256.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/sha256.rs @@ -8,7 +8,7 @@ use crate::execution::entry_point::CallEntryPoint; use crate::retdata; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion, trivial_external_entry_point_new}; #[test_case(FeatureContract::TestContract(CairoVersion::Native), 902520; "Native")] #[test_case(FeatureContract::TestContract(CairoVersion::Cairo1), 893890; "VM")] diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/storage_read_write.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/storage_read_write.rs index 0cac173d8b..39c2d6a3e3 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/storage_read_write.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/storage_read_write.rs @@ -12,7 +12,7 @@ use crate::retdata; use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion, trivial_external_entry_point_new}; #[test_case(FeatureContract::TestContract(CairoVersion::Native), 25920; "Native")] #[test_case(FeatureContract::TestContract(CairoVersion::Cairo1), REQUIRED_GAS_STORAGE_READ_WRITE_TEST; "VM" @@ -30,14 +30,11 @@ fn test_storage_read_write(test_contract: FeatureContract, expected_gas: u64) { ..trivial_external_entry_point_new(test_contract) }; let storage_address = entry_point_call.storage_address; - assert_eq!( - entry_point_call.execute_directly(&mut state).unwrap().execution, - CallExecution { - retdata: retdata![value], - gas_consumed: expected_gas, - ..CallExecution::default() - } - ); + assert_eq!(entry_point_call.execute_directly(&mut state).unwrap().execution, CallExecution { + retdata: retdata![value], + gas_consumed: expected_gas, + ..CallExecution::default() + }); // Verify that the state has changed. let value_from_state = diff --git a/crates/blockifier/src/fee/actual_cost_test.rs b/crates/blockifier/src/fee/actual_cost_test.rs index dcb43cab28..a556f6b017 100644 --- a/crates/blockifier/src/fee/actual_cost_test.rs +++ b/crates/blockifier/src/fee/actual_cost_test.rs @@ -13,7 +13,7 @@ use crate::fee::gas_usage::{ use crate::state::cached_state::StateChangesCount; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{create_calldata, create_trivial_calldata, CairoVersion, BALANCE}; +use crate::test_utils::{BALANCE, CairoVersion, create_calldata, create_trivial_calldata}; use crate::transaction::constants; use crate::transaction::objects::{GasVector, HasRelatedFeeType, StarknetResources}; use crate::transaction::test_utils::{ @@ -337,15 +337,12 @@ fn test_calculate_tx_gas_usage( // A tx that changes the account and some other balance in execute. let some_other_account_address = account_contract.get_instance_address(17); - let execute_calldata = create_calldata( - fee_token_address, - constants::TRANSFER_ENTRY_POINT_NAME, - &[ + let execute_calldata = + create_calldata(fee_token_address, constants::TRANSFER_ENTRY_POINT_NAME, &[ *some_other_account_address.0.key(), // Calldata: recipient. Felt::TWO, // Calldata: lsb amount. Felt::ZERO, // Calldata: msb amount. - ], - ); + ]); let account_tx = account_invoke_tx(invoke_tx_args! { resource_bounds: max_resource_bounds, diff --git a/crates/blockifier/src/fee/fee_test.rs b/crates/blockifier/src/fee/fee_test.rs index 9c86e5f9d3..11b01532e5 100644 --- a/crates/blockifier/src/fee/fee_test.rs +++ b/crates/blockifier/src/fee/fee_test.rs @@ -16,8 +16,8 @@ use crate::invoke_tx_args; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - CairoVersion, BALANCE, + CairoVersion, DEFAULT_ETH_L1_DATA_GAS_PRICE, DEFAULT_ETH_L1_GAS_PRICE, }; diff --git a/crates/blockifier/src/state/cached_state_test.rs b/crates/blockifier/src/state/cached_state_test.rs index 190e2a77ee..aa9c6e30b4 100644 --- a/crates/blockifier/src/state/cached_state_test.rs +++ b/crates/blockifier/src/state/cached_state_test.rs @@ -7,10 +7,10 @@ use starknet_api::{class_hash, contract_address, felt, patricia_key}; use crate::context::{BlockContext, ChainInfo}; use crate::state::cached_state::*; +use crate::test_utils::CairoVersion; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::dict_state_reader::DictStateReader; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::CairoVersion; use crate::{compiled_class_hash, nonce, storage_key}; const CONTRACT_ADDRESS: &str = "0x100"; @@ -508,15 +508,12 @@ fn test_state_changes_keys() { assert_eq!(keys0, keys0.difference(&empty_keys)); assert_eq!(empty_keys, keys0.difference(&keys0)); assert_eq!(empty_keys.count(), StateChangesCount::default()); - assert_eq!( - keys0.count(), - StateChangesCount { - n_storage_updates: 2, - n_class_hash_updates: 1, - n_compiled_class_hash_updates: 2, - n_modified_contracts: 2 - } - ); + assert_eq!(keys0.count(), StateChangesCount { + n_storage_updates: 2, + n_class_hash_updates: 1, + n_compiled_class_hash_updates: 2, + n_modified_contracts: 2 + }); let mut keys0_copy = keys0.clone(); let mut empty_keys_copy = empty_keys.clone(); @@ -535,48 +532,39 @@ fn test_state_changes_keys() { modified_contracts: HashSet::from([contract_address1, contract_address3]), }; - assert_eq!( - keys0.difference(&keys1), - StateChangesKeys { - nonce_keys: HashSet::from([contract_address0]), - class_hash_keys: HashSet::new(), - storage_keys: HashSet::from([(contract_address2, storage_key!(0x200_u16),)]), - compiled_class_hash_keys: HashSet::from([class_hash1]), - modified_contracts: HashSet::from([contract_address2]), - } - ); - assert_eq!( - keys1.difference(&keys0), - StateChangesKeys { - nonce_keys: HashSet::from([contract_address1]), - class_hash_keys: HashSet::from([contract_address2]), - storage_keys: HashSet::new(), - compiled_class_hash_keys: HashSet::new(), - modified_contracts: HashSet::from([contract_address3]), - } - ); + assert_eq!(keys0.difference(&keys1), StateChangesKeys { + nonce_keys: HashSet::from([contract_address0]), + class_hash_keys: HashSet::new(), + storage_keys: HashSet::from([(contract_address2, storage_key!(0x200_u16),)]), + compiled_class_hash_keys: HashSet::from([class_hash1]), + modified_contracts: HashSet::from([contract_address2]), + }); + assert_eq!(keys1.difference(&keys0), StateChangesKeys { + nonce_keys: HashSet::from([contract_address1]), + class_hash_keys: HashSet::from([contract_address2]), + storage_keys: HashSet::new(), + compiled_class_hash_keys: HashSet::new(), + modified_contracts: HashSet::from([contract_address3]), + }); let keys1_copy = keys1.clone(); keys1.extend(&keys0); keys0.extend(&keys1_copy); assert_eq!(keys0, keys1); - assert_eq!( - keys0, - StateChangesKeys { - nonce_keys: HashSet::from([contract_address0, contract_address1]), - class_hash_keys: HashSet::from([contract_address1, contract_address2]), - storage_keys: HashSet::from([ - (contract_address2, storage_key!(0x300_u16)), - (contract_address2, storage_key!(0x200_u16)), - ]), - compiled_class_hash_keys: HashSet::from([class_hash0, class_hash1]), - modified_contracts: HashSet::from([ - contract_address1, - contract_address2, - contract_address3 - ]), - } - ) + assert_eq!(keys0, StateChangesKeys { + nonce_keys: HashSet::from([contract_address0, contract_address1]), + class_hash_keys: HashSet::from([contract_address1, contract_address2]), + storage_keys: HashSet::from([ + (contract_address2, storage_key!(0x300_u16)), + (contract_address2, storage_key!(0x200_u16)), + ]), + compiled_class_hash_keys: HashSet::from([class_hash0, class_hash1]), + modified_contracts: HashSet::from([ + contract_address1, + contract_address2, + contract_address3 + ]), + }) } #[rstest] diff --git a/crates/blockifier/src/state/errors.rs b/crates/blockifier/src/state/errors.rs index 5347d182f7..b85fece93c 100644 --- a/crates/blockifier/src/state/errors.rs +++ b/crates/blockifier/src/state/errors.rs @@ -1,7 +1,7 @@ use cairo_vm::types::errors::program_errors::ProgramError; use num_bigint::{BigUint, TryFromBigIntError}; -use starknet_api::core::{ClassHash, ContractAddress}; use starknet_api::StarknetApiError; +use starknet_api::core::{ClassHash, ContractAddress}; use thiserror::Error; use crate::abi::constants; diff --git a/crates/blockifier/src/state/state_wrapper.rs b/crates/blockifier/src/state/state_wrapper.rs index 9ea7735d84..ad7bca91cf 100644 --- a/crates/blockifier/src/state/state_wrapper.rs +++ b/crates/blockifier/src/state/state_wrapper.rs @@ -1,8 +1,8 @@ use std::collections::{HashMap, HashSet}; +use starknet_api::StarknetApiError; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::state::StorageKey; -use starknet_api::StarknetApiError; use starknet_types_core::felt::Felt; use crate::execution::contract_class::ContractClass; diff --git a/crates/blockifier/src/test_utils.rs b/crates/blockifier/src/test_utils.rs index e31e948861..e32adbafe5 100644 --- a/crates/blockifier/src/test_utils.rs +++ b/crates/blockifier/src/test_utils.rs @@ -17,11 +17,11 @@ use std::sync::Arc; use cairo_native::starknet::SyscallResult; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use starknet_api::core::{ - calculate_contract_address, ClassHash, ContractAddress, Nonce, PatriciaKey, + calculate_contract_address, }; use starknet_api::state::StorageKey; use starknet_api::transaction::{ @@ -52,8 +52,8 @@ use crate::execution::native::utils::{ decode_felts_as_str, encode_str_as_felts, }; -use crate::execution::syscalls::hint_processor::FAILED_TO_CALCULATE_CONTRACT_ADDRESS; use crate::execution::syscalls::SyscallSelector; +use crate::execution::syscalls::hint_processor::FAILED_TO_CALCULATE_CONTRACT_ADDRESS; use crate::state::cached_state::{CachedState, StateChangesCount}; use crate::state::state_api::State; use crate::test_utils::cached_state::get_erc20_class_hash_mapping; @@ -554,15 +554,10 @@ pub fn prepare_erc20_deploy_test_state() -> (ContractAddress, CachedState { @@ -302,27 +282,19 @@ fn test_infinite_recursion( let execute_calldata = if normal_recurse { create_calldata(contract_address, "recurse", &[felt!(recursion_depth)]) } else { - create_calldata( - contract_address, - "recursive_syscall", - &[ - *contract_address.0.key(), // Calldata: raw contract address. - selector_from_name("recursive_syscall").0, // Calldata: raw selector - felt!(recursion_depth), - ], - ) + create_calldata(contract_address, "recursive_syscall", &[ + *contract_address.0.key(), // Calldata: raw contract address. + selector_from_name("recursive_syscall").0, // Calldata: raw selector + felt!(recursion_depth), + ]) }; - let tx_execution_info = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - resource_bounds: max_resource_bounds, - sender_address: account_address, - calldata: execute_calldata, - nonce: nonce_manager.next(account_address), - }, - ) + let tx_execution_info = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + resource_bounds: max_resource_bounds, + sender_address: account_address, + calldata: execute_calldata, + nonce: nonce_manager.next(account_address), + }) .unwrap(); if success { assert!(tx_execution_info.revert_error.is_none()); @@ -421,20 +393,16 @@ fn test_max_fee_limit_validate( let estimated_min_fee = get_fee_by_gas_vector(block_info, estimated_min_gas_usage_vector, &account_tx.fee_type()); - let error_trace = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - max_fee: estimated_min_fee, - // TODO(Ori, 1/2/2024): Write an indicative expect message explaining why the conversion - // works. - resource_bounds: l1_resource_bounds( - estimated_min_l1_gas.try_into().expect("Failed to convert u128 to u64."), - block_info.gas_prices.get_l1_gas_price_by_fee_type(&account_tx.fee_type()).into() - ), - ..tx_args - }, - ) + let error_trace = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + max_fee: estimated_min_fee, + // TODO(Ori, 1/2/2024): Write an indicative expect message explaining why the conversion + // works. + resource_bounds: l1_resource_bounds( + estimated_min_l1_gas.try_into().expect("Failed to convert u128 to u64."), + block_info.gas_prices.get_l1_gas_price_by_fee_type(&account_tx.fee_type()).into() + ), + ..tx_args + }) .unwrap_err() .to_string(); @@ -468,15 +436,11 @@ fn test_recursion_depth_exceeded( .expect("Failed to convert usize to u8."); let recursive_syscall_entry_point_name = "recursive_syscall"; - let calldata = create_calldata( - contract_address, - recursive_syscall_entry_point_name, - &[ - *contract_address.0.key(), // Calldata: raw contract address. - selector_from_name(recursive_syscall_entry_point_name).0, // Calldata: raw selector. - felt!(max_inner_recursion_depth), - ], - ); + let calldata = create_calldata(contract_address, recursive_syscall_entry_point_name, &[ + *contract_address.0.key(), // Calldata: raw contract address. + selector_from_name(recursive_syscall_entry_point_name).0, // Calldata: raw selector. + felt!(max_inner_recursion_depth), + ]); let invoke_args = invoke_tx_args! { max_fee, sender_address: account_address, @@ -493,15 +457,11 @@ fn test_recursion_depth_exceeded( let exceeding_recursion_depth = max_inner_recursion_depth + 1; - let calldata = create_calldata( - contract_address, - recursive_syscall_entry_point_name, - &[ - *contract_address.0.key(), // Calldata: raw contract address. - selector_from_name(recursive_syscall_entry_point_name).0, // Calldata: raw selector. - felt!(exceeding_recursion_depth), - ], - ); + let calldata = create_calldata(contract_address, recursive_syscall_entry_point_name, &[ + *contract_address.0.key(), // Calldata: raw contract address. + selector_from_name(recursive_syscall_entry_point_name).0, // Calldata: raw selector. + felt!(exceeding_recursion_depth), + ]); let invoke_args = crate::test_utils::invoke::InvokeTxArgs { calldata, nonce: nonce_manager.next(account_address), @@ -533,22 +493,18 @@ fn test_revert_invoke( // Invoke a function that changes the state and reverts. let storage_key = felt!(9_u8); - let tx_execution_info = run_invoke_tx( - state, - &block_context, - invoke_tx_args! { - max_fee, - sender_address: account_address, - calldata: create_calldata( - test_contract_address, - "write_and_revert", - // Write some non-zero value. - &[storage_key, felt!(99_u8)] - ), - version: transaction_version, - nonce: nonce_manager.next(account_address), - }, - ) + let tx_execution_info = run_invoke_tx(state, &block_context, invoke_tx_args! { + max_fee, + sender_address: account_address, + calldata: create_calldata( + test_contract_address, + "write_and_revert", + // Write some non-zero value. + &[storage_key, felt!(99_u8)] + ), + version: transaction_version, + nonce: nonce_manager.next(account_address), + }) .unwrap(); // TODO(Dori, 1/7/2023): Verify that the actual fee collected is exactly the fee computed for @@ -711,15 +667,11 @@ fn test_reverted_reach_steps_limit( }; // Invoke the `recurse` function with 0 iterations. This call should succeed. - let result = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - nonce: nonce_manager.next(account_address), - calldata: recursive_function_calldata(&contract_address, 0, false), - ..recursion_base_args.clone() - }, - ) + let result = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + nonce: nonce_manager.next(account_address), + calldata: recursive_function_calldata(&contract_address, 0, false), + ..recursion_base_args.clone() + }) .unwrap(); let n_steps_0 = result.receipt.resources.total_charged_steps(); let actual_fee_0 = result.receipt.fee.0; @@ -727,15 +679,11 @@ fn test_reverted_reach_steps_limit( assert!(!result.is_reverted()); // Invoke the `recurse` function with 1 iteration. This call should succeed. - let result = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - nonce: nonce_manager.next(account_address), - calldata: recursive_function_calldata(&contract_address, 1, false), - ..recursion_base_args.clone() - }, - ) + let result = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + nonce: nonce_manager.next(account_address), + calldata: recursive_function_calldata(&contract_address, 1, false), + ..recursion_base_args.clone() + }) .unwrap(); let n_steps_1 = result.receipt.resources.total_charged_steps(); let actual_fee_1 = result.receipt.fee.0; @@ -754,15 +702,11 @@ fn test_reverted_reach_steps_limit( let fail_depth = block_context.versioned_constants.invoke_tx_max_n_steps / steps_diff_as_u32; // Invoke the `recurse` function with `fail_depth` iterations. This call should fail. - let result = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - nonce: nonce_manager.next(account_address), - calldata: recursive_function_calldata(&contract_address, fail_depth, false), - ..recursion_base_args.clone() - }, - ) + let result = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + nonce: nonce_manager.next(account_address), + calldata: recursive_function_calldata(&contract_address, fail_depth, false), + ..recursion_base_args.clone() + }) .unwrap(); let n_steps_fail = result.receipt.resources.total_charged_steps(); let actual_fee_fail: u128 = result.receipt.fee.0; @@ -775,15 +719,11 @@ fn test_reverted_reach_steps_limit( assert!(actual_fee_fail > actual_fee_1); // Invoke the `recurse` function with `fail_depth`+1 iterations. This call should fail. - let result = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - nonce: nonce_manager.next(account_address), - calldata: recursive_function_calldata(&contract_address, fail_depth + 1, false), - ..recursion_base_args - }, - ) + let result = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + nonce: nonce_manager.next(account_address), + calldata: recursive_function_calldata(&contract_address, fail_depth + 1, false), + ..recursion_base_args + }) .unwrap(); let n_steps_fail_next = result.receipt.resources.total_charged_steps(); let actual_fee_fail_next: u128 = result.receipt.fee.0; @@ -812,15 +752,11 @@ fn test_n_reverted_steps( }; // Invoke the `recursive_fail` function with 0 iterations. This call should fail. - let result = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - nonce: nonce_manager.next(account_address), - calldata: recursive_function_calldata(&contract_address, 0, true), - ..recursion_base_args.clone() - }, - ) + let result = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + nonce: nonce_manager.next(account_address), + calldata: recursive_function_calldata(&contract_address, 0, true), + ..recursion_base_args.clone() + }) .unwrap(); // Ensure the transaction was reverted. assert!(result.is_reverted()); @@ -829,15 +765,11 @@ fn test_n_reverted_steps( let actual_fee_0 = result.receipt.fee.0; // Invoke the `recursive_fail` function with 1 iterations. This call should fail. - let result = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - nonce: nonce_manager.next(account_address), - calldata: recursive_function_calldata(&contract_address, 1, true), - ..recursion_base_args.clone() - }, - ) + let result = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + nonce: nonce_manager.next(account_address), + calldata: recursive_function_calldata(&contract_address, 1, true), + ..recursion_base_args.clone() + }) .unwrap(); // Ensure the transaction was reverted. assert!(result.is_reverted()); @@ -846,15 +778,11 @@ fn test_n_reverted_steps( let actual_fee_1 = result.receipt.fee.0; // Invoke the `recursive_fail` function with 2 iterations. This call should fail. - let result = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - nonce: nonce_manager.next(account_address), - calldata: recursive_function_calldata(&contract_address, 2, true), - ..recursion_base_args.clone() - }, - ) + let result = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + nonce: nonce_manager.next(account_address), + calldata: recursive_function_calldata(&contract_address, 2, true), + ..recursion_base_args.clone() + }) .unwrap(); let n_steps_2 = result.receipt.resources.total_charged_steps(); let actual_fee_2 = result.receipt.fee.0; @@ -878,15 +806,11 @@ fn test_n_reverted_steps( actual_resources_0.vm_resources.n_steps = n_steps_0; // Invoke the `recursive_fail` function with 100 iterations. This call should fail. - let result = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - nonce: nonce_manager.next(account_address), - calldata: recursive_function_calldata(&contract_address, 100, true), - ..recursion_base_args - }, - ) + let result = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + nonce: nonce_manager.next(account_address), + calldata: recursive_function_calldata(&contract_address, 100, true), + ..recursion_base_args + }) .unwrap(); let n_steps_100 = result.receipt.resources.total_charged_steps(); let actual_fee_100 = result.receipt.fee.0; @@ -992,16 +916,12 @@ fn test_insufficient_max_fee_reverts( }; // Invoke the `recurse` function with depth 1 and MAX_FEE. This call should succeed. - let tx_execution_info1 = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - resource_bounds: max_resource_bounds, - nonce: nonce_manager.next(account_address), - calldata: recursive_function_calldata(&contract_address, 1, false), - ..recursion_base_args.clone() - }, - ) + let tx_execution_info1 = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + resource_bounds: max_resource_bounds, + nonce: nonce_manager.next(account_address), + calldata: recursive_function_calldata(&contract_address, 1, false), + ..recursion_base_args.clone() + }) .unwrap(); assert!(!tx_execution_info1.is_reverted()); let actual_fee_depth1 = tx_execution_info1.receipt.fee; @@ -1013,16 +933,12 @@ fn test_insufficient_max_fee_reverts( // Invoke the `recurse` function with depth of 2 and the actual fee of depth 1 as max_fee. // This call should fail due to insufficient max fee (steps bound based on max_fee is not so // tight as to stop execution between iterations 1 and 2). - let tx_execution_info2 = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - resource_bounds: l1_resource_bounds(gas_ammount, gas_price), - nonce: nonce_manager.next(account_address), - calldata: recursive_function_calldata(&contract_address, 2, false), - ..recursion_base_args.clone() - }, - ) + let tx_execution_info2 = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + resource_bounds: l1_resource_bounds(gas_ammount, gas_price), + nonce: nonce_manager.next(account_address), + calldata: recursive_function_calldata(&contract_address, 2, false), + ..recursion_base_args.clone() + }) .unwrap(); assert!(tx_execution_info2.is_reverted()); assert!(tx_execution_info2.receipt.fee == actual_fee_depth1); @@ -1031,16 +947,12 @@ fn test_insufficient_max_fee_reverts( // Invoke the `recurse` function with depth of 824 and the actual fee of depth 1 as max_fee. // This call should fail due to no remaining steps (execution steps based on max_fee are bounded // well enough to catch this mid-execution). - let tx_execution_info3 = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - resource_bounds: l1_resource_bounds(gas_ammount, gas_price), - nonce: nonce_manager.next(account_address), - calldata: recursive_function_calldata(&contract_address, 824, false), - ..recursion_base_args - }, - ) + let tx_execution_info3 = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + resource_bounds: l1_resource_bounds(gas_ammount, gas_price), + nonce: nonce_manager.next(account_address), + calldata: recursive_function_calldata(&contract_address, 824, false), + ..recursion_base_args + }) .unwrap(); assert!(tx_execution_info3.is_reverted()); assert!(tx_execution_info3.receipt.fee == actual_fee_depth1); @@ -1126,11 +1038,11 @@ fn test_count_actual_storage_changes( create_calldata(contract_address, "test_count_actual_storage_changes", &[]); let recipient = 435_u16; let transfer_amount: Felt = 1.into(); - let transfer_calldata = create_calldata( - fee_token_address, - TRANSFER_ENTRY_POINT_NAME, - &[felt!(recipient), transfer_amount, felt!(0_u8)], - ); + let transfer_calldata = create_calldata(fee_token_address, TRANSFER_ENTRY_POINT_NAME, &[ + felt!(recipient), + transfer_amount, + felt!(0_u8), + ]); // Run transactions; using transactional state to count only storage changes of the current // transaction. @@ -1322,11 +1234,11 @@ fn test_concurrency_execute_fee_transfer( // Case 2: The transaction read from and write to the sequenser balance before executing fee // transfer. - let transfer_calldata = create_calldata( - fee_token_address, - TRANSFER_ENTRY_POINT_NAME, - &[*block_context.block_info.sequencer_address.0.key(), felt!(TRANSFER_AMOUNT), felt!(0_u8)], - ); + let transfer_calldata = create_calldata(fee_token_address, TRANSFER_ENTRY_POINT_NAME, &[ + *block_context.block_info.sequencer_address.0.key(), + felt!(TRANSFER_AMOUNT), + felt!(0_u8), + ]); // Set the sequencer balance to a constant value to check that the read set did not changed. fund_account( diff --git a/crates/blockifier/src/transaction/errors.rs b/crates/blockifier/src/transaction/errors.rs index 7707c4c93d..25bcd49bf1 100644 --- a/crates/blockifier/src/transaction/errors.rs +++ b/crates/blockifier/src/transaction/errors.rs @@ -1,8 +1,8 @@ use cairo_vm::types::errors::program_errors::ProgramError; use num_bigint::BigUint; +use starknet_api::StarknetApiError; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, Nonce}; use starknet_api::transaction::{Fee, TransactionVersion}; -use starknet_api::StarknetApiError; use starknet_types_core::felt::FromStrError; use thiserror::Error; diff --git a/crates/blockifier/src/transaction/execution_flavors_test.rs b/crates/blockifier/src/transaction/execution_flavors_test.rs index 608feac892..22534bc851 100644 --- a/crates/blockifier/src/transaction/execution_flavors_test.rs +++ b/crates/blockifier/src/transaction/execution_flavors_test.rs @@ -21,17 +21,17 @@ use crate::test_utils::contracts::FeatureContract; use crate::test_utils::dict_state_reader::DictStateReader; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ + BALANCE, + CairoVersion, + MAX_FEE, + MAX_L1_GAS_AMOUNT, + MAX_L1_GAS_PRICE, + NonceManager, create_calldata, create_trivial_calldata, get_syscall_resources, get_tx_resources, u64_from_usize, - CairoVersion, - NonceManager, - BALANCE, - MAX_FEE, - MAX_L1_GAS_AMOUNT, - MAX_L1_GAS_PRICE, }; use crate::transaction::errors::{ TransactionExecutionError, @@ -40,10 +40,10 @@ use crate::transaction::errors::{ }; use crate::transaction::objects::{FeeType, GasVector, TransactionExecutionInfo}; use crate::transaction::test_utils::{ + INVALID, account_invoke_tx, l1_resource_bounds, max_resource_bounds, - INVALID, }; use crate::transaction::transaction_types::TransactionType; use crate::transaction::transactions::ExecutableTransaction; @@ -65,11 +65,11 @@ fn create_flavors_test_state( let test_contract = FeatureContract::TestContract(cairo_version); let account_contract = FeatureContract::AccountWithoutValidations(cairo_version); let faulty_account_contract = FeatureContract::FaultyAccount(cairo_version); - let state = test_state( - chain_info, - BALANCE, - &[(account_contract, 1), (faulty_account_contract, 1), (test_contract, 1)], - ); + let state = test_state(chain_info, BALANCE, &[ + (account_contract, 1), + (faulty_account_contract, 1), + (test_contract, 1), + ]); FlavorTestInitialState { state, account_address: account_contract.get_instance_address(0), @@ -145,11 +145,9 @@ fn check_gas_and_fee( } fn recurse_calldata(contract_address: ContractAddress, fail: bool, depth: u32) -> Calldata { - create_calldata( - contract_address, - if fail { "recursive_fail" } else { "recurse" }, - &[felt!(depth)], - ) + create_calldata(contract_address, if fail { "recursive_fail" } else { "recurse" }, &[felt!( + depth + )]) } /// Test simulate / validate / charge_fee flag combinations in pre-validation stage. @@ -664,15 +662,11 @@ fn test_simulate_validate_charge_fee_post_execution( assert!(felt!(actual_fee.0) < current_balance); let transfer_amount = current_balance - Felt::from(actual_fee.0 / 2); let recipient = felt!(7_u8); - let transfer_calldata = create_calldata( - fee_token_address, - "transfer", - &[ - recipient, // Calldata: to. - transfer_amount, - felt!(0_u8), - ], - ); + let transfer_calldata = create_calldata(fee_token_address, "transfer", &[ + recipient, // Calldata: to. + transfer_amount, + felt!(0_u8), + ]); let tx_execution_info = account_invoke_tx(invoke_tx_args! { max_fee: actual_fee, resource_bounds: l1_resource_bounds(success_actual_gas, gas_price.into()), diff --git a/crates/blockifier/src/transaction/post_execution_test.rs b/crates/blockifier/src/transaction/post_execution_test.rs index bb6dd8f43c..d5546ccc9f 100644 --- a/crates/blockifier/src/transaction/post_execution_test.rs +++ b/crates/blockifier/src/transaction/post_execution_test.rs @@ -17,18 +17,18 @@ use crate::invoke_tx_args; use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{create_calldata, CairoVersion, BALANCE, MAX_L1_GAS_PRICE}; +use crate::test_utils::{BALANCE, CairoVersion, MAX_L1_GAS_PRICE, create_calldata}; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::errors::TransactionExecutionError; use crate::transaction::objects::{FeeType, HasRelatedFeeType, TransactionInfoCreator}; use crate::transaction::test_utils::{ + TestInitData, account_invoke_tx, block_context, l1_resource_bounds, max_fee, max_resource_bounds, run_invoke_tx, - TestInitData, }; use crate::transaction::transactions::ExecutableTransaction; @@ -52,17 +52,13 @@ fn calldata_for_write_and_transfer( transfer_amount: Felt, fee_token_address: ContractAddress, ) -> Calldata { - create_calldata( - test_contract_address, - "test_write_and_transfer", - &[ - storage_address, // Calldata: storage address. - storage_value, // Calldata: storage value. - recipient, // Calldata: to. - transfer_amount, // Calldata: amount. - *fee_token_address.0.key(), // Calldata: fee token address. - ], - ) + create_calldata(test_contract_address, "test_write_and_transfer", &[ + storage_address, // Calldata: storage address. + storage_value, // Calldata: storage value. + recipient, // Calldata: to. + transfer_amount, // Calldata: amount. + *fee_token_address.0.key(), // Calldata: fee token address. + ]) } /// Tests that when a transaction drains an account's balance before fee transfer, the execution is @@ -99,15 +95,11 @@ fn test_revert_on_overdraft( assert_eq!(state.get_storage_at(contract_address, storage_key).unwrap(), felt!(0_u8)); // Approve the test contract to transfer funds. - let approve_calldata = create_calldata( - fee_token_address, - "approve", - &[ - *contract_address.0.key(), // Calldata: to. - felt!(BALANCE), - felt!(0_u8), - ], - ); + let approve_calldata = create_calldata(fee_token_address, "approve", &[ + *contract_address.0.key(), // Calldata: to. + felt!(BALANCE), + felt!(0_u8), + ]); let approve_tx: AccountTransaction = account_invoke_tx(invoke_tx_args! { max_fee, @@ -124,25 +116,21 @@ fn test_revert_on_overdraft( // Transfer a valid amount of funds to compute the cost of a successful // `test_write_and_transfer` operation. This operation should succeed. - let execution_info = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - max_fee, - sender_address: account_address, - calldata: calldata_for_write_and_transfer( - contract_address, - storage_address, - expected_final_value, - recipient, - final_received_amount, - fee_token_address - ), - version, - resource_bounds: max_resource_bounds.clone(), - nonce: nonce_manager.next(account_address), - }, - ) + let execution_info = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + max_fee, + sender_address: account_address, + calldata: calldata_for_write_and_transfer( + contract_address, + storage_address, + expected_final_value, + recipient, + final_received_amount, + fee_token_address + ), + version, + resource_bounds: max_resource_bounds.clone(), + nonce: nonce_manager.next(account_address), + }) .unwrap(); assert!(!execution_info.is_reverted()); @@ -155,25 +143,21 @@ fn test_revert_on_overdraft( // Attempt to transfer the entire balance, such that no funds remain to pay transaction fee. // This operation should revert. - let execution_info = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - max_fee, - sender_address: account_address, - calldata: calldata_for_write_and_transfer( - contract_address, - storage_address, - felt!(0_u8), - recipient, - balance, - fee_token_address - ), - version, - resource_bounds: max_resource_bounds, - nonce: nonce_manager.next(account_address), - }, - ) + let execution_info = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + max_fee, + sender_address: account_address, + calldata: calldata_for_write_and_transfer( + contract_address, + storage_address, + felt!(0_u8), + recipient, + balance, + fee_token_address + ), + version, + resource_bounds: max_resource_bounds, + nonce: nonce_manager.next(account_address), + }) .unwrap(); // Compute the expected balance after the reverted write+transfer (tx fee should be charged). @@ -243,17 +227,13 @@ fn test_revert_on_resource_overuse( // We need this kind of invocation, to be able to test the specific scenario: the resource // bounds must be enough to allow completion of the transaction, and yet must still fail // post-execution bounds check. - let execution_info_measure = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - max_fee, - resource_bounds: max_resource_bounds, - nonce: nonce_manager.next(account_address), - calldata: write_a_lot_calldata(), - ..base_args.clone() - }, - ) + let execution_info_measure = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + max_fee, + resource_bounds: max_resource_bounds, + nonce: nonce_manager.next(account_address), + calldata: write_a_lot_calldata(), + ..base_args.clone() + }) .unwrap(); assert_eq!(execution_info_measure.revert_error, None); let actual_fee = execution_info_measure.receipt.fee; @@ -269,17 +249,13 @@ fn test_revert_on_resource_overuse( // Run the same function, with a different written value (to keep cost high), with the actual // resources used as upper bounds. Make sure execution does not revert. - let execution_info_tight = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - max_fee: actual_fee, - resource_bounds: l1_resource_bounds(actual_gas_usage, MAX_L1_GAS_PRICE), - nonce: nonce_manager.next(account_address), - calldata: write_a_lot_calldata(), - ..base_args.clone() - }, - ) + let execution_info_tight = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + max_fee: actual_fee, + resource_bounds: l1_resource_bounds(actual_gas_usage, MAX_L1_GAS_PRICE), + nonce: nonce_manager.next(account_address), + calldata: write_a_lot_calldata(), + ..base_args.clone() + }) .unwrap(); assert_eq!(execution_info_tight.revert_error, None); assert_eq!(execution_info_tight.receipt.fee, actual_fee); @@ -288,17 +264,13 @@ fn test_revert_on_resource_overuse( // Re-run the same function with max bounds slightly below the actual usage, and verify it's // reverted. let low_max_fee = Fee(execution_info_measure.receipt.fee.0 - 1); - let execution_info_result = run_invoke_tx( - &mut state, - &block_context, - invoke_tx_args! { - max_fee: low_max_fee, - resource_bounds: l1_resource_bounds(actual_gas_usage - 1, MAX_L1_GAS_PRICE), - nonce: nonce_manager.next(account_address), - calldata: write_a_lot_calldata(), - ..base_args - }, - ); + let execution_info_result = run_invoke_tx(&mut state, &block_context, invoke_tx_args! { + max_fee: low_max_fee, + resource_bounds: l1_resource_bounds(actual_gas_usage - 1, MAX_L1_GAS_PRICE), + nonce: nonce_manager.next(account_address), + calldata: write_a_lot_calldata(), + ..base_args + }); // Assert the transaction was reverted with the correct error. if is_revertible { diff --git a/crates/blockifier/src/transaction/test_utils.rs b/crates/blockifier/src/transaction/test_utils.rs index ed9c1dd1e8..08f8231d6f 100644 --- a/crates/blockifier/src/transaction/test_utils.rs +++ b/crates/blockifier/src/transaction/test_utils.rs @@ -25,19 +25,19 @@ use crate::state::cached_state::CachedState; use crate::state::state_api::State; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::declare::declare_tx; -use crate::test_utils::deploy_account::{deploy_account_tx, DeployAccountTxArgs}; +use crate::test_utils::deploy_account::{DeployAccountTxArgs, deploy_account_tx}; use crate::test_utils::dict_state_reader::DictStateReader; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::invoke::{invoke_tx, InvokeTxArgs}; +use crate::test_utils::invoke::{InvokeTxArgs, invoke_tx}; use crate::test_utils::{ - create_calldata, - default_testing_resource_bounds, - CairoVersion, - NonceManager, BALANCE, + CairoVersion, MAX_FEE, MAX_L1_GAS_AMOUNT, MAX_L1_GAS_PRICE, + NonceManager, + create_calldata, + default_testing_resource_bounds, }; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::constants; diff --git a/crates/blockifier/src/transaction/transaction_execution.rs b/crates/blockifier/src/transaction/transaction_execution.rs index f2fb174a84..d2fd357ed4 100644 --- a/crates/blockifier/src/transaction/transaction_execution.rs +++ b/crates/blockifier/src/transaction/transaction_execution.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; -use starknet_api::core::{calculate_contract_address, ContractAddress}; +use starknet_api::core::{ContractAddress, calculate_contract_address}; use starknet_api::transaction::{Fee, Transaction as StarknetApiTransaction, TransactionHash}; use crate::bouncer::verify_tx_weights_in_bounds; diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index 1115b280ca..9b5c4159d9 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -44,8 +44,8 @@ use crate::execution::call_info::{ }; use crate::execution::entry_point::{CallEntryPoint, CallType}; use crate::execution::errors::{ConstructorEntryPointExecutionError, EntryPointExecutionError}; -use crate::execution::syscalls::hint_processor::{EmitEventError, L1_GAS, L2_GAS}; use crate::execution::syscalls::SyscallSelector; +use crate::execution::syscalls::hint_processor::{EmitEventError, L1_GAS, L2_GAS}; use crate::fee::actual_cost::TransactionReceipt; use crate::fee::fee_utils::balance_to_big_uint; use crate::fee::gas_usage::{ @@ -64,25 +64,25 @@ use crate::test_utils::initial_test_state::test_state; use crate::test_utils::invoke::invoke_tx; use crate::test_utils::prices::Prices; use crate::test_utils::{ - create_calldata, - create_trivial_calldata, - default_testing_resource_bounds, - get_syscall_resources, - get_tx_resources, - test_erc20_sequencer_balance_key, - CairoVersion, - NonceManager, - SaltManager, BALANCE, CHAIN_ID_NAME, CURRENT_BLOCK_NUMBER, CURRENT_BLOCK_NUMBER_FOR_VALIDATE, CURRENT_BLOCK_TIMESTAMP, CURRENT_BLOCK_TIMESTAMP_FOR_VALIDATE, + CairoVersion, MAX_FEE, MAX_L1_GAS_AMOUNT, MAX_L1_GAS_PRICE, + NonceManager, + SaltManager, TEST_SEQUENCER_ADDRESS, + create_calldata, + create_trivial_calldata, + default_testing_resource_bounds, + get_syscall_resources, + get_tx_resources, + test_erc20_sequencer_balance_key, }; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::constants; @@ -101,15 +101,8 @@ use crate::transaction::objects::{ TransactionResources, }; use crate::transaction::test_utils::{ - account_invoke_tx, - block_context, - calculate_class_info_for_testing, - create_account_tx_for_validate_test, - create_account_tx_for_validate_test_nonce_0, - l1_resource_bounds, - max_resource_bounds, - FaultyAccountTxCreatorArgs, CALL_CONTRACT, + FaultyAccountTxCreatorArgs, GET_BLOCK_HASH, GET_BLOCK_NUMBER, GET_BLOCK_TIMESTAMP, @@ -117,6 +110,13 @@ use crate::transaction::test_utils::{ GET_SEQUENCER_ADDRESS, INVALID, VALID, + account_invoke_tx, + block_context, + calculate_class_info_for_testing, + create_account_tx_for_validate_test, + create_account_tx_for_validate_test_nonce_0, + l1_resource_bounds, + max_resource_bounds, }; use crate::transaction::transaction_types::TransactionType; use crate::transaction::transactions::{ExecutableTransaction, L1HandlerTransaction}; @@ -824,11 +824,10 @@ fn test_max_fee_exceeds_balance( let block_context = &block_context; let account_contract = FeatureContract::AccountWithoutValidations(account_cairo_version); let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); - let state = &mut test_state( - &block_context.chain_info, - BALANCE, - &[(account_contract, 1), (test_contract, 1)], - ); + let state = &mut test_state(&block_context.chain_info, BALANCE, &[ + (account_contract, 1), + (test_contract, 1), + ]); let account_contract_address = account_contract.get_instance_address(0); let default_args = invoke_tx_args! { sender_address: account_contract_address, @@ -890,11 +889,10 @@ fn test_insufficient_resource_bounds( let block_context = &block_context; let account_contract = FeatureContract::AccountWithoutValidations(account_cairo_version); let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); - let state = &mut test_state( - &block_context.chain_info, - BALANCE, - &[(account_contract, 1), (test_contract, 1)], - ); + let state = &mut test_state(&block_context.chain_info, BALANCE, &[ + (account_contract, 1), + (test_contract, 1), + ]); let valid_invoke_tx_args = invoke_tx_args! { sender_address: account_contract.get_instance_address(0), calldata: create_trivial_calldata(test_contract.get_instance_address(0)), @@ -981,11 +979,10 @@ fn test_actual_fee_gt_resource_bounds( let block_context = &block_context; let account_contract = FeatureContract::AccountWithoutValidations(account_cairo_version); let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); - let state = &mut test_state( - &block_context.chain_info, - BALANCE, - &[(account_contract, 1), (test_contract, 1)], - ); + let state = &mut test_state(&block_context.chain_info, BALANCE, &[ + (account_contract, 1), + (test_contract, 1), + ]); let invoke_tx_args = invoke_tx_args! { sender_address: account_contract.get_instance_address(0), calldata: create_trivial_calldata(test_contract.get_instance_address(0)), @@ -1024,11 +1021,10 @@ fn test_invalid_nonce( ) { let account_contract = FeatureContract::AccountWithoutValidations(account_cairo_version); let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); - let state = &mut test_state( - &block_context.chain_info, - BALANCE, - &[(account_contract, 1), (test_contract, 1)], - ); + let state = &mut test_state(&block_context.chain_info, BALANCE, &[ + (account_contract, 1), + (test_contract, 1), + ]); let valid_invoke_tx_args = invoke_tx_args! { sender_address: account_contract.get_instance_address(0), calldata: create_trivial_calldata(test_contract.get_instance_address(0)), @@ -1604,25 +1600,22 @@ fn test_validate_accounts_tx( // Valid logic. let nonce_manager = &mut NonceManager::default(); let declared_contract_cairo_version = CairoVersion::from_declare_tx_version(tx_version); - let account_tx = create_account_tx_for_validate_test( - nonce_manager, - FaultyAccountTxCreatorArgs { + let account_tx = + create_account_tx_for_validate_test(nonce_manager, FaultyAccountTxCreatorArgs { scenario: VALID, contract_address_salt: salt_manager.next_salt(), additional_data: None, declared_contract: Some(FeatureContract::TestContract(declared_contract_cairo_version)), resource_bounds: default_testing_resource_bounds(), ..default_args - }, - ); + }); let result = account_tx.execute(state, block_context, true, true); assert!(result.is_ok(), "Execution failed: {:?}", result.unwrap_err()); if tx_type != TransactionType::DeployAccount { // Call self (allowed). - let account_tx = create_account_tx_for_validate_test( - nonce_manager, - FaultyAccountTxCreatorArgs { + let account_tx = + create_account_tx_for_validate_test(nonce_manager, FaultyAccountTxCreatorArgs { scenario: CALL_CONTRACT, additional_data: Some(vec![*sender_address.0.key()]), declared_contract: Some(FeatureContract::AccountWithLongValidate( @@ -1630,8 +1623,7 @@ fn test_validate_accounts_tx( )), resource_bounds: default_testing_resource_bounds(), ..default_args - }, - ); + }); let result = account_tx.execute(state, block_context, true, true); assert!(result.is_ok(), "Execution failed: {:?}", result.unwrap_err()); } @@ -1639,9 +1631,8 @@ fn test_validate_accounts_tx( if let CairoVersion::Cairo0 = cairo_version { // Call the syscall get_block_number and assert the returned block number was modified // for validate. - let account_tx = create_account_tx_for_validate_test( - nonce_manager, - FaultyAccountTxCreatorArgs { + let account_tx = + create_account_tx_for_validate_test(nonce_manager, FaultyAccountTxCreatorArgs { scenario: GET_BLOCK_NUMBER, contract_address_salt: salt_manager.next_salt(), additional_data: Some(vec![Felt::from(CURRENT_BLOCK_NUMBER_FOR_VALIDATE)]), @@ -1650,24 +1641,21 @@ fn test_validate_accounts_tx( )), resource_bounds: default_testing_resource_bounds(), ..default_args - }, - ); + }); let result = account_tx.execute(state, block_context, true, true); assert!(result.is_ok(), "Execution failed: {:?}", result.unwrap_err()); // Call the syscall get_block_timestamp and assert the returned timestamp was modified // for validate. - let account_tx = create_account_tx_for_validate_test( - nonce_manager, - FaultyAccountTxCreatorArgs { + let account_tx = + create_account_tx_for_validate_test(nonce_manager, FaultyAccountTxCreatorArgs { scenario: GET_BLOCK_TIMESTAMP, contract_address_salt: salt_manager.next_salt(), additional_data: Some(vec![Felt::from(CURRENT_BLOCK_TIMESTAMP_FOR_VALIDATE)]), declared_contract: Some(FeatureContract::Empty(declared_contract_cairo_version)), resource_bounds: default_testing_resource_bounds(), ..default_args - }, - ); + }); let result = account_tx.execute(state, block_context, true, true); assert!(result.is_ok(), "Execution failed: {:?}", result.unwrap_err()); } @@ -1705,11 +1693,10 @@ fn test_valid_flag( let block_context = &block_context; let account_contract = FeatureContract::AccountWithoutValidations(account_cairo_version); let test_contract = FeatureContract::TestContract(test_contract_cairo_version); - let state = &mut test_state( - &block_context.chain_info, - BALANCE, - &[(account_contract, 1), (test_contract, 1)], - ); + let state = &mut test_state(&block_context.chain_info, BALANCE, &[ + (account_contract, 1), + (test_contract, 1), + ]); let account_tx = account_invoke_tx(invoke_tx_args! { sender_address: account_contract.get_instance_address(0), @@ -1733,11 +1720,10 @@ fn test_only_query_flag( let block_context = &block_context; let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1); - let state = &mut test_state( - &block_context.chain_info, - account_balance, - &[(account, 1), (test_contract, 1)], - ); + let state = &mut test_state(&block_context.chain_info, account_balance, &[ + (account, 1), + (test_contract, 1), + ]); let mut version = Felt::from(3_u8); if only_query { let query_version_base = Felt::TWO.pow(constants::QUERY_VERSION_BASE_BIT); @@ -1977,11 +1963,10 @@ fn test_execute_tx_with_invalid_transaction_version( let state = &mut test_state(&block_context.chain_info, BALANCE, &[(account, 1), (test_contract, 1)]); let invalid_version = 12345_u64; - let calldata = create_calldata( - test_contract.get_instance_address(0), - "test_tx_version", - &[felt!(invalid_version)], - ); + let calldata = + create_calldata(test_contract.get_instance_address(0), "test_tx_version", &[felt!( + invalid_version + )]); let account_tx = account_invoke_tx(invoke_tx_args! { resource_bounds: max_resource_bounds, sender_address: account.get_instance_address(0), @@ -2051,11 +2036,10 @@ fn test_emit_event_exceeds_limit( let test_contract = FeatureContract::TestContract(cairo_version); let account_contract = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); let block_context = &block_context; - let state = &mut test_state( - &block_context.chain_info, - BALANCE, - &[(test_contract, 1), (account_contract, 1)], - ); + let state = &mut test_state(&block_context.chain_info, BALANCE, &[ + (test_contract, 1), + (account_contract, 1), + ]); let calldata = [ vec![felt!(u16::try_from(n_emitted_events).expect("Failed to convert usize to u16."))] diff --git a/crates/blockifier/src/utils_test.rs b/crates/blockifier/src/utils_test.rs index de44312e42..fe935e079c 100644 --- a/crates/blockifier/src/utils_test.rs +++ b/crates/blockifier/src/utils_test.rs @@ -4,10 +4,10 @@ use std::num::NonZeroU128; use pretty_assertions::assert_eq; use crate::utils::{ + STRICT_SUBTRACT_MAPPING_ERROR, strict_subtract_mappings, subtract_mappings, u128_div_ceil, - STRICT_SUBTRACT_MAPPING_ERROR, }; #[test] diff --git a/crates/blockifier/src/versioned_constants_test.rs b/crates/blockifier/src/versioned_constants_test.rs index 7a6f9f545d..375c745240 100644 --- a/crates/blockifier/src/versioned_constants_test.rs +++ b/crates/blockifier/src/versioned_constants_test.rs @@ -1,5 +1,5 @@ use cairo_vm::types::builtin_name::BuiltinName; -use glob::{glob, Paths}; +use glob::{Paths, glob}; use pretty_assertions::assert_eq; use super::*; diff --git a/crates/blockifier/tests/erc20_tests.rs b/crates/blockifier/tests/erc20_tests.rs index 2131a09d51..b7c43b6259 100644 --- a/crates/blockifier/tests/erc20_tests.rs +++ b/crates/blockifier/tests/erc20_tests.rs @@ -57,33 +57,34 @@ mod transfer_tests { let mut context = TestContext::new().with_caller(address_from.into()); - assert_eq!( - context.call_entry_point("balance_of", vec![address_from.into()]), - vec![total_supply, Felt::from(0u128)] - ); - - assert_eq!( - context.call_entry_point("balance_of", vec![address_to.into()]), - vec![Felt::from(0u128), Felt::from(0u128)] - ); - - assert_eq!( - context.call_entry_point( - "transfer", - vec![address_to.into(), balance_to_transfer, Felt::from(0u128)], - ), + assert_eq!(context.call_entry_point("balance_of", vec![address_from.into()]), vec![ + total_supply, + Felt::from(0u128) + ]); + + assert_eq!(context.call_entry_point("balance_of", vec![address_to.into()]), vec![ + Felt::from(0u128), + Felt::from(0u128) + ]); + + assert_eq!( + context.call_entry_point("transfer", vec![ + address_to.into(), + balance_to_transfer, + Felt::from(0u128) + ],), vec![Felt::from(true)] ); - assert_eq!( - context.call_entry_point("balance_of", vec![address_from.into()]), - vec![(balance_after_transfer), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_from.into()]), vec![ + (balance_after_transfer), + Felt::from(0u128) + ]); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to.into()]), - vec![(balance_to_transfer), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to.into()]), vec![ + (balance_to_transfer), + Felt::from(0u128) + ]); } #[test] @@ -96,35 +97,36 @@ mod transfer_tests { let mut context = TestContext::new().with_caller(address_from.into()); - assert_eq!( - context.call_entry_point("balance_of", vec![address_from.into()]), - vec![(total_supply), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_from.into()]), vec![ + (total_supply), + Felt::from(0u128) + ]); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to.into()]), - vec![Felt::from(0u128), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to.into()]), vec![ + Felt::from(0u128), + Felt::from(0u128) + ]); assert_eq!( &context - .call_entry_point_raw( - "transfer", - vec![address_to.into(), balance_to_transfer, Felt::from(0u128)], - ) + .call_entry_point_raw("transfer", vec![ + address_to.into(), + balance_to_transfer, + Felt::from(0u128) + ],) .unwrap_err(), U256_SUB_OVERFLOW, ); - assert_eq!( - context.call_entry_point("balance_of", vec![address_from.into()]), - vec![(total_supply), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_from.into()]), vec![ + (total_supply), + Felt::from(0u128) + ]); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to.into()]), - vec![Felt::from(0u128), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to.into()]), vec![ + Felt::from(0u128), + Felt::from(0u128) + ]); } #[test] @@ -138,33 +140,34 @@ mod transfer_tests { let mut context = TestContext::new().with_caller(address_from.into()); - assert_eq!( - context.call_entry_point("balance_of", vec![address_from.into()]), - vec![(total_supply), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_from.into()]), vec![ + (total_supply), + Felt::from(0u128) + ]); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to.into()]), - vec![Felt::from(0u128), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to.into()]), vec![ + Felt::from(0u128), + Felt::from(0u128) + ]); assert_eq!( - context.call_entry_point( - "transfer", - vec![address_to.into(), balance_to_transfer, Felt::from(0u128)], - ), + context.call_entry_point("transfer", vec![ + address_to.into(), + balance_to_transfer, + Felt::from(0u128) + ],), vec![Felt::from(true)] ); - assert_eq!( - context.call_entry_point("balance_of", vec![address_from.into()]), - vec![(balance_after_transfer), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_from.into()]), vec![ + (balance_after_transfer), + Felt::from(0u128) + ]); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to.into()]), - vec![(balance_to_transfer), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to.into()]), vec![ + (balance_to_transfer), + Felt::from(0u128) + ]); let event = context.get_event(0).unwrap(); let event = (event.keys[1], event.keys[2], event.data[0]); @@ -192,10 +195,11 @@ mod allowance_tests { ); assert_eq!( - context.call_entry_point( - "approve", - vec![address_to.into(), balance_to_transfer, Felt::from(0u128)], - ), + context.call_entry_point("approve", vec![ + address_to.into(), + balance_to_transfer, + Felt::from(0u128) + ],), vec![Felt::from(true)] ); @@ -220,10 +224,11 @@ mod allowance_tests { ); assert_eq!( - context.call_entry_point( - "approve", - vec![address_to.into(), balance_to_transfer, Felt::from(0u128)], - ), + context.call_entry_point("approve", vec![ + address_to.into(), + balance_to_transfer, + Felt::from(0u128) + ],), vec![Felt::from(true)] ); @@ -255,48 +260,46 @@ mod transfer_from_tests { let mut context = TestContext::new().with_caller(address_from.into()); - assert_eq!( - context.call_entry_point("balance_of", vec![address_from.into()]), - vec![(total_supply), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_from.into()]), vec![ + (total_supply), + Felt::from(0u128) + ]); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to.into()]), - vec![Felt::from(0u128), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to.into()]), vec![ + Felt::from(0u128), + Felt::from(0u128) + ]); assert_eq!( - context.call_entry_point( - "approve", - vec![address_spender.into(), balance_to_transfer, Felt::from(0u128)], - ), + context.call_entry_point("approve", vec![ + address_spender.into(), + balance_to_transfer, + Felt::from(0u128) + ],), vec![Felt::from(true)] ); let mut context = context.with_caller(address_spender.into()); assert_eq!( - context.call_entry_point( - "transfer_from", - vec![ - address_from.into(), - address_to.into(), - balance_to_transfer, - Felt::from(0u128) - ], - ), + context.call_entry_point("transfer_from", vec![ + address_from.into(), + address_to.into(), + balance_to_transfer, + Felt::from(0u128) + ],), vec![Felt::from(true)] ); - assert_eq!( - context.call_entry_point("balance_of", vec![address_from.into()]), - vec![(balance_after_transfer), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_from.into()]), vec![ + (balance_after_transfer), + Felt::from(0u128) + ]); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to.into()]), - vec![(balance_to_transfer), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to.into()]), vec![ + (balance_to_transfer), + Felt::from(0u128) + ]); } #[test] @@ -310,21 +313,22 @@ mod transfer_from_tests { let mut context = TestContext::new().with_caller(address_from.into()); - assert_eq!( - context.call_entry_point("balance_of", vec![address_from.into()]), - vec![(total_supply), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_from.into()]), vec![ + (total_supply), + Felt::from(0u128) + ]); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to.into()]), - vec![Felt::from(0u128), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to.into()]), vec![ + Felt::from(0u128), + Felt::from(0u128) + ]); assert_eq!( - context.call_entry_point( - "approve", - vec![address_spender.into(), balance_to_transfer, Felt::from(0u128)], - ), + context.call_entry_point("approve", vec![ + address_spender.into(), + balance_to_transfer, + Felt::from(0u128) + ],), vec![Felt::from(true)] ); @@ -332,28 +336,25 @@ mod transfer_from_tests { assert_eq!( &context - .call_entry_point_raw( - "transfer_from", - vec![ - address_from.into(), - address_to.into(), - (Felt::from(BALANCE_TO_TRANSFER + 1)), - Felt::from(0u128) - ], - ) + .call_entry_point_raw("transfer_from", vec![ + address_from.into(), + address_to.into(), + (Felt::from(BALANCE_TO_TRANSFER + 1)), + Felt::from(0u128) + ],) .unwrap_err(), U256_SUB_OVERFLOW, ); - assert_eq!( - context.call_entry_point("balance_of", vec![address_from.into()]), - vec![(total_supply), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_from.into()]), vec![ + (total_supply), + Felt::from(0u128) + ]); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to.into()]), - vec![Felt::from(0u128), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to.into()]), vec![ + Felt::from(0u128), + Felt::from(0u128) + ]); } #[test] @@ -367,21 +368,22 @@ mod transfer_from_tests { let mut context = TestContext::new().with_caller(address_from.into()); - assert_eq!( - context.call_entry_point("balance_of", vec![address_from.into()]), - vec![(total_supply), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_from.into()]), vec![ + (total_supply), + Felt::from(0u128) + ]); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to.into()]), - vec![Felt::from(0u128), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to.into()]), vec![ + Felt::from(0u128), + Felt::from(0u128) + ]); assert_eq!( - context.call_entry_point( - "approve", - vec![address_spender.into(), balance_to_transfer, Felt::from(0u128)], - ), + context.call_entry_point("approve", vec![ + address_spender.into(), + balance_to_transfer, + Felt::from(0u128) + ],), vec![Felt::from(true)] ); @@ -389,28 +391,25 @@ mod transfer_from_tests { assert_eq!( &context - .call_entry_point_raw( - "transfer_from", - vec![ - address_from.into(), - address_to.into(), - balance_to_transfer, - Felt::from(0u128) - ], - ) + .call_entry_point_raw("transfer_from", vec![ + address_from.into(), + address_to.into(), + balance_to_transfer, + Felt::from(0u128) + ],) .unwrap_err(), U256_SUB_OVERFLOW, ); - assert_eq!( - context.call_entry_point("balance_of", vec![address_from.into()]), - vec![(total_supply), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_from.into()]), vec![ + (total_supply), + Felt::from(0u128) + ]); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to.into()]), - vec![Felt::from(0u128), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to.into()]), vec![ + Felt::from(0u128), + Felt::from(0u128) + ]); } #[test] @@ -424,21 +423,22 @@ mod transfer_from_tests { let mut context = TestContext::new().with_caller(address_from.into()); - assert_eq!( - context.call_entry_point("balance_of", vec![address_from.into()]), - vec![(total_supply), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_from.into()]), vec![ + (total_supply), + Felt::from(0u128) + ]); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to.into()]), - vec![Felt::from(0u128), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to.into()]), vec![ + Felt::from(0u128), + Felt::from(0u128) + ]); assert_eq!( - context.call_entry_point( - "approve", - vec![address_spender.into(), balance_to_transfer, Felt::from(0u128)], - ), + context.call_entry_point("approve", vec![ + address_spender.into(), + balance_to_transfer, + Felt::from(0u128) + ],), vec![Felt::from(true)] ); @@ -451,15 +451,12 @@ mod transfer_from_tests { let mut context = context.with_caller(address_spender.into()); assert_eq!( - context.call_entry_point( - "transfer_from", - vec![ - address_from.into(), - address_to.into(), - balance_to_transfer, - Felt::from(0u128) - ], - ), + context.call_entry_point("transfer_from", vec![ + address_from.into(), + address_to.into(), + balance_to_transfer, + Felt::from(0u128) + ],), vec![Felt::from(true)] ); @@ -480,10 +477,11 @@ mod metadata_tests { let mut context = TestContext::new(); let result = context.call_entry_point("name", vec![]); - assert_eq!( - result, - vec![Felt::from(0), Felt::from_bytes_be_slice(NAME.as_bytes()), Felt::from(NAME.len())] - ); + assert_eq!(result, vec![ + Felt::from(0), + Felt::from_bytes_be_slice(NAME.as_bytes()), + Felt::from(NAME.len()) + ]); } #[test] @@ -491,14 +489,11 @@ mod metadata_tests { let mut context = TestContext::new(); let result = context.call_entry_point("symbol", vec![]); - assert_eq!( - result, - vec![ - Felt::from(0), - Felt::from_bytes_be_slice(SYMBOL.as_bytes()), - Felt::from(SYMBOL.len()) - ] - ); + assert_eq!(result, vec![ + Felt::from(0), + Felt::from_bytes_be_slice(SYMBOL.as_bytes()), + Felt::from(SYMBOL.len()) + ]); } #[test] @@ -520,32 +515,29 @@ pub mod mintable_tests { let mut context = TestContext::new().with_caller(Signers::Alice.into()); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to_mint_to.into()]), - vec![Felt::from(0u128), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to_mint_to.into()]), vec![ + Felt::from(0u128), + Felt::from(0u128) + ]); assert_eq!( - context.call_entry_point( - "mint", - vec![ - address_to_mint_to.into(), - Felt::from(BALANCE_TO_TRANSFER), - Felt::from(0u128), - ], - ), + context.call_entry_point("mint", vec![ + address_to_mint_to.into(), + Felt::from(BALANCE_TO_TRANSFER), + Felt::from(0u128), + ],), vec![] ); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to_mint_to.into()]), - vec![Felt::from(BALANCE_TO_TRANSFER), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to_mint_to.into()]), vec![ + Felt::from(BALANCE_TO_TRANSFER), + Felt::from(0u128) + ]); - assert_eq!( - context.call_entry_point("total_supply", vec![]), - vec![Felt::from(TOTAL_SUPPLY + BALANCE_TO_TRANSFER), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("total_supply", vec![]), vec![ + Felt::from(TOTAL_SUPPLY + BALANCE_TO_TRANSFER), + Felt::from(0u128) + ]); } #[test] @@ -555,34 +547,31 @@ pub mod mintable_tests { let mut context = TestContext::new().with_caller(address_of_minter.into()); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to_mint_to.into()]), - vec![Felt::from(0u128), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to_mint_to.into()]), vec![ + Felt::from(0u128), + Felt::from(0u128) + ]); assert_eq!( &context - .call_entry_point_raw( - "mint", - vec![ - address_to_mint_to.into(), - Felt::from(BALANCE_TO_TRANSFER), - Felt::from(0u128) - ] - ) + .call_entry_point_raw("mint", vec![ + address_to_mint_to.into(), + Felt::from(BALANCE_TO_TRANSFER), + Felt::from(0u128) + ]) .unwrap_err(), CALLER_IS_NOT_THE_OWNER, ); - assert_eq!( - context.call_entry_point("balance_of", vec![address_to_mint_to.into()]), - vec![Felt::from(0u128), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("balance_of", vec![address_to_mint_to.into()]), vec![ + Felt::from(0u128), + Felt::from(0u128) + ]); - assert_eq!( - context.call_entry_point("total_supply", vec![]), - vec![Felt::from(TOTAL_SUPPLY), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("total_supply", vec![]), vec![ + Felt::from(TOTAL_SUPPLY), + Felt::from(0u128) + ]); } #[test] @@ -593,14 +582,11 @@ pub mod mintable_tests { let mut context = TestContext::new().with_caller(owner.into()); assert_eq!( - context.call_entry_point( - "mint", - vec![ - address_to_mint_to.into(), - Felt::from(BALANCE_TO_TRANSFER), - Felt::from(0u128), - ], - ), + context.call_entry_point("mint", vec![ + address_to_mint_to.into(), + Felt::from(BALANCE_TO_TRANSFER), + Felt::from(0u128), + ],), vec![] ); @@ -647,10 +633,10 @@ pub mod burnable_tests { vec![Felt::from(TOTAL_SUPPLY - BALANCE_TO_TRANSFER), Felt::from(0u128)] ); - assert_eq!( - context.call_entry_point("total_supply", vec![]), - vec![Felt::from(TOTAL_SUPPLY - BALANCE_TO_TRANSFER), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("total_supply", vec![]), vec![ + Felt::from(TOTAL_SUPPLY - BALANCE_TO_TRANSFER), + Felt::from(0u128) + ]); } #[test] @@ -664,10 +650,10 @@ pub mod burnable_tests { U256_SUB_OVERFLOW, ); - assert_eq!( - context.call_entry_point("total_supply", vec![]), - vec![Felt::from(TOTAL_SUPPLY), Felt::from(0u128)] - ); + assert_eq!(context.call_entry_point("total_supply", vec![]), vec![ + Felt::from(TOTAL_SUPPLY), + Felt::from(0u128) + ]); } #[test] diff --git a/crates/blockifier/tests/feature_contracts_compatibility_test.rs b/crates/blockifier/tests/feature_contracts_compatibility_test.rs index cac102c77d..ce6c975d20 100644 --- a/crates/blockifier/tests/feature_contracts_compatibility_test.rs +++ b/crates/blockifier/tests/feature_contracts_compatibility_test.rs @@ -1,7 +1,7 @@ use std::fs; -use blockifier::test_utils::contracts::FeatureContract; use blockifier::test_utils::CairoVersion; +use blockifier::test_utils::contracts::FeatureContract; use pretty_assertions::assert_eq; use rstest::rstest; diff --git a/crates/committer_cli/benches/committer_bench.rs b/crates/committer_cli/benches/committer_bench.rs index 6a006df2fa..da1ee6cbc2 100644 --- a/crates/committer_cli/benches/committer_bench.rs +++ b/crates/committer_cli/benches/committer_bench.rs @@ -12,7 +12,7 @@ use std::collections::HashMap; use committer_cli::commands::commit; use committer_cli::parse_input::read::parse_input; use committer_cli::tests::utils::parse_from_python::TreeFlowInput; -use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; +use criterion::{BatchSize, Criterion, criterion_group, criterion_main}; use starknet_committer::block_committer::input::StarknetStorageValue; use starknet_committer::hash_function::hash::TreeHashFunctionImpl; use starknet_committer::patricia_merkle_tree::tree::OriginalSkeletonStorageTrieConfig; diff --git a/crates/committer_cli/src/commands.rs b/crates/committer_cli/src/commands.rs index fad171a4cb..f71348e3b6 100644 --- a/crates/committer_cli/src/commands.rs +++ b/crates/committer_cli/src/commands.rs @@ -2,8 +2,8 @@ use starknet_committer::block_committer::commit::commit_block; use starknet_committer::block_committer::input::{Config, ConfigImpl, Input}; use tracing::info; use tracing::level_filters::LevelFilter; -use tracing_subscriber::reload::Handle; use tracing_subscriber::Registry; +use tracing_subscriber::reload::Handle; use crate::filled_tree_output::filled_forest::SerializedForest; use crate::parse_input::read::{parse_input, write_to_file}; diff --git a/crates/committer_cli/src/tests/utils/random_structs.rs b/crates/committer_cli/src/tests/utils/random_structs.rs index 5f175acb93..c3aea8ff7e 100644 --- a/crates/committer_cli/src/tests/utils/random_structs.rs +++ b/crates/committer_cli/src/tests/utils/random_structs.rs @@ -2,8 +2,8 @@ use std::cmp::min; use std::collections::HashMap; use ethnum::U256; -use rand::prelude::IteratorRandom; use rand::Rng; +use rand::prelude::IteratorRandom; use rand_distr::num_traits::ToPrimitive; use rand_distr::{Distribution, Geometric}; use starknet_committer::block_committer::input::{ContractAddress, StarknetStorageValue}; diff --git a/crates/committer_cli/src/tracing_utils.rs b/crates/committer_cli/src/tracing_utils.rs index 2a859abdd1..fbc817828d 100644 --- a/crates/committer_cli/src/tracing_utils.rs +++ b/crates/committer_cli/src/tracing_utils.rs @@ -1,7 +1,7 @@ use tracing::level_filters::LevelFilter; use tracing_subscriber::prelude::*; use tracing_subscriber::reload::Handle; -use tracing_subscriber::{filter, fmt, reload, Registry}; +use tracing_subscriber::{Registry, filter, fmt, reload}; // TODO(Amos, 1/8/2024) Move all tracing instantiations in the Sequencer repo to a common location. pub fn configure_tracing() -> Handle { diff --git a/crates/consensus_manager/src/config.rs b/crates/consensus_manager/src/config.rs index 8c05aaf123..ea020d06a5 100644 --- a/crates/consensus_manager/src/config.rs +++ b/crates/consensus_manager/src/config.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; -use papyrus_config::dumping::{ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::Validate; diff --git a/crates/gateway/src/communication.rs b/crates/gateway/src/communication.rs index e7107c750c..ab4e16c273 100644 --- a/crates/gateway/src/communication.rs +++ b/crates/gateway/src/communication.rs @@ -1,4 +1,4 @@ -use starknet_mempool_infra::component_server::{create_empty_server, EmptyServer}; +use starknet_mempool_infra::component_server::{EmptyServer, create_empty_server}; use crate::gateway::Gateway; diff --git a/crates/gateway/src/compilation.rs b/crates/gateway/src/compilation.rs index aab1affc40..a012f105cf 100644 --- a/crates/gateway/src/compilation.rs +++ b/crates/gateway/src/compilation.rs @@ -5,10 +5,10 @@ use cairo_lang_starknet_classes::contract_class::ContractClass as CairoLangContr use starknet_api::contract_class::ClassInfo; use starknet_api::core::CompiledClassHash; use starknet_api::rpc_transaction::RpcDeclareTransaction; +use starknet_sierra_compile::SierraToCasmCompiler; use starknet_sierra_compile::cairo_lang_compiler::CairoLangSierraToCasmCompiler; use starknet_sierra_compile::config::SierraToCasmCompilationConfig; use starknet_sierra_compile::utils::into_contract_class_for_compilation; -use starknet_sierra_compile::SierraToCasmCompiler; use tracing::{debug, error}; use crate::errors::{GatewayResult, GatewaySpecError}; diff --git a/crates/gateway/src/compiler_version.rs b/crates/gateway/src/compiler_version.rs index ce6fa55c23..1fa7ba75e2 100644 --- a/crates/gateway/src/compiler_version.rs +++ b/crates/gateway/src/compiler_version.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; use cairo_lang_starknet_classes::compiler_version::VersionId as CairoLangVersionId; use cairo_lang_starknet_classes::contract_class::version_id_from_serialized_sierra_program; -use papyrus_config::dumping::{ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use starknet_sierra_compile::utils::sierra_program_as_felts_to_big_uint_as_hex; diff --git a/crates/gateway/src/config.rs b/crates/gateway/src/config.rs index 87543e2da8..cafe52b842 100644 --- a/crates/gateway/src/config.rs +++ b/crates/gateway/src/config.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; use std::net::IpAddr; use blockifier::context::ChainInfo; -use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, append_sub_config_name, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use starknet_api::core::Nonce; diff --git a/crates/gateway/src/errors.rs b/crates/gateway/src/errors.rs index 0b875ad946..7b8c0a7213 100644 --- a/crates/gateway/src/errors.rs +++ b/crates/gateway/src/errors.rs @@ -5,9 +5,6 @@ use axum::response::{IntoResponse, Response}; use blockifier::state::errors::StateError; use enum_assoc::Assoc; use papyrus_rpc::error::{ - unexpected_error, - validation_failure, - JsonRpcError, CLASS_ALREADY_DECLARED, CLASS_HASH_NOT_FOUND, COMPILATION_FAILED, @@ -17,9 +14,12 @@ use papyrus_rpc::error::{ INSUFFICIENT_ACCOUNT_BALANCE, INSUFFICIENT_MAX_FEE, INVALID_TRANSACTION_NONCE, + JsonRpcError, NON_ACCOUNT, UNSUPPORTED_CONTRACT_CLASS_VERSION, UNSUPPORTED_TX_VERSION, + unexpected_error, + validation_failure, }; use serde_json::{Error as SerdeError, Value}; use starknet_api::block::GasPrice; diff --git a/crates/gateway/src/gateway_test.rs b/crates/gateway/src/gateway_test.rs index 0015858609..3fede66f75 100644 --- a/crates/gateway/src/gateway_test.rs +++ b/crates/gateway/src/gateway_test.rs @@ -17,8 +17,8 @@ use starknet_sierra_compile::config::SierraToCasmCompilationConfig; use crate::compilation::GatewayCompiler; use crate::config::{StatefulTransactionValidatorConfig, StatelessTransactionValidatorConfig}; -use crate::gateway::{add_tx, AppState, SharedMempoolClient}; -use crate::state_reader_test_utils::{local_test_state_reader_factory, TestStateReaderFactory}; +use crate::gateway::{AppState, SharedMempoolClient, add_tx}; +use crate::state_reader_test_utils::{TestStateReaderFactory, local_test_state_reader_factory}; use crate::stateful_transaction_validator::StatefulTransactionValidator; use crate::stateless_transaction_validator::StatelessTransactionValidator; use crate::utils::rpc_tx_to_account_tx; diff --git a/crates/gateway/src/rpc_state_reader.rs b/crates/gateway/src/rpc_state_reader.rs index 60fec240bd..25a11f602e 100644 --- a/crates/gateway/src/rpc_state_reader.rs +++ b/crates/gateway/src/rpc_state_reader.rs @@ -5,14 +5,14 @@ use blockifier::state::state_api::{StateReader as BlockifierStateReader, StateRe use papyrus_rpc::CompiledContractClass; use reqwest::blocking::Client as BlockingClient; use serde::Serialize; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use starknet_api::block::BlockNumber; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::state::StorageKey; use starknet_types_core::felt::Felt; use crate::config::RpcStateReaderConfig; -use crate::errors::{serde_err_to_state_err, RPCStateReaderError, RPCStateReaderResult}; +use crate::errors::{RPCStateReaderError, RPCStateReaderResult, serde_err_to_state_err}; use crate::rpc_objects::{ BlockHeader, BlockId, @@ -21,10 +21,10 @@ use crate::rpc_objects::{ GetCompiledContractClassParams, GetNonceParams, GetStorageAtParams, - RpcResponse, RPC_CLASS_HASH_NOT_FOUND, RPC_ERROR_BLOCK_NOT_FOUND, RPC_ERROR_CONTRACT_ADDRESS_NOT_FOUND, + RpcResponse, }; use crate::state_reader::{MempoolStateReader, StateReaderFactory}; diff --git a/crates/gateway/src/state_reader_test_utils.rs b/crates/gateway/src/state_reader_test_utils.rs index a806bed9b6..e614e8caf0 100644 --- a/crates/gateway/src/state_reader_test_utils.rs +++ b/crates/gateway/src/state_reader_test_utils.rs @@ -6,7 +6,7 @@ use blockifier::state::state_api::{StateReader as BlockifierStateReader, StateRe use blockifier::test_utils::contracts::FeatureContract; use blockifier::test_utils::dict_state_reader::DictStateReader; use blockifier::test_utils::initial_test_state::test_state; -use blockifier::test_utils::{CairoVersion, BALANCE}; +use blockifier::test_utils::{BALANCE, CairoVersion}; use starknet_api::block::BlockNumber; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::state::StorageKey; @@ -75,11 +75,10 @@ pub fn local_test_state_reader_factory( let account_contract = FeatureContract::AccountWithoutValidations(cairo_version); let test_contract = FeatureContract::TestContract(cairo_version); - let state_reader = test_state( - block_context.chain_info(), - account_balance, - &[(account_contract, 1), (test_contract, 1)], - ); + let state_reader = test_state(block_context.chain_info(), account_balance, &[ + (account_contract, 1), + (test_contract, 1), + ]); TestStateReaderFactory { state_reader: TestStateReader { diff --git a/crates/gateway/src/stateful_transaction_validator_test.rs b/crates/gateway/src/stateful_transaction_validator_test.rs index afefb0ae9c..c1416ed790 100644 --- a/crates/gateway/src/stateful_transaction_validator_test.rs +++ b/crates/gateway/src/stateful_transaction_validator_test.rs @@ -8,12 +8,12 @@ use blockifier::test_utils::CairoVersion; use blockifier::transaction::errors::{TransactionFeeError, TransactionPreValidationError}; use mempool_test_utils::invoke_tx_args; use mempool_test_utils::starknet_api_test_utils::{ - deploy_account_tx, - external_invoke_tx, - invoke_tx, TEST_SENDER_ADDRESS, VALID_L1_GAS_MAX_AMOUNT, VALID_L1_GAS_MAX_PRICE_PER_UNIT, + deploy_account_tx, + external_invoke_tx, + invoke_tx, }; use mockall::predicate::eq; use num_bigint::BigUint; diff --git a/crates/gateway/src/stateless_transaction_validator.rs b/crates/gateway/src/stateless_transaction_validator.rs index b663bf5852..a90d97ff1b 100644 --- a/crates/gateway/src/stateless_transaction_validator.rs +++ b/crates/gateway/src/stateless_transaction_validator.rs @@ -8,7 +8,7 @@ use starknet_api::rpc_transaction::{ use starknet_api::state::EntryPoint; use starknet_api::transaction::Resource; use starknet_types_core::felt::Felt; -use tracing::{instrument, Level}; +use tracing::{Level, instrument}; use crate::compiler_version::VersionId; use crate::config::StatelessTransactionValidatorConfig; diff --git a/crates/gateway/src/stateless_transaction_validator_test.rs b/crates/gateway/src/stateless_transaction_validator_test.rs index 880706615e..bbbad7a263 100644 --- a/crates/gateway/src/stateless_transaction_validator_test.rs +++ b/crates/gateway/src/stateless_transaction_validator_test.rs @@ -4,12 +4,12 @@ use std::vec; use assert_matches::assert_matches; use mempool_test_utils::declare_tx_args; use mempool_test_utils::starknet_api_test_utils::{ + NON_EMPTY_RESOURCE_BOUNDS, + TransactionType, create_resource_bounds_mapping, external_declare_tx, rpc_tx_for_testing, zero_resource_bounds_mapping, - TransactionType, - NON_EMPTY_RESOURCE_BOUNDS, }; use rstest::rstest; use starknet_api::core::EntryPointSelector; diff --git a/crates/gateway/src/utils.rs b/crates/gateway/src/utils.rs index 1b8af37bb6..dcd6680810 100644 --- a/crates/gateway/src/utils.rs +++ b/crates/gateway/src/utils.rs @@ -5,7 +5,7 @@ use blockifier::transaction::transactions::{ DeployAccountTransaction as BlockifierDeployAccountTransaction, InvokeTransaction as BlockifierInvokeTransaction, }; -use starknet_api::core::{calculate_contract_address, ChainId, ClassHash, ContractAddress}; +use starknet_api::core::{ChainId, ClassHash, ContractAddress, calculate_contract_address}; use starknet_api::rpc_transaction::{ RpcDeclareTransaction, RpcDeployAccountTransaction, diff --git a/crates/mempool/src/mempool_test.rs b/crates/mempool/src/mempool_test.rs index 5e220056ec..39e463b4dd 100644 --- a/crates/mempool/src/mempool_test.rs +++ b/crates/mempool/src/mempool_test.rs @@ -624,14 +624,10 @@ fn test_add_tx_after_get_txs_fails_on_duplicate_nonce() { // Test. mempool.get_txs(1).unwrap(); - add_tx_expect_error( - &mut mempool, - &input_tx, - MempoolError::DuplicateNonce { - address: contract_address!("0x0"), - nonce: Nonce(felt!(0_u16)), - }, - ); + add_tx_expect_error(&mut mempool, &input_tx, MempoolError::DuplicateNonce { + address: contract_address!("0x0"), + nonce: Nonce(felt!(0_u16)), + }); } #[rstest] diff --git a/crates/mempool/src/transaction_pool.rs b/crates/mempool/src/transaction_pool.rs index 2e6ea52eb9..f6f535f331 100644 --- a/crates/mempool/src/transaction_pool.rs +++ b/crates/mempool/src/transaction_pool.rs @@ -1,4 +1,4 @@ -use std::collections::{hash_map, BTreeMap, HashMap}; +use std::collections::{BTreeMap, HashMap, hash_map}; use starknet_api::core::{ContractAddress, Nonce}; use starknet_api::executable_transaction::Transaction; diff --git a/crates/mempool_infra/src/component_client/local_component_client.rs b/crates/mempool_infra/src/component_client/local_component_client.rs index ce561bc3ac..071a5aec16 100644 --- a/crates/mempool_infra/src/component_client/local_component_client.rs +++ b/crates/mempool_infra/src/component_client/local_component_client.rs @@ -1,4 +1,4 @@ -use tokio::sync::mpsc::{channel, Sender}; +use tokio::sync::mpsc::{Sender, channel}; use crate::component_definitions::ComponentRequestAndResponseSender; diff --git a/crates/mempool_infra/src/component_client/remote_component_client.rs b/crates/mempool_infra/src/component_client/remote_component_client.rs index c7cc5f8121..ce7b9ceff6 100644 --- a/crates/mempool_infra/src/component_client/remote_component_client.rs +++ b/crates/mempool_infra/src/component_client/remote_component_client.rs @@ -6,8 +6,8 @@ use bincode::{deserialize, serialize}; use hyper::body::to_bytes; use hyper::header::CONTENT_TYPE; use hyper::{Body, Client, Request as HyperRequest, Response as HyperResponse, StatusCode, Uri}; -use serde::de::DeserializeOwned; use serde::Serialize; +use serde::de::DeserializeOwned; use super::definitions::{ClientError, ClientResult}; use crate::component_definitions::APPLICATION_OCTET_STREAM; diff --git a/crates/mempool_infra/src/component_definitions.rs b/crates/mempool_infra/src/component_definitions.rs index 5cd742a85f..9707e27584 100644 --- a/crates/mempool_infra/src/component_definitions.rs +++ b/crates/mempool_infra/src/component_definitions.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; use std::net::IpAddr; use async_trait::async_trait; -use papyrus_config::dumping::{ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/crates/mempool_infra/src/component_server/empty_component_server.rs b/crates/mempool_infra/src/component_server/empty_component_server.rs index 53b03b6bfd..3a316a9c58 100644 --- a/crates/mempool_infra/src/component_server/empty_component_server.rs +++ b/crates/mempool_infra/src/component_server/empty_component_server.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; -use super::definitions::{start_component, ComponentServerStarter}; +use super::definitions::{ComponentServerStarter, start_component}; use crate::component_runner::ComponentStarter; pub struct EmptyServer { diff --git a/crates/mempool_infra/src/component_server/local_component_server.rs b/crates/mempool_infra/src/component_server/local_component_server.rs index 51cd4941fa..80d741d910 100644 --- a/crates/mempool_infra/src/component_server/local_component_server.rs +++ b/crates/mempool_infra/src/component_server/local_component_server.rs @@ -2,7 +2,7 @@ use async_trait::async_trait; use tokio::sync::mpsc::Receiver; use tracing::error; -use super::definitions::{request_response_loop, start_component, ComponentServerStarter}; +use super::definitions::{ComponentServerStarter, request_response_loop, start_component}; use crate::component_definitions::{ComponentRequestAndResponseSender, ComponentRequestHandler}; use crate::component_runner::ComponentStarter; @@ -31,7 +31,7 @@ use crate::component_runner::ComponentStarter; /// # Example /// ```rust /// // Example usage of the LocalComponentServer -/// use std::sync::mpsc::{channel, Receiver}; +/// use std::sync::mpsc::{Receiver, channel}; /// /// use async_trait::async_trait; /// use starknet_mempool_infra::component_runner::{ComponentStartError, ComponentStarter}; diff --git a/crates/mempool_infra/src/component_server/remote_component_server.rs b/crates/mempool_infra/src/component_server/remote_component_server.rs index 70dc099d6e..e8efd420a9 100644 --- a/crates/mempool_infra/src/component_server/remote_component_server.rs +++ b/crates/mempool_infra/src/component_server/remote_component_server.rs @@ -8,15 +8,15 @@ use hyper::body::to_bytes; use hyper::header::CONTENT_TYPE; use hyper::service::{make_service_fn, service_fn}; use hyper::{Body, Request as HyperRequest, Response as HyperResponse, Server, StatusCode}; -use serde::de::DeserializeOwned; use serde::Serialize; +use serde::de::DeserializeOwned; use tokio::sync::Mutex; use super::definitions::ComponentServerStarter; use crate::component_definitions::{ + APPLICATION_OCTET_STREAM, ComponentRequestHandler, ServerError, - APPLICATION_OCTET_STREAM, }; /// The `RemoteComponentServer` struct is a generic server that handles requests and responses for a diff --git a/crates/mempool_infra/src/trace_util.rs b/crates/mempool_infra/src/trace_util.rs index 057af5b98e..4a57fef806 100644 --- a/crates/mempool_infra/src/trace_util.rs +++ b/crates/mempool_infra/src/trace_util.rs @@ -1,6 +1,6 @@ use tracing::metadata::LevelFilter; use tracing_subscriber::prelude::*; -use tracing_subscriber::{fmt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt}; const DEFAULT_LEVEL: LevelFilter = LevelFilter::INFO; diff --git a/crates/mempool_infra/tests/active_local_component_client_server_test.rs b/crates/mempool_infra/tests/active_local_component_client_server_test.rs index 4b30505bc5..374a261cbc 100644 --- a/crates/mempool_infra/tests/active_local_component_client_server_test.rs +++ b/crates/mempool_infra/tests/active_local_component_client_server_test.rs @@ -14,7 +14,7 @@ use starknet_mempool_infra::component_server::{ EmptyServer, LocalActiveComponentServer, }; -use tokio::sync::mpsc::{channel, Sender}; +use tokio::sync::mpsc::{Sender, channel}; use tokio::sync::{Barrier, Mutex}; use tokio::task; diff --git a/crates/mempool_infra/tests/local_component_client_server_test.rs b/crates/mempool_infra/tests/local_component_client_server_test.rs index 09ff93f0f7..389bd03e52 100644 --- a/crates/mempool_infra/tests/local_component_client_server_test.rs +++ b/crates/mempool_infra/tests/local_component_client_server_test.rs @@ -20,7 +20,7 @@ use starknet_mempool_infra::component_server::{ComponentServerStarter, LocalComp use tokio::sync::mpsc::channel; use tokio::task; -use crate::common::{test_a_b_functionality, ComponentA, ComponentB, ValueA, ValueB}; +use crate::common::{ComponentA, ComponentB, ValueA, ValueB, test_a_b_functionality}; type ComponentAClient = LocalComponentClient; type ComponentBClient = LocalComponentClient; diff --git a/crates/mempool_infra/tests/remote_component_client_server_test.rs b/crates/mempool_infra/tests/remote_component_client_server_test.rs index eea574cdf2..0c16b96366 100644 --- a/crates/mempool_infra/tests/remote_component_client_server_test.rs +++ b/crates/mempool_infra/tests/remote_component_client_server_test.rs @@ -24,9 +24,9 @@ use rstest::rstest; use serde::Serialize; use starknet_mempool_infra::component_client::{ClientError, ClientResult, RemoteComponentClient}; use starknet_mempool_infra::component_definitions::{ + APPLICATION_OCTET_STREAM, ComponentRequestHandler, ServerError, - APPLICATION_OCTET_STREAM, }; use starknet_mempool_infra::component_server::{ComponentServerStarter, RemoteComponentServer}; use tokio::sync::Mutex; @@ -35,7 +35,7 @@ use tokio::task; type ComponentAClient = RemoteComponentClient; type ComponentBClient = RemoteComponentClient; -use crate::common::{test_a_b_functionality, ComponentA, ComponentB, ValueB}; +use crate::common::{ComponentA, ComponentB, ValueB, test_a_b_functionality}; const LOCAL_IP: IpAddr = IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)); const MAX_RETRIES: usize = 0; diff --git a/crates/mempool_node/src/bin/mempool_dump_config.rs b/crates/mempool_node/src/bin/mempool_dump_config.rs index 9eaebbcb69..5475141e4f 100644 --- a/crates/mempool_node/src/bin/mempool_dump_config.rs +++ b/crates/mempool_node/src/bin/mempool_dump_config.rs @@ -1,5 +1,5 @@ use papyrus_config::dumping::SerializeConfig; -use starknet_mempool_node::config::{MempoolNodeConfig, DEFAULT_CONFIG_PATH}; +use starknet_mempool_node::config::{DEFAULT_CONFIG_PATH, MempoolNodeConfig}; /// Updates the default config file by: /// cargo run --bin mempool_dump_config -q diff --git a/crates/mempool_node/src/communication.rs b/crates/mempool_node/src/communication.rs index 34ef6cc65a..dcf10157fd 100644 --- a/crates/mempool_node/src/communication.rs +++ b/crates/mempool_node/src/communication.rs @@ -16,7 +16,7 @@ use starknet_mempool_types::communication::{ MempoolRequestAndResponseSender, SharedMempoolClient, }; -use tokio::sync::mpsc::{channel, Receiver, Sender}; +use tokio::sync::mpsc::{Receiver, Sender, channel}; use crate::config::MempoolNodeConfig; diff --git a/crates/mempool_node/src/components.rs b/crates/mempool_node/src/components.rs index ba7c822327..f6827c5b30 100644 --- a/crates/mempool_node/src/components.rs +++ b/crates/mempool_node/src/components.rs @@ -1,6 +1,6 @@ -use starknet_batcher::batcher::{create_batcher, Batcher}; +use starknet_batcher::batcher::{Batcher, create_batcher}; use starknet_consensus_manager::consensus_manager::ConsensusManager; -use starknet_gateway::gateway::{create_gateway, Gateway}; +use starknet_gateway::gateway::{Gateway, create_gateway}; use starknet_mempool::mempool::Mempool; use crate::communication::MempoolNodeClients; diff --git a/crates/mempool_node/src/config/config_test.rs b/crates/mempool_node/src/config/config_test.rs index 70919b0f26..e5188377a2 100644 --- a/crates/mempool_node/src/config/config_test.rs +++ b/crates/mempool_node/src/config/config_test.rs @@ -17,9 +17,9 @@ use validator::{Validate, ValidationErrors}; use crate::config::{ ComponentConfig, ComponentExecutionConfig, + DEFAULT_CONFIG_PATH, LocationType, MempoolNodeConfig, - DEFAULT_CONFIG_PATH, }; fn check_validation_error( diff --git a/crates/mempool_node/src/config/mod.rs b/crates/mempool_node/src/config/mod.rs index 9f7ff51809..ad5ca6e7c9 100644 --- a/crates/mempool_node/src/config/mod.rs +++ b/crates/mempool_node/src/config/mod.rs @@ -7,10 +7,10 @@ use std::path::Path; use clap::Command; use papyrus_config::dumping::{ + SerializeConfig, append_sub_config_name, ser_optional_sub_config, ser_param, - SerializeConfig, }; use papyrus_config::loading::load_and_process_config; use papyrus_config::{ConfigError, ParamPath, ParamPrivacyInput, SerializedParam}; diff --git a/crates/mempool_node/src/main.rs b/crates/mempool_node/src/main.rs index 7ab874fd80..fce2ad8b8c 100644 --- a/crates/mempool_node/src/main.rs +++ b/crates/mempool_node/src/main.rs @@ -1,8 +1,8 @@ use std::env::args; use std::process::exit; -use papyrus_config::validators::config_validate; use papyrus_config::ConfigError; +use papyrus_config::validators::config_validate; use starknet_mempool_infra::trace_util::configure_tracing; use starknet_mempool_node::config::MempoolNodeConfig; use starknet_mempool_node::servers::run_component_servers; diff --git a/crates/mempool_node/src/servers.rs b/crates/mempool_node/src/servers.rs index 220534b431..1da3020c36 100644 --- a/crates/mempool_node/src/servers.rs +++ b/crates/mempool_node/src/servers.rs @@ -2,13 +2,13 @@ use std::future::pending; use std::pin::Pin; use futures::{Future, FutureExt}; -use starknet_batcher::communication::{create_local_batcher_server, LocalBatcherServer}; +use starknet_batcher::communication::{LocalBatcherServer, create_local_batcher_server}; use starknet_consensus_manager::communication::{ - create_local_consensus_manager_server, LocalConsensusManagerServer, + create_local_consensus_manager_server, }; -use starknet_gateway::communication::{create_gateway_server, GatewayServer}; -use starknet_mempool::communication::{create_mempool_server, MempoolServer}; +use starknet_gateway::communication::{GatewayServer, create_gateway_server}; +use starknet_mempool::communication::{MempoolServer, create_mempool_server}; use starknet_mempool_infra::component_server::ComponentServerStarter; use tracing::error; diff --git a/crates/mempool_node/src/utils.rs b/crates/mempool_node/src/utils.rs index 6cece8bae5..771b10981d 100644 --- a/crates/mempool_node/src/utils.rs +++ b/crates/mempool_node/src/utils.rs @@ -1,7 +1,7 @@ -use crate::communication::{create_node_channels, create_node_clients, MempoolNodeClients}; +use crate::communication::{MempoolNodeClients, create_node_channels, create_node_clients}; use crate::components::create_components; use crate::config::MempoolNodeConfig; -use crate::servers::{create_servers, Servers}; +use crate::servers::{Servers, create_servers}; pub fn create_clients_servers_from_config( config: &MempoolNodeConfig, diff --git a/crates/mempool_test_utils/src/starknet_api_test_utils.rs b/crates/mempool_test_utils/src/starknet_api_test_utils.rs index 1688bc4111..7e57fb8c2e 100644 --- a/crates/mempool_test_utils/src/starknet_api_test_utils.rs +++ b/crates/mempool_test_utils/src/starknet_api_test_utils.rs @@ -7,7 +7,7 @@ use std::rc::Rc; use std::sync::OnceLock; use blockifier::test_utils::contracts::FeatureContract; -use blockifier::test_utils::{create_trivial_calldata, CairoVersion, NonceManager}; +use blockifier::test_utils::{CairoVersion, NonceManager, create_trivial_calldata}; use serde_json::to_string_pretty; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; @@ -36,13 +36,13 @@ use starknet_api::{calldata, felt}; use starknet_types_core::felt::Felt; use crate::{ + COMPILED_CLASS_HASH_OF_CONTRACT_CLASS, + CONTRACT_CLASS_FILE, + TEST_FILES_FOLDER, declare_tx_args, deploy_account_tx_args, get_absolute_path, invoke_tx_args, - COMPILED_CLASS_HASH_OF_CONTRACT_CLASS, - CONTRACT_CLASS_FILE, - TEST_FILES_FOLDER, }; pub const VALID_L1_GAS_MAX_AMOUNT: u64 = 203484; @@ -222,14 +222,11 @@ impl MultiAccountTransactionGenerator { let nonce_manager = SharedNonceManager::default(); for (account_id, account) in accounts.into_iter().enumerate() { let n_current_contract = account_type_to_n_instances.entry(account).or_insert(0); - account_contracts.insert( - account_id, - AccountTransactionGenerator { - account, - contract_instance_id: *n_current_contract, - nonce_manager: nonce_manager.clone(), - }, - ); + account_contracts.insert(account_id, AccountTransactionGenerator { + account, + contract_instance_id: *n_current_contract, + nonce_manager: nonce_manager.clone(), + }); *n_current_contract += 1; } diff --git a/crates/native_blockifier/src/lib.rs b/crates/native_blockifier/src/lib.rs index 8ce52197ed..4d00debf31 100644 --- a/crates/native_blockifier/src/lib.rs +++ b/crates/native_blockifier/src/lib.rs @@ -20,7 +20,7 @@ pub mod state_readers; pub mod storage; pub mod test_utils; -use errors::{add_py_exceptions, UndeclaredClassHashError}; +use errors::{UndeclaredClassHashError, add_py_exceptions}; use py_block_executor::PyBlockExecutor; use py_objects::PyExecutionResources; use py_validator::PyValidator; diff --git a/crates/native_blockifier/src/py_block_executor.rs b/crates/native_blockifier/src/py_block_executor.rs index eb4832282e..421a60abe0 100644 --- a/crates/native_blockifier/src/py_block_executor.rs +++ b/crates/native_blockifier/src/py_block_executor.rs @@ -23,8 +23,8 @@ use starknet_types_core::felt::Felt; use crate::errors::{NativeBlockifierError, NativeBlockifierResult}; use crate::py_objects::{PyBouncerConfig, PyConcurrencyConfig, PyVersionedConstantsOverrides}; use crate::py_state_diff::{PyBlockInfo, PyStateDiff}; -use crate::py_transaction::{py_tx, PyClassInfo, PY_TX_PARSING_ERR}; -use crate::py_utils::{int_to_chain_id, into_block_number_hash_pair, PyFelt}; +use crate::py_transaction::{PY_TX_PARSING_ERR, PyClassInfo, py_tx}; +use crate::py_utils::{PyFelt, int_to_chain_id, into_block_number_hash_pair}; use crate::state_readers::papyrus_state::PapyrusReader; use crate::storage::{PapyrusStorage, Storage, StorageConfig}; diff --git a/crates/native_blockifier/src/py_declare.rs b/crates/native_blockifier/src/py_declare.rs index 9e01caaaaf..0c975e78c6 100644 --- a/crates/native_blockifier/src/py_declare.rs +++ b/crates/native_blockifier/src/py_declare.rs @@ -21,7 +21,7 @@ use starknet_types_core::felt::Felt; use crate::errors::{NativeBlockifierInputError, NativeBlockifierResult}; use crate::py_transaction::{PyClassInfo, PyDataAvailabilityMode, PyResourceBoundsMapping}; -use crate::py_utils::{from_py_felts, py_attr, PyFelt}; +use crate::py_utils::{PyFelt, from_py_felts, py_attr}; #[derive(FromPyObject)] struct PyDeclareTransactionV0V1 { diff --git a/crates/native_blockifier/src/py_deploy_account.rs b/crates/native_blockifier/src/py_deploy_account.rs index a5671842a0..5c1b0e9004 100644 --- a/crates/native_blockifier/src/py_deploy_account.rs +++ b/crates/native_blockifier/src/py_deploy_account.rs @@ -21,7 +21,7 @@ use starknet_types_core::felt::Felt; use crate::errors::{NativeBlockifierInputError, NativeBlockifierResult}; use crate::py_transaction::{PyDataAvailabilityMode, PyResourceBoundsMapping}; -use crate::py_utils::{from_py_felts, py_attr, PyFelt}; +use crate::py_utils::{PyFelt, from_py_felts, py_attr}; #[derive(FromPyObject)] struct PyDeployAccountTransactionV1 { diff --git a/crates/native_blockifier/src/py_invoke_function.rs b/crates/native_blockifier/src/py_invoke_function.rs index 64f7559917..70393c0182 100644 --- a/crates/native_blockifier/src/py_invoke_function.rs +++ b/crates/native_blockifier/src/py_invoke_function.rs @@ -23,7 +23,7 @@ use starknet_types_core::felt::Felt; use crate::errors::{NativeBlockifierInputError, NativeBlockifierResult}; use crate::py_transaction::{PyDataAvailabilityMode, PyResourceBoundsMapping}; -use crate::py_utils::{from_py_felts, py_attr, PyFelt}; +use crate::py_utils::{PyFelt, from_py_felts, py_attr}; #[derive(FromPyObject)] struct PyInvokeTransactionV0 { diff --git a/crates/native_blockifier/src/py_l1_handler.rs b/crates/native_blockifier/src/py_l1_handler.rs index 3c72eb7508..7a1a1bbd46 100644 --- a/crates/native_blockifier/src/py_l1_handler.rs +++ b/crates/native_blockifier/src/py_l1_handler.rs @@ -7,7 +7,7 @@ use starknet_api::core::{ContractAddress, EntryPointSelector, Nonce}; use starknet_api::transaction::{Calldata, Fee, TransactionHash}; use crate::errors::{NativeBlockifierInputError, NativeBlockifierResult}; -use crate::py_utils::{from_py_felts, py_attr, PyFelt}; +use crate::py_utils::{PyFelt, from_py_felts, py_attr}; #[derive(FromPyObject)] struct PyL1HandlerTransaction { diff --git a/crates/native_blockifier/src/py_state_diff.rs b/crates/native_blockifier/src/py_state_diff.rs index fb71058e88..d937527b88 100644 --- a/crates/native_blockifier/src/py_state_diff.rs +++ b/crates/native_blockifier/src/py_state_diff.rs @@ -11,8 +11,8 @@ use blockifier::test_utils::{ }; use blockifier::versioned_constants::VersionedConstants; use indexmap::IndexMap; -use pyo3::prelude::*; use pyo3::FromPyObject; +use pyo3::prelude::*; use starknet_api::block::{BlockNumber, BlockTimestamp}; use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_api::state::{StateDiff, StorageKey}; diff --git a/crates/native_blockifier/src/py_testing_wrappers.rs b/crates/native_blockifier/src/py_testing_wrappers.rs index f0d9f607e0..2ddc8eeef3 100644 --- a/crates/native_blockifier/src/py_testing_wrappers.rs +++ b/crates/native_blockifier/src/py_testing_wrappers.rs @@ -1,7 +1,7 @@ use blockifier::execution::contract_class::estimate_casm_hash_computation_resources; use blockifier::transaction::errors::{TransactionExecutionError, TransactionFeeError}; use cairo_lang_starknet_classes::NestedIntList; -use pyo3::{pyfunction, PyResult}; +use pyo3::{PyResult, pyfunction}; use crate::errors::NativeBlockifierResult; use crate::py_objects::PyExecutionResources; diff --git a/crates/native_blockifier/src/py_transaction.rs b/crates/native_blockifier/src/py_transaction.rs index 443ed57c90..b75eff3301 100644 --- a/crates/native_blockifier/src/py_transaction.rs +++ b/crates/native_blockifier/src/py_transaction.rs @@ -11,8 +11,8 @@ use blockifier::transaction::transaction_execution::Transaction; use blockifier::transaction::transaction_types::TransactionType; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; -use starknet_api::transaction::{Resource, ResourceBounds}; use starknet_api::StarknetApiError; +use starknet_api::transaction::{Resource, ResourceBounds}; use crate::errors::{NativeBlockifierInputError, NativeBlockifierResult}; use crate::py_declare::py_declare; diff --git a/crates/native_blockifier/src/py_validator.rs b/crates/native_blockifier/src/py_validator.rs index e035f0c4ef..3cd94c207f 100644 --- a/crates/native_blockifier/src/py_validator.rs +++ b/crates/native_blockifier/src/py_validator.rs @@ -6,7 +6,7 @@ use blockifier::transaction::account_transaction::AccountTransaction; use blockifier::transaction::objects::TransactionInfoCreator; use blockifier::transaction::transaction_types::TransactionType; use blockifier::versioned_constants::VersionedConstants; -use pyo3::{pyclass, pymethods, PyAny}; +use pyo3::{PyAny, pyclass, pymethods}; use starknet_api::core::Nonce; use starknet_api::transaction::TransactionHash; use starknet_types_core::felt::Felt; @@ -15,7 +15,7 @@ use crate::errors::NativeBlockifierResult; use crate::py_block_executor::PyOsConfig; use crate::py_objects::PyVersionedConstantsOverrides; use crate::py_state_diff::PyBlockInfo; -use crate::py_transaction::{py_account_tx, PyClassInfo, PY_TX_PARSING_ERR}; +use crate::py_transaction::{PY_TX_PARSING_ERR, PyClassInfo, py_account_tx}; use crate::py_utils::PyFelt; use crate::state_readers::py_state_reader::PyStateReader; diff --git a/crates/native_blockifier/src/state_readers/papyrus_state.rs b/crates/native_blockifier/src/state_readers/papyrus_state.rs index 463d242b0c..535b2fd92e 100644 --- a/crates/native_blockifier/src/state_readers/papyrus_state.rs +++ b/crates/native_blockifier/src/state_readers/papyrus_state.rs @@ -2,10 +2,10 @@ use blockifier::execution::contract_class::{ContractClass, ContractClassV0, Cont use blockifier::state::errors::StateError; use blockifier::state::global_cache::GlobalContractCache; use blockifier::state::state_api::{StateReader, StateResult}; +use papyrus_storage::StorageReader; use papyrus_storage::compiled_class::CasmStorageReader; use papyrus_storage::db::RO; use papyrus_storage::state::StateStorageReader; -use papyrus_storage::StorageReader; use starknet_api::block::BlockNumber; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::state::{StateNumber, StorageKey}; diff --git a/crates/native_blockifier/src/state_readers/papyrus_state_test.rs b/crates/native_blockifier/src/state_readers/papyrus_state_test.rs index e999276084..73c94114ee 100644 --- a/crates/native_blockifier/src/state_readers/papyrus_state_test.rs +++ b/crates/native_blockifier/src/state_readers/papyrus_state_test.rs @@ -5,10 +5,10 @@ use blockifier::execution::call_info::{CallExecution, Retdata}; use blockifier::execution::entry_point::CallEntryPoint; use blockifier::retdata; use blockifier::state::cached_state::CachedState; -use blockifier::state::global_cache::{GlobalContractCache, GLOBAL_CONTRACT_CACHE_SIZE_FOR_TEST}; +use blockifier::state::global_cache::{GLOBAL_CONTRACT_CACHE_SIZE_FOR_TEST, GlobalContractCache}; use blockifier::state::state_api::StateReader; use blockifier::test_utils::contracts::FeatureContract; -use blockifier::test_utils::{trivial_external_entry_point_new, CairoVersion}; +use blockifier::test_utils::{CairoVersion, trivial_external_entry_point_new}; use indexmap::IndexMap; use papyrus_storage::class::ClassStorageWriter; use papyrus_storage::state::StateStorageWriter; diff --git a/crates/native_blockifier/src/storage.rs b/crates/native_blockifier/src/storage.rs index d08a4b6383..6e9ed4fb14 100644 --- a/crates/native_blockifier/src/storage.rs +++ b/crates/native_blockifier/src/storage.rs @@ -15,10 +15,10 @@ use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContract use starknet_api::hash::StarkHash; use starknet_api::state::{ContractClass, StateDiff, StateNumber, ThinStateDiff}; +use crate::PyStateDiff; use crate::errors::NativeBlockifierResult; use crate::py_state_diff::PyBlockInfo; -use crate::py_utils::{int_to_chain_id, PyFelt}; -use crate::PyStateDiff; +use crate::py_utils::{PyFelt, int_to_chain_id}; const GENESIS_BLOCK_ID: u64 = u64::MAX; diff --git a/crates/papyrus_base_layer/src/base_layer_test.rs b/crates/papyrus_base_layer/src/base_layer_test.rs index bd61e08dfd..3a641f25bd 100644 --- a/crates/papyrus_base_layer/src/base_layer_test.rs +++ b/crates/papyrus_base_layer/src/base_layer_test.rs @@ -6,10 +6,10 @@ use pretty_assertions::assert_eq; use starknet_api::block::{BlockHash, BlockNumber}; use starknet_api::felt; use tar::Archive; -use tempfile::{tempdir, TempDir}; +use tempfile::{TempDir, tempdir}; -use crate::ethereum_base_layer_contract::{EthereumBaseLayerConfig, EthereumBaseLayerContract}; use crate::BaseLayerContract; +use crate::ethereum_base_layer_contract::{EthereumBaseLayerConfig, EthereumBaseLayerContract}; type EthereumContractAddress = String; type TestEthereumNodeHandle = (GanacheInstance, TempDir); diff --git a/crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs b/crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs index ed902849ee..e217b5ad0f 100644 --- a/crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs +++ b/crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs @@ -7,12 +7,12 @@ use ethers::contract::Contract; use ethers::prelude::{AbiError, Address, ContractError, Http, Middleware, Provider}; use ethers::providers::ProviderError; use ethers::types::{I256, U256}; -use papyrus_config::dumping::{ser_param, ser_required_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, ser_param, ser_required_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializationType, SerializedParam}; use serde::{Deserialize, Serialize}; +use starknet_api::StarknetApiError; use starknet_api::block::{BlockHash, BlockNumber}; use starknet_api::hash::StarkHash; -use starknet_api::StarknetApiError; use url::ParseError; use crate::BaseLayerContract; diff --git a/crates/papyrus_common/src/block_hash.rs b/crates/papyrus_common/src/block_hash.rs index eaee133485..c1c7a2836b 100644 --- a/crates/papyrus_common/src/block_hash.rs +++ b/crates/papyrus_common/src/block_hash.rs @@ -4,6 +4,7 @@ mod block_hash_test; use std::iter::zip; +use starknet_api::StarknetApiError; use starknet_api::block::{BlockBody, BlockHash, BlockHeader}; use starknet_api::core::{ ChainId, @@ -20,11 +21,10 @@ use starknet_api::transaction::{ TransactionHash, TransactionOutput, }; -use starknet_api::StarknetApiError; use starknet_types_core::felt::Felt; use starknet_types_core::hash::{Pedersen, StarkHash as CoreStarkHash}; -use crate::transaction_hash::{ascii_as_felt, HashChain, ZERO}; +use crate::transaction_hash::{HashChain, ZERO, ascii_as_felt}; use crate::usize_into_felt; #[derive(Debug, thiserror::Error)] diff --git a/crates/papyrus_common/src/block_hash_test.rs b/crates/papyrus_common/src/block_hash_test.rs index 6ab92e63aa..ed1cd569ff 100644 --- a/crates/papyrus_common/src/block_hash_test.rs +++ b/crates/papyrus_common/src/block_hash_test.rs @@ -4,11 +4,11 @@ use starknet_api::block::Block; use starknet_api::core::ChainId; use crate::block_hash::{ + BlockHashError, + BlockHashVersion, calculate_block_hash_by_version, calculate_event_commitment_by_version, calculate_transaction_commitment_by_version, - BlockHashError, - BlockHashVersion, }; fn validate_block_hash_util(file_name: &str, version: BlockHashVersion) { diff --git a/crates/papyrus_common/src/state_diff_commitment_test.rs b/crates/papyrus_common/src/state_diff_commitment_test.rs index c49142367f..ce51bd41fc 100644 --- a/crates/papyrus_common/src/state_diff_commitment_test.rs +++ b/crates/papyrus_common/src/state_diff_commitment_test.rs @@ -11,7 +11,7 @@ use starknet_api::hash::PoseidonHash; use starknet_api::state::{StateDiff, StorageKey, ThinStateDiff}; use starknet_api::{class_hash, contract_address, felt, patricia_key}; -use crate::state_diff_commitment::{calculate_state_diff_commitment, StateDiffVersion}; +use crate::state_diff_commitment::{StateDiffVersion, calculate_state_diff_commitment}; #[test] fn state_diff_commitment() { diff --git a/crates/papyrus_common/src/transaction_hash.rs b/crates/papyrus_common/src/transaction_hash.rs index 6b4da55441..bca4343aab 100644 --- a/crates/papyrus_common/src/transaction_hash.rs +++ b/crates/papyrus_common/src/transaction_hash.rs @@ -3,8 +3,9 @@ mod transaction_hash_test; use lazy_static::lazy_static; +use starknet_api::StarknetApiError; use starknet_api::block::BlockNumber; -use starknet_api::core::{calculate_contract_address, ChainId, ContractAddress}; +use starknet_api::core::{ChainId, ContractAddress, calculate_contract_address}; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::hash::StarkHash; use starknet_api::transaction::{ @@ -29,7 +30,6 @@ use starknet_api::transaction::{ TransactionHash, TransactionVersion, }; -use starknet_api::StarknetApiError; use starknet_types_core::felt::Felt; use starknet_types_core::hash::{Pedersen, Poseidon, StarkHash as CoreStarkHash}; diff --git a/crates/papyrus_common/src/transaction_hash_test.rs b/crates/papyrus_common/src/transaction_hash_test.rs index c79cd6f03b..aec78200cd 100644 --- a/crates/papyrus_common/src/transaction_hash_test.rs +++ b/crates/papyrus_common/src/transaction_hash_test.rs @@ -8,10 +8,10 @@ use starknet_api::transaction::{Transaction, TransactionHash}; use starknet_types_core::felt::Felt; use super::{ + CONSTRUCTOR_ENTRY_POINT_SELECTOR, ascii_as_felt, get_transaction_hash, validate_transaction_hash, - CONSTRUCTOR_ENTRY_POINT_SELECTOR, }; use crate::TransactionOptions; diff --git a/crates/papyrus_config/src/command.rs b/crates/papyrus_config/src/command.rs index f21d1e9bee..ccc5ed875f 100644 --- a/crates/papyrus_config/src/command.rs +++ b/crates/papyrus_config/src/command.rs @@ -1,8 +1,8 @@ use std::collections::BTreeMap; use std::path::PathBuf; -use clap::{value_parser, Arg, ArgMatches, Command}; -use serde_json::{json, Value}; +use clap::{Arg, ArgMatches, Command, value_parser}; +use serde_json::{Value, json}; use crate::loading::update_config_map; use crate::{ConfigError, ParamPath, SerializationType, SerializedParam}; diff --git a/crates/papyrus_config/src/config_test.rs b/crates/papyrus_config/src/config_test.rs index 52b40126fb..ff6bc7da99 100644 --- a/crates/papyrus_config/src/config_test.rs +++ b/crates/papyrus_config/src/config_test.rs @@ -17,6 +17,7 @@ use validator::Validate; use crate::command::{get_command_matches, update_config_map_by_command_args}; use crate::converters::deserialize_milliseconds_to_duration; use crate::dumping::{ + SerializeConfig, append_sub_config_name, combine_config_map_and_pointers, ser_generated_param, @@ -25,7 +26,6 @@ use crate::dumping::{ ser_param, ser_pointer_target_param, ser_required_param, - SerializeConfig, }; use crate::loading::{ load, @@ -254,10 +254,11 @@ fn test_pointers_flow() { ser_param("a1", &json!(5), "This is a.", ParamPrivacyInput::Public), ser_param("a2", &json!(5), "This is a.", ParamPrivacyInput::Private), ]); - let pointers = vec![( - ser_pointer_target_param("common_a", &json!(10), "This is common a"), - vec!["a1".to_owned(), "a2".to_owned()], - )]; + let pointers = + vec![(ser_pointer_target_param("common_a", &json!(10), "This is common a"), vec![ + "a1".to_owned(), + "a2".to_owned(), + ])]; let stored_map = combine_config_map_and_pointers(config_map, &pointers).unwrap(); assert_eq!( stored_map["a1"], @@ -543,10 +544,10 @@ fn deeply_nested_optionals() { vec!["Testing".to_owned(), "--level1.#is_none".to_owned(), "false".to_owned()], ) .unwrap(); - assert_eq!( - l1, - Level0 { level0_value: 1, level1: Some(Level1 { level1_value: 0, level2: None }) } - ); + assert_eq!(l1, Level0 { + level0_value: 1, + level1: Some(Level1 { level1_value: 0, level2: None }) + }); let l2 = load_and_process_config::( File::open(file_path.clone()).unwrap(), @@ -560,13 +561,10 @@ fn deeply_nested_optionals() { ], ) .unwrap(); - assert_eq!( - l2, - Level0 { - level0_value: 1, - level1: Some(Level1 { level1_value: 0, level2: Some(Level2 { level2_value: None }) }), - } - ); + assert_eq!(l2, Level0 { + level0_value: 1, + level1: Some(Level1 { level1_value: 0, level2: Some(Level2 { level2_value: None }) }), + }); let l2_value = load_and_process_config::( File::open(file_path).unwrap(), @@ -582,14 +580,8 @@ fn deeply_nested_optionals() { ], ) .unwrap(); - assert_eq!( - l2_value, - Level0 { - level0_value: 1, - level1: Some(Level1 { - level1_value: 0, - level2: Some(Level2 { level2_value: Some(1) }), - }), - } - ); + assert_eq!(l2_value, Level0 { + level0_value: 1, + level1: Some(Level1 { level1_value: 0, level2: Some(Level2 { level2_value: Some(1) }) }), + }); } diff --git a/crates/papyrus_config/src/dumping.rs b/crates/papyrus_config/src/dumping.rs index f744b415d8..ea933415fa 100644 --- a/crates/papyrus_config/src/dumping.rs +++ b/crates/papyrus_config/src/dumping.rs @@ -40,17 +40,17 @@ use std::io::{BufWriter, Write}; use itertools::chain; use serde::Serialize; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use crate::{ ConfigError, + IS_NONE_MARK, ParamPath, ParamPrivacy, ParamPrivacyInput, SerializationType, SerializedContent, SerializedParam, - IS_NONE_MARK, }; /// Serialization for configs. @@ -279,14 +279,11 @@ pub(crate) fn combine_config_map_and_pointers( config_map.get(pointing_param).ok_or(ConfigError::PointerSourceNotFound { pointing_param: pointing_param.to_owned(), })?; - config_map.insert( - pointing_param.to_owned(), - SerializedParam { - description: pointing_serialized_param.description.clone(), - content: SerializedContent::PointerTarget(target_param.to_owned()), - privacy: pointing_serialized_param.privacy.clone(), - }, - ); + config_map.insert(pointing_param.to_owned(), SerializedParam { + description: pointing_serialized_param.description.clone(), + content: SerializedContent::PointerTarget(target_param.to_owned()), + privacy: pointing_serialized_param.privacy.clone(), + }); } } Ok(json!(config_map)) diff --git a/crates/papyrus_config/src/lib.rs b/crates/papyrus_config/src/lib.rs index 75705d8890..1a48c8a33e 100644 --- a/crates/papyrus_config/src/lib.rs +++ b/crates/papyrus_config/src/lib.rs @@ -12,7 +12,7 @@ //! use std::path::Path; //! //! use clap::Command; -//! use papyrus_config::dumping::{ser_param, SerializeConfig}; +//! use papyrus_config::dumping::{SerializeConfig, ser_param}; //! use papyrus_config::loading::load_and_process_config; //! use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; //! use serde::{Deserialize, Serialize}; @@ -38,12 +38,13 @@ //! let file_path = dir.path().join("config.json"); //! ConfigExample { key: 42 }.dump_to_file(&vec![], file_path.to_str().unwrap()); //! let file = File::open(file_path).unwrap(); -//! let loaded_config = load_and_process_config::( -//! file, -//! Command::new("Program"), -//! vec!["Program".to_owned(), "--key".to_owned(), "770".to_owned()], -//! ) -//! .unwrap(); +//! let loaded_config = +//! load_and_process_config::(file, Command::new("Program"), vec![ +//! "Program".to_owned(), +//! "--key".to_owned(), +//! "770".to_owned(), +//! ]) +//! .unwrap(); //! assert_eq!(loaded_config.key, 770); //! ``` diff --git a/crates/papyrus_config/src/loading.rs b/crates/papyrus_config/src/loading.rs index 50df585217..632441850a 100644 --- a/crates/papyrus_config/src/loading.rs +++ b/crates/papyrus_config/src/loading.rs @@ -9,22 +9,22 @@ use std::fs::File; use std::ops::IndexMut; use std::path::PathBuf; -use clap::parser::Values; use clap::Command; +use clap::parser::Values; use command::{get_command_matches, update_config_map_by_command_args}; use itertools::any; use serde::Deserialize; -use serde_json::{json, Map, Value}; +use serde_json::{Map, Value, json}; use crate::validators::validate_path_exists; use crate::{ - command, ConfigError, + IS_NONE_MARK, ParamPath, SerializationType, SerializedContent, SerializedParam, - IS_NONE_MARK, + command, }; /// Deserializes config from flatten JSON. diff --git a/crates/papyrus_execution/src/execution_test.rs b/crates/papyrus_execution/src/execution_test.rs index 4862e02ff0..ac6f48b6ba 100644 --- a/crates/papyrus_execution/src/execution_test.rs +++ b/crates/papyrus_execution/src/execution_test.rs @@ -38,9 +38,6 @@ use crate::objects::{ TransactionTrace, }; use crate::test_utils::{ - execute_simulate_transactions, - prepare_storage, - TxsScenarioBuilder, ACCOUNT_ADDRESS, ACCOUNT_CLASS_HASH, ACCOUNT_INITIAL_BALANCE, @@ -51,16 +48,19 @@ use crate::test_utils::{ NEW_ACCOUNT_ADDRESS, SEQUENCER_ADDRESS, TEST_ERC20_CONTRACT_ADDRESS, + TxsScenarioBuilder, + execute_simulate_transactions, + prepare_storage, }; use crate::testing_instances::get_test_execution_config; use crate::{ - estimate_fee, - execute_call, - get_versioned_constants, ExecutableTransactionInput, ExecutionError, FeeEstimationResult, RevertedTransaction, + estimate_fee, + execute_call, + get_versioned_constants, }; // Test calling entry points of a deprecated class. @@ -298,38 +298,29 @@ fn simulate_invoke() { let TransactionTrace::Invoke(exec_only_trace) = &exec_only.transaction_trace else { panic!("Wrong trace type, expected InvokeTransactionTrace.") }; - assert_matches!( - exec_only_trace, - InvokeTransactionTrace { - validate_invocation: None, - execute_invocation: FunctionInvocationResult::Ok(_), - fee_transfer_invocation: None, - } - ); + assert_matches!(exec_only_trace, InvokeTransactionTrace { + validate_invocation: None, + execute_invocation: FunctionInvocationResult::Ok(_), + fee_transfer_invocation: None, + }); let TransactionTrace::Invoke(validate_trace) = &validate.transaction_trace else { panic!("Wrong trace type, expected InvokeTransactionTrace.") }; - assert_matches!( - validate_trace, - InvokeTransactionTrace { - validate_invocation: Some(_), - execute_invocation: FunctionInvocationResult::Ok(_), - fee_transfer_invocation: None, - } - ); + assert_matches!(validate_trace, InvokeTransactionTrace { + validate_invocation: Some(_), + execute_invocation: FunctionInvocationResult::Ok(_), + fee_transfer_invocation: None, + }); let TransactionTrace::Invoke(charge_fee_trace) = &charge_fee.transaction_trace else { panic!("Wrong trace type, expected InvokeTransactionTrace.") }; - assert_matches!( - charge_fee_trace, - InvokeTransactionTrace { - validate_invocation: None, - execute_invocation: FunctionInvocationResult::Ok(_), - fee_transfer_invocation: Some(_), - } - ); + assert_matches!(charge_fee_trace, InvokeTransactionTrace { + validate_invocation: None, + execute_invocation: FunctionInvocationResult::Ok(_), + fee_transfer_invocation: Some(_), + }); assert_eq!(charge_fee.fee_estimation.gas_price, GAS_PRICE.price_in_wei); assert_eq!(exec_only_trace.execute_invocation, charge_fee_trace.execute_invocation); @@ -339,14 +330,11 @@ fn simulate_invoke() { else { panic!("Wrong trace type, expected InvokeTransactionTrace.") }; - assert_matches!( - charge_fee_validate_trace, - InvokeTransactionTrace { - validate_invocation: Some(_), - execute_invocation: FunctionInvocationResult::Ok(_), - fee_transfer_invocation: Some(_), - } - ); + assert_matches!(charge_fee_validate_trace, InvokeTransactionTrace { + validate_invocation: Some(_), + execute_invocation: FunctionInvocationResult::Ok(_), + fee_transfer_invocation: Some(_), + }); // TODO(yair): Compare the trace to an expected trace. } @@ -375,39 +363,36 @@ fn simulate_declare_deprecated() { let TransactionTrace::Declare(exec_only_trace) = &exec_only.transaction_trace else { panic!("Wrong trace type, expected DeclareTransactionTrace.") }; - assert_matches!( - exec_only_trace, - DeclareTransactionTrace { validate_invocation: None, fee_transfer_invocation: None } - ); + assert_matches!(exec_only_trace, DeclareTransactionTrace { + validate_invocation: None, + fee_transfer_invocation: None + }); let TransactionTrace::Declare(validate_trace) = &validate.transaction_trace else { panic!("Wrong trace type, expected DeclareTransactionTrace.") }; - assert_matches!( - validate_trace, - DeclareTransactionTrace { validate_invocation: Some(_), fee_transfer_invocation: None } - ); + assert_matches!(validate_trace, DeclareTransactionTrace { + validate_invocation: Some(_), + fee_transfer_invocation: None + }); let TransactionTrace::Declare(charge_fee_trace) = &charge_fee.transaction_trace else { panic!("Wrong trace type, expected DeclareTransactionTrace.") }; - assert_matches!( - charge_fee_trace, - DeclareTransactionTrace { validate_invocation: None, fee_transfer_invocation: Some(_) } - ); + assert_matches!(charge_fee_trace, DeclareTransactionTrace { + validate_invocation: None, + fee_transfer_invocation: Some(_) + }); let TransactionTrace::Declare(charge_fee_validate_trace) = &charge_fee_validate.transaction_trace else { panic!("Wrong trace type, expected DeclareTransactionTrace.") }; - assert_matches!( - charge_fee_validate_trace, - DeclareTransactionTrace { - validate_invocation: Some(_), - fee_transfer_invocation: Some(_), - } - ); + assert_matches!(charge_fee_validate_trace, DeclareTransactionTrace { + validate_invocation: Some(_), + fee_transfer_invocation: Some(_), + }); // TODO(yair): Compare the trace to an expected trace. } @@ -436,39 +421,36 @@ fn simulate_declare() { let TransactionTrace::Declare(exec_only_trace) = &exec_only.transaction_trace else { panic!("Wrong trace type, expected DeclareTransactionTrace.") }; - assert_matches!( - exec_only_trace, - DeclareTransactionTrace { validate_invocation: None, fee_transfer_invocation: None } - ); + assert_matches!(exec_only_trace, DeclareTransactionTrace { + validate_invocation: None, + fee_transfer_invocation: None + }); let TransactionTrace::Declare(validate_trace) = &validate.transaction_trace else { panic!("Wrong trace type, expected DeclareTransactionTrace.") }; - assert_matches!( - validate_trace, - DeclareTransactionTrace { validate_invocation: Some(_), fee_transfer_invocation: None } - ); + assert_matches!(validate_trace, DeclareTransactionTrace { + validate_invocation: Some(_), + fee_transfer_invocation: None + }); let TransactionTrace::Declare(charge_fee_trace) = &charge_fee.transaction_trace else { panic!("Wrong trace type, expected DeclareTransactionTrace.") }; - assert_matches!( - charge_fee_trace, - DeclareTransactionTrace { validate_invocation: None, fee_transfer_invocation: Some(_) } - ); + assert_matches!(charge_fee_trace, DeclareTransactionTrace { + validate_invocation: None, + fee_transfer_invocation: Some(_) + }); let TransactionTrace::Declare(charge_fee_validate_trace) = &charge_fee_validate.transaction_trace else { panic!("Wrong trace type, expected DeclareTransactionTrace.") }; - assert_matches!( - charge_fee_validate_trace, - DeclareTransactionTrace { - validate_invocation: Some(_), - fee_transfer_invocation: Some(_), - } - ); + assert_matches!(charge_fee_validate_trace, DeclareTransactionTrace { + validate_invocation: Some(_), + fee_transfer_invocation: Some(_), + }); // TODO(yair): Compare the trace to an expected trace. } @@ -497,53 +479,41 @@ fn simulate_deploy_account() { let TransactionTrace::DeployAccount(exec_only_trace) = &exec_only.transaction_trace else { panic!("Wrong trace type, expected DeployAccountTransactionTrace.") }; - assert_matches!( - exec_only_trace, - DeployAccountTransactionTrace { - validate_invocation: None, - fee_transfer_invocation: None, - constructor_invocation: _, - } - ); + assert_matches!(exec_only_trace, DeployAccountTransactionTrace { + validate_invocation: None, + fee_transfer_invocation: None, + constructor_invocation: _, + }); let TransactionTrace::DeployAccount(validate_trace) = &validate.transaction_trace else { panic!("Wrong trace type, expected DeployAccountTransactionTrace.") }; - assert_matches!( - validate_trace, - DeployAccountTransactionTrace { - validate_invocation: Some(_), - fee_transfer_invocation: None, - constructor_invocation: _ - } - ); + assert_matches!(validate_trace, DeployAccountTransactionTrace { + validate_invocation: Some(_), + fee_transfer_invocation: None, + constructor_invocation: _ + }); let TransactionTrace::DeployAccount(charge_fee_trace) = &charge_fee.transaction_trace else { panic!("Wrong trace type, expected DeployAccountTransactionTrace.") }; - assert_matches!( - charge_fee_trace, - DeployAccountTransactionTrace { - validate_invocation: None, - fee_transfer_invocation: Some(_), - constructor_invocation: _ - } - ); + assert_matches!(charge_fee_trace, DeployAccountTransactionTrace { + validate_invocation: None, + fee_transfer_invocation: Some(_), + constructor_invocation: _ + }); let TransactionTrace::DeployAccount(charge_fee_validate_trace) = &charge_fee_validate.transaction_trace else { panic!("Wrong trace type, expected DeployAccountTransactionTrace.") }; - assert_matches!( - charge_fee_validate_trace, - DeployAccountTransactionTrace { - validate_invocation: Some(_), - fee_transfer_invocation: Some(_), - constructor_invocation: _ - } - ); + assert_matches!(charge_fee_validate_trace, DeployAccountTransactionTrace { + validate_invocation: Some(_), + fee_transfer_invocation: Some(_), + constructor_invocation: _ + }); // TODO(yair): Compare the trace to an expected trace. } diff --git a/crates/papyrus_execution/src/execution_utils.rs b/crates/papyrus_execution/src/execution_utils.rs index 928728acab..ca315c485b 100644 --- a/crates/papyrus_execution/src/execution_utils.rs +++ b/crates/papyrus_execution/src/execution_utils.rs @@ -16,7 +16,7 @@ use cairo_vm::types::errors::program_errors::ProgramError; use indexmap::IndexMap; use papyrus_common::state::{DeployedContract, ReplacedClass, StorageEntry}; use papyrus_storage::compiled_class::CasmStorageReader; -use papyrus_storage::db::{TransactionKind, RO}; +use papyrus_storage::db::{RO, TransactionKind}; use papyrus_storage::state::StateStorageReader; use papyrus_storage::{StorageError, StorageResult, StorageTxn}; use starknet_api::core::{ClassHash, ContractAddress, Nonce}; diff --git a/crates/papyrus_execution/src/lib.rs b/crates/papyrus_execution/src/lib.rs index 1409313452..d562d9764e 100644 --- a/crates/papyrus_execution/src/lib.rs +++ b/crates/papyrus_execution/src/lib.rs @@ -25,7 +25,7 @@ use std::num::NonZeroU128; use std::path::Path; use std::sync::{Arc, LazyLock}; -use blockifier::blockifier::block::{pre_process_block, BlockInfo, BlockNumberHashPair, GasPrices}; +use blockifier::blockifier::block::{BlockInfo, BlockNumberHashPair, GasPrices, pre_process_block}; use blockifier::bouncer::BouncerConfig; use blockifier::context::{BlockContext, ChainInfo, FeeTokenAddresses, TransactionContext}; use blockifier::execution::call_info::CallExecution; @@ -50,9 +50,9 @@ use cairo_vm::types::builtin_name::BuiltinName; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use execution_utils::{get_trace_constructor, induced_state_diff}; use objects::{PriceUnit, TransactionSimulationOutput}; -use papyrus_common::transaction_hash::get_transaction_hash; use papyrus_common::TransactionOptions; -use papyrus_config::dumping::{ser_param, SerializeConfig}; +use papyrus_common::transaction_hash::get_transaction_hash; +use papyrus_config::dumping::{SerializeConfig, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use papyrus_storage::header::HeaderStorageReader; use papyrus_storage::{StorageError, StorageReader}; @@ -80,11 +80,11 @@ use starknet_api::transaction::{ TransactionHash, TransactionVersion, }; -use starknet_api::{contract_address, felt, patricia_key, StarknetApiError}; +use starknet_api::{StarknetApiError, contract_address, felt, patricia_key}; use state_reader::ExecutionStateReader; use tracing::trace; -use crate::objects::{tx_execution_output_to_fee_estimation, FeeEstimation, PendingData}; +use crate::objects::{FeeEstimation, PendingData, tx_execution_output_to_fee_estimation}; const STARKNET_VERSION_O_13_0: &str = "0.13.0"; const STARKNET_VERSION_O_13_1: &str = "0.13.1"; diff --git a/crates/papyrus_execution/src/state_reader.rs b/crates/papyrus_execution/src/state_reader.rs index a15df3c3c8..9bb005ff22 100644 --- a/crates/papyrus_execution/src/state_reader.rs +++ b/crates/papyrus_execution/src/state_reader.rs @@ -20,7 +20,7 @@ use starknet_api::state::{StateNumber, StorageKey}; use starknet_types_core::felt::Felt; use crate::execution_utils; -use crate::execution_utils::{get_contract_class, ExecutionUtilsError}; +use crate::execution_utils::{ExecutionUtilsError, get_contract_class}; use crate::objects::PendingData; /// A view into the state at a specific state number. diff --git a/crates/papyrus_execution/src/state_reader_test.rs b/crates/papyrus_execution/src/state_reader_test.rs index 332eec48c9..e80ec021ea 100644 --- a/crates/papyrus_execution/src/state_reader_test.rs +++ b/crates/papyrus_execution/src/state_reader_test.rs @@ -82,58 +82,48 @@ fn read_state() { .unwrap() .append_classes(BlockNumber(0), &[], &[]) .unwrap() - .append_header( - BlockNumber(1), - &BlockHeader { - block_hash: BlockHash(felt!(1_u128)), - block_number: BlockNumber(1), - ..Default::default() - }, - ) + .append_header(BlockNumber(1), &BlockHeader { + block_hash: BlockHash(felt!(1_u128)), + block_number: BlockNumber(1), + ..Default::default() + }) .unwrap() .append_body(BlockNumber(1), BlockBody::default()) .unwrap() - .append_state_diff( - BlockNumber(1), - ThinStateDiff { - deployed_contracts: indexmap!( - address0 => class_hash0, - address1 => class_hash1, + .append_state_diff(BlockNumber(1), ThinStateDiff { + deployed_contracts: indexmap!( + address0 => class_hash0, + address1 => class_hash1, + ), + storage_diffs: indexmap!( + address0 => indexmap!( + storage_key0 => storage_value0, ), - storage_diffs: indexmap!( - address0 => indexmap!( - storage_key0 => storage_value0, - ), - ), - declared_classes: indexmap!( - class_hash0 => compiled_class_hash0, - class_hash5 => compiled_class_hash0, - ), - deprecated_declared_classes: vec![class_hash1], - nonces: indexmap!( - address0 => nonce0, - address1 => Nonce::default(), - ), - replaced_classes: indexmap!(), - }, - ) + ), + declared_classes: indexmap!( + class_hash0 => compiled_class_hash0, + class_hash5 => compiled_class_hash0, + ), + deprecated_declared_classes: vec![class_hash1], + nonces: indexmap!( + address0 => nonce0, + address1 => Nonce::default(), + ), + replaced_classes: indexmap!(), + }) .unwrap() - .append_classes( - BlockNumber(1), - &[(class_hash0, &class0), (class_hash5, &class0)], - &[(class_hash1, &class1)], - ) + .append_classes(BlockNumber(1), &[(class_hash0, &class0), (class_hash5, &class0)], &[( + class_hash1, + &class1, + )]) .unwrap() .append_casm(&class_hash0, &casm0) .unwrap() - .append_header( - BlockNumber(2), - &BlockHeader { - block_hash: BlockHash(felt!(2_u128)), - block_number: BlockNumber(2), - ..Default::default() - }, - ) + .append_header(BlockNumber(2), &BlockHeader { + block_hash: BlockHash(felt!(2_u128)), + block_number: BlockNumber(2), + ..Default::default() + }) .unwrap() .append_body(BlockNumber(2), BlockBody::default()) .unwrap() @@ -240,10 +230,11 @@ fn read_state() { // Test get_class_hash_at when the class is replaced. if let Some(pending_data) = &mut state_reader2.maybe_pending_data { - pending_data.replaced_classes = vec![ - ReplacedClass { address: address0, class_hash: class_hash3 }, - ReplacedClass { address: address2, class_hash: class_hash3 }, - ]; + pending_data.replaced_classes = + vec![ReplacedClass { address: address0, class_hash: class_hash3 }, ReplacedClass { + address: address2, + class_hash: class_hash3, + }]; } assert_eq!(state_reader2.get_class_hash_at(address0).unwrap(), class_hash3); assert_eq!(state_reader2.get_class_hash_at(address2).unwrap(), class_hash3); diff --git a/crates/papyrus_execution/src/test_utils.rs b/crates/papyrus_execution/src/test_utils.rs index 51c0259bb6..abed787327 100644 --- a/crates/papyrus_execution/src/test_utils.rs +++ b/crates/papyrus_execution/src/test_utils.rs @@ -49,7 +49,7 @@ use starknet_types_core::felt::Felt; use crate::execution_utils::selector_from_name; use crate::objects::{PendingData, TransactionSimulationOutput}; use crate::testing_instances::get_test_execution_config; -use crate::{simulate_transactions, ExecutableTransactionInput, OnlyQuery, SierraSize}; +use crate::{ExecutableTransactionInput, OnlyQuery, SierraSize, simulate_transactions}; lazy_static! { pub static ref CHAIN_ID: ChainId = ChainId::Other(String::from("TEST_CHAIN_ID")); @@ -110,78 +110,65 @@ pub fn prepare_storage(mut storage_writer: StorageWriter) { storage_writer .begin_rw_txn() .unwrap() - .append_header( - BlockNumber(0), - &BlockHeader { - l1_gas_price: *GAS_PRICE, - sequencer: *SEQUENCER_ADDRESS, - timestamp: *BLOCK_TIMESTAMP, - ..Default::default() - }, - ) + .append_header(BlockNumber(0), &BlockHeader { + l1_gas_price: *GAS_PRICE, + sequencer: *SEQUENCER_ADDRESS, + timestamp: *BLOCK_TIMESTAMP, + ..Default::default() + }) .unwrap() .append_body(BlockNumber(0), BlockBody::default()) .unwrap() - .append_state_diff( - BlockNumber(0), - ThinStateDiff { - deployed_contracts: indexmap!( - *TEST_ERC20_CONTRACT_ADDRESS => *TEST_ERC20_CONTRACT_CLASS_HASH, - *CONTRACT_ADDRESS => class_hash0, - *DEPRECATED_CONTRACT_ADDRESS => class_hash1, - *ACCOUNT_ADDRESS => *ACCOUNT_CLASS_HASH, - ), - storage_diffs: indexmap!( - *TEST_ERC20_CONTRACT_ADDRESS => indexmap!( - // Give the accounts some balance. - account_balance_key => *ACCOUNT_INITIAL_BALANCE, - new_account_balance_key => *ACCOUNT_INITIAL_BALANCE, - // Give the first account mint permission (what is this?). - minter_var_address => *ACCOUNT_ADDRESS.0.key() - ), - ), - declared_classes: indexmap!( - // The class is not used in the execution, so it can be default. - class_hash0 => CompiledClassHash::default() - ), - deprecated_declared_classes: vec![ - *TEST_ERC20_CONTRACT_CLASS_HASH, - class_hash1, - *ACCOUNT_CLASS_HASH, - ], - nonces: indexmap!( - *TEST_ERC20_CONTRACT_ADDRESS => Nonce::default(), - *CONTRACT_ADDRESS => Nonce::default(), - *DEPRECATED_CONTRACT_ADDRESS => Nonce::default(), - *ACCOUNT_ADDRESS => Nonce::default(), + .append_state_diff(BlockNumber(0), ThinStateDiff { + deployed_contracts: indexmap!( + *TEST_ERC20_CONTRACT_ADDRESS => *TEST_ERC20_CONTRACT_CLASS_HASH, + *CONTRACT_ADDRESS => class_hash0, + *DEPRECATED_CONTRACT_ADDRESS => class_hash1, + *ACCOUNT_ADDRESS => *ACCOUNT_CLASS_HASH, + ), + storage_diffs: indexmap!( + *TEST_ERC20_CONTRACT_ADDRESS => indexmap!( + // Give the accounts some balance. + account_balance_key => *ACCOUNT_INITIAL_BALANCE, + new_account_balance_key => *ACCOUNT_INITIAL_BALANCE, + // Give the first account mint permission (what is this?). + minter_var_address => *ACCOUNT_ADDRESS.0.key() ), - replaced_classes: indexmap!(), - }, - ) - .unwrap() - .append_classes( - BlockNumber(0), - &[(class_hash0, &ContractClass::default())], - &[ - (*TEST_ERC20_CONTRACT_CLASS_HASH, &get_test_erc20_fee_contract_class()), - (class_hash1, &get_test_deprecated_contract_class()), - (*ACCOUNT_CLASS_HASH, &get_test_account_class()), + ), + declared_classes: indexmap!( + // The class is not used in the execution, so it can be default. + class_hash0 => CompiledClassHash::default() + ), + deprecated_declared_classes: vec![ + *TEST_ERC20_CONTRACT_CLASS_HASH, + class_hash1, + *ACCOUNT_CLASS_HASH, ], - ) + nonces: indexmap!( + *TEST_ERC20_CONTRACT_ADDRESS => Nonce::default(), + *CONTRACT_ADDRESS => Nonce::default(), + *DEPRECATED_CONTRACT_ADDRESS => Nonce::default(), + *ACCOUNT_ADDRESS => Nonce::default(), + ), + replaced_classes: indexmap!(), + }) + .unwrap() + .append_classes(BlockNumber(0), &[(class_hash0, &ContractClass::default())], &[ + (*TEST_ERC20_CONTRACT_CLASS_HASH, &get_test_erc20_fee_contract_class()), + (class_hash1, &get_test_deprecated_contract_class()), + (*ACCOUNT_CLASS_HASH, &get_test_account_class()), + ]) .unwrap() .append_casm(&class_hash0, &get_test_casm()) .unwrap() - .append_header( - BlockNumber(1), - &BlockHeader { - l1_gas_price: *GAS_PRICE, - sequencer: *SEQUENCER_ADDRESS, - timestamp: *BLOCK_TIMESTAMP, - block_hash: BlockHash(felt!(1_u128)), - parent_hash: BlockHash(felt!(0_u128)), - ..Default::default() - }, - ) + .append_header(BlockNumber(1), &BlockHeader { + l1_gas_price: *GAS_PRICE, + sequencer: *SEQUENCER_ADDRESS, + timestamp: *BLOCK_TIMESTAMP, + block_hash: BlockHash(felt!(1_u128)), + parent_hash: BlockHash(felt!(0_u128)), + ..Default::default() + }) .unwrap() .append_body(BlockNumber(1), BlockBody::default()) .unwrap() diff --git a/crates/papyrus_execution/src/testing_instances.rs b/crates/papyrus_execution/src/testing_instances.rs index af53c859bd..e029f278d9 100644 --- a/crates/papyrus_execution/src/testing_instances.rs +++ b/crates/papyrus_execution/src/testing_instances.rs @@ -3,7 +3,7 @@ /// Returns the storage key of a storage variable. pub use blockifier::abi::abi_utils::get_storage_var_address; -use papyrus_test_utils::{auto_impl_get_test_instance, get_number_of_variants, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, auto_impl_get_test_instance, get_number_of_variants}; use starknet_api::block::GasPrice; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, PatriciaKey}; use starknet_api::deprecated_contract_class::EntryPointType; @@ -12,6 +12,7 @@ use starknet_api::transaction::{Calldata, EventContent, Fee, MessageToL1}; use starknet_api::{contract_address, felt, patricia_key}; use starknet_types_core::felt::Felt; +use crate::ExecutionConfig; use crate::objects::{ CallType, DeclareTransactionTrace, @@ -29,7 +30,6 @@ use crate::objects::{ RevertReason, TransactionTrace, }; -use crate::ExecutionConfig; /// Creates ExecutionConfig for tests. pub fn get_test_execution_config() -> ExecutionConfig { diff --git a/crates/papyrus_load_test/src/compare_endpoints.rs b/crates/papyrus_load_test/src/compare_endpoints.rs index e3968e2f8a..72f2aa09df 100644 --- a/crates/papyrus_load_test/src/compare_endpoints.rs +++ b/crates/papyrus_load_test/src/compare_endpoints.rs @@ -1,5 +1,5 @@ use std::env::var; -use std::fs::{create_dir, remove_dir_all, File}; +use std::fs::{File, create_dir, remove_dir_all}; use std::io::Write; use std::path::Path; diff --git a/crates/papyrus_load_test/src/create_files.rs b/crates/papyrus_load_test/src/create_files.rs index 4880a60092..ca52297bf6 100644 --- a/crates/papyrus_load_test/src/create_files.rs +++ b/crates/papyrus_load_test/src/create_files.rs @@ -8,9 +8,6 @@ use reqwest::{Client, Url}; use serde_json::Value as jsonVal; use crate::{ - get_last_block_number, - get_random_block_number, - path_in_resources, GET_BLOCK_TRANSACTION_COUNT_BY_HASH_WEIGHT, GET_BLOCK_TRANSACTION_COUNT_BY_NUMBER_WEIGHT, GET_BLOCK_WITH_FULL_TRANSACTIONS_BY_HASH_WEIGHT, @@ -23,8 +20,8 @@ use crate::{ GET_CLASS_BY_NUMBER_WEIGHT, GET_CLASS_HASH_AT_BY_HASH_WEIGHT, GET_CLASS_HASH_AT_BY_NUMBER_WEIGHT, - GET_EVENTS_WITHOUT_ADDRESS_WEIGHT, GET_EVENTS_WITH_ADDRESS_WEIGHT, + GET_EVENTS_WITHOUT_ADDRESS_WEIGHT, GET_NONCE_BY_HASH_WEIGHT, GET_NONCE_BY_NUMBER_WEIGHT, GET_STATE_UPDATE_BY_HASH_WEIGHT, @@ -35,6 +32,9 @@ use crate::{ GET_TRANSACTION_BY_BLOCK_ID_AND_INDEX_BY_NUMBER_WEIGHT, GET_TRANSACTION_BY_HASH_WEIGHT, GET_TRANSACTION_RECEIPT_WEIGHT, + get_last_block_number, + get_random_block_number, + path_in_resources, }; // The limit on the storage size for request arguments. diff --git a/crates/papyrus_load_test/src/create_request.rs b/crates/papyrus_load_test/src/create_request.rs index 8040ddac24..2d79a5825b 100644 --- a/crates/papyrus_load_test/src/create_request.rs +++ b/crates/papyrus_load_test/src/create_request.rs @@ -1,6 +1,6 @@ use std::str::SplitWhitespace; -use serde_json::{json, Value as jsonVal}; +use serde_json::{Value as jsonVal, json}; use crate::jsonrpc_request; diff --git a/crates/papyrus_load_test/src/lib.rs b/crates/papyrus_load_test/src/lib.rs index e8e259cef9..1683fd26da 100644 --- a/crates/papyrus_load_test/src/lib.rs +++ b/crates/papyrus_load_test/src/lib.rs @@ -20,7 +20,7 @@ use goose::goose::{GooseUser, TransactionError}; use once_cell::sync::OnceCell; use rand::Rng; use serde::Deserialize; -use serde_json::{json, Value as jsonVal}; +use serde_json::{Value as jsonVal, json}; type PostResult = Result>; diff --git a/crates/papyrus_load_test/src/main.rs b/crates/papyrus_load_test/src/main.rs index 8375cd8efc..913a89874b 100644 --- a/crates/papyrus_load_test/src/main.rs +++ b/crates/papyrus_load_test/src/main.rs @@ -13,7 +13,7 @@ use std::env; use std::fs::File; use assert_matches::assert_matches; -use goose::{util, GooseAttack}; +use goose::{GooseAttack, util}; use papyrus_load_test::create_files::create_files; use papyrus_load_test::scenarios; use serde::Serialize; diff --git a/crates/papyrus_load_test/src/scenarios.rs b/crates/papyrus_load_test/src/scenarios.rs index 61b7df4f9c..e5ea3c8637 100644 --- a/crates/papyrus_load_test/src/scenarios.rs +++ b/crates/papyrus_load_test/src/scenarios.rs @@ -1,7 +1,6 @@ use goose::goose::Scenario; use crate::{ - transactions as txs, BLOCK_HASH_AND_NUMBER_WEIGHT, BLOCK_NUMBER_WEIGHT, CHAIN_ID_WEIGHT, @@ -17,8 +16,8 @@ use crate::{ GET_CLASS_BY_NUMBER_WEIGHT, GET_CLASS_HASH_AT_BY_HASH_WEIGHT, GET_CLASS_HASH_AT_BY_NUMBER_WEIGHT, - GET_EVENTS_WITHOUT_ADDRESS_WEIGHT, GET_EVENTS_WITH_ADDRESS_WEIGHT, + GET_EVENTS_WITHOUT_ADDRESS_WEIGHT, GET_NONCE_BY_HASH_WEIGHT, GET_NONCE_BY_NUMBER_WEIGHT, GET_STATE_UPDATE_BY_HASH_WEIGHT, @@ -33,6 +32,7 @@ use crate::{ TRACE_BLOCK_TRANSACTIONS_BY_HASH_WEIGHT, TRACE_BLOCK_TRANSACTIONS_BY_NUMBER_WEIGHT, TRACE_TRANSACTION_WEIGHT, + transactions as txs, }; // TODO(dvir): add also traceTransaction, simulateTransactions, estimateFee and call endpoints. diff --git a/crates/papyrus_load_test/src/transactions.rs b/crates/papyrus_load_test/src/transactions.rs index f98d2d4094..c394cebae7 100644 --- a/crates/papyrus_load_test/src/transactions.rs +++ b/crates/papyrus_load_test/src/transactions.rs @@ -1,11 +1,11 @@ use std::fs::File; -use std::io::prelude::*; use std::io::BufReader; +use std::io::prelude::*; use std::sync::Arc; use goose::goose::{Transaction, TransactionFunction}; use rand::Rng; -use serde_json::{json, Value as jsonVal}; +use serde_json::{Value as jsonVal, json}; use crate::{create_request, jsonrpc_request, path_in_resources, post_jsonrpc_request}; diff --git a/crates/papyrus_monitoring_gateway/src/gateway_test.rs b/crates/papyrus_monitoring_gateway/src/gateway_test.rs index 8c1dc4487e..28dedf69e4 100644 --- a/crates/papyrus_monitoring_gateway/src/gateway_test.rs +++ b/crates/papyrus_monitoring_gateway/src/gateway_test.rs @@ -1,21 +1,21 @@ use std::net::{SocketAddr, TcpListener}; use std::sync::Arc; +use axum::Router; use axum::body::Body; use axum::http::{Request, StatusCode}; use axum::response::Response; -use axum::Router; use http_body::combinators::UnsyncBoxBody; use metrics::{absolute_counter, describe_counter, register_counter}; use metrics_exporter_prometheus::PrometheusBuilder; use papyrus_storage::{table_names, test_utils}; use pretty_assertions::assert_eq; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use starknet_client::reader::MockStarknetReader; use starknet_client::writer::MockStarknetWriter; use tower::ServiceExt; -use crate::{app, is_ready, MONITORING_PREFIX}; +use crate::{MONITORING_PREFIX, app, is_ready}; const TEST_CONFIG_PRESENTATION: &str = "full_general_config_presentation"; const PUBLIC_TEST_CONFIG_PRESENTATION: &str = "public_general_config_presentation"; diff --git a/crates/papyrus_monitoring_gateway/src/lib.rs b/crates/papyrus_monitoring_gateway/src/lib.rs index 1f7e068c91..fd8a08d94b 100644 --- a/crates/papyrus_monitoring_gateway/src/lib.rs +++ b/crates/papyrus_monitoring_gateway/src/lib.rs @@ -19,16 +19,16 @@ use axum::{Json, Router}; use metrics_exporter_prometheus::{BuildError, PrometheusBuilder, PrometheusHandle}; use metrics_process::Collector; use papyrus_config::converters::{deserialize_optional_map, serialize_optional_map}; -use papyrus_config::dumping::{ser_generated_param, ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, ser_generated_param, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializationType, SerializedParam}; use papyrus_storage::mmap_file::MMapFileStats; use papyrus_storage::{DbStats, StorageError, StorageReader}; use rand::distributions::Alphanumeric; -use rand::{thread_rng, Rng}; +use rand::{Rng, thread_rng}; use serde::{Deserialize, Serialize}; +use starknet_client::RetryConfig; use starknet_client::reader::{StarknetFeederGatewayClient, StarknetReader}; use starknet_client::writer::{StarknetGatewayClient, StarknetWriter}; -use starknet_client::RetryConfig; use tracing::{debug, info, instrument}; use validator::Validate; diff --git a/crates/papyrus_network/src/bin_utils/mod.rs b/crates/papyrus_network/src/bin_utils/mod.rs index dfe9ea105f..46e4bdefd8 100644 --- a/crates/papyrus_network/src/bin_utils/mod.rs +++ b/crates/papyrus_network/src/bin_utils/mod.rs @@ -3,7 +3,7 @@ use std::time::Duration; use libp2p::identity::Keypair; use libp2p::swarm::NetworkBehaviour; -use libp2p::{noise, yamux, Multiaddr, Swarm, SwarmBuilder}; +use libp2p::{Multiaddr, Swarm, SwarmBuilder, noise, yamux}; use tracing::debug; pub fn build_swarm( diff --git a/crates/papyrus_network/src/discovery/flow_test.rs b/crates/papyrus_network/src/discovery/flow_test.rs index 1b7f296d81..5da464bcbf 100644 --- a/crates/papyrus_network/src/discovery/flow_test.rs +++ b/crates/papyrus_network/src/discovery/flow_test.rs @@ -7,7 +7,7 @@ use libp2p::identity::Keypair; use libp2p::kad::store::MemoryStore; use libp2p::swarm::behaviour::toggle::Toggle; use libp2p::swarm::{NetworkBehaviour, SwarmEvent}; -use libp2p::{identify, kad, Multiaddr, Swarm}; +use libp2p::{Multiaddr, Swarm, identify, kad}; use libp2p_swarm_test::SwarmExt; use starknet_api::core::ChainId; diff --git a/crates/papyrus_network/src/discovery/identify_impl.rs b/crates/papyrus_network/src/discovery/identify_impl.rs index 945aed2942..ff27ec5476 100644 --- a/crates/papyrus_network/src/discovery/identify_impl.rs +++ b/crates/papyrus_network/src/discovery/identify_impl.rs @@ -1,4 +1,4 @@ -use libp2p::{identify, Multiaddr, PeerId}; +use libp2p::{Multiaddr, PeerId, identify}; use crate::mixed_behaviour; use crate::mixed_behaviour::BridgedBehaviour; diff --git a/crates/papyrus_network/src/discovery/mod.rs b/crates/papyrus_network/src/discovery/mod.rs index ff78e6e8b9..7cfae49d09 100644 --- a/crates/papyrus_network/src/discovery/mod.rs +++ b/crates/papyrus_network/src/discovery/mod.rs @@ -5,17 +5,16 @@ mod flow_test; pub mod identify_impl; pub mod kad_impl; -use std::task::{ready, Context, Poll, Waker}; +use std::task::{Context, Poll, Waker, ready}; use std::time::Duration; use futures::future::BoxFuture; -use futures::{pin_mut, Future, FutureExt}; +use futures::{Future, FutureExt, pin_mut}; use kad_impl::KadToOtherBehaviourEvent; use libp2p::core::Endpoint; use libp2p::swarm::behaviour::ConnectionEstablished; use libp2p::swarm::dial_opts::{DialOpts, PeerCondition}; use libp2p::swarm::{ - dummy, AddressChange, ConnectionClosed, ConnectionDenied, @@ -25,6 +24,7 @@ use libp2p::swarm::{ FromSwarm, NetworkBehaviour, ToSwarm, + dummy, }; use libp2p::{Multiaddr, PeerId}; use tokio_retry::strategy::ExponentialBackoff; diff --git a/crates/papyrus_network/src/gossipsub_impl.rs b/crates/papyrus_network/src/gossipsub_impl.rs index f2d4327ff3..e58329a57c 100644 --- a/crates/papyrus_network/src/gossipsub_impl.rs +++ b/crates/papyrus_network/src/gossipsub_impl.rs @@ -1,5 +1,5 @@ use libp2p::gossipsub::TopicHash; -use libp2p::{gossipsub, PeerId}; +use libp2p::{PeerId, gossipsub}; use tracing::error; use crate::mixed_behaviour; diff --git a/crates/papyrus_network/src/lib.rs b/crates/papyrus_network/src/lib.rs index 0ce213ba9b..eefa36755d 100644 --- a/crates/papyrus_network/src/lib.rs +++ b/crates/papyrus_network/src/lib.rs @@ -24,7 +24,7 @@ use papyrus_config::converters::{ deserialize_seconds_to_duration, serialize_optional_vec_u8, }; -use papyrus_config::dumping::{ser_optional_param, ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, ser_optional_param, ser_param}; use papyrus_config::validators::validate_vec_u256; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; diff --git a/crates/papyrus_network/src/mixed_behaviour.rs b/crates/papyrus_network/src/mixed_behaviour.rs index 5f6daebeb1..c9aae71b53 100644 --- a/crates/papyrus_network/src/mixed_behaviour.rs +++ b/crates/papyrus_network/src/mixed_behaviour.rs @@ -2,15 +2,15 @@ use libp2p::identity::Keypair; use libp2p::kad::store::MemoryStore; +use libp2p::swarm::NetworkBehaviour; use libp2p::swarm::behaviour::toggle::Toggle; use libp2p::swarm::dial_opts::DialOpts; -use libp2p::swarm::NetworkBehaviour; -use libp2p::{gossipsub, identify, kad, Multiaddr, PeerId, StreamProtocol}; +use libp2p::{Multiaddr, PeerId, StreamProtocol, gossipsub, identify, kad}; use starknet_api::core::ChainId; -use crate::discovery::identify_impl::{IdentifyToOtherBehaviourEvent, IDENTIFY_PROTOCOL_VERSION}; -use crate::discovery::kad_impl::KadToOtherBehaviourEvent; use crate::discovery::DiscoveryConfig; +use crate::discovery::identify_impl::{IDENTIFY_PROTOCOL_VERSION, IdentifyToOtherBehaviourEvent}; +use crate::discovery::kad_impl::KadToOtherBehaviourEvent; use crate::peer_manager::PeerManagerConfig; use crate::{discovery, gossipsub_impl, peer_manager, sqmr}; diff --git a/crates/papyrus_network/src/network_manager/mod.rs b/crates/papyrus_network/src/network_manager/mod.rs index 6a44f64a5b..471ce661a3 100644 --- a/crates/papyrus_network/src/network_manager/mod.rs +++ b/crates/papyrus_network/src/network_manager/mod.rs @@ -11,10 +11,10 @@ use std::task::{Context, Poll}; use futures::channel::mpsc::{Receiver, SendError, Sender}; use futures::channel::oneshot; -use futures::future::{ready, BoxFuture, Ready}; +use futures::future::{BoxFuture, Ready, ready}; use futures::sink::With; use futures::stream::{self, FuturesUnordered, Map, Stream}; -use futures::{pin_mut, FutureExt, Sink, SinkExt, StreamExt}; +use futures::{FutureExt, Sink, SinkExt, StreamExt, pin_mut}; use libp2p::gossipsub::{SubscriptionError, TopicHash}; use libp2p::swarm::SwarmEvent; use libp2p::{Multiaddr, PeerId, StreamProtocol, Swarm}; @@ -29,8 +29,8 @@ use crate::gossipsub_impl::Topic; use crate::mixed_behaviour::{self, BridgedBehaviour}; use crate::sqmr::behaviour::SessionError; use crate::sqmr::{self, InboundSessionId, OutboundSessionId, SessionId}; -use crate::utils::{is_localhost, StreamHashMap}; -use crate::{gossipsub_impl, NetworkConfig}; +use crate::utils::{StreamHashMap, is_localhost}; +use crate::{NetworkConfig, gossipsub_impl}; #[derive(thiserror::Error, Debug)] pub enum NetworkError { diff --git a/crates/papyrus_network/src/network_manager/test.rs b/crates/papyrus_network/src/network_manager/test.rs index 111a22836b..1b5cc7cd47 100644 --- a/crates/papyrus_network/src/network_manager/test.rs +++ b/crates/papyrus_network/src/network_manager/test.rs @@ -6,11 +6,11 @@ use std::time::Duration; use std::vec; use deadqueue::unlimited::Queue; -use futures::channel::mpsc::{unbounded, UnboundedSender}; +use futures::channel::mpsc::{UnboundedSender, unbounded}; use futures::channel::oneshot; use futures::future::FutureExt; use futures::stream::Stream; -use futures::{pin_mut, Future, SinkExt, StreamExt}; +use futures::{Future, SinkExt, StreamExt, pin_mut}; use lazy_static::lazy_static; use libp2p::core::ConnectedPoint; use libp2p::gossipsub::{SubscriptionError, TopicHash}; @@ -20,8 +20,8 @@ use tokio::select; use tokio::sync::Mutex; use tokio::time::sleep; -use super::swarm_trait::{Event, SwarmTrait}; use super::GenericNetworkManager; +use super::swarm_trait::{Event, SwarmTrait}; use crate::gossipsub_impl::{self, Topic}; use crate::mixed_behaviour; use crate::network_manager::ServerQueryManager; diff --git a/crates/papyrus_network/src/network_manager/test_utils.rs b/crates/papyrus_network/src/network_manager/test_utils.rs index 9fa61099f7..2f1f0de475 100644 --- a/crates/papyrus_network/src/network_manager/test_utils.rs +++ b/crates/papyrus_network/src/network_manager/test_utils.rs @@ -1,6 +1,6 @@ use futures::channel::mpsc::{Receiver, SendError, Sender}; use futures::channel::oneshot; -use futures::future::{ready, Ready}; +use futures::future::{Ready, ready}; use futures::sink::With; use futures::stream::Map; use futures::{FutureExt, SinkExt, StreamExt}; diff --git a/crates/papyrus_network/src/peer_manager/behaviour_impl.rs b/crates/papyrus_network/src/peer_manager/behaviour_impl.rs index 82fa9317bc..f8a648e382 100644 --- a/crates/papyrus_network/src/peer_manager/behaviour_impl.rs +++ b/crates/papyrus_network/src/peer_manager/behaviour_impl.rs @@ -1,14 +1,14 @@ -use std::task::{ready, Poll}; +use std::task::{Poll, ready}; use libp2p::swarm::behaviour::ConnectionEstablished; use libp2p::swarm::{ - dummy, ConnectionClosed, ConnectionId, DialError, DialFailure, NetworkBehaviour, ToSwarm, + dummy, }; use libp2p::{Multiaddr, PeerId}; use tracing::{debug, error}; diff --git a/crates/papyrus_network/src/peer_manager/mod.rs b/crates/papyrus_network/src/peer_manager/mod.rs index efa4bebb92..c5b62476df 100644 --- a/crates/papyrus_network/src/peer_manager/mod.rs +++ b/crates/papyrus_network/src/peer_manager/mod.rs @@ -1,11 +1,11 @@ use std::collections::HashMap; use std::time::Duration; -use futures::future::BoxFuture; use futures::FutureExt; -use libp2p::swarm::dial_opts::DialOpts; -use libp2p::swarm::ToSwarm; +use futures::future::BoxFuture; use libp2p::PeerId; +use libp2p::swarm::ToSwarm; +use libp2p::swarm::dial_opts::DialOpts; use tracing::info; pub use self::behaviour_impl::ToOtherBehaviourEvent; diff --git a/crates/papyrus_network/src/sqmr/behaviour.rs b/crates/papyrus_network/src/sqmr/behaviour.rs index 88787ceeb0..ec5557ceef 100644 --- a/crates/papyrus_network/src/sqmr/behaviour.rs +++ b/crates/papyrus_network/src/sqmr/behaviour.rs @@ -4,8 +4,8 @@ mod behaviour_test; use std::collections::{HashMap, HashSet, VecDeque}; use std::io; -use std::sync::atomic::AtomicUsize; use std::sync::Arc; +use std::sync::atomic::AtomicUsize; use std::task::{Context, Poll, Waker}; use std::time::Duration; diff --git a/crates/papyrus_network/src/sqmr/flow_test.rs b/crates/papyrus_network/src/sqmr/flow_test.rs index 619bdafeb5..104f8b2b1c 100644 --- a/crates/papyrus_network/src/sqmr/flow_test.rs +++ b/crates/papyrus_network/src/sqmr/flow_test.rs @@ -1,5 +1,5 @@ -use std::collections::hash_map::DefaultHasher; use std::collections::HashMap; +use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use std::time::Duration; diff --git a/crates/papyrus_network/src/sqmr/handler.rs b/crates/papyrus_network/src/sqmr/handler.rs index 5a6dc3bee0..83cfa10fe4 100644 --- a/crates/papyrus_network/src/sqmr/handler.rs +++ b/crates/papyrus_network/src/sqmr/handler.rs @@ -5,8 +5,8 @@ mod inbound_session; use std::collections::{HashMap, HashSet, VecDeque}; use std::io; -use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; +use std::sync::atomic::{AtomicUsize, Ordering}; use std::task::{Context, Poll}; use std::time::Duration; diff --git a/crates/papyrus_network/src/sqmr/handler/inbound_session.rs b/crates/papyrus_network/src/sqmr/handler/inbound_session.rs index 26819cc0f9..5fe7850cb8 100644 --- a/crates/papyrus_network/src/sqmr/handler/inbound_session.rs +++ b/crates/papyrus_network/src/sqmr/handler/inbound_session.rs @@ -2,7 +2,7 @@ use std::collections::VecDeque; use std::future::Future; use std::io; use std::pin::Pin; -use std::task::{ready, Context, Poll, Waker}; +use std::task::{Context, Poll, Waker, ready}; use futures::future::BoxFuture; use futures::io::WriteHalf; @@ -10,8 +10,8 @@ use futures::{AsyncWriteExt, FutureExt}; use libp2p::swarm::Stream; use replace_with::replace_with_or_abort; -use super::super::messages::write_message; use super::super::Bytes; +use super::super::messages::write_message; pub(super) struct InboundSession { pending_messages: VecDeque, diff --git a/crates/papyrus_network/src/sqmr/handler_test.rs b/crates/papyrus_network/src/sqmr/handler_test.rs index 22d34afe99..b807bdb5bc 100644 --- a/crates/papyrus_network/src/sqmr/handler_test.rs +++ b/crates/papyrus_network/src/sqmr/handler_test.rs @@ -1,12 +1,12 @@ use std::collections::HashSet; use std::io; use std::pin::Pin; -use std::sync::atomic::AtomicUsize; use std::sync::Arc; +use std::sync::atomic::AtomicUsize; use assert_matches::assert_matches; use futures::task::{Context, Poll}; -use futures::{select, AsyncReadExt, AsyncWriteExt, FutureExt, Stream as StreamTrait, StreamExt}; +use futures::{AsyncReadExt, AsyncWriteExt, FutureExt, Stream as StreamTrait, StreamExt, select}; use lazy_static::lazy_static; use libp2p::swarm::handler::{ ConnectionEvent, diff --git a/crates/papyrus_network/src/sqmr/protocol.rs b/crates/papyrus_network/src/sqmr/protocol.rs index 6b91057818..5a2bd0c6ec 100644 --- a/crates/papyrus_network/src/sqmr/protocol.rs +++ b/crates/papyrus_network/src/sqmr/protocol.rs @@ -7,11 +7,11 @@ use std::{io, iter}; use futures::future::BoxFuture; use futures::io::{ReadHalf, WriteHalf}; use futures::{AsyncRead, AsyncReadExt, AsyncWrite, FutureExt}; -use libp2p::core::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; use libp2p::StreamProtocol; +use libp2p::core::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; -use super::messages::{read_message_without_length_prefix, write_message_without_length_prefix}; use super::Bytes; +use super::messages::{read_message_without_length_prefix, write_message_without_length_prefix}; pub struct InboundProtocol { supported_protocols: Vec, diff --git a/crates/papyrus_network/src/sqmr/protocol_test.rs b/crates/papyrus_network/src/sqmr/protocol_test.rs index f061153e81..9c1e68bfb6 100644 --- a/crates/papyrus_network/src/sqmr/protocol_test.rs +++ b/crates/papyrus_network/src/sqmr/protocol_test.rs @@ -1,6 +1,6 @@ -use libp2p::core::upgrade::{InboundUpgrade, OutboundUpgrade}; -use libp2p::core::UpgradeInfo; use libp2p::StreamProtocol; +use libp2p::core::UpgradeInfo; +use libp2p::core::upgrade::{InboundUpgrade, OutboundUpgrade}; use pretty_assertions::assert_eq; use super::super::messages::{read_message, write_message}; diff --git a/crates/papyrus_network/src/test_utils/get_stream.rs b/crates/papyrus_network/src/test_utils/get_stream.rs index 62ca75a029..704b0fdfa3 100644 --- a/crates/papyrus_network/src/test_utils/get_stream.rs +++ b/crates/papyrus_network/src/test_utils/get_stream.rs @@ -3,8 +3,8 @@ use std::task::{Context, Poll}; use futures::future::BoxFuture; use futures::{AsyncRead, AsyncWrite, FutureExt}; -use libp2p::core::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; use libp2p::core::Endpoint; +use libp2p::core::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; use libp2p::swarm::handler::{ConnectionEvent, FullyNegotiatedInbound, FullyNegotiatedOutbound}; use libp2p::swarm::{ ConnectionDenied, diff --git a/crates/papyrus_network/src/test_utils/mod.rs b/crates/papyrus_network/src/test_utils/mod.rs index 9afbb35347..0b1176340a 100644 --- a/crates/papyrus_network/src/test_utils/mod.rs +++ b/crates/papyrus_network/src/test_utils/mod.rs @@ -3,7 +3,7 @@ mod get_stream; use std::collections::{HashMap, HashSet}; use std::fmt::Debug; use std::pin::Pin; -use std::task::{ready, Context, Poll}; +use std::task::{Context, Poll, ready}; use std::time::Duration; use futures::future::{Either, Future}; diff --git a/crates/papyrus_network/src/utils.rs b/crates/papyrus_network/src/utils.rs index bc0a3ab971..23a0251aaa 100644 --- a/crates/papyrus_network/src/utils.rs +++ b/crates/papyrus_network/src/utils.rs @@ -6,8 +6,8 @@ use std::pin::Pin; use std::task::{Context, Poll, Waker}; use futures::stream::{Stream, StreamExt}; -use libp2p::core::multiaddr::Protocol; use libp2p::Multiaddr; +use libp2p::core::multiaddr::Protocol; // This is an implementation of `StreamMap` from tokio_stream. The reason we're implementing it // ourselves is that the implementation in tokio_stream requires that the values implement the diff --git a/crates/papyrus_node/examples/get_transaction_hash.rs b/crates/papyrus_node/examples/get_transaction_hash.rs index 6db09ac171..1cb0fca8d0 100644 --- a/crates/papyrus_node/examples/get_transaction_hash.rs +++ b/crates/papyrus_node/examples/get_transaction_hash.rs @@ -5,13 +5,13 @@ use std::sync::Mutex; use clap::{Arg, Command}; use futures::future::join_all; use once_cell::sync::OnceCell; +use papyrus_common::TransactionOptions; use papyrus_common::transaction_hash::{ - get_transaction_hash, MAINNET_TRANSACTION_HASH_WITH_VERSION, + get_transaction_hash, }; -use papyrus_common::TransactionOptions; use reqwest::Client; -use serde_json::{json, to_writer_pretty, Map, Value}; +use serde_json::{Map, Value, json, to_writer_pretty}; use starknet_api::core::ChainId; use starknet_api::transaction::{self, Transaction}; use starknet_client::reader::objects::transaction::TransactionType; @@ -252,11 +252,9 @@ fn create_map_of_transaction( transaction_info.insert( "only_query_transaction_hash".to_string(), json!( - get_transaction_hash( - transaction, - &chain_id, - &TransactionOptions { only_query: true } - ) + get_transaction_hash(transaction, &chain_id, &TransactionOptions { + only_query: true + }) .expect("Couldn't get only query transaction hash") ), ); diff --git a/crates/papyrus_node/src/bin/papyrus_dump_config.rs b/crates/papyrus_node/src/bin/papyrus_dump_config.rs index 8ae2050317..f44c2ccd42 100644 --- a/crates/papyrus_node/src/bin/papyrus_dump_config.rs +++ b/crates/papyrus_node/src/bin/papyrus_dump_config.rs @@ -7,7 +7,7 @@ use papyrus_config::dumping::SerializeConfig; #[cfg(feature = "rpc")] use papyrus_node::config::pointers::CONFIG_POINTERS; #[cfg(feature = "rpc")] -use papyrus_node::config::{NodeConfig, DEFAULT_CONFIG_PATH}; +use papyrus_node::config::{DEFAULT_CONFIG_PATH, NodeConfig}; /// Updates the default config file by: /// cargo run --bin papyrus_dump_config -q diff --git a/crates/papyrus_node/src/config/config_test.rs b/crates/papyrus_node/src/config/config_test.rs index 652a65d675..8d62022860 100644 --- a/crates/papyrus_node/src/config/config_test.rs +++ b/crates/papyrus_node/src/config/config_test.rs @@ -17,14 +17,14 @@ use papyrus_config::{SerializationType, SerializedContent, SerializedParam}; use papyrus_monitoring_gateway::MonitoringGatewayConfig; use papyrus_test_utils::get_absolute_path; use pretty_assertions::assert_eq; -use serde_json::{json, Map, Value}; +use serde_json::{Map, Value, json}; use starknet_api::core::ChainId; use tempfile::NamedTempFile; use validator::Validate; #[cfg(feature = "rpc")] use crate::config::pointers::CONFIG_POINTERS; -use crate::config::{node_command, NodeConfig, DEFAULT_CONFIG_PATH}; +use crate::config::{DEFAULT_CONFIG_PATH, NodeConfig, node_command}; // Returns the required and generated params in config/papyrus/default_config.json with the default // value from the config presentation. diff --git a/crates/papyrus_node/src/config/mod.rs b/crates/papyrus_node/src/config/mod.rs index e185710e53..a681487744 100644 --- a/crates/papyrus_node/src/config/mod.rs +++ b/crates/papyrus_node/src/config/mod.rs @@ -12,16 +12,16 @@ use std::path::{Path, PathBuf}; use std::time::Duration; use std::{env, fs, io}; -use clap::{arg, value_parser, Arg, ArgMatches, Command}; -use itertools::{chain, Itertools}; +use clap::{Arg, ArgMatches, Command, arg, value_parser}; +use itertools::{Itertools, chain}; use lazy_static::lazy_static; use papyrus_base_layer::ethereum_base_layer_contract::EthereumBaseLayerConfig; use papyrus_config::dumping::{ + SerializeConfig, append_sub_config_name, ser_optional_sub_config, ser_param, ser_pointer_target_param, - SerializeConfig, }; use papyrus_config::loading::load_and_process_config; use papyrus_config::{ConfigError, ParamPath, ParamPrivacyInput, SerializedParam}; @@ -31,10 +31,10 @@ use papyrus_network::NetworkConfig; use papyrus_p2p_sync::client::{P2PSyncClient, P2PSyncClientConfig}; #[cfg(feature = "rpc")] use papyrus_rpc::RpcConfig; -use papyrus_storage::db::DbConfig; use papyrus_storage::StorageConfig; -use papyrus_sync::sources::central::CentralSourceConfig; +use papyrus_storage::db::DbConfig; use papyrus_sync::SyncConfig; +use papyrus_sync::sources::central::CentralSourceConfig; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; use starknet_api::core::ChainId; diff --git a/crates/papyrus_node/src/config/pointers.rs b/crates/papyrus_node/src/config/pointers.rs index 0cee496fce..ebc192f97c 100644 --- a/crates/papyrus_node/src/config/pointers.rs +++ b/crates/papyrus_node/src/config/pointers.rs @@ -7,31 +7,31 @@ use std::path::{Path, PathBuf}; use std::time::Duration; use std::{env, fs, io}; -use clap::{arg, value_parser, Arg, ArgMatches, Command}; -use itertools::{chain, Itertools}; +use clap::{Arg, ArgMatches, Command, arg, value_parser}; +use itertools::{Itertools, chain}; use lazy_static::lazy_static; use papyrus_base_layer::ethereum_base_layer_contract::EthereumBaseLayerConfig; #[cfg(not(feature = "rpc"))] +use papyrus_config::ParamPrivacyInput; +#[cfg(not(feature = "rpc"))] use papyrus_config::dumping::ser_param; use papyrus_config::dumping::{ + SerializeConfig, append_sub_config_name, ser_optional_sub_config, ser_pointer_target_param, - SerializeConfig, }; use papyrus_config::loading::load_and_process_config; -#[cfg(not(feature = "rpc"))] -use papyrus_config::ParamPrivacyInput; use papyrus_config::{ConfigError, ParamPath, SerializedParam}; use papyrus_monitoring_gateway::MonitoringGatewayConfig; use papyrus_network::NetworkConfig; use papyrus_p2p_sync::client::{P2PSyncClient, P2PSyncClientConfig}; #[cfg(feature = "rpc")] use papyrus_rpc::RpcConfig; -use papyrus_storage::db::DbConfig; use papyrus_storage::StorageConfig; -use papyrus_sync::sources::central::CentralSourceConfig; +use papyrus_storage::db::DbConfig; use papyrus_sync::SyncConfig; +use papyrus_sync::sources::central::CentralSourceConfig; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; use starknet_api::core::ChainId; diff --git a/crates/papyrus_node/src/main.rs b/crates/papyrus_node/src/main.rs index 7bf3fef898..84798eb156 100644 --- a/crates/papyrus_node/src/main.rs +++ b/crates/papyrus_node/src/main.rs @@ -2,20 +2,20 @@ mod main_test; use std::env::args; -use std::future::{pending, Future}; +use std::future::{Future, pending}; use std::process::exit; use std::sync::Arc; use std::time::Duration; -use futures::stream::StreamExt; use futures::FutureExt; +use futures::stream::StreamExt; use papyrus_base_layer::ethereum_base_layer_contract::EthereumBaseLayerConfig; +use papyrus_common::BlockHashAndNumber; use papyrus_common::metrics::COLLECT_PROFILING_METRICS; use papyrus_common::pending_classes::PendingClasses; -use papyrus_common::BlockHashAndNumber; +use papyrus_config::ConfigError; use papyrus_config::presentation::get_config_presentation; use papyrus_config::validators::config_validate; -use papyrus_config::ConfigError; use papyrus_consensus::config::ConsensusConfig; use papyrus_consensus::papyrus_consensus_context::PapyrusConsensusContext; use papyrus_consensus::simulation_network_receiver::NetworkReceiver; @@ -23,7 +23,7 @@ use papyrus_consensus::types::ConsensusError; use papyrus_monitoring_gateway::MonitoringServer; use papyrus_network::gossipsub_impl::Topic; use papyrus_network::network_manager::NetworkManager; -use papyrus_network::{network_manager, NetworkConfig}; +use papyrus_network::{NetworkConfig, network_manager}; use papyrus_node::config::NodeConfig; use papyrus_node::version::VERSION_FULL; use papyrus_p2p_sync::client::{ @@ -33,24 +33,24 @@ use papyrus_p2p_sync::client::{ P2PSyncClientError, }; use papyrus_p2p_sync::server::{P2PSyncServer, P2PSyncServerChannels}; -use papyrus_p2p_sync::{Protocol, BUFFER_SIZE}; +use papyrus_p2p_sync::{BUFFER_SIZE, Protocol}; #[cfg(feature = "rpc")] use papyrus_rpc::run_server; -use papyrus_storage::{open_storage, update_storage_metrics, StorageReader, StorageWriter}; +use papyrus_storage::{StorageReader, StorageWriter, open_storage, update_storage_metrics}; use papyrus_sync::sources::base_layer::{BaseLayerSourceError, EthereumBaseLayerSource}; use papyrus_sync::sources::central::{CentralError, CentralSource, CentralSourceConfig}; use papyrus_sync::sources::pending::PendingSource; use papyrus_sync::{StateSync, StateSyncError, SyncConfig}; use starknet_api::block::{BlockHash, BlockNumber}; use starknet_api::felt; -use starknet_client::reader::objects::pending_data::{PendingBlock, PendingBlockOrDeprecated}; use starknet_client::reader::PendingData; +use starknet_client::reader::objects::pending_data::{PendingBlock, PendingBlockOrDeprecated}; use tokio::sync::RwLock; use tokio::task::{JoinError, JoinHandle}; use tracing::metadata::LevelFilter; -use tracing::{debug, debug_span, error, info, warn, Instrument}; +use tracing::{Instrument, debug, debug_span, error, info, warn}; use tracing_subscriber::prelude::*; -use tracing_subscriber::{fmt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt}; // TODO(yair): Add to config. const DEFAULT_LEVEL: LevelFilter = LevelFilter::INFO; diff --git a/crates/papyrus_node/src/main_test.rs b/crates/papyrus_node/src/main_test.rs index 80a07421e9..46ef8f4f5b 100644 --- a/crates/papyrus_node/src/main_test.rs +++ b/crates/papyrus_node/src/main_test.rs @@ -2,7 +2,7 @@ use std::time::Duration; use metrics_exporter_prometheus::PrometheusBuilder; use papyrus_node::config::NodeConfig; -use papyrus_storage::{open_storage, StorageConfig}; +use papyrus_storage::{StorageConfig, open_storage}; use papyrus_test_utils::prometheus_is_contained; use tempfile::TempDir; diff --git a/crates/papyrus_p2p_sync/src/client/header.rs b/crates/papyrus_p2p_sync/src/client/header.rs index 87964116b7..0501e40658 100644 --- a/crates/papyrus_p2p_sync/src/client/header.rs +++ b/crates/papyrus_p2p_sync/src/client/header.rs @@ -11,7 +11,7 @@ use starknet_api::block::BlockNumber; use tracing::debug; use super::stream_builder::{BlockData, BlockNumberLimit, DataStreamBuilder}; -use super::{P2PSyncClientError, ALLOWED_SIGNATURES_LENGTH, NETWORK_DATA_TIMEOUT}; +use super::{ALLOWED_SIGNATURES_LENGTH, NETWORK_DATA_TIMEOUT, P2PSyncClientError}; impl BlockData for SignedBlockHeader { fn write_to_storage( diff --git a/crates/papyrus_p2p_sync/src/client/header_test.rs b/crates/papyrus_p2p_sync/src/client/header_test.rs index 668a8e601d..db6e53672d 100644 --- a/crates/papyrus_p2p_sync/src/client/header_test.rs +++ b/crates/papyrus_p2p_sync/src/client/header_test.rs @@ -12,13 +12,13 @@ use starknet_api::block::{BlockHeader, BlockNumber}; use tokio::time::timeout; use super::test_utils::{ - create_block_hashes_and_signatures, - setup, - TestArgs, HEADER_QUERY_LENGTH, SLEEP_DURATION_TO_LET_SYNC_ADVANCE, TIMEOUT_FOR_NEW_QUERY_AFTER_PARTIAL_RESPONSE, + TestArgs, WAIT_PERIOD_FOR_NEW_DATA, + create_block_hashes_and_signatures, + setup, }; #[tokio::test] diff --git a/crates/papyrus_p2p_sync/src/client/mod.rs b/crates/papyrus_p2p_sync/src/client/mod.rs index 06b3ecdf7f..cea0353b00 100644 --- a/crates/papyrus_p2p_sync/src/client/mod.rs +++ b/crates/papyrus_p2p_sync/src/client/mod.rs @@ -12,11 +12,11 @@ mod transaction; use std::collections::BTreeMap; use std::time::Duration; -use futures::channel::mpsc::SendError; use futures::Stream; +use futures::channel::mpsc::SendError; use header::HeaderStreamBuilder; use papyrus_config::converters::deserialize_seconds_to_duration; -use papyrus_config::dumping::{ser_optional_param, ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, ser_optional_param, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use papyrus_network::network_manager::SqmrClientSender; use papyrus_protobuf::converters::ProtobufConversionError; diff --git a/crates/papyrus_p2p_sync/src/client/state_diff.rs b/crates/papyrus_p2p_sync/src/client/state_diff.rs index e682ddec71..7fc4076e5f 100644 --- a/crates/papyrus_p2p_sync/src/client/state_diff.rs +++ b/crates/papyrus_p2p_sync/src/client/state_diff.rs @@ -14,7 +14,7 @@ use starknet_api::block::BlockNumber; use starknet_api::state::ThinStateDiff; use crate::client::stream_builder::{BlockData, BlockNumberLimit, DataStreamBuilder}; -use crate::client::{P2PSyncClientError, NETWORK_DATA_TIMEOUT}; +use crate::client::{NETWORK_DATA_TIMEOUT, P2PSyncClientError}; impl BlockData for (ThinStateDiff, BlockNumber) { #[latency_histogram("p2p_sync_state_diff_write_to_storage_latency_seconds", true)] diff --git a/crates/papyrus_p2p_sync/src/client/state_diff_test.rs b/crates/papyrus_p2p_sync/src/client/state_diff_test.rs index acc76333cb..e7c97b9a17 100644 --- a/crates/papyrus_p2p_sync/src/client/state_diff_test.rs +++ b/crates/papyrus_p2p_sync/src/client/state_diff_test.rs @@ -15,7 +15,7 @@ use papyrus_protobuf::sync::{ StateDiffChunk, }; use papyrus_storage::state::StateStorageReader; -use papyrus_test_utils::{get_rng, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, get_rng}; use rand::RngCore; use rand_chacha::ChaCha8Rng; use starknet_api::block::{BlockHeader, BlockNumber}; @@ -25,13 +25,13 @@ use starknet_types_core::felt::Felt; use static_assertions::const_assert; use super::test_utils::{ - create_block_hashes_and_signatures, - setup, - TestArgs, HEADER_QUERY_LENGTH, SLEEP_DURATION_TO_LET_SYNC_ADVANCE, STATE_DIFF_QUERY_LENGTH, + TestArgs, WAIT_PERIOD_FOR_NEW_DATA, + create_block_hashes_and_signatures, + setup, }; use super::{P2PSyncClientError, StateDiffQuery}; diff --git a/crates/papyrus_p2p_sync/src/client/stream_builder.rs b/crates/papyrus_p2p_sync/src/client/stream_builder.rs index a7cd2cfa31..2784eb639c 100644 --- a/crates/papyrus_p2p_sync/src/client/stream_builder.rs +++ b/crates/papyrus_p2p_sync/src/client/stream_builder.rs @@ -2,9 +2,9 @@ use std::cmp::min; use std::time::Duration; use async_stream::stream; +use futures::StreamExt; use futures::future::BoxFuture; use futures::stream::BoxStream; -use futures::StreamExt; use papyrus_network::network_manager::{ClientResponsesManager, SqmrClientSender}; use papyrus_protobuf::converters::ProtobufConversionError; use papyrus_protobuf::sync::{BlockHashOrNumber, DataOrFin, Direction, Query}; diff --git a/crates/papyrus_p2p_sync/src/client/test_utils.rs b/crates/papyrus_p2p_sync/src/client/test_utils.rs index 74a0c98317..edd746b2be 100644 --- a/crates/papyrus_p2p_sync/src/client/test_utils.rs +++ b/crates/papyrus_p2p_sync/src/client/test_utils.rs @@ -1,11 +1,11 @@ use std::time::Duration; use lazy_static::lazy_static; +use papyrus_network::network_manager::GenericReceiver; use papyrus_network::network_manager::test_utils::{ - mock_register_sqmr_protocol_client, MockClientResponsesManager, + mock_register_sqmr_protocol_client, }; -use papyrus_network::network_manager::GenericReceiver; use papyrus_protobuf::sync::{ DataOrFin, HeaderQuery, @@ -14,8 +14,8 @@ use papyrus_protobuf::sync::{ StateDiffQuery, TransactionQuery, }; -use papyrus_storage::test_utils::get_test_storage; use papyrus_storage::StorageReader; +use papyrus_storage::test_utils::get_test_storage; use starknet_api::block::{BlockHash, BlockSignature}; use starknet_api::crypto::utils::Signature; use starknet_api::hash::StarkHash; diff --git a/crates/papyrus_p2p_sync/src/client/transaction.rs b/crates/papyrus_p2p_sync/src/client/transaction.rs index 69589c2009..5084ba5391 100644 --- a/crates/papyrus_p2p_sync/src/client/transaction.rs +++ b/crates/papyrus_p2p_sync/src/client/transaction.rs @@ -9,7 +9,7 @@ use starknet_api::block::{BlockBody, BlockNumber}; use starknet_api::transaction::FullTransaction; use super::stream_builder::{BlockData, BlockNumberLimit, DataStreamBuilder}; -use super::{P2PSyncClientError, NETWORK_DATA_TIMEOUT}; +use super::{NETWORK_DATA_TIMEOUT, P2PSyncClientError}; impl BlockData for (BlockBody, BlockNumber) { fn write_to_storage( diff --git a/crates/papyrus_p2p_sync/src/server/mod.rs b/crates/papyrus_p2p_sync/src/server/mod.rs index 205a10239a..ec139e620d 100644 --- a/crates/papyrus_p2p_sync/src/server/mod.rs +++ b/crates/papyrus_p2p_sync/src/server/mod.rs @@ -23,7 +23,7 @@ use papyrus_storage::body::BodyStorageReader; use papyrus_storage::class::ClassStorageReader; use papyrus_storage::header::HeaderStorageReader; use papyrus_storage::state::StateStorageReader; -use papyrus_storage::{db, StorageReader, StorageTxn}; +use papyrus_storage::{StorageReader, StorageTxn, db}; use starknet_api::block::BlockNumber; use starknet_api::core::ClassHash; use starknet_api::state::ThinStateDiff; diff --git a/crates/papyrus_p2p_sync/src/server/test.rs b/crates/papyrus_p2p_sync/src/server/test.rs index ce39d53e76..cccad321e2 100644 --- a/crates/papyrus_p2p_sync/src/server/test.rs +++ b/crates/papyrus_p2p_sync/src/server/test.rs @@ -1,15 +1,15 @@ use std::fmt::Debug; -use futures::channel::mpsc::Sender; use futures::StreamExt; +use futures::channel::mpsc::Sender; use lazy_static::lazy_static; use papyrus_common::pending_classes::ApiContractClass; use papyrus_common::state::create_random_state_diff; +use papyrus_network::network_manager::ServerQueryManager; use papyrus_network::network_manager::test_utils::{ create_test_server_query_manager, mock_register_sqmr_protocol_server, }; -use papyrus_network::network_manager::ServerQueryManager; use papyrus_protobuf::converters::ProtobufConversionError; use papyrus_protobuf::sync::{ BlockHashOrNumber, @@ -30,7 +30,7 @@ use papyrus_storage::header::{HeaderStorageReader, HeaderStorageWriter}; use papyrus_storage::state::StateStorageWriter; use papyrus_storage::test_utils::get_test_storage; use papyrus_storage::{StorageReader, StorageWriter}; -use papyrus_test_utils::{get_rng, get_test_body, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, get_rng, get_test_body}; use rand::random; use starknet_api::block::{BlockBody, BlockHash, BlockHeader, BlockNumber, BlockSignature}; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; @@ -43,7 +43,7 @@ use starknet_api::transaction::{ TransactionOutput, }; -use super::{split_thin_state_diff, FetchBlockDataFromDb, P2PSyncServer, P2PSyncServerChannels}; +use super::{FetchBlockDataFromDb, P2PSyncServer, P2PSyncServerChannels, split_thin_state_diff}; use crate::server::register_query; const BUFFER_SIZE: usize = 10; const NUM_OF_BLOCKS: u64 = 10; diff --git a/crates/papyrus_proc_macros/src/lib.rs b/crates/papyrus_proc_macros/src/lib.rs index b04ef485fa..21e00b0296 100644 --- a/crates/papyrus_proc_macros/src/lib.rs +++ b/crates/papyrus_proc_macros/src/lib.rs @@ -1,10 +1,9 @@ use std::str::FromStr; use proc_macro::TokenStream; -use quote::{quote, ToTokens}; +use quote::{ToTokens, quote}; use syn::parse::{Parse, ParseStream, Result}; use syn::{ - parse_macro_input, ExprLit, Ident, ItemFn, @@ -14,6 +13,7 @@ use syn::{ Meta, Token, TraitItem, + parse_macro_input, }; /// This macro is a wrapper around the "rpc" macro supplied by the jsonrpsee library that generates diff --git a/crates/papyrus_protobuf/src/converters/class.rs b/crates/papyrus_protobuf/src/converters/class.rs index 596501ae42..27cdcb2617 100644 --- a/crates/papyrus_protobuf/src/converters/class.rs +++ b/crates/papyrus_protobuf/src/converters/class.rs @@ -8,8 +8,8 @@ use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::{deprecated_contract_class, state}; use starknet_types_core::felt::Felt; -use super::common::volition_domain_to_enum_int; use super::ProtobufConversionError; +use super::common::volition_domain_to_enum_int; use crate::sync::{ClassQuery, DataOrFin, Query}; use crate::{auto_impl_into_and_try_from_vec_u8, protobuf}; diff --git a/crates/papyrus_protobuf/src/converters/event_test.rs b/crates/papyrus_protobuf/src/converters/event_test.rs index 4a0a3cce58..13dcec0180 100644 --- a/crates/papyrus_protobuf/src/converters/event_test.rs +++ b/crates/papyrus_protobuf/src/converters/event_test.rs @@ -1,4 +1,4 @@ -use papyrus_test_utils::{get_rng, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, get_rng}; use starknet_api::transaction::{Event, TransactionHash}; use crate::sync::DataOrFin; diff --git a/crates/papyrus_protobuf/src/converters/header.rs b/crates/papyrus_protobuf/src/converters/header.rs index d5175c7df1..a5618ed7fb 100644 --- a/crates/papyrus_protobuf/src/converters/header.rs +++ b/crates/papyrus_protobuf/src/converters/header.rs @@ -23,8 +23,8 @@ use starknet_api::core::{ use starknet_api::crypto::utils::Signature; use starknet_api::hash::PoseidonHash; -use super::common::{enum_int_to_l1_data_availability_mode, l1_data_availability_mode_to_enum_int}; use super::ProtobufConversionError; +use super::common::{enum_int_to_l1_data_availability_mode, l1_data_availability_mode_to_enum_int}; use crate::sync::{DataOrFin, HeaderQuery, Query, SignedBlockHeader}; use crate::{auto_impl_into_and_try_from_vec_u8, protobuf}; diff --git a/crates/papyrus_protobuf/src/converters/header_test.rs b/crates/papyrus_protobuf/src/converters/header_test.rs index 4afa000486..8e99eb364c 100644 --- a/crates/papyrus_protobuf/src/converters/header_test.rs +++ b/crates/papyrus_protobuf/src/converters/header_test.rs @@ -1,4 +1,4 @@ -use papyrus_test_utils::{get_rng, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, get_rng}; use crate::sync::{DataOrFin, HeaderQuery, SignedBlockHeader}; diff --git a/crates/papyrus_protobuf/src/converters/receipt.rs b/crates/papyrus_protobuf/src/converters/receipt.rs index f7be5423b1..3211a1c96a 100644 --- a/crates/papyrus_protobuf/src/converters/receipt.rs +++ b/crates/papyrus_protobuf/src/converters/receipt.rs @@ -17,8 +17,8 @@ use starknet_api::transaction::{ }; use starknet_types_core::felt::Felt; -use super::common::try_from_starkfelt_to_u128; use super::ProtobufConversionError; +use super::common::try_from_starkfelt_to_u128; use crate::protobuf; impl TryFrom for TransactionOutput { diff --git a/crates/papyrus_protobuf/src/converters/state_diff.rs b/crates/papyrus_protobuf/src/converters/state_diff.rs index 070d85cc82..a645522c91 100644 --- a/crates/papyrus_protobuf/src/converters/state_diff.rs +++ b/crates/papyrus_protobuf/src/converters/state_diff.rs @@ -8,8 +8,8 @@ use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::state::{StorageKey, ThinStateDiff}; use starknet_types_core::felt::Felt; -use super::common::volition_domain_to_enum_int; use super::ProtobufConversionError; +use super::common::volition_domain_to_enum_int; use crate::sync::{ ContractDiff, DataOrFin, diff --git a/crates/papyrus_protobuf/src/converters/state_diff_test.rs b/crates/papyrus_protobuf/src/converters/state_diff_test.rs index 3cc84b420b..74c8d94b86 100644 --- a/crates/papyrus_protobuf/src/converters/state_diff_test.rs +++ b/crates/papyrus_protobuf/src/converters/state_diff_test.rs @@ -1,4 +1,4 @@ -use papyrus_test_utils::{get_rng, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, get_rng}; use crate::sync::{ ContractDiff, diff --git a/crates/papyrus_protobuf/src/converters/transaction.rs b/crates/papyrus_protobuf/src/converters/transaction.rs index a929942c1a..64b69bb80d 100644 --- a/crates/papyrus_protobuf/src/converters/transaction.rs +++ b/crates/papyrus_protobuf/src/converters/transaction.rs @@ -37,13 +37,13 @@ use starknet_api::transaction::{ }; use starknet_types_core::felt::Felt; +use super::ProtobufConversionError; use super::common::{ enum_int_to_volition_domain, - try_from_starkfelt_to_u128, try_from_starkfelt_to_u32, + try_from_starkfelt_to_u128, volition_domain_to_enum_int, }; -use super::ProtobufConversionError; use crate::sync::{DataOrFin, Query, TransactionQuery}; use crate::{auto_impl_into_and_try_from_vec_u8, protobuf}; diff --git a/crates/papyrus_protobuf/src/converters/transaction_test.rs b/crates/papyrus_protobuf/src/converters/transaction_test.rs index 82387f1539..bfad5ce8e8 100644 --- a/crates/papyrus_protobuf/src/converters/transaction_test.rs +++ b/crates/papyrus_protobuf/src/converters/transaction_test.rs @@ -1,5 +1,5 @@ use lazy_static::lazy_static; -use papyrus_test_utils::{get_rng, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, get_rng}; use rand::random; use starknet_api::execution_resources::{Builtin, ExecutionResources, GasVector}; use starknet_api::transaction::{ diff --git a/crates/papyrus_protobuf/src/sync.rs b/crates/papyrus_protobuf/src/sync.rs index cd6a20d23f..e0eab1d3a1 100644 --- a/crates/papyrus_protobuf/src/sync.rs +++ b/crates/papyrus_protobuf/src/sync.rs @@ -2,7 +2,7 @@ use std::fmt::Debug; use indexmap::IndexMap; #[cfg(any(feature = "testing", test))] -use papyrus_test_utils::{auto_impl_get_test_instance, get_number_of_variants, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, auto_impl_get_test_instance, get_number_of_variants}; use starknet_api::block::{BlockHash, BlockHeader, BlockNumber, BlockSignature}; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::state::StorageKey; diff --git a/crates/papyrus_rpc/src/api.rs b/crates/papyrus_rpc/src/api.rs index d26e9edb36..16f81c2ddf 100644 --- a/crates/papyrus_rpc/src/api.rs +++ b/crates/papyrus_rpc/src/api.rs @@ -1,8 +1,8 @@ use std::sync::Arc; use jsonrpsee::{Methods, RpcModule}; -use papyrus_common::pending_classes::PendingClasses; use papyrus_common::BlockHashAndNumber; +use papyrus_common::pending_classes::PendingClasses; use papyrus_execution::ExecutionConfig; use papyrus_storage::StorageReader; use serde::{Deserialize, Serialize}; diff --git a/crates/papyrus_rpc/src/lib.rs b/crates/papyrus_rpc/src/lib.rs index b62ec8f966..abcfc22d5c 100644 --- a/crates/papyrus_rpc/src/lib.rs +++ b/crates/papyrus_rpc/src/lib.rs @@ -23,13 +23,13 @@ use std::sync::Arc; use jsonrpsee::core::RpcResult; use jsonrpsee::server::{ServerBuilder, ServerHandle}; +use jsonrpsee::types::ErrorObjectOwned; use jsonrpsee::types::error::ErrorCode::InternalError; use jsonrpsee::types::error::INTERNAL_ERROR_MSG; -use jsonrpsee::types::ErrorObjectOwned; pub use latest::error; -use papyrus_common::pending_classes::PendingClasses; use papyrus_common::BlockHashAndNumber; -use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig}; +use papyrus_common::pending_classes::PendingClasses; +use papyrus_config::dumping::{SerializeConfig, append_sub_config_name, ser_param}; use papyrus_config::validators::validate_ascii; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use papyrus_execution::ExecutionConfig; @@ -42,9 +42,9 @@ use rpc_metrics::MetricLogger; use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockNumber, BlockStatus}; use starknet_api::core::ChainId; +use starknet_client::RetryConfig; use starknet_client::reader::PendingData; use starknet_client::writer::StarknetGatewayClient; -use starknet_client::RetryConfig; use tokio::sync::RwLock; use tracing::{debug, error, info, instrument}; // Aliasing the latest version of the RPC. diff --git a/crates/papyrus_rpc/src/middleware.rs b/crates/papyrus_rpc/src/middleware.rs index 9489fffc56..be8654c16c 100644 --- a/crates/papyrus_rpc/src/middleware.rs +++ b/crates/papyrus_rpc/src/middleware.rs @@ -4,8 +4,8 @@ use regex::Regex; use tower::BoxError; use tracing::{debug, instrument}; -use crate::version_config::{VersionState, VERSION_CONFIG, VERSION_PATTERN}; use crate::SERVER_MAX_BODY_SIZE; +use crate::version_config::{VERSION_CONFIG, VERSION_PATTERN, VersionState}; /// [`Tower`] middleware intended to proxy method requests to the right version of the API. /// The middleware reads the JsonRPC request body and request path diff --git a/crates/papyrus_rpc/src/rpc_metrics/mod.rs b/crates/papyrus_rpc/src/rpc_metrics/mod.rs index a5098f80e9..79dec77b17 100644 --- a/crates/papyrus_rpc/src/rpc_metrics/mod.rs +++ b/crates/papyrus_rpc/src/rpc_metrics/mod.rs @@ -5,9 +5,9 @@ use std::collections::HashSet; use std::net::SocketAddr; use std::time::Instant; +use jsonrpsee::Methods; use jsonrpsee::server::logger::{HttpRequest, Logger, MethodKind, TransportProtocol}; use jsonrpsee::types::Params; -use jsonrpsee::Methods; use metrics::{histogram, increment_counter, register_counter, register_histogram}; // Name of the metrics. diff --git a/crates/papyrus_rpc/src/rpc_metrics/rpc_metrics_test.rs b/crates/papyrus_rpc/src/rpc_metrics/rpc_metrics_test.rs index caa153af0b..a26e6d65fc 100644 --- a/crates/papyrus_rpc/src/rpc_metrics/rpc_metrics_test.rs +++ b/crates/papyrus_rpc/src/rpc_metrics/rpc_metrics_test.rs @@ -1,8 +1,8 @@ use std::sync::Arc; use std::time::Instant; -use jsonrpsee::server::logger::{Logger, TransportProtocol}; use jsonrpsee::Methods; +use jsonrpsee::server::logger::{Logger, TransportProtocol}; use metrics_exporter_prometheus::PrometheusBuilder; use papyrus_storage::body::BodyStorageWriter; use papyrus_storage::class::ClassStorageWriter; @@ -16,13 +16,13 @@ use starknet_api::block::{BlockBody, BlockHeader, BlockNumber}; use starknet_api::state::ThinStateDiff; use crate::rpc_metrics::{ - get_method_and_version, - MetricLogger, FAILED_REQUESTS, ILLEGAL_METHOD, INCOMING_REQUEST, METHOD_LABEL, + MetricLogger, VERSION_LABEL, + get_method_and_version, }; use crate::run_server; use crate::test_utils::{ diff --git a/crates/papyrus_rpc/src/rpc_test.rs b/crates/papyrus_rpc/src/rpc_test.rs index a4249a956e..76899b37ea 100644 --- a/crates/papyrus_rpc/src/rpc_test.rs +++ b/crates/papyrus_rpc/src/rpc_test.rs @@ -3,7 +3,7 @@ use std::{panic, vec}; use assert_matches::assert_matches; use futures_util::future::join_all; -use hyper::{header, Body, Request}; +use hyper::{Body, Request, header}; use jsonrpsee::core::client::ClientT; use jsonrpsee::core::http_helpers::read_body; use jsonrpsee::core::{Error, RpcResult}; @@ -26,7 +26,7 @@ use crate::test_utils::{ get_test_rpc_config, }; use crate::version_config::VERSION_CONFIG; -use crate::{get_block_status, run_server, SERVER_MAX_BODY_SIZE}; +use crate::{SERVER_MAX_BODY_SIZE, get_block_status, run_server}; #[tokio::test] async fn run_server_no_blocks() { diff --git a/crates/papyrus_rpc/src/test_utils.rs b/crates/papyrus_rpc/src/test_utils.rs index cba4502ac4..1e4917f412 100644 --- a/crates/papyrus_rpc/src/test_utils.rs +++ b/crates/papyrus_rpc/src/test_utils.rs @@ -6,8 +6,8 @@ use jsonrpsee::core::RpcResult; use jsonrpsee::server::RpcModule; use jsonrpsee::types::ErrorObjectOwned; use jsonschema::JSONSchema; -use papyrus_common::pending_classes::PendingClasses; use papyrus_common::BlockHashAndNumber; +use papyrus_common::pending_classes::PendingClasses; use papyrus_execution::ExecutionConfig; use papyrus_storage::test_utils::get_test_storage_by_scope; use papyrus_storage::{StorageScope, StorageWriter}; @@ -23,9 +23,9 @@ use strum::IntoEnumIterator; use strum_macros::EnumIter; use tokio::sync::RwLock; -use crate::api::JsonRpcServerTrait; -use crate::version_config::{VersionId, VERSION_PATTERN}; use crate::RpcConfig; +use crate::api::JsonRpcServerTrait; +use crate::version_config::{VERSION_PATTERN, VersionId}; pub fn get_test_rpc_config() -> RpcConfig { RpcConfig { diff --git a/crates/papyrus_rpc/src/v0_6/api/api_impl.rs b/crates/papyrus_rpc/src/v0_6/api/api_impl.rs index 8a91b6aad8..c4367c89db 100644 --- a/crates/papyrus_rpc/src/v0_6/api/api_impl.rs +++ b/crates/papyrus_rpc/src/v0_6/api/api_impl.rs @@ -1,9 +1,9 @@ use std::sync::Arc; use async_trait::async_trait; +use jsonrpsee::RpcModule; use jsonrpsee::core::RpcResult; use jsonrpsee::types::ErrorObjectOwned; -use jsonrpsee::RpcModule; use lazy_static::lazy_static; use papyrus_common::pending_classes::{PendingClasses, PendingClassesTrait}; use papyrus_execution::objects::{ @@ -11,12 +11,12 @@ use papyrus_execution::objects::{ PendingData as ExecutionPendingData, }; use papyrus_execution::{ + ExecutableTransactionInput, + ExecutionConfig, estimate_fee as exec_estimate_fee, execute_call, execution_utils, simulate_transactions as exec_simulate_transactions, - ExecutableTransactionInput, - ExecutionConfig, }; use papyrus_storage::body::events::{EventIndex, EventsReader}; use papyrus_storage::body::{BodyStorageReader, TransactionIndex}; @@ -35,51 +35,49 @@ use starknet_api::transaction::{ TransactionHash, TransactionOffsetInBlock, }; +use starknet_client::ClientError; +use starknet_client::reader::PendingData; use starknet_client::reader::objects::pending_data::{ DeprecatedPendingBlock, PendingBlockOrDeprecated, PendingStateUpdate as ClientPendingStateUpdate, }; -use starknet_client::reader::PendingData; use starknet_client::writer::{StarknetWriter, WriterClientError}; -use starknet_client::ClientError; use starknet_types_core::felt::Felt; use tokio::sync::RwLock; use tracing::{instrument, trace, warn}; use super::super::block::{ - get_accepted_block_number, - get_block_header_by_number, Block, BlockHeader, BlockNotRevertedValidator, GeneralBlockHeader, PendingBlockHeader, ResourcePrice, + get_accepted_block_number, + get_block_header_by_number, }; use super::super::broadcasted_transaction::{ BroadcastedDeclareTransaction, BroadcastedTransaction, }; use super::super::error::{ - ContractError, - JsonRpcError, - TransactionExecutionError, BLOCK_NOT_FOUND, CLASS_HASH_NOT_FOUND, CONTRACT_NOT_FOUND, + ContractError, INVALID_TRANSACTION_HASH, INVALID_TRANSACTION_INDEX, + JsonRpcError, NO_BLOCKS, PAGE_SIZE_TOO_BIG, TOO_MANY_KEYS_IN_FILTER, TRANSACTION_HASH_NOT_FOUND, + TransactionExecutionError, }; use super::super::execution::TransactionTrace; use super::super::state::{AcceptedStateUpdate, PendingStateUpdate, StateUpdate}; use super::super::transaction::{ - get_block_tx_hashes_by_number, - get_block_txs_by_number, Event, GeneralTransactionReceipt, L1HandlerMsgHash, @@ -94,6 +92,8 @@ use super::super::transaction::{ Transactions, TypedDeployAccountTransaction, TypedInvokeTransaction, + get_block_tx_hashes_by_number, + get_block_txs_by_number, }; use super::super::write_api_error::{ starknet_error_to_declare_error, @@ -106,8 +106,6 @@ use super::super::write_api_result::{ AddInvokeOkResult, }; use super::{ - execution_error_to_error_object_owned, - stored_txn_to_executable_txn, BlockHashAndNumber, BlockId, CallRequest, @@ -120,18 +118,20 @@ use super::{ SimulatedTransaction, SimulationFlag, TransactionTraceWithHash, + execution_error_to_error_object_owned, + stored_txn_to_executable_txn, }; use crate::api::{BlockHashOrNumber, JsonRpcServerTrait, Tag}; use crate::pending::client_pending_data_to_execution_pending_data; -use crate::syncing_state::{get_last_synced_block, SyncStatus, SyncingState}; +use crate::syncing_state::{SyncStatus, SyncingState, get_last_synced_block}; use crate::version_config::VERSION_0_6 as VERSION; use crate::{ + ContinuationTokenAsStruct, + GENESIS_HASH, get_block_status, get_latest_block_number, internal_server_error, verify_storage_scope, - ContinuationTokenAsStruct, - GENESIS_HASH, }; const IGNORE_L1_DA_MODE: bool = true; diff --git a/crates/papyrus_rpc/src/v0_6/api/mod.rs b/crates/papyrus_rpc/src/v0_6/api/mod.rs index 6c20c3db50..355b0d1b4d 100644 --- a/crates/papyrus_rpc/src/v0_6/api/mod.rs +++ b/crates/papyrus_rpc/src/v0_6/api/mod.rs @@ -5,17 +5,17 @@ use flate2::bufread::GzDecoder; use jsonrpsee::core::RpcResult; use jsonrpsee::proc_macros::rpc; use jsonrpsee::types::ErrorObjectOwned; +use papyrus_common::BlockHashAndNumber; use papyrus_common::deprecated_class_abi::calculate_deprecated_class_abi_length; use papyrus_common::pending_classes::ApiContractClass; -use papyrus_common::BlockHashAndNumber; use papyrus_execution::objects::PriceUnit; use papyrus_execution::{AbiSize, ExecutableTransactionInput, ExecutionError, SierraSize}; use papyrus_proc_macros::versioned_rpc; +use papyrus_storage::StorageTxn; use papyrus_storage::compiled_class::CasmStorageReader; -use papyrus_storage::db::serialization::StorageSerdeError; use papyrus_storage::db::RO; +use papyrus_storage::db::serialization::StorageSerdeError; use papyrus_storage::state::StateStorageReader; -use papyrus_storage::StorageTxn; use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockNumber, GasPrice}; use starknet_api::core::{ClassHash, ContractAddress, Nonce}; @@ -33,11 +33,11 @@ use super::broadcasted_transaction::{ }; use super::deprecated_contract_class::ContractClass as DeprecatedContractClass; use super::error::{ - ContractError, - JsonRpcError, BLOCK_NOT_FOUND, CONTRACT_NOT_FOUND, + ContractError, INVALID_CONTINUATION_TOKEN, + JsonRpcError, }; use super::execution::TransactionTrace; use super::state::{ContractClass, StateUpdate}; @@ -60,7 +60,7 @@ use super::transaction::{ use super::write_api_result::{AddDeclareOkResult, AddDeployAccountOkResult, AddInvokeOkResult}; use crate::api::{BlockId, CallRequest}; use crate::syncing_state::SyncingState; -use crate::{internal_server_error, ContinuationTokenAsStruct}; +use crate::{ContinuationTokenAsStruct, internal_server_error}; pub mod api_impl; #[cfg(test)] diff --git a/crates/papyrus_rpc/src/v0_6/api/test.rs b/crates/papyrus_rpc/src/v0_6/api/test.rs index 94f4ae69e0..c74e1dae0b 100644 --- a/crates/papyrus_rpc/src/v0_6/api/test.rs +++ b/crates/papyrus_rpc/src/v0_6/api/test.rs @@ -6,15 +6,16 @@ use std::ops::Index; use assert_matches::assert_matches; use async_trait::async_trait; -use indexmap::{indexmap, IndexMap}; +use indexmap::{IndexMap, indexmap}; use itertools::Itertools; -use jsonrpsee::core::Error; use jsonrpsee::Methods; +use jsonrpsee::core::Error; use jsonschema::JSONSchema; use lazy_static::lazy_static; use mockall::predicate::eq; -use papyrus_common::pending_classes::{ApiContractClass, PendingClassesTrait}; use papyrus_common::BlockHashAndNumber; +use papyrus_common::pending_classes::{ApiContractClass, PendingClassesTrait}; +use papyrus_storage::StorageScope; use papyrus_storage::base_layer::BaseLayerStorageWriter; use papyrus_storage::body::events::EventIndex; use papyrus_storage::body::{BodyStorageWriter, TransactionIndex}; @@ -22,8 +23,8 @@ use papyrus_storage::class::ClassStorageWriter; use papyrus_storage::header::HeaderStorageWriter; use papyrus_storage::state::StateStorageWriter; use papyrus_storage::test_utils::get_test_storage; -use papyrus_storage::StorageScope; use papyrus_test_utils::{ + GetTestInstance, auto_impl_get_test_instance, get_number_of_variants, get_rng, @@ -31,10 +32,9 @@ use papyrus_test_utils::{ get_test_body, get_test_state_diff, send_request, - GetTestInstance, }; use pretty_assertions::assert_eq; -use rand::{random, RngCore}; +use rand::{RngCore, random}; use rand_chacha::ChaCha8Rng; use reqwest::StatusCode; use serde::{Deserialize, Serialize}; @@ -76,6 +76,7 @@ use starknet_api::transaction::{ TransactionOutput as StarknetApiTransactionOutput, }; use starknet_api::{felt, patricia_key}; +use starknet_client::ClientError; use starknet_client::reader::objects::pending_data::{ DeprecatedPendingBlock, PendingBlockOrDeprecated, @@ -104,7 +105,6 @@ use starknet_client::writer::objects::transaction::{ InvokeTransaction as ClientInvokeTransaction, }; use starknet_client::writer::{MockStarknetWriter, WriterClientError, WriterClientResult}; -use starknet_client::ClientError; use starknet_types_core::felt::Felt; use super::super::api::EventsChunk; @@ -112,8 +112,6 @@ use super::super::block::{Block, GeneralBlockHeader, PendingBlockHeader, Resourc use super::super::broadcasted_transaction::BroadcastedDeclareTransaction; use super::super::deprecated_contract_class::ContractClass as DeprecatedContractClass; use super::super::error::{ - unexpected_error, - JsonRpcError, BLOCK_NOT_FOUND, CLASS_HASH_NOT_FOUND, COMPILATION_FAILED, @@ -121,10 +119,12 @@ use super::super::error::{ DUPLICATE_TX, INVALID_CONTINUATION_TOKEN, INVALID_TRANSACTION_INDEX, + JsonRpcError, NO_BLOCKS, PAGE_SIZE_TOO_BIG, TOO_MANY_KEYS_IN_FILTER, TRANSACTION_HASH_NOT_FOUND, + unexpected_error, }; use super::super::state::{ AcceptedStateUpdate, @@ -163,11 +163,12 @@ use super::super::write_api_result::{ AddDeployAccountOkResult, AddInvokeOkResult, }; -use super::api_impl::{JsonRpcServerImpl, BLOCK_HASH_TABLE_ADDRESS}; +use super::api_impl::{BLOCK_HASH_TABLE_ADDRESS, JsonRpcServerImpl}; use super::{ContinuationToken, EventFilter, GatewayContractClass}; use crate::api::{BlockHashOrNumber, BlockId, Tag}; use crate::syncing_state::SyncStatus; use crate::test_utils::{ + SpecFile, call_api_then_assert_and_validate_schema_for_err, call_api_then_assert_and_validate_schema_for_result, get_method_names_from_spec, @@ -182,15 +183,14 @@ use crate::test_utils::{ method_name_to_spec_method_name, raw_call, validate_schema, - SpecFile, }; use crate::version_config::VERSION_0_6 as VERSION; use crate::{ + ContinuationTokenAsStruct, + GENESIS_HASH, internal_server_error, internal_server_error_with_msg, run_server, - ContinuationTokenAsStruct, - GENESIS_HASH, }; const NODE_VERSION: &str = "NODE VERSION"; @@ -412,10 +412,9 @@ async fn get_block_transaction_count() { // Get block by number. let res = module - .call::<_, usize>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(block.header.block_number))], - ) + .call::<_, usize>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + block.header.block_number, + ))]) .await .unwrap(); assert_eq!(res, transaction_count); @@ -455,10 +454,9 @@ async fn get_block_transaction_count() { // Ask for an invalid block number. let err = module - .call::<_, usize>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(BlockNumber(1)))], - ) + .call::<_, usize>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + BlockNumber(1), + ))]) .await .unwrap_err(); assert_matches!(err, Error::Call(err) if err == BLOCK_NOT_FOUND.into()); @@ -523,10 +521,9 @@ async fn get_block_w_full_transactions() { // Get block by number. let block = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(expected_block_header.block_number))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + expected_block_header.block_number, + ))]) .await .unwrap(); assert_eq!(block, expected_block); @@ -544,32 +541,27 @@ async fn get_block_w_full_transactions() { .commit() .unwrap(); let block = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Hash(expected_block_header.block_hash))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Hash( + expected_block_header.block_hash, + ))]) .await .unwrap(); assert_eq!(block.status, Some(BlockStatus::AcceptedOnL1)); // Ask for an invalid block hash. let err = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Hash(BlockHash(felt!( - "0x642b629ad8ce233b55798c83bb629a59bf0a0092f67da28d6d66776680d5484" - ))))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Hash(BlockHash( + felt!("0x642b629ad8ce233b55798c83bb629a59bf0a0092f67da28d6d66776680d5484"), + )))]) .await .unwrap_err(); assert_matches!(err, Error::Call(err) if err == BLOCK_NOT_FOUND.into()); // Ask for an invalid block number. let err = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(BlockNumber(1)))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + BlockNumber(1), + ))]) .await .unwrap_err(); assert_matches!(err, Error::Call(err) if err == BLOCK_NOT_FOUND.into()); @@ -692,10 +684,9 @@ async fn get_block_w_transaction_hashes() { // Get block by number. let block = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(expected_block_header.block_number))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + expected_block_header.block_number, + ))]) .await .unwrap(); assert_eq!(block, expected_block); @@ -713,10 +704,9 @@ async fn get_block_w_transaction_hashes() { .commit() .unwrap(); let block = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Hash(expected_block_header.block_hash))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Hash( + expected_block_header.block_hash, + ))]) .await .unwrap(); assert_eq!(block.status, Some(BlockStatus::AcceptedOnL1)); @@ -736,10 +726,9 @@ async fn get_block_w_transaction_hashes() { // Ask for an invalid block number. let err = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(BlockNumber(1)))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + BlockNumber(1), + ))]) .await .unwrap_err(); assert_matches!(err, Error::Call(err) if err == BLOCK_NOT_FOUND.into()); @@ -1020,10 +1009,9 @@ async fn get_transaction_status() { assert_eq!(res.unwrap(), expected_status); assert!(validate_schema( &get_starknet_spec_api_schema_for_method_results( - &[( - SpecFile::StarknetApiOpenrpc, - &[method_name_to_spec_method_name(method_name).as_str()] - )], + &[(SpecFile::StarknetApiOpenrpc, &[ + method_name_to_spec_method_name(method_name).as_str() + ])], &VERSION, ), &json_response["result"], @@ -1054,20 +1042,17 @@ async fn get_transaction_status() { pending_block.transactions_mutable().push(client_transaction.clone()); pending_block.transaction_receipts_mutable().push(client_transaction_receipt.clone()); } - let (json_response, result) = raw_call::<_, _, TransactionStatus>( - &module, - method_name, - &[client_transaction_receipt.transaction_hash], - ) + let (json_response, result) = raw_call::<_, _, TransactionStatus>(&module, method_name, &[ + client_transaction_receipt.transaction_hash, + ]) .await; assert_eq!(result.unwrap(), expected_status); // Validating schema again since pending has a different schema assert!(validate_schema( &get_starknet_spec_api_schema_for_method_results( - &[( - SpecFile::StarknetApiOpenrpc, - &[method_name_to_spec_method_name(method_name).as_str()] - )], + &[(SpecFile::StarknetApiOpenrpc, &[ + method_name_to_spec_method_name(method_name).as_str() + ])], &VERSION, ), &json_response["result"], @@ -1076,11 +1061,9 @@ async fn get_transaction_status() { // Ask for transaction status when the pending block is not up to date. *pending_data.write().await.block.parent_block_hash_mutable() = BlockHash(random::().into()); - let (_, res) = raw_call::<_, _, TransactionStatus>( - &module, - method_name, - &[client_transaction_receipt.transaction_hash], - ) + let (_, res) = raw_call::<_, _, TransactionStatus>(&module, method_name, &[ + client_transaction_receipt.transaction_hash, + ]) .await; assert_eq!(res.unwrap_err(), TRANSACTION_HASH_NOT_FOUND.into()); @@ -1150,10 +1133,9 @@ async fn get_transaction_receipt() { ); assert!(validate_schema( &get_starknet_spec_api_schema_for_method_results( - &[( - SpecFile::StarknetApiOpenrpc, - &[method_name_to_spec_method_name(method_name).as_str()] - )], + &[(SpecFile::StarknetApiOpenrpc, &[ + method_name_to_spec_method_name(method_name).as_str() + ])], &VERSION, ), &json_response["result"], @@ -1182,12 +1164,11 @@ async fn get_transaction_receipt() { } let expected_result = GeneralTransactionReceipt::PendingTransactionReceipt(expected_receipt); - let (json_response, result) = raw_call::<_, _, PendingTransactionReceipt>( - &module, - method_name, - &[client_transaction_receipt.transaction_hash], - ) - .await; + let (json_response, result) = + raw_call::<_, _, PendingTransactionReceipt>(&module, method_name, &[ + client_transaction_receipt.transaction_hash, + ]) + .await; // See above for explanation why we compare the json strings. assert_eq!( serde_json::to_value(result.unwrap()).unwrap(), @@ -1196,10 +1177,9 @@ async fn get_transaction_receipt() { // Validating schema again since pending has a different schema assert!(validate_schema( &get_starknet_spec_api_schema_for_method_results( - &[( - SpecFile::StarknetApiOpenrpc, - &[method_name_to_spec_method_name(method_name).as_str()] - )], + &[(SpecFile::StarknetApiOpenrpc, &[ + method_name_to_spec_method_name(method_name).as_str() + ])], &VERSION, ), &json_response["result"], @@ -1208,11 +1188,9 @@ async fn get_transaction_receipt() { // Ask for transaction receipt when the pending block is not up to date. *pending_data.write().await.block.parent_block_hash_mutable() = BlockHash(random::().into()); - let (_, res) = raw_call::<_, _, TransactionReceipt>( - &module, - method_name, - &[client_transaction_receipt.transaction_hash], - ) + let (_, res) = raw_call::<_, _, TransactionReceipt>(&module, method_name, &[ + client_transaction_receipt.transaction_hash, + ]) .await; assert_eq!(res.unwrap_err(), TRANSACTION_HASH_NOT_FOUND.into()); @@ -1939,15 +1917,11 @@ fn generate_client_transaction_client_receipt_and_rpc_receipt( break (client_transaction, output); }; *client_transaction.transaction_hash_mut() = pending_transaction_hash; - ( - client_transaction, - client_transaction_receipt, - PendingTransactionReceipt { - finality_status: PendingTransactionFinalityStatus::AcceptedOnL2, - transaction_hash: pending_transaction_hash, - output, - }, - ) + (client_transaction, client_transaction_receipt, PendingTransactionReceipt { + finality_status: PendingTransactionFinalityStatus::AcceptedOnL2, + transaction_hash: pending_transaction_hash, + output, + }) } fn generate_client_transaction_and_rpc_transaction( @@ -1966,10 +1940,10 @@ fn generate_client_transaction_and_rpc_transaction( continue; }; let transaction_hash = client_transaction.transaction_hash(); - break ( - client_transaction, - TransactionWithHash { transaction: rpc_transaction, transaction_hash }, - ); + break (client_transaction, TransactionWithHash { + transaction: rpc_transaction, + transaction_hash, + }); } } @@ -2246,10 +2220,9 @@ async fn get_state_update() { // Get state update by block number. let res = module - .call::<_, StateUpdate>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(header.block_number))], - ) + .call::<_, StateUpdate>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + header.block_number, + ))]) .await .unwrap(); assert_eq!(res, expected_update); @@ -2340,10 +2313,9 @@ async fn get_state_update() { // Ask for an invalid block number. let err = module - .call::<_, StateUpdate>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(BlockNumber(2)))], - ) + .call::<_, StateUpdate>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + BlockNumber(2), + ))]) .await .unwrap_err(); assert_matches!(err, Error::Call(err) if err == BLOCK_NOT_FOUND.into()); @@ -3165,19 +3137,16 @@ async fn serialize_returns_valid_json() { .unwrap(); let schema = get_starknet_spec_api_schema_for_components( - &[( - SpecFile::StarknetApiOpenrpc, - &[ - "BLOCK_WITH_TXS", - "BLOCK_WITH_TX_HASHES", - "STATE_UPDATE", - "CONTRACT_CLASS", - "DEPRECATED_CONTRACT_CLASS", - "TXN", - "TXN_RECEIPT", - "EVENTS_CHUNK", - ], - )], + &[(SpecFile::StarknetApiOpenrpc, &[ + "BLOCK_WITH_TXS", + "BLOCK_WITH_TX_HASHES", + "STATE_UPDATE", + "CONTRACT_CLASS", + "DEPRECATED_CONTRACT_CLASS", + "TXN", + "TXN_RECEIPT", + "EVENTS_CHUNK", + ])], &VERSION, ); validate_state(&state_diff, server_address, &schema).await; @@ -3321,14 +3290,10 @@ async fn get_deprecated_class_state_mutability() { .unwrap() .append_state_diff(header.block_number, state_diff) .unwrap() - .append_classes( - header.block_number, - &[], - &[ - (ClassHash(felt!("0x0")), &class_without_state_mutability), - (ClassHash(felt!("0x1")), &class_with_state_mutability), - ], - ) + .append_classes(header.block_number, &[], &[ + (ClassHash(felt!("0x0")), &class_without_state_mutability), + (ClassHash(felt!("0x1")), &class_with_state_mutability), + ]) .unwrap() .commit() .unwrap(); diff --git a/crates/papyrus_rpc/src/v0_6/broadcasted_transaction_test.rs b/crates/papyrus_rpc/src/v0_6/broadcasted_transaction_test.rs index 7780dfdb5b..404ce6054e 100644 --- a/crates/papyrus_rpc/src/v0_6/broadcasted_transaction_test.rs +++ b/crates/papyrus_rpc/src/v0_6/broadcasted_transaction_test.rs @@ -3,10 +3,10 @@ use std::collections::HashMap; use jsonschema::JSONSchema; use lazy_static::lazy_static; use papyrus_test_utils::{ + GetTestInstance, auto_impl_get_test_instance, get_number_of_variants, get_rng, - GetTestInstance, }; use starknet_api::core::{CompiledClassHash, ContractAddress, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; @@ -39,7 +39,7 @@ use super::{ DeclareType, ResourceBoundsMapping, }; -use crate::test_utils::{get_starknet_spec_api_schema_for_components, SpecFile}; +use crate::test_utils::{SpecFile, get_starknet_spec_api_schema_for_components}; use crate::version_config::VERSION_0_6 as Version; fn validate_tx_fits_rpc(tx: BroadcastedDeclareTransaction) { @@ -139,18 +139,15 @@ fn declare_v1_fits_rpc() { contract_class: DeprecatedContractClass { abi, entry_points_by_type: HashMap::from([ - ( - DeprecatedEntryPointType::Constructor, - vec![DeprecatedEntryPoint::get_test_instance(&mut rng)], - ), - ( - DeprecatedEntryPointType::External, - vec![DeprecatedEntryPoint::get_test_instance(&mut rng)], - ), - ( - DeprecatedEntryPointType::L1Handler, - vec![DeprecatedEntryPoint::get_test_instance(&mut rng)], - ), + (DeprecatedEntryPointType::Constructor, vec![ + DeprecatedEntryPoint::get_test_instance(&mut rng), + ]), + (DeprecatedEntryPointType::External, vec![ + DeprecatedEntryPoint::get_test_instance(&mut rng), + ]), + (DeprecatedEntryPointType::L1Handler, vec![ + DeprecatedEntryPoint::get_test_instance(&mut rng), + ]), ]), ..GetTestInstance::get_test_instance(&mut rng) }, diff --git a/crates/papyrus_rpc/src/v0_6/execution_test.rs b/crates/papyrus_rpc/src/v0_6/execution_test.rs index 5129d2d866..6f46cf2b63 100644 --- a/crates/papyrus_rpc/src/v0_6/execution_test.rs +++ b/crates/papyrus_rpc/src/v0_6/execution_test.rs @@ -7,11 +7,12 @@ use std::sync::Arc; use assert_matches::assert_matches; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use indexmap::indexmap; -use jsonrpsee::core::Error; use jsonrpsee::RpcModule; +use jsonrpsee::core::Error; use lazy_static::lazy_static; use papyrus_common::pending_classes::{ApiContractClass, PendingClasses, PendingClassesTrait}; use papyrus_common::state::{DeclaredClassHashEntry, DeployedContract, StorageEntry}; +use papyrus_execution::ExecutableTransactionInput; use papyrus_execution::execution_utils::selector_from_name; use papyrus_execution::objects::{ CallType, @@ -23,19 +24,18 @@ use papyrus_execution::objects::{ RevertReason, }; use papyrus_execution::testing_instances::get_storage_var_address; -use papyrus_execution::ExecutableTransactionInput; +use papyrus_storage::StorageWriter; use papyrus_storage::body::BodyStorageWriter; use papyrus_storage::class::ClassStorageWriter; use papyrus_storage::compiled_class::CasmStorageWriter; use papyrus_storage::header::HeaderStorageWriter; use papyrus_storage::state::StateStorageWriter; -use papyrus_storage::StorageWriter; use papyrus_test_utils::{ + GetTestInstance, auto_impl_get_test_instance, get_number_of_variants, get_rng, read_json_file, - GetTestInstance, }; use pretty_assertions::assert_eq; use starknet_api::block::{ @@ -73,6 +73,7 @@ use starknet_api::transaction::{ TransactionVersion, }; use starknet_api::{calldata, class_hash, contract_address, felt, patricia_key}; +use starknet_client::reader::PendingData; use starknet_client::reader::objects::pending_data::{ DeprecatedPendingBlock, PendingBlockOrDeprecated, @@ -84,24 +85,23 @@ use starknet_client::reader::objects::transaction::{ Transaction as ClientTransaction, TransactionReceipt as ClientTransactionReceipt, }; -use starknet_client::reader::PendingData; use starknet_types_core::felt::Felt; use tokio::sync::RwLock; use super::api::api_impl::JsonRpcServerImpl; use super::api::{ - decompress_program, FeeEstimate, SimulatedTransaction, SimulationFlag, TransactionTraceWithHash, + decompress_program, }; use super::broadcasted_transaction::{ BroadcastedDeclareTransaction, BroadcastedDeclareV1Transaction, BroadcastedTransaction, }; -use super::error::{TransactionExecutionError, BLOCK_NOT_FOUND, CONTRACT_NOT_FOUND}; +use super::error::{BLOCK_NOT_FOUND, CONTRACT_NOT_FOUND, TransactionExecutionError}; use super::execution::{ DeclareTransactionTrace, DeployAccountTransactionTrace, @@ -122,6 +122,7 @@ use super::transaction::{ }; use crate::api::{BlockHashOrNumber, BlockId, CallRequest, Tag}; use crate::test_utils::{ + SpecFile, call_and_validate_schema_for_result, call_api_then_assert_and_validate_schema_for_result, get_starknet_spec_api_schema_for_components, @@ -132,7 +133,6 @@ use crate::test_utils::{ get_test_rpc_server_and_storage_writer, get_test_rpc_server_and_storage_writer_from_params, validate_schema, - SpecFile, }; use crate::version_config::VERSION_0_6 as VERSION; @@ -751,41 +751,32 @@ async fn trace_block_transactions_regular_and_pending() { writer .begin_rw_txn() .unwrap() - .append_header( - BlockNumber(2), - &BlockHeader { - l1_gas_price: *GAS_PRICE, - sequencer: *SEQUENCER_ADDRESS, - timestamp: *BLOCK_TIMESTAMP, - block_hash: BlockHash(felt!("0x2")), - parent_hash: BlockHash(felt!("0x1")), - ..Default::default() - }, - ) + .append_header(BlockNumber(2), &BlockHeader { + l1_gas_price: *GAS_PRICE, + sequencer: *SEQUENCER_ADDRESS, + timestamp: *BLOCK_TIMESTAMP, + block_hash: BlockHash(felt!("0x2")), + parent_hash: BlockHash(felt!("0x1")), + ..Default::default() + }) .unwrap() - .append_body( - BlockNumber(2), - BlockBody { - transactions: vec![tx1, tx2], - transaction_outputs: vec![ - starknet_api::transaction::TransactionOutput::Invoke( - starknet_api::transaction::InvokeTransactionOutput::default(), - ), - starknet_api::transaction::TransactionOutput::Invoke( - starknet_api::transaction::InvokeTransactionOutput::default(), - ), - ], - transaction_hashes: vec![tx_hash1, tx_hash2], - }, - ) + .append_body(BlockNumber(2), BlockBody { + transactions: vec![tx1, tx2], + transaction_outputs: vec![ + starknet_api::transaction::TransactionOutput::Invoke( + starknet_api::transaction::InvokeTransactionOutput::default(), + ), + starknet_api::transaction::TransactionOutput::Invoke( + starknet_api::transaction::InvokeTransactionOutput::default(), + ), + ], + transaction_hashes: vec![tx_hash1, tx_hash2], + }) .unwrap() - .append_state_diff( - BlockNumber(2), - ThinStateDiff { - nonces: indexmap!(*ACCOUNT_ADDRESS => Nonce(felt!(2_u128))), - ..Default::default() - }, - ) + .append_state_diff(BlockNumber(2), ThinStateDiff { + nonces: indexmap!(*ACCOUNT_ADDRESS => Nonce(felt!(2_u128))), + ..Default::default() + }) .unwrap() .append_classes(BlockNumber(2), &[], &[]) .unwrap() @@ -866,10 +857,9 @@ async fn trace_block_transactions_regular_and_pending() { prepare_storage_for_execution(storage_writer); let res = module - .call::<_, Vec>( - "starknet_V0_6_traceBlockTransactions", - [BlockId::Tag(Tag::Pending)], - ) + .call::<_, Vec>("starknet_V0_6_traceBlockTransactions", [ + BlockId::Tag(Tag::Pending), + ]) .await .unwrap(); @@ -953,42 +943,33 @@ async fn trace_block_transactions_and_trace_transaction_execution_context() { writer .begin_rw_txn() .unwrap() - .append_header( - BlockNumber(2), - &BlockHeader { - block_number: BlockNumber(2), - l1_gas_price: *GAS_PRICE, - sequencer: *SEQUENCER_ADDRESS, - timestamp: *BLOCK_TIMESTAMP, - block_hash: BlockHash(felt!("0x2")), - parent_hash: BlockHash(felt!("0x1")), - ..Default::default() - }, - ) + .append_header(BlockNumber(2), &BlockHeader { + block_number: BlockNumber(2), + l1_gas_price: *GAS_PRICE, + sequencer: *SEQUENCER_ADDRESS, + timestamp: *BLOCK_TIMESTAMP, + block_hash: BlockHash(felt!("0x2")), + parent_hash: BlockHash(felt!("0x1")), + ..Default::default() + }) .unwrap() - .append_body( - BlockNumber(2), - BlockBody { - transactions: vec![tx1, tx2], - transaction_outputs: vec![ - starknet_api::transaction::TransactionOutput::Invoke( - starknet_api::transaction::InvokeTransactionOutput::default(), - ), - starknet_api::transaction::TransactionOutput::Invoke( - starknet_api::transaction::InvokeTransactionOutput::default(), - ), - ], - transaction_hashes: vec![tx_hash1, tx_hash2], - }, - ) + .append_body(BlockNumber(2), BlockBody { + transactions: vec![tx1, tx2], + transaction_outputs: vec![ + starknet_api::transaction::TransactionOutput::Invoke( + starknet_api::transaction::InvokeTransactionOutput::default(), + ), + starknet_api::transaction::TransactionOutput::Invoke( + starknet_api::transaction::InvokeTransactionOutput::default(), + ), + ], + transaction_hashes: vec![tx_hash1, tx_hash2], + }) .unwrap() - .append_state_diff( - BlockNumber(2), - ThinStateDiff { - nonces: indexmap!(*ACCOUNT_ADDRESS => Nonce(felt!(2_u128))), - ..Default::default() - }, - ) + .append_state_diff(BlockNumber(2), ThinStateDiff { + nonces: indexmap!(*ACCOUNT_ADDRESS => Nonce(felt!(2_u128))), + ..Default::default() + }) .unwrap() .append_classes(BlockNumber(2), &[], &[]) .unwrap() @@ -1018,10 +999,9 @@ async fn trace_block_transactions_and_trace_transaction_execution_context() { ); let res = module - .call::<_, Vec>( - "starknet_V0_6_traceBlockTransactions", - [BlockId::HashOrNumber(BlockHashOrNumber::Number(BlockNumber(2)))], - ) + .call::<_, Vec>("starknet_V0_6_traceBlockTransactions", [ + BlockId::HashOrNumber(BlockHashOrNumber::Number(BlockNumber(2))), + ]) .await .unwrap(); validate_result(res[0].trace_root.clone()); @@ -1136,10 +1116,9 @@ async fn pending_trace_block_transactions_and_trace_transaction_execution_contex ); let res = module - .call::<_, Vec>( - "starknet_V0_6_traceBlockTransactions", - [BlockId::Tag(Tag::Pending)], - ) + .call::<_, Vec>("starknet_V0_6_traceBlockTransactions", [ + BlockId::Tag(Tag::Pending), + ]) .await .unwrap(); validate_result(res[0].trace_root.clone()); @@ -1571,76 +1550,63 @@ fn prepare_storage_for_execution(mut storage_writer: StorageWriter) -> StorageWr storage_writer .begin_rw_txn() .unwrap() - .append_header( - BlockNumber(0), - &BlockHeader { - l1_gas_price: *GAS_PRICE, - sequencer: *SEQUENCER_ADDRESS, - timestamp: *BLOCK_TIMESTAMP, - // Test that l1_da_mode is ignored by changing its value - l1_da_mode: L1DataAvailabilityMode::Blob, - ..Default::default() - }, - ) + .append_header(BlockNumber(0), &BlockHeader { + l1_gas_price: *GAS_PRICE, + sequencer: *SEQUENCER_ADDRESS, + timestamp: *BLOCK_TIMESTAMP, + // Test that l1_da_mode is ignored by changing its value + l1_da_mode: L1DataAvailabilityMode::Blob, + ..Default::default() + }) .unwrap() .append_body(BlockNumber(0), BlockBody::default()) .unwrap() - .append_state_diff( - BlockNumber(0), - ThinStateDiff { - deployed_contracts: indexmap!( - *DEPRECATED_CONTRACT_ADDRESS => class_hash1, - *CONTRACT_ADDRESS => class_hash2, - *ACCOUNT_ADDRESS => *ACCOUNT_CLASS_HASH, - *TEST_ERC20_CONTRACT_ADDRESS => *TEST_ERC20_CONTRACT_CLASS_HASH, - ), - storage_diffs: indexmap!( - *TEST_ERC20_CONTRACT_ADDRESS => indexmap!( - // Give the accounts some balance. - account_balance_key => *ACCOUNT_INITIAL_BALANCE, - // Give the first account mint permission (what is this?). - minter_var_address => *ACCOUNT_ADDRESS.0.key() - ), - ), - declared_classes: indexmap!(class_hash2 => compiled_class_hash), - deprecated_declared_classes: vec![ - class_hash1, - *ACCOUNT_CLASS_HASH, - *TEST_ERC20_CONTRACT_CLASS_HASH, - ], - nonces: indexmap!( - *TEST_ERC20_CONTRACT_ADDRESS => Nonce::default(), - *CONTRACT_ADDRESS => Nonce::default(), - *DEPRECATED_CONTRACT_ADDRESS => Nonce::default(), - *ACCOUNT_ADDRESS => Nonce::default(), + .append_state_diff(BlockNumber(0), ThinStateDiff { + deployed_contracts: indexmap!( + *DEPRECATED_CONTRACT_ADDRESS => class_hash1, + *CONTRACT_ADDRESS => class_hash2, + *ACCOUNT_ADDRESS => *ACCOUNT_CLASS_HASH, + *TEST_ERC20_CONTRACT_ADDRESS => *TEST_ERC20_CONTRACT_CLASS_HASH, + ), + storage_diffs: indexmap!( + *TEST_ERC20_CONTRACT_ADDRESS => indexmap!( + // Give the accounts some balance. + account_balance_key => *ACCOUNT_INITIAL_BALANCE, + // Give the first account mint permission (what is this?). + minter_var_address => *ACCOUNT_ADDRESS.0.key() ), - replaced_classes: indexmap!(), - }, - ) - .unwrap() - .append_classes( - BlockNumber(0), - &[(class_hash2, &class2)], - &[ - (class_hash1, &class1), - (*ACCOUNT_CLASS_HASH, &account_class), - (*TEST_ERC20_CONTRACT_CLASS_HASH, &fee_contract_class), + ), + declared_classes: indexmap!(class_hash2 => compiled_class_hash), + deprecated_declared_classes: vec![ + class_hash1, + *ACCOUNT_CLASS_HASH, + *TEST_ERC20_CONTRACT_CLASS_HASH, ], - ) + nonces: indexmap!( + *TEST_ERC20_CONTRACT_ADDRESS => Nonce::default(), + *CONTRACT_ADDRESS => Nonce::default(), + *DEPRECATED_CONTRACT_ADDRESS => Nonce::default(), + *ACCOUNT_ADDRESS => Nonce::default(), + ), + replaced_classes: indexmap!(), + }) + .unwrap() + .append_classes(BlockNumber(0), &[(class_hash2, &class2)], &[ + (class_hash1, &class1), + (*ACCOUNT_CLASS_HASH, &account_class), + (*TEST_ERC20_CONTRACT_CLASS_HASH, &fee_contract_class), + ]) .unwrap() .append_casm(&class_hash2, &casm) .unwrap() - .append_header( - BlockNumber(1), - &BlockHeader { - l1_gas_price: different_gas_price, - sequencer: *SEQUENCER_ADDRESS, - timestamp: *BLOCK_TIMESTAMP, - block_hash: BlockHash(felt!("0x1")), - block_number: BlockNumber(1), - ..Default::default() - }, - ) + .append_header(BlockNumber(1), &BlockHeader { + l1_gas_price: different_gas_price, + sequencer: *SEQUENCER_ADDRESS, + timestamp: *BLOCK_TIMESTAMP, + block_hash: BlockHash(felt!("0x1")), + block_number: BlockNumber(1), + ..Default::default() + }) .unwrap() .append_body(BlockNumber(1), BlockBody::default()) .unwrap() @@ -1658,15 +1624,12 @@ fn write_empty_block(mut storage_writer: StorageWriter) { storage_writer .begin_rw_txn() .unwrap() - .append_header( - BlockNumber(0), - &BlockHeader { - l1_gas_price: *GAS_PRICE, - sequencer: *SEQUENCER_ADDRESS, - timestamp: *BLOCK_TIMESTAMP, - ..Default::default() - }, - ) + .append_header(BlockNumber(0), &BlockHeader { + l1_gas_price: *GAS_PRICE, + sequencer: *SEQUENCER_ADDRESS, + timestamp: *BLOCK_TIMESTAMP, + ..Default::default() + }) .unwrap() .append_body(BlockNumber(0), BlockBody::default()) .unwrap() diff --git a/crates/papyrus_rpc/src/v0_6/transaction.rs b/crates/papyrus_rpc/src/v0_6/transaction.rs index 9bed607338..293e085d2a 100644 --- a/crates/papyrus_rpc/src/v0_6/transaction.rs +++ b/crates/papyrus_rpc/src/v0_6/transaction.rs @@ -6,13 +6,13 @@ use std::collections::HashMap; use std::fmt::Display; use std::sync::Arc; -use ethers::core::abi::{encode_packed, Token}; +use ethers::core::abi::{Token, encode_packed}; use ethers::core::utils::keccak256; use jsonrpsee::types::ErrorObjectOwned; use papyrus_execution::objects::PriceUnit; +use papyrus_storage::StorageTxn; use papyrus_storage::body::BodyStorageReader; use papyrus_storage::db::TransactionKind; -use papyrus_storage::StorageTxn; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use starknet_api::block::{BlockHash, BlockNumber, BlockStatus}; use starknet_api::core::{ diff --git a/crates/papyrus_rpc/src/v0_6/transaction_test.rs b/crates/papyrus_rpc/src/v0_6/transaction_test.rs index 5bd9f0d709..b5c3275837 100644 --- a/crates/papyrus_rpc/src/v0_6/transaction_test.rs +++ b/crates/papyrus_rpc/src/v0_6/transaction_test.rs @@ -1,8 +1,8 @@ use papyrus_test_utils::{ + GetTestInstance, auto_impl_get_test_instance, get_number_of_variants, get_rng, - GetTestInstance, }; use pretty_assertions::assert_eq; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, Nonce, PatriciaKey}; diff --git a/crates/papyrus_rpc/src/v0_6/write_api_error.rs b/crates/papyrus_rpc/src/v0_6/write_api_error.rs index ba977c0411..a5a9643238 100644 --- a/crates/papyrus_rpc/src/v0_6/write_api_error.rs +++ b/crates/papyrus_rpc/src/v0_6/write_api_error.rs @@ -1,9 +1,6 @@ use starknet_client::starknet_error::{KnownStarknetErrorCode, StarknetError, StarknetErrorCode}; use super::error::{ - unexpected_error, - validation_failure, - JsonRpcError, CLASS_ALREADY_DECLARED, CLASS_HASH_NOT_FOUND, COMPILATION_FAILED, @@ -13,9 +10,12 @@ use super::error::{ INSUFFICIENT_ACCOUNT_BALANCE, INSUFFICIENT_MAX_FEE, INVALID_TRANSACTION_NONCE, + JsonRpcError, NON_ACCOUNT, UNSUPPORTED_CONTRACT_CLASS_VERSION, UNSUPPORTED_TX_VERSION, + unexpected_error, + validation_failure, }; #[cfg(test)] diff --git a/crates/papyrus_rpc/src/v0_6/write_api_error_test.rs b/crates/papyrus_rpc/src/v0_6/write_api_error_test.rs index dc7b8a7d2e..75be8778bc 100644 --- a/crates/papyrus_rpc/src/v0_6/write_api_error_test.rs +++ b/crates/papyrus_rpc/src/v0_6/write_api_error_test.rs @@ -10,7 +10,7 @@ use super::{ starknet_error_to_deploy_account_error, starknet_error_to_invoke_error, }; -use crate::test_utils::{get_starknet_spec_api_schema_for_method_errors, SpecFile}; +use crate::test_utils::{SpecFile, get_starknet_spec_api_schema_for_method_errors}; use crate::version_config::VERSION_0_6 as Version; const MESSAGE: &str = "message"; diff --git a/crates/papyrus_rpc/src/v0_6/write_api_result_test.rs b/crates/papyrus_rpc/src/v0_6/write_api_result_test.rs index 1cd5dc863b..56dc2f1d69 100644 --- a/crates/papyrus_rpc/src/v0_6/write_api_result_test.rs +++ b/crates/papyrus_rpc/src/v0_6/write_api_result_test.rs @@ -1,4 +1,4 @@ -use papyrus_test_utils::{auto_impl_get_test_instance, get_rng, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, auto_impl_get_test_instance, get_rng}; use serde::Serialize; use starknet_api::core::{ClassHash, ContractAddress, PatriciaKey}; use starknet_api::felt; @@ -11,7 +11,7 @@ use starknet_client::writer::objects::response::{ }; use super::{AddDeclareOkResult, AddDeployAccountOkResult, AddInvokeOkResult}; -use crate::test_utils::{get_starknet_spec_api_schema_for_method_results, SpecFile}; +use crate::test_utils::{SpecFile, get_starknet_spec_api_schema_for_method_results}; use crate::version_config::VERSION_0_6 as VERSION; auto_impl_get_test_instance! { diff --git a/crates/papyrus_rpc/src/v0_7/api/api_impl.rs b/crates/papyrus_rpc/src/v0_7/api/api_impl.rs index fc503f168c..80d04a64d9 100644 --- a/crates/papyrus_rpc/src/v0_7/api/api_impl.rs +++ b/crates/papyrus_rpc/src/v0_7/api/api_impl.rs @@ -1,24 +1,24 @@ use std::sync::Arc; use async_trait::async_trait; +use jsonrpsee::RpcModule; use jsonrpsee::core::RpcResult; use jsonrpsee::types::ErrorObjectOwned; -use jsonrpsee::RpcModule; use lazy_static::lazy_static; use papyrus_common::pending_classes::{PendingClasses, PendingClassesTrait}; use papyrus_execution::objects::{FeeEstimation, PendingData as ExecutionPendingData}; use papyrus_execution::{ + ExecutableTransactionInput, + ExecutionConfig, estimate_fee as exec_estimate_fee, execute_call, execution_utils, simulate_transactions as exec_simulate_transactions, - ExecutableTransactionInput, - ExecutionConfig, }; use papyrus_storage::body::events::{EventIndex, EventsReader}; use papyrus_storage::body::{BodyStorageReader, TransactionIndex}; use papyrus_storage::compiled_class::CasmStorageReader; -use papyrus_storage::db::{TransactionKind, RO}; +use papyrus_storage::db::{RO, TransactionKind}; use papyrus_storage::state::StateStorageReader; use papyrus_storage::{StorageError, StorageReader, StorageTxn}; use starknet_api::block::{BlockHash, BlockNumber, BlockStatus}; @@ -34,6 +34,8 @@ use starknet_api::transaction::{ TransactionOffsetInBlock, TransactionVersion, }; +use starknet_client::ClientError; +use starknet_client::reader::PendingData; use starknet_client::reader::objects::pending_data::{ DeprecatedPendingBlock, PendingBlockOrDeprecated, @@ -43,46 +45,42 @@ use starknet_client::reader::objects::transaction::{ Transaction as ClientTransaction, TransactionReceipt as ClientTransactionReceipt, }; -use starknet_client::reader::PendingData; use starknet_client::writer::{StarknetWriter, WriterClientError}; -use starknet_client::ClientError; use starknet_types_core::felt::Felt; use tokio::sync::RwLock; use tracing::{instrument, trace, warn}; use super::super::block::{ - get_accepted_block_number, - get_block_header_by_number, Block, BlockHeader, BlockNotRevertedValidator, GeneralBlockHeader, PendingBlockHeader, ResourcePrice, + get_accepted_block_number, + get_block_header_by_number, }; use super::super::broadcasted_transaction::{ BroadcastedDeclareTransaction, BroadcastedTransaction, }; use super::super::error::{ - ContractError, - JsonRpcError, - TransactionExecutionError, BLOCK_NOT_FOUND, CLASS_HASH_NOT_FOUND, CONTRACT_NOT_FOUND, + ContractError, INVALID_TRANSACTION_HASH, INVALID_TRANSACTION_INDEX, + JsonRpcError, NO_BLOCKS, PAGE_SIZE_TOO_BIG, TOO_MANY_KEYS_IN_FILTER, TRANSACTION_HASH_NOT_FOUND, + TransactionExecutionError, }; use super::super::execution::TransactionTrace; use super::super::state::{AcceptedStateUpdate, PendingStateUpdate, StateUpdate}; use super::super::transaction::{ - get_block_tx_hashes_by_number, - get_block_txs_by_number, Event, GeneralTransactionReceipt, L1HandlerMsgHash, @@ -100,6 +98,8 @@ use super::super::transaction::{ Transactions, TypedDeployAccountTransaction, TypedInvokeTransaction, + get_block_tx_hashes_by_number, + get_block_txs_by_number, }; use super::super::write_api_error::{ starknet_error_to_declare_error, @@ -112,8 +112,6 @@ use super::super::write_api_result::{ AddInvokeOkResult, }; use super::{ - execution_error_to_error_object_owned, - stored_txn_to_executable_txn, BlockHashAndNumber, BlockId, CallRequest, @@ -126,18 +124,20 @@ use super::{ SimulatedTransaction, SimulationFlag, TransactionTraceWithHash, + execution_error_to_error_object_owned, + stored_txn_to_executable_txn, }; use crate::api::{BlockHashOrNumber, JsonRpcServerTrait, Tag}; use crate::pending::client_pending_data_to_execution_pending_data; -use crate::syncing_state::{get_last_synced_block, SyncStatus, SyncingState}; +use crate::syncing_state::{SyncStatus, SyncingState, get_last_synced_block}; use crate::version_config::VERSION_0_7 as VERSION; use crate::{ + ContinuationTokenAsStruct, + GENESIS_HASH, get_block_status, get_latest_block_number, internal_server_error, verify_storage_scope, - ContinuationTokenAsStruct, - GENESIS_HASH, }; const DONT_IGNORE_L1_DA_MODE: bool = false; diff --git a/crates/papyrus_rpc/src/v0_7/api/mod.rs b/crates/papyrus_rpc/src/v0_7/api/mod.rs index a19000eaf0..50c8fdcc47 100644 --- a/crates/papyrus_rpc/src/v0_7/api/mod.rs +++ b/crates/papyrus_rpc/src/v0_7/api/mod.rs @@ -6,17 +6,17 @@ use flate2::bufread::GzDecoder; use jsonrpsee::core::RpcResult; use jsonrpsee::proc_macros::rpc; use jsonrpsee::types::ErrorObjectOwned; +use papyrus_common::BlockHashAndNumber; use papyrus_common::deprecated_class_abi::calculate_deprecated_class_abi_length; use papyrus_common::pending_classes::ApiContractClass; -use papyrus_common::BlockHashAndNumber; use papyrus_execution::objects::FeeEstimation; use papyrus_execution::{AbiSize, ExecutableTransactionInput, ExecutionError, SierraSize}; use papyrus_proc_macros::versioned_rpc; +use papyrus_storage::StorageTxn; use papyrus_storage::compiled_class::CasmStorageReader; -use papyrus_storage::db::serialization::StorageSerdeError; use papyrus_storage::db::RO; +use papyrus_storage::db::serialization::StorageSerdeError; use papyrus_storage::state::StateStorageReader; -use papyrus_storage::StorageTxn; use serde::{Deserialize, Serialize}; use starknet_api::block::BlockNumber; use starknet_api::core::{ClassHash, ContractAddress, Nonce}; @@ -37,11 +37,11 @@ use super::broadcasted_transaction::{ }; use super::deprecated_contract_class::ContractClass as DeprecatedContractClass; use super::error::{ - ContractError, - JsonRpcError, BLOCK_NOT_FOUND, CONTRACT_NOT_FOUND, + ContractError, INVALID_CONTINUATION_TOKEN, + JsonRpcError, }; use super::execution::TransactionTrace; use super::state::{ContractClass, StateUpdate}; @@ -64,7 +64,7 @@ use super::transaction::{ use super::write_api_result::{AddDeclareOkResult, AddDeployAccountOkResult, AddInvokeOkResult}; use crate::api::{BlockId, CallRequest}; use crate::syncing_state::SyncingState; -use crate::{internal_server_error, ContinuationTokenAsStruct}; +use crate::{ContinuationTokenAsStruct, internal_server_error}; pub mod api_impl; #[cfg(test)] diff --git a/crates/papyrus_rpc/src/v0_7/api/test.rs b/crates/papyrus_rpc/src/v0_7/api/test.rs index 4da2add3a4..536ea793b5 100644 --- a/crates/papyrus_rpc/src/v0_7/api/test.rs +++ b/crates/papyrus_rpc/src/v0_7/api/test.rs @@ -7,15 +7,16 @@ use std::ops::Index; use assert_matches::assert_matches; use async_trait::async_trait; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; -use indexmap::{indexmap, IndexMap}; +use indexmap::{IndexMap, indexmap}; use itertools::Itertools; -use jsonrpsee::core::Error; use jsonrpsee::Methods; +use jsonrpsee::core::Error; use jsonschema::JSONSchema; use lazy_static::lazy_static; use mockall::predicate::eq; -use papyrus_common::pending_classes::{ApiContractClass, PendingClassesTrait}; use papyrus_common::BlockHashAndNumber; +use papyrus_common::pending_classes::{ApiContractClass, PendingClassesTrait}; +use papyrus_storage::StorageScope; use papyrus_storage::base_layer::BaseLayerStorageWriter; use papyrus_storage::body::events::EventIndex; use papyrus_storage::body::{BodyStorageWriter, TransactionIndex}; @@ -24,8 +25,8 @@ use papyrus_storage::compiled_class::CasmStorageWriter; use papyrus_storage::header::HeaderStorageWriter; use papyrus_storage::state::StateStorageWriter; use papyrus_storage::test_utils::get_test_storage; -use papyrus_storage::StorageScope; use papyrus_test_utils::{ + GetTestInstance, auto_impl_get_test_instance, get_number_of_variants, get_rng, @@ -33,10 +34,9 @@ use papyrus_test_utils::{ get_test_body, get_test_state_diff, send_request, - GetTestInstance, }; use pretty_assertions::assert_eq; -use rand::{random, RngCore}; +use rand::{RngCore, random}; use rand_chacha::ChaCha8Rng; use reqwest::StatusCode; use serde::{Deserialize, Serialize}; @@ -81,6 +81,7 @@ use starknet_api::transaction::{ TransactionOutput as StarknetApiTransactionOutput, }; use starknet_api::{felt, patricia_key}; +use starknet_client::ClientError; use starknet_client::reader::objects::pending_data::{ DeprecatedPendingBlock, PendingBlockOrDeprecated, @@ -109,7 +110,6 @@ use starknet_client::writer::objects::transaction::{ InvokeTransaction as ClientInvokeTransaction, }; use starknet_client::writer::{MockStarknetWriter, WriterClientError, WriterClientResult}; -use starknet_client::ClientError; use starknet_types_core::felt::Felt; use super::super::api::EventsChunk; @@ -117,8 +117,6 @@ use super::super::block::{Block, GeneralBlockHeader, PendingBlockHeader, Resourc use super::super::broadcasted_transaction::BroadcastedDeclareTransaction; use super::super::deprecated_contract_class::ContractClass as DeprecatedContractClass; use super::super::error::{ - unexpected_error, - JsonRpcError, BLOCK_NOT_FOUND, CLASS_HASH_NOT_FOUND, COMPILATION_FAILED, @@ -126,10 +124,12 @@ use super::super::error::{ DUPLICATE_TX, INVALID_CONTINUATION_TOKEN, INVALID_TRANSACTION_INDEX, + JsonRpcError, NO_BLOCKS, PAGE_SIZE_TOO_BIG, TOO_MANY_KEYS_IN_FILTER, TRANSACTION_HASH_NOT_FOUND, + unexpected_error, }; use super::super::state::{ AcceptedStateUpdate, @@ -170,11 +170,12 @@ use super::super::write_api_result::{ AddDeployAccountOkResult, AddInvokeOkResult, }; -use super::api_impl::{JsonRpcServerImpl, BLOCK_HASH_TABLE_ADDRESS}; +use super::api_impl::{BLOCK_HASH_TABLE_ADDRESS, JsonRpcServerImpl}; use super::{ContinuationToken, EventFilter, GatewayContractClass}; use crate::api::{BlockHashOrNumber, BlockId, Tag}; use crate::syncing_state::SyncStatus; use crate::test_utils::{ + SpecFile, call_and_validate_schema_for_result, call_api_then_assert_and_validate_schema_for_err, call_api_then_assert_and_validate_schema_for_result, @@ -190,16 +191,15 @@ use crate::test_utils::{ method_name_to_spec_method_name, raw_call, validate_schema, - SpecFile, }; use crate::v0_7::api::CompiledContractClass; use crate::version_config::VERSION_0_7 as VERSION; use crate::{ + ContinuationTokenAsStruct, + GENESIS_HASH, internal_server_error, internal_server_error_with_msg, run_server, - ContinuationTokenAsStruct, - GENESIS_HASH, }; const NODE_VERSION: &str = "NODE VERSION"; @@ -421,10 +421,9 @@ async fn get_block_transaction_count() { // Get block by number. let res = module - .call::<_, usize>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(block.header.block_number))], - ) + .call::<_, usize>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + block.header.block_number, + ))]) .await .unwrap(); assert_eq!(res, transaction_count); @@ -464,10 +463,9 @@ async fn get_block_transaction_count() { // Ask for an invalid block number. let err = module - .call::<_, usize>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(BlockNumber(1)))], - ) + .call::<_, usize>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + BlockNumber(1), + ))]) .await .unwrap_err(); assert_matches!(err, Error::Call(err) if err == BLOCK_NOT_FOUND.into()); @@ -531,10 +529,9 @@ async fn get_block_w_full_transactions() { // Get block by number. let block = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(expected_block_header.block_number))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + expected_block_header.block_number, + ))]) .await .unwrap(); assert_eq!(block, expected_block); @@ -552,32 +549,27 @@ async fn get_block_w_full_transactions() { .commit() .unwrap(); let block = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Hash(expected_block_header.block_hash))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Hash( + expected_block_header.block_hash, + ))]) .await .unwrap(); assert_eq!(block.status, Some(BlockStatus::AcceptedOnL1)); // Ask for an invalid block hash. let err = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Hash(BlockHash(felt!( - "0x642b629ad8ce233b55798c83bb629a59bf0a0092f67da28d6d66776680d5484" - ))))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Hash(BlockHash( + felt!("0x642b629ad8ce233b55798c83bb629a59bf0a0092f67da28d6d66776680d5484"), + )))]) .await .unwrap_err(); assert_matches!(err, Error::Call(err) if err == BLOCK_NOT_FOUND.into()); // Ask for an invalid block number. let err = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(BlockNumber(1)))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + BlockNumber(1), + ))]) .await .unwrap_err(); assert_matches!(err, Error::Call(err) if err == BLOCK_NOT_FOUND.into()); @@ -710,10 +702,9 @@ async fn get_block_w_full_transactions_and_receipts() { // Get block by number. let block = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(block_number))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + block_number, + ))]) .await .unwrap(); assert_eq!(block.header, expected_block_header); @@ -738,22 +729,18 @@ async fn get_block_w_full_transactions_and_receipts() { // Ask for an invalid block hash. let err = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Hash(BlockHash(felt!( - "0x642b629ad8ce233b55798c83bb629a59bf0a0092f67da28d6d66776680d5484" - ))))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Hash(BlockHash( + felt!("0x642b629ad8ce233b55798c83bb629a59bf0a0092f67da28d6d66776680d5484"), + )))]) .await .unwrap_err(); assert_matches!(err, Error::Call(err) if err == BLOCK_NOT_FOUND.into()); // Ask for an invalid block number. let err = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(BlockNumber(1)))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + BlockNumber(1), + ))]) .await .unwrap_err(); assert_matches!(err, Error::Call(err) if err == BLOCK_NOT_FOUND.into()); @@ -896,10 +883,9 @@ async fn get_block_w_transaction_hashes() { // Get block by number. let block = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(expected_block_header.block_number))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + expected_block_header.block_number, + ))]) .await .unwrap(); assert_eq!(block, expected_block); @@ -917,10 +903,9 @@ async fn get_block_w_transaction_hashes() { .commit() .unwrap(); let block = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Hash(expected_block_header.block_hash))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Hash( + expected_block_header.block_hash, + ))]) .await .unwrap(); assert_eq!(block.status, Some(BlockStatus::AcceptedOnL1)); @@ -940,10 +925,9 @@ async fn get_block_w_transaction_hashes() { // Ask for an invalid block number. let err = module - .call::<_, Block>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(BlockNumber(1)))], - ) + .call::<_, Block>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + BlockNumber(1), + ))]) .await .unwrap_err(); assert_matches!(err, Error::Call(err) if err == BLOCK_NOT_FOUND.into()); @@ -1227,10 +1211,9 @@ async fn get_transaction_status() { assert_eq!(res.unwrap(), expected_status); assert!(validate_schema( &get_starknet_spec_api_schema_for_method_results( - &[( - SpecFile::StarknetApiOpenrpc, - &[method_name_to_spec_method_name(method_name).as_str()] - )], + &[(SpecFile::StarknetApiOpenrpc, &[ + method_name_to_spec_method_name(method_name).as_str() + ])], &VERSION, ), &json_response["result"], @@ -1261,20 +1244,17 @@ async fn get_transaction_status() { pending_block.transactions_mutable().push(client_transaction.clone()); pending_block.transaction_receipts_mutable().push(client_transaction_receipt.clone()); } - let (json_response, result) = raw_call::<_, _, TransactionStatus>( - &module, - method_name, - &[client_transaction_receipt.transaction_hash], - ) + let (json_response, result) = raw_call::<_, _, TransactionStatus>(&module, method_name, &[ + client_transaction_receipt.transaction_hash, + ]) .await; assert_eq!(result.unwrap(), expected_status); // Validating schema again since pending has a different schema assert!(validate_schema( &get_starknet_spec_api_schema_for_method_results( - &[( - SpecFile::StarknetApiOpenrpc, - &[method_name_to_spec_method_name(method_name).as_str()] - )], + &[(SpecFile::StarknetApiOpenrpc, &[ + method_name_to_spec_method_name(method_name).as_str() + ])], &VERSION, ), &json_response["result"], @@ -1283,11 +1263,9 @@ async fn get_transaction_status() { // Ask for transaction status when the pending block is not up to date. *pending_data.write().await.block.parent_block_hash_mutable() = BlockHash(random::().into()); - let (_, res) = raw_call::<_, _, TransactionStatus>( - &module, - method_name, - &[client_transaction_receipt.transaction_hash], - ) + let (_, res) = raw_call::<_, _, TransactionStatus>(&module, method_name, &[ + client_transaction_receipt.transaction_hash, + ]) .await; assert_eq!(res.unwrap_err(), TRANSACTION_HASH_NOT_FOUND.into()); @@ -1379,12 +1357,11 @@ async fn get_transaction_receipt() { } let expected_result = GeneralTransactionReceipt::PendingTransactionReceipt(expected_receipt); - let (json_response, result) = raw_call::<_, _, PendingTransactionReceipt>( - &module, - method_name, - &[client_transaction_receipt.transaction_hash], - ) - .await; + let (json_response, result) = + raw_call::<_, _, PendingTransactionReceipt>(&module, method_name, &[ + client_transaction_receipt.transaction_hash, + ]) + .await; // See above for explanation why we compare the json strings. assert_eq!( serde_json::to_value(result.unwrap()).unwrap(), @@ -1393,10 +1370,9 @@ async fn get_transaction_receipt() { // Validating schema again since pending has a different schema assert!(validate_schema( &get_starknet_spec_api_schema_for_method_results( - &[( - SpecFile::StarknetApiOpenrpc, - &[method_name_to_spec_method_name(method_name).as_str()] - )], + &[(SpecFile::StarknetApiOpenrpc, &[ + method_name_to_spec_method_name(method_name).as_str() + ])], &VERSION, ), &json_response["result"], @@ -1405,11 +1381,9 @@ async fn get_transaction_receipt() { // Ask for transaction receipt when the pending block is not up to date. *pending_data.write().await.block.parent_block_hash_mutable() = BlockHash(random::().into()); - let (_, res) = raw_call::<_, _, TransactionReceipt>( - &module, - method_name, - &[client_transaction_receipt.transaction_hash], - ) + let (_, res) = raw_call::<_, _, TransactionReceipt>(&module, method_name, &[ + client_transaction_receipt.transaction_hash, + ]) .await; assert_eq!(res.unwrap_err(), TRANSACTION_HASH_NOT_FOUND.into()); @@ -2138,16 +2112,11 @@ fn generate_client_transaction_client_receipt_rpc_transaction_and_rpc_receipt( }; // rpc_transaction contains no hash so no need to change it. *client_transaction.transaction_hash_mut() = pending_transaction_hash; - ( - client_transaction, - client_transaction_receipt, - rpc_transaction, - PendingTransactionReceipt { - finality_status: PendingTransactionFinalityStatus::AcceptedOnL2, - transaction_hash: pending_transaction_hash, - output, - }, - ) + (client_transaction, client_transaction_receipt, rpc_transaction, PendingTransactionReceipt { + finality_status: PendingTransactionFinalityStatus::AcceptedOnL2, + transaction_hash: pending_transaction_hash, + output, + }) } fn generate_client_transaction_and_rpc_transaction( @@ -2166,10 +2135,10 @@ fn generate_client_transaction_and_rpc_transaction( continue; }; let transaction_hash = client_transaction.transaction_hash(); - break ( - client_transaction, - TransactionWithHash { transaction: rpc_transaction, transaction_hash }, - ); + break (client_transaction, TransactionWithHash { + transaction: rpc_transaction, + transaction_hash, + }); } } @@ -2446,10 +2415,9 @@ async fn get_state_update() { // Get state update by block number. let res = module - .call::<_, StateUpdate>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(header.block_number))], - ) + .call::<_, StateUpdate>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + header.block_number, + ))]) .await .unwrap(); assert_eq!(res, expected_update); @@ -2540,10 +2508,9 @@ async fn get_state_update() { // Ask for an invalid block number. let err = module - .call::<_, StateUpdate>( - method_name, - [BlockId::HashOrNumber(BlockHashOrNumber::Number(BlockNumber(2)))], - ) + .call::<_, StateUpdate>(method_name, [BlockId::HashOrNumber(BlockHashOrNumber::Number( + BlockNumber(2), + ))]) .await .unwrap_err(); assert_matches!(err, Error::Call(err) if err == BLOCK_NOT_FOUND.into()); @@ -3365,19 +3332,16 @@ async fn serialize_returns_valid_json() { .unwrap(); let schema = get_starknet_spec_api_schema_for_components( - &[( - SpecFile::StarknetApiOpenrpc, - &[ - "BLOCK_WITH_TXS", - "BLOCK_WITH_TX_HASHES", - "STATE_UPDATE", - "CONTRACT_CLASS", - "DEPRECATED_CONTRACT_CLASS", - "TXN", - "TXN_RECEIPT", - "EVENTS_CHUNK", - ], - )], + &[(SpecFile::StarknetApiOpenrpc, &[ + "BLOCK_WITH_TXS", + "BLOCK_WITH_TX_HASHES", + "STATE_UPDATE", + "CONTRACT_CLASS", + "DEPRECATED_CONTRACT_CLASS", + "TXN", + "TXN_RECEIPT", + "EVENTS_CHUNK", + ])], &VERSION, ); validate_state(&state_diff, server_address, &schema).await; @@ -3522,14 +3486,10 @@ async fn get_deprecated_class_state_mutability() { .unwrap() .append_state_diff(header.block_number, state_diff) .unwrap() - .append_classes( - header.block_number, - &[], - &[ - (ClassHash(felt!("0x0")), &class_without_state_mutability), - (ClassHash(felt!("0x1")), &class_with_state_mutability), - ], - ) + .append_classes(header.block_number, &[], &[ + (ClassHash(felt!("0x0")), &class_without_state_mutability), + (ClassHash(felt!("0x1")), &class_with_state_mutability), + ]) .unwrap() .commit() .unwrap(); diff --git a/crates/papyrus_rpc/src/v0_7/broadcasted_transaction_test.rs b/crates/papyrus_rpc/src/v0_7/broadcasted_transaction_test.rs index 134ae838cb..b788616c6e 100644 --- a/crates/papyrus_rpc/src/v0_7/broadcasted_transaction_test.rs +++ b/crates/papyrus_rpc/src/v0_7/broadcasted_transaction_test.rs @@ -3,10 +3,10 @@ use std::collections::HashMap; use jsonschema::JSONSchema; use lazy_static::lazy_static; use papyrus_test_utils::{ + GetTestInstance, auto_impl_get_test_instance, get_number_of_variants, get_rng, - GetTestInstance, }; use starknet_api::core::{CompiledClassHash, ContractAddress, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; @@ -39,7 +39,7 @@ use super::{ DeclareType, ResourceBoundsMapping, }; -use crate::test_utils::{get_starknet_spec_api_schema_for_components, SpecFile}; +use crate::test_utils::{SpecFile, get_starknet_spec_api_schema_for_components}; use crate::version_config::VERSION_0_7 as Version; fn validate_tx_fits_rpc(tx: BroadcastedDeclareTransaction) { @@ -139,18 +139,15 @@ fn declare_v1_fits_rpc() { contract_class: DeprecatedContractClass { abi, entry_points_by_type: HashMap::from([ - ( - DeprecatedEntryPointType::Constructor, - vec![DeprecatedEntryPoint::get_test_instance(&mut rng)], - ), - ( - DeprecatedEntryPointType::External, - vec![DeprecatedEntryPoint::get_test_instance(&mut rng)], - ), - ( - DeprecatedEntryPointType::L1Handler, - vec![DeprecatedEntryPoint::get_test_instance(&mut rng)], - ), + (DeprecatedEntryPointType::Constructor, vec![ + DeprecatedEntryPoint::get_test_instance(&mut rng), + ]), + (DeprecatedEntryPointType::External, vec![ + DeprecatedEntryPoint::get_test_instance(&mut rng), + ]), + (DeprecatedEntryPointType::L1Handler, vec![ + DeprecatedEntryPoint::get_test_instance(&mut rng), + ]), ]), ..GetTestInstance::get_test_instance(&mut rng) }, diff --git a/crates/papyrus_rpc/src/v0_7/execution_test.rs b/crates/papyrus_rpc/src/v0_7/execution_test.rs index 107af2f353..b28d2f5a01 100644 --- a/crates/papyrus_rpc/src/v0_7/execution_test.rs +++ b/crates/papyrus_rpc/src/v0_7/execution_test.rs @@ -6,8 +6,8 @@ use std::sync::Arc; use assert_matches::assert_matches; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use indexmap::indexmap; -use jsonrpsee::core::Error; use jsonrpsee::RpcModule; +use jsonrpsee::core::Error; use lazy_static::lazy_static; use papyrus_common::pending_classes::{ApiContractClass, PendingClasses, PendingClassesTrait}; use papyrus_common::state::{ @@ -15,6 +15,7 @@ use papyrus_common::state::{ DeployedContract as CommonDeployedContract, StorageEntry as CommonStorageEntry, }; +use papyrus_execution::ExecutableTransactionInput; use papyrus_execution::execution_utils::selector_from_name; use papyrus_execution::objects::{ CallType, @@ -27,19 +28,18 @@ use papyrus_execution::objects::{ RevertReason, }; use papyrus_execution::testing_instances::get_storage_var_address; -use papyrus_execution::ExecutableTransactionInput; +use papyrus_storage::StorageWriter; use papyrus_storage::body::BodyStorageWriter; use papyrus_storage::class::ClassStorageWriter; use papyrus_storage::compiled_class::CasmStorageWriter; use papyrus_storage::header::HeaderStorageWriter; use papyrus_storage::state::StateStorageWriter; -use papyrus_storage::StorageWriter; use papyrus_test_utils::{ + GetTestInstance, auto_impl_get_test_instance, get_number_of_variants, get_rng, read_json_file, - GetTestInstance, }; use pretty_assertions::assert_eq; use starknet_api::block::{ @@ -77,6 +77,7 @@ use starknet_api::transaction::{ TransactionVersion, }; use starknet_api::{calldata, class_hash, contract_address, felt, patricia_key}; +use starknet_client::reader::PendingData; use starknet_client::reader::objects::pending_data::{ PendingBlock, PendingBlockOrDeprecated, @@ -88,23 +89,22 @@ use starknet_client::reader::objects::transaction::{ Transaction as ClientTransaction, TransactionReceipt as ClientTransactionReceipt, }; -use starknet_client::reader::PendingData; use starknet_types_core::felt::Felt; use tokio::sync::RwLock; use super::api::api_impl::JsonRpcServerImpl; use super::api::{ - decompress_program, SimulatedTransaction, SimulationFlag, TransactionTraceWithHash, + decompress_program, }; use super::broadcasted_transaction::{ BroadcastedDeclareTransaction, BroadcastedDeclareV1Transaction, BroadcastedTransaction, }; -use super::error::{TransactionExecutionError, BLOCK_NOT_FOUND, CONTRACT_NOT_FOUND}; +use super::error::{BLOCK_NOT_FOUND, CONTRACT_NOT_FOUND, TransactionExecutionError}; use super::execution::{ DeclareTransactionTrace, DeployAccountTransactionTrace, @@ -134,6 +134,7 @@ use super::transaction::{ }; use crate::api::{BlockHashOrNumber, BlockId, CallRequest, Tag}; use crate::test_utils::{ + SpecFile, call_and_validate_schema_for_result, call_api_then_assert_and_validate_schema_for_result, get_starknet_spec_api_schema_for_components, @@ -144,7 +145,6 @@ use crate::test_utils::{ get_test_rpc_server_and_storage_writer, get_test_rpc_server_and_storage_writer_from_params, validate_schema, - SpecFile, }; use crate::version_config::VERSION_0_7 as VERSION; @@ -786,41 +786,32 @@ async fn trace_block_transactions_regular_and_pending() { writer .begin_rw_txn() .unwrap() - .append_header( - BlockNumber(3), - &BlockHeader { - l1_gas_price: *GAS_PRICE, - sequencer: *SEQUENCER_ADDRESS, - timestamp: *BLOCK_TIMESTAMP, - block_hash: BlockHash(felt!("0x3")), - parent_hash: BlockHash(felt!("0x2")), - ..Default::default() - }, - ) + .append_header(BlockNumber(3), &BlockHeader { + l1_gas_price: *GAS_PRICE, + sequencer: *SEQUENCER_ADDRESS, + timestamp: *BLOCK_TIMESTAMP, + block_hash: BlockHash(felt!("0x3")), + parent_hash: BlockHash(felt!("0x2")), + ..Default::default() + }) .unwrap() - .append_body( - BlockNumber(3), - BlockBody { - transactions: vec![tx1, tx2], - transaction_outputs: vec![ - starknet_api::transaction::TransactionOutput::Invoke( - starknet_api::transaction::InvokeTransactionOutput::default(), - ), - starknet_api::transaction::TransactionOutput::Invoke( - starknet_api::transaction::InvokeTransactionOutput::default(), - ), - ], - transaction_hashes: vec![tx_hash1, tx_hash2], - }, - ) + .append_body(BlockNumber(3), BlockBody { + transactions: vec![tx1, tx2], + transaction_outputs: vec![ + starknet_api::transaction::TransactionOutput::Invoke( + starknet_api::transaction::InvokeTransactionOutput::default(), + ), + starknet_api::transaction::TransactionOutput::Invoke( + starknet_api::transaction::InvokeTransactionOutput::default(), + ), + ], + transaction_hashes: vec![tx_hash1, tx_hash2], + }) .unwrap() - .append_state_diff( - BlockNumber(3), - StarknetApiStateDiff { - nonces: indexmap!(*ACCOUNT_ADDRESS => Nonce(felt!(2_u128))), - ..Default::default() - }, - ) + .append_state_diff(BlockNumber(3), StarknetApiStateDiff { + nonces: indexmap!(*ACCOUNT_ADDRESS => Nonce(felt!(2_u128))), + ..Default::default() + }) .unwrap() .append_classes(BlockNumber(3), &[], &[]) .unwrap() @@ -902,10 +893,9 @@ async fn trace_block_transactions_regular_and_pending() { prepare_storage_for_execution(storage_writer); let res = module - .call::<_, Vec>( - "starknet_V0_7_traceBlockTransactions", - [BlockId::Tag(Tag::Pending)], - ) + .call::<_, Vec>("starknet_V0_7_traceBlockTransactions", [ + BlockId::Tag(Tag::Pending), + ]) .await .unwrap(); @@ -989,42 +979,33 @@ async fn trace_block_transactions_and_trace_transaction_execution_context() { writer .begin_rw_txn() .unwrap() - .append_header( - BlockNumber(3), - &BlockHeader { - block_number: BlockNumber(3), - l1_gas_price: *GAS_PRICE, - sequencer: *SEQUENCER_ADDRESS, - timestamp: *BLOCK_TIMESTAMP, - block_hash: BlockHash(felt!("0x3")), - parent_hash: BlockHash(felt!("0x2")), - ..Default::default() - }, - ) + .append_header(BlockNumber(3), &BlockHeader { + block_number: BlockNumber(3), + l1_gas_price: *GAS_PRICE, + sequencer: *SEQUENCER_ADDRESS, + timestamp: *BLOCK_TIMESTAMP, + block_hash: BlockHash(felt!("0x3")), + parent_hash: BlockHash(felt!("0x2")), + ..Default::default() + }) .unwrap() - .append_body( - BlockNumber(3), - BlockBody { - transactions: vec![tx1, tx2], - transaction_outputs: vec![ - starknet_api::transaction::TransactionOutput::Invoke( - starknet_api::transaction::InvokeTransactionOutput::default(), - ), - starknet_api::transaction::TransactionOutput::Invoke( - starknet_api::transaction::InvokeTransactionOutput::default(), - ), - ], - transaction_hashes: vec![tx_hash1, tx_hash2], - }, - ) + .append_body(BlockNumber(3), BlockBody { + transactions: vec![tx1, tx2], + transaction_outputs: vec![ + starknet_api::transaction::TransactionOutput::Invoke( + starknet_api::transaction::InvokeTransactionOutput::default(), + ), + starknet_api::transaction::TransactionOutput::Invoke( + starknet_api::transaction::InvokeTransactionOutput::default(), + ), + ], + transaction_hashes: vec![tx_hash1, tx_hash2], + }) .unwrap() - .append_state_diff( - BlockNumber(3), - StarknetApiStateDiff { - nonces: indexmap!(*ACCOUNT_ADDRESS => Nonce(felt!(2_u128))), - ..Default::default() - }, - ) + .append_state_diff(BlockNumber(3), StarknetApiStateDiff { + nonces: indexmap!(*ACCOUNT_ADDRESS => Nonce(felt!(2_u128))), + ..Default::default() + }) .unwrap() .append_classes(BlockNumber(3), &[], &[]) .unwrap() @@ -1054,10 +1035,9 @@ async fn trace_block_transactions_and_trace_transaction_execution_context() { ); let res = module - .call::<_, Vec>( - "starknet_V0_7_traceBlockTransactions", - [BlockId::HashOrNumber(BlockHashOrNumber::Number(BlockNumber(3)))], - ) + .call::<_, Vec>("starknet_V0_7_traceBlockTransactions", [ + BlockId::HashOrNumber(BlockHashOrNumber::Number(BlockNumber(3))), + ]) .await .unwrap(); validate_result(res[0].trace_root.clone()); @@ -1173,10 +1153,9 @@ async fn pending_trace_block_transactions_and_trace_transaction_execution_contex ); let res = module - .call::<_, Vec>( - "starknet_V0_7_traceBlockTransactions", - [BlockId::Tag(Tag::Pending)], - ) + .call::<_, Vec>("starknet_V0_7_traceBlockTransactions", [ + BlockId::Tag(Tag::Pending), + ]) .await .unwrap(); validate_result(res[0].trace_root.clone()); @@ -1655,75 +1634,62 @@ fn prepare_storage_for_execution(mut storage_writer: StorageWriter) -> StorageWr storage_writer .begin_rw_txn() .unwrap() - .append_header( - BlockNumber(0), - &BlockHeader { - l1_gas_price: *GAS_PRICE, - l1_data_gas_price: *DATA_GAS_PRICE, - sequencer: *SEQUENCER_ADDRESS, - timestamp: *BLOCK_TIMESTAMP, - ..Default::default() - }, - ) + .append_header(BlockNumber(0), &BlockHeader { + l1_gas_price: *GAS_PRICE, + l1_data_gas_price: *DATA_GAS_PRICE, + sequencer: *SEQUENCER_ADDRESS, + timestamp: *BLOCK_TIMESTAMP, + ..Default::default() + }) .unwrap() .append_body(BlockNumber(0), BlockBody::default()) .unwrap() - .append_state_diff( - BlockNumber(0), - StarknetApiStateDiff { - deployed_contracts: indexmap!( - *DEPRECATED_CONTRACT_ADDRESS => class_hash1, - *CONTRACT_ADDRESS => class_hash2, - *ACCOUNT_ADDRESS => *ACCOUNT_CLASS_HASH, - *TEST_ERC20_CONTRACT_ADDRESS => *TEST_ERC20_CONTRACT_CLASS_HASH, - ), - storage_diffs: indexmap!( - *TEST_ERC20_CONTRACT_ADDRESS => indexmap!( - // Give the accounts some balance. - account_balance_key => *ACCOUNT_INITIAL_BALANCE, - // Give the first account mint permission (what is this?). - minter_var_address => *ACCOUNT_ADDRESS.0.key() - ), - ), - declared_classes: indexmap!(class_hash2 => compiled_class_hash), - deprecated_declared_classes: vec![ - class_hash1, - *ACCOUNT_CLASS_HASH, - *TEST_ERC20_CONTRACT_CLASS_HASH, - ], - nonces: indexmap!( - *TEST_ERC20_CONTRACT_ADDRESS => Nonce::default(), - *CONTRACT_ADDRESS => Nonce::default(), - *DEPRECATED_CONTRACT_ADDRESS => Nonce::default(), - *ACCOUNT_ADDRESS => Nonce::default(), + .append_state_diff(BlockNumber(0), StarknetApiStateDiff { + deployed_contracts: indexmap!( + *DEPRECATED_CONTRACT_ADDRESS => class_hash1, + *CONTRACT_ADDRESS => class_hash2, + *ACCOUNT_ADDRESS => *ACCOUNT_CLASS_HASH, + *TEST_ERC20_CONTRACT_ADDRESS => *TEST_ERC20_CONTRACT_CLASS_HASH, + ), + storage_diffs: indexmap!( + *TEST_ERC20_CONTRACT_ADDRESS => indexmap!( + // Give the accounts some balance. + account_balance_key => *ACCOUNT_INITIAL_BALANCE, + // Give the first account mint permission (what is this?). + minter_var_address => *ACCOUNT_ADDRESS.0.key() ), - replaced_classes: indexmap!(), - }, - ) - .unwrap() - .append_classes( - BlockNumber(0), - &[(class_hash2, &class2)], - &[ - (class_hash1, &class1), - (*ACCOUNT_CLASS_HASH, &account_class), - (*TEST_ERC20_CONTRACT_CLASS_HASH, &fee_contract_class), + ), + declared_classes: indexmap!(class_hash2 => compiled_class_hash), + deprecated_declared_classes: vec![ + class_hash1, + *ACCOUNT_CLASS_HASH, + *TEST_ERC20_CONTRACT_CLASS_HASH, ], - ) + nonces: indexmap!( + *TEST_ERC20_CONTRACT_ADDRESS => Nonce::default(), + *CONTRACT_ADDRESS => Nonce::default(), + *DEPRECATED_CONTRACT_ADDRESS => Nonce::default(), + *ACCOUNT_ADDRESS => Nonce::default(), + ), + replaced_classes: indexmap!(), + }) + .unwrap() + .append_classes(BlockNumber(0), &[(class_hash2, &class2)], &[ + (class_hash1, &class1), + (*ACCOUNT_CLASS_HASH, &account_class), + (*TEST_ERC20_CONTRACT_CLASS_HASH, &fee_contract_class), + ]) .unwrap() .append_casm(&class_hash2, &casm) .unwrap() - .append_header( - BlockNumber(1), - &BlockHeader { - l1_gas_price: different_gas_price, - sequencer: *SEQUENCER_ADDRESS, - timestamp: *BLOCK_TIMESTAMP, - block_hash: BlockHash(felt!("0x1")), - block_number: BlockNumber(1), - ..Default::default() - }, - ) + .append_header(BlockNumber(1), &BlockHeader { + l1_gas_price: different_gas_price, + sequencer: *SEQUENCER_ADDRESS, + timestamp: *BLOCK_TIMESTAMP, + block_hash: BlockHash(felt!("0x1")), + block_number: BlockNumber(1), + ..Default::default() + }) .unwrap() .append_body(BlockNumber(1), BlockBody::default()) .unwrap() @@ -1731,19 +1697,16 @@ fn prepare_storage_for_execution(mut storage_writer: StorageWriter) -> StorageWr .unwrap() .append_classes(BlockNumber(1), &[], &[]) .unwrap() - .append_header( - BlockNumber(2), - &BlockHeader { - l1_gas_price: *GAS_PRICE, - sequencer: *SEQUENCER_ADDRESS, - timestamp: *BLOCK_TIMESTAMP, - // Test that l1_da_mode affects the fee. - l1_da_mode: L1DataAvailabilityMode::Blob, - block_hash: BlockHash(felt!("0x2")), - block_number: BlockNumber(2), - ..Default::default() - }, - ) + .append_header(BlockNumber(2), &BlockHeader { + l1_gas_price: *GAS_PRICE, + sequencer: *SEQUENCER_ADDRESS, + timestamp: *BLOCK_TIMESTAMP, + // Test that l1_da_mode affects the fee. + l1_da_mode: L1DataAvailabilityMode::Blob, + block_hash: BlockHash(felt!("0x2")), + block_number: BlockNumber(2), + ..Default::default() + }) .unwrap() .append_body(BlockNumber(2), BlockBody::default()) .unwrap() @@ -1761,16 +1724,13 @@ fn write_empty_block(mut storage_writer: StorageWriter) { storage_writer .begin_rw_txn() .unwrap() - .append_header( - BlockNumber(0), - &BlockHeader { - l1_gas_price: *GAS_PRICE, - l1_data_gas_price: *DATA_GAS_PRICE, - sequencer: *SEQUENCER_ADDRESS, - timestamp: *BLOCK_TIMESTAMP, - ..Default::default() - }, - ) + .append_header(BlockNumber(0), &BlockHeader { + l1_gas_price: *GAS_PRICE, + l1_data_gas_price: *DATA_GAS_PRICE, + sequencer: *SEQUENCER_ADDRESS, + timestamp: *BLOCK_TIMESTAMP, + ..Default::default() + }) .unwrap() .append_body(BlockNumber(0), BlockBody::default()) .unwrap() diff --git a/crates/papyrus_rpc/src/v0_7/transaction.rs b/crates/papyrus_rpc/src/v0_7/transaction.rs index 8f4596b664..a4123ae194 100644 --- a/crates/papyrus_rpc/src/v0_7/transaction.rs +++ b/crates/papyrus_rpc/src/v0_7/transaction.rs @@ -8,13 +8,13 @@ use std::num::NonZeroU64; use std::ops::Add; use std::sync::Arc; -use ethers::core::abi::{encode_packed, Token}; +use ethers::core::abi::{Token, encode_packed}; use ethers::core::utils::keccak256; use jsonrpsee::types::ErrorObjectOwned; use papyrus_execution::objects::PriceUnit; +use papyrus_storage::StorageTxn; use papyrus_storage::body::BodyStorageReader; use papyrus_storage::db::TransactionKind; -use papyrus_storage::StorageTxn; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use starknet_api::block::{BlockHash, BlockNumber, BlockStatus}; use starknet_api::core::{ diff --git a/crates/papyrus_rpc/src/v0_7/transaction_test.rs b/crates/papyrus_rpc/src/v0_7/transaction_test.rs index 5bd9f0d709..b5c3275837 100644 --- a/crates/papyrus_rpc/src/v0_7/transaction_test.rs +++ b/crates/papyrus_rpc/src/v0_7/transaction_test.rs @@ -1,8 +1,8 @@ use papyrus_test_utils::{ + GetTestInstance, auto_impl_get_test_instance, get_number_of_variants, get_rng, - GetTestInstance, }; use pretty_assertions::assert_eq; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, Nonce, PatriciaKey}; diff --git a/crates/papyrus_rpc/src/v0_7/write_api_error.rs b/crates/papyrus_rpc/src/v0_7/write_api_error.rs index ba977c0411..a5a9643238 100644 --- a/crates/papyrus_rpc/src/v0_7/write_api_error.rs +++ b/crates/papyrus_rpc/src/v0_7/write_api_error.rs @@ -1,9 +1,6 @@ use starknet_client::starknet_error::{KnownStarknetErrorCode, StarknetError, StarknetErrorCode}; use super::error::{ - unexpected_error, - validation_failure, - JsonRpcError, CLASS_ALREADY_DECLARED, CLASS_HASH_NOT_FOUND, COMPILATION_FAILED, @@ -13,9 +10,12 @@ use super::error::{ INSUFFICIENT_ACCOUNT_BALANCE, INSUFFICIENT_MAX_FEE, INVALID_TRANSACTION_NONCE, + JsonRpcError, NON_ACCOUNT, UNSUPPORTED_CONTRACT_CLASS_VERSION, UNSUPPORTED_TX_VERSION, + unexpected_error, + validation_failure, }; #[cfg(test)] diff --git a/crates/papyrus_rpc/src/v0_7/write_api_error_test.rs b/crates/papyrus_rpc/src/v0_7/write_api_error_test.rs index 26a2eaf285..14d683453c 100644 --- a/crates/papyrus_rpc/src/v0_7/write_api_error_test.rs +++ b/crates/papyrus_rpc/src/v0_7/write_api_error_test.rs @@ -10,7 +10,7 @@ use super::{ starknet_error_to_deploy_account_error, starknet_error_to_invoke_error, }; -use crate::test_utils::{get_starknet_spec_api_schema_for_method_errors, SpecFile}; +use crate::test_utils::{SpecFile, get_starknet_spec_api_schema_for_method_errors}; use crate::version_config::VERSION_0_7 as Version; const MESSAGE: &str = "message"; diff --git a/crates/papyrus_rpc/src/v0_7/write_api_result_test.rs b/crates/papyrus_rpc/src/v0_7/write_api_result_test.rs index 0c8d30351b..c3ec820b08 100644 --- a/crates/papyrus_rpc/src/v0_7/write_api_result_test.rs +++ b/crates/papyrus_rpc/src/v0_7/write_api_result_test.rs @@ -1,4 +1,4 @@ -use papyrus_test_utils::{auto_impl_get_test_instance, get_rng, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, auto_impl_get_test_instance, get_rng}; use serde::Serialize; use starknet_api::core::{ClassHash, ContractAddress, PatriciaKey}; use starknet_api::felt; @@ -11,7 +11,7 @@ use starknet_client::writer::objects::response::{ }; use super::{AddDeclareOkResult, AddDeployAccountOkResult, AddInvokeOkResult}; -use crate::test_utils::{get_starknet_spec_api_schema_for_method_results, SpecFile}; +use crate::test_utils::{SpecFile, get_starknet_spec_api_schema_for_method_results}; use crate::version_config::VERSION_0_7 as VERSION; auto_impl_get_test_instance! { diff --git a/crates/papyrus_rpc/src/version_config_test.rs b/crates/papyrus_rpc/src/version_config_test.rs index f1e3f349b0..a6fb850a04 100644 --- a/crates/papyrus_rpc/src/version_config_test.rs +++ b/crates/papyrus_rpc/src/version_config_test.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use pretty_assertions::assert_eq; -use super::{VersionState, VERSION_CONFIG}; +use super::{VERSION_CONFIG, VersionState}; #[tokio::test] async fn validate_version_configuration() { diff --git a/crates/papyrus_rpc/tests/gateway_integration_test.rs b/crates/papyrus_rpc/tests/gateway_integration_test.rs index 2b8e238cc0..4804533886 100644 --- a/crates/papyrus_rpc/tests/gateway_integration_test.rs +++ b/crates/papyrus_rpc/tests/gateway_integration_test.rs @@ -3,8 +3,8 @@ use std::env; use jsonrpsee::core::client::ClientT; use jsonrpsee::http_client::{HttpClient, HttpClientBuilder}; use jsonrpsee::rpc_params; -use papyrus_common::transaction_hash::get_transaction_hash; use papyrus_common::TransactionOptions; +use papyrus_common::transaction_hash::get_transaction_hash; use papyrus_rpc::{ AddInvokeOkResultRPC0_6, InvokeTransactionRPC0_6, diff --git a/crates/papyrus_storage/src/base_layer.rs b/crates/papyrus_storage/src/base_layer.rs index ea5e844e71..f5f0c40565 100644 --- a/crates/papyrus_storage/src/base_layer.rs +++ b/crates/papyrus_storage/src/base_layer.rs @@ -42,7 +42,7 @@ mod base_layer_test; use starknet_api::block::BlockNumber; use crate::db::table_types::Table; -use crate::db::{TransactionKind, RW}; +use crate::db::{RW, TransactionKind}; use crate::{MarkerKind, StorageResult, StorageTxn}; /// Interface for reading data related to the base layer. diff --git a/crates/papyrus_storage/src/bin/storage_benchmark.rs b/crates/papyrus_storage/src/bin/storage_benchmark.rs index 61da955958..dd082d158b 100644 --- a/crates/papyrus_storage/src/bin/storage_benchmark.rs +++ b/crates/papyrus_storage/src/bin/storage_benchmark.rs @@ -1,11 +1,11 @@ -use std::fs::{read_to_string, File}; +use std::fs::{File, read_to_string}; use std::time::Duration; use clap::{Arg, Command}; use papyrus_common::storage_query::StorageQuery; +use papyrus_storage::StorageConfig; use papyrus_storage::db::DbConfig; use papyrus_storage::state::StateStorageReader; -use papyrus_storage::StorageConfig; use serde::{Deserialize, Serialize}; use starknet_api::core::ChainId; use statistical::median; diff --git a/crates/papyrus_storage/src/body/events_test.rs b/crates/papyrus_storage/src/body/events_test.rs index 3765b96cde..3c78eab8fe 100644 --- a/crates/papyrus_storage/src/body/events_test.rs +++ b/crates/papyrus_storage/src/body/events_test.rs @@ -12,7 +12,7 @@ use starknet_api::transaction::{ TransactionOffsetInBlock, }; -use crate::body::events::{get_events_from_tx, EventIndex, EventsReader}; +use crate::body::events::{EventIndex, EventsReader, get_events_from_tx}; use crate::body::{BodyStorageWriter, TransactionIndex}; use crate::db::table_types::Table; use crate::header::HeaderStorageWriter; @@ -235,10 +235,10 @@ fn get_events_from_tx_test() { ((ca1, EventIndex(tx_index, EventIndexInTransactionOutput(2))), e3.content.clone()); // All events. - assert_eq!( - get_events_from_tx(events.clone(), tx_index, ca1, 0), - vec![e1_output.clone(), e3_output.clone()] - ); + assert_eq!(get_events_from_tx(events.clone(), tx_index, ca1, 0), vec![ + e1_output.clone(), + e3_output.clone() + ]); assert_eq!(get_events_from_tx(events.clone(), tx_index, ca2, 0), vec![e2_output.clone()]); // All events of starting from the second event. diff --git a/crates/papyrus_storage/src/body/mod.rs b/crates/papyrus_storage/src/body/mod.rs index 066be012aa..5fd3e5a1c2 100644 --- a/crates/papyrus_storage/src/body/mod.rs +++ b/crates/papyrus_storage/src/body/mod.rs @@ -59,7 +59,7 @@ use tracing::debug; use crate::db::serialization::{NoVersionValueWrapper, VersionZeroWrapper}; use crate::db::table_types::{CommonPrefix, DbCursorTrait, NoValue, SimpleTable, Table}; -use crate::db::{DbTransaction, TableHandle, TransactionKind, RW}; +use crate::db::{DbTransaction, RW, TableHandle, TransactionKind}; use crate::{ FileHandlers, MarkerKind, @@ -456,11 +456,11 @@ fn write_transactions<'env>( let tx_output_location = file_handlers.append_transaction_output(tx_output); write_events(tx_output, txn, events_table, transaction_index)?; transaction_hash_to_idx_table.insert(txn, tx_hash, &transaction_index)?; - transaction_metadata_table.append( - txn, - &transaction_index, - &TransactionMetadata { tx_location, tx_output_location, tx_hash: *tx_hash }, - )?; + transaction_metadata_table.append(txn, &transaction_index, &TransactionMetadata { + tx_location, + tx_output_location, + tx_hash: *tx_hash, + })?; // If this is the last iteration, update the file offset table. if index == block_body.transactions.len() - 1 { diff --git a/crates/papyrus_storage/src/class.rs b/crates/papyrus_storage/src/class.rs index ceede70b94..428e85f290 100644 --- a/crates/papyrus_storage/src/class.rs +++ b/crates/papyrus_storage/src/class.rs @@ -74,7 +74,7 @@ use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContract use starknet_api::state::ContractClass; use crate::db::table_types::Table; -use crate::db::{TransactionKind, RW}; +use crate::db::{RW, TransactionKind}; use crate::state::{DeclaredClassesTable, DeprecatedDeclaredClassesTable, FileOffsetTable}; use crate::{ DbTransaction, diff --git a/crates/papyrus_storage/src/class_test.rs b/crates/papyrus_storage/src/class_test.rs index 72392da987..5ab4d17eac 100644 --- a/crates/papyrus_storage/src/class_test.rs +++ b/crates/papyrus_storage/src/class_test.rs @@ -9,9 +9,9 @@ use starknet_api::hash::StarkHash; use starknet_api::state::{ContractClass, StateNumber, ThinStateDiff}; use super::{ClassStorageReader, ClassStorageWriter}; +use crate::StorageError; use crate::state::{StateStorageReader, StateStorageWriter}; use crate::test_utils::get_test_storage; -use crate::StorageError; #[test] fn append_classes_writes_correct_data() { @@ -28,20 +28,16 @@ fn append_classes_writes_correct_data() { writer .begin_rw_txn() .unwrap() - .append_state_diff( - BlockNumber(0), - ThinStateDiff { - declared_classes: indexmap! { class_hash => CompiledClassHash::default() }, - deprecated_declared_classes: vec![deprecated_class_hash], - ..Default::default() - }, - ) + .append_state_diff(BlockNumber(0), ThinStateDiff { + declared_classes: indexmap! { class_hash => CompiledClassHash::default() }, + deprecated_declared_classes: vec![deprecated_class_hash], + ..Default::default() + }) .unwrap() - .append_classes( - BlockNumber(0), - &[(class_hash, &expected_class)], - &[(deprecated_class_hash, &expected_deprecated_class)], - ) + .append_classes(BlockNumber(0), &[(class_hash, &expected_class)], &[( + deprecated_class_hash, + &expected_deprecated_class, + )]) .unwrap() .commit() .unwrap(); diff --git a/crates/papyrus_storage/src/compiled_class.rs b/crates/papyrus_storage/src/compiled_class.rs index be55c0a1dd..588361c411 100644 --- a/crates/papyrus_storage/src/compiled_class.rs +++ b/crates/papyrus_storage/src/compiled_class.rs @@ -44,7 +44,7 @@ use starknet_api::core::ClassHash; use crate::db::serialization::VersionZeroWrapper; use crate::db::table_types::{SimpleTable, Table}; -use crate::db::{DbTransaction, TableHandle, TransactionKind, RW}; +use crate::db::{DbTransaction, RW, TableHandle, TransactionKind}; use crate::mmap_file::LocationInFile; use crate::{FileHandlers, MarkerKind, MarkersTable, OffsetKind, StorageResult, StorageTxn}; diff --git a/crates/papyrus_storage/src/compiled_class_test.rs b/crates/papyrus_storage/src/compiled_class_test.rs index f3c1229402..de038b2a83 100644 --- a/crates/papyrus_storage/src/compiled_class_test.rs +++ b/crates/papyrus_storage/src/compiled_class_test.rs @@ -4,10 +4,10 @@ use papyrus_test_utils::read_json_file; use pretty_assertions::assert_eq; use starknet_api::core::ClassHash; +use crate::StorageError; use crate::compiled_class::{CasmStorageReader, CasmStorageWriter}; use crate::db::{DbError, KeyAlreadyExistsError}; use crate::test_utils::get_test_storage; -use crate::StorageError; #[test] fn append_casm() { diff --git a/crates/papyrus_storage/src/db/db_test.rs b/crates/papyrus_storage/src/db/db_test.rs index 747d88f458..760a22b4ba 100644 --- a/crates/papyrus_storage/src/db/db_test.rs +++ b/crates/papyrus_storage/src/db/db_test.rs @@ -5,7 +5,7 @@ use tempfile::TempDir; use crate::db::serialization::{NoVersionValueWrapper, ValueSerde, VersionZeroWrapper}; use crate::db::table_types::Table; -use crate::db::{get_page_size, open_env, DbError, DbIter, DbReader, DbResult, DbWriter}; +use crate::db::{DbError, DbIter, DbReader, DbResult, DbWriter, get_page_size, open_env}; use crate::test_utils::get_test_config; pub(crate) fn get_test_env() -> ((DbReader, DbWriter), TempDir) { diff --git a/crates/papyrus_storage/src/db/mod.rs b/crates/papyrus_storage/src/db/mod.rs index 2573ebb7b0..8ad07b38d6 100644 --- a/crates/papyrus_storage/src/db/mod.rs +++ b/crates/papyrus_storage/src/db/mod.rs @@ -30,7 +30,7 @@ use std::result; use std::sync::Arc; use libmdbx::{DatabaseFlags, Geometry, PageSize, WriteMap}; -use papyrus_config::dumping::{ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, ser_param}; use papyrus_config::validators::{validate_ascii, validate_path_exists}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use papyrus_proc_macros::latency_histogram; diff --git a/crates/papyrus_storage/src/db/table_types/dup_sort_tables.rs b/crates/papyrus_storage/src/db/table_types/dup_sort_tables.rs index 7c607b6b9d..fd88759305 100644 --- a/crates/papyrus_storage/src/db/table_types/dup_sort_tables.rs +++ b/crates/papyrus_storage/src/db/table_types/dup_sort_tables.rs @@ -19,10 +19,10 @@ use crate::db::{ DbValueType, DbWriter, KeyAlreadyExistsError, + RW, TableHandle, TableIdentifier, TransactionKind, - RW, }; // NOTICE: If a write operation fails (insert, upsert, append, delete, append_greater_sub_key), the diff --git a/crates/papyrus_storage/src/db/table_types/dup_sort_tables_test.rs b/crates/papyrus_storage/src/db/table_types/dup_sort_tables_test.rs index c8c01a9275..1dc76c9284 100644 --- a/crates/papyrus_storage/src/db/table_types/dup_sort_tables_test.rs +++ b/crates/papyrus_storage/src/db/table_types/dup_sort_tables_test.rs @@ -3,9 +3,9 @@ use assert_matches::assert_matches; use super::{DupSortTableType, DupSortUtils}; use crate::db::db_test::get_test_env; use crate::db::serialization::NoVersionValueWrapper; -use crate::db::table_types::dup_sort_tables::add_one; -use crate::db::table_types::test_utils::{random_table_test, table_test, TableKey, TableValue}; use crate::db::table_types::Table; +use crate::db::table_types::dup_sort_tables::add_one; +use crate::db::table_types::test_utils::{TableKey, TableValue, random_table_test, table_test}; use crate::db::{DbError, DbResult, DbWriter, TableIdentifier}; #[test] diff --git a/crates/papyrus_storage/src/db/table_types/mod.rs b/crates/papyrus_storage/src/db/table_types/mod.rs index 78113259da..b5d1d2e47a 100644 --- a/crates/papyrus_storage/src/db/table_types/mod.rs +++ b/crates/papyrus_storage/src/db/table_types/mod.rs @@ -4,7 +4,7 @@ use std::marker::PhantomData; use libmdbx::Cursor; use super::serialization::{Key as KeyTrait, ValueSerde}; -use super::{DbResult, DbTransaction, TransactionKind, RW}; +use super::{DbResult, DbTransaction, RW, TransactionKind}; mod dup_sort_tables; mod simple_table; diff --git a/crates/papyrus_storage/src/db/table_types/simple_table.rs b/crates/papyrus_storage/src/db/table_types/simple_table.rs index 3720814544..64329c4c4f 100644 --- a/crates/papyrus_storage/src/db/table_types/simple_table.rs +++ b/crates/papyrus_storage/src/db/table_types/simple_table.rs @@ -19,10 +19,10 @@ use crate::db::{ DbValueType, DbWriter, KeyAlreadyExistsError, + RW, TableHandle, TableIdentifier, TransactionKind, - RW, }; // A simple mapping between key and value. diff --git a/crates/papyrus_storage/src/db/table_types/simple_table_test.rs b/crates/papyrus_storage/src/db/table_types/simple_table_test.rs index 855c70dcc6..ee9720ad37 100644 --- a/crates/papyrus_storage/src/db/table_types/simple_table_test.rs +++ b/crates/papyrus_storage/src/db/table_types/simple_table_test.rs @@ -1,5 +1,5 @@ -use crate::db::table_types::test_utils::table_test; use crate::db::DbWriter; +use crate::db::table_types::test_utils::table_test; #[test] fn simple_table_test() { diff --git a/crates/papyrus_storage/src/db/table_types/test_utils.rs b/crates/papyrus_storage/src/db/table_types/test_utils.rs index 579f405b97..7925afce01 100644 --- a/crates/papyrus_storage/src/db/table_types/test_utils.rs +++ b/crates/papyrus_storage/src/db/table_types/test_utils.rs @@ -1,15 +1,15 @@ use assert_matches::assert_matches; -use rand::rngs::ThreadRng; use rand::Rng; +use rand::rngs::ThreadRng; use tracing::debug; use super::{Table, TableType}; +use crate::DbError; use crate::db::db_test::get_test_env; use crate::db::serialization::{NoVersionValueWrapper, StorageSerde, StorageSerdeError}; use crate::db::table_types::{DbCursor, DbCursorTrait}; -use crate::db::{DbReader, DbResult, DbWriter, TableHandle, TableIdentifier, RO, RW}; +use crate::db::{DbReader, DbResult, DbWriter, RO, RW, TableHandle, TableIdentifier}; use crate::serialization::serializers::auto_storage_serde; -use crate::DbError; // TODO(dvir): consider adding tests with keys and values in different sizes. diff --git a/crates/papyrus_storage/src/header.rs b/crates/papyrus_storage/src/header.rs index 6944c33342..8a568cd1ee 100644 --- a/crates/papyrus_storage/src/header.rs +++ b/crates/papyrus_storage/src/header.rs @@ -61,7 +61,7 @@ use tracing::debug; use crate::db::serialization::NoVersionValueWrapper; use crate::db::table_types::{DbCursorTrait, SimpleTable, Table}; -use crate::db::{DbTransaction, TableHandle, TransactionKind, RW}; +use crate::db::{DbTransaction, RW, TableHandle, TransactionKind}; use crate::{MarkerKind, MarkersTable, StorageError, StorageResult, StorageTxn}; #[derive(Debug, Default, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)] diff --git a/crates/papyrus_storage/src/header_test.rs b/crates/papyrus_storage/src/header_test.rs index d5342cfad4..09ded0b786 100644 --- a/crates/papyrus_storage/src/header_test.rs +++ b/crates/papyrus_storage/src/header_test.rs @@ -126,15 +126,15 @@ fn append_2_headers(writer: &mut StorageWriter) { writer .begin_rw_txn() .unwrap() - .append_header( - BlockNumber(0), - &BlockHeader { block_hash: BlockHash(felt!("0x0")), ..BlockHeader::default() }, - ) + .append_header(BlockNumber(0), &BlockHeader { + block_hash: BlockHash(felt!("0x0")), + ..BlockHeader::default() + }) .unwrap() - .append_header( - BlockNumber(1), - &BlockHeader { block_hash: BlockHash(felt!("0x1")), ..BlockHeader::default() }, - ) + .append_header(BlockNumber(1), &BlockHeader { + block_hash: BlockHash(felt!("0x1")), + ..BlockHeader::default() + }) .unwrap() .commit() .unwrap(); diff --git a/crates/papyrus_storage/src/lib.rs b/crates/papyrus_storage/src/lib.rs index e02e825006..cd1351f9f5 100644 --- a/crates/papyrus_storage/src/lib.rs +++ b/crates/papyrus_storage/src/lib.rs @@ -110,15 +110,15 @@ use db::db_stats::{DbTableStats, DbWholeStats}; use db::serialization::{Key, NoVersionValueWrapper, ValueSerde, VersionZeroWrapper}; use db::table_types::{CommonPrefix, NoValue, Table, TableType}; use mmap_file::{ - open_file, FileHandler, LocationInFile, MMapFileError, MmapFileConfig, Reader, Writer, + open_file, }; -use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, append_sub_config_name, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use papyrus_proc_macros::latency_histogram; use serde::{Deserialize, Serialize}; @@ -135,17 +135,17 @@ use version::{StorageVersionError, Version}; use crate::body::TransactionIndex; use crate::db::table_types::SimpleTable; use crate::db::{ - open_env, DbConfig, DbError, DbReader, DbTransaction, DbWriter, + RO, + RW, TableHandle, TableIdentifier, TransactionKind, - RO, - RW, + open_env, }; use crate::header::StorageBlockHeader; use crate::mmap_file::MMapFileStats; diff --git a/crates/papyrus_storage/src/mmap_file/mod.rs b/crates/papyrus_storage/src/mmap_file/mod.rs index 6928895122..9a4f671d49 100644 --- a/crates/papyrus_storage/src/mmap_file/mod.rs +++ b/crates/papyrus_storage/src/mmap_file/mod.rs @@ -16,7 +16,7 @@ use std::result; use std::sync::{Arc, Mutex}; use memmap2::{MmapMut, MmapOptions}; -use papyrus_config::dumping::{ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; #[cfg(test)] use papyrus_test_utils::GetTestInstance; @@ -28,7 +28,7 @@ use tracing::{debug, instrument, trace}; use validator::{Validate, ValidationError}; use crate::db::serialization::{StorageSerde, StorageSerdeError, ValueSerde}; -use crate::db::{TransactionKind, RO, RW}; +use crate::db::{RO, RW, TransactionKind}; type MmapFileResult = result::Result; diff --git a/crates/papyrus_storage/src/serialization/serializers.rs b/crates/papyrus_storage/src/serialization/serializers.rs index 2b19e9b01b..b902bd02be 100644 --- a/crates/papyrus_storage/src/serialization/serializers.rs +++ b/crates/papyrus_storage/src/serialization/serializers.rs @@ -6,12 +6,12 @@ use std::sync::Arc; use byteorder::BigEndian; use cairo_lang_casm::hints::Hint; +use cairo_lang_starknet_classes::NestedIntList; use cairo_lang_starknet_classes::casm_contract_class::{ CasmContractClass, CasmContractEntryPoint, CasmContractEntryPoints, }; -use cairo_lang_starknet_classes::NestedIntList; use cairo_lang_utils::bigint::BigUintAsHex; use indexmap::IndexMap; use integer_encoding::*; @@ -123,21 +123,21 @@ use starknet_api::transaction::{ use starknet_types_core::felt::Felt; use tracing::warn; -use crate::body::events::EventIndex; use crate::body::TransactionIndex; +use crate::body::events::EventIndex; use crate::compression_utils::{ + IsCompressed, compress, decompress, decompress_from_reader, serialize_and_compress, - IsCompressed, }; use crate::db::serialization::{StorageSerde, StorageSerdeError}; use crate::db::table_types::NoValue; use crate::header::StorageBlockHeader; use crate::mmap_file::LocationInFile; #[cfg(test)] -use crate::serialization::serializers_test::{create_storage_serde_test, StorageSerdeTest}; +use crate::serialization::serializers_test::{StorageSerdeTest, create_storage_serde_test}; use crate::state::data::IndexedDeprecatedContractClass; use crate::version::Version; use crate::{MarkerKind, OffsetKind, TransactionMetadata}; diff --git a/crates/papyrus_storage/src/serialization/serializers_test.rs b/crates/papyrus_storage/src/serialization/serializers_test.rs index 1c5459198e..61f476080d 100644 --- a/crates/papyrus_storage/src/serialization/serializers_test.rs +++ b/crates/papyrus_storage/src/serialization/serializers_test.rs @@ -6,7 +6,7 @@ use std::path::Path; use cairo_lang_casm::hints::CoreHintBase; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; -use papyrus_test_utils::{get_rng, read_json_file, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, get_rng, read_json_file}; use pretty_assertions::assert_eq; use starknet_api::block::BlockNumber; use starknet_api::core::ContractAddress; diff --git a/crates/papyrus_storage/src/state/mod.rs b/crates/papyrus_storage/src/state/mod.rs index 5a872c29ec..95e858ed3c 100644 --- a/crates/papyrus_storage/src/state/mod.rs +++ b/crates/papyrus_storage/src/state/mod.rs @@ -68,9 +68,9 @@ use tracing::debug; use crate::db::serialization::{NoVersionValueWrapper, VersionZeroWrapper}; use crate::db::table_types::{CommonPrefix, DbCursorTrait, SimpleTable, Table}; -use crate::db::{DbTransaction, TableHandle, TransactionKind, RW}; +use crate::db::{DbTransaction, RW, TableHandle, TransactionKind}; #[cfg(feature = "document_calls")] -use crate::document_calls::{add_query, StorageQuery}; +use crate::document_calls::{StorageQuery, add_query}; use crate::mmap_file::LocationInFile; use crate::state::data::IndexedDeprecatedContractClass; use crate::{ diff --git a/crates/papyrus_storage/src/state/state_test.rs b/crates/papyrus_storage/src/state/state_test.rs index 09cd1e787e..1ed81843a2 100644 --- a/crates/papyrus_storage/src/state/state_test.rs +++ b/crates/papyrus_storage/src/state/state_test.rs @@ -1,6 +1,6 @@ use assert_matches::assert_matches; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; -use indexmap::{indexmap, IndexMap}; +use indexmap::{IndexMap, indexmap}; use papyrus_test_utils::get_test_state_diff; use pretty_assertions::assert_eq; use starknet_api::block::BlockNumber; @@ -11,11 +11,11 @@ use starknet_api::state::{ContractClass, StateNumber, StorageKey, ThinStateDiff} use starknet_api::{felt, patricia_key}; use starknet_types_core::felt::Felt; +use crate::StorageWriter; use crate::class::{ClassStorageReader, ClassStorageWriter}; use crate::compiled_class::{CasmStorageReader, CasmStorageWriter}; use crate::state::{StateStorageReader, StateStorageWriter}; use crate::test_utils::get_test_storage; -use crate::StorageWriter; #[test] fn get_class_definition_at() { @@ -44,11 +44,10 @@ fn get_class_definition_at() { txn = txn.append_state_diff(BlockNumber(0), diff0).unwrap(); txn = txn.append_state_diff(BlockNumber(1), diff1).unwrap(); txn = txn - .append_classes( - BlockNumber(0), - &[(nc0, &new_class)], - &[(dc0, &dep_class), (dc1, &dep_class)], - ) + .append_classes(BlockNumber(0), &[(nc0, &new_class)], &[ + (dc0, &dep_class), + (dc1, &dep_class), + ]) .unwrap(); txn = txn.append_classes(BlockNumber(1), &[(nc1, &new_class)], &[(dc0, &dep_class)]).unwrap(); txn.commit().unwrap(); @@ -272,14 +271,11 @@ fn test_get_class_after_append_thin_state_diff() { let mut txn = writer.begin_rw_txn().unwrap(); // Append an empty state diff. txn = txn - .append_state_diff( - BlockNumber(0), - ThinStateDiff { - declared_classes: indexmap! { CLASS_HASH => CompiledClassHash::default() }, - deprecated_declared_classes: vec![DEPRECATED_CLASS_HASH], - ..Default::default() - }, - ) + .append_state_diff(BlockNumber(0), ThinStateDiff { + declared_classes: indexmap! { CLASS_HASH => CompiledClassHash::default() }, + deprecated_declared_classes: vec![DEPRECATED_CLASS_HASH], + ..Default::default() + }) .unwrap(); assert_eq!(txn.get_class_marker().unwrap(), BlockNumber(0)); @@ -486,11 +482,10 @@ fn revert_state() { .collect::>(), ) .unwrap() - .append_classes( - BlockNumber(1), - &[(class2, &ContractClass::default())], - &[(class1, &DeprecatedContractClass::default())], - ) + .append_classes(BlockNumber(1), &[(class2, &ContractClass::default())], &[( + class1, + &DeprecatedContractClass::default(), + )]) .unwrap() .append_casm(&class2, &compiled_class2) .unwrap() @@ -710,11 +705,10 @@ fn declare_revert_declare_scenario() { .unwrap() .append_state_diff(BlockNumber(0), diff0.clone()) .unwrap() - .append_classes( - BlockNumber(0), - &[(class_hash, &class)], - &[(deprecated_class_hash, &deprecated_class)], - ) + .append_classes(BlockNumber(0), &[(class_hash, &class)], &[( + deprecated_class_hash, + &deprecated_class, + )]) .unwrap() .commit() .unwrap(); @@ -750,11 +744,10 @@ fn declare_revert_declare_scenario() { .unwrap() .append_state_diff(BlockNumber(0), diff0.clone()) .unwrap() - .append_classes( - BlockNumber(0), - &[(class_hash, &class)], - &[(deprecated_class_hash, &deprecated_class)], - ) + .append_classes(BlockNumber(0), &[(class_hash, &class)], &[( + deprecated_class_hash, + &deprecated_class, + )]) .unwrap() .commit() .unwrap(); diff --git a/crates/papyrus_storage/src/test_instances.rs b/crates/papyrus_storage/src/test_instances.rs index 70edfec51e..d8580ce131 100644 --- a/crates/papyrus_storage/src/test_instances.rs +++ b/crates/papyrus_storage/src/test_instances.rs @@ -1,4 +1,4 @@ -use papyrus_test_utils::{auto_impl_get_test_instance, get_number_of_variants, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, auto_impl_get_test_instance, get_number_of_variants}; use starknet_api::block::{BlockHash, BlockNumber, BlockTimestamp, GasPricePerToken}; use starknet_api::core::{ EventCommitment, diff --git a/crates/papyrus_storage/src/test_utils.rs b/crates/papyrus_storage/src/test_utils.rs index 937b5f1ec1..173b7f5ac6 100644 --- a/crates/papyrus_storage/src/test_utils.rs +++ b/crates/papyrus_storage/src/test_utils.rs @@ -2,11 +2,11 @@ //! Test utilities for the storage crate users. use starknet_api::core::ChainId; -use tempfile::{tempdir, TempDir}; +use tempfile::{TempDir, tempdir}; use crate::db::DbConfig; use crate::mmap_file::MmapFileConfig; -use crate::{open_storage, StorageConfig, StorageReader, StorageScope, StorageWriter}; +use crate::{StorageConfig, StorageReader, StorageScope, StorageWriter, open_storage}; /// Returns a db config and the temporary directory that holds this db. /// The TempDir object is returned as a handler for the lifetime of this object (the temp diff --git a/crates/papyrus_storage/src/utils.rs b/crates/papyrus_storage/src/utils.rs index bcb33c99e9..d6cfa0ef62 100644 --- a/crates/papyrus_storage/src/utils.rs +++ b/crates/papyrus_storage/src/utils.rs @@ -16,10 +16,10 @@ use starknet_types_core::felt::Felt; use tracing::debug; use crate::compiled_class::CasmStorageReader; -use crate::db::table_types::Table; use crate::db::RO; +use crate::db::table_types::Table; use crate::state::StateStorageReader; -use crate::{open_storage, StorageConfig, StorageError, StorageReader, StorageResult, StorageTxn}; +use crate::{StorageConfig, StorageError, StorageReader, StorageResult, StorageTxn, open_storage}; #[derive(Serialize)] struct DumpDeclaredClass { @@ -70,15 +70,12 @@ fn dump_declared_classes_table_by_block_range_internal( if !first { writer.write_all(b",")?; } - serde_json::to_writer( - &mut writer, - &DumpDeclaredClass { - class_hash: *class_hash, - compiled_class_hash: *compiled_class_hash, - sierra_program: contract_class.sierra_program.clone(), - entry_points_by_type: contract_class.entry_points_by_type.clone(), - }, - )?; + serde_json::to_writer(&mut writer, &DumpDeclaredClass { + class_hash: *class_hash, + compiled_class_hash: *compiled_class_hash, + sierra_program: contract_class.sierra_program.clone(), + entry_points_by_type: contract_class.entry_points_by_type.clone(), + })?; first = false; } } diff --git a/crates/papyrus_storage/src/utils_test.rs b/crates/papyrus_storage/src/utils_test.rs index 9d201440c3..cdc9c29057 100644 --- a/crates/papyrus_storage/src/utils_test.rs +++ b/crates/papyrus_storage/src/utils_test.rs @@ -16,7 +16,7 @@ use super::update_storage_metrics; use crate::class::ClassStorageWriter; use crate::state::StateStorageWriter; use crate::test_utils::get_test_storage; -use crate::utils::{dump_declared_classes_table_by_block_range_internal, DumpDeclaredClass}; +use crate::utils::{DumpDeclaredClass, dump_declared_classes_table_by_block_range_internal}; // TODO(yael): fix dump_table_to_file. #[test] @@ -28,14 +28,11 @@ fn test_dump_declared_classes() { let ((reader, mut writer), _temp_dir) = get_test_storage(); for i in 0..5 { let i_felt = Felt::from(i as u128); - declared_classes.push(( - ClassHash(i_felt), - ContractClass { - sierra_program: vec![i_felt, i_felt], - entry_points_by_type: HashMap::new(), - abi: "".to_string(), - }, - )); + declared_classes.push((ClassHash(i_felt), ContractClass { + sierra_program: vec![i_felt, i_felt], + entry_points_by_type: HashMap::new(), + abi: "".to_string(), + })); state_diffs.push(ThinStateDiff { deployed_contracts: indexmap!(), storage_diffs: indexmap!(), diff --git a/crates/papyrus_storage/src/version.rs b/crates/papyrus_storage/src/version.rs index 4d1e700ffe..b58a3c3bc3 100644 --- a/crates/papyrus_storage/src/version.rs +++ b/crates/papyrus_storage/src/version.rs @@ -5,7 +5,7 @@ mod version_test; use std::fmt::Display; use crate::db::table_types::Table; -use crate::db::{TransactionKind, RW}; +use crate::db::{RW, TransactionKind}; use crate::{StorageError, StorageResult, StorageTxn}; const VERSION_STATE_KEY: &str = "storage_version_state"; diff --git a/crates/papyrus_storage/src/version_test.rs b/crates/papyrus_storage/src/version_test.rs index 8a0b64d1ae..5ed9802a3d 100644 --- a/crates/papyrus_storage/src/version_test.rs +++ b/crates/papyrus_storage/src/version_test.rs @@ -10,21 +10,21 @@ use crate::test_utils::{ }; use crate::version::{ StorageVersionError, + VERSION_BLOCKS_KEY, + VERSION_STATE_KEY, Version, VersionStorageReader, VersionStorageWriter, - VERSION_BLOCKS_KEY, - VERSION_STATE_KEY, }; use crate::{ - open_storage, - set_version_if_needed, - verify_storage_version, + STORAGE_VERSION_BLOCKS, + STORAGE_VERSION_STATE, StorageError, StorageScope, StorageWriter, - STORAGE_VERSION_BLOCKS, - STORAGE_VERSION_STATE, + open_storage, + set_version_if_needed, + verify_storage_version, }; // TODO: Add this test for set_blocks_version or combine the logic. @@ -93,16 +93,14 @@ fn version_migration() { get_test_storage_with_config_by_scope(StorageScope::FullArchive); // Set the storage version on a lower minor version. - change_storage_version( - &mut writer, - VERSION_STATE_KEY, - &Version { major: STORAGE_VERSION_STATE.major, minor: 0 }, - ); - change_storage_version( - &mut writer, - VERSION_BLOCKS_KEY, - &Version { major: STORAGE_VERSION_BLOCKS.major, minor: 0 }, - ); + change_storage_version(&mut writer, VERSION_STATE_KEY, &Version { + major: STORAGE_VERSION_STATE.major, + minor: 0, + }); + change_storage_version(&mut writer, VERSION_BLOCKS_KEY, &Version { + major: STORAGE_VERSION_BLOCKS.major, + minor: 0, + }); drop(reader); drop(writer); diff --git a/crates/papyrus_sync/src/lib.rs b/crates/papyrus_sync/src/lib.rs index 10a57782ee..7d50fdc20b 100644 --- a/crates/papyrus_sync/src/lib.rs +++ b/crates/papyrus_sync/src/lib.rs @@ -16,12 +16,12 @@ use std::time::Duration; use async_stream::try_stream; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use chrono::{TimeZone, Utc}; -use futures_util::{pin_mut, select, Stream, StreamExt}; +use futures_util::{Stream, StreamExt, pin_mut, select}; use indexmap::IndexMap; use papyrus_common::pending_classes::PendingClasses; -use papyrus_common::{metrics as papyrus_metrics, BlockHashAndNumber}; +use papyrus_common::{BlockHashAndNumber, metrics as papyrus_metrics}; use papyrus_config::converters::deserialize_seconds_to_duration; -use papyrus_config::dumping::{ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use papyrus_proc_macros::latency_histogram; use papyrus_storage::base_layer::{BaseLayerStorageReader, BaseLayerStorageWriter}; diff --git a/crates/papyrus_sync/src/pending_sync.rs b/crates/papyrus_sync/src/pending_sync.rs index 0a6afbce3d..de858215c5 100644 --- a/crates/papyrus_sync/src/pending_sync.rs +++ b/crates/papyrus_sync/src/pending_sync.rs @@ -5,8 +5,8 @@ use std::time::Duration; use futures::stream::FuturesUnordered; use futures_util::{FutureExt, StreamExt}; use papyrus_common::pending_classes::{PendingClasses, PendingClassesTrait}; -use papyrus_storage::header::HeaderStorageReader; use papyrus_storage::StorageReader; +use papyrus_storage::header::HeaderStorageReader; use starknet_api::block::{BlockHash, BlockNumber}; use starknet_api::core::ClassHash; use starknet_client::reader::{DeclaredClassHashEntry, PendingData}; @@ -14,9 +14,9 @@ use starknet_types_core::felt::Felt; use tokio::sync::RwLock; use tracing::{debug, trace}; +use crate::StateSyncError; use crate::sources::central::CentralSourceTrait; use crate::sources::pending::PendingSourceTrait; -use crate::StateSyncError; // Update the pending data and return when a new block is discovered. pub(crate) async fn sync_pending_data< diff --git a/crates/papyrus_sync/src/sources/base_layer.rs b/crates/papyrus_sync/src/sources/base_layer.rs index 5c4eddb7a1..fb3ce65e73 100644 --- a/crates/papyrus_sync/src/sources/base_layer.rs +++ b/crates/papyrus_sync/src/sources/base_layer.rs @@ -1,8 +1,8 @@ use async_trait::async_trait; #[cfg(test)] use mockall::automock; -use papyrus_base_layer::ethereum_base_layer_contract::EthereumBaseLayerContract; use papyrus_base_layer::BaseLayerContract; +use papyrus_base_layer::ethereum_base_layer_contract::EthereumBaseLayerContract; use starknet_api::block::{BlockHash, BlockNumber}; pub type EthereumBaseLayerSource = EthereumBaseLayerContract; diff --git a/crates/papyrus_sync/src/sources/central.rs b/crates/papyrus_sync/src/sources/central.rs index f113bb26f3..d6db0a704d 100644 --- a/crates/papyrus_sync/src/sources/central.rs +++ b/crates/papyrus_sync/src/sources/central.rs @@ -17,20 +17,20 @@ use itertools::chain; use lru::LruCache; #[cfg(test)] use mockall::automock; -use papyrus_common::pending_classes::ApiContractClass; use papyrus_common::BlockHashAndNumber; +use papyrus_common::pending_classes::ApiContractClass; use papyrus_config::converters::{deserialize_optional_map, serialize_optional_map}; -use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, append_sub_config_name, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use papyrus_storage::state::StateStorageReader; use papyrus_storage::{StorageError, StorageReader}; use serde::{Deserialize, Serialize}; +use starknet_api::StarknetApiError; use starknet_api::block::{Block, BlockHash, BlockNumber, BlockSignature}; use starknet_api::core::{ClassHash, CompiledClassHash, SequencerPublicKey}; use starknet_api::crypto::utils::Signature; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; use starknet_api::state::StateDiff; -use starknet_api::StarknetApiError; use starknet_client::reader::{ BlockSignatureData, ReaderClientError, diff --git a/crates/papyrus_sync/src/sources/central/state_update_stream.rs b/crates/papyrus_sync/src/sources/central/state_update_stream.rs index db811567c6..82d5b72391 100644 --- a/crates/papyrus_sync/src/sources/central/state_update_stream.rs +++ b/crates/papyrus_sync/src/sources/central/state_update_stream.rs @@ -7,8 +7,8 @@ use futures_util::stream::FuturesOrdered; use futures_util::{Future, Stream, StreamExt}; use indexmap::IndexMap; use lru::LruCache; -use papyrus_storage::state::StateStorageReader; use papyrus_storage::StorageReader; +use papyrus_storage::state::StateStorageReader; use starknet_api::block::BlockNumber; use starknet_api::core::ClassHash; use starknet_api::state::{StateDiff, StateNumber}; diff --git a/crates/papyrus_sync/src/sources/central_sync_test.rs b/crates/papyrus_sync/src/sources/central_sync_test.rs index 6a90c6a765..9f0ce196cd 100644 --- a/crates/papyrus_sync/src/sources/central_sync_test.rs +++ b/crates/papyrus_sync/src/sources/central_sync_test.rs @@ -7,8 +7,8 @@ use async_trait::async_trait; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use futures::StreamExt; use indexmap::IndexMap; -use papyrus_common::pending_classes::{ApiContractClass, PendingClasses}; use papyrus_common::BlockHashAndNumber; +use papyrus_common::pending_classes::{ApiContractClass, PendingClasses}; use papyrus_storage::base_layer::BaseLayerStorageReader; use papyrus_storage::header::HeaderStorageReader; use papyrus_storage::state::StateStorageReader; diff --git a/crates/papyrus_sync/src/sources/central_test.rs b/crates/papyrus_sync/src/sources/central_test.rs index 41b687ca75..3acd9f4ac1 100644 --- a/crates/papyrus_sync/src/sources/central_test.rs +++ b/crates/papyrus_sync/src/sources/central_test.rs @@ -4,7 +4,7 @@ use std::sync::{Arc, Mutex}; use assert_matches::assert_matches; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use futures_util::pin_mut; -use indexmap::{indexmap, IndexMap}; +use indexmap::{IndexMap, indexmap}; use lru::LruCache; use mockall::predicate; use papyrus_storage::class::ClassStorageWriter; @@ -27,6 +27,7 @@ use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContract use starknet_api::hash::StarkHash; use starknet_api::state::{ContractClass as sn_api_ContractClass, StorageKey, ThinStateDiff}; use starknet_api::{felt, patricia_key}; +use starknet_client::ClientError; use starknet_client::reader::objects::block::BlockPostV0_13_1; use starknet_client::reader::{ Block, @@ -41,11 +42,10 @@ use starknet_client::reader::{ StateUpdate, StorageEntry, }; -use starknet_client::ClientError; use tokio_stream::StreamExt; -use super::state_update_stream::StateUpdateStreamConfig; use super::ApiContractClass; +use super::state_update_stream::StateUpdateStreamConfig; use crate::sources::central::{CentralError, CentralSourceTrait, GenericCentralSource}; const TEST_CONCURRENT_REQUESTS: usize = 300; @@ -462,35 +462,29 @@ async fn stream_compiled_classes() { writer .begin_rw_txn() .unwrap() - .append_state_diff( - BlockNumber(0), - ThinStateDiff { - deployed_contracts: indexmap! {}, - storage_diffs: indexmap! {}, - declared_classes: indexmap! { - ClassHash(felt!("0x0")) => CompiledClassHash(felt!("0x0")), - ClassHash(felt!("0x1")) => CompiledClassHash(felt!("0x1")), - }, - deprecated_declared_classes: vec![], - nonces: indexmap! {}, - replaced_classes: indexmap! {}, + .append_state_diff(BlockNumber(0), ThinStateDiff { + deployed_contracts: indexmap! {}, + storage_diffs: indexmap! {}, + declared_classes: indexmap! { + ClassHash(felt!("0x0")) => CompiledClassHash(felt!("0x0")), + ClassHash(felt!("0x1")) => CompiledClassHash(felt!("0x1")), }, - ) + deprecated_declared_classes: vec![], + nonces: indexmap! {}, + replaced_classes: indexmap! {}, + }) .unwrap() - .append_state_diff( - BlockNumber(1), - ThinStateDiff { - deployed_contracts: indexmap! {}, - storage_diffs: indexmap! {}, - declared_classes: indexmap! { - ClassHash(felt!("0x2")) => CompiledClassHash(felt!("0x2")), - ClassHash(felt!("0x3")) => CompiledClassHash(felt!("0x3")), - }, - deprecated_declared_classes: vec![], - nonces: indexmap! {}, - replaced_classes: indexmap! {}, + .append_state_diff(BlockNumber(1), ThinStateDiff { + deployed_contracts: indexmap! {}, + storage_diffs: indexmap! {}, + declared_classes: indexmap! { + ClassHash(felt!("0x2")) => CompiledClassHash(felt!("0x2")), + ClassHash(felt!("0x3")) => CompiledClassHash(felt!("0x3")), }, - ) + deprecated_declared_classes: vec![], + nonces: indexmap! {}, + replaced_classes: indexmap! {}, + }) .unwrap() .append_classes( BlockNumber(0), diff --git a/crates/papyrus_sync/src/sources/pending.rs b/crates/papyrus_sync/src/sources/pending.rs index 6ab434fbcf..0608300f50 100644 --- a/crates/papyrus_sync/src/sources/pending.rs +++ b/crates/papyrus_sync/src/sources/pending.rs @@ -7,13 +7,13 @@ use std::sync::Arc; use async_trait::async_trait; #[cfg(test)] use mockall::automock; +use starknet_client::ClientCreationError; use starknet_client::reader::{ PendingData, ReaderClientError, StarknetFeederGatewayClient, StarknetReader, }; -use starknet_client::ClientCreationError; // TODO(dvir): add pending config. use super::central::CentralSourceConfig; diff --git a/crates/papyrus_sync/src/sync_test.rs b/crates/papyrus_sync/src/sync_test.rs index 1210117c2c..0fc0cac066 100644 --- a/crates/papyrus_sync/src/sync_test.rs +++ b/crates/papyrus_sync/src/sync_test.rs @@ -10,7 +10,7 @@ use papyrus_storage::base_layer::BaseLayerStorageReader; use papyrus_storage::header::HeaderStorageWriter; use papyrus_storage::test_utils::get_test_storage; use papyrus_storage::{StorageReader, StorageWriter}; -use papyrus_test_utils::{get_rng, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, get_rng}; use pretty_assertions::assert_eq; use starknet_api::block::{BlockHash, BlockHeader, BlockNumber}; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce, PatriciaKey}; @@ -33,14 +33,14 @@ use crate::sources::base_layer::MockBaseLayerSourceTrait; use crate::sources::central::MockCentralSourceTrait; use crate::sources::pending::MockPendingSourceTrait; use crate::{ - sort_state_diff, - stream_new_base_layer_block, - sync_pending_data, + GENESIS_HASH, GenericStateSync, StateSyncError, SyncConfig, SyncEvent, - GENESIS_HASH, + sort_state_diff, + stream_new_base_layer_block, + sync_pending_data, }; // TODO(anatg): Add a test to check that the sync calls the sort_state_diff function @@ -365,15 +365,12 @@ async fn pending_sync_new_data_has_more_advanced_hash_and_less_transactions() { writer .begin_rw_txn() .unwrap() - .append_header( - BlockNumber(0), - &BlockHeader { - block_hash: FIRST_BLOCK_HASH, - parent_hash: genesis_hash, - block_number: BlockNumber(0), - ..Default::default() - }, - ) + .append_header(BlockNumber(0), &BlockHeader { + block_hash: FIRST_BLOCK_HASH, + parent_hash: genesis_hash, + block_number: BlockNumber(0), + ..Default::default() + }) .unwrap() .commit() .unwrap(); @@ -479,15 +476,12 @@ async fn pending_sync_doesnt_stop_when_data_has_block_hash_field_with_the_same_h writer .begin_rw_txn() .unwrap() - .append_header( - BlockNumber(0), - &BlockHeader { - block_hash: FIRST_BLOCK_HASH, - parent_hash: genesis_hash, - block_number: BlockNumber(0), - ..Default::default() - }, - ) + .append_header(BlockNumber(0), &BlockHeader { + block_hash: FIRST_BLOCK_HASH, + parent_hash: genesis_hash, + block_number: BlockNumber(0), + ..Default::default() + }) .unwrap() .commit() .unwrap(); @@ -553,15 +547,12 @@ async fn pending_sync_updates_when_data_has_block_hash_field_with_the_same_hash_ writer .begin_rw_txn() .unwrap() - .append_header( - BlockNumber(0), - &BlockHeader { - block_hash: FIRST_BLOCK_HASH, - parent_hash: genesis_hash, - block_number: BlockNumber(0), - ..Default::default() - }, - ) + .append_header(BlockNumber(0), &BlockHeader { + block_hash: FIRST_BLOCK_HASH, + parent_hash: genesis_hash, + block_number: BlockNumber(0), + ..Default::default() + }) .unwrap() .commit() .unwrap(); @@ -705,15 +696,12 @@ async fn pending_sync_classes_are_cleaned_on_first_pending_data_from_latest_bloc writer .begin_rw_txn() .unwrap() - .append_header( - BlockNumber(0), - &BlockHeader { - block_hash: FIRST_BLOCK_HASH, - parent_hash: genesis_hash, - block_number: BlockNumber(0), - ..Default::default() - }, - ) + .append_header(BlockNumber(0), &BlockHeader { + block_hash: FIRST_BLOCK_HASH, + parent_hash: genesis_hash, + block_number: BlockNumber(0), + ..Default::default() + }) .unwrap() .commit() .unwrap(); diff --git a/crates/papyrus_test_utils/src/lib.rs b/crates/papyrus_test_utils/src/lib.rs index 20c39d27ee..5c1ecec545 100644 --- a/crates/papyrus_test_utils/src/lib.rs +++ b/crates/papyrus_test_utils/src/lib.rs @@ -22,12 +22,12 @@ use cairo_lang_casm::operand::{ Register, ResOperand, }; +use cairo_lang_starknet_classes::NestedIntList; use cairo_lang_starknet_classes::casm_contract_class::{ CasmContractClass, CasmContractEntryPoint, CasmContractEntryPoints, }; -use cairo_lang_starknet_classes::NestedIntList; use cairo_lang_utils::bigint::BigUintAsHex; use indexmap::IndexMap; use num_bigint::BigUint; diff --git a/crates/sequencing/papyrus_block_builder/src/lib.rs b/crates/sequencing/papyrus_block_builder/src/lib.rs index 7725bc48e8..9199c19c1c 100644 --- a/crates/sequencing/papyrus_block_builder/src/lib.rs +++ b/crates/sequencing/papyrus_block_builder/src/lib.rs @@ -5,8 +5,8 @@ use std::sync::mpsc::{self, Receiver}; -use papyrus_storage::body::BodyStorageReader; use papyrus_storage::StorageReader; +use papyrus_storage::body::BodyStorageReader; use starknet_api::block::BlockNumber; use starknet_api::transaction::Transaction; use tracing::instrument; diff --git a/crates/sequencing/papyrus_block_builder/src/test.rs b/crates/sequencing/papyrus_block_builder/src/test.rs index b4319778e4..0fbdc8f2d8 100644 --- a/crates/sequencing/papyrus_block_builder/src/test.rs +++ b/crates/sequencing/papyrus_block_builder/src/test.rs @@ -1,6 +1,6 @@ +use papyrus_storage::StorageScope; use papyrus_storage::body::BodyStorageWriter; use papyrus_storage::test_utils::get_test_storage_by_scope; -use papyrus_storage::StorageScope; use papyrus_test_utils::get_test_block; use pretty_assertions::assert_eq; use starknet_api::block::BlockNumber; diff --git a/crates/sequencing/papyrus_consensus/src/config.rs b/crates/sequencing/papyrus_consensus/src/config.rs index 1f49b03c4b..8f0c63adb7 100644 --- a/crates/sequencing/papyrus_consensus/src/config.rs +++ b/crates/sequencing/papyrus_consensus/src/config.rs @@ -10,11 +10,11 @@ use papyrus_config::converters::{ deserialize_seconds_to_duration, }; use papyrus_config::dumping::{ + SerializeConfig, append_sub_config_name, ser_optional_sub_config, ser_param, ser_required_param, - SerializeConfig, }; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializationType, SerializedParam}; use serde::{Deserialize, Serialize}; diff --git a/crates/sequencing/papyrus_consensus/src/lib.rs b/crates/sequencing/papyrus_consensus/src/lib.rs index cc077c83b3..1ee0c1e954 100644 --- a/crates/sequencing/papyrus_consensus/src/lib.rs +++ b/crates/sequencing/papyrus_consensus/src/lib.rs @@ -18,4 +18,4 @@ pub(crate) mod test_utils; #[allow(missing_docs)] pub mod types; -pub use manager::{run_consensus, ProposalWrapper}; +pub use manager::{ProposalWrapper, run_consensus}; diff --git a/crates/sequencing/papyrus_consensus/src/manager_test.rs b/crates/sequencing/papyrus_consensus/src/manager_test.rs index 5a5337b0b8..4568e55ba8 100644 --- a/crates/sequencing/papyrus_consensus/src/manager_test.rs +++ b/crates/sequencing/papyrus_consensus/src/manager_test.rs @@ -2,20 +2,20 @@ use std::time::Duration; use std::vec; use async_trait::async_trait; -use futures::channel::{mpsc, oneshot}; use futures::SinkExt; +use futures::channel::{mpsc, oneshot}; use lazy_static::lazy_static; use mockall::mock; use mockall::predicate::eq; -use papyrus_network::network_manager::test_utils::create_test_broadcasted_message_manager; use papyrus_network::network_manager::BroadcastedMessageManager; +use papyrus_network::network_manager::test_utils::create_test_broadcasted_message_manager; use papyrus_protobuf::consensus::{ConsensusMessage, Vote}; use papyrus_protobuf::converters::ProtobufConversionError; use starknet_api::block::{BlockHash, BlockNumber}; use starknet_api::transaction::Transaction; use starknet_types_core::felt::Felt; -use super::{run_consensus, MultiHeightManager}; +use super::{MultiHeightManager, run_consensus}; use crate::config::TimeoutsConfig; use crate::test_utils::{precommit, prevote, proposal}; use crate::types::{ diff --git a/crates/sequencing/papyrus_consensus/src/papyrus_consensus_context.rs b/crates/sequencing/papyrus_consensus/src/papyrus_consensus_context.rs index cc1955f428..63bdc1e992 100644 --- a/crates/sequencing/papyrus_consensus/src/papyrus_consensus_context.rs +++ b/crates/sequencing/papyrus_consensus/src/papyrus_consensus_context.rs @@ -6,9 +6,9 @@ use core::panic; use std::time::Duration; use async_trait::async_trait; +use futures::StreamExt; use futures::channel::{mpsc, oneshot}; use futures::sink::SinkExt; -use futures::StreamExt; use papyrus_network::network_manager::BroadcastTopicSender; use papyrus_protobuf::consensus::{ConsensusMessage, Proposal, Vote}; use papyrus_storage::body::BodyStorageReader; @@ -17,8 +17,9 @@ use papyrus_storage::{StorageError, StorageReader}; use starknet_api::block::{BlockHash, BlockNumber}; use starknet_api::core::ContractAddress; use starknet_api::transaction::Transaction; -use tracing::{debug, debug_span, info, warn, Instrument}; +use tracing::{Instrument, debug, debug_span, info, warn}; +use crate::ProposalWrapper; use crate::types::{ ConsensusBlock, ConsensusContext, @@ -27,7 +28,6 @@ use crate::types::{ Round, ValidatorId, }; -use crate::ProposalWrapper; // TODO: add debug messages and span to the tasks. diff --git a/crates/sequencing/papyrus_consensus/src/papyrus_consensus_context_test.rs b/crates/sequencing/papyrus_consensus/src/papyrus_consensus_context_test.rs index 9b89f634ed..82abddf858 100644 --- a/crates/sequencing/papyrus_consensus/src/papyrus_consensus_context_test.rs +++ b/crates/sequencing/papyrus_consensus/src/papyrus_consensus_context_test.rs @@ -1,8 +1,8 @@ -use futures::channel::{mpsc, oneshot}; use futures::StreamExt; +use futures::channel::{mpsc, oneshot}; use papyrus_network::network_manager::test_utils::{ - mock_register_broadcast_topic, BroadcastNetworkMock, + mock_register_broadcast_topic, }; use papyrus_protobuf::consensus::{ConsensusMessage, Proposal, Vote}; use papyrus_storage::body::BodyStorageWriter; diff --git a/crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs b/crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs index ecccbe3dc5..8c5a4201d6 100644 --- a/crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs +++ b/crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs @@ -12,7 +12,7 @@ use super::SingleHeightConsensus; use crate::config::TimeoutsConfig; use crate::single_height_consensus::{ShcReturn, ShcTask}; use crate::state_machine::StateMachineEvent; -use crate::test_utils::{precommit, prevote, MockTestContext, TestBlock}; +use crate::test_utils::{MockTestContext, TestBlock, precommit, prevote}; use crate::types::{ConsensusBlock, ConsensusError, ProposalInit, ValidatorId}; lazy_static! { diff --git a/crates/starknet_api/Cargo.toml b/crates/starknet_api/Cargo.toml index be278c6d39..000cd48d82 100644 --- a/crates/starknet_api/Cargo.toml +++ b/crates/starknet_api/Cargo.toml @@ -11,7 +11,7 @@ testing = [] [dependencies] bitvec = "1.0.1" -cairo-lang-starknet-classes = "2.7.0-dev.0" +cairo-lang-starknet-classes = { workspace = true } derive_more = "0.99.17" hex = "0.4.3" indexmap = { version = "2.1.0", features = ["serde"] } diff --git a/crates/starknet_api/src/block.rs b/crates/starknet_api/src/block.rs index 26729420fc..493e5aa8d0 100644 --- a/crates/starknet_api/src/block.rs +++ b/crates/starknet_api/src/block.rs @@ -17,7 +17,7 @@ use crate::core::{ StateDiffCommitment, TransactionCommitment, }; -use crate::crypto::utils::{verify_message_hash_signature, CryptoError, Signature}; +use crate::crypto::utils::{CryptoError, Signature, verify_message_hash_signature}; use crate::data_availability::L1DataAvailabilityMode; use crate::hash::StarkHash; use crate::serde_utils::{BytesAsHex, PrefixedBytesAsHex}; diff --git a/crates/starknet_api/src/block_hash/block_hash_calculator.rs b/crates/starknet_api/src/block_hash/block_hash_calculator.rs index a4dcdf3c40..d703f342a1 100644 --- a/crates/starknet_api/src/block_hash/block_hash_calculator.rs +++ b/crates/starknet_api/src/block_hash/block_hash_calculator.rs @@ -4,10 +4,10 @@ use serde::{Deserialize, Serialize}; use starknet_types_core::felt::Felt; use starknet_types_core::hash::Poseidon; -use super::event_commitment::{calculate_event_commitment, EventLeafElement}; -use super::receipt_commitment::{calculate_receipt_commitment, ReceiptElement}; +use super::event_commitment::{EventLeafElement, calculate_event_commitment}; +use super::receipt_commitment::{ReceiptElement, calculate_receipt_commitment}; use super::state_diff_hash::calculate_state_diff_hash; -use super::transaction_commitment::{calculate_transaction_commitment, TransactionLeafElement}; +use super::transaction_commitment::{TransactionLeafElement, calculate_transaction_commitment}; use crate::block::{BlockHash, BlockHeaderWithoutHash}; use crate::core::{EventCommitment, ReceiptCommitment, StateDiffCommitment, TransactionCommitment}; use crate::crypto::utils::HashChain; diff --git a/crates/starknet_api/src/block_hash/block_hash_calculator_test.rs b/crates/starknet_api/src/block_hash/block_hash_calculator_test.rs index 258c793b19..176a348da7 100644 --- a/crates/starknet_api/src/block_hash/block_hash_calculator_test.rs +++ b/crates/starknet_api/src/block_hash/block_hash_calculator_test.rs @@ -11,10 +11,10 @@ use crate::block::{ StarknetVersion, }; use crate::block_hash::block_hash_calculator::{ - calculate_block_commitments, - calculate_block_hash, BlockHeaderCommitments, TransactionHashingData, + calculate_block_commitments, + calculate_block_hash, }; use crate::block_hash::test_utils::{get_state_diff, get_transaction_output}; use crate::core::{ diff --git a/crates/starknet_api/src/block_hash/event_commitment_test.rs b/crates/starknet_api/src/block_hash/event_commitment_test.rs index 132bc86d87..76affac88a 100644 --- a/crates/starknet_api/src/block_hash/event_commitment_test.rs +++ b/crates/starknet_api/src/block_hash/event_commitment_test.rs @@ -1,7 +1,7 @@ use starknet_types_core::felt::Felt; use starknet_types_core::hash::Poseidon; -use super::{calculate_event_commitment, calculate_event_hash, EventLeafElement}; +use super::{EventLeafElement, calculate_event_commitment, calculate_event_hash}; use crate::core::{ContractAddress, EventCommitment, PatriciaKey}; use crate::transaction::{Event, EventContent, EventData, EventKey, TransactionHash}; use crate::{contract_address, felt, patricia_key}; diff --git a/crates/starknet_api/src/block_hash/receipt_commitment_test.rs b/crates/starknet_api/src/block_hash/receipt_commitment_test.rs index 53dc119f78..652acc4983 100644 --- a/crates/starknet_api/src/block_hash/receipt_commitment_test.rs +++ b/crates/starknet_api/src/block_hash/receipt_commitment_test.rs @@ -3,10 +3,10 @@ use starknet_types_core::hash::Poseidon; use super::calculate_messages_sent_hash; use crate::block_hash::receipt_commitment::{ + ReceiptElement, calculate_receipt_commitment, calculate_receipt_hash, get_revert_reason_hash, - ReceiptElement, }; use crate::block_hash::test_utils::{generate_message_to_l1, get_transaction_output}; use crate::core::ReceiptCommitment; diff --git a/crates/starknet_api/src/core.rs b/crates/starknet_api/src/core.rs index 03147360c6..c4af8f5fdb 100644 --- a/crates/starknet_api/src/core.rs +++ b/crates/starknet_api/src/core.rs @@ -16,7 +16,7 @@ use crate::crypto::utils::PublicKey; use crate::hash::{PoseidonHash, StarkHash}; use crate::serde_utils::{BytesAsHex, PrefixedBytesAsHex}; use crate::transaction::{Calldata, ContractAddressSalt}; -use crate::{impl_from_through_intermediate, StarknetApiError}; +use crate::{StarknetApiError, impl_from_through_intermediate}; /// A chain id. #[derive(Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord)] diff --git a/crates/starknet_api/src/core_test.rs b/crates/starknet_api/src/core_test.rs index eed3b3900a..b760b6cceb 100644 --- a/crates/starknet_api/src/core_test.rs +++ b/crates/starknet_api/src/core_test.rs @@ -3,15 +3,15 @@ use starknet_types_core::felt::Felt; use starknet_types_core::hash::{Pedersen, StarkHash as CoreStarkHash}; use crate::core::{ - calculate_contract_address, + CONTRACT_ADDRESS_PREFIX, ClassHash, ContractAddress, EthAddress, + L2_ADDRESS_UPPER_BOUND, Nonce, PatriciaKey, StarknetApiError, - CONTRACT_ADDRESS_PREFIX, - L2_ADDRESS_UPPER_BOUND, + calculate_contract_address, }; use crate::hash::StarkHash; use crate::transaction::{Calldata, ContractAddressSalt}; diff --git a/crates/starknet_api/src/crypto/crypto_test.rs b/crates/starknet_api/src/crypto/crypto_test.rs index 7d78fc35ba..b0ea14e632 100644 --- a/crates/starknet_api/src/crypto/crypto_test.rs +++ b/crates/starknet_api/src/crypto/crypto_test.rs @@ -2,7 +2,7 @@ use starknet_types_core::hash::{Poseidon, StarkHash}; -use crate::crypto::utils::{verify_message_hash_signature, PublicKey, Signature}; +use crate::crypto::utils::{PublicKey, Signature, verify_message_hash_signature}; use crate::felt; #[test] diff --git a/crates/starknet_api/src/deprecated_contract_class.rs b/crates/starknet_api/src/deprecated_contract_class.rs index eb5de5db90..3c1bb54f18 100644 --- a/crates/starknet_api/src/deprecated_contract_class.rs +++ b/crates/starknet_api/src/deprecated_contract_class.rs @@ -7,10 +7,10 @@ use serde::de::Error as DeserializationError; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_json::Value; +use crate::StarknetApiError; use crate::core::EntryPointSelector; use crate::hash::StarkHash; use crate::serde_utils::deserialize_optional_contract_class_abi_entry_vector; -use crate::StarknetApiError; /// A deprecated contract class. #[derive(Debug, Clone, Default, Eq, PartialEq, Deserialize, Serialize)] diff --git a/crates/starknet_api/src/rpc_transaction.rs b/crates/starknet_api/src/rpc_transaction.rs index 2c402c2d9b..65c4a39254 100644 --- a/crates/starknet_api/src/rpc_transaction.rs +++ b/crates/starknet_api/src/rpc_transaction.rs @@ -7,12 +7,13 @@ use std::collections::BTreeMap; use serde::{Deserialize, Serialize}; use starknet_types_core::felt::Felt; +use crate::StarknetApiError; use crate::core::{ - calculate_contract_address, ClassHash, CompiledClassHash, ContractAddress, Nonce, + calculate_contract_address, }; use crate::data_availability::DataAvailabilityMode; use crate::state::EntryPoint; @@ -26,7 +27,6 @@ use crate::transaction::{ Tip, TransactionSignature, }; -use crate::StarknetApiError; /// Transactions that are ready to be broadcasted to the network through RPC and are not included in /// a block. diff --git a/crates/starknet_api/src/serde_utils.rs b/crates/starknet_api/src/serde_utils.rs index c23b7f4ed7..8a70d5e3b3 100644 --- a/crates/starknet_api/src/serde_utils.rs +++ b/crates/starknet_api/src/serde_utils.rs @@ -3,9 +3,9 @@ #[path = "serde_utils_test.rs"] mod serde_utils_test; +use serde::Deserializer; use serde::de::{Deserialize, Visitor}; use serde::ser::{Serialize, SerializeTuple}; -use serde::Deserializer; use crate::deprecated_contract_class::ContractClassAbiEntry; diff --git a/crates/starknet_api/src/serde_utils_test.rs b/crates/starknet_api/src/serde_utils_test.rs index 2a94ae6379..e13609693b 100644 --- a/crates/starknet_api/src/serde_utils_test.rs +++ b/crates/starknet_api/src/serde_utils_test.rs @@ -8,11 +8,11 @@ use crate::deprecated_contract_class::{ TypedParameter, }; use crate::serde_utils::{ + BytesAsHex, + InnerDeserializationError, bytes_from_hex_str, deserialize_optional_contract_class_abi_entry_vector, hex_str_from_bytes, - BytesAsHex, - InnerDeserializationError, }; #[test] @@ -147,23 +147,18 @@ fn deserialize_valid_optional_contract_class_abi_entry_vector() { } "#; let res: DummyContractClass = serde_json::from_str(json).unwrap(); - assert_eq!( - res, - DummyContractClass { - abi: Some(vec![ContractClassAbiEntry::Constructor(FunctionAbiEntry::< - ConstructorType, - > { - name: "constructor".to_string(), - inputs: vec![TypedParameter { - name: "implementation".to_string(), - r#type: "felt".to_string(), - }], - outputs: vec![], - state_mutability: None, - r#type: ConstructorType::Constructor, - })]) - } - ); + assert_eq!(res, DummyContractClass { + abi: Some(vec![ContractClassAbiEntry::Constructor(FunctionAbiEntry:: { + name: "constructor".to_string(), + inputs: vec![TypedParameter { + name: "implementation".to_string(), + r#type: "felt".to_string(), + }], + outputs: vec![], + state_mutability: None, + r#type: ConstructorType::Constructor, + })]) + }); } #[test] diff --git a/crates/starknet_api/src/state.rs b/crates/starknet_api/src/state.rs index ed6dd2ef70..ddb77cb1fe 100644 --- a/crates/starknet_api/src/state.rs +++ b/crates/starknet_api/src/state.rs @@ -21,7 +21,7 @@ use crate::core::{ }; use crate::deprecated_contract_class::ContractClass as DeprecatedContractClass; use crate::hash::StarkHash; -use crate::{impl_from_through_intermediate, StarknetApiError}; +use crate::{StarknetApiError, impl_from_through_intermediate}; pub type DeclaredClasses = IndexMap; pub type DeprecatedDeclaredClasses = IndexMap; diff --git a/crates/starknet_api/src/state_test.rs b/crates/starknet_api/src/state_test.rs index 47b9a56b15..9d6f47515a 100644 --- a/crates/starknet_api/src/state_test.rs +++ b/crates/starknet_api/src/state_test.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use indexmap::{indexmap, IndexMap}; +use indexmap::{IndexMap, indexmap}; use serde_json::json; use super::ThinStateDiff; diff --git a/crates/starknet_api/src/transaction.rs b/crates/starknet_api/src/transaction.rs index 5aa8cdcb08..3bd484d7f2 100644 --- a/crates/starknet_api/src/transaction.rs +++ b/crates/starknet_api/src/transaction.rs @@ -8,6 +8,7 @@ use starknet_types_core::felt::Felt; use strum::IntoEnumIterator; use strum_macros::EnumIter; +use crate::StarknetApiError; use crate::block::{BlockHash, BlockNumber}; use crate::core::{ ChainId, @@ -35,7 +36,6 @@ use crate::transaction_hash::{ get_invoke_transaction_v3_hash, get_l1_handler_transaction_hash, }; -use crate::StarknetApiError; pub trait TransactionHasher { fn calculate_transaction_hash( diff --git a/crates/starknet_api/src/transaction_hash.rs b/crates/starknet_api/src/transaction_hash.rs index cb01a4c451..d2429f0c84 100644 --- a/crates/starknet_api/src/transaction_hash.rs +++ b/crates/starknet_api/src/transaction_hash.rs @@ -2,8 +2,9 @@ use std::sync::LazyLock; use starknet_types_core::felt::Felt; +use crate::StarknetApiError; use crate::block::BlockNumber; -use crate::core::{calculate_contract_address, ChainId, ContractAddress}; +use crate::core::{ChainId, ContractAddress, calculate_contract_address}; use crate::crypto::utils::HashChain; use crate::data_availability::DataAvailabilityMode; use crate::transaction::{ @@ -28,7 +29,6 @@ use crate::transaction::{ TransactionHash, TransactionVersion, }; -use crate::StarknetApiError; type ResourceName = [u8; 7]; diff --git a/crates/starknet_client/src/reader/mod.rs b/crates/starknet_client/src/reader/mod.rs index 8120205f69..34f934d988 100644 --- a/crates/starknet_client/src/reader/mod.rs +++ b/crates/starknet_client/src/reader/mod.rs @@ -9,16 +9,19 @@ mod starknet_feeder_gateway_client_test; use std::collections::HashMap; use async_trait::async_trait; -use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::{ + CasmContractClass, + CasmContractEntryPoints, +}; #[cfg(any(feature = "testing", test))] use mockall::automock; use papyrus_common::pending_classes::ApiContractClass; use serde::{Deserialize, Serialize}; +use starknet_api::StarknetApiError; use starknet_api::block::BlockNumber; use starknet_api::core::{ClassHash, SequencerPublicKey}; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; use starknet_api::transaction::TransactionHash; -use starknet_api::StarknetApiError; use starknet_types_core::felt::Felt; use tracing::{debug, error, instrument}; use url::Url; @@ -299,7 +302,15 @@ impl StarknetReader for StarknetFeederGatewayClient { .contains(&class_hash) { debug!("Using default compiled class for class hash {}.", class_hash); - return Ok(Some(CasmContractClass::default())); + return Ok(Some(CasmContractClass { + prime: Default::default(), + compiler_version: String::default(), + bytecode: vec![], + bytecode_segment_lengths: None, + hints: vec![], + pythonic_hints: None, + entry_points_by_type: CasmContractEntryPoints::default(), + })); } let mut url = self.urls.get_compiled_class_by_class_hash.clone(); diff --git a/crates/starknet_client/src/reader/objects/block_test.rs b/crates/starknet_client/src/reader/objects/block_test.rs index f587def9fb..a90f607381 100644 --- a/crates/starknet_client/src/reader/objects/block_test.rs +++ b/crates/starknet_client/src/reader/objects/block_test.rs @@ -9,6 +9,7 @@ use starknet_api::transaction::{TransactionHash, TransactionOffsetInBlock}; use starknet_api::{felt, patricia_key}; use super::{Block, GlobalRoot, TransactionReceiptsError}; +use crate::reader::ReaderClientError; use crate::reader::objects::block::BlockPostV0_13_1; use crate::reader::objects::state::{ DeclaredClassHashEntry, @@ -19,7 +20,6 @@ use crate::reader::objects::state::{ StorageEntry, }; use crate::reader::objects::transaction::TransactionReceipt; -use crate::reader::ReaderClientError; use crate::test_utils::read_resource::read_resource_file; #[test] diff --git a/crates/starknet_client/src/reader/objects/test_utils.rs b/crates/starknet_client/src/reader/objects/test_utils.rs index 3876eeb723..4f197b2707 100644 --- a/crates/starknet_client/src/reader/objects/test_utils.rs +++ b/crates/starknet_client/src/reader/objects/test_utils.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use papyrus_test_utils::{auto_impl_get_test_instance, get_number_of_variants, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, auto_impl_get_test_instance, get_number_of_variants}; use starknet_api::core::{ ClassHash, CompiledClassHash, diff --git a/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs b/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs index 835b433501..c45e7a55fc 100644 --- a/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs +++ b/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs @@ -36,20 +36,20 @@ use starknet_api::{felt, patricia_key}; use super::objects::state::StateUpdate; use super::objects::transaction::IntermediateDeclareTransaction; use super::{ + BLOCK_NUMBER_QUERY, + CLASS_HASH_QUERY, ContractClass, + GET_BLOCK_URL, + GET_STATE_UPDATE_URL, GenericContractClass, PendingData, ReaderClientError, ReaderClientResult, StarknetFeederGatewayClient, StarknetReader, - BLOCK_NUMBER_QUERY, - CLASS_HASH_QUERY, - GET_BLOCK_URL, - GET_STATE_UPDATE_URL, }; -use crate::reader::objects::block::{BlockSignatureData, BlockSignatureMessage}; use crate::reader::Block; +use crate::reader::objects::block::{BlockSignatureData, BlockSignatureMessage}; use crate::test_utils::read_resource::read_resource_file; use crate::test_utils::retry::get_test_config; @@ -264,24 +264,18 @@ async fn deprecated_contract_class() { }, entry_points_by_type: HashMap::from([ (DeprecatedEntryPointType::L1Handler, vec![]), - ( - DeprecatedEntryPointType::Constructor, - vec![DeprecatedEntryPoint { - selector: EntryPointSelector(felt!( - "0x028ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194" - )), - offset: EntryPointOffset(62), - }], - ), - ( - DeprecatedEntryPointType::External, - vec![DeprecatedEntryPoint { - selector: EntryPointSelector(felt!( - "0x0000000000000000000000000000000000000000000000000000000000000000" - )), - offset: EntryPointOffset(86), - }], - ), + (DeprecatedEntryPointType::Constructor, vec![DeprecatedEntryPoint { + selector: EntryPointSelector(felt!( + "0x028ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194" + )), + offset: EntryPointOffset(62), + }]), + (DeprecatedEntryPointType::External, vec![DeprecatedEntryPoint { + selector: EntryPointSelector(felt!( + "0x0000000000000000000000000000000000000000000000000000000000000000" + )), + offset: EntryPointOffset(86), + }]), ]), }; let mock_by_hash = mock( diff --git a/crates/starknet_client/src/retry.rs b/crates/starknet_client/src/retry.rs index bbebc9bd39..ba4e949ef7 100644 --- a/crates/starknet_client/src/retry.rs +++ b/crates/starknet_client/src/retry.rs @@ -7,7 +7,7 @@ use std::fmt::Debug; use std::iter::Take; use std::time::Duration; -use papyrus_config::dumping::{ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use tokio_retry::strategy::ExponentialBackoff; diff --git a/crates/starknet_client/src/starknet_client_test.rs b/crates/starknet_client/src/starknet_client_test.rs index 1c7fad3d90..767cdb9e6f 100644 --- a/crates/starknet_client/src/starknet_client_test.rs +++ b/crates/starknet_client/src/starknet_client_test.rs @@ -3,7 +3,7 @@ use mockito::mock; use reqwest::StatusCode; use crate::starknet_error::{KnownStarknetErrorCode, StarknetError, StarknetErrorCode}; -use crate::test_utils::retry::{get_test_config, MAX_RETRIES}; +use crate::test_utils::retry::{MAX_RETRIES, get_test_config}; use crate::{ClientError, RetryErrorCode, StarknetClient}; const NODE_VERSION: &str = "NODE VERSION"; diff --git a/crates/starknet_client/src/writer/objects/test_utils.rs b/crates/starknet_client/src/writer/objects/test_utils.rs index e13e17ccea..e56cbc4db0 100644 --- a/crates/starknet_client/src/writer/objects/test_utils.rs +++ b/crates/starknet_client/src/writer/objects/test_utils.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use papyrus_test_utils::{auto_impl_get_test_instance, get_number_of_variants, GetTestInstance}; +use papyrus_test_utils::{GetTestInstance, auto_impl_get_test_instance, get_number_of_variants}; use starknet_api::core::{ClassHash, ContractAddress}; use starknet_api::deprecated_contract_class::{ ContractClassAbiEntry as DeprecatedContractClassAbiEntry, diff --git a/crates/starknet_client/src/writer/starknet_gateway_client_test.rs b/crates/starknet_client/src/writer/starknet_gateway_client_test.rs index d08538518d..96dbcc0f2d 100644 --- a/crates/starknet_client/src/writer/starknet_gateway_client_test.rs +++ b/crates/starknet_client/src/writer/starknet_gateway_client_test.rs @@ -1,7 +1,7 @@ use std::fmt::Debug; use std::future::Future; -use mockito::{mock, Matcher}; +use mockito::{Matcher, mock}; use papyrus_test_utils::read_json_file; use serde::{Deserialize, Serialize}; diff --git a/crates/starknet_committer/src/forest/filled_forest.rs b/crates/starknet_committer/src/forest/filled_forest.rs index e1d0037112..635ee53438 100644 --- a/crates/starknet_committer/src/forest/filled_forest.rs +++ b/crates/starknet_committer/src/forest/filled_forest.rs @@ -136,22 +136,19 @@ impl FilledForest { let original_contract_state = original_contracts_trie_leaves .get(&node_index) .ok_or(ForestError::MissingContractCurrentState(contract_address))?; - leaf_index_to_leaf_input.insert( - node_index, - ContractStateInput { - leaf_index: node_index, - nonce: *(address_to_nonce - .get(&contract_address) - .unwrap_or(&original_contract_state.nonce)), - class_hash: *(address_to_class_hash - .get(&contract_address) - .unwrap_or(&original_contract_state.class_hash)), - updated_skeleton: contract_address_to_storage_skeleton - .remove(&contract_address) - .ok_or(ForestError::MissingUpdatedSkeleton(contract_address))?, - storage_updates, - }, - ); + leaf_index_to_leaf_input.insert(node_index, ContractStateInput { + leaf_index: node_index, + nonce: *(address_to_nonce + .get(&contract_address) + .unwrap_or(&original_contract_state.nonce)), + class_hash: *(address_to_class_hash + .get(&contract_address) + .unwrap_or(&original_contract_state.class_hash)), + updated_skeleton: contract_address_to_storage_skeleton + .remove(&contract_address) + .ok_or(ForestError::MissingUpdatedSkeleton(contract_address))?, + storage_updates, + }); } Ok(leaf_index_to_leaf_input) } diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/external_test_utils.rs b/crates/starknet_patricia/src/patricia_merkle_tree/external_test_utils.rs index 136b661b76..e1021df567 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/external_test_utils.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/external_test_utils.rs @@ -17,7 +17,7 @@ use crate::felt::Felt; use crate::hash::hash_trait::HashOutput; use crate::patricia_merkle_tree::errors::TypesError; use crate::storage::map_storage::MapStorage; -use crate::storage::storage_trait::{create_db_key, StarknetPrefix, StorageKey, StorageValue}; +use crate::storage::storage_trait::{StarknetPrefix, StorageKey, StorageValue, create_db_key}; impl TryFrom<&U256> for Felt { type Error = TypesError; @@ -85,13 +85,10 @@ where &leaf_modifications .iter() .map(|(index, data)| { - ( - *index, - match data.is_empty() { - true => SkeletonLeaf::Zero, - false => SkeletonLeaf::NonZero, - }, - ) + (*index, match data.is_empty() { + true => SkeletonLeaf::Zero, + false => SkeletonLeaf::NonZero, + }) }) .collect(), ) diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree.rs b/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree.rs index db98b66a1b..a662e12c0f 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree.rs @@ -216,11 +216,10 @@ impl FilledTreeImpl { }); let hash = TH::compute_node_hash(&data); - Self::write_to_output_map( - filled_tree_output_map, - index, - FilledNode { hash, data }, - )?; + Self::write_to_output_map(filled_tree_output_map, index, FilledNode { + hash, + data, + })?; Ok(hash) } UpdatedSkeletonNode::Edge(path_to_bottom) => { @@ -237,11 +236,10 @@ impl FilledTreeImpl { let data = NodeData::Edge(EdgeData { path_to_bottom: *path_to_bottom, bottom_hash }); let hash = TH::compute_node_hash(&data); - Self::write_to_output_map( - filled_tree_output_map, - index, - FilledNode { hash, data }, - )?; + Self::write_to_output_map(filled_tree_output_map, index, FilledNode { + hash, + data, + })?; Ok(hash) } UpdatedSkeletonNode::UnmodifiedSubTree(hash_result) => Ok(*hash_result), @@ -254,11 +252,10 @@ impl FilledTreeImpl { } let data = NodeData::Leaf(leaf_data); let hash = TH::compute_node_hash(&data); - Self::write_to_output_map( - filled_tree_output_map, - index, - FilledNode { hash, data }, - )?; + Self::write_to_output_map(filled_tree_output_map, index, FilledNode { + hash, + data, + })?; if let Some(output) = leaf_output { Self::write_to_output_map(leaf_index_to_leaf_output, index, output)? }; diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree_test.rs b/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree_test.rs index f564700146..bac29ca9d9 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree_test.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree_test.rs @@ -378,16 +378,13 @@ fn create_mock_binary_entry_for_testing( left_hash: &str, right_hash: &str, ) -> (NodeIndex, FilledNode) { - ( - NodeIndex::from(index), - FilledNode { - hash: HashOutput(Felt::from_hex(hash).unwrap()), - data: NodeData::Binary(BinaryData { - left_hash: HashOutput(Felt::from_hex(left_hash).unwrap()), - right_hash: HashOutput(Felt::from_hex(right_hash).unwrap()), - }), - }, - ) + (NodeIndex::from(index), FilledNode { + hash: HashOutput(Felt::from_hex(hash).unwrap()), + data: NodeData::Binary(BinaryData { + left_hash: HashOutput(Felt::from_hex(left_hash).unwrap()), + right_hash: HashOutput(Felt::from_hex(right_hash).unwrap()), + }), + }) } fn create_mock_edge_entry_for_testing( @@ -397,31 +394,22 @@ fn create_mock_edge_entry_for_testing( length: u8, bottom_hash: &str, ) -> (NodeIndex, FilledNode) { - ( - NodeIndex::from(index), - FilledNode { - hash: HashOutput(Felt::from_hex(hash).unwrap()), - data: NodeData::Edge(EdgeData { - bottom_hash: HashOutput(Felt::from_hex(bottom_hash).unwrap()), - path_to_bottom: PathToBottom::new( - path.into(), - EdgePathLength::new(length).unwrap(), - ) + (NodeIndex::from(index), FilledNode { + hash: HashOutput(Felt::from_hex(hash).unwrap()), + data: NodeData::Edge(EdgeData { + bottom_hash: HashOutput(Felt::from_hex(bottom_hash).unwrap()), + path_to_bottom: PathToBottom::new(path.into(), EdgePathLength::new(length).unwrap()) .unwrap(), - }), - }, - ) + }), + }) } fn create_mock_leaf_entry_for_testing( index: u128, hash: &str, ) -> (NodeIndex, FilledNode) { - ( - NodeIndex::from(index), - FilledNode { - hash: HashOutput(Felt::from_hex(hash).unwrap()), - data: NodeData::Leaf(MockLeaf(Felt::from_hex(hash).unwrap())), - }, - ) + (NodeIndex::from(index), FilledNode { + hash: HashOutput(Felt::from_hex(hash).unwrap()), + data: NodeData::Leaf(MockLeaf(Felt::from_hex(hash).unwrap())), + }) } diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree.rs b/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree.rs index c17cf47243..0b9091913a 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree.rs @@ -22,7 +22,7 @@ use crate::patricia_merkle_tree::original_skeleton_tree::tree::{ use crate::patricia_merkle_tree::original_skeleton_tree::utils::split_leaves; use crate::patricia_merkle_tree::types::{NodeIndex, SortedLeafIndices, SubTreeHeight}; use crate::storage::errors::StorageError; -use crate::storage::storage_trait::{create_db_key, StarknetPrefix, Storage, StorageKey}; +use crate::storage::storage_trait::{StarknetPrefix, Storage, StorageKey, create_db_key}; #[cfg(test)] #[path = "create_tree_test.rs"] diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree_test.rs b/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree_test.rs index c02e7aaba0..c81b1a868b 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree_test.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree_test.rs @@ -17,9 +17,9 @@ use crate::patricia_merkle_tree::external_test_utils::{ create_unmodified_subtree_skeleton_node, }; use crate::patricia_merkle_tree::internal_test_utils::{ - small_tree_index_to_full, MockLeaf, OriginalSkeletonMockTrieConfig, + small_tree_index_to_full, }; use crate::patricia_merkle_tree::node_data::inner_node::{EdgePath, EdgePathLength, PathToBottom}; use crate::patricia_merkle_tree::node_data::leaf::LeafModifications; diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/utils_test.rs b/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/utils_test.rs index da55e02e75..04488f93af 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/utils_test.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/utils_test.rs @@ -1,6 +1,6 @@ -use ethnum::{uint, U256}; -use rand::rngs::ThreadRng; +use ethnum::{U256, uint}; use rand::Rng; +use rand::rngs::ThreadRng; use rstest::rstest; use super::split_leaves; diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/types_test.rs b/crates/starknet_patricia/src/patricia_merkle_tree/types_test.rs index 08447d3b6f..6e688b0d47 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/types_test.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/types_test.rs @@ -1,6 +1,6 @@ -use ethnum::{uint, U256}; -use rand::rngs::ThreadRng; +use ethnum::{U256, uint}; use rand::Rng; +use rand::rngs::ThreadRng; use rstest::rstest; use crate::felt::Felt; diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper_test.rs b/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper_test.rs index 83634c1db3..23154cff4c 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper_test.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper_test.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use ethnum::{uint, U256}; +use ethnum::{U256, uint}; use pretty_assertions::assert_eq; use rstest::{fixture, rstest}; @@ -8,13 +8,13 @@ use crate::felt::Felt; use crate::hash::hash_trait::HashOutput; use crate::patricia_merkle_tree::filled_tree::tree::FilledTree; use crate::patricia_merkle_tree::internal_test_utils::{ - as_fully_indexed, - get_initial_updated_skeleton, - small_tree_index_to_full, MockLeaf, MockTrie, OriginalSkeletonMockTrieConfig, TestTreeHashFunction, + as_fully_indexed, + get_initial_updated_skeleton, + small_tree_index_to_full, }; use crate::patricia_merkle_tree::node_data::inner_node::{EdgePathLength, PathToBottom}; use crate::patricia_merkle_tree::original_skeleton_tree::node::OriginalSkeletonNode; @@ -24,9 +24,9 @@ use crate::patricia_merkle_tree::original_skeleton_tree::tree::{ }; use crate::patricia_merkle_tree::types::{NodeIndex, SortedLeafIndices, SubTreeHeight}; use crate::patricia_merkle_tree::updated_skeleton_tree::create_tree_helper::{ + TempSkeletonNode, get_path_to_lca, has_leaves_on_both_sides, - TempSkeletonNode, }; use crate::patricia_merkle_tree::updated_skeleton_tree::node::UpdatedSkeletonNode; use crate::patricia_merkle_tree::updated_skeleton_tree::tree::{ diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/tree_test.rs b/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/tree_test.rs index 8f9cb3d6ec..df9f4d699a 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/tree_test.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/tree_test.rs @@ -5,9 +5,9 @@ use rstest::{fixture, rstest}; use crate::felt::Felt; use crate::hash::hash_trait::HashOutput; use crate::patricia_merkle_tree::internal_test_utils::{ - get_initial_updated_skeleton, MockLeaf, OriginalSkeletonMockTrieConfig, + get_initial_updated_skeleton, }; use crate::patricia_merkle_tree::node_data::inner_node::PathToBottom; use crate::patricia_merkle_tree::node_data::leaf::{LeafModifications, SkeletonLeaf}; diff --git a/crates/starknet_sierra_compile/src/cairo_lang_compiler.rs b/crates/starknet_sierra_compile/src/cairo_lang_compiler.rs index b78e1bbc78..c8fbf2d7c7 100644 --- a/crates/starknet_sierra_compile/src/cairo_lang_compiler.rs +++ b/crates/starknet_sierra_compile/src/cairo_lang_compiler.rs @@ -4,9 +4,9 @@ use cairo_lang_starknet_classes::allowed_libfuncs::ListSelector; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use cairo_lang_starknet_classes::contract_class::ContractClass; +use crate::SierraToCasmCompiler; use crate::config::SierraToCasmCompilationConfig; use crate::errors::CompilationUtilError; -use crate::SierraToCasmCompiler; /// A compiler that compiles Sierra programs to Casm. Uses the code from the /// `cairo_lang_starknet_classes` crate. diff --git a/crates/starknet_sierra_compile/src/compile_test.rs b/crates/starknet_sierra_compile/src/compile_test.rs index 547b92c497..3e2f0b0b25 100644 --- a/crates/starknet_sierra_compile/src/compile_test.rs +++ b/crates/starknet_sierra_compile/src/compile_test.rs @@ -2,14 +2,14 @@ use std::env; use std::path::Path; use assert_matches::assert_matches; -use mempool_test_utils::{get_absolute_path, FAULTY_ACCOUNT_CLASS_FILE, TEST_FILES_FOLDER}; +use mempool_test_utils::{FAULTY_ACCOUNT_CLASS_FILE, TEST_FILES_FOLDER, get_absolute_path}; use rstest::{fixture, rstest}; +use crate::SierraToCasmCompiler; use crate::cairo_lang_compiler::CairoLangSierraToCasmCompiler; use crate::config::SierraToCasmCompilationConfig; use crate::errors::CompilationUtilError; use crate::test_utils::contract_class_from_file; -use crate::SierraToCasmCompiler; #[fixture] fn compiler() -> impl SierraToCasmCompiler { diff --git a/crates/starknet_sierra_compile/src/config.rs b/crates/starknet_sierra_compile/src/config.rs index 175ded0fca..b607c59f31 100644 --- a/crates/starknet_sierra_compile/src/config.rs +++ b/crates/starknet_sierra_compile/src/config.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; -use papyrus_config::dumping::{ser_param, SerializeConfig}; +use papyrus_config::dumping::{SerializeConfig, ser_param}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::Validate; diff --git a/crates/tests-integration/src/integration_test_setup.rs b/crates/tests-integration/src/integration_test_setup.rs index 0cb1a95da5..6f884d1f10 100644 --- a/crates/tests-integration/src/integration_test_setup.rs +++ b/crates/tests-integration/src/integration_test_setup.rs @@ -1,7 +1,7 @@ use std::net::SocketAddr; -use blockifier::test_utils::contracts::FeatureContract; use blockifier::test_utils::CairoVersion; +use blockifier::test_utils::contracts::FeatureContract; use starknet_api::executable_transaction::Transaction; use starknet_api::rpc_transaction::RpcTransaction; use starknet_api::transaction::TransactionHash; @@ -14,7 +14,7 @@ use starknet_task_executor::tokio_executor::TokioExecutor; use tokio::runtime::Handle; use tokio::task::JoinHandle; -use crate::integration_test_utils::{create_config, GatewayClient}; +use crate::integration_test_utils::{GatewayClient, create_config}; use crate::mock_batcher::MockBatcher; use crate::state_reader::spawn_test_rpc_state_reader; diff --git a/crates/tests-integration/src/integration_test_utils.rs b/crates/tests-integration/src/integration_test_utils.rs index 1905b68dda..75584f7cfc 100644 --- a/crates/tests-integration/src/integration_test_utils.rs +++ b/crates/tests-integration/src/integration_test_utils.rs @@ -3,8 +3,8 @@ use std::net::SocketAddr; use axum::body::Body; use blockifier::test_utils::contracts::FeatureContract; use mempool_test_utils::starknet_api_test_utils::{ - rpc_tx_to_json, MultiAccountTransactionGenerator, + rpc_tx_to_json, }; use reqwest::{Client, Response}; use starknet_api::rpc_transaction::RpcTransaction; diff --git a/crates/tests-integration/src/state_reader.rs b/crates/tests-integration/src/state_reader.rs index f9cde785c0..5000ace1bf 100644 --- a/crates/tests-integration/src/state_reader.rs +++ b/crates/tests-integration/src/state_reader.rs @@ -6,26 +6,26 @@ use blockifier::context::{BlockContext, ChainInfo}; use blockifier::execution::contract_class::NativeContractClassV1; use blockifier::test_utils::contracts::FeatureContract; use blockifier::test_utils::{ - CairoVersion, BALANCE, CURRENT_BLOCK_TIMESTAMP, + CairoVersion, DEFAULT_ETH_L1_GAS_PRICE, DEFAULT_STRK_L1_GAS_PRICE, TEST_SEQUENCER_ADDRESS, }; use blockifier::transaction::objects::FeeType; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; -use indexmap::{indexmap, IndexMap}; +use indexmap::{IndexMap, indexmap}; use itertools::Itertools; use mempool_test_utils::starknet_api_test_utils::deploy_account_tx; use papyrus_common::pending_classes::PendingClasses; -use papyrus_rpc::{run_server, RpcConfig}; +use papyrus_rpc::{RpcConfig, run_server}; use papyrus_storage::body::BodyStorageWriter; use papyrus_storage::class::ClassStorageWriter; use papyrus_storage::compiled_class::CasmStorageWriter; use papyrus_storage::header::HeaderStorageWriter; use papyrus_storage::state::StateStorageWriter; -use papyrus_storage::{open_storage, StorageConfig, StorageReader}; +use papyrus_storage::{StorageConfig, StorageReader, open_storage}; use starknet_api::block::{ BlockBody, BlockHeader, diff --git a/crates/tests-integration/tests/end_to_end_test.rs b/crates/tests-integration/tests/end_to_end_test.rs index acfe1aa0da..81d1828075 100644 --- a/crates/tests-integration/tests/end_to_end_test.rs +++ b/crates/tests-integration/tests/end_to_end_test.rs @@ -1,5 +1,5 @@ -use blockifier::test_utils::contracts::FeatureContract; use blockifier::test_utils::CairoVersion; +use blockifier::test_utils::contracts::FeatureContract; use starknet_api::transaction::TransactionHash; use starknet_mempool_integration_tests::integration_test_utils::setup_with_tx_generation;