diff --git a/crates/native_blockifier/src/py_block_executor.rs b/crates/native_blockifier/src/py_block_executor.rs index 28c44dd716..bcd9d28d6c 100644 --- a/crates/native_blockifier/src/py_block_executor.rs +++ b/crates/native_blockifier/src/py_block_executor.rs @@ -35,9 +35,6 @@ use crate::transaction_executor::TransactionExecutor; #[path = "py_block_executor_test.rs"] mod py_block_executor_test; -const MAX_STEPS_PER_TX: u32 = 4_000_000; -const MAX_VALIDATE_STEPS_PER_TX: u32 = 1_000_000; - /// Stripped down `TransactionExecutionInfo` for Python serialization, containing only the required /// fields. #[derive(Debug, Serialize)] @@ -86,10 +83,11 @@ pub struct PyBlockExecutor { #[pymethods] impl PyBlockExecutor { #[new] - #[pyo3(signature = (general_config, validate_max_n_steps, max_recursion_depth, global_contract_cache_size, target_storage_config))] + #[pyo3(signature = (general_config, validate_max_n_steps, invoke_max_n_steps, max_recursion_depth, global_contract_cache_size, target_storage_config))] pub fn create( general_config: PyGeneralConfig, validate_max_n_steps: u32, + invoke_max_n_steps: u32, max_recursion_depth: usize, global_contract_cache_size: usize, target_storage_config: StorageConfig, @@ -97,8 +95,11 @@ impl PyBlockExecutor { log::debug!("Initializing Block Executor..."); let storage = PapyrusStorage::new(target_storage_config).expect("Failed to initialize storage"); - let versioned_constants = - versioned_constants_with_overrides(validate_max_n_steps, max_recursion_depth); + let versioned_constants = versioned_constants_with_overrides( + validate_max_n_steps, + invoke_max_n_steps, + max_recursion_depth, + ); log::debug!("Initialized Block Executor."); Self { @@ -420,17 +421,6 @@ fn pre_process_block( let old_block_number_and_hash = old_block_number_and_hash .map(|(block_number, block_hash)| BlockNumberHashPair::new(block_number, block_hash.0)); - // Input validation. - if versioned_constants.invoke_tx_max_n_steps > MAX_STEPS_PER_TX { - Err(NativeBlockifierInputError::MaxStepsPerTxOutOfRange( - versioned_constants.invoke_tx_max_n_steps, - ))?; - } else if versioned_constants.validate_max_n_steps > MAX_VALIDATE_STEPS_PER_TX { - Err(NativeBlockifierInputError::MaxValidateStepsPerTxOutOfRange( - versioned_constants.validate_max_n_steps, - ))?; - } - let (block_info, chain_info) = into_block_context_args(general_config, block_info)?; let block_context = pre_process_block_blockifier( state, diff --git a/crates/native_blockifier/src/py_utils.rs b/crates/native_blockifier/src/py_utils.rs index 32bc360256..e41c92d4b4 100644 --- a/crates/native_blockifier/src/py_utils.rs +++ b/crates/native_blockifier/src/py_utils.rs @@ -102,10 +102,12 @@ where pub fn versioned_constants_with_overrides( validate_max_n_steps: u32, + invoke_max_n_steps: u32, max_recursion_depth: usize, ) -> VersionedConstants { let mut versioned_constants = VersionedConstants::latest_constants().clone(); versioned_constants.max_recursion_depth = max_recursion_depth; versioned_constants.validate_max_n_steps = validate_max_n_steps; + versioned_constants.invoke_tx_max_n_steps = invoke_max_n_steps; versioned_constants } diff --git a/crates/native_blockifier/src/py_validator.rs b/crates/native_blockifier/src/py_validator.rs index 7eaf5b2d75..5480014f03 100644 --- a/crates/native_blockifier/src/py_validator.rs +++ b/crates/native_blockifier/src/py_validator.rs @@ -32,18 +32,22 @@ pub struct PyValidator { #[pymethods] impl PyValidator { #[new] - #[pyo3(signature = (general_config, state_reader_proxy, next_block_info, validate_max_n_steps, max_recursion_depth, global_contract_cache_size, max_nonce_for_validation_skip))] + #[pyo3(signature = (general_config, state_reader_proxy, next_block_info, validate_max_n_steps, invoke_max_n_steps, max_recursion_depth, global_contract_cache_size, max_nonce_for_validation_skip))] pub fn create( general_config: PyGeneralConfig, state_reader_proxy: &PyAny, next_block_info: PyBlockInfo, validate_max_n_steps: u32, + invoke_max_n_steps: u32, max_recursion_depth: usize, global_contract_cache_size: usize, max_nonce_for_validation_skip: PyFelt, ) -> NativeBlockifierResult { - let versioned_constants = - versioned_constants_with_overrides(validate_max_n_steps, max_recursion_depth); + let versioned_constants = versioned_constants_with_overrides( + validate_max_n_steps, + invoke_max_n_steps, + max_recursion_depth, + ); let global_contract_cache = GlobalContractCache::new(global_contract_cache_size); let state_reader = PyStateReader::new(state_reader_proxy); let state = CachedState::new(state_reader, global_contract_cache);