From b5fb285188fb2b5ab123651129bc2709a224f3c0 Mon Sep 17 00:00:00 2001 From: mohammad-starkware <130282237+MohammadNassar1@users.noreply.github.com> Date: Thu, 4 Jul 2024 13:39:06 +0300 Subject: [PATCH] chore: upgrade blockifier version to v0.8.0-dev.0 (#360) --- Cargo.lock | 450 ++++++++++-------- Cargo.toml | 25 +- crates/gateway/Cargo.toml | 3 + crates/gateway/src/compilation.rs | 4 +- crates/gateway/src/compiler_version.rs | 13 +- crates/gateway/src/rpc_state_reader.rs | 6 +- crates/gateway/src/state_reader.rs | 4 +- crates/gateway/src/state_reader_test_utils.rs | 10 +- .../stateful_transaction_validator_test.rs | 23 +- .../src/stateless_transaction_validator.rs | 4 +- .../stateless_transaction_validator_test.rs | 32 +- crates/gateway/src/test_utils.rs | 10 +- crates/mempool/Cargo.toml | 1 + crates/mempool/src/mempool_test.rs | 48 +- crates/starknet_sierra_compile/Cargo.toml | 2 +- crates/starknet_sierra_compile/src/utils.rs | 20 +- crates/test_utils/Cargo.toml | 1 + .../test_utils/src/starknet_api_test_utils.rs | 115 ++--- crates/tests-integration/Cargo.toml | 1 + crates/tests-integration/src/state_reader.rs | 10 +- 20 files changed, 420 insertions(+), 362 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16f588b3..c1ff8d3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -549,47 +549,9 @@ dependencies = [ [[package]] name = "blockifier" -version = "0.7.0-dev.1" -source = "git+https://github.com/starkware-libs/blockifier.git?branch=main-mempool#cbfddc375cd5bde74170e9f72b7fe7e2d2a21555" -dependencies = [ - "anyhow", - "ark-ec", - "ark-ff", - "ark-secp256k1", - "ark-secp256r1", - "cached", - "cairo-felt", - "cairo-lang-casm", - "cairo-lang-runner", - "cairo-lang-starknet-classes", - "cairo-lang-utils", - "cairo-vm", - "derive_more", - "indexmap 2.2.6", - "itertools 0.10.5", - "keccak", - "log", - "num-bigint", - "num-integer", - "num-rational", - "num-traits 0.2.19", - "once_cell", - "phf", - "rstest", - "serde", - "serde_json", - "sha3", - "starknet-crypto 0.5.2", - "starknet_api", - "strum 0.24.1", - "strum_macros 0.24.3", - "thiserror", -] - -[[package]] -name = "blockifier" -version = "0.7.0-dev.1" -source = "git+https://github.com/starkware-libs/blockifier.git?rev=6babc28a#6babc28a5714a5e8ba2d3d84895c41d4f612a40f" +version = "0.8.0-dev.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4f57ce711234b75654cda8d80198b4623a4a5390b8cb2e2c8d740d8def8d8d" dependencies = [ "anyhow", "ark-ec", @@ -597,7 +559,6 @@ dependencies = [ "ark-secp256k1", "ark-secp256r1", "cached", - "cairo-felt", "cairo-lang-casm", "cairo-lang-runner", "cairo-lang-starknet-classes", @@ -619,6 +580,7 @@ dependencies = [ "serde_json", "sha3", "starknet-crypto 0.5.2", + "starknet-types-core", "starknet_api", "strum 0.24.1", "strum_macros 0.24.3", @@ -635,6 +597,16 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "bstr" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -719,24 +691,11 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" -[[package]] -name = "cairo-felt" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae932292b9ba497a4e892b56aa4e0c6f329a455180fdbdc132700dfe68d9b153" -dependencies = [ - "lazy_static", - "num-bigint", - "num-integer", - "num-traits 0.2.19", - "serde", -] - [[package]] name = "cairo-lang-casm" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6296d5748288d9fb97175d31aff9f68ea3f602456923895e512b078e9a2210a0" +checksum = "4e67d781fe3f8a8edfeb308e012b1e1a575bc2f1818e264b98758699602826e5" dependencies = [ "cairo-lang-utils", "indoc", @@ -748,9 +707,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7be5083c3328dad2248a94f0a24b3520c588e7d3bd5891770e4c91d3facade3" +checksum = "1d1b91df87775298a32faca8683da42fafe12bac4bd659755fe8ad0852a2ca65" dependencies = [ "anyhow", "cairo-lang-defs", @@ -764,6 +723,7 @@ dependencies = [ "cairo-lang-sierra-generator", "cairo-lang-syntax", "cairo-lang-utils", + "indoc", "salsa", "smol_str", "thiserror", @@ -771,18 +731,18 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a3cbf67fd766cb7ed48b72e6abf7041857518c9b9fd42475a60c138671c6603" +checksum = "6d98288c8967adbe12b97d2b6c87db240728899af9f22e0eeb1d8b90262a5d0f" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b284e41dfc158dfbdc02612dbfdb27a55547d23063bdc53105eeec41d8df006" +checksum = "60176d0dbf4edc0afe75343ef6460e8544b92c298c829ed9a0e04271296438d5" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -790,28 +750,28 @@ dependencies = [ "cairo-lang-parser", "cairo-lang-syntax", "cairo-lang-utils", - "itertools 0.11.0", + "itertools 0.12.1", "salsa", "smol_str", ] [[package]] name = "cairo-lang-diagnostics" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6314b24901af8be75cd0e1363e3ff1a8020066372501f4cfc9161726b06ec2a" +checksum = "2617a46069a30f6616b3b2ac61f2f84102aadf0a890c361e835ae89ed680bb6c" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", "cairo-lang-utils", - "itertools 0.11.0", + "itertools 0.12.1", ] [[package]] name = "cairo-lang-eq-solver" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f95f5c8f7ea75580d164b5304251022e3d47f43fc1c778a01381b55ca9f268c" +checksum = "70bcca24edb847fc14242ce89e5e942dbca3db7cd8270d44cf4b6296998b8bcc" dependencies = [ "cairo-lang-utils", "good_lp", @@ -819,9 +779,9 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e58b80f0b413ef1320358fde1a0877fc3fbf740f5cead0de3e947a1bc3bfd4" +checksum = "29e2126b984e05a531cabdf0f8ab7fbdbeb1853202e76784256373b76588f89c" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -831,11 +791,32 @@ dependencies = [ "smol_str", ] +[[package]] +name = "cairo-lang-formatter" +version = "2.7.0-rc.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8551db414f1ab22f94a47d5cfb213e3bbd0e096d500990e5e4518d48822dfa" +dependencies = [ + "anyhow", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-parser", + "cairo-lang-syntax", + "cairo-lang-utils", + "diffy", + "ignore", + "itertools 0.12.1", + "salsa", + "serde", + "smol_str", + "thiserror", +] + [[package]] name = "cairo-lang-lowering" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abe6d604a06ea96c05b3666f2e8fac63cb8709e13667de272912f81db004a16b" +checksum = "4d7820cef63a4f9e3c380b29e1a90b01687e2e36e172ce59c7f7c0888a386a7f" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -847,7 +828,7 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "id-arena", - "itertools 0.11.0", + "itertools 0.12.1", "log", "num-bigint", "num-traits 0.2.19", @@ -858,9 +839,9 @@ dependencies = [ [[package]] name = "cairo-lang-parser" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf1c279de47a77422f81b8a98023cd523cf0ae79f7153d60c4cf8b62b8ece2f" +checksum = "8724e5c3ddf632a61f096d6073b4b94e4b77925cb4ccd5b3e59e738fad0885ec" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -868,7 +849,7 @@ dependencies = [ "cairo-lang-syntax-codegen", "cairo-lang-utils", "colored", - "itertools 0.11.0", + "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", "salsa", @@ -878,9 +859,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1177a07498bdf45cba62f0c727388ff7433072847dbf701c58fa3c3e358154e" +checksum = "4e27d87f738d77895a5601c3451cfac3c998c45cab75b99b98ae4074369614fc" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -890,16 +871,16 @@ dependencies = [ "cairo-lang-utils", "indent", "indoc", - "itertools 0.11.0", + "itertools 0.12.1", "salsa", "smol_str", ] [[package]] name = "cairo-lang-proc-macros" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c90d812ec983c5a8e3173aca3fc55036b9739201c89f30271ee14a4c1189379" +checksum = "70f8c9a7127bff999715ce632fa1c96fdafecf1ad401b9739d5af530a7b33adf" dependencies = [ "cairo-lang-debug", "quote", @@ -908,9 +889,9 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3985495d7e9dc481e97135d7139cfa098024351fb51d5feef8366b5fbc104807" +checksum = "dc4ddd050058e7b08b6de3d7d0160aa9f8dd6c16f2a5b4da6e1429a9e143eb47" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -922,15 +903,13 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc7c5969d107d24dbd7612ab7afec65d25475fe51d4bb708e3c773f2346c92b" +checksum = "26d8ba0a0ad648f80cc008aa7f386c3058afbff99284c8accdbecb114b84dc8d" dependencies = [ "ark-ff", "ark-secp256k1", "ark-secp256r1", - "ark-std", - "cairo-felt", "cairo-lang-casm", "cairo-lang-lowering", "cairo-lang-sierra", @@ -941,21 +920,23 @@ dependencies = [ "cairo-lang-starknet", "cairo-lang-utils", "cairo-vm", - "itertools 0.11.0", + "itertools 0.12.1", "keccak", "num-bigint", "num-integer", "num-traits 0.2.19", + "rand", + "sha2", "smol_str", - "starknet-crypto 0.6.2", + "starknet-types-core", "thiserror", ] [[package]] name = "cairo-lang-semantic" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5cfadbb9ca3479a6b5c02c0a125a5747835ba57a2de9c4e9764f42d85abe059" +checksum = "4fd5d4e1531db649593e14cc0f038ceaf0b355b0b538c45874d7fe8b8fef7169" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -965,78 +946,84 @@ dependencies = [ "cairo-lang-plugins", "cairo-lang-proc-macros", "cairo-lang-syntax", + "cairo-lang-test-utils", "cairo-lang-utils", "id-arena", "indoc", - "itertools 0.11.0", + "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", "once_cell", "salsa", "smol_str", + "toml", ] [[package]] name = "cairo-lang-sierra" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74a57492267a5a8891866b6e48cdefa508b5f05931a5f8eaf004b9de15b1ffd6" +checksum = "89b56bc9e96b479ae74e30b1004a7599480e3850b5d7a492788036807568eebe" dependencies = [ "anyhow", - "cairo-felt", "cairo-lang-utils", "const-fnv1a-hash", "convert_case 0.6.0", "derivative", - "itertools 0.11.0", + "itertools 0.12.1", "lalrpop", "lalrpop-util", "num-bigint", + "num-integer", "num-traits 0.2.19", + "once_cell", "regex", "salsa", "serde", "serde_json", "sha3", "smol_str", + "starknet-types-core", "thiserror", ] [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fdbb4bd95477123653b9200bd4e9dceae95a914f6fe85b2bed83b223e36fb5a" +checksum = "c80caa2c4202dfc58bba56e4b0bebc8152dc06f979342aea6c5310566bcfa26d" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", "cairo-lang-sierra-type-size", "cairo-lang-utils", - "itertools 0.11.0", + "itertools 0.12.1", + "num-bigint", "num-traits 0.2.19", "thiserror", ] [[package]] name = "cairo-lang-sierra-gas" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "882cb178f1b79aabf70acce1d87b08d569d8a4b0ce8b1d8f538a02cdb36789db" +checksum = "40eebf3d027a5663a47679319cf9aad312cd417a47afb638f34bf83ba2e45944" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", "cairo-lang-sierra-type-size", "cairo-lang-utils", - "itertools 0.11.0", + "itertools 0.12.1", + "num-bigint", "num-traits 0.2.19", "thiserror", ] [[package]] name = "cairo-lang-sierra-generator" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d80c9d29e6d3f4ab60e698ebe2de84dcf90570c3dd1cfa7b01bd5c42470331c" +checksum = "cd35fc261cc700d02698aa2d95654a0ed9cfb543cb152c618906367f899e1cde" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1048,21 +1035,22 @@ dependencies = [ "cairo-lang-sierra", "cairo-lang-syntax", "cairo-lang-utils", - "itertools 0.11.0", + "itertools 0.12.1", "num-traits 0.2.19", "once_cell", "salsa", + "serde", + "serde_json", "smol_str", ] [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ac02c90be2630ae861db6af226090da92741020519768332dd2c07e24d94c75" +checksum = "f3af5f65598f90160754c7d9e277ec6eb187b6f4fa018676109666c1f6cb3024" dependencies = [ "assert_matches", - "cairo-felt", "cairo-lang-casm", "cairo-lang-sierra", "cairo-lang-sierra-ap-change", @@ -1070,17 +1058,18 @@ dependencies = [ "cairo-lang-sierra-type-size", "cairo-lang-utils", "indoc", - "itertools 0.11.0", + "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", + "starknet-types-core", "thiserror", ] [[package]] name = "cairo-lang-sierra-type-size" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d102b10989f9637b1c916dd950cbd1bd8bb1b6a7aaa1a3035390be0683b92d85" +checksum = "d1f5b3fab76e649246e17f5c12b584a2e0b729fecafbf23f24b86a8250df8849" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -1088,12 +1077,11 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27921a2bf82d191d28afd570b913341080c8fc25c83bf870dbf1252570b1b41" +checksum = "c85460aed78bc233a089aeecd27a1ed3d82a2eb079e4b2d7dc62d50ad7326b1a" dependencies = [ "anyhow", - "cairo-felt", "cairo-lang-compiler", "cairo-lang-defs", "cairo-lang-diagnostics", @@ -1109,27 +1097,27 @@ dependencies = [ "const_format", "indent", "indoc", - "itertools 0.11.0", + "itertools 0.12.1", "once_cell", "serde", "serde_json", "smol_str", + "starknet-types-core", "thiserror", ] [[package]] name = "cairo-lang-starknet-classes" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8623b076ef3569e4262da5da270a84658b1ff242fe0c9624fbe432e7a937d101" +checksum = "167f3754129e279fa1759a990bfec1f8b48d8acee9f1d46862ec5d298d3de171" dependencies = [ - "cairo-felt", "cairo-lang-casm", "cairo-lang-sierra", "cairo-lang-sierra-to-casm", "cairo-lang-utils", "convert_case 0.6.0", - "itertools 0.11.0", + "itertools 0.12.1", "num-bigint", "num-integer", "num-traits 0.2.19", @@ -1138,15 +1126,15 @@ dependencies = [ "serde_json", "sha3", "smol_str", - "starknet-crypto 0.6.2", + "starknet-types-core", "thiserror", ] [[package]] name = "cairo-lang-syntax" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c62f5bd74e249636e7c48d8b95e6cc0ee991206d4a6cbe5c2624184a828e70b" +checksum = "fff58f236a630117b382039701cb94186a054a32132149d6ceddf7f5f3ce673b" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1160,23 +1148,36 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a744747e9ab03b65480265304490f3e29d99e4cb297e39d0e6fdb047c1bc86a7" +checksum = "654c66a6408f85a1118f37f8f818c61dd1e0f5623901cba7c87b290703285e43" dependencies = [ "genco", "xshell", ] +[[package]] +name = "cairo-lang-test-utils" +version = "2.7.0-rc.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bcefb85292f9fb18b03f47e2fcc56b3b02945485495c7d75ae2c85e17295c63" +dependencies = [ + "cairo-lang-formatter", + "cairo-lang-utils", + "colored", + "log", + "pretty_assertions", +] + [[package]] name = "cairo-lang-utils" -version = "2.6.4" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6f98e8769412907ceb106c21c70907cc0c87ca0a2a44c82b6229a695a6f9b48" +checksum = "d7c6907351815be936e9aad13437604391264067789d4d1e9ef15c099258a08a" dependencies = [ "hashbrown 0.14.5", "indexmap 2.2.6", - "itertools 0.11.0", + "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", "parity-scale-codec", @@ -1186,34 +1187,32 @@ dependencies = [ [[package]] name = "cairo-vm" -version = "0.9.3" +version = "1.0.0-rc3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d90d260c5b0c0812f02fcbdc21eb0d5908fcecdca888fb779b54c3967f7f88bf" +checksum = "a0fa4c74b86c0f17b58ced4fdab5c1da0a41fb12725ad7601e12bb27d8d90435" dependencies = [ "anyhow", "bincode 2.0.0-rc.3", "bitvec", - "cairo-felt", "generic-array", "hashbrown 0.14.5", "hex", "keccak", "lazy_static", - "mimalloc", "nom", "num-bigint", "num-integer", "num-prime", "num-traits 0.2.19", "rand", - "rust_decimal", "serde", "serde_json", "sha2", "sha3", "starknet-crypto 0.6.2", - "starknet-curve 0.4.2", + "starknet-types-core", "thiserror-no-std", + "zip", ] [[package]] @@ -1651,6 +1650,15 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" +[[package]] +name = "diffy" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e616e59155c92257e84970156f506287853355f58cd4a6eb167385722c32b790" +dependencies = [ + "nu-ansi-term", +] + [[package]] name = "digest" version = "0.9.0" @@ -2417,6 +2425,19 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "globset" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + [[package]] name = "gloo-net" version = "0.4.0" @@ -2731,6 +2752,22 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" +[[package]] +name = "ignore" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + [[package]] name = "impl-codec" version = "0.6.0" @@ -3136,9 +3173,9 @@ dependencies = [ [[package]] name = "lambdaworks-crypto" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458fee521f12d0aa97a2e06eaf134398a5d2ae7b2074af77eb402b0d93138c47" +checksum = "7fb5d4f22241504f7c7b8d2c3a7d7835d7c07117f10bff2a7d96a9ef6ef217c3" dependencies = [ "lambdaworks-math", "serde", @@ -3148,9 +3185,9 @@ dependencies = [ [[package]] name = "lambdaworks-math" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c74ce6f0d9cb672330b6ca59e85a6c3607a3329e0372ab0d3fe38c2d38e50f9" +checksum = "358e172628e713b80a530a59654154bfc45783a6ed70ea284839800cebdf8f97" dependencies = [ "serde", "serde_json", @@ -3210,16 +3247,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "libmimalloc-sys" -version = "0.1.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23aa6811d3bd4deb8a84dde645f943476d13b248d818edcf8ce0b2f37f036b44" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "libredox" version = "0.1.3" @@ -3349,15 +3376,6 @@ dependencies = [ "syn 2.0.68", ] -[[package]] -name = "mimalloc" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68914350ae34959d83f732418d51e2427a794055d0b9529f48259ac07af65633" -dependencies = [ - "libmimalloc-sys", -] - [[package]] name = "mime" version = "0.3.17" @@ -3446,6 +3464,16 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-bigint" version = "0.4.6" @@ -3685,6 +3713,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "page_size" version = "0.6.0" @@ -3697,25 +3731,29 @@ dependencies = [ [[package]] name = "papyrus_common" -version = "0.4.0-dev.2" -source = "git+https://github.com/starkware-libs/papyrus.git?rev=56c6fdc2#56c6fdc2851ab1c60663a679f8b75a28cd0f954e" +version = "0.4.0-dev.4" +source = "git+https://github.com/starkware-libs/papyrus.git?rev=22de602#22de602d4a1cc8ab0f207a4eb8259917b89922ab" dependencies = [ "bitvec", "cairo-lang-starknet-classes", "hex", + "indexmap 2.2.6", + "itertools 0.10.5", "lazy_static", + "rand", "serde", "serde_json", "sha3", "starknet-crypto 0.5.2", + "starknet-types-core", "starknet_api", "thiserror", ] [[package]] name = "papyrus_config" -version = "0.4.0-dev.2" -source = "git+https://github.com/starkware-libs/papyrus.git?rev=56c6fdc2#56c6fdc2851ab1c60663a679f8b75a28cd0f954e" +version = "0.4.0-dev.4" +source = "git+https://github.com/starkware-libs/papyrus.git?rev=22de602#22de602d4a1cc8ab0f207a4eb8259917b89922ab" dependencies = [ "clap", "itertools 0.10.5", @@ -3728,11 +3766,11 @@ dependencies = [ [[package]] name = "papyrus_execution" -version = "0.4.0-dev.2" -source = "git+https://github.com/starkware-libs/papyrus.git?rev=56c6fdc2#56c6fdc2851ab1c60663a679f8b75a28cd0f954e" +version = "0.4.0-dev.4" +source = "git+https://github.com/starkware-libs/papyrus.git?rev=22de602#22de602d4a1cc8ab0f207a4eb8259917b89922ab" dependencies = [ "anyhow", - "blockifier 0.7.0-dev.1 (git+https://github.com/starkware-libs/blockifier.git?rev=6babc28a)", + "blockifier", "cairo-lang-starknet-classes", "cairo-vm", "indexmap 2.2.6", @@ -3744,6 +3782,7 @@ dependencies = [ "papyrus_storage", "serde", "serde_json", + "starknet-types-core", "starknet_api", "thiserror", "tracing", @@ -3751,8 +3790,8 @@ dependencies = [ [[package]] name = "papyrus_proc_macros" -version = "0.4.0-dev.2" -source = "git+https://github.com/starkware-libs/papyrus.git?rev=56c6fdc2#56c6fdc2851ab1c60663a679f8b75a28cd0f954e" +version = "0.4.0-dev.4" +source = "git+https://github.com/starkware-libs/papyrus.git?rev=22de602#22de602d4a1cc8ab0f207a4eb8259917b89922ab" dependencies = [ "quote", "syn 2.0.68", @@ -3760,8 +3799,8 @@ dependencies = [ [[package]] name = "papyrus_rpc" -version = "0.4.0-dev.2" -source = "git+https://github.com/starkware-libs/papyrus.git?rev=56c6fdc2#56c6fdc2851ab1c60663a679f8b75a28cd0f954e" +version = "0.4.0-dev.4" +source = "git+https://github.com/starkware-libs/papyrus.git?rev=22de602#22de602d4a1cc8ab0f207a4eb8259917b89922ab" dependencies = [ "anyhow", "async-trait", @@ -3784,6 +3823,7 @@ dependencies = [ "regex", "serde", "serde_json", + "starknet-types-core", "starknet_api", "starknet_client", "thiserror", @@ -3797,14 +3837,13 @@ dependencies = [ [[package]] name = "papyrus_storage" -version = "0.4.0-dev.2" -source = "git+https://github.com/starkware-libs/papyrus.git?rev=56c6fdc2#56c6fdc2851ab1c60663a679f8b75a28cd0f954e" +version = "0.4.0-dev.4" +source = "git+https://github.com/starkware-libs/papyrus.git?rev=22de602#22de602d4a1cc8ab0f207a4eb8259917b89922ab" dependencies = [ "byteorder", "cairo-lang-casm", "cairo-lang-starknet-classes", "cairo-lang-utils", - "flate2", "human_bytes", "indexmap 2.2.6", "integer-encoding", @@ -3820,17 +3859,19 @@ dependencies = [ "primitive-types", "serde", "serde_json", + "starknet-types-core", "starknet_api", "thiserror", "tracing", "validator", + "zstd 0.13.1", ] [[package]] name = "parity-scale-codec" -version = "3.6.5" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ "arrayvec", "bitvec", @@ -4514,16 +4555,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "rust_decimal" -version = "1.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1790d1c4c0ca81211399e0e0af16333276f375209e71a37b67698a373db5b47a" -dependencies = [ - "arrayvec", - "num-traits 0.2.19", -] - [[package]] name = "rustc-demangle" version = "0.1.24" @@ -5162,11 +5193,10 @@ dependencies = [ [[package]] name = "starknet-types-core" -version = "0.0.11" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1e16522c1c9aa7fc149a46816cd18aa12a5fc2b2b75a018089022db473a9237" +checksum = "ce6bacf0ba19bc721e518bc4bf389ff13daa8a7c5db5fd320600473b8aa9fcbd" dependencies = [ - "bitvec", "lambdaworks-crypto", "lambdaworks-math", "lazy_static", @@ -5178,9 +5208,11 @@ dependencies = [ [[package]] name = "starknet_api" -version = "0.12.0-dev.1" -source = "git+https://github.com/starkware-libs/starknet-api.git?branch=main-mempool#1c6269442cd502c9dbf39777ac5be3e8c1d390b7" +version = "0.13.0-dev.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66a6dc6b4f77fff0f28894cc36d5a691784550054d06c6850e901278aed2c7e6" dependencies = [ + "bitvec", "cairo-lang-starknet-classes", "derive_more", "hex", @@ -5190,6 +5222,7 @@ dependencies = [ "primitive-types", "serde", "serde_json", + "sha3", "starknet-crypto 0.5.2", "starknet-types-core", "strum 0.24.1", @@ -5199,8 +5232,8 @@ dependencies = [ [[package]] name = "starknet_client" -version = "0.4.0-dev.2" -source = "git+https://github.com/starkware-libs/papyrus.git?rev=56c6fdc2#56c6fdc2851ab1c60663a679f8b75a28cd0f954e" +version = "0.4.0-dev.4" +source = "git+https://github.com/starkware-libs/papyrus.git?rev=22de602#22de602d4a1cc8ab0f207a4eb8259917b89922ab" dependencies = [ "async-trait", "cairo-lang-starknet-classes", @@ -5213,6 +5246,7 @@ dependencies = [ "serde", "serde_json", "serde_repr", + "starknet-types-core", "starknet_api", "strum 0.25.0", "strum_macros 0.25.3", @@ -5230,10 +5264,12 @@ dependencies = [ "assert_matches", "async-trait", "axum", - "blockifier 0.7.0-dev.1 (git+https://github.com/starkware-libs/blockifier.git?branch=main-mempool)", + "blockifier", "cairo-lang-starknet-classes", "cairo-vm", "hyper", + "num-bigint", + "num-traits 0.2.19", "papyrus_config", "papyrus_rpc", "pretty_assertions", @@ -5241,6 +5277,7 @@ dependencies = [ "rstest", "serde", "serde_json", + "starknet-types-core", "starknet_api", "starknet_mempool", "starknet_mempool_infra", @@ -5262,6 +5299,7 @@ dependencies = [ "itertools 0.13.0", "pretty_assertions", "rstest", + "starknet-types-core", "starknet_api", "starknet_mempool_infra", "starknet_mempool_types", @@ -5288,7 +5326,7 @@ name = "starknet_mempool_integration_tests" version = "0.0.0" dependencies = [ "axum", - "blockifier 0.7.0-dev.1 (git+https://github.com/starkware-libs/blockifier.git?branch=main-mempool)", + "blockifier", "cairo-lang-starknet-classes", "indexmap 2.2.6", "papyrus_common", @@ -5298,6 +5336,7 @@ dependencies = [ "reqwest", "rstest", "serde_json", + "starknet-types-core", "starknet_api", "starknet_client", "starknet_gateway", @@ -5350,9 +5389,9 @@ dependencies = [ "cairo-lang-sierra", "cairo-lang-starknet-classes", "cairo-lang-utils", - "num-bigint", "serde", "serde_json", + "starknet-types-core", "starknet_api", "test_utils", "thiserror", @@ -5568,8 +5607,9 @@ name = "test_utils" version = "0.0.0" dependencies = [ "assert_matches", - "blockifier 0.7.0-dev.1 (git+https://github.com/starkware-libs/blockifier.git?branch=main-mempool)", + "blockifier", "serde_json", + "starknet-types-core", "starknet_api", ] @@ -6512,7 +6552,7 @@ dependencies = [ "pbkdf2 0.11.0", "sha1", "time", - "zstd", + "zstd 0.11.2+zstd.1.5.2", ] [[package]] @@ -6521,7 +6561,16 @@ version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ - "zstd-safe", + "zstd-safe 5.0.2+zstd.1.5.2", +] + +[[package]] +name = "zstd" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" +dependencies = [ + "zstd-safe 7.1.0", ] [[package]] @@ -6534,6 +6583,15 @@ dependencies = [ "zstd-sys", ] +[[package]] +name = "zstd-safe" +version = "7.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd99b45c6bc03a018c8b8a86025678c87e55526064e38f9df301989dce7ec0a" +dependencies = [ + "zstd-sys", +] + [[package]] name = "zstd-sys" version = "2.0.11+zstd.1.5.6" diff --git a/Cargo.toml b/Cargo.toml index 31097576..1d6d9a08 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,12 +36,12 @@ async-trait = "0.1.79" axum = "0.6.12" # TODO(YaelD, 28/5/2024): The special Blockifier version is needed in order to be aligned with the # starknet-api version. This should be removed once we have a mono-repo. -blockifier = { git = "https://github.com/starkware-libs/blockifier.git", branch = "main-mempool" } +blockifier ="0.8.0-dev.0" bincode = "1.3.3" -cairo-lang-sierra = "2.6.0" -cairo-lang-starknet-classes = "2.6.0" -cairo-lang-utils = "2.6.0" -cairo-vm = "0.9.2" +cairo-lang-sierra = "2.7.0-dev.0" +cairo-lang-starknet-classes = "2.7.0-dev.0" +cairo-lang-utils = "2.7.0-dev.0" +cairo-vm = "1.0.0-rc3" clap = "4.3.10" colored = "2.1.0" const_format = "0.2.30" @@ -50,23 +50,26 @@ futures = "0.3.30" hyper = { version = "0.14", features = ["client", "server", "http1", "http2", "tcp"] } indexmap = "2.1.0" itertools = "0.13.0" +lazy_static = "1.4.0" +num-traits = "0.2" num-bigint = { version = "0.4.5", default-features = false } # TODO(YaelD, 28/5/2024): The special Papyrus version is needed in order to be aligned with the # starknet-api version. This should be removed once we have a mono-repo. -papyrus_common = { git = "https://github.com/starkware-libs/papyrus.git", rev = "56c6fdc2" } -papyrus_config = { git = "https://github.com/starkware-libs/papyrus.git", rev = "56c6fdc2" } -papyrus_rpc = { git = "https://github.com/starkware-libs/papyrus.git", rev = "56c6fdc2" } -papyrus_storage = { git = "https://github.com/starkware-libs/papyrus.git", rev = "56c6fdc2" } +papyrus_common = { git = "https://github.com/starkware-libs/papyrus.git", rev = "22de602" } +papyrus_config = { git = "https://github.com/starkware-libs/papyrus.git", rev = "22de602" } +papyrus_rpc = { git = "https://github.com/starkware-libs/papyrus.git", rev = "22de602" } +papyrus_storage = { git = "https://github.com/starkware-libs/papyrus.git", rev = "22de602" } pretty_assertions = "1.4.0" reqwest = { version = "0.11", features = ["blocking", "json"] } rstest = "0.17.0" serde = { version = "1.0.193", features = ["derive"] } serde_json = "1.0" # TODO(Arni, 1/5/2024): Use a fixed version once the StarkNet API is stable. -starknet_api = { git = "https://github.com/starkware-libs/starknet-api.git", branch = "main-mempool" } +starknet_api = "0.13.0-dev.9" # TODO(YaelD, 28/5/2024): The special Papyrus version is needed in order to be aligned with the # starknet-api version. This should be removed once we have a mono-repo. -starknet_client = { git = "https://github.com/starkware-libs/papyrus.git", rev = "56c6fdc2" } +starknet_client = { git = "https://github.com/starkware-libs/papyrus.git", rev = "22de602" } +starknet-types-core = { version = "0.1.5", features = ["std", "hash", "prime-bigint"] } strum = "0.24.1" tempfile = "3.3.0" thiserror = "1.0" diff --git a/crates/gateway/Cargo.toml b/crates/gateway/Cargo.toml index 1cb064ca..6db13e5a 100644 --- a/crates/gateway/Cargo.toml +++ b/crates/gateway/Cargo.toml @@ -18,6 +18,7 @@ blockifier= { workspace = true , features = ["testing"] } cairo-lang-starknet-classes.workspace = true cairo-vm.workspace = true hyper.workspace = true +num-traits.workspace = true papyrus_config.workspace = true papyrus_rpc.workspace = true reqwest.workspace = true @@ -27,6 +28,7 @@ starknet_api.workspace = true starknet_mempool_infra = { path = "../mempool_infra", version = "0.0" } starknet_mempool_types = { path = "../mempool_types", version = "0.0" } starknet_sierra_compile = { path = "../starknet_sierra_compile", version = "0.0" } +starknet-types-core.workspace = true test_utils = { path = "../test_utils", version = "0.0"} thiserror.workspace = true tokio.workspace = true @@ -34,6 +36,7 @@ validator.workspace = true [dev-dependencies] assert_matches.workspace = true +num-bigint.workspace = true pretty_assertions.workspace = true rstest.workspace = true starknet_mempool = { path = "../mempool", version = "0.0" } diff --git a/crates/gateway/src/compilation.rs b/crates/gateway/src/compilation.rs index d52bbd91..5381ce44 100644 --- a/crates/gateway/src/compilation.rs +++ b/crates/gateway/src/compilation.rs @@ -2,7 +2,6 @@ use std::panic; use std::sync::OnceLock; use blockifier::execution::contract_class::{ClassInfo, ContractClass, ContractClassV1}; -use blockifier::execution::execution_utils::felt_to_stark_felt; use cairo_lang_starknet_classes::casm_contract_class::{ CasmContractClass, CasmContractEntryPoints, }; @@ -40,8 +39,7 @@ pub fn compile_contract_class(declare_tx: &RPCDeclareTransaction) -> GatewayResu }; validate_casm_class(&casm_contract_class)?; - let hash_result = - CompiledClassHash(felt_to_stark_felt(&casm_contract_class.compiled_class_hash())); + let hash_result = CompiledClassHash(casm_contract_class.compiled_class_hash()); if hash_result != tx.compiled_class_hash { return Err(GatewayError::CompiledClassHashMismatch { supplied: tx.compiled_class_hash, diff --git a/crates/gateway/src/compiler_version.rs b/crates/gateway/src/compiler_version.rs index 6317c991..0aaf177f 100644 --- a/crates/gateway/src/compiler_version.rs +++ b/crates/gateway/src/compiler_version.rs @@ -1,10 +1,11 @@ use std::collections::BTreeMap; use cairo_lang_starknet_classes::compiler_version::VersionId as CairoLangVersionId; +use num_traits::ToPrimitive; use papyrus_config::dumping::{ser_param, SerializeConfig}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; -use starknet_api::hash::StarkFelt; +use starknet_types_core::felt::Felt; use thiserror::Error; use validator::Validate; @@ -41,7 +42,7 @@ impl std::fmt::Display for VersionId { } impl VersionId { - pub fn from_sierra_program(sierra_program: &[StarkFelt]) -> Result { + pub fn from_sierra_program(sierra_program: &[Felt]) -> Result { let sierra_program_length = sierra_program.len(); if sierra_program_length < 3 { @@ -55,12 +56,12 @@ impl VersionId { } fn get_version_component( - sierra_program: &[StarkFelt], + sierra_program: &[Felt], index: usize, ) -> Result { - let felt = sierra_program[index]; - felt.try_into().map_err(|_| VersionIdError::InvalidVersion { - message: format!("version contains a value that is out of range: {}", felt), + let felt = &sierra_program[index]; + felt.to_usize().ok_or(VersionIdError::InvalidVersion { + message: format!("version contains a value that is out of range: {:?}", felt), }) } diff --git a/crates/gateway/src/rpc_state_reader.rs b/crates/gateway/src/rpc_state_reader.rs index 53ee2caa..a5af4fe6 100644 --- a/crates/gateway/src/rpc_state_reader.rs +++ b/crates/gateway/src/rpc_state_reader.rs @@ -8,8 +8,8 @@ use serde::Serialize; use serde_json::{json, Value}; use starknet_api::block::BlockNumber; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; -use starknet_api::hash::StarkFelt; 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}; @@ -94,12 +94,12 @@ impl BlockifierStateReader for RpcStateReader { &self, contract_address: ContractAddress, key: StorageKey, - ) -> StateResult { + ) -> StateResult { let get_storage_at_params = GetStorageAtParams { block_id: self.block_id, contract_address, key }; let result = self.send_rpc_request("starknet_getStorageAt", get_storage_at_params)?; - let value: StarkFelt = serde_json::from_value(result).map_err(serde_err_to_state_err)?; + let value: Felt = serde_json::from_value(result).map_err(serde_err_to_state_err)?; Ok(value) } diff --git a/crates/gateway/src/state_reader.rs b/crates/gateway/src/state_reader.rs index 1833bc29..66d5f1de 100644 --- a/crates/gateway/src/state_reader.rs +++ b/crates/gateway/src/state_reader.rs @@ -4,8 +4,8 @@ use blockifier::state::errors::StateError; use blockifier::state::state_api::{StateReader as BlockifierStateReader, StateResult}; use starknet_api::block::BlockNumber; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; -use starknet_api::hash::StarkFelt; use starknet_api::state::StorageKey; +use starknet_types_core::felt::Felt; pub trait MempoolStateReader: BlockifierStateReader + Send + Sync { fn get_block_info(&self) -> Result; @@ -30,7 +30,7 @@ impl BlockifierStateReader for Box { &self, contract_address: ContractAddress, key: StorageKey, - ) -> StateResult { + ) -> StateResult { self.as_ref().get_storage_at(contract_address, key) } diff --git a/crates/gateway/src/state_reader_test_utils.rs b/crates/gateway/src/state_reader_test_utils.rs index 5f3adb27..b298c697 100644 --- a/crates/gateway/src/state_reader_test_utils.rs +++ b/crates/gateway/src/state_reader_test_utils.rs @@ -5,14 +5,14 @@ use blockifier::state::errors::StateError; use blockifier::state::state_api::{StateReader as BlockifierStateReader, StateResult}; use blockifier::test_utils::contracts::FeatureContract; use blockifier::test_utils::dict_state_reader::DictStateReader; -use blockifier::test_utils::initial_test_state::{fund_account, test_state_reader}; +use blockifier::test_utils::initial_test_state::{fund_account, test_state}; use blockifier::test_utils::{CairoVersion, BALANCE}; use blockifier::versioned_constants::VersionedConstants; use starknet_api::block::BlockNumber; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; -use starknet_api::hash::StarkFelt; use starknet_api::rpc_transaction::RPCTransaction; use starknet_api::state::StorageKey; +use starknet_types_core::felt::Felt; use test_utils::starknet_api_test_utils::deployed_account_contract_address; use crate::state_reader::{MempoolStateReader, StateReaderFactory}; @@ -34,7 +34,7 @@ impl BlockifierStateReader for TestStateReader { &self, contract_address: ContractAddress, key: StorageKey, - ) -> StateResult { + ) -> StateResult { self.blockifier_state_reader.get_storage_at(contract_address, key) } @@ -82,7 +82,7 @@ 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_reader( + let state_reader = test_state( block_context.chain_info(), account_balance, &[(account_contract, 1), (test_contract, 1)], @@ -91,7 +91,7 @@ pub fn local_test_state_reader_factory( TestStateReaderFactory { state_reader: TestStateReader { block_info: block_context.block_info().clone(), - blockifier_state_reader: state_reader, + blockifier_state_reader: state_reader.state, }, } } diff --git a/crates/gateway/src/stateful_transaction_validator_test.rs b/crates/gateway/src/stateful_transaction_validator_test.rs index 746d203e..6349f8a1 100644 --- a/crates/gateway/src/stateful_transaction_validator_test.rs +++ b/crates/gateway/src/stateful_transaction_validator_test.rs @@ -3,9 +3,10 @@ use blockifier::context::BlockContext; use blockifier::test_utils::CairoVersion; use blockifier::transaction::errors::{TransactionFeeError, TransactionPreValidationError}; use rstest::rstest; -use starknet_api::hash::StarkFelt; +use starknet_api::felt; use starknet_api::rpc_transaction::RPCTransaction; use starknet_api::transaction::TransactionHash; +use starknet_types_core::felt::Felt; use test_utils::starknet_api_test_utils::{ declare_tx, deploy_account_tx, invoke_tx, VALID_L1_GAS_MAX_AMOUNT, VALID_L1_GAS_MAX_PRICE_PER_UNIT, @@ -24,30 +25,30 @@ use crate::stateful_transaction_validator::StatefulTransactionValidator; #[case::valid_invoke_tx_cairo1( invoke_tx(CairoVersion::Cairo1), local_test_state_reader_factory(CairoVersion::Cairo1, false), - Ok(TransactionHash(StarkFelt::try_from( + Ok(TransactionHash(felt!( "0x007d70505b4487a4e1c1a4b4e4342cb5aa9e73b86d031891170c45a57ad8b4e6" - ).unwrap())) + ))) )] #[case::valid_invoke_tx_cairo0( invoke_tx(CairoVersion::Cairo0), local_test_state_reader_factory(CairoVersion::Cairo0, false), - Ok(TransactionHash(StarkFelt::try_from( + Ok(TransactionHash(felt!( "0x032e3a969a64027f15ce2b526d8dff47d47524c58ff0363f93ce4cbe7c280861" - ).unwrap())) + ))) )] #[case::valid_deploy_account_tx( deploy_account_tx(), local_test_state_reader_factory_for_deploy_account(&external_tx), - Ok(TransactionHash(StarkFelt::try_from( + Ok(TransactionHash(felt!( "0x013287740b37dc112391de4ef0f7cd7aeca323537ca2a78a1108c6aee5a55d70" - ).unwrap())) + ))) )] #[case::valid_declare_tx( declare_tx(), local_test_state_reader_factory(CairoVersion::Cairo1, false), - Ok(TransactionHash(StarkFelt::try_from( + Ok(TransactionHash(felt!( "0x02da54b89e00d2e201f8e3ed2bcc715a69e89aefdce88aff2d2facb8dec55c0a" - ).unwrap())) + ))) )] #[case::invalid_tx( invoke_tx(CairoVersion::Cairo1), @@ -58,8 +59,8 @@ use crate::stateful_transaction_validator::StatefulTransactionValidator; TransactionFeeError::L1GasBoundsExceedBalance { max_amount: VALID_L1_GAS_MAX_AMOUNT, max_price: VALID_L1_GAS_MAX_PRICE_PER_UNIT, - balance_low: StarkFelt::ZERO, - balance_high: StarkFelt::ZERO, + balance_low: Felt::ZERO, + balance_high: Felt::ZERO, } ) ) diff --git a/crates/gateway/src/stateless_transaction_validator.rs b/crates/gateway/src/stateless_transaction_validator.rs index 97a47dd4..c66282c0 100644 --- a/crates/gateway/src/stateless_transaction_validator.rs +++ b/crates/gateway/src/stateless_transaction_validator.rs @@ -1,9 +1,9 @@ -use starknet_api::hash::StarkFelt; use starknet_api::rpc_transaction::{ RPCDeclareTransaction, RPCDeployAccountTransaction, RPCInvokeTransaction, RPCTransaction, ResourceBoundsMapping, }; use starknet_api::transaction::Resource; +use starknet_types_core::felt::Felt; use crate::compiler_version::VersionId; use crate::config::StatelessTransactionValidatorConfig; @@ -111,7 +111,7 @@ impl StatelessTransactionValidator { fn validate_sierra_version( &self, - sierra_program: &[StarkFelt], + sierra_program: &[Felt], ) -> StatelessTransactionValidatorResult<()> { // Any patch version is valid. (i.e. when check version for upper bound, we ignore the Z // part in a version X.Y.Z). diff --git a/crates/gateway/src/stateless_transaction_validator_test.rs b/crates/gateway/src/stateless_transaction_validator_test.rs index acab44cd..f5dbc722 100644 --- a/crates/gateway/src/stateless_transaction_validator_test.rs +++ b/crates/gateway/src/stateless_transaction_validator_test.rs @@ -1,9 +1,9 @@ use assert_matches::assert_matches; use rstest::rstest; -use starknet_api::hash::StarkFelt; use starknet_api::rpc_transaction::{ContractClass, ResourceBoundsMapping}; use starknet_api::transaction::{Calldata, Resource, ResourceBounds, TransactionSignature}; -use starknet_api::{calldata, stark_felt}; +use starknet_api::{calldata, felt}; +use starknet_types_core::felt::Felt; use test_utils::declare_tx_args; use test_utils::starknet_api_test_utils::{ create_resource_bounds_mapping, external_declare_tx, external_tx_for_testing, @@ -76,14 +76,14 @@ const DEFAULT_VALIDATOR_CONFIG_FOR_TESTING: StatelessTransactionValidatorConfig #[case::non_empty_valid_calldata( DEFAULT_VALIDATOR_CONFIG_FOR_TESTING, zero_resource_bounds_mapping(), - calldata![StarkFelt::from_u128(1)], + calldata![Felt::ONE], TransactionSignature::default() )] #[case::non_empty_valid_signature( DEFAULT_VALIDATOR_CONFIG_FOR_TESTING, zero_resource_bounds_mapping(), calldata![], - TransactionSignature(vec![StarkFelt::from_u128(1)]) + TransactionSignature(vec![Felt::ONE]) )] #[case::valid_tx( DEFAULT_VALIDATOR_CONFIG_FOR_TESTING, @@ -155,7 +155,7 @@ fn test_calldata_too_long( let tx = external_tx_for_testing( tx_type, zero_resource_bounds_mapping(), - calldata![StarkFelt::from_u128(1), StarkFelt::from_u128(2)], + calldata![Felt::ONE, Felt::TWO], TransactionSignature::default(), ); @@ -179,7 +179,7 @@ fn test_signature_too_long( tx_type, zero_resource_bounds_mapping(), calldata![], - TransactionSignature(vec![StarkFelt::from_u128(1), StarkFelt::from_u128(2)]), + TransactionSignature(vec![Felt::ONE, Felt::TWO]), ); assert_eq!( @@ -202,7 +202,7 @@ fn test_signature_too_long( ) )] #[case::sierra_program_length_one( - vec![stark_felt!(1_u128)], + vec![felt!(1_u128)], StatelessTransactionValidatorError::InvalidSierraVersion ( VersionIdError::InvalidVersion { message: "Sierra program is too short. got program of length 1 which is not long enough \ @@ -211,7 +211,7 @@ fn test_signature_too_long( ) )] #[case::sierra_program_length_two( - vec![stark_felt!(1_u128), stark_felt!(3_u128)], + vec![felt!(1_u128), felt!(3_u128)], StatelessTransactionValidatorError::InvalidSierraVersion ( VersionIdError::InvalidVersion { message: "Sierra program is too short. got program of length 2 which is not long enough \ @@ -221,14 +221,14 @@ fn test_signature_too_long( )] #[case::invalid_character_in_sierra_version( vec![ - stark_felt!(1_u128), - stark_felt!(3_u128), - stark_felt!(0x10000000000000000_u128), // Does not fit into a usize. + felt!(1_u128), + felt!(3_u128), + felt!(0x10000000000000000_u128), // Does not fit into a usize. ], StatelessTransactionValidatorError::InvalidSierraVersion ( VersionIdError::InvalidVersion { message: "version contains a value that is out of range: \ - 0x0000000000000000000000000000000000000000000000010000000000000000".into() + 0x10000000000000000".into() } ) ) @@ -250,7 +250,7 @@ fn test_signature_too_long( }) ] fn test_declare_sierra_version_failure( - #[case] sierra_program: Vec, + #[case] sierra_program: Vec, #[case] expected_error: StatelessTransactionValidatorError, ) { let tx_validator = @@ -268,7 +268,7 @@ fn test_declare_sierra_version_failure( #[case::max_sierra_version_patch_zero(create_sierra_program(&VersionId { patch: 0, ..MAX_SIERRA_VERSION }))] #[case::max_sierra_version_patch_non_trivial(create_sierra_program(&VersionId { patch: 1, ..MAX_SIERRA_VERSION }))] #[case::max_sierra_version(create_sierra_program(&MAX_SIERRA_VERSION))] -fn test_declare_sierra_version_sucsses(#[case] sierra_program: Vec) { +fn test_declare_sierra_version_sucsses(#[case] sierra_program: Vec) { let tx_validator = StatelessTransactionValidator { config: DEFAULT_VALIDATOR_CONFIG_FOR_TESTING }; @@ -288,7 +288,7 @@ fn test_declare_bytecode_size_too_long() { }, }; let sierra_program_length = config_max_bytecode_size + 1; - let sierra_program = vec![stark_felt!(1_u128); sierra_program_length]; + let sierra_program = vec![felt!(1_u128); sierra_program_length]; let contract_class = ContractClass { sierra_program, ..Default::default() }; let tx = external_declare_tx(declare_tx_args!(contract_class)); @@ -313,7 +313,7 @@ fn test_declare_contract_class_size_too_long() { }, }; let contract_class = - ContractClass { sierra_program: vec![stark_felt!(1_u128); 3], ..Default::default() }; + ContractClass { sierra_program: vec![felt!(1_u128); 3], ..Default::default() }; let contract_class_length = serde_json::to_string(&contract_class).unwrap().len(); let tx = external_declare_tx(declare_tx_args!(contract_class)); diff --git a/crates/gateway/src/test_utils.rs b/crates/gateway/src/test_utils.rs index 0db95811..b9db3165 100644 --- a/crates/gateway/src/test_utils.rs +++ b/crates/gateway/src/test_utils.rs @@ -1,11 +1,11 @@ -use starknet_api::hash::StarkFelt; +use starknet_types_core::felt::Felt; use crate::compiler_version::VersionId; -pub fn create_sierra_program(version_id: &VersionId) -> Vec { +pub fn create_sierra_program(version_id: &VersionId) -> Vec { vec![ - StarkFelt::from(u64::try_from(version_id.major).unwrap()), - StarkFelt::from(u64::try_from(version_id.minor).unwrap()), - StarkFelt::from(u64::try_from(version_id.patch).unwrap()), + Felt::from(u64::try_from(version_id.major).unwrap()), + Felt::from(u64::try_from(version_id.minor).unwrap()), + Felt::from(u64::try_from(version_id.patch).unwrap()), ] } diff --git a/crates/mempool/Cargo.toml b/crates/mempool/Cargo.toml index 6d175dc9..3c79703c 100644 --- a/crates/mempool/Cargo.toml +++ b/crates/mempool/Cargo.toml @@ -21,5 +21,6 @@ assert_matches.workspace = true itertools.workspace = true pretty_assertions.workspace = true rstest.workspace = true +starknet-types-core.workspace = true starknet_api = { workspace = true, features = ["testing"] } tokio.workspace = true diff --git a/crates/mempool/src/mempool_test.rs b/crates/mempool/src/mempool_test.rs index f4ac0f65..6becf8d3 100644 --- a/crates/mempool/src/mempool_test.rs +++ b/crates/mempool/src/mempool_test.rs @@ -3,19 +3,20 @@ use itertools::zip_eq; use pretty_assertions::assert_eq; use rstest::{fixture, rstest}; use starknet_api::core::{ContractAddress, Nonce, PatriciaKey}; -use starknet_api::hash::{StarkFelt, StarkHash}; +use starknet_api::hash::StarkHash; use starknet_api::transaction::{Tip, TransactionHash}; -use starknet_api::{contract_address, patricia_key}; +use starknet_api::{contract_address, felt, patricia_key}; use starknet_mempool_types::errors::MempoolError; use starknet_mempool_types::mempool_types::{Account, ThinTransaction}; +use starknet_types_core::felt::Felt; use crate::mempool::{Mempool, MempoolInput, TransactionReference}; /// Creates a valid input for mempool's `add_tx` with optional default values. /// Usage: -/// 1. add_tx_input!(tip: 1, tx_hash: StarkFelt::TWO, address: "0x3", nonce: 4) -/// 2. add_tx_input!(tip: 1, tx_hash: StarkFelt::TWO, address: "0x3") -/// 3. add_tx_input!(tip:1 , tx_hash: StarkFelt::TWO) +/// 1. add_tx_input!(tip: 1, tx_hash: Felt::TWO, sender_address: 3_u8, nonce: 4) +/// 2. add_tx_input!(tip: 1, tx_hash: Felt::TWO, sender_address: 3_u8) +/// 3. add_tx_input!(tip:1 , tx_hash: Felt::TWO) macro_rules! add_tx_input { // Pattern for all four arguments with keyword arguments. (tip: $tip:expr, tx_hash: $tx_hash:expr, sender_address: $sender_address:expr, nonce: $nonce:expr) => {{ @@ -23,7 +24,7 @@ macro_rules! add_tx_input { let account = Account { sender_address, ..Default::default() }; let tx = ThinTransaction { tip: Tip($tip), - tx_hash: TransactionHash($tx_hash), + tx_hash: TransactionHash(StarkHash::from($tx_hash)), sender_address, nonce: Nonce($nonce), }; @@ -31,11 +32,11 @@ macro_rules! add_tx_input { }}; // Pattern for three arguments. (tip: $tip:expr, tx_hash: $tx_hash:expr, sender_address: $sender_address:expr) => { - add_tx_input!(tip: $tip, tx_hash: $tx_hash, sender_address: $sender_address, nonce: StarkFelt::ZERO) + add_tx_input!(tip: $tip, tx_hash: $tx_hash, sender_address: $sender_address, nonce: Felt::ZERO) }; // Pattern for two arguments. (tip: $tip:expr, tx_hash: $tx_hash:expr) => { - add_tx_input!(tip: $tip, tx_hash: $tx_hash, sender_address: ContractAddress::default(), nonce: StarkFelt::ZERO) + add_tx_input!(tip: $tip, tx_hash: $tx_hash, sender_address: "0x0", nonce: Felt::ZERO) }; } @@ -63,11 +64,9 @@ fn check_mempool_txs_eq(mempool: &Mempool, expected_txs: &[ThinTransaction]) { #[case(5)] // Requesting more transactions than are in the queue #[case(2)] // Requesting fewer transactions than are in the queue fn test_get_txs(#[case] requested_txs: usize) { - let input_tip_50_address_0 = add_tx_input!(tip: 50, tx_hash: StarkFelt::ONE); - let input_tip_100_address_1 = - add_tx_input!(tip: 100, tx_hash: StarkFelt::TWO, sender_address: "0x1"); - let input_tip_10_address_2 = - add_tx_input!(tip: 10, tx_hash: StarkFelt::THREE, sender_address: "0x2"); + let input_tip_50_address_0 = add_tx_input!(tip: 50, tx_hash: 1); + let input_tip_100_address_1 = add_tx_input!(tip: 100, tx_hash: 2, sender_address: "0x1"); + let input_tip_10_address_2 = add_tx_input!(tip: 10, tx_hash: 3, sender_address: "0x2"); let mut mempool = Mempool::new([ input_tip_50_address_0.clone(), @@ -94,11 +93,9 @@ fn test_get_txs(#[case] requested_txs: usize) { #[rstest] fn test_add_tx(mut mempool: Mempool) { - let input_tip_50_address_0 = add_tx_input!(tip: 50, tx_hash: StarkFelt::ONE); - let input_tip_100_address_1 = - add_tx_input!(tip: 100, tx_hash: StarkFelt::TWO, sender_address: "0x1"); - let input_tip_80_address_2 = - add_tx_input!(tip: 80, tx_hash: StarkFelt::THREE, sender_address: "0x2"); + let input_tip_50_address_0 = add_tx_input!(tip: 50, tx_hash: 1); + let input_tip_100_address_1 = add_tx_input!(tip: 100, tx_hash: 2, sender_address: "0x1"); + let input_tip_80_address_2 = add_tx_input!(tip: 80, tx_hash: 3, sender_address: "0x3"); assert_eq!(mempool.add_tx(input_tip_50_address_0.clone()), Ok(())); assert_eq!(mempool.add_tx(input_tip_100_address_1.clone()), Ok(())); @@ -111,18 +108,18 @@ fn test_add_tx(mut mempool: Mempool) { #[test] fn test_new_with_duplicate_tx() { - let input = add_tx_input!(tip: 0, tx_hash: StarkFelt::ONE); + let input = add_tx_input!(tip: 0, tx_hash: 1); let same_input = input.clone(); assert!(matches!( Mempool::new([input, same_input]), - Err(MempoolError::DuplicateTransaction { tx_hash: TransactionHash(StarkFelt::ONE) }) + Err(MempoolError::DuplicateTransaction { .. }) )); } #[rstest] fn test_add_tx_with_duplicate_tx(mut mempool: Mempool) { - let input = add_tx_input!(tip: 50, tx_hash: StarkFelt::ONE); + let input = add_tx_input!(tip: 50, tx_hash: Felt::ONE); let same_input = input.clone(); assert_eq!(mempool.add_tx(input), Ok(())); @@ -137,11 +134,11 @@ fn test_add_tx_with_duplicate_tx(mut mempool: Mempool) { #[rstest] fn test_add_tx_with_identical_tip_succeeds(mut mempool: Mempool) { - let input1 = add_tx_input!(tip: 1, tx_hash: StarkFelt::TWO); + let input1 = add_tx_input!(tip: 1, tx_hash: 2); // Create a transaction with identical tip, it should be allowed through since the priority // queue tie-breaks identical tips by other tx-unique identifiers (for example tx hash). - let input2 = add_tx_input!(tip: 1, tx_hash: StarkFelt::ONE, sender_address: "0x1"); + let input2 = add_tx_input!(tip: 1, tx_hash: 1, sender_address: "0x1"); assert_eq!(mempool.add_tx(input1.clone()), Ok(())); assert_eq!(mempool.add_tx(input2.clone()), Ok(())); @@ -153,12 +150,11 @@ fn test_add_tx_with_identical_tip_succeeds(mut mempool: Mempool) { #[rstest] fn test_tip_priority_over_tx_hash(mut mempool: Mempool) { - let input_big_tip_small_hash = add_tx_input!(tip: 2, tx_hash: StarkFelt::ONE); + let input_big_tip_small_hash = add_tx_input!(tip: 2, tx_hash: Felt::ONE); // Create a transaction with identical tip, it should be allowed through since the priority // queue tie-breaks identical tips by other tx-unique identifiers (for example tx hash). - let input_small_tip_big_hash = - add_tx_input!(tip: 1, tx_hash: StarkFelt::TWO, sender_address: "0x1"); + let input_small_tip_big_hash = add_tx_input!(tip: 1, tx_hash: Felt::TWO, sender_address: "0x1"); assert_eq!(mempool.add_tx(input_big_tip_small_hash.clone()), Ok(())); assert_eq!(mempool.add_tx(input_small_tip_big_hash.clone()), Ok(())); diff --git a/crates/starknet_sierra_compile/Cargo.toml b/crates/starknet_sierra_compile/Cargo.toml index e5d9e244..2a0f8cf0 100644 --- a/crates/starknet_sierra_compile/Cargo.toml +++ b/crates/starknet_sierra_compile/Cargo.toml @@ -12,10 +12,10 @@ workspace = true cairo-lang-sierra.workspace = true cairo-lang-starknet-classes.workspace = true cairo-lang-utils.workspace = true -num-bigint.workspace = true serde_json.workspace = true serde.workspace = true starknet_api.workspace = true +starknet-types-core.workspace = true thiserror.workspace = true [dev-dependencies] diff --git a/crates/starknet_sierra_compile/src/utils.rs b/crates/starknet_sierra_compile/src/utils.rs index ec995ef3..717eaf17 100644 --- a/crates/starknet_sierra_compile/src/utils.rs +++ b/crates/starknet_sierra_compile/src/utils.rs @@ -5,23 +5,19 @@ use cairo_lang_starknet_classes::contract_class::{ ContractEntryPoints as CairoLangContractEntryPoints, }; use cairo_lang_utils::bigint::BigUintAsHex; -use num_bigint::BigUint; -use starknet_api::hash::StarkFelt; use starknet_api::rpc_transaction::{ ContractClass as StarknetApiContractClass, EntryPointByType as StarknetApiEntryPointByType, }; use starknet_api::state::EntryPoint as StarknetApiEntryPoint; +use starknet_types_core::felt::Felt; /// Retruns a [`CairoLangContractClass`] struct ready for Sierra to Casm compilation. Note the `abi` /// field is None as it is not relevant for the compilation. pub fn into_contract_class_for_compilation( starknet_api_contract_class: &StarknetApiContractClass, ) -> CairoLangContractClass { - let sierra_program = starknet_api_contract_class - .sierra_program - .iter() - .map(stark_felt_to_big_uint_as_hex) - .collect(); + let sierra_program = + starknet_api_contract_class.sierra_program.iter().map(felt_to_big_uint_as_hex).collect(); let entry_points_by_type = into_cairo_lang_contract_entry_points(&starknet_api_contract_class.entry_points_by_type); @@ -55,15 +51,11 @@ fn into_cairo_lang_contract_entry_point( entry_point: &StarknetApiEntryPoint, ) -> CairoLangContractEntryPoint { CairoLangContractEntryPoint { - selector: stark_felt_to_big_uint(&entry_point.selector.0), + selector: entry_point.selector.0.to_biguint(), function_idx: entry_point.function_idx.0, } } -fn stark_felt_to_big_uint_as_hex(stark_felt: &StarkFelt) -> BigUintAsHex { - BigUintAsHex { value: stark_felt_to_big_uint(stark_felt) } -} - -fn stark_felt_to_big_uint(stark_felt: &StarkFelt) -> BigUint { - BigUint::from_bytes_be(stark_felt.bytes()) +fn felt_to_big_uint_as_hex(felt: &Felt) -> BigUintAsHex { + BigUintAsHex { value: felt.to_biguint() } } diff --git a/crates/test_utils/Cargo.toml b/crates/test_utils/Cargo.toml index 91539c14..8e4f2113 100644 --- a/crates/test_utils/Cargo.toml +++ b/crates/test_utils/Cargo.toml @@ -10,6 +10,7 @@ license.workspace = true [dependencies] assert_matches.workspace = true blockifier.workspace = true +starknet-types-core.workspace = true starknet_api.workspace = true serde_json.workspace = true diff --git a/crates/test_utils/src/starknet_api_test_utils.rs b/crates/test_utils/src/starknet_api_test_utils.rs index d458a868..956c31fb 100644 --- a/crates/test_utils/src/starknet_api_test_utils.rs +++ b/crates/test_utils/src/starknet_api_test_utils.rs @@ -10,7 +10,6 @@ use starknet_api::core::{ calculate_contract_address, ClassHash, CompiledClassHash, ContractAddress, Nonce, }; use starknet_api::data_availability::DataAvailabilityMode; -use starknet_api::hash::StarkFelt; use starknet_api::rpc_transaction::{ ContractClass, RPCDeclareTransactionV3, RPCDeployAccountTransaction, RPCDeployAccountTransactionV3, RPCInvokeTransactionV3, RPCTransaction, ResourceBoundsMapping, @@ -19,7 +18,8 @@ use starknet_api::transaction::{ AccountDeploymentData, Calldata, ContractAddressSalt, PaymasterData, ResourceBounds, Tip, TransactionSignature, TransactionVersion, }; -use starknet_api::{calldata, stark_felt}; +use starknet_api::{calldata, felt}; +use starknet_types_core::felt::Felt; use crate::{ declare_tx_args, deploy_account_tx_args, get_absolute_path, invoke_tx_args, @@ -46,7 +46,7 @@ pub fn external_tx_for_testing( TransactionType::Declare => { // Minimal contract class. let contract_class = ContractClass { - sierra_program: vec![stark_felt!(1_u32), stark_felt!(3_u32), stark_felt!(0_u32)], + sierra_program: vec![felt!(1_u32), felt!(3_u32), felt!(0_u32)], ..Default::default() }; external_declare_tx(declare_tx_args!(resource_bounds, signature, contract_class)) @@ -90,7 +90,7 @@ pub fn declare_tx() -> RPCTransaction { env::set_current_dir(get_absolute_path(TEST_FILES_FOLDER)).expect("Couldn't set working dir."); let json_file_path = Path::new(CONTRACT_CLASS_FILE); let contract_class = serde_json::from_reader(File::open(json_file_path).unwrap()).unwrap(); - let compiled_class_hash = CompiledClassHash(stark_felt!(COMPILED_CLASS_HASH_OF_CONTRACT_CLASS)); + let compiled_class_hash = CompiledClassHash(felt!(COMPILED_CLASS_HASH_OF_CONTRACT_CLASS)); let account_contract = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); let account_address = account_contract.get_instance_address(0); @@ -98,7 +98,7 @@ pub fn declare_tx() -> RPCTransaction { let nonce = nonce_manager.next(account_address); external_declare_tx(declare_tx_args!( - signature: TransactionSignature(vec![StarkFelt::ZERO]), + signature: TransactionSignature(vec![Felt::ZERO]), sender_address: account_address, resource_bounds: executable_resource_bounds_mapping(), nonce, @@ -261,66 +261,69 @@ impl Default for DeclareTxArgs { } pub fn external_invoke_tx(invoke_args: InvokeTxArgs) -> RPCTransaction { - match invoke_args.version { - TransactionVersion::THREE => starknet_api::rpc_transaction::RPCTransaction::Invoke( - starknet_api::rpc_transaction::RPCInvokeTransaction::V3(RPCInvokeTransactionV3 { - resource_bounds: invoke_args.resource_bounds, - tip: invoke_args.tip, - calldata: invoke_args.calldata, - sender_address: invoke_args.sender_address, - nonce: invoke_args.nonce, - signature: invoke_args.signature, - nonce_data_availability_mode: invoke_args.nonce_data_availability_mode, - fee_data_availability_mode: invoke_args.fee_data_availability_mode, - paymaster_data: invoke_args.paymaster_data, - account_deployment_data: invoke_args.account_deployment_data, - }), - ), - _ => panic!("Unsupported transaction version: {:?}.", invoke_args.version), + if invoke_args.version != TransactionVersion::THREE { + panic!("Unsupported transaction version: {:?}.", invoke_args.version); } + + starknet_api::rpc_transaction::RPCTransaction::Invoke( + starknet_api::rpc_transaction::RPCInvokeTransaction::V3(RPCInvokeTransactionV3 { + resource_bounds: invoke_args.resource_bounds, + tip: invoke_args.tip, + calldata: invoke_args.calldata, + sender_address: invoke_args.sender_address, + nonce: invoke_args.nonce, + signature: invoke_args.signature, + nonce_data_availability_mode: invoke_args.nonce_data_availability_mode, + fee_data_availability_mode: invoke_args.fee_data_availability_mode, + paymaster_data: invoke_args.paymaster_data, + account_deployment_data: invoke_args.account_deployment_data, + }), + ) } pub fn external_deploy_account_tx(deploy_tx_args: DeployAccountTxArgs) -> RPCTransaction { - match deploy_tx_args.version { - TransactionVersion::THREE => starknet_api::rpc_transaction::RPCTransaction::DeployAccount( - starknet_api::rpc_transaction::RPCDeployAccountTransaction::V3( - RPCDeployAccountTransactionV3 { - resource_bounds: deploy_tx_args.resource_bounds, - tip: deploy_tx_args.tip, - contract_address_salt: deploy_tx_args.contract_address_salt, - class_hash: deploy_tx_args.class_hash, - constructor_calldata: deploy_tx_args.constructor_calldata, - nonce: deploy_tx_args.nonce, - signature: deploy_tx_args.signature, - nonce_data_availability_mode: deploy_tx_args.nonce_data_availability_mode, - fee_data_availability_mode: deploy_tx_args.fee_data_availability_mode, - paymaster_data: deploy_tx_args.paymaster_data, - }, - ), - ), - _ => panic!("Unsupported transaction version: {:?}.", deploy_tx_args.version), + if deploy_tx_args.version != TransactionVersion::THREE { + panic!("Unsupported transaction version: {:?}.", deploy_tx_args.version); } + + starknet_api::rpc_transaction::RPCTransaction::DeployAccount( + starknet_api::rpc_transaction::RPCDeployAccountTransaction::V3( + RPCDeployAccountTransactionV3 { + resource_bounds: deploy_tx_args.resource_bounds, + tip: deploy_tx_args.tip, + contract_address_salt: deploy_tx_args.contract_address_salt, + class_hash: deploy_tx_args.class_hash, + constructor_calldata: deploy_tx_args.constructor_calldata, + nonce: deploy_tx_args.nonce, + signature: deploy_tx_args.signature, + nonce_data_availability_mode: deploy_tx_args.nonce_data_availability_mode, + fee_data_availability_mode: deploy_tx_args.fee_data_availability_mode, + paymaster_data: deploy_tx_args.paymaster_data, + }, + ), + ) } pub fn external_declare_tx(declare_tx_args: DeclareTxArgs) -> RPCTransaction { - match declare_tx_args.version { - TransactionVersion::THREE => starknet_api::rpc_transaction::RPCTransaction::Declare( - starknet_api::rpc_transaction::RPCDeclareTransaction::V3(RPCDeclareTransactionV3 { - contract_class: declare_tx_args.contract_class, - signature: declare_tx_args.signature, - sender_address: declare_tx_args.sender_address, - resource_bounds: declare_tx_args.resource_bounds, - tip: declare_tx_args.tip, - nonce_data_availability_mode: declare_tx_args.nonce_data_availability_mode, - fee_data_availability_mode: declare_tx_args.fee_data_availability_mode, - paymaster_data: declare_tx_args.paymaster_data, - account_deployment_data: declare_tx_args.account_deployment_data, - nonce: declare_tx_args.nonce, - compiled_class_hash: declare_tx_args.class_hash, - }), - ), - _ => panic!("Unsupported transaction version: {:?}.", declare_tx_args.version), + if declare_tx_args.version != TransactionVersion::THREE { + panic!("Unsupported transaction version: {:?}.", declare_tx_args.version); } + + starknet_api::rpc_transaction::RPCTransaction::Declare( + starknet_api::rpc_transaction::RPCDeclareTransaction::V3(RPCDeclareTransactionV3 { + contract_class: declare_tx_args.contract_class, + signature: declare_tx_args.signature, + sender_address: declare_tx_args.sender_address, + resource_bounds: declare_tx_args.resource_bounds, + tip: declare_tx_args.tip, + nonce_data_availability_mode: declare_tx_args.nonce_data_availability_mode, + fee_data_availability_mode: declare_tx_args.fee_data_availability_mode, + paymaster_data: declare_tx_args.paymaster_data, + account_deployment_data: declare_tx_args.account_deployment_data, + nonce: declare_tx_args.nonce, + compiled_class_hash: declare_tx_args.class_hash, + }), + ) } pub fn external_tx_to_json(tx: &RPCTransaction) -> String { diff --git a/crates/tests-integration/Cargo.toml b/crates/tests-integration/Cargo.toml index 0259a0f8..9332a6c8 100644 --- a/crates/tests-integration/Cargo.toml +++ b/crates/tests-integration/Cargo.toml @@ -25,6 +25,7 @@ starknet_mempool = { path = "../mempool", version = "0.0" } starknet_mempool_infra = { path = "../mempool_infra", version = "0.0" } starknet_mempool_types = { path = "../mempool_types", version = "0.0" } starknet_task_executor = { path = "../task_executor", version = "0.0" } +starknet-types-core.workspace = true strum.workspace = true tempfile.workspace = true test_utils = { path = "../test_utils", version = "0.0" } diff --git a/crates/tests-integration/src/state_reader.rs b/crates/tests-integration/src/state_reader.rs index 060a50df..81d2e6e4 100644 --- a/crates/tests-integration/src/state_reader.rs +++ b/crates/tests-integration/src/state_reader.rs @@ -25,12 +25,12 @@ use starknet_api::block::{ }; use starknet_api::core::{ClassHash, ContractAddress, PatriciaKey, SequencerContractAddress}; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; -use starknet_api::hash::{StarkFelt, StarkHash}; use starknet_api::state::{StorageKey, ThinStateDiff}; -use starknet_api::{contract_address, patricia_key, stark_felt}; +use starknet_api::{contract_address, felt, patricia_key}; use starknet_client::reader::PendingData; use starknet_gateway::config::RpcStateReaderConfig; use starknet_gateway::rpc_state_reader::RpcStateReaderFactory; +use starknet_types_core::felt::Felt; use strum::IntoEnumIterator; use tempfile::tempdir; use test_utils::starknet_api_test_utils::{deploy_account_tx, deployed_account_contract_address}; @@ -249,7 +249,7 @@ fn test_block_header(block_number: BlockNumber) -> BlockHeader { } fn fund_feature_account_contract( - storage_diffs: &mut IndexMap>, + storage_diffs: &mut IndexMap>, contract: &FeatureContract, instance: u16, initial_balances: u128, @@ -271,13 +271,13 @@ fn fund_feature_account_contract( } fn fund_account( - storage_diffs: &mut IndexMap>, + storage_diffs: &mut IndexMap>, account_address: &ContractAddress, initial_balances: u128, chain_info: &ChainInfo, ) { let key_value = indexmap! { - get_fee_token_var_address(*account_address) => stark_felt!(initial_balances), + get_fee_token_var_address(*account_address) => felt!(initial_balances), }; for fee_type in FeeType::iter() { storage_diffs