From 3633d98007f546c7de9cdcc6204497ae24888cb7 Mon Sep 17 00:00:00 2001 From: mohammad-starkware <130282237+MohammadNassar1@users.noreply.github.com> Date: Tue, 18 Jun 2024 15:34:39 +0300 Subject: [PATCH] chore: upgrade sn-api version (#241) --- Cargo.lock | 481 ++++++++++++++---- Cargo.toml | 2 +- crates/gateway/src/gateway.rs | 6 +- crates/gateway/src/gateway_test.rs | 6 +- crates/gateway/src/starknet_api_test_utils.rs | 135 +++-- .../src/stateful_transaction_validator.rs | 4 +- .../src/stateless_transaction_validator.rs | 33 +- .../stateless_transaction_validator_test.rs | 2 +- crates/gateway/src/utils.rs | 31 +- .../src/integration_test_setup.rs | 6 +- .../src/integration_test_utils.rs | 8 +- 11 files changed, 502 insertions(+), 212 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 012cffaf..ac3be3c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -400,9 +400,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.72" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -544,6 +544,45 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blockifier" +version = "0.7.0-dev.1" +source = "git+https://github.com/starkware-libs/blockifier.git?rev=6057646f#6057646f81511f6df04fcab7f766c6302db951dc" +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" @@ -692,9 +731,9 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10d9c31baeb6b52586b5adc88f01e90f86389d63d94363c562de5c79352e545b" +checksum = "6296d5748288d9fb97175d31aff9f68ea3f602456923895e512b078e9a2210a0" dependencies = [ "cairo-lang-utils", "indoc", @@ -706,9 +745,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7148cb2d72a3db24a6d2ef2b2602102cc5099cb9f6b913e5047fb009cb3a22a1" +checksum = "a7be5083c3328dad2248a94f0a24b3520c588e7d3bd5891770e4c91d3facade3" dependencies = [ "anyhow", "cairo-lang-defs", @@ -729,18 +768,18 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a761eb8e31ea65a2dd45f729c74f1770315f97124dad93d1f6853a10d460c6b" +checksum = "2a3cbf67fd766cb7ed48b72e6abf7041857518c9b9fd42475a60c138671c6603" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6d60bc5d72fe7a95ba34e041dcbdf1cf3bfccb87008a515514b74913fa8ff05" +checksum = "7b284e41dfc158dfbdc02612dbfdb27a55547d23063bdc53105eeec41d8df006" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -755,9 +794,9 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356089e1b0a0ba9e115566191745613b3806a20259ad76764df82ab534d5412a" +checksum = "c6314b24901af8be75cd0e1363e3ff1a8020066372501f4cfc9161726b06ec2a" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -767,9 +806,9 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc43246cc2e5afd5a028bcdd63876ac3f8b1f4fb3ff785daaa0f0fbb51c9d906" +checksum = "4f95f5c8f7ea75580d164b5304251022e3d47f43fc1c778a01381b55ca9f268c" dependencies = [ "cairo-lang-utils", "good_lp", @@ -777,9 +816,9 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bcb9a4a40e53fa099774bd08bbcc3430f51213cc7fb1b50c2e9d01155731798" +checksum = "d3e58b80f0b413ef1320358fde1a0877fc3fbf740f5cead0de3e947a1bc3bfd4" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -791,9 +830,9 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba60e1e2477aa0f610ccf29189097d580464607c94b51741e1c18e64d6cee5f" +checksum = "abe6d604a06ea96c05b3666f2e8fac63cb8709e13667de272912f81db004a16b" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -816,9 +855,9 @@ dependencies = [ [[package]] name = "cairo-lang-parser" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f16ba1535e0cc5e79c2eff6592859bbdac03dc53d4dcdd26dbdbc04a77c3f5c" +checksum = "eaf1c279de47a77422f81b8a98023cd523cf0ae79f7153d60c4cf8b62b8ece2f" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -836,9 +875,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81c8cf6e0ee3d6b19429cc1663738b22f1ecea7d51bf7452e8e1086f08798baf" +checksum = "a1177a07498bdf45cba62f0c727388ff7433072847dbf701c58fa3c3e358154e" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -855,9 +894,9 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67f9da66325ce7ed6c002360f26106fe79deb9f8a2fca30abdbb8d388da7bb46" +checksum = "0c90d812ec983c5a8e3173aca3fc55036b9739201c89f30271ee14a4c1189379" dependencies = [ "cairo-lang-debug", "quote", @@ -866,9 +905,9 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e198af1ab3d05c7fb8b6a9a7a2e9bce245a6c855df5f770b751d29874a23b152" +checksum = "3985495d7e9dc481e97135d7139cfa098024351fb51d5feef8366b5fbc104807" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -880,9 +919,9 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf211f5431e2a6f4802b1b6483bf8e998e506a3be5369ed54a8807aae6e4dbf" +checksum = "fcc7c5969d107d24dbd7612ab7afec65d25475fe51d4bb708e3c773f2346c92b" dependencies = [ "ark-ff", "ark-secp256k1", @@ -911,9 +950,9 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7df81521c2125e3e95b683cc99374db1aebd7ddb317c5ca3dd92a235a9eb13" +checksum = "d5cfadbb9ca3479a6b5c02c0a125a5747835ba57a2de9c4e9764f42d85abe059" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -936,9 +975,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07da3ca1434c62a7cc7cd77d2941ef47a1c23b37325781b59407b78d8c61d863" +checksum = "74a57492267a5a8891866b6e48cdefa508b5f05931a5f8eaf004b9de15b1ffd6" dependencies = [ "anyhow", "cairo-felt", @@ -962,9 +1001,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122c9055eb609a511178e3dce577de061819fd4c4c6b7452804557f76ca43bbf" +checksum = "6fdbb4bd95477123653b9200bd4e9dceae95a914f6fe85b2bed83b223e36fb5a" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -977,9 +1016,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf049d9aea65c6e38da219a3700c72f78795d11449d9adcec28047ef8d63bd23" +checksum = "882cb178f1b79aabf70acce1d87b08d569d8a4b0ce8b1d8f538a02cdb36789db" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -992,9 +1031,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e1d75e0830279ca1bd0189e3326720d6e081225f7d81ed060bbd22c6b37e980" +checksum = "4d80c9d29e6d3f4ab60e698ebe2de84dcf90570c3dd1cfa7b01bd5c42470331c" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1015,9 +1054,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a3c3be88c8562fbf93b0803c186e7282f6daad93576c07f61b04a591fde468f" +checksum = "3ac02c90be2630ae861db6af226090da92741020519768332dd2c07e24d94c75" dependencies = [ "assert_matches", "cairo-felt", @@ -1036,9 +1075,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38da6f98c6b16945c89d2ae351c82d636ed38d3e6eb02f7c8679e3e03a63988" +checksum = "d102b10989f9637b1c916dd950cbd1bd8bb1b6a7aaa1a3035390be0683b92d85" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -1046,9 +1085,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9ffa8b3b8c47138c36b1907cebb5047dfc4de29ec10ece5bd6d6853243ec50" +checksum = "a27921a2bf82d191d28afd570b913341080c8fc25c83bf870dbf1252570b1b41" dependencies = [ "anyhow", "cairo-felt", @@ -1077,9 +1116,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet-classes" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47c64ae2bb00173e3a88760128bf72de356fa80eb19fa47602479063648b4003" +checksum = "8623b076ef3569e4262da5da270a84658b1ff242fe0c9624fbe432e7a937d101" dependencies = [ "cairo-felt", "cairo-lang-casm", @@ -1102,9 +1141,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8262c426a57e1e5ec297db24278464841500613445e2cb1c43d5f71ad91ee8d6" +checksum = "4c62f5bd74e249636e7c48d8b95e6cc0ee991206d4a6cbe5c2624184a828e70b" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1118,9 +1157,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e2d692eae4bb4179a4a1148fd5eb738a91653d86750c813658ffad4a99fa97" +checksum = "a744747e9ab03b65480265304490f3e29d99e4cb297e39d0e6fdb047c1bc86a7" dependencies = [ "genco", "xshell", @@ -1128,9 +1167,9 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf733a7cdc4166d0baf0ed8a98d9ada827daee6653b37d9326e334e53481c6d3" +checksum = "e6f98e8769412907ceb106c21c70907cc0c87ca0a2a44c82b6229a695a6f9b48" dependencies = [ "hashbrown 0.14.5", "indexmap 2.2.6", @@ -1144,9 +1183,9 @@ dependencies = [ [[package]] name = "cairo-vm" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd569684da80d747273613d5c809e4f81bf6f6b1b64d0301b12bac8f2fb8ffb1" +checksum = "d90d260c5b0c0812f02fcbdc21eb0d5908fcecdca888fb779b54c3967f7f88bf" dependencies = [ "anyhow", "bincode", @@ -1164,6 +1203,7 @@ dependencies = [ "num-prime", "num-traits 0.2.19", "rand", + "rust_decimal", "serde", "serde_json", "sha2", @@ -1207,9 +1247,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.98" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" dependencies = [ "jobserver", "libc", @@ -1263,18 +1303,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" dependencies = [ "anstream", "anstyle", @@ -1284,9 +1324,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "coins-bip32" @@ -1671,6 +1711,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "displaydoc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "dunce" version = "1.0.4" @@ -2580,9 +2631,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "d0e7a4dd27b9476dc40cb050d3632d3bba3a70ddbff012285f7f8559a1e7e545" [[package]] name = "httpdate" @@ -2661,6 +2712,124 @@ dependencies = [ "tokio-native-tls", ] +[[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f8ac670d7422d7f76b32e17a5db556510825b29ec9154f235977c9caba61036" +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.66", +] + [[package]] name = "id-arena" version = "2.2.1" @@ -2686,12 +2855,14 @@ dependencies = [ [[package]] name = "idna" -version = "0.5.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "icu_normalizer", + "icu_properties", + "smallvec", + "utf8_iter", ] [[package]] @@ -3214,6 +3385,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 = "lock_api" version = "0.4.12" @@ -3549,9 +3726,9 @@ dependencies = [ [[package]] name = "object" -version = "0.35.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" dependencies = [ "memchr", ] @@ -3707,7 +3884,7 @@ version = "0.4.0-dev.2" source = "git+https://github.com/starkware-libs/papyrus.git?rev=5d37fc32#5d37fc3202cb46d2e757bfdd489e809b3e47012b" dependencies = [ "anyhow", - "blockifier", + "blockifier 0.7.0-dev.1 (git+https://github.com/starkware-libs/blockifier.git?rev=6babc28a)", "cairo-lang-starknet-classes", "cairo-vm", "indexmap 2.2.6", @@ -4372,9 +4549,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", @@ -4384,9 +4561,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -4395,9 +4572,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "relative-path" @@ -4552,6 +4729,16 @@ 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" @@ -5138,6 +5325,12 @@ dependencies = [ "num-traits 0.1.43", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "starknet-crypto" version = "0.5.2" @@ -5238,7 +5431,7 @@ dependencies = [ [[package]] name = "starknet_api" version = "0.12.0-dev.1" -source = "git+https://github.com/starkware-libs/starknet-api.git?branch=main-mempool#859f491205e293c71dd22ca13ae72d92a9aed51b" +source = "git+https://github.com/starkware-libs/starknet-api.git?branch=main-mempool#8f13188f46f5255536fc0d6993789aa65275ad60" dependencies = [ "cairo-lang-starknet-classes", "derive_more", @@ -5288,7 +5481,7 @@ version = "0.0.0" dependencies = [ "assert_matches", "axum", - "blockifier", + "blockifier 0.7.0-dev.1 (git+https://github.com/starkware-libs/blockifier.git?rev=6057646f)", "cairo-lang-starknet-classes", "hyper", "papyrus_config", @@ -5343,7 +5536,7 @@ name = "starknet_mempool_integration_tests" version = "0.0.0" dependencies = [ "axum", - "blockifier", + "blockifier 0.7.0-dev.1 (git+https://github.com/starkware-libs/blockifier.git?rev=6057646f)", "indexmap 2.2.6", "papyrus_common", "papyrus_rpc", @@ -5561,6 +5754,17 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -5695,6 +5899,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 = "tinyvec" version = "1.6.0" @@ -5887,7 +6101,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.11", + "winnow 0.6.13", ] [[package]] @@ -6127,12 +6341,12 @@ dependencies = [ [[package]] name = "url" -version = "2.5.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "f7c25da092f0a868cdf09e8674cd3b7ef3a7d92a24253e663a2fb85e2496de56" dependencies = [ "form_urlencoded", - "idna 0.5.0", + "idna 1.0.0", "percent-encoding", ] @@ -6142,11 +6356,23 @@ 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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" @@ -6506,9 +6732,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.11" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c52728401e1dc672a56e81e593e912aa54c78f40246869f78359a2bf24d29d" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" dependencies = [ "memchr", ] @@ -6523,6 +6749,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[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" @@ -6572,6 +6810,30 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[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.66", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.34" @@ -6592,6 +6854,27 @@ dependencies = [ "syn 2.0.66", ] +[[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.66", + "synstructure", +] + [[package]] name = "zeroize" version = "1.8.1" @@ -6612,6 +6895,28 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "zerovec" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb2cc8827d6c0994478a15c53f374f46fbd41bea663d809b14744bc42e6b109c" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "zip" version = "0.6.6" diff --git a/Cargo.toml b/Cargo.toml index e5dcfc32..a4a60007 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ 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", rev = "6babc28a", features = [ +blockifier = { git = "https://github.com/starkware-libs/blockifier.git", rev = "6057646f", features = [ "testing", ] } cairo-lang-sierra = "2.6.0" diff --git a/crates/gateway/src/gateway.rs b/crates/gateway/src/gateway.rs index 47c0b570..b95f5396 100644 --- a/crates/gateway/src/gateway.rs +++ b/crates/gateway/src/gateway.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use axum::extract::State; use axum::routing::{get, post}; use axum::{Json, Router}; -use starknet_api::external_transaction::ExternalTransaction; +use starknet_api::rpc_transaction::RPCTransaction; use starknet_api::transaction::TransactionHash; use starknet_mempool_types::communication::SharedMempoolClient; use starknet_mempool_types::mempool_types::{Account, MempoolInput}; @@ -82,7 +82,7 @@ async fn is_alive() -> GatewayResult { async fn add_tx( State(app_state): State, - Json(tx): Json, + Json(tx): Json, ) -> GatewayResult> { let mempool_input = tokio::task::spawn_blocking(move || { process_tx( @@ -109,7 +109,7 @@ fn process_tx( stateless_tx_validator: StatelessTransactionValidator, stateful_tx_validator: &StatefulTransactionValidator, state_reader_factory: &dyn StateReaderFactory, - tx: ExternalTransaction, + tx: RPCTransaction, ) -> GatewayResult { // TODO(Arni, 1/5/2024): Perform congestion control. diff --git a/crates/gateway/src/gateway_test.rs b/crates/gateway/src/gateway_test.rs index 61ef1152..8bf73f9b 100644 --- a/crates/gateway/src/gateway_test.rs +++ b/crates/gateway/src/gateway_test.rs @@ -6,7 +6,7 @@ use axum::extract::State; use axum::http::StatusCode; use axum::response::{IntoResponse, Response}; use blockifier::context::ChainInfo; -use starknet_api::external_transaction::ExternalTransaction; +use starknet_api::rpc_transaction::RPCTransaction; use starknet_api::transaction::TransactionHash; use starknet_mempool::communication::create_mempool_server; use starknet_mempool::mempool::Mempool; @@ -76,10 +76,10 @@ async fn to_bytes(res: Response) -> Bytes { res.into_body().collect().await.unwrap().to_bytes() } -fn calculate_hash(external_tx: &ExternalTransaction) -> TransactionHash { +fn calculate_hash(external_tx: &RPCTransaction) -> TransactionHash { assert_matches!( external_tx, - ExternalTransaction::Invoke(_), + RPCTransaction::Invoke(_), "Only Invoke supported for now, extend as needed." ); diff --git a/crates/gateway/src/starknet_api_test_utils.rs b/crates/gateway/src/starknet_api_test_utils.rs index b475cc99..6a23737f 100644 --- a/crates/gateway/src/starknet_api_test_utils.rs +++ b/crates/gateway/src/starknet_api_test_utils.rs @@ -3,13 +3,12 @@ use blockifier::test_utils::{create_trivial_calldata, CairoVersion, NonceManager use serde_json::to_string_pretty; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; -use starknet_api::external_transaction::{ - ContractClass, ExternalDeclareTransaction, ExternalDeclareTransactionV3, - ExternalDeployAccountTransaction, ExternalDeployAccountTransactionV3, - ExternalInvokeTransaction, ExternalInvokeTransactionV3, ExternalTransaction, +use starknet_api::hash::StarkFelt; +use starknet_api::rpc_transaction::{ + ContractClass, RPCDeclareTransaction, RPCDeclareTransactionV3, RPCDeployAccountTransaction, + RPCDeployAccountTransactionV3, RPCInvokeTransaction, RPCInvokeTransactionV3, RPCTransaction, ResourceBoundsMapping, }; -use starknet_api::hash::StarkFelt; use starknet_api::transaction::{ AccountDeploymentData, Calldata, ContractAddressSalt, PaymasterData, ResourceBounds, Tip, TransactionSignature, TransactionVersion, @@ -28,14 +27,14 @@ pub enum TransactionType { Invoke, } -pub fn get_sender_address(tx: &ExternalTransaction) -> ContractAddress { +pub fn get_sender_address(tx: &RPCTransaction) -> ContractAddress { match tx { - ExternalTransaction::Declare(ExternalDeclareTransaction::V3(tx)) => tx.sender_address, + RPCTransaction::Declare(RPCDeclareTransaction::V3(tx)) => tx.sender_address, // TODO(Mohammad): Add support for deploy account. - ExternalTransaction::DeployAccount(ExternalDeployAccountTransaction::V3(_)) => { + RPCTransaction::DeployAccount(RPCDeployAccountTransaction::V3(_)) => { ContractAddress::default() } - ExternalTransaction::Invoke(ExternalInvokeTransaction::V3(tx)) => tx.sender_address, + RPCTransaction::Invoke(RPCInvokeTransaction::V3(tx)) => tx.sender_address, } } @@ -44,7 +43,7 @@ pub fn external_tx_for_testing( resource_bounds: ResourceBoundsMapping, calldata: Calldata, signature: TransactionSignature, -) -> ExternalTransaction { +) -> RPCTransaction { match tx_type { TransactionType::Declare => { let contract_class = ContractClass { @@ -86,7 +85,7 @@ pub fn executable_resource_bounds_mapping() -> ResourceBoundsMapping { ) } -pub fn invoke_tx() -> ExternalTransaction { +pub fn invoke_tx() -> RPCTransaction { let cairo_version = CairoVersion::Cairo1; let account_contract = FeatureContract::AccountWithoutValidations(cairo_version); let account_address = account_contract.get_instance_address(0); @@ -256,88 +255,78 @@ impl Default for DeclareTxArgs { } } -pub fn external_invoke_tx(invoke_args: InvokeTxArgs) -> ExternalTransaction { +pub fn external_invoke_tx(invoke_args: InvokeTxArgs) -> RPCTransaction { match invoke_args.version { - TransactionVersion::THREE => { - starknet_api::external_transaction::ExternalTransaction::Invoke( - starknet_api::external_transaction::ExternalInvokeTransaction::V3( - ExternalInvokeTransactionV3 { - 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, - }, - ), - ) - } + 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), } } -pub fn external_deploy_account_tx(deploy_tx_args: DeployAccountTxArgs) -> ExternalTransaction { +pub fn external_deploy_account_tx(deploy_tx_args: DeployAccountTxArgs) -> RPCTransaction { match deploy_tx_args.version { - TransactionVersion::THREE => { - starknet_api::external_transaction::ExternalTransaction::DeployAccount( - starknet_api::external_transaction::ExternalDeployAccountTransaction::V3( - ExternalDeployAccountTransactionV3 { - 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, - }, - ), - ) - } + 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), } } -pub fn external_declare_tx(declare_tx_args: DeclareTxArgs) -> ExternalTransaction { +pub fn external_declare_tx(declare_tx_args: DeclareTxArgs) -> RPCTransaction { match declare_tx_args.version { - TransactionVersion::THREE => { - starknet_api::external_transaction::ExternalTransaction::Declare( - starknet_api::external_transaction::ExternalDeclareTransaction::V3( - ExternalDeclareTransactionV3 { - 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, - }, - ), - ) - } + 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), } } -pub fn external_tx_to_json(tx: &ExternalTransaction) -> String { +pub fn external_tx_to_json(tx: &RPCTransaction) -> String { let mut tx_json = serde_json::to_value(tx) .unwrap_or_else(|tx| panic!("Failed to serialize transaction: {tx:?}")); // Add type and version manually let type_string = match tx { - ExternalTransaction::Declare(_) => "DECLARE", - ExternalTransaction::DeployAccount(_) => "DEPLOY_ACCOUNT", - ExternalTransaction::Invoke(_) => "INVOKE", + RPCTransaction::Declare(_) => "DECLARE", + RPCTransaction::DeployAccount(_) => "DEPLOY_ACCOUNT", + RPCTransaction::Invoke(_) => "INVOKE", }; tx_json diff --git a/crates/gateway/src/stateful_transaction_validator.rs b/crates/gateway/src/stateful_transaction_validator.rs index 8cb7fad3..c45a2887 100644 --- a/crates/gateway/src/stateful_transaction_validator.rs +++ b/crates/gateway/src/stateful_transaction_validator.rs @@ -5,7 +5,7 @@ use blockifier::context::BlockContext; use blockifier::execution::contract_class::ClassInfo; use blockifier::state::cached_state::CachedState; use blockifier::versioned_constants::VersionedConstants; -use starknet_api::external_transaction::ExternalTransaction; +use starknet_api::rpc_transaction::RPCTransaction; use starknet_api::transaction::TransactionHash; use crate::config::StatefulTransactionValidatorConfig; @@ -25,7 +25,7 @@ impl StatefulTransactionValidator { pub fn run_validate( &self, state_reader_factory: &dyn StateReaderFactory, - external_tx: &ExternalTransaction, + external_tx: &RPCTransaction, optional_class_info: Option, deploy_account_tx_hash: Option, ) -> StatefulTransactionValidatorResult { diff --git a/crates/gateway/src/stateless_transaction_validator.rs b/crates/gateway/src/stateless_transaction_validator.rs index 94d08ee9..274d4c9c 100644 --- a/crates/gateway/src/stateless_transaction_validator.rs +++ b/crates/gateway/src/stateless_transaction_validator.rs @@ -1,6 +1,6 @@ -use starknet_api::external_transaction::{ - ExternalDeclareTransaction, ExternalDeployAccountTransaction, ExternalInvokeTransaction, - ExternalTransaction, ResourceBoundsMapping, +use starknet_api::rpc_transaction::{ + RPCDeclareTransaction, RPCDeployAccountTransaction, RPCInvokeTransaction, RPCTransaction, + ResourceBoundsMapping, }; use starknet_api::transaction::Resource; @@ -17,14 +17,14 @@ pub struct StatelessTransactionValidator { } impl StatelessTransactionValidator { - pub fn validate(&self, tx: &ExternalTransaction) -> StatelessTransactionValidatorResult<()> { + pub fn validate(&self, tx: &RPCTransaction) -> StatelessTransactionValidatorResult<()> { // TODO(Arni, 1/5/2024): Add a mechanism that validate the sender address is not blocked. // TODO(Arni, 1/5/2024): Validate transaction version. self.validate_resource_bounds(tx)?; self.validate_tx_size(tx)?; - if let ExternalTransaction::Declare(declare_tx) = tx { + if let RPCTransaction::Declare(declare_tx) = tx { self.validate_declare_tx(declare_tx)?; } Ok(()) @@ -32,7 +32,7 @@ impl StatelessTransactionValidator { fn validate_resource_bounds( &self, - tx: &ExternalTransaction, + tx: &RPCTransaction, ) -> StatelessTransactionValidatorResult<()> { let resource_bounds_mapping = tx.resource_bounds(); @@ -46,10 +46,7 @@ impl StatelessTransactionValidator { Ok(()) } - fn validate_tx_size( - &self, - tx: &ExternalTransaction, - ) -> StatelessTransactionValidatorResult<()> { + fn validate_tx_size(&self, tx: &RPCTransaction) -> StatelessTransactionValidatorResult<()> { self.validate_tx_calldata_size(tx)?; self.validate_tx_signature_size(tx)?; @@ -58,17 +55,17 @@ impl StatelessTransactionValidator { fn validate_tx_calldata_size( &self, - tx: &ExternalTransaction, + tx: &RPCTransaction, ) -> StatelessTransactionValidatorResult<()> { let calldata = match tx { - ExternalTransaction::Declare(_) => { + RPCTransaction::Declare(_) => { // Declare transaction has no calldata. return Ok(()); } - ExternalTransaction::DeployAccount(ExternalDeployAccountTransaction::V3(tx)) => { + RPCTransaction::DeployAccount(RPCDeployAccountTransaction::V3(tx)) => { &tx.constructor_calldata } - ExternalTransaction::Invoke(ExternalInvokeTransaction::V3(tx)) => &tx.calldata, + RPCTransaction::Invoke(RPCInvokeTransaction::V3(tx)) => &tx.calldata, }; let calldata_length = calldata.0.len(); @@ -84,7 +81,7 @@ impl StatelessTransactionValidator { fn validate_tx_signature_size( &self, - tx: &ExternalTransaction, + tx: &RPCTransaction, ) -> StatelessTransactionValidatorResult<()> { let signature = tx.signature(); @@ -101,17 +98,17 @@ impl StatelessTransactionValidator { fn validate_declare_tx( &self, - declare_tx: &ExternalDeclareTransaction, + declare_tx: &RPCDeclareTransaction, ) -> StatelessTransactionValidatorResult<()> { let contract_class = match declare_tx { - ExternalDeclareTransaction::V3(tx) => &tx.contract_class, + RPCDeclareTransaction::V3(tx) => &tx.contract_class, }; self.validate_class_length(contract_class) } fn validate_class_length( &self, - contract_class: &starknet_api::external_transaction::ContractClass, + contract_class: &starknet_api::rpc_transaction::ContractClass, ) -> StatelessTransactionValidatorResult<()> { let bytecode_size = contract_class.sierra_program.len(); if bytecode_size > self.config.max_bytecode_size { diff --git a/crates/gateway/src/stateless_transaction_validator_test.rs b/crates/gateway/src/stateless_transaction_validator_test.rs index 8c7500cd..c074e41d 100644 --- a/crates/gateway/src/stateless_transaction_validator_test.rs +++ b/crates/gateway/src/stateless_transaction_validator_test.rs @@ -1,7 +1,7 @@ use assert_matches::assert_matches; use rstest::rstest; -use starknet_api::external_transaction::{ContractClass, ResourceBoundsMapping}; 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}; diff --git a/crates/gateway/src/utils.rs b/crates/gateway/src/utils.rs index 87933d2d..2e438f63 100644 --- a/crates/gateway/src/utils.rs +++ b/crates/gateway/src/utils.rs @@ -6,9 +6,8 @@ use blockifier::transaction::transactions::{ InvokeTransaction as BlockifierInvokeTransaction, }; use starknet_api::core::{calculate_contract_address, ChainId, ClassHash, ContractAddress, Nonce}; -use starknet_api::external_transaction::{ - ExternalDeclareTransaction, ExternalDeployAccountTransaction, ExternalInvokeTransaction, - ExternalTransaction, +use starknet_api::rpc_transaction::{ + RPCDeclareTransaction, RPCDeployAccountTransaction, RPCInvokeTransaction, RPCTransaction, }; use starknet_api::transaction::{ DeclareTransaction, DeclareTransactionV3, DeployAccountTransaction, DeployAccountTransactionV3, @@ -23,21 +22,21 @@ macro_rules! implement_ref_getters { ($(($member_name:ident, $member_type:ty));* $(;)?) => { $(fn $member_name(&self) -> &$member_type { match self { - starknet_api::external_transaction::ExternalTransaction::Declare( - starknet_api::external_transaction::ExternalDeclareTransaction::V3(tx) + starknet_api::rpc_transaction::RPCTransaction::Declare( + starknet_api::rpc_transaction::RPCDeclareTransaction::V3(tx) ) => &tx.$member_name, - starknet_api::external_transaction::ExternalTransaction::DeployAccount( - starknet_api::external_transaction::ExternalDeployAccountTransaction::V3(tx) + starknet_api::rpc_transaction::RPCTransaction::DeployAccount( + starknet_api::rpc_transaction::RPCDeployAccountTransaction::V3(tx) ) => &tx.$member_name, - starknet_api::external_transaction::ExternalTransaction::Invoke( - starknet_api::external_transaction::ExternalInvokeTransaction::V3(tx) + starknet_api::rpc_transaction::RPCTransaction::Invoke( + starknet_api::rpc_transaction::RPCInvokeTransaction::V3(tx) ) => &tx.$member_name, } })* }; } -impl ExternalTransactionExt for ExternalTransaction { +impl RPCTransactionExt for RPCTransaction { implement_ref_getters!( (nonce, Nonce); (tip, Tip) @@ -45,7 +44,7 @@ impl ExternalTransactionExt for ExternalTransaction { } pub fn external_tx_to_thin_tx( - external_tx: &ExternalTransaction, + external_tx: &RPCTransaction, tx_hash: TransactionHash, ) -> ThinTransaction { ThinTransaction { @@ -57,19 +56,19 @@ pub fn external_tx_to_thin_tx( } // TODO(Mohammad): Remove this trait once it is implemented in StarkNet API. -pub trait ExternalTransactionExt { +pub trait RPCTransactionExt { fn nonce(&self) -> &Nonce; fn tip(&self) -> &Tip; } pub fn external_tx_to_account_tx( - external_tx: &ExternalTransaction, + external_tx: &RPCTransaction, // FIXME(yael 15/4/24): calculate class_info inside the function once compilation code is ready optional_class_info: Option, chain_id: &ChainId, ) -> StatefulTransactionValidatorResult { match external_tx { - ExternalTransaction::Declare(ExternalDeclareTransaction::V3(tx)) => { + RPCTransaction::Declare(RPCDeclareTransaction::V3(tx)) => { let declare_tx = DeclareTransaction::V3(DeclareTransactionV3 { class_hash: ClassHash::default(), /* FIXME(yael 15/4/24): call the starknet-api * function once ready */ @@ -90,7 +89,7 @@ pub fn external_tx_to_account_tx( let declare_tx = BlockifierDeclareTransaction::new(declare_tx, tx_hash, class_info)?; Ok(AccountTransaction::Declare(declare_tx)) } - ExternalTransaction::DeployAccount(ExternalDeployAccountTransaction::V3(tx)) => { + RPCTransaction::DeployAccount(RPCDeployAccountTransaction::V3(tx)) => { let deploy_account_tx = DeployAccountTransaction::V3(DeployAccountTransactionV3 { resource_bounds: tx.resource_bounds.clone().into(), tip: tx.tip, @@ -118,7 +117,7 @@ pub fn external_tx_to_account_tx( ); Ok(AccountTransaction::DeployAccount(deploy_account_tx)) } - ExternalTransaction::Invoke(ExternalInvokeTransaction::V3(tx)) => { + RPCTransaction::Invoke(RPCInvokeTransaction::V3(tx)) => { let invoke_tx = InvokeTransaction::V3(InvokeTransactionV3 { resource_bounds: tx.resource_bounds.clone().into(), tip: tx.tip, diff --git a/crates/tests-integration/src/integration_test_setup.rs b/crates/tests-integration/src/integration_test_setup.rs index eade620e..31b48798 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 std::sync::Arc; -use starknet_api::external_transaction::ExternalTransaction; +use starknet_api::rpc_transaction::RPCTransaction; use starknet_api::transaction::TransactionHash; use starknet_gateway::config::GatewayNetworkConfig; use starknet_gateway::errors::GatewayError; @@ -72,11 +72,11 @@ impl IntegrationTestSetup { } } - pub async fn assert_add_tx_success(&self, tx: &ExternalTransaction) -> TransactionHash { + pub async fn assert_add_tx_success(&self, tx: &RPCTransaction) -> TransactionHash { self.gateway_client.assert_add_tx_success(tx).await } - pub async fn assert_add_tx_error(&self, tx: &ExternalTransaction) -> GatewayError { + pub async fn assert_add_tx_error(&self, tx: &RPCTransaction) -> GatewayError { self.gateway_client.assert_add_tx_error(tx).await } diff --git a/crates/tests-integration/src/integration_test_utils.rs b/crates/tests-integration/src/integration_test_utils.rs index e9f8f988..429ada19 100644 --- a/crates/tests-integration/src/integration_test_utils.rs +++ b/crates/tests-integration/src/integration_test_utils.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use axum::body::Body; use reqwest::{Client, Response}; -use starknet_api::external_transaction::ExternalTransaction; +use starknet_api::rpc_transaction::RPCTransaction; use starknet_api::transaction::TransactionHash; use starknet_gateway::config::{ GatewayConfig, GatewayNetworkConfig, StatefulTransactionValidatorConfig, @@ -51,7 +51,7 @@ impl GatewayClient { Self { socket, client } } - pub async fn assert_add_tx_success(&self, tx: &ExternalTransaction) -> TransactionHash { + pub async fn assert_add_tx_success(&self, tx: &RPCTransaction) -> TransactionHash { let response = self.add_tx(tx).await; assert!(response.status().is_success()); @@ -59,13 +59,13 @@ impl GatewayClient { } // TODO: implement when usage eventually arises. - pub async fn assert_add_tx_error(&self, _tx: &ExternalTransaction) -> GatewayError { + pub async fn assert_add_tx_error(&self, _tx: &RPCTransaction) -> GatewayError { todo!() } // Prefer using assert_add_tx_success or other higher level methods of this client, to ensure // tests are boilerplate and implementation-detail free. - pub async fn add_tx(&self, tx: &ExternalTransaction) -> Response { + pub async fn add_tx(&self, tx: &RPCTransaction) -> Response { let tx_json = external_tx_to_json(tx); self.client .post(format!("http://{}/add_tx", self.socket))