Skip to content

Commit

Permalink
chore(starknet_gateway): refactor skip validate check towards early r…
Browse files Browse the repository at this point in the history
…eturn
  • Loading branch information
ArniStarkware committed Jan 14, 2025
1 parent d23aa5d commit c985ac5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion crates/blockifier/cairo_native
Submodule cairo_native updated 109 files
21 changes: 10 additions & 11 deletions crates/starknet_gateway/src/stateful_transaction_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,18 @@ impl StatefulTransactionValidator {
}
}

// Check if validation of an invoke transaction should be skipped due to deploy_account not being
// processed yet. This feature is used to improve UX for users sending deploy_account + invoke at
// once.
/// Check if validation of an invoke transaction should be skipped due to deploy_account not being
/// processed yet. This feature is used to improve UX for users sending deploy_account + invoke at
/// once.
fn skip_stateful_validations(tx: &ExecutableTransaction, account_nonce: Nonce) -> bool {
match tx {
ExecutableTransaction::Invoke(ExecutableInvokeTransaction { tx, .. }) => {
// check if the transaction nonce is 1, meaning it is post deploy_account, and the
// account nonce is zero, meaning the account was not deployed yet. The mempool also
// verifies that the deploy_account transaction exists.
tx.nonce() == Nonce(Felt::ONE) && account_nonce == Nonce(Felt::ZERO)
}
ExecutableTransaction::DeployAccount(_) | ExecutableTransaction::Declare(_) => false,
if let ExecutableTransaction::Invoke(ExecutableInvokeTransaction { tx, .. }) = tx {
// TODO(Arni): Add a verification that there is a deploy_account transaction in the mempool.
// check if the transaction nonce is 1, meaning it is post deploy_account, and the
// account nonce is zero, meaning the account was not deployed yet.
return tx.nonce() == Nonce(Felt::ONE) && account_nonce == Nonce(Felt::ZERO);
}

false
}

pub fn get_latest_block_info(
Expand Down

0 comments on commit c985ac5

Please sign in to comment.