From 7f1ff03e850b14ef4da3feb0f410b0910251c637 Mon Sep 17 00:00:00 2001 From: Yonatan Iluz Date: Sun, 24 Nov 2024 11:49:03 +0200 Subject: [PATCH] Fix native commit. --- crates/blockifier/cairo_native | 2 +- crates/blockifier/src/versioned_constants.rs | 36 ++++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/crates/blockifier/cairo_native b/crates/blockifier/cairo_native index 564f7e2136..ebfa9a116d 160000 --- a/crates/blockifier/cairo_native +++ b/crates/blockifier/cairo_native @@ -1 +1 @@ -Subproject commit 564f7e2136e53a1e43033aefa3836b4dc591ffc1 +Subproject commit ebfa9a116d03618e90fc52773e73958b179dd775 diff --git a/crates/blockifier/src/versioned_constants.rs b/crates/blockifier/src/versioned_constants.rs index 59b63b5e6f..158ff0cbd9 100644 --- a/crates/blockifier/src/versioned_constants.rs +++ b/crates/blockifier/src/versioned_constants.rs @@ -568,23 +568,29 @@ pub struct GasCosts { impl GasCosts { pub fn get_builtin_gas_cost(&self, builtin: &BuiltinName) -> Result { - const KECCAK_BUILTIN_GAS_COST : u64 = 136189; - match *builtin { - BuiltinName::range_check => Ok(self.range_check_gas_cost), - BuiltinName::pedersen => Ok(self.pedersen_gas_cost), - BuiltinName::bitwise => Ok(self.bitwise_builtin_gas_cost), - BuiltinName::ec_op => Ok(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 => Ok(KECCAK_BUILTIN_GAS_COST), - BuiltinName::poseidon => Ok(self.poseidon_gas_cost), - BuiltinName::range_check96 => Ok(self.range_check_gas_cost), - BuiltinName::add_mod => Ok(self.add_mod_gas_cost), - BuiltinName::mul_mod => Ok(self.mul_mod_gas_cost), - BuiltinName::segment_arena => Err(GasCostsError::VirtualBuiltin), + 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::poseidon => self.poseidon_gas_cost, + BuiltinName::range_check96 => self.range_check_gas_cost, + BuiltinName::add_mod => self.add_mod_gas_cost, + BuiltinName::mul_mod => self.mul_mod_gas_cost, + BuiltinName::segment_arena => return Err(GasCostsError::VirtualBuiltin), // The following are unsupported builtins in Cairo 1 - BuiltinName::output | BuiltinName::ecdsa => Err(GasCostsError::UnsupportedBuiltinInCairo1 {builtin: *builtin,}), - } + BuiltinName::output | BuiltinName::ecdsa => { + return Err(GasCostsError::UnsupportedBuiltinInCairo1 { builtin: *builtin }) + } + }; + + Ok(gas_cost) } + pub fn get_syscall_gas_cost(&self, selector: &SyscallSelector) -> Result { match selector {