From 4fa0280a1fcf5f9bff04f29996ff80971b3941c8 Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Mon, 11 Nov 2024 20:29:54 +0200 Subject: [PATCH] chore: remove redundent function latest_constants_with_overrides --- crates/blockifier/src/versioned_constants.rs | 8 -------- .../gateway/src/stateful_transaction_validator.rs | 14 +++++++++----- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/crates/blockifier/src/versioned_constants.rs b/crates/blockifier/src/versioned_constants.rs index 0e1d9c14204..5fb29cd5734 100644 --- a/crates/blockifier/src/versioned_constants.rs +++ b/crates/blockifier/src/versioned_constants.rs @@ -301,14 +301,6 @@ impl VersionedConstants { Self { vm_resource_fee_cost, archival_data_gas_costs, ..latest } } - // TODO(Arni): Share code with latest_with_overrides. - pub fn latest_constants_with_overrides( - validate_max_n_steps: u32, - max_recursion_depth: usize, - ) -> Self { - Self { validate_max_n_steps, max_recursion_depth, ..Self::latest_constants().clone() } - } - // TODO(Arni): Consider replacing each call to this function with `latest_with_overrides`, and // squashing the functions together. /// Returns the latest versioned constants, applying the given overrides. diff --git a/crates/gateway/src/stateful_transaction_validator.rs b/crates/gateway/src/stateful_transaction_validator.rs index 6384ab039d1..f882b92b804 100644 --- a/crates/gateway/src/stateful_transaction_validator.rs +++ b/crates/gateway/src/stateful_transaction_validator.rs @@ -7,7 +7,7 @@ use blockifier::bouncer::BouncerConfig; use blockifier::context::{BlockContext, ChainInfo}; use blockifier::state::cached_state::CachedState; use blockifier::transaction::account_transaction::AccountTransaction; -use blockifier::versioned_constants::VersionedConstants; +use blockifier::versioned_constants::{VersionedConstants, VersionedConstantsOverrides}; #[cfg(test)] use mockall::automock; use starknet_api::core::{ContractAddress, Nonce}; @@ -95,10 +95,14 @@ impl StatefulTransactionValidator { let latest_block_info = get_latest_block_info(state_reader_factory)?; let state_reader = state_reader_factory.get_state_reader(latest_block_info.block_number); let state = CachedState::new(state_reader); - let versioned_constants = VersionedConstants::latest_constants_with_overrides( - self.config.validate_max_n_steps, - self.config.max_recursion_depth, - ); + // TODO(Arni): Set versioned constants overrieds as part of the validate config. + let versioned_constants_overrides = VersionedConstantsOverrides { + validate_max_n_steps: self.config.validate_max_n_steps, + max_recursion_depth: self.config.max_recursion_depth, + ..Default::default() + }; + let versioned_constants = + VersionedConstants::get_versioned_constants(versioned_constants_overrides); let mut block_info = latest_block_info; block_info.block_number = block_info.block_number.unchecked_next(); // TODO(yael 21/4/24): create the block context using pre_process_block once we will be