From 025870c60d44a9a848a05b3278bc5bee8e69f6c8 Mon Sep 17 00:00:00 2001 From: Yonatan-Starkware Date: Thu, 28 Nov 2024 11:52:28 +0200 Subject: [PATCH] chore(blockifier): add keccak_builtin_gas_cost --- .../blockifier/resources/versioned_constants_0_13_0.json | 1 + .../blockifier/resources/versioned_constants_0_13_1.json | 1 + .../blockifier/resources/versioned_constants_0_13_1_1.json | 1 + .../blockifier/resources/versioned_constants_0_13_2.json | 1 + .../blockifier/resources/versioned_constants_0_13_2_1.json | 1 + .../blockifier/resources/versioned_constants_0_13_3.json | 1 + .../blockifier/resources/versioned_constants_0_13_4.json | 1 + crates/blockifier/src/versioned_constants.rs | 7 ++----- 8 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/blockifier/resources/versioned_constants_0_13_0.json b/crates/blockifier/resources/versioned_constants_0_13_0.json index ca4b3ff356d..c191ca22beb 100644 --- a/crates/blockifier/resources/versioned_constants_0_13_0.json +++ b/crates/blockifier/resources/versioned_constants_0_13_0.json @@ -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, diff --git a/crates/blockifier/resources/versioned_constants_0_13_1.json b/crates/blockifier/resources/versioned_constants_0_13_1.json index e858521cd18..83d93313ec0 100644 --- a/crates/blockifier/resources/versioned_constants_0_13_1.json +++ b/crates/blockifier/resources/versioned_constants_0_13_1.json @@ -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, diff --git a/crates/blockifier/resources/versioned_constants_0_13_1_1.json b/crates/blockifier/resources/versioned_constants_0_13_1_1.json index 0d139c39dfe..9aa8d6fda80 100644 --- a/crates/blockifier/resources/versioned_constants_0_13_1_1.json +++ b/crates/blockifier/resources/versioned_constants_0_13_1_1.json @@ -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, diff --git a/crates/blockifier/resources/versioned_constants_0_13_2.json b/crates/blockifier/resources/versioned_constants_0_13_2.json index 9e34c5d31d2..0507b89dbca 100644 --- a/crates/blockifier/resources/versioned_constants_0_13_2.json +++ b/crates/blockifier/resources/versioned_constants_0_13_2.json @@ -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, diff --git a/crates/blockifier/resources/versioned_constants_0_13_2_1.json b/crates/blockifier/resources/versioned_constants_0_13_2_1.json index 4e6dac10154..cb9329524b5 100644 --- a/crates/blockifier/resources/versioned_constants_0_13_2_1.json +++ b/crates/blockifier/resources/versioned_constants_0_13_2_1.json @@ -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, diff --git a/crates/blockifier/resources/versioned_constants_0_13_3.json b/crates/blockifier/resources/versioned_constants_0_13_3.json index 4e6dac10154..cb9329524b5 100644 --- a/crates/blockifier/resources/versioned_constants_0_13_3.json +++ b/crates/blockifier/resources/versioned_constants_0_13_3.json @@ -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, diff --git a/crates/blockifier/resources/versioned_constants_0_13_4.json b/crates/blockifier/resources/versioned_constants_0_13_4.json index 608541b977f..893d077ae9f 100644 --- a/crates/blockifier/resources/versioned_constants_0_13_4.json +++ b/crates/blockifier/resources/versioned_constants_0_13_4.json @@ -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, diff --git a/crates/blockifier/src/versioned_constants.rs b/crates/blockifier/src/versioned_constants.rs index 75ea2e9673c..41de09c08cd 100644 --- a/crates/blockifier/src/versioned_constants.rs +++ b/crates/blockifier/src/versioned_constants.rs @@ -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, @@ -620,16 +621,12 @@ pub struct GasCosts { impl GasCosts { pub fn get_builtin_gas_cost(&self, builtin: &BuiltinName) -> Result { - 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,