Skip to content

Commit

Permalink
chore(blockifier): add keccak_builtin_gas_cost
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonatan-Starkware committed Dec 5, 2024
1 parent 1ba00f0 commit 025870c
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"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,
Expand Down
7 changes: 2 additions & 5 deletions crates/blockifier/src/versioned_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ pub struct GasCosts {
// retrieving its price from the table.
pub range_check_gas_cost: u64,
// Priced builtins.
pub keccak_builtin_gas_cost : u64,
pub pedersen_gas_cost: u64,
pub bitwise_builtin_gas_cost: u64,
pub ecop_gas_cost: u64,
Expand Down Expand Up @@ -620,16 +621,12 @@ pub struct GasCosts {

impl GasCosts {
pub fn get_builtin_gas_cost(&self, builtin: &BuiltinName) -> Result<u64, GasCostsError> {
const KECCAK_BUILTIN_GAS_COST: u64 = 136189;

let gas_cost = match *builtin {
BuiltinName::range_check => self.range_check_gas_cost,
BuiltinName::pedersen => self.pedersen_gas_cost,
BuiltinName::bitwise => self.bitwise_builtin_gas_cost,
BuiltinName::ec_op => self.ecop_gas_cost,
// TODO (Yonatan): once keccak_builtin_gas_cost is being inserted to the versioned
// constants, replace the constant with field's value
BuiltinName::keccak => KECCAK_BUILTIN_GAS_COST,
BuiltinName::keccak => self.keccak_builtin_gas_cost,
BuiltinName::poseidon => self.poseidon_gas_cost,
BuiltinName::range_check96 => self.range_check_gas_cost,
BuiltinName::add_mod => self.add_mod_gas_cost,
Expand Down

0 comments on commit 025870c

Please sign in to comment.