diff --git a/Cargo.lock b/Cargo.lock index c4979e4dbf..21154c1c5a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -933,9 +933,11 @@ dependencies = [ [[package]] name = "blockifier" -version = "0.5.0-dev.0" -source = "git+https://github.com/starkware-libs/blockifier?branch=yair/bump_sn_api#800719078688cabedaded49431571ae80339d144" +version = "0.5.0-rc.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fcbbfed0fe22d2dfbb9cda105b2eacb05cb420fb855d6ba71cb7d8c06d5ceca" dependencies = [ + "anyhow", "ark-ec", "ark-ff", "ark-secp256k1", @@ -944,19 +946,18 @@ dependencies = [ "cairo-felt", "cairo-lang-casm", "cairo-lang-runner", - "cairo-lang-starknet", + "cairo-lang-starknet-classes", "cairo-lang-utils", "cairo-vm", - "ctor", "derive_more", "indexmap 2.1.0", "itertools 0.10.5", "keccak", "log", - "memoize", "num-bigint", "num-integer", "num-traits 0.2.17", + "once_cell", "phf", "serde", "serde_json", @@ -1099,26 +1100,24 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "039c26a5d37099dc502c24374972d510380d556ad8b1ebc709018317e15aaa4b" +checksum = "79c609f2d50a308006b0c04a3e1f9eda79fc4b6cc7d5cdb128c45ae020af7391" dependencies = [ "cairo-lang-utils", "indoc", "num-bigint", "num-traits 0.2.17", "parity-scale-codec", - "parity-scale-codec-derive", "schemars", "serde", - "thiserror", ] [[package]] name = "cairo-lang-compiler" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00cba807bad1c5eb232246595e60dd168ba1665ee8c3e54c41bb8eaddf4cb28b" +checksum = "f9d0e519f55e16aca12c48330b058e84368fa0a2751bc6322f63e474e98039bd" dependencies = [ "anyhow", "cairo-lang-defs", @@ -1133,23 +1132,24 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "salsa", + "smol_str", "thiserror", ] [[package]] name = "cairo-lang-debug" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e0ecf0a142e38df1565ff236dcc1d80d7abcff2bc41d6b3212f8b6d9f05c0a4" +checksum = "a28f52797c69c11cfe7099747eccdf837ecd71ff17ef443f45dff743426a7163" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd30e1f4ea6eab863bef95aeff0fde6fd6c075e83635ff58e91a03ae46080640" +checksum = "a65986f560d3c1ac573ac26e9d9e000ad95f82b64b7d1f4b49005608049c8c09" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -1164,9 +1164,9 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d804a0dd8daf7afb60277262d5a3dbcc77c92e70dd7e0c561633f9d465af27" +checksum = "0a9e688f43671b7cb397bcb4fbdb55158633369a1f5ae4e61ea42207eb371d63" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1176,9 +1176,9 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d4ae66190fb6da39f88d970b4f11fe0a19fe44046a5008cb90063d08e1022c" +checksum = "8c516416fe6b202df2d94611e984b6177ac87f8553b17765f9430608132f5645" dependencies = [ "cairo-lang-utils", "good_lp", @@ -1186,9 +1186,9 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f3b5f333742ef84bc08942820db78c59be513f8c7ba1785d4cd7d3424fd7826" +checksum = "cd837ab31b831e9f7b8376ff83f77fff01ad5a6a7bd23bf146bcfaad62d4b039" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -1200,9 +1200,9 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ad5141f2f5bb887a158bab910b658ddca7f30c08701bc107789880fc9a81648" +checksum = "dae6a996bd5f5c6f1ac6f961c507d2d841c9ecfbd6aa645a74140907d8a13280" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1225,9 +1225,9 @@ dependencies = [ [[package]] name = "cairo-lang-parser" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee8e4ba24c66b1b8b00028d1b54e6d6f19a32c6f614d5c6b927dd4bf1251b831" +checksum = "3ead70afebbb01898f7a1d29e3bfb91ee545c29446680ccbb66f5c51f1741313" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -1245,9 +1245,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b3e1847ca9e303a6f7abdb97d1cd29c5f595db1f373b911626d7ca5fa31ce37" +checksum = "32ecdc7986014341e0165a027105e612985c32a7bcd2f7c0fc4cd6197b37eb67" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -1264,9 +1264,9 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0a9fe6e2dd307b0c53c75c6eb625719a07829b475b3c4a04caefe4e1c92236" +checksum = "5629126ebb5347cdad42fa7388535118521b4f68419f957728fe53760a726e83" dependencies = [ "cairo-lang-debug", "quote", @@ -1275,9 +1275,9 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55bbcb9001359e2e168cfde7369bd1d6e84ac15efa425331b2b32f03958b1d24" +checksum = "60125ce673e4c453ffe532ba15b295a0664334c4af666e43ab94ecaa2915fa8a" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -1289,9 +1289,9 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9867f8e30b824988c249fbed6325ace995503143d02c45c60fc15e572b6c11c7" +checksum = "76d269f3b2fe2613cb70f72f4a2c7928d119232766a83ffc7bbb3fb0aba2c74b" dependencies = [ "ark-ff", "ark-secp256k1", @@ -1301,6 +1301,7 @@ dependencies = [ "cairo-lang-casm", "cairo-lang-sierra", "cairo-lang-sierra-ap-change", + "cairo-lang-sierra-generator", "cairo-lang-sierra-to-casm", "cairo-lang-sierra-type-size", "cairo-lang-starknet", @@ -1311,15 +1312,16 @@ dependencies = [ "num-bigint", "num-integer", "num-traits 0.2.17", + "smol_str", "starknet-crypto 0.6.1", "thiserror", ] [[package]] name = "cairo-lang-semantic" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede5ef4b7ddbf7c07359956ab0c121cbe797453090e95338869af7fdb38e5b2b" +checksum = "0773a59a843e532aea274efaa7be499b6953a1aaeb0d64c8b8c11109ba1da2c4" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1342,9 +1344,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f96b2c3ca1202536e0d17ef96e854d421a977f955f9ea6e034754f428b28ec90" +checksum = "f06cf259fa7022e55f4a997c691510728119a3a2025e8fd9a8d18d3871b91259" dependencies = [ "anyhow", "cairo-felt", @@ -1368,9 +1370,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "761219bb5acfbc13ca71f405d4c46ae0787eb81633a861f3ec6f82e778e74c70" +checksum = "927b7624e3e6c45552a70b50760706b49939f4eec24ad03359dd9a3de383e58d" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1383,9 +1385,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eef3a50fd3561f32fb90a6b11ad2e6e1343d650f7c5c520d7074e91bb6a6cffc" +checksum = "bce6e6355cb8f06714879a031d9c85e80d4261468e93a3c62b440b4804518e43" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1398,9 +1400,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aff8f590e59a378f93c26c29f123e71914c286dc94a4a9e0c09d991abfd933c6" +checksum = "085979b1238d59a2d0feebca864ddbd91854f6c057c96cf904ee5e7229e6590a" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1421,9 +1423,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e65019e277a1c7e9aa9f0a5f0c4c58bb1e8d4aaaf82bdad06588523cd40dcc2" +checksum = "048b7e1627faddfcde39bc4bfaca81ef88fa01c984e17f322195a3598632bcd1" dependencies = [ "assert_matches", "cairo-felt", @@ -1442,9 +1444,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de64514c18b09805c739547694e0b33a01ae72736b7c48d356a5c6fa8e06604d" +checksum = "5f5b15790a43e099efa6631b0a3a956feed3079ed5f6b8bb853bc9747c3eb305" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -1452,29 +1454,48 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bab15d4b6a0be7bfa1f6fc71183dc821dc99034c3285f9610077225dcb4208f" +checksum = "0fff12ebd720839dd1d51ac776b53e2ad7b898d5bc28c3998d17f380da85c8a9" dependencies = [ "anyhow", "cairo-felt", - "cairo-lang-casm", "cairo-lang-compiler", "cairo-lang-defs", "cairo-lang-diagnostics", "cairo-lang-filesystem", "cairo-lang-lowering", + "cairo-lang-plugins", "cairo-lang-semantic", "cairo-lang-sierra", "cairo-lang-sierra-generator", - "cairo-lang-sierra-to-casm", + "cairo-lang-starknet-classes", "cairo-lang-syntax", "cairo-lang-utils", "const_format", - "convert_case 0.6.0", "indent", "indoc", "itertools 0.11.0", + "once_cell", + "serde", + "serde_json", + "smol_str", + "thiserror", +] + +[[package]] +name = "cairo-lang-starknet-classes" +version = "2.6.0-rc.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e306eeaf4766fc701a74e727c1a88c2c5d2b40748d07d0548ec8e0b0ca11dec6" +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", "num-bigint", "num-integer", "num-traits 0.2.17", @@ -1489,9 +1510,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba0316e4631c9e0423236caf4318bd914f15b4715aab8d76da042e69b758fcd1" +checksum = "6f5fb36c2d85254af7e33b130809cea8969150bbe8df03c51876b546224704a3" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1505,9 +1526,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32c7c3674f737bff4bd9657ff5c8dc6f42a1dd7c6bc9dac3e25a33b67d2137dc" +checksum = "5784bda479025abf46e895def0672d04634c7a5b8820279617d03778a6110321" dependencies = [ "genco", "xshell", @@ -1515,10 +1536,11 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.5.0-dev.1" +version = "2.6.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b3a2a904d203bc95f244aec32b3054cc0f7fd0eb84a614136ca6e199b62059a" +checksum = "d812e9b5472c7f10cd3c8e9155d4532bc251e5352a7d1d646934c20fa0dc8bdb" dependencies = [ + "hashbrown 0.14.3", "indexmap 2.1.0", "itertools 0.11.0", "num-bigint", @@ -2011,16 +2033,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "ctor" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e366bff8cd32dd8754b0991fb66b279dc48f598c3a18914852a6673deef583" -dependencies = [ - "quote", - "syn 2.0.39", -] - [[package]] name = "ctr" version = "0.9.2" @@ -4805,29 +4817,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "memoize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5df4051db13d0816cf23196d3baa216385ae099339f5d0645a8d9ff2305e82b8" -dependencies = [ - "lazy_static", - "lru 0.7.8", - "memoize-inner", -] - -[[package]] -name = "memoize-inner" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27bdece7e91f0d1e33df7b46ec187a93ea0d4e642113a1039ac8bfdd4a3273ac" -dependencies = [ - "lazy_static", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "metrics" version = "0.21.1" @@ -5422,9 +5411,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" @@ -5566,7 +5555,7 @@ name = "papyrus_common" version = "0.3.0-dev.1" dependencies = [ "bitvec", - "cairo-lang-starknet", + "cairo-lang-starknet-classes", "hex", "lazy_static", "pretty_assertions", @@ -5603,7 +5592,7 @@ dependencies = [ "assert_matches", "blockifier", "cairo-lang-casm", - "cairo-lang-starknet", + "cairo-lang-starknet-classes", "cairo-lang-utils", "cairo-vm", "indexmap 2.1.0", @@ -5756,7 +5745,7 @@ dependencies = [ "async-trait", "base64 0.13.1", "cairo-lang-casm", - "cairo-lang-starknet", + "cairo-lang-starknet-classes", "camelpaste", "derive_more", "enum-iterator", @@ -5810,7 +5799,7 @@ dependencies = [ "assert_matches", "byteorder", "cairo-lang-casm", - "cairo-lang-starknet", + "cairo-lang-starknet-classes", "cairo-lang-utils", "camelpaste", "clap", @@ -5855,7 +5844,7 @@ dependencies = [ "assert_matches", "async-stream", "async-trait", - "cairo-lang-starknet", + "cairo-lang-starknet-classes", "chrono", "futures", "futures-channel", @@ -7776,11 +7765,11 @@ dependencies = [ [[package]] name = "starknet_api" -version = "0.7.0-rc.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a1012226101cbe3c0483c637ca90186240f131f6af89069ae37c59073f16f9" +checksum = "e8bfc63e01213a3a39af29aa061435b80a24919ac02d1dce758d9e1ac8be2a44" dependencies = [ - "cairo-lang-starknet", + "cairo-lang-starknet-classes", "derive_more", "hex", "indexmap 2.1.0", @@ -7800,7 +7789,7 @@ version = "0.3.0-dev.1" dependencies = [ "assert_matches", "async-trait", - "cairo-lang-starknet", + "cairo-lang-starknet-classes", "enum-iterator", "http", "indexmap 2.1.0", @@ -8087,7 +8076,7 @@ name = "test_utils" version = "0.3.0-dev.1" dependencies = [ "cairo-lang-casm", - "cairo-lang-starknet", + "cairo-lang-starknet-classes", "cairo-lang-utils", "indexmap 2.1.0", "num-bigint", diff --git a/Cargo.toml b/Cargo.toml index 2acb02f8f3..d5f5f3621f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,12 +33,12 @@ async-trait = "0.1.56" axum = "0.6.12" base64 = "0.13.0" bitvec = "1.0.1" -blockifier = { git = "https://github.com/starkware-libs/blockifier", branch = "yair/bump_sn_api" } +blockifier = "0.5.0-rc.0" bytes = "1" byteorder = "1.4.3" -cairo-lang-starknet = "=2.5.0-dev.1" -cairo-lang-casm = "=2.5.0-dev.1" -cairo-lang-utils = "=2.5.0-dev.1" +cairo-lang-casm = "=2.6.0-rc.0" +cairo-lang-utils = "=2.6.0-rc.0" +cairo-lang-starknet-classes = "=2.6.0-rc.0" cairo-vm = "0.9.1" camelpaste = "0.1.0" chrono = "0.4.26" @@ -101,7 +101,7 @@ serde_repr = "0.1" serde_yaml = "0.9.16" sha3 = "0.10.8" simple_logger = "4.0.0" -starknet_api = "0.7.0-rc.0" +starknet_api = "0.8.0" starknet-core = "0.6.0" starknet-crypto = "0.5.1" strum = "0.25.0" diff --git a/crates/papyrus_common/Cargo.toml b/crates/papyrus_common/Cargo.toml index 91cfb18e5c..029291d25a 100644 --- a/crates/papyrus_common/Cargo.toml +++ b/crates/papyrus_common/Cargo.toml @@ -8,7 +8,7 @@ description = "Common utils and objects for a Starknet node." [dependencies] bitvec.workspace = true -cairo-lang-starknet.workspace = true +cairo-lang-starknet-classes.workspace = true hex.workspace = true lazy_static.workspace = true serde.workspace = true diff --git a/crates/papyrus_common/src/pending_classes.rs b/crates/papyrus_common/src/pending_classes.rs index 78a854e632..85abd49c6d 100644 --- a/crates/papyrus_common/src/pending_classes.rs +++ b/crates/papyrus_common/src/pending_classes.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use std::sync::Arc; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use starknet_api::core::ClassHash; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; use starknet_api::state::ContractClass; diff --git a/crates/papyrus_execution/Cargo.toml b/crates/papyrus_execution/Cargo.toml index fbc5de61e0..ac03ff97ea 100644 --- a/crates/papyrus_execution/Cargo.toml +++ b/crates/papyrus_execution/Cargo.toml @@ -12,7 +12,7 @@ testing = ["rand", "rand_chacha", "test_utils"] [dependencies] anyhow.workspace = true blockifier.workspace = true -cairo-lang-starknet.workspace = true +cairo-lang-starknet-classes.workspace = true cairo-vm.workspace = true indexmap.workspace = true itertools.workspace = true diff --git a/crates/papyrus_execution/src/execution_test.rs b/crates/papyrus_execution/src/execution_test.rs index 1f642af912..238d7f3788 100644 --- a/crates/papyrus_execution/src/execution_test.rs +++ b/crates/papyrus_execution/src/execution_test.rs @@ -5,9 +5,9 @@ use std::sync::Arc; use assert_matches::assert_matches; use blockifier::abi::abi_utils::get_storage_var_address; -use blockifier::abi::constants::STEP_GAS_COST; use blockifier::execution::call_info::Retdata; use blockifier::transaction::errors::TransactionExecutionError as BlockifierTransactionExecutionError; +use blockifier::versioned_constants::VersionedConstants; use indexmap::indexmap; use papyrus_storage::test_utils::get_test_storage; use pretty_assertions::assert_eq; @@ -669,8 +669,9 @@ fn test_default_execution_config() { invoke_tx_max_n_steps: 3_000_000, validate_tx_max_n_steps: 1_000_000, max_recursion_depth: 50, - step_gas_cost: STEP_GAS_COST, - initial_gas_cost: 10_u64.pow(8) * STEP_GAS_COST, + step_gas_cost: VersionedConstants::latest_constants().gas_cost("step_gas_cost"), + initial_gas_cost: 10_u64.pow(8) + * VersionedConstants::latest_constants().gas_cost("step_gas_cost"), vm_resource_fee_cost, }; let mut execution_config_segments = BTreeMap::new(); diff --git a/crates/papyrus_execution/src/lib.rs b/crates/papyrus_execution/src/lib.rs index 39a86fc4b3..22639e8429 100644 --- a/crates/papyrus_execution/src/lib.rs +++ b/crates/papyrus_execution/src/lib.rs @@ -20,9 +20,11 @@ pub mod testing_instances; pub mod objects; use std::collections::{BTreeMap, HashMap}; +use std::num::NonZeroU128; use std::sync::Arc; -use blockifier::block_context::{BlockContext, FeeTokenAddresses, GasPrices}; +use blockifier::block::{pre_process_block, BlockInfo, BlockNumberHashPair, GasPrices}; +use blockifier::context::{BlockContext, ChainInfo, FeeTokenAddresses, TransactionContext}; use blockifier::execution::call_info::CallExecution; use blockifier::execution::contract_class::ContractClass as BlockifierContractClass; use blockifier::execution::entry_point::{ @@ -31,17 +33,17 @@ use blockifier::execution::entry_point::{ EntryPointExecutionContext, ExecutionResources, }; -use blockifier::state::cached_state::CachedState; -use blockifier::state::state_api::State; +use blockifier::state::cached_state::{CachedState, GlobalContractCache}; use blockifier::transaction::errors::TransactionExecutionError as BlockifierTransactionExecutionError; use blockifier::transaction::objects::{ - AccountTransactionContext, - DeprecatedAccountTransactionContext, + DeprecatedTransactionInfo, TransactionExecutionInfo, + TransactionInfo, }; use blockifier::transaction::transaction_execution::Transaction as BlockifierTransaction; use blockifier::transaction::transactions::ExecutableTransaction; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use blockifier::versioned_constants::VersionedConstants; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use execution_utils::{get_trace_constructor, induced_state_diff}; use objects::{PriceUnit, TransactionSimulationOutput}; use papyrus_common::transaction_hash::get_transaction_hash; @@ -50,13 +52,14 @@ use papyrus_storage::header::HeaderStorageReader; use papyrus_storage::{StorageError, StorageReader}; use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockNumber, GasPrice}; -use starknet_api::core::{ChainId, ClassHash, ContractAddress, EntryPointSelector}; +use starknet_api::core::{ChainId, ClassHash, ContractAddress, EntryPointSelector, PatriciaKey}; // TODO: merge multiple EntryPointType structs in SN_API into one. use starknet_api::deprecated_contract_class::{ ContractClass as DeprecatedContractClass, EntryPointType, }; -use starknet_api::state::{StateNumber, StorageKey, ThinStateDiff}; +use starknet_api::hash::StarkHash; +use starknet_api::state::{StateNumber, ThinStateDiff}; use starknet_api::transaction::{ Calldata, DeclareTransaction, @@ -71,12 +74,19 @@ use starknet_api::transaction::{ TransactionHash, TransactionVersion, }; -use starknet_api::StarknetApiError; +use starknet_api::{contract_address, patricia_key, StarknetApiError}; use state_reader::ExecutionStateReader; use tracing::trace; use crate::objects::PendingData; +// TODO(yair): understand what it is and whether the use of this constant should change. +const GLOBAL_CONTRACT_CACHE_SIZE: usize = 100; + +// TODO(Eitan): get from config. +const STRK_FEE_TOKEN_ADDRESS: &str = + "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"; + /// Result type for execution functions. pub type ExecutionResult = Result; @@ -154,6 +164,8 @@ pub enum ExecutionError { #[error("Missing compiled class with hash {class_hash} (The CASM table isn't synced)")] MissingCompiledClass { class_hash: ClassHash }, #[error(transparent)] + StateError(#[from] blockifier::state::errors::StateError), + #[error(transparent)] StorageError(#[from] StorageError), #[error( "Execution failed at transaction {transaction_index:?} with error: {execution_error:?}" @@ -204,7 +216,18 @@ pub fn execute_call( initial_gas: execution_config.initial_gas_cost, }; + let mut cached_state = CachedState::new( + ExecutionStateReader { + storage_reader: storage_reader.clone(), + state_number, + maybe_pending_data: maybe_pending_data.clone(), + missing_compiled_class: None, + }, + GlobalContractCache::new(GLOBAL_CONTRACT_CACHE_SIZE), + ); + let block_context = create_block_context( + &mut cached_state, block_context_number, chain_id.clone(), &storage_reader, @@ -212,16 +235,12 @@ pub fn execute_call( execution_config, )?; - let mut cached_state = CachedState::from(ExecutionStateReader { - storage_reader, - state_number, - maybe_pending_data, - missing_compiled_class: None, - }); let mut context = EntryPointExecutionContext::new_invoke( - &block_context, // TODO(yair): fix when supporting v3 transactions - &AccountTransactionContext::Deprecated(DeprecatedAccountTransactionContext::default()), + Arc::new(TransactionContext { + block_context, + tx_info: TransactionInfo::Deprecated(DeprecatedTransactionInfo::default()), + }), true, // limit_steps_by_resources ) .map_err(|err| ExecutionError::ContractError(err.into()))?; @@ -258,47 +277,75 @@ fn verify_contract_exists( } fn create_block_context( + cached_state: &mut CachedState, block_context_number: BlockNumber, chain_id: ChainId, storage_reader: &StorageReader, maybe_pending_data: Option<&PendingData>, execution_config: &BlockExecutionConfig, ) -> ExecutionResult { - let (block_number, block_timestamp, gas_prices, sequencer_address) = match maybe_pending_data { - Some(pending_data) => ( - block_context_number.next(), - pending_data.timestamp, - pending_data.l1_gas_price, - pending_data.sequencer, - ), - None => { - let header = storage_reader - .begin_ro_txn()? - .get_block_header(block_context_number)? - .expect("Should have block header."); - (header.block_number, header.timestamp, header.l1_gas_price, header.sequencer) - } - }; + let (block_number, block_timestamp, l1_gas_price, l1_data_gas_price, sequencer_address) = + match maybe_pending_data { + Some(pending_data) => ( + block_context_number.next(), + pending_data.timestamp, + pending_data.l1_gas_price, + pending_data.l1_data_gas_price, + pending_data.sequencer, + ), + None => { + let header = storage_reader + .begin_ro_txn()? + .get_block_header(block_context_number)? + .expect("Should have block header."); + ( + header.block_number, + header.timestamp, + header.l1_gas_price, + header.l1_data_gas_price, + header.sequencer, + ) + } + }; + let ten_blocks_ago = get_10_blocks_ago(&block_context_number, cached_state)?; - Ok(BlockContext { - chain_id, - block_number, + let block_info = BlockInfo { block_timestamp, sequencer_address: sequencer_address.0, - // TODO(barak, 01/10/2023): Change strk_fee_token_address once it exists. + // TODO(yair): set to true when da mode is Blob (not supported yet). + use_kzg_da: false, + block_number, + // TODO(yair): What to do about blocks pre 0.13.1 where the data gas price were 0? + gas_prices: GasPrices { + eth_l1_gas_price: NonZeroU128::new(l1_gas_price.price_in_wei.0) + .unwrap_or(NonZeroU128::MIN), + strk_l1_gas_price: NonZeroU128::new(l1_gas_price.price_in_fri.0) + .unwrap_or(NonZeroU128::MIN), + eth_l1_data_gas_price: NonZeroU128::new(l1_data_gas_price.price_in_wei.0) + .unwrap_or(NonZeroU128::MIN), + strk_l1_data_gas_price: NonZeroU128::new(l1_data_gas_price.price_in_fri.0) + .unwrap_or(NonZeroU128::MIN), + }, + }; + let chain_info = ChainInfo { + chain_id, + // TODO(Eitan): add the correct fee token addresses to the execution config. fee_token_addresses: FeeTokenAddresses { - strk_fee_token_address: execution_config.fee_contract_address, + strk_fee_token_address: contract_address!(STRK_FEE_TOKEN_ADDRESS), eth_fee_token_address: execution_config.fee_contract_address, }, - vm_resource_fee_cost: Arc::clone(&execution_config.vm_resource_fee_cost), - invoke_tx_max_n_steps: execution_config.invoke_tx_max_n_steps, - validate_max_n_steps: execution_config.validate_tx_max_n_steps, - max_recursion_depth: execution_config.max_recursion_depth, - gas_prices: GasPrices { - eth_l1_gas_price: gas_prices.price_in_wei.0, - strk_l1_gas_price: gas_prices.price_in_fri.0, - }, - }) + }; + + // TODO(yair): set the correct versioned constants for re-execution. + let versioned_constants = VersionedConstants::latest_constants().clone(); + + Ok(pre_process_block( + cached_state, + ten_blocks_ago, + block_info, + chain_info, + versioned_constants, + )?) } /// The transaction input to be executed. @@ -467,8 +514,12 @@ pub fn estimate_fee( Err(RevertedTransaction { index, revert_reason }) } else { let gas_price = match tx_execution_output.price_unit { - PriceUnit::Wei => GasPrice(block_context.gas_prices.eth_l1_gas_price), - PriceUnit::Fri => GasPrice(block_context.gas_prices.strk_l1_gas_price), + PriceUnit::Wei => { + GasPrice(block_context.block_info().gas_prices.eth_l1_gas_price.get()) + } + PriceUnit::Fri => { + GasPrice(block_context.block_info().gas_prices.strk_l1_gas_price.get()) + } }; Ok(( gas_price, @@ -501,7 +552,19 @@ fn execute_transactions( charge_fee: bool, validate: bool, ) -> ExecutionResult<(Vec, BlockContext)> { + // The starknet state will be from right before the block in which the transactions should run. + let mut cached_state = CachedState::new( + ExecutionStateReader { + storage_reader: storage_reader.clone(), + state_number, + maybe_pending_data: maybe_pending_data.clone(), + missing_compiled_class: None, + }, + GlobalContractCache::new(GLOBAL_CONTRACT_CACHE_SIZE), + ); + let block_context = create_block_context( + &mut cached_state, block_context_block_number, chain_id.clone(), &storage_reader, @@ -509,17 +572,6 @@ fn execute_transactions( execution_config, )?; - // The starknet state will be from right before the block in which the transactions should run. - let mut cached_state = CachedState::from(ExecutionStateReader { - storage_reader, - state_number, - maybe_pending_data, - missing_compiled_class: None, - }); - - // TODO(yair): this is a temporary bug fix, delete once the blockifier is fixed and add a test. - set_block_hash_contract(state_number, &mut cached_state)?; - let (txs, tx_hashes) = match tx_hashes { Some(tx_hashes) => (txs, tx_hashes), None => { @@ -585,28 +637,23 @@ impl From<(usize, BlockifierTransactionExecutionError)> for ExecutionError { } } -/// Sets the block hash contract (contract at address 1) with the block hash of the block 10 blocks -/// ago. -fn set_block_hash_contract( - state_number: StateNumber, - cached_state: &mut CachedState, -) -> ExecutionResult<()> { - if state_number.is_after(BlockNumber(10)) { - let block_min_10 = state_number.0.0 - 10; - let header_10_blocks_ago = cached_state - .state - .storage_reader - .begin_ro_txn()? - .get_block_header(BlockNumber(block_min_10))? - .expect("State should be > 10."); - - cached_state.set_storage_at( - ContractAddress::from(1_u128), - StorageKey::from(block_min_10), - header_10_blocks_ago.block_hash.0, - ); +fn get_10_blocks_ago( + block_number: &BlockNumber, + cached_state: &CachedState, +) -> ExecutionResult> { + if block_number.0 < 10 { + return Ok(None); } - Ok(()) + let block_min_10 = BlockNumber(block_number.0 - 10); + let Some(header_10_blocks_ago) = + cached_state.state.storage_reader.begin_ro_txn()?.get_block_header(block_min_10)? + else { + return Ok(None); + }; + Ok(Some(BlockNumberHashPair { + number: header_10_blocks_ago.block_number, + hash: header_10_blocks_ago.block_hash, + })) } fn to_blockifier_tx( @@ -750,8 +797,12 @@ pub fn simulate_transactions( .map(|(tx_execution_output, trace_constructor)| { let fee = tx_execution_output.execution_info.actual_fee; let gas_price = match tx_execution_output.price_unit { - PriceUnit::Wei => GasPrice(block_context.gas_prices.eth_l1_gas_price), - PriceUnit::Fri => GasPrice(block_context.gas_prices.strk_l1_gas_price), + PriceUnit::Wei => { + GasPrice(block_context.block_info().gas_prices.eth_l1_gas_price.get()) + } + PriceUnit::Fri => { + GasPrice(block_context.block_info().gas_prices.strk_l1_gas_price.get()) + } }; match trace_constructor(tx_execution_output.execution_info) { Ok(transaction_trace) => Ok(TransactionSimulationOutput { diff --git a/crates/papyrus_execution/src/state_reader.rs b/crates/papyrus_execution/src/state_reader.rs index 7ee567021e..4142e1e543 100644 --- a/crates/papyrus_execution/src/state_reader.rs +++ b/crates/papyrus_execution/src/state_reader.rs @@ -75,12 +75,12 @@ impl BlockifierStateReader for ExecutionStateReader { fn get_compiled_contract_class( &mut self, - class_hash: &ClassHash, + class_hash: ClassHash, ) -> StateResult { if let Some(pending_casm) = self .maybe_pending_data .as_ref() - .and_then(|pending_data| pending_data.classes.get_compiled_class(*class_hash)) + .and_then(|pending_data| pending_data.classes.get_compiled_class(class_hash)) { return Ok(BlockifierContractClass::V1( ContractClassV1::try_from(pending_casm).map_err(StateError::ProgramError)?, @@ -89,7 +89,7 @@ impl BlockifierStateReader for ExecutionStateReader { if let Some(ApiContractClass::DeprecatedContractClass(pending_deprecated_class)) = self .maybe_pending_data .as_ref() - .and_then(|pending_data| pending_data.classes.get_class(*class_hash)) + .and_then(|pending_data| pending_data.classes.get_class(class_hash)) { return Ok(BlockifierContractClass::V0( ContractClassV0::try_from(pending_deprecated_class) @@ -98,13 +98,13 @@ impl BlockifierStateReader for ExecutionStateReader { } match get_contract_class( &self.storage_reader.begin_ro_txn().map_err(storage_err_to_state_err)?, - class_hash, + &class_hash, self.state_number, ) { Ok(Some(contract_class)) => Ok(contract_class), - Ok(None) => Err(StateError::UndeclaredClassHash(*class_hash)), + Ok(None) => Err(StateError::UndeclaredClassHash(class_hash)), Err(ExecutionUtilsError::CasmTableNotSynced) => { - self.missing_compiled_class = Some(*class_hash); + self.missing_compiled_class = Some(class_hash); Err(StateError::StateReadError("Casm table not fully synced".to_string())) } Err(ExecutionUtilsError::ProgramError(err)) => Err(StateError::ProgramError(err)), diff --git a/crates/papyrus_execution/src/state_reader_test.rs b/crates/papyrus_execution/src/state_reader_test.rs index 8585bef7fd..5e1d6c5cd7 100644 --- a/crates/papyrus_execution/src/state_reader_test.rs +++ b/crates/papyrus_execution/src/state_reader_test.rs @@ -149,7 +149,7 @@ fn read_state() { let class_hash_after_block_0 = state_reader0.get_class_hash_at(address0).unwrap(); assert_eq!(class_hash_after_block_0, ClassHash::default()); let compiled_contract_class_after_block_0 = - state_reader0.get_compiled_contract_class(&class_hash0); + state_reader0.get_compiled_contract_class(class_hash0); assert_matches!( compiled_contract_class_after_block_0, Err(StateError::UndeclaredClassHash(class_hash)) if class_hash == class_hash0 @@ -170,12 +170,12 @@ fn read_state() { let class_hash_after_block_1 = state_reader1.get_class_hash_at(address0).unwrap(); assert_eq!(class_hash_after_block_1, class_hash0); let compiled_contract_class_after_block_1 = - state_reader1.get_compiled_contract_class(&class_hash0).unwrap(); + state_reader1.get_compiled_contract_class(class_hash0).unwrap(); assert_eq!(compiled_contract_class_after_block_1, blockifier_casm0); // Test that if we try to get a casm and it's missing, that an error is returned and the field // `missing_compiled_class` is set to its hash - state_reader1.get_compiled_contract_class(&class_hash5).unwrap_err(); + state_reader1.get_compiled_contract_class(class_hash5).unwrap_err(); assert_eq!(state_reader1.missing_compiled_class.unwrap(), class_hash5); let state_number2 = StateNumber::right_after_block(BlockNumber(2)); @@ -219,13 +219,13 @@ fn read_state() { assert_eq!(state_reader2.get_compiled_class_hash(class_hash2).unwrap(), compiled_class_hash2); assert_eq!(state_reader2.get_nonce_at(address0).unwrap(), nonce0); assert_eq!(state_reader2.get_nonce_at(address2).unwrap(), nonce1); - assert_eq!(state_reader2.get_compiled_contract_class(&class_hash0).unwrap(), blockifier_casm0); - assert_eq!(state_reader2.get_compiled_contract_class(&class_hash2).unwrap(), blockifier_casm1); + assert_eq!(state_reader2.get_compiled_contract_class(class_hash0).unwrap(), blockifier_casm0); + assert_eq!(state_reader2.get_compiled_contract_class(class_hash2).unwrap(), blockifier_casm1); // Test that if we only got the class without the casm then an error is returned. - state_reader2.get_compiled_contract_class(&class_hash3).unwrap_err(); + state_reader2.get_compiled_contract_class(class_hash3).unwrap_err(); // Test that if the class is deprecated it is returned. assert_eq!( - state_reader2.get_compiled_contract_class(&class_hash4).unwrap(), + state_reader2.get_compiled_contract_class(class_hash4).unwrap(), BlockifierContractClass::V0(ContractClassV0::try_from(class1).unwrap()) ); diff --git a/crates/papyrus_execution/src/test_utils.rs b/crates/papyrus_execution/src/test_utils.rs index c381fafcb1..ccdc3be7af 100644 --- a/crates/papyrus_execution/src/test_utils.rs +++ b/crates/papyrus_execution/src/test_utils.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use blockifier::abi::abi_utils::get_storage_var_address; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use indexmap::indexmap; use lazy_static::lazy_static; use papyrus_storage::body::BodyStorageWriter; diff --git a/crates/papyrus_rpc/Cargo.toml b/crates/papyrus_rpc/Cargo.toml index a4d261ad7f..81428f0cc2 100644 --- a/crates/papyrus_rpc/Cargo.toml +++ b/crates/papyrus_rpc/Cargo.toml @@ -39,7 +39,7 @@ validator = { workspace = true, features = ["derive"] } [dev-dependencies] assert_matches.workspace = true cairo-lang-casm.workspace = true -cairo-lang-starknet.workspace = true +cairo-lang-starknet-classes.workspace = true camelpaste.workspace = true derive_more.workspace = true enum-iterator.workspace = true diff --git a/crates/papyrus_rpc/src/v0_4/execution_test.rs b/crates/papyrus_rpc/src/v0_4/execution_test.rs index c8df4fcef7..22bc198435 100644 --- a/crates/papyrus_rpc/src/v0_4/execution_test.rs +++ b/crates/papyrus_rpc/src/v0_4/execution_test.rs @@ -4,7 +4,7 @@ use std::path::Path; use std::sync::Arc; use assert_matches::assert_matches; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use indexmap::{indexmap, IndexMap}; use jsonrpsee::core::Error; use jsonrpsee::RpcModule; @@ -148,6 +148,12 @@ lazy_static! { overall_fee: Fee(167500000000000,), }; + pub static ref EXPECTED_FEE_ESTIMATE_SKIP_VALIDATE: FeeEstimate = FeeEstimate { + gas_consumed: stark_felt!("0x68a"), + gas_price: GAS_PRICE.price_in_wei, + overall_fee: Fee(167400000000000,), + }; + // A message from L1 contract at address 0x987 to the contract at CONTRACT_ADDRESS that calls // the entry point "l1_handle" with the value 0x123, the retdata should be 0x123. pub static ref MESSAGE_FROM_L1: MessageFromL1 = MessageFromL1 { @@ -360,7 +366,7 @@ async fn call_estimate_fee() { ], &VERSION_0_4, SpecFile::StarknetApiOpenrpc, - &vec![EXPECTED_FEE_ESTIMATE.clone()], + &vec![EXPECTED_FEE_ESTIMATE_SKIP_VALIDATE.clone()], ) .await; @@ -373,7 +379,7 @@ async fn call_estimate_fee() { ) .await .unwrap(); - assert_ne!(res, vec![EXPECTED_FEE_ESTIMATE.clone()]); + assert_ne!(res, vec![EXPECTED_FEE_ESTIMATE_SKIP_VALIDATE.clone()]); // TODO(shahak): Write a new contract and test execution info. The reason we can't do this with // the current contract is that the transaction hash appears in the calldata and thus it is @@ -414,7 +420,7 @@ async fn pending_call_estimate_fee() { ) .await .unwrap(); - assert_eq!(res, vec![EXPECTED_FEE_ESTIMATE.clone()]); + assert_eq!(res, vec![EXPECTED_FEE_ESTIMATE_SKIP_VALIDATE.clone()]); // TODO(shahak): Write a new contract and test execution info. The reason we can't do this with // the current contract is that the transaction hash appears in the calldata and thus it is @@ -571,7 +577,7 @@ async fn call_simulate_skip_validate() { let simulated_tx = res.pop().unwrap(); - assert_eq!(simulated_tx.fee_estimation, *EXPECTED_FEE_ESTIMATE); + assert_eq!(simulated_tx.fee_estimation, *EXPECTED_FEE_ESTIMATE_SKIP_VALIDATE); assert_matches!(simulated_tx.transaction_trace, TransactionTrace::Invoke(_)); diff --git a/crates/papyrus_rpc/src/v0_5/execution_test.rs b/crates/papyrus_rpc/src/v0_5/execution_test.rs index 08761c1567..16fb8059b0 100644 --- a/crates/papyrus_rpc/src/v0_5/execution_test.rs +++ b/crates/papyrus_rpc/src/v0_5/execution_test.rs @@ -4,7 +4,7 @@ use std::path::Path; use std::sync::Arc; use assert_matches::assert_matches; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use indexmap::{indexmap, IndexMap}; use jsonrpsee::core::Error; use jsonrpsee::RpcModule; @@ -136,6 +136,12 @@ lazy_static! { overall_fee: Fee(167500000000000,), }; + pub static ref EXPECTED_FEE_ESTIMATE_SKIP_VALIDATE: FeeEstimate = FeeEstimate { + gas_consumed: stark_felt!("0x68a"), + gas_price: GAS_PRICE.price_in_wei, + overall_fee: Fee(167400000000000,), + }; + // A message from L1 contract at address 0x987 to the contract at CONTRACT_ADDRESS that calls // the entry point "l1_handle" with the value 0x123, the retdata should be 0x123. pub static ref MESSAGE_FROM_L1: MessageFromL1 = MessageFromL1 { @@ -347,7 +353,7 @@ async fn call_estimate_fee() { ], &VERSION_0_5, SpecFile::StarknetApiOpenrpc, - &vec![EXPECTED_FEE_ESTIMATE.clone()], + &vec![EXPECTED_FEE_ESTIMATE_SKIP_VALIDATE.clone()], ) .await; @@ -360,7 +366,7 @@ async fn call_estimate_fee() { ) .await .unwrap(); - assert_ne!(res, vec![EXPECTED_FEE_ESTIMATE.clone()]); + assert_ne!(res, vec![EXPECTED_FEE_ESTIMATE_SKIP_VALIDATE.clone()]); // TODO(shahak): Write a new contract and test execution info. The reason we can't do this with // the current contract is that the transaction hash appears in the calldata and thus it is @@ -401,7 +407,7 @@ async fn pending_call_estimate_fee() { ) .await .unwrap(); - assert_eq!(res, vec![EXPECTED_FEE_ESTIMATE.clone()]); + assert_eq!(res, vec![EXPECTED_FEE_ESTIMATE_SKIP_VALIDATE.clone()]); // TODO(shahak): Write a new contract and test execution info. The reason we can't do this with // the current contract is that the transaction hash appears in the calldata and thus it is @@ -556,7 +562,7 @@ async fn call_simulate_skip_validate() { let simulated_tx = res.pop().unwrap(); - assert_eq!(simulated_tx.fee_estimation, *EXPECTED_FEE_ESTIMATE); + assert_eq!(simulated_tx.fee_estimation, *EXPECTED_FEE_ESTIMATE_SKIP_VALIDATE); assert_matches!(simulated_tx.transaction_trace, TransactionTrace::Invoke(_)); diff --git a/crates/papyrus_rpc/src/v0_6/execution_test.rs b/crates/papyrus_rpc/src/v0_6/execution_test.rs index da4d9096cc..4f2e36feac 100644 --- a/crates/papyrus_rpc/src/v0_6/execution_test.rs +++ b/crates/papyrus_rpc/src/v0_6/execution_test.rs @@ -4,7 +4,7 @@ use std::path::Path; use std::sync::Arc; use assert_matches::assert_matches; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use indexmap::{indexmap, IndexMap}; use jsonrpsee::core::Error; use jsonrpsee::RpcModule; @@ -138,6 +138,13 @@ lazy_static! { unit: PriceUnit::Wei, }; + pub static ref EXPECTED_FEE_ESTIMATE_SKIP_VALIDATE: FeeEstimate = FeeEstimate { + gas_consumed: stark_felt!("0x68a"), + gas_price: GAS_PRICE.price_in_wei, + overall_fee: Fee(167400000000000,), + unit: PriceUnit::Wei, + }; + // A message from L1 contract at address 0x987 to the contract at CONTRACT_ADDRESS that calls // the entry point "l1_handle" with the value 0x123, the retdata should be 0x123. pub static ref MESSAGE_FROM_L1: MessageFromL1 = MessageFromL1 { @@ -613,7 +620,7 @@ async fn call_simulate_skip_validate() { let simulated_tx = res.pop().unwrap(); - assert_eq!(simulated_tx.fee_estimation, *EXPECTED_FEE_ESTIMATE); + assert_eq!(simulated_tx.fee_estimation, *EXPECTED_FEE_ESTIMATE_SKIP_VALIDATE); assert_matches!(simulated_tx.transaction_trace, TransactionTrace::Invoke(_)); diff --git a/crates/papyrus_storage/Cargo.toml b/crates/papyrus_storage/Cargo.toml index aed783adfb..29f6bbf6be 100644 --- a/crates/papyrus_storage/Cargo.toml +++ b/crates/papyrus_storage/Cargo.toml @@ -11,8 +11,8 @@ testing = ["tempfile"] [dependencies] byteorder.workspace = true -cairo-lang-starknet.workspace = true -cairo-lang-casm.workspace = true +cairo-lang-starknet-classes.workspace = true +cairo-lang-casm = { workspace = true, features = ["parity-scale-codec"] } cairo-lang-utils.workspace = true clap.workspace = true flate2.workspace = true @@ -38,6 +38,7 @@ validator = { workspace = true, features = ["derive"] } [dev-dependencies] assert_matches.workspace = true +cairo-lang-casm = { workspace = true, features = ["parity-scale-codec", "schemars"] } camelpaste.workspace = true insta = { workspace = true, features = ["yaml"] } metrics-exporter-prometheus.workspace = true diff --git a/crates/papyrus_storage/src/compiled_class.rs b/crates/papyrus_storage/src/compiled_class.rs index ff792bb843..be212ed129 100644 --- a/crates/papyrus_storage/src/compiled_class.rs +++ b/crates/papyrus_storage/src/compiled_class.rs @@ -8,7 +8,7 @@ //! use papyrus_storage::open_storage; //! # use papyrus_storage::{db::DbConfig, StorageConfig}; //! # use starknet_api::core::ChainId; -//! use cairo_lang_starknet::casm_contract_class::CasmContractClass; +//! use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; //! use papyrus_storage::compiled_class::{CasmStorageReader, CasmStorageWriter}; //! use starknet_api::core::ClassHash; //! @@ -37,7 +37,7 @@ #[path = "compiled_class_test.rs"] mod casm_test; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use papyrus_proc_macros::latency_histogram; use starknet_api::block::BlockNumber; use starknet_api::core::ClassHash; diff --git a/crates/papyrus_storage/src/compiled_class_test.rs b/crates/papyrus_storage/src/compiled_class_test.rs index 472db34141..6ca0439402 100644 --- a/crates/papyrus_storage/src/compiled_class_test.rs +++ b/crates/papyrus_storage/src/compiled_class_test.rs @@ -1,5 +1,5 @@ use assert_matches::assert_matches; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use pretty_assertions::assert_eq; use starknet_api::core::ClassHash; use test_utils::read_json_file; diff --git a/crates/papyrus_storage/src/lib.rs b/crates/papyrus_storage/src/lib.rs index 8c1a2945c8..b01918a96a 100644 --- a/crates/papyrus_storage/src/lib.rs +++ b/crates/papyrus_storage/src/lib.rs @@ -75,7 +75,7 @@ use std::fmt::Debug; use std::sync::Arc; use body::events::EventIndex; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use db::db_stats::{DbTableStats, DbWholeStats}; use db::serialization::{Key, NoVersionValueWrapper, ValueSerde}; use db::table_types::Table; diff --git a/crates/papyrus_storage/src/serializers.rs b/crates/papyrus_storage/src/serializers.rs index 6e7d9828dd..9d1d643db3 100644 --- a/crates/papyrus_storage/src/serializers.rs +++ b/crates/papyrus_storage/src/serializers.rs @@ -10,12 +10,12 @@ use std::sync::Arc; use byteorder::BigEndian; use cairo_lang_casm::hints::Hint; -use cairo_lang_starknet::casm_contract_class::{ +use cairo_lang_starknet_classes::casm_contract_class::{ CasmContractClass, CasmContractEntryPoint, CasmContractEntryPoints, }; -use cairo_lang_starknet::NestedIntList; +use cairo_lang_starknet_classes::NestedIntList; use cairo_lang_utils::bigint::BigUintAsHex; use indexmap::IndexMap; use integer_encoding::*; diff --git a/crates/papyrus_storage/src/serializers_test.rs b/crates/papyrus_storage/src/serializers_test.rs index 8f84dc13e1..33e089783b 100644 --- a/crates/papyrus_storage/src/serializers_test.rs +++ b/crates/papyrus_storage/src/serializers_test.rs @@ -1,7 +1,7 @@ use std::fmt::Debug; use cairo_lang_casm::hints::CoreHintBase; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use pretty_assertions::assert_eq; use starknet_api::block::BlockNumber; use starknet_api::core::ContractAddress; diff --git a/crates/papyrus_storage/src/state/mod.rs b/crates/papyrus_storage/src/state/mod.rs index 91e0f8e4da..a90db3bce9 100644 --- a/crates/papyrus_storage/src/state/mod.rs +++ b/crates/papyrus_storage/src/state/mod.rs @@ -54,7 +54,7 @@ mod state_test; use std::collections::HashSet; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use indexmap::IndexMap; use papyrus_proc_macros::latency_histogram; use starknet_api::block::BlockNumber; diff --git a/crates/papyrus_storage/src/state/state_test.rs b/crates/papyrus_storage/src/state/state_test.rs index e48f327ff2..5eb6a36648 100644 --- a/crates/papyrus_storage/src/state/state_test.rs +++ b/crates/papyrus_storage/src/state/state_test.rs @@ -1,5 +1,5 @@ use assert_matches::assert_matches; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use indexmap::{indexmap, IndexMap}; use pretty_assertions::assert_eq; use starknet_api::block::BlockNumber; diff --git a/crates/papyrus_sync/Cargo.toml b/crates/papyrus_sync/Cargo.toml index 392782f6d8..ce3dfe8426 100644 --- a/crates/papyrus_sync/Cargo.toml +++ b/crates/papyrus_sync/Cargo.toml @@ -8,7 +8,7 @@ license-file.workspace = true [dependencies] async-stream.workspace = true async-trait.workspace = true -cairo-lang-starknet.workspace = true +cairo-lang-starknet-classes.workspace = true chrono.workspace = true futures-channel.workspace = true futures-util.workspace = true diff --git a/crates/papyrus_sync/src/lib.rs b/crates/papyrus_sync/src/lib.rs index 477575103a..1c09558614 100644 --- a/crates/papyrus_sync/src/lib.rs +++ b/crates/papyrus_sync/src/lib.rs @@ -14,7 +14,7 @@ use std::sync::Arc; use std::time::Duration; use async_stream::try_stream; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use chrono::{TimeZone, Utc}; use futures_util::{pin_mut, select, Stream, StreamExt}; use indexmap::IndexMap; diff --git a/crates/papyrus_sync/src/sources/central.rs b/crates/papyrus_sync/src/sources/central.rs index b43c04e18c..3df87c1c34 100644 --- a/crates/papyrus_sync/src/sources/central.rs +++ b/crates/papyrus_sync/src/sources/central.rs @@ -9,7 +9,7 @@ use std::sync::{Arc, Mutex}; use async_stream::stream; use async_trait::async_trait; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use futures::stream::BoxStream; use futures_util::StreamExt; use indexmap::IndexMap; diff --git a/crates/papyrus_sync/src/sources/central_sync_test.rs b/crates/papyrus_sync/src/sources/central_sync_test.rs index b5981a61c9..00945641b6 100644 --- a/crates/papyrus_sync/src/sources/central_sync_test.rs +++ b/crates/papyrus_sync/src/sources/central_sync_test.rs @@ -4,7 +4,7 @@ use std::time::Duration; use assert_matches::assert_matches; use async_stream::stream; use async_trait::async_trait; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use futures::StreamExt; use indexmap::IndexMap; use papyrus_common::pending_classes::{ApiContractClass, PendingClasses}; diff --git a/crates/papyrus_sync/src/sources/central_test.rs b/crates/papyrus_sync/src/sources/central_test.rs index ba5998f248..3eac7c7900 100644 --- a/crates/papyrus_sync/src/sources/central_test.rs +++ b/crates/papyrus_sync/src/sources/central_test.rs @@ -2,7 +2,7 @@ use std::num::NonZeroUsize; use std::sync::{Arc, Mutex}; use assert_matches::assert_matches; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use futures_util::pin_mut; use indexmap::{indexmap, IndexMap}; use lru::LruCache; diff --git a/crates/papyrus_sync/src/sync_test.rs b/crates/papyrus_sync/src/sync_test.rs index 116e6aba45..3ec16a8735 100644 --- a/crates/papyrus_sync/src/sync_test.rs +++ b/crates/papyrus_sync/src/sync_test.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use std::time::Duration; use assert_matches::assert_matches; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use futures_util::StreamExt; use indexmap::IndexMap; use papyrus_common::pending_classes::{ApiContractClass, PendingClasses, PendingClassesTrait}; diff --git a/crates/starknet_client/Cargo.toml b/crates/starknet_client/Cargo.toml index 31e31a1652..68faf3b75b 100644 --- a/crates/starknet_client/Cargo.toml +++ b/crates/starknet_client/Cargo.toml @@ -11,7 +11,7 @@ testing = ["enum-iterator", "mockall", "rand", "rand_chacha", "test_utils"] [dependencies] async-trait.workspace = true -cairo-lang-starknet.workspace = true +cairo-lang-starknet-classes.workspace = true enum-iterator = { workspace = true, optional = true } http.workspace = true indexmap = { workspace = true, features = ["serde"] } diff --git a/crates/starknet_client/src/reader/mod.rs b/crates/starknet_client/src/reader/mod.rs index a08180e247..7d2af953f6 100644 --- a/crates/starknet_client/src/reader/mod.rs +++ b/crates/starknet_client/src/reader/mod.rs @@ -9,7 +9,7 @@ mod starknet_feeder_gateway_client_test; use std::collections::HashMap; use async_trait::async_trait; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; #[cfg(any(feature = "testing", test))] use mockall::automock; use papyrus_common::pending_classes::ApiContractClass; diff --git a/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs b/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs index fd318272f6..daa473f7ca 100644 --- a/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs +++ b/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; use std::future::Future; use assert_matches::assert_matches; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use indexmap::indexmap; use mockito::mock; use pretty_assertions::assert_eq; diff --git a/crates/test_utils/Cargo.toml b/crates/test_utils/Cargo.toml index d7f2b0e8fd..51fdc8fbd5 100644 --- a/crates/test_utils/Cargo.toml +++ b/crates/test_utils/Cargo.toml @@ -8,7 +8,7 @@ license-file.workspace = true [features] [dependencies] -cairo-lang-starknet.workspace = true +cairo-lang-starknet-classes.workspace = true cairo-lang-casm.workspace = true cairo-lang-utils.workspace = true indexmap = { workspace = true, features = ["serde"] } diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index cec4ea71a6..c1106179e5 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs @@ -21,12 +21,12 @@ use cairo_lang_casm::operand::{ Register, ResOperand, }; -use cairo_lang_starknet::casm_contract_class::{ +use cairo_lang_starknet_classes::casm_contract_class::{ CasmContractClass, CasmContractEntryPoint, CasmContractEntryPoints, }; -use cairo_lang_starknet::NestedIntList; +use cairo_lang_starknet_classes::NestedIntList; use cairo_lang_utils::bigint::BigUintAsHex; use indexmap::IndexMap; use num_bigint::BigUint;