Skip to content

Commit

Permalink
chore(blockifier): replace entry_point_gas_cost with initial_budget
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonatan-Starkware committed Dec 1, 2024
1 parent 6f268c8 commit 1b6f311
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 93 deletions.
22 changes: 9 additions & 13 deletions crates/blockifier/resources/versioned_constants_0_13_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,24 @@
"syscall_base_gas_cost": {
"step_gas_cost": 100
},
"entry_point_gas_cost": {
"entry_point_initial_budget": 1,
"step_gas_cost": 500
},
"fee_transfer_gas_cost": {
"entry_point_gas_cost": 1,
"step_gas_cost": 100
"entry_point_initial_budget": 1,
"step_gas_cost": 600
},
"transaction_gas_cost": {
"entry_point_gas_cost": 2,
"entry_point_initial_budget": 2,
"fee_transfer_gas_cost": 1,
"step_gas_cost": 100
"step_gas_cost": 1100
},
"call_contract_gas_cost": {
"syscall_base_gas_cost": 1,
"step_gas_cost": 10,
"entry_point_gas_cost": 1
"step_gas_cost": 510,
"entry_point_initial_budget": 1
},
"deploy_gas_cost": {
"syscall_base_gas_cost": 1,
"step_gas_cost": 200,
"entry_point_gas_cost": 1
"step_gas_cost": 700,
"entry_point_initial_budget": 1
},
"get_block_hash_gas_cost": {
"syscall_base_gas_cost": 1,
Expand Down Expand Up @@ -611,4 +607,4 @@
1000
]
}
}
}
20 changes: 8 additions & 12 deletions crates/blockifier/resources/versioned_constants_0_13_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,24 @@
"syscall_base_gas_cost": {
"step_gas_cost": 100
},
"entry_point_gas_cost": {
"entry_point_initial_budget": 1,
"step_gas_cost": 500
},
"fee_transfer_gas_cost": {
"entry_point_gas_cost": 1,
"step_gas_cost": 100
"entry_point_initial_budget": 1,
"step_gas_cost": 600
},
"transaction_gas_cost": {
"entry_point_gas_cost": 2,
"entry_point_initial_budget": 2,
"fee_transfer_gas_cost": 1,
"step_gas_cost": 100
"step_gas_cost": 1100
},
"call_contract_gas_cost": {
"syscall_base_gas_cost": 1,
"step_gas_cost": 10,
"entry_point_gas_cost": 1
"step_gas_cost": 510,
"entry_point_initial_budget": 1
},
"deploy_gas_cost": {
"syscall_base_gas_cost": 1,
"step_gas_cost": 200,
"entry_point_gas_cost": 1
"step_gas_cost": 700,
"entry_point_initial_budget": 1
},
"get_block_hash_gas_cost": {
"syscall_base_gas_cost": 1,
Expand Down
20 changes: 8 additions & 12 deletions crates/blockifier/resources/versioned_constants_0_13_1_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,24 @@
"syscall_base_gas_cost": {
"step_gas_cost": 100
},
"entry_point_gas_cost": {
"entry_point_initial_budget": 1,
"step_gas_cost": 500
},
"fee_transfer_gas_cost": {
"entry_point_gas_cost": 1,
"step_gas_cost": 100
"entry_point_initial_budget": 1,
"step_gas_cost": 600
},
"transaction_gas_cost": {
"entry_point_gas_cost": 2,
"entry_point_initial_budget": 2,
"fee_transfer_gas_cost": 1,
"step_gas_cost": 100
"step_gas_cost": 1100
},
"call_contract_gas_cost": {
"syscall_base_gas_cost": 1,
"step_gas_cost": 10,
"entry_point_gas_cost": 1
"step_gas_cost": 510,
"entry_point_initial_budget": 1
},
"deploy_gas_cost": {
"syscall_base_gas_cost": 1,
"step_gas_cost": 200,
"entry_point_gas_cost": 1
"step_gas_cost": 700,
"entry_point_initial_budget": 1
},
"get_block_hash_gas_cost": {
"syscall_base_gas_cost": 1,
Expand Down
20 changes: 8 additions & 12 deletions crates/blockifier/resources/versioned_constants_0_13_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,21 @@
"os_constants": {
"block_hash_contract_address": 1,
"call_contract_gas_cost": {
"entry_point_gas_cost": 1,
"step_gas_cost": 10,
"entry_point_initial_budget": 1,
"step_gas_cost": 510,
"syscall_base_gas_cost": 1
},
"constructor_entry_point_selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194",
"default_entry_point_selector": 0,
"deploy_gas_cost": {
"entry_point_gas_cost": 1,
"step_gas_cost": 200,
"entry_point_initial_budget": 1,
"step_gas_cost": 700,
"syscall_base_gas_cost": 1
},
"emit_event_gas_cost": {
"step_gas_cost": 10,
"syscall_base_gas_cost": 1
},
"entry_point_gas_cost": {
"entry_point_initial_budget": 1,
"step_gas_cost": 500
},
"entry_point_initial_budget": {
"step_gas_cost": 100
},
Expand All @@ -91,8 +87,8 @@
"error_entry_point_not_found": "ENTRYPOINT_NOT_FOUND",
"execute_entry_point_selector": "0x15d40a3d6ca2ac30f4031e42be28da9b056fef9bb7357ac5e85627ee876e5ad",
"fee_transfer_gas_cost": {
"entry_point_gas_cost": 1,
"step_gas_cost": 100
"entry_point_initial_budget": 1,
"step_gas_cost": 600
},
"get_block_hash_gas_cost": {
"step_gas_cost": 50,
Expand Down Expand Up @@ -207,9 +203,9 @@
"step_gas_cost": 100
},
"transaction_gas_cost": {
"entry_point_gas_cost": 2,
"entry_point_initial_budget": 2,
"fee_transfer_gas_cost": 1,
"step_gas_cost": 100
"step_gas_cost": 1100
},
"transfer_entry_point_selector": "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e",
"validate_declare_entry_point_selector": "0x289da278a8dc833409cabfdad1581e8e7d40e42dcaed693fa4008dcdb4963b3",
Expand Down
20 changes: 8 additions & 12 deletions crates/blockifier/resources/versioned_constants_0_13_2_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,21 @@
"os_constants": {
"block_hash_contract_address": 1,
"call_contract_gas_cost": {
"entry_point_gas_cost": 1,
"step_gas_cost": 10,
"entry_point_initial_budget": 1,
"step_gas_cost": 510,
"syscall_base_gas_cost": 1
},
"constructor_entry_point_selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194",
"default_entry_point_selector": 0,
"deploy_gas_cost": {
"entry_point_gas_cost": 1,
"step_gas_cost": 200,
"entry_point_initial_budget": 1,
"step_gas_cost": 700,
"syscall_base_gas_cost": 1
},
"emit_event_gas_cost": {
"step_gas_cost": 10,
"syscall_base_gas_cost": 1
},
"entry_point_gas_cost": {
"entry_point_initial_budget": 1,
"step_gas_cost": 500
},
"entry_point_initial_budget": {
"step_gas_cost": 100
},
Expand All @@ -91,8 +87,8 @@
"error_entry_point_not_found": "ENTRYPOINT_NOT_FOUND",
"execute_entry_point_selector": "0x15d40a3d6ca2ac30f4031e42be28da9b056fef9bb7357ac5e85627ee876e5ad",
"fee_transfer_gas_cost": {
"entry_point_gas_cost": 1,
"step_gas_cost": 100
"entry_point_initial_budget": 1,
"step_gas_cost": 600
},
"get_block_hash_gas_cost": {
"step_gas_cost": 50,
Expand Down Expand Up @@ -207,9 +203,9 @@
"step_gas_cost": 100
},
"transaction_gas_cost": {
"entry_point_gas_cost": 2,
"entry_point_initial_budget": 2,
"fee_transfer_gas_cost": 1,
"step_gas_cost": 100
"step_gas_cost": 1100
},
"transfer_entry_point_selector": "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e",
"validate_declare_entry_point_selector": "0x289da278a8dc833409cabfdad1581e8e7d40e42dcaed693fa4008dcdb4963b3",
Expand Down
20 changes: 8 additions & 12 deletions crates/blockifier/resources/versioned_constants_0_13_3.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,21 @@
"os_constants": {
"block_hash_contract_address": 1,
"call_contract_gas_cost": {
"entry_point_gas_cost": 1,
"step_gas_cost": 10,
"entry_point_initial_budget": 1,
"step_gas_cost": 510,
"syscall_base_gas_cost": 1
},
"constructor_entry_point_selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194",
"default_entry_point_selector": 0,
"deploy_gas_cost": {
"entry_point_gas_cost": 1,
"step_gas_cost": 200,
"entry_point_initial_budget": 1,
"step_gas_cost": 700,
"syscall_base_gas_cost": 1
},
"emit_event_gas_cost": {
"step_gas_cost": 10,
"syscall_base_gas_cost": 1
},
"entry_point_gas_cost": {
"entry_point_initial_budget": 1,
"step_gas_cost": 500
},
"entry_point_initial_budget": {
"step_gas_cost": 100
},
Expand All @@ -91,8 +87,8 @@
"error_entry_point_not_found": "ENTRYPOINT_NOT_FOUND",
"execute_entry_point_selector": "0x15d40a3d6ca2ac30f4031e42be28da9b056fef9bb7357ac5e85627ee876e5ad",
"fee_transfer_gas_cost": {
"entry_point_gas_cost": 1,
"step_gas_cost": 100
"entry_point_initial_budget": 1,
"step_gas_cost": 600
},
"get_block_hash_gas_cost": {
"step_gas_cost": 50,
Expand Down Expand Up @@ -207,9 +203,9 @@
"step_gas_cost": 100
},
"transaction_gas_cost": {
"entry_point_gas_cost": 2,
"entry_point_initial_budget": 2,
"fee_transfer_gas_cost": 1,
"step_gas_cost": 100
"step_gas_cost": 1100
},
"transfer_entry_point_selector": "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e",
"validate_declare_entry_point_selector": "0x289da278a8dc833409cabfdad1581e8e7d40e42dcaed693fa4008dcdb4963b3",
Expand Down
10 changes: 3 additions & 7 deletions crates/blockifier/resources/versioned_constants_0_13_4.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@
"os_constants": {
"block_hash_contract_address": 1,
"call_contract_gas_cost": {
"entry_point_gas_cost": 1,
"entry_point_initial_budget": 1,
"step_gas_cost": 860,
"range_check_gas_cost": 15
},
"constructor_entry_point_selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194",
"default_entry_point_selector": 0,
"deploy_gas_cost": {
"entry_point_gas_cost": 1,
"entry_point_initial_budget": 1,
"step_gas_cost": 1128,
"range_check_gas_cost": 18,
"pedersen_gas_cost": 7
Expand All @@ -74,10 +74,6 @@
"step_gas_cost": 100,
"range_check_gas_cost": 1
},
"entry_point_gas_cost": {
"entry_point_initial_budget": 1,
"step_gas_cost": 500
},
"entry_point_initial_budget": {
"step_gas_cost": 100
},
Expand Down Expand Up @@ -114,7 +110,7 @@
"l1_data_gas_index": 2,
"l2_gas_index": 1,
"library_call_gas_cost": {
"entry_point_gas_cost": 1,
"entry_point_initial_budget": 1,
"step_gas_cost": 836,
"range_check_gas_cost": 15
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub const REQUIRED_GAS_CALL_CONTRACT_TEST: u64 = 170370;
pub const REQUIRED_GAS_CALL_CONTRACT_TEST: u64 = 120370;
pub const REQUIRED_GAS_STORAGE_READ_WRITE_TEST: u64 = 16990;
pub const REQUIRED_GAS_GET_CLASS_HASH_AT_TEST: u64 = 7830;
pub const REQUIRED_GAS_LIBRARY_CALL_TEST: u64 = 167970;
pub const REQUIRED_GAS_LIBRARY_CALL_TEST: u64 = 117970;
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn no_constructor(cairo_version: CairoVersion) {
let deploy_call = &entry_point_call.execute_directly(&mut state).unwrap();
assert_eq!(
deploy_call.execution,
CallExecution { retdata: retdata![], gas_consumed: 205200, ..CallExecution::default() }
CallExecution { retdata: retdata![], gas_consumed: 155200, ..CallExecution::default() }
);

let deployed_contract_address = calculate_contract_address(
Expand Down Expand Up @@ -119,7 +119,7 @@ fn with_constructor(cairo_version: CairoVersion) {
let deploy_call = &entry_point_call.execute_directly(&mut state).unwrap();
assert_eq!(
deploy_call.execution,
CallExecution { retdata: retdata![], gas_consumed: 214550, ..CallExecution::default() }
CallExecution { retdata: retdata![], gas_consumed: 164550, ..CallExecution::default() }
);

let constructor_call = &deploy_call.inner_calls[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn test_library_call_assert_fails(cairo_version: CairoVersion) {
// 'ENTRYPOINT_FAILED'.
felt!("0x454e545259504f494e545f4641494c4544")
]),
gas_consumed: 150980,
gas_consumed: 100980,
failed: true,
..Default::default()
}
Expand Down Expand Up @@ -133,7 +133,7 @@ fn test_nested_library_call(cairo_version: CairoVersion) {
class_hash: Some(test_class_hash),
code_address: None,
call_type: CallType::Delegate,
initial_gas: 9998985960,
initial_gas: 9999085960,
..trivial_external_entry_point_new(test_contract)
};
let library_entry_point = CallEntryPoint {
Expand All @@ -148,12 +148,12 @@ fn test_nested_library_call(cairo_version: CairoVersion) {
class_hash: Some(test_class_hash),
code_address: None,
call_type: CallType::Delegate,
initial_gas: 9999136940,
initial_gas: 9999186940,
..trivial_external_entry_point_new(test_contract)
};
let storage_entry_point = CallEntryPoint {
calldata: calldata![felt!(key), felt!(value)],
initial_gas: 9998834320,
initial_gas: 9998984320,
..nested_storage_entry_point
};

Expand Down Expand Up @@ -243,7 +243,7 @@ fn test_nested_library_call(cairo_version: CairoVersion) {
call: main_entry_point.clone(),
execution: CallExecution {
retdata: retdata![felt!(value)],
gas_consumed: 475110,
gas_consumed: 325110,
..CallExecution::default()
},
charged_resources: main_call_resources,
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/transaction/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ fn add_kzg_da_resources_to_resources_mapping(
},
validate_gas_consumed: 4740, // The gas consumption results from parsing the input
// arguments.
execute_gas_consumed: 162080,
execute_gas_consumed: 112080,
inner_call_initial_gas: versioned_constants_for_account_testing().default_initial_gas_cost(),
},
CairoVersion::Cairo1)]
Expand Down
1 change: 0 additions & 1 deletion crates/blockifier/src/versioned_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,6 @@ pub struct GasCosts {
pub entry_point_initial_budget: u64,
pub syscall_base_gas_cost: u64,
// OS gas costs.
pub entry_point_gas_cost: u64,
pub transaction_gas_cost: u64,
// Syscall gas costs.
pub call_contract_gas_cost: u64,
Expand Down
Loading

0 comments on commit 1b6f311

Please sign in to comment.