Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(blockifier): add keccak_builtin_gas_cost #2327

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading