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 1, 2024
1 parent bb1a527 commit e041eaa
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 @@ -73,6 +73,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 @@ -73,6 +73,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 @@ -73,6 +73,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 @@ -122,6 +122,7 @@
"memory_hole_gas_cost": 10,
"nop_entry_point_offset": -1,
"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 @@ -122,6 +122,7 @@
"memory_hole_gas_cost": 10,
"nop_entry_point_offset": -1,
"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 @@ -122,6 +122,7 @@
"memory_hole_gas_cost": 10,
"nop_entry_point_offset": -1,
"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 @@ -123,6 +123,7 @@
"memory_hole_gas_cost": 10,
"nop_entry_point_offset": -1,
"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 @@ -571,6 +571,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 @@ -614,16 +615,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 e041eaa

Please sign in to comment.