diff --git a/Cargo.lock b/Cargo.lock index bf3080d122..eed8fb4f9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -541,9 +541,9 @@ checksum = "3a4f925191b4367301851c6d99b09890311d74b0d43f274c0b34c86d308a3663" [[package]] name = "cairo-lang-casm" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41870f7cebe80bd143f01e6b2c56b878e91a5235e4cfdd415978679a0419c63a" +checksum = "8b03e943deaaeaa7cbec1f33121ae4f25032423c9a41cdfc7400f1b06e127f73" dependencies = [ "cairo-lang-utils", "indoc 2.0.5", @@ -555,9 +555,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e815743134ba249131df7e0dc615c129e19f03146935edec6eeb17efa0c990e" +checksum = "59e4a03eb659c903bf67604ddf284f8081a22e022b2917f6848ceb5a971ea694" dependencies = [ "anyhow", "cairo-lang-defs", @@ -579,18 +579,18 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6b021e2b4bc6603b9885cf612db5524c52f24a221f6493bc34e4e408002658" +checksum = "837a97430285c91aed314a80fa5443178f9b434ce6ffb81a87abf0b77c2f10b6" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4c21caff6d1e83bada34660877ce4a0a526c5055a5d4628bc0613852f84d251" +checksum = "43823e8c537aeb98e46fcde8be00f86aad2078e6bfa89e3acca356b56fa5646a" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -605,9 +605,9 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df4e13d42baf9a94516215ebc97ec528731118553bf85f8545a24f8eee639cd" +checksum = "726eb6b8f1337ffec205516f7135d3b71108587a15c88fa96d7041f1095b4559" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -617,9 +617,9 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e6a8fd8e66897df92b141b75051ac2faed86f0b9d25885d40e712aad319177c" +checksum = "b925889c20a789f5360eb2da4ade6837943140f555fa4ecd8000cb65633afe62" dependencies = [ "cairo-lang-utils", "good_lp", @@ -627,9 +627,9 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d0a8a9f1dd202b57111998e961b6991c96500297f7229210ef25c671f1d6b96" +checksum = "8533fa78ab2ae0235c855457f2e8674a08d30bfe83411cd9bb5165c959fdf818" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -641,9 +641,9 @@ dependencies = [ [[package]] name = "cairo-lang-formatter" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc293a771e95a62b6cda7b700bac1751c93b21939e1b0f0200973a7d54425601" +checksum = "91770d67f53f8a3dea922ddbf793982648efa24a80f2c9d38c3366a405d3716c" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -662,9 +662,9 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6947483f4ad7e988689e0f70a8abd508ab4ba01747bd218d5fe4967953fdb95" +checksum = "114c41cfb84087bf8d494a9e5e688f41808b76fd685d8ab5d3260e44d8c55a7f" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -687,9 +687,9 @@ dependencies = [ [[package]] name = "cairo-lang-parser" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "331fb4f23c3fbbb1707ef89b4b0a9cc53bd80d25a6345d54c6c3c6f5758ba515" +checksum = "03c008f31de0724197e58252439ca55f6677fbd9eba14e2d9dc7d6bf277acbc9" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -707,9 +707,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e69909f7a2f03c967bda0837e048b662a98c338e44a06b91f190f149f0e11ec" +checksum = "cf35bfc609ab6eebf44d677dbf13895124a21cd968a4b77661ae646231ca6a1d" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -726,9 +726,9 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7234af714f714b36088f47a0d6ae3b099a84af9557f139e29a4c56550f448f7d" +checksum = "9e1f9cc07f207a23d932fec65c02cb605687b66c96db2d109f704ed08eb5b1f5" dependencies = [ "cairo-lang-debug", "quote", @@ -737,9 +737,9 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1d8aa35b0b94efc42a043b064dbc3156cc1c6250e53106b36e44487fb4ec07" +checksum = "0342e3a7b6ffc3e294f13560ee738b93b8ae89f8a1c22b5bb11474a0586d9b52" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -751,9 +751,9 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9567f072c989671bcd8053e66b57b3d75ef62872755a4b68238d60505e2ef5" +checksum = "cdeca10974e4b3712d5998a611e363218e3d858c29b6e08b7aa21c28801bf77e" dependencies = [ "ark-ff", "ark-secp256k1", @@ -782,9 +782,9 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae9aa769d17c3f5878c6f53abd749996fb296470f038be502ae72ce390d9300" +checksum = "74ff271b014038dba66d1089a34d33a07ffe9ebd04d0cd72a48cc6d89a34c3b3" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -809,9 +809,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1f4eef1416c2f55c4fe186ffde3ad973097b771169cfdd1d166660f249f332d" +checksum = "630c5f2625f1bc28c2d49aa4ae83026f10d5aef078a6a0a561597022bbea9c20" dependencies = [ "anyhow", "cairo-lang-utils", @@ -837,9 +837,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92fffc29d9f21ae43137e1df4227c20409f7a2d3cde882d7cd7323fccde7337" +checksum = "7d52220c919a8780c7f8c0712af6debbcb85bd030073469ddd32be4adada087d" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -853,9 +853,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ea81b70595967d16344d0a8b586fecb44f6e86d0cc037a70e296b5129991005" +checksum = "8f0d7f5332f2a42f3af5ab2fa1070780916e5abd8f971d397bca2fa74bfce935" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -869,9 +869,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc59884047bd150f18e299ed1417768e3ad79724e2cfaf9355b543dbe5757da4" +checksum = "c997dbf2ee6ccaae8d11301b8a2b72641757edfbbbd35807e5143861028a4e5b" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -894,9 +894,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f5c2a976e426f5710421be9b9983970b94beb786bcc0f05aac75464b4bb003f" +checksum = "e9ba5d395b1e2ef05ed2c5898735df60d8ae9abab4f92c4b6f88ba79bbcafcd9" dependencies = [ "assert_matches", "cairo-lang-casm", @@ -915,9 +915,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b196da788634f0bc6e30c1ca47e973dc794e6142874b8ee261e1a030098e66a8" +checksum = "9d4ba6a52be450a3f2dc3fffe3660b76127af5b57526db7deb1cbd5a5a2a9be5" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -925,9 +925,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0e1930b4bbac1cf4b9cf7f616d2f87b76c0aa1628ebde60b3290a9f88a5d24" +checksum = "d4a76537c39673c8d22972a9ac01293f4296512d7f4d9dc357a5202e0f1e185b" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -956,9 +956,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet-classes" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef6711435b8f1ee5e9fc87da697226ee6b908b216cbaf83097b9311fe35ab57" +checksum = "fd56fec847ccd3b0a0928c5a33d8a9bab262be52f87ccc361593f0376e186700" dependencies = [ "cairo-lang-casm", "cairo-lang-sierra", @@ -980,9 +980,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "636bbb643726497151769f457bf3d014ba50e5b010a62f5849c8a4a190e64f1d" +checksum = "b209e3efbaa9889fc2aa8c0f83fc7cfd453cede0c29562fe581cb42eaff015ea" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -996,9 +996,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5cc986bacd9e82f36793deb2f007053fbf87aaf4dc792c0738d98d52a4a651b" +checksum = "7664a426d0344b98bb96d3891fd4e571eb79b561009a8db12aa7424662b50129" dependencies = [ "genco", "xshell", @@ -1006,9 +1006,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-utils" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93a406bae95cfdf8db8370f4c52a34d68dc300575d9e50ac8e645f0150b24700" +checksum = "ff1fd08b403ccdbaf9497150f9cc870627c7bf3d7450e5cb978ab7cbf1d6bccf" dependencies = [ "cairo-lang-formatter", "cairo-lang-utils", @@ -1019,9 +1019,9 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.7.0-rc.1" +version = "2.7.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc4d29b6c19ebb5ec4b3bc07f5ab300b2275abfa16a32dc5b7db17651768709c" +checksum = "794a02dfe6bcef32eb49dc0a25e8f968e644053c53481bb4245b00e6d7dbeb7c" dependencies = [ "hashbrown 0.14.5", "indexmap 2.2.6", @@ -1035,9 +1035,9 @@ dependencies = [ [[package]] name = "cairo-vm" -version = "1.0.0-rc4" +version = "1.0.0-rc5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f805c860c1f3831b93787c470e166ca762da9aba00c8b3a373076420f0e8bb2c" +checksum = "e09134ea1e0be6c1fbd330f0945df0512fa70944fd0b3ecc2f74a6008f01e9da" dependencies = [ "anyhow", "bincode", diff --git a/Cargo.toml b/Cargo.toml index 75a2444a16..103fa3da93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,11 +20,11 @@ ark-secp256k1 = "0.4.0" ark-secp256r1 = "0.4.0" assert_matches = "1.5.0" cached = "0.44.0" -cairo-lang-casm = "2.7.0-rc.1" -cairo-lang-runner = "2.7.0-rc.1" -cairo-lang-starknet-classes = "2.7.0-rc.1" -cairo-lang-utils = "2.7.0-rc.1" -cairo-vm = "1.0.0-rc4" +cairo-lang-casm = "2.7.0-rc.2" +cairo-lang-runner = "2.7.0-rc.2" +cairo-lang-starknet-classes = "2.7.0-rc.2" +cairo-lang-utils = "2.7.0-rc.2" +cairo-vm = "1.0.0-rc5" criterion = "0.3" derive_more = "0.99.17" glob = "0.3.1" diff --git a/crates/blockifier/src/concurrency/worker_logic_test.rs b/crates/blockifier/src/concurrency/worker_logic_test.rs index 28b8cac3af..1f28b1ee4f 100644 --- a/crates/blockifier/src/concurrency/worker_logic_test.rs +++ b/crates/blockifier/src/concurrency/worker_logic_test.rs @@ -3,7 +3,9 @@ use std::sync::Mutex; use rstest::rstest; use starknet_api::core::{ContractAddress, Nonce, PatriciaKey}; -use starknet_api::transaction::{ContractAddressSalt, ResourceBoundsMapping}; +use starknet_api::transaction::{ + ContractAddressSalt, Fee, ResourceBoundsMapping, TransactionVersion, +}; use starknet_api::{contract_address, felt, patricia_key}; use starknet_types_core::felt::Felt; @@ -31,7 +33,8 @@ use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::constants::DEPLOY_CONTRACT_FUNCTION_ENTRY_POINT_NAME; use crate::transaction::objects::HasRelatedFeeType; use crate::transaction::test_utils::{ - account_invoke_tx, calculate_class_info_for_testing, emit_n_events_tx, max_resource_bounds, + account_invoke_tx, calculate_class_info_for_testing, emit_n_events_tx, max_fee, + max_resource_bounds, }; use crate::transaction::transaction_execution::Transaction; use crate::{declare_tx_args, invoke_tx_args, nonce, storage_key}; @@ -525,7 +528,14 @@ fn test_worker_validate(max_resource_bounds: ResourceBoundsMapping) { } #[rstest] -fn test_deploy_before_declare(max_resource_bounds: ResourceBoundsMapping) { +#[case::declare_cairo0(CairoVersion::Cairo0, TransactionVersion::ONE)] +#[case::declare_cairo1(CairoVersion::Cairo1, TransactionVersion::THREE)] +fn test_deploy_before_declare( + max_fee: Fee, + max_resource_bounds: ResourceBoundsMapping, + #[case] cairo_version: CairoVersion, + #[case] version: TransactionVersion, +) { // Create the state. let block_context = BlockContext::create_for_account_testing(); let chain_info = &block_context.chain_info; @@ -536,7 +546,7 @@ fn test_deploy_before_declare(max_resource_bounds: ResourceBoundsMapping) { // Create transactions. let account_address_0 = account_contract.get_instance_address(0); let account_address_1 = account_contract.get_instance_address(1); - let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1); + let test_contract = FeatureContract::TestContract(cairo_version); let test_class_hash = test_contract.get_class_hash(); let test_class_info = calculate_class_info_for_testing(test_contract.get_class()); let test_compiled_class_hash = test_contract.get_compiled_class_hash(); @@ -546,6 +556,8 @@ fn test_deploy_before_declare(max_resource_bounds: ResourceBoundsMapping) { resource_bounds: max_resource_bounds.clone(), class_hash: test_class_hash, compiled_class_hash: test_compiled_class_hash, + version, + max_fee, nonce: nonce!(0_u8), }, test_class_info.clone(), @@ -555,7 +567,7 @@ fn test_deploy_before_declare(max_resource_bounds: ResourceBoundsMapping) { let invoke_tx = account_invoke_tx(invoke_tx_args! { sender_address: account_address_1, calldata: create_calldata( - account_contract.get_instance_address(0), + account_address_0, DEPLOY_CONTRACT_FUNCTION_ENTRY_POINT_NAME, &[ test_class_hash.0, // Class hash. diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index f00601020a..e21c90de2e 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -1102,6 +1102,7 @@ fn test_declare_tx( let compiled_class_hash = empty_contract.get_compiled_class_hash(); let class_info = calculate_class_info_for_testing(empty_contract.get_class()); let sender_address = account.get_instance_address(0); + let mut nonce_manager = NonceManager::default(); let starknet_resources = StarknetResources::new( 0, 0, @@ -1116,9 +1117,10 @@ fn test_declare_tx( max_fee: Fee(MAX_FEE), sender_address, version: tx_version, - resource_bounds: max_resource_bounds, + resource_bounds: max_resource_bounds.clone(), class_hash, compiled_class_hash, + nonce: nonce_manager.next(sender_address), }, class_info.clone(), ); @@ -1214,6 +1216,26 @@ fn test_declare_tx( // Verify class declaration. let contract_class_from_state = state.get_compiled_contract_class(class_hash).unwrap(); assert_eq!(contract_class_from_state, class_info.contract_class()); + + // Checks that redeclaring the same contract fails. + let account_tx2 = declare_tx( + declare_tx_args! { + max_fee: Fee(MAX_FEE), + sender_address, + version: tx_version, + resource_bounds: max_resource_bounds, + class_hash, + compiled_class_hash, + nonce: nonce_manager.next(sender_address), + }, + class_info.clone(), + ); + let result = account_tx2.execute(state, block_context, true, true); + assert_matches!( + result.unwrap_err(), + TransactionExecutionError::DeclareTransactionError{ class_hash:already_declared_class_hash } if + already_declared_class_hash == class_hash + ); } #[rstest]