From d6951f24fc2082c7aa89cdbc063648915b131d74 Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Sun, 13 Oct 2024 19:00:51 -0400 Subject: [PATCH] Skip post verification check in `StatefulValidator` validation logic --- .../src/blockifier/stateful_validator.rs | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/crates/blockifier/src/blockifier/stateful_validator.rs b/crates/blockifier/src/blockifier/stateful_validator.rs index 39d41a668cc..ecd08d11067 100644 --- a/crates/blockifier/src/blockifier/stateful_validator.rs +++ b/crates/blockifier/src/blockifier/stateful_validator.rs @@ -88,11 +88,18 @@ impl StatefulValidator { if validate { // `__validate__` call. let versioned_constants = &tx_context.block_context.versioned_constants(); - let (_optional_call_info, actual_cost) = - self.validate(&tx, versioned_constants.tx_initial_gas())?; - // Post validations. - PostValidationReport::verify(&tx_context, &actual_cost)?; + // On fee-disabled mode, we don't need to worry about transaction running out of resources + // error as we will allocate max resources for the transaction to run with. + let (_optional_call_info, actual_cost) = + self.validate(&tx, versioned_constants.tx_initial_gas(), fee_check)?; + + // We will only do the post validation if we're running in fee-enabled mode. As it + // verifies that the actual cost of validation is within sender bounds (ie tx max fee). + if !skip_fee_check { + // Post validations. + PostValidationReport::verify(&tx_context, &actual_cost)?; + } } // See similar comment in `run_revertible` for context. @@ -140,15 +147,24 @@ impl StatefulValidator { Ok(()) } + /// Katana patch: + /// + /// We added a new parameter `limit_steps_by_resources` to the `validate` method. This is to + /// toggle between fee-enabled and disabled modes. + /// + /// In fee-enabled mode, we limit the number of steps based on the transaction resources + /// (ie max fee). In fee-disabled mode, ie `limit_steps_by_resources = false`, the execution + /// resources will be set to maximum number of steps allowed. See [`EntryPointExecution::max_steps`]. fn validate( &mut self, tx: &AccountTransaction, mut remaining_gas: u64, + limit_steps_by_resources: bool, ) -> StatefulValidatorResult<(Option, TransactionReceipt)> { let mut execution_resources = ExecutionResources::default(); let tx_context = Arc::new(self.tx_executor.block_context.to_tx_context(tx)); - let limit_steps_by_resources = true; + // let limit_steps_by_resources = true; let validate_call_info = tx.validate_tx( self.tx_executor.block_state.as_mut().expect(BLOCK_STATE_ACCESS_ERR), &mut execution_resources,