Skip to content

Commit

Permalink
chore: update resources for OS with revert log
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyalesokhin-starkware committed Sep 4, 2024
1 parent ecfcd2a commit af7290f
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 37 deletions.
28 changes: 14 additions & 14 deletions crates/blockifier/resources/versioned_constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
"os_resources": {
"execute_syscalls": {
"CallContract": {
"n_steps": 827,
"n_steps": 860,
"builtin_instance_counter": {
"range_check_builtin": 15
},
Expand All @@ -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
Expand Down Expand Up @@ -294,7 +294,7 @@
"n_memory_holes": 0
},
"LibraryCall": {
"n_steps": 818,
"n_steps": 836,
"builtin_instance_counter": {
"range_check_builtin": 15
},
Expand All @@ -308,7 +308,7 @@
"n_memory_holes": 0
},
"ReplaceClass": {
"n_steps": 98,
"n_steps": 104,
"builtin_instance_counter": {
"range_check_builtin": 1
},
Expand Down Expand Up @@ -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
},
Expand All @@ -418,7 +418,7 @@
"Declare": {
"deprecated_resources": {
"constant": {
"n_steps": 3099,
"n_steps": 3161,
"builtin_instance_counter": {
"pedersen_builtin": 16,
"range_check_builtin": 56,
Expand All @@ -434,7 +434,7 @@
},
"resources": {
"constant": {
"n_steps": 3231,
"n_steps": 3293,
"builtin_instance_counter": {
"pedersen_builtin": 4,
"range_check_builtin": 64,
Expand All @@ -452,7 +452,7 @@
"DeployAccount": {
"deprecated_resources": {
"constant": {
"n_steps": 4020,
"n_steps": 4114,
"builtin_instance_counter": {
"pedersen_builtin": 23,
"range_check_builtin": 72
Expand All @@ -469,7 +469,7 @@
},
"resources": {
"constant": {
"n_steps": 4169,
"n_steps": 4263,
"builtin_instance_counter": {
"pedersen_builtin": 11,
"range_check_builtin": 80,
Expand All @@ -489,7 +489,7 @@
"InvokeFunction": {
"deprecated_resources": {
"constant": {
"n_steps": 3769,
"n_steps": 3854,
"builtin_instance_counter": {
"pedersen_builtin": 14,
"range_check_builtin": 69
Expand All @@ -506,7 +506,7 @@
},
"resources": {
"constant": {
"n_steps": 3942,
"n_steps": 4027,
"builtin_instance_counter": {
"pedersen_builtin": 4,
"range_check_builtin": 77,
Expand All @@ -526,7 +526,7 @@
"L1Handler": {
"deprecated_resources": {
"constant": {
"n_steps": 1234,
"n_steps": 1257,
"builtin_instance_counter": {
"pedersen_builtin": 11,
"range_check_builtin": 16
Expand Down Expand Up @@ -616,4 +616,4 @@
100
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)]),
};
Expand Down Expand Up @@ -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)]),
},
Expand All @@ -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)]),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]),
};
Expand All @@ -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)]),
};
Expand Down Expand Up @@ -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)]),
};
Expand Down
10 changes: 6 additions & 4 deletions crates/blockifier/src/transaction/account_transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down
7 changes: 4 additions & 3 deletions crates/blockifier/src/transaction/execution_flavors_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/transaction/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]),
},
Expand Down Expand Up @@ -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,
};

Expand Down
8 changes: 4 additions & 4 deletions crates/papyrus_rpc/src/v0_6/execution_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,16 @@ 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: FeeEstimate = FeeEstimate {
gas_consumed: felt!("0x680"),
gas_consumed: felt!("0x681"),
gas_price: GAS_PRICE.price_in_wei,
overall_fee: Fee(166400000000000,),
overall_fee: Fee(166500000000000,),
unit: PriceUnit::Wei,
};

pub static ref EXPECTED_FEE_ESTIMATE_SKIP_VALIDATE: FeeEstimate = FeeEstimate {
gas_consumed: felt!("0x680"),
gas_consumed: felt!("0x681"),
gas_price: GAS_PRICE.price_in_wei,
overall_fee: Fee(166400000000000,),
overall_fee: Fee(166500000000000,),
unit: PriceUnit::Wei,
};

Expand Down
8 changes: 4 additions & 4 deletions crates/papyrus_rpc/src/v0_7/execution_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,20 @@ 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,
};

pub static ref EXPECTED_FEE_ESTIMATE_SKIP_VALIDATE: 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,
};

Expand Down

0 comments on commit af7290f

Please sign in to comment.