Skip to content

Commit

Permalink
chore(blockifier): remove charge fee flag from stateful validation
Browse files Browse the repository at this point in the history
  • Loading branch information
meship-starkware committed Aug 8, 2024
1 parent 68fa35c commit 05b760b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions crates/blockifier/src/blockifier/stateful_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ impl<S: StateReader> StatefulValidator<S> {
&mut self,
tx: AccountTransaction,
skip_validate: bool,
charge_fee: bool,
) -> StatefulValidatorResult<()> {
// Deploy account transactions should be fully executed, since the constructor must run
// before `__validate_deploy__`. The execution already includes all necessary validations,
// so they are skipped here.
if let AccountTransaction::DeployAccount(_) = tx {
self.execute(tx, charge_fee)?;
self.execute(tx)?;
return Ok(());
}

Expand All @@ -84,8 +83,8 @@ impl<S: StateReader> StatefulValidator<S> {
Ok(())
}

fn execute(&mut self, tx: AccountTransaction, charge_fee: bool) -> StatefulValidatorResult<()> {
self.tx_executor.execute(&Transaction::AccountTransaction(tx), charge_fee)?;
fn execute(&mut self, tx: AccountTransaction) -> StatefulValidatorResult<()> {
self.tx_executor.execute(&Transaction::AccountTransaction(tx), true)?;
Ok(())
}

Expand All @@ -98,7 +97,7 @@ impl<S: StateReader> StatefulValidator<S> {
// Run pre-validation in charge fee mode to perform fee and balance related checks.
// TODO (Meshi, 1/10/2024): When resource bound is supported in FaultyAccountTxCreatorArgs
// Change charge_fee to true.
let charge_fee = tx_context.tx_info.enforce_fee().unwrap();
let charge_fee = true;
tx.perform_pre_validation_stage(
self.tx_executor.block_state.as_mut().expect(BLOCK_STATE_ACCESS_ERR),
tx_context,
Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/blockifier/stateful_validator_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn test_transaction_validator(
// Test the stateful validator.
let mut stateful_validator = StatefulValidator::create(state, block_context);

let result = stateful_validator.perform_validations(tx, false, true);
let result = stateful_validator.perform_validations(tx, false);
assert!(result.is_ok(), "Validation failed: {:?}", result.unwrap_err());
}

Expand All @@ -96,6 +96,6 @@ fn test_transaction_validator_skip_validate(max_resource_bounds: ResourceBoundsM

let mut stateful_validator = StatefulValidator::create(state, block_context);
// The transaction validations should be skipped and the function should return Ok.
let result = stateful_validator.perform_validations(tx, true, true);
let result = stateful_validator.perform_validations(tx, true);
assert_matches!(result, Ok(()));
}
2 changes: 1 addition & 1 deletion crates/gateway/src/stateful_transaction_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl StatefulTransactionValidatorTrait for BlockifierStatefulValidator {
account_tx: AccountTransaction,
skip_validate: bool,
) -> BlockifierStatefulValidatorResult<()> {
self.perform_validations(account_tx, skip_validate, true)
self.perform_validations(account_tx, skip_validate)
}

fn get_nonce(
Expand Down
2 changes: 1 addition & 1 deletion crates/native_blockifier/src/py_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl PyValidator {
// processed.
let skip_validate = self
.skip_validate_due_to_unprocessed_deploy_account(&account_tx, deploy_account_tx_hash)?;
self.stateful_validator.perform_validations(account_tx, skip_validate, true)?;
self.stateful_validator.perform_validations(account_tx, skip_validate)?;

Ok(())
}
Expand Down

0 comments on commit 05b760b

Please sign in to comment.