Skip to content

Commit

Permalink
Skip post verification check in StatefulValidator validation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy committed Oct 13, 2024
1 parent dd69217 commit d6951f2
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions crates/blockifier/src/blockifier/stateful_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,18 @@ impl<S: StateReader> StatefulValidator<S> {
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.
Expand Down Expand Up @@ -140,15 +147,24 @@ impl<S: StateReader> StatefulValidator<S> {
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<CallInfo>, 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,
Expand Down

0 comments on commit d6951f2

Please sign in to comment.