Skip to content

Commit

Permalink
chore(blockifier): split builtin gas costs from base gas costs
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonatan-Starkware committed Dec 15, 2024
1 parent 723bf96 commit 9e5b0c7
Show file tree
Hide file tree
Showing 11 changed files with 161 additions and 152 deletions.
27 changes: 12 additions & 15 deletions crates/blockifier/resources/versioned_constants_0_13_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,17 @@
"default_entry_point_selector": 0,
"stored_block_hash_buffer": 10,
"step_gas_cost": 100,
"range_check_gas_cost": 70,
"keccak_builtin_gas_cost": 0,
"pedersen_gas_cost": 0,
"bitwise_builtin_gas_cost": 0,
"ecop_gas_cost": 0,
"poseidon_gas_cost": 0,
"add_mod_gas_cost": 0,
"mul_mod_gas_cost": 0,
"ecdsa_gas_cost": 0,
"builtin_gas_costs": {
"range_check_gas_cost": 70,
"keccak_builtin_gas_cost": 0,
"pedersen_gas_cost": 0,
"bitwise_builtin_gas_cost": 0,
"ecop_gas_cost": 0,
"poseidon_gas_cost": 0,
"add_mod_gas_cost": 0,
"mul_mod_gas_cost": 0,
"ecdsa_gas_cost": 0
},
"memory_hole_gas_cost": 10,
"os_contract_addresses": {
"block_hash_contract_address": 1,
Expand All @@ -101,11 +103,6 @@
"entry_point_initial_budget": 1,
"step_gas_cost": 600
},
"transaction_gas_cost": {
"entry_point_initial_budget": 2,
"fee_transfer_gas_cost": 1,
"step_gas_cost": 1100
},
"error_block_number_out_of_range": "Block number out of range",
"error_out_of_gas": "Out of gas",
"error_entry_point_failed": "ENTRYPOINT_FAILED",
Expand Down Expand Up @@ -620,4 +617,4 @@
1000
]
}
}
}
27 changes: 12 additions & 15 deletions crates/blockifier/resources/versioned_constants_0_13_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,17 @@
"default_entry_point_selector": 0,
"stored_block_hash_buffer": 10,
"step_gas_cost": 100,
"range_check_gas_cost": 70,
"keccak_builtin_gas_cost": 0,
"pedersen_gas_cost": 0,
"bitwise_builtin_gas_cost": 0,
"ecop_gas_cost": 0,
"poseidon_gas_cost": 0,
"add_mod_gas_cost": 0,
"mul_mod_gas_cost": 0,
"ecdsa_gas_cost": 0,
"builtin_gas_costs": {
"range_check_gas_cost": 70,
"keccak_builtin_gas_cost": 0,
"pedersen_gas_cost": 0,
"bitwise_builtin_gas_cost": 0,
"ecop_gas_cost": 0,
"poseidon_gas_cost": 0,
"add_mod_gas_cost": 0,
"mul_mod_gas_cost": 0,
"ecdsa_gas_cost": 0
},
"os_contract_addresses": {
"block_hash_contract_address": 1,
"alias_contract_address": 2,
Expand All @@ -101,11 +103,6 @@
"entry_point_initial_budget": 1,
"step_gas_cost": 600
},
"transaction_gas_cost": {
"entry_point_initial_budget": 2,
"fee_transfer_gas_cost": 1,
"step_gas_cost": 1100
},
"error_block_number_out_of_range": "Block number out of range",
"error_out_of_gas": "Out of gas",
"error_entry_point_failed": "ENTRYPOINT_FAILED",
Expand Down Expand Up @@ -656,4 +653,4 @@
10000
]
}
}
}
27 changes: 12 additions & 15 deletions crates/blockifier/resources/versioned_constants_0_13_1_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,17 @@
"default_entry_point_selector": 0,
"stored_block_hash_buffer": 10,
"step_gas_cost": 100,
"range_check_gas_cost": 70,
"keccak_builtin_gas_cost": 0,
"pedersen_gas_cost": 0,
"bitwise_builtin_gas_cost": 0,
"ecop_gas_cost": 0,
"poseidon_gas_cost": 0,
"add_mod_gas_cost": 0,
"mul_mod_gas_cost": 0,
"ecdsa_gas_cost": 0,
"builtin_gas_costs": {
"range_check_gas_cost": 70,
"keccak_builtin_gas_cost": 0,
"pedersen_gas_cost": 0,
"bitwise_builtin_gas_cost": 0,
"ecop_gas_cost": 0,
"poseidon_gas_cost": 0,
"add_mod_gas_cost": 0,
"mul_mod_gas_cost": 0,
"ecdsa_gas_cost": 0
},
"memory_hole_gas_cost": 10,
"os_contract_addresses": {
"block_hash_contract_address": 1,
Expand All @@ -101,11 +103,6 @@
"entry_point_initial_budget": 1,
"step_gas_cost": 600
},
"transaction_gas_cost": {
"entry_point_initial_budget": 2,
"fee_transfer_gas_cost": 1,
"step_gas_cost": 1100
},
"error_block_number_out_of_range": "Block number out of range",
"error_out_of_gas": "Out of gas",
"error_entry_point_failed": "ENTRYPOINT_FAILED",
Expand Down Expand Up @@ -656,4 +653,4 @@
10000
]
}
}
}
27 changes: 12 additions & 15 deletions crates/blockifier/resources/versioned_constants_0_13_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,23 @@
"alias_contract_address": 2,
"reserved_contract_address": 3
},
"range_check_gas_cost": 70,
"keccak_builtin_gas_cost": 0,
"pedersen_gas_cost": 0,
"bitwise_builtin_gas_cost": 594,
"ecop_gas_cost": 0,
"poseidon_gas_cost": 0,
"add_mod_gas_cost": 0,
"mul_mod_gas_cost": 0,
"ecdsa_gas_cost": 0,
"builtin_gas_costs": {
"range_check_gas_cost": 70,
"keccak_builtin_gas_cost": 0,
"pedersen_gas_cost": 0,
"bitwise_builtin_gas_cost": 594,
"ecop_gas_cost": 0,
"poseidon_gas_cost": 0,
"add_mod_gas_cost": 0,
"mul_mod_gas_cost": 0,
"ecdsa_gas_cost": 0
},
"sierra_array_len_bound": 4294967296,
"step_gas_cost": 100,
"stored_block_hash_buffer": 10,
"syscall_base_gas_cost": {
"step_gas_cost": 100
},
"transaction_gas_cost": {
"entry_point_initial_budget": 2,
"fee_transfer_gas_cost": 1,
"step_gas_cost": 1100
},
"transfer_entry_point_selector": "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e",
"validate_declare_entry_point_selector": "0x289da278a8dc833409cabfdad1581e8e7d40e42dcaed693fa4008dcdb4963b3",
"validate_deploy_entry_point_selector": "0x36fcbf06cd96843058359e1a75928beacfac10727dab22a3972f0af8aa92895",
Expand Down Expand Up @@ -663,4 +660,4 @@
10000
]
}
}
}
27 changes: 12 additions & 15 deletions crates/blockifier/resources/versioned_constants_0_13_2_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,23 @@
"alias_contract_address": 2,
"reserved_contract_address": 3
},
"range_check_gas_cost": 70,
"keccak_builtin_gas_cost": 0,
"pedersen_gas_cost": 0,
"bitwise_builtin_gas_cost": 594,
"ecop_gas_cost": 0,
"poseidon_gas_cost": 0,
"add_mod_gas_cost": 0,
"mul_mod_gas_cost": 0,
"ecdsa_gas_cost": 0,
"builtin_gas_costs": {
"range_check_gas_cost": 70,
"keccak_builtin_gas_cost": 0,
"pedersen_gas_cost": 0,
"bitwise_builtin_gas_cost": 594,
"ecop_gas_cost": 0,
"poseidon_gas_cost": 0,
"add_mod_gas_cost": 0,
"mul_mod_gas_cost": 0,
"ecdsa_gas_cost": 0
},
"sierra_array_len_bound": 4294967296,
"step_gas_cost": 100,
"stored_block_hash_buffer": 10,
"syscall_base_gas_cost": {
"step_gas_cost": 100
},
"transaction_gas_cost": {
"entry_point_initial_budget": 2,
"fee_transfer_gas_cost": 1,
"step_gas_cost": 1100
},
"transfer_entry_point_selector": "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e",
"validate_declare_entry_point_selector": "0x289da278a8dc833409cabfdad1581e8e7d40e42dcaed693fa4008dcdb4963b3",
"validate_deploy_entry_point_selector": "0x36fcbf06cd96843058359e1a75928beacfac10727dab22a3972f0af8aa92895",
Expand Down Expand Up @@ -663,4 +660,4 @@
10000
]
}
}
}
27 changes: 12 additions & 15 deletions crates/blockifier/resources/versioned_constants_0_13_3.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,23 @@
"alias_contract_address": 2,
"reserved_contract_address": 3
},
"range_check_gas_cost": 70,
"keccak_builtin_gas_cost": 0,
"pedersen_gas_cost": 0,
"bitwise_builtin_gas_cost": 594,
"ecop_gas_cost": 0,
"poseidon_gas_cost": 0,
"add_mod_gas_cost": 0,
"mul_mod_gas_cost": 0,
"ecdsa_gas_cost": 0,
"builtin_gas_costs": {
"range_check_gas_cost": 70,
"keccak_builtin_gas_cost": 0,
"pedersen_gas_cost": 0,
"bitwise_builtin_gas_cost": 594,
"ecop_gas_cost": 0,
"poseidon_gas_cost": 0,
"add_mod_gas_cost": 0,
"mul_mod_gas_cost": 0,
"ecdsa_gas_cost": 0
},
"sierra_array_len_bound": 4294967296,
"step_gas_cost": 100,
"stored_block_hash_buffer": 10,
"syscall_base_gas_cost": {
"step_gas_cost": 100
},
"transaction_gas_cost": {
"entry_point_initial_budget": 2,
"fee_transfer_gas_cost": 1,
"step_gas_cost": 1100
},
"transfer_entry_point_selector": "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e",
"validate_declare_entry_point_selector": "0x289da278a8dc833409cabfdad1581e8e7d40e42dcaed693fa4008dcdb4963b3",
"validate_deploy_entry_point_selector": "0x36fcbf06cd96843058359e1a75928beacfac10727dab22a3972f0af8aa92895",
Expand Down Expand Up @@ -663,4 +660,4 @@
10000
]
}
}
}
28 changes: 12 additions & 16 deletions crates/blockifier/resources/versioned_constants_0_13_4.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,27 +91,23 @@
"alias_contract_address": 2,
"reserved_contract_address": 3
},
"range_check_gas_cost": 70,
"keccak_builtin_gas_cost": 136189,
"pedersen_gas_cost": 4050,
"bitwise_builtin_gas_cost": 583,
"ecop_gas_cost": 4085,
"poseidon_gas_cost": 491,
"add_mod_gas_cost": 230,
"mul_mod_gas_cost": 604,
"ecdsa_gas_cost": 10561,
"builtin_gas_costs": {
"range_check_gas_cost": 70,
"keccak_builtin_gas_cost": 136189,
"pedersen_gas_cost": 4050,
"bitwise_builtin_gas_cost": 583,
"ecop_gas_cost": 4085,
"poseidon_gas_cost": 491,
"add_mod_gas_cost": 230,
"mul_mod_gas_cost": 604,
"ecdsa_gas_cost": 10561
},
"sierra_array_len_bound": 4294967296,
"step_gas_cost": 100,
"stored_block_hash_buffer": 10,
"syscall_base_gas_cost": {
"step_gas_cost": 100
},
"transaction_gas_cost": {
"step_gas_cost": 4098,
"pedersen_gas_cost": 4,
"range_check_gas_cost": 77,
"poseidon_gas_cost": 11
},
"transfer_entry_point_selector": "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e",
"validate_declare_entry_point_selector": "0x289da278a8dc833409cabfdad1581e8e7d40e42dcaed693fa4008dcdb4963b3",
"validate_deploy_entry_point_selector": "0x36fcbf06cd96843058359e1a75928beacfac10727dab22a3972f0af8aa92895",
Expand Down Expand Up @@ -666,4 +662,4 @@
10000
]
}
}
}
12 changes: 6 additions & 6 deletions crates/blockifier/src/execution/entry_point_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ fn prepare_program_extra_data(
// Create the builtin cost segment, the builtin order should be the same as the price builtin
// array in the os in compiled_class.cairo in load_compiled_class_facts.
let builtin_price_array = [
gas_costs.base.pedersen_gas_cost,
gas_costs.base.bitwise_builtin_gas_cost,
gas_costs.base.ecop_gas_cost,
gas_costs.base.poseidon_gas_cost,
gas_costs.base.add_mod_gas_cost,
gas_costs.base.mul_mod_gas_cost,
gas_costs.builtins.pedersen_gas_cost,
gas_costs.builtins.bitwise_builtin_gas_cost,
gas_costs.builtins.ecop_gas_cost,
gas_costs.builtins.poseidon_gas_cost,
gas_costs.builtins.add_mod_gas_cost,
gas_costs.builtins.mul_mod_gas_cost,
];

let data = builtin_price_array
Expand Down
12 changes: 6 additions & 6 deletions crates/blockifier/src/execution/native/entry_point_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ pub fn execute_entry_point_call(
let builtin_costs = BuiltinCosts {
// todo(rodrigo): Unsure of what value `const` means, but 1 is the right value.
r#const: 1,
pedersen: gas_costs.base.pedersen_gas_cost,
bitwise: gas_costs.base.bitwise_builtin_gas_cost,
ecop: gas_costs.base.ecop_gas_cost,
poseidon: gas_costs.base.poseidon_gas_cost,
add_mod: gas_costs.base.add_mod_gas_cost,
mul_mod: gas_costs.base.mul_mod_gas_cost,
pedersen: gas_costs.builtins.pedersen_gas_cost,
bitwise: gas_costs.builtins.bitwise_builtin_gas_cost,
ecop: gas_costs.builtins.ecop_gas_cost,
poseidon: gas_costs.builtins.poseidon_gas_cost,
add_mod: gas_costs.builtins.add_mod_gas_cost,
mul_mod: gas_costs.builtins.mul_mod_gas_cost,
};

// Grow the stack (if it's below the red zone) to handle deep Cairo recursions -
Expand Down
Loading

0 comments on commit 9e5b0c7

Please sign in to comment.