From 78a33725dae46b3a633b4ab3ff21ddc2c98f3a6c Mon Sep 17 00:00:00 2001 From: Ilya Lesokhin Date: Tue, 3 Sep 2024 10:44:41 +0300 Subject: [PATCH] chore: update resources for OS with revert log --- .../resources/versioned_constants.json | 34 +++++++++---------- .../deprecated_syscalls_test.rs | 6 ++-- .../syscalls/syscall_tests/library_call.rs | 6 ++-- .../transaction/account_transactions_test.rs | 10 +++--- .../src/transaction/execution_flavors_test.rs | 7 ++-- .../src/transaction/transactions_test.rs | 4 +-- crates/papyrus_rpc/src/v0_7/execution_test.rs | 4 +-- 7 files changed, 37 insertions(+), 34 deletions(-) diff --git a/crates/blockifier/resources/versioned_constants.json b/crates/blockifier/resources/versioned_constants.json index 4020e8d97db..eb475369071 100644 --- a/crates/blockifier/resources/versioned_constants.json +++ b/crates/blockifier/resources/versioned_constants.json @@ -194,7 +194,7 @@ "os_resources": { "execute_syscalls": { "CallContract": { - "n_steps": 827, + "n_steps": 860, "builtin_instance_counter": { "range_check_builtin": 15 }, @@ -215,7 +215,7 @@ "n_memory_holes": 0 }, "Deploy": { - "n_steps": 1099, + "n_steps": 1128, "builtin_instance_counter": { "pedersen_builtin": 7, "range_check_builtin": 18 @@ -294,7 +294,7 @@ "n_memory_holes": 0 }, "LibraryCall": { - "n_steps": 818, + "n_steps": 836, "builtin_instance_counter": { "range_check_builtin": 15 }, @@ -308,7 +308,7 @@ "n_memory_holes": 0 }, "ReplaceClass": { - "n_steps": 98, + "n_steps": 104, "builtin_instance_counter": { "range_check_builtin": 1 }, @@ -400,14 +400,14 @@ "n_memory_holes": 0 }, "StorageRead": { - "n_steps": 87, + "n_steps": 89, "builtin_instance_counter": { "range_check_builtin": 1 }, "n_memory_holes": 0 }, "StorageWrite": { - "n_steps": 89, + "n_steps": 93, "builtin_instance_counter": { "range_check_builtin": 1 }, @@ -418,7 +418,7 @@ "Declare": { "deprecated_resources": { "constant": { - "n_steps": 3099, + "n_steps": 3161, "builtin_instance_counter": { "pedersen_builtin": 16, "range_check_builtin": 56, @@ -434,10 +434,10 @@ }, "resources": { "constant": { - "n_steps": 3231, + "n_steps": 3254, "builtin_instance_counter": { "pedersen_builtin": 4, - "range_check_builtin": 64, + "range_check_builtin": 61, "poseidon_builtin": 14 }, "n_memory_holes": 0 @@ -452,7 +452,7 @@ "DeployAccount": { "deprecated_resources": { "constant": { - "n_steps": 4020, + "n_steps": 4114, "builtin_instance_counter": { "pedersen_builtin": 23, "range_check_builtin": 72 @@ -469,10 +469,10 @@ }, "resources": { "constant": { - "n_steps": 4169, + "n_steps": 4224, "builtin_instance_counter": { "pedersen_builtin": 11, - "range_check_builtin": 80, + "range_check_builtin": 77, "poseidon_builtin": 10 }, "n_memory_holes": 0 @@ -489,7 +489,7 @@ "InvokeFunction": { "deprecated_resources": { "constant": { - "n_steps": 3769, + "n_steps": 3854, "builtin_instance_counter": { "pedersen_builtin": 14, "range_check_builtin": 69 @@ -506,10 +506,10 @@ }, "resources": { "constant": { - "n_steps": 3942, + "n_steps": 3988, "builtin_instance_counter": { "pedersen_builtin": 4, - "range_check_builtin": 77, + "range_check_builtin": 74, "poseidon_builtin": 11 }, "n_memory_holes": 0 @@ -526,7 +526,7 @@ "L1Handler": { "deprecated_resources": { "constant": { - "n_steps": 1234, + "n_steps": 1257, "builtin_instance_counter": { "pedersen_builtin": 11, "range_check_builtin": 16 @@ -616,4 +616,4 @@ 100 ] } -} \ No newline at end of file +} diff --git a/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs b/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs index 53722c921f5..c0489043fe0 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs @@ -151,7 +151,7 @@ fn test_nested_library_call() { ..nested_storage_entry_point }; let storage_entry_point_resources = ExecutionResources { - n_steps: 218, + n_steps: 224, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(BuiltinName::range_check, 2)]), }; @@ -243,7 +243,7 @@ fn test_call_contract() { }, execution: expected_execution.clone(), resources: ExecutionResources { - n_steps: 218, + n_steps: 224, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(BuiltinName::range_check, 2)]), }, @@ -262,7 +262,7 @@ fn test_call_contract() { execution: expected_execution, resources: &get_syscall_resources(DeprecatedSyscallSelector::CallContract) + &ExecutionResources { - n_steps: 257, + n_steps: 263, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(BuiltinName::range_check, 3)]), }, diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs index 81b8684c300..79997176b6d 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs @@ -138,7 +138,7 @@ fn test_nested_library_call(test_contract: FeatureContract, expected_gas: u64) { }; let storage_entry_point_resources = ExecutionResources { - n_steps: 243, + n_steps: 249, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(BuiltinName::range_check, 7)]), }; @@ -157,7 +157,7 @@ fn test_nested_library_call(test_contract: FeatureContract, expected_gas: u64) { let library_call_resources = &get_syscall_resources(SyscallSelector::LibraryCall) + &ExecutionResources { - n_steps: 388, + n_steps: 394, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(BuiltinName::range_check, 15)]), }; @@ -188,7 +188,7 @@ fn test_nested_library_call(test_contract: FeatureContract, expected_gas: u64) { let main_call_resources = &(&get_syscall_resources(SyscallSelector::LibraryCall) * 3) + &ExecutionResources { - n_steps: 749, + n_steps: 761, n_memory_holes: 2, builtin_instance_counter: HashMap::from([(BuiltinName::range_check, 27)]), }; diff --git a/crates/blockifier/src/transaction/account_transactions_test.rs b/crates/blockifier/src/transaction/account_transactions_test.rs index 82faa7eacaf..2cf06030123 100644 --- a/crates/blockifier/src/transaction/account_transactions_test.rs +++ b/crates/blockifier/src/transaction/account_transactions_test.rs @@ -110,7 +110,7 @@ fn test_circuit(block_context: BlockContext, max_resource_bounds: DeprecatedReso .unwrap(); assert!(tx_execution_info.revert_error.is_none()); - assert_eq!(tx_execution_info.receipt.gas, GasVector::from_l1_gas(6688)); + assert_eq!(tx_execution_info.receipt.gas, GasVector::from_l1_gas(6806)); } #[rstest] @@ -152,7 +152,7 @@ fn test_rc96_holes( [&BuiltinName::range_check96], 24 ); - assert_eq!(tx_execution_info.receipt.gas, GasVector::from_l1_gas(6604)); + assert_eq!(tx_execution_info.receipt.gas, GasVector::from_l1_gas(6722)); } #[rstest] @@ -292,7 +292,7 @@ fn test_infinite_recursion( max_resource_bounds: DeprecatedResourceBoundsMapping, ) { // Limit the number of execution steps (so we quickly hit the limit). - block_context.versioned_constants.invoke_tx_max_n_steps = 4100; + block_context.versioned_constants.invoke_tx_max_n_steps = 4200; let TestInitData { mut state, account_address, contract_address, mut nonce_manager } = create_test_init_data(&block_context.chain_info, CairoVersion::Cairo0); @@ -702,7 +702,7 @@ fn test_reverted_reach_steps_limit( create_test_init_data(&block_context.chain_info, cairo_version); // Limit the number of execution steps (so we quickly hit the limit). - block_context.versioned_constants.invoke_tx_max_n_steps = 5000; + block_context.versioned_constants.invoke_tx_max_n_steps = 6000; let recursion_base_args = invoke_tx_args! { max_fee, resource_bounds: max_resource_bounds, @@ -771,6 +771,8 @@ fn test_reverted_reach_steps_limit( // Make sure that the failed transaction gets charged for the extra steps taken, compared with // the smaller valid transaction. + + // If this fail, try to increase the `invoke_tx_max_n_steps` above. assert!(n_steps_fail > n_steps_1); assert!(actual_fee_fail > actual_fee_1); diff --git a/crates/blockifier/src/transaction/execution_flavors_test.rs b/crates/blockifier/src/transaction/execution_flavors_test.rs index 608feac8920..38711bd1935 100644 --- a/crates/blockifier/src/transaction/execution_flavors_test.rs +++ b/crates/blockifier/src/transaction/execution_flavors_test.rs @@ -474,10 +474,10 @@ fn test_simulate_validate_charge_fee_mid_execution( // Second scenario: limit resources via sender bounds. Should revert if and only if step limit // is derived from sender bounds (`charge_fee` mode). - let (gas_bound, fee_bound) = gas_and_fee(6001, validate, &fee_type); + let (gas_bound, fee_bound) = gas_and_fee(6047, validate, &fee_type); // If `charge_fee` is true, execution is limited by sender bounds, so less resources will be // used. Otherwise, execution is limited by block bounds, so more resources will be used. - let (limited_gas_used, limited_fee) = gas_and_fee(7653, validate, &fee_type); + let (limited_gas_used, limited_fee) = gas_and_fee(7699, validate, &fee_type); let (unlimited_gas_used, unlimited_fee) = gas_and_fee( u64_from_usize( get_syscall_resources(SyscallSelector::CallContract).n_steps @@ -651,7 +651,7 @@ fn test_simulate_validate_charge_fee_post_execution( u64_from_usize( get_syscall_resources(SyscallSelector::CallContract).n_steps + get_tx_resources(TransactionType::InvokeFunction).n_steps - + 4244, + + 4268, ), validate, &fee_type, @@ -685,6 +685,7 @@ fn test_simulate_validate_charge_fee_post_execution( .execute(&mut state, &block_context, charge_fee, validate) .unwrap(); assert_eq!(tx_execution_info.is_reverted(), charge_fee); + if charge_fee { assert!( tx_execution_info diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index f52e7444386..e151866b952 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -1857,7 +1857,7 @@ fn test_l1_handler(#[values(false, true)] use_kzg_da: bool) { ..Default::default() }, resources: ExecutionResources { - n_steps: 154, + n_steps: 158, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(BuiltinName::range_check, 6)]), }, @@ -1893,7 +1893,7 @@ fn test_l1_handler(#[values(false, true)] use_kzg_da: bool) { + 6, ), ]), - n_steps: get_tx_resources(TransactionType::L1Handler).n_steps + 167, + n_steps: get_tx_resources(TransactionType::L1Handler).n_steps + 171, n_memory_holes: 0, }; diff --git a/crates/papyrus_rpc/src/v0_7/execution_test.rs b/crates/papyrus_rpc/src/v0_7/execution_test.rs index 107af2f353b..045453df63f 100644 --- a/crates/papyrus_rpc/src/v0_7/execution_test.rs +++ b/crates/papyrus_rpc/src/v0_7/execution_test.rs @@ -171,11 +171,11 @@ lazy_static! { // TODO(yair): verify this is the correct fee, got this value by printing the result of the // call. pub static ref EXPECTED_FEE_ESTIMATE: FeeEstimation = FeeEstimation { - gas_consumed: felt!("0x680"), + gas_consumed: felt!("0x681"), gas_price: GAS_PRICE.price_in_wei, data_gas_consumed: Felt::ZERO, data_gas_price: DATA_GAS_PRICE.price_in_wei, - overall_fee: Fee(166400000000000,), + overall_fee: Fee(166500000000000,), unit: PriceUnit::Wei, };