Skip to content

Commit

Permalink
refactor: rename Transaction::nonce to nonce_opt to signal that it's …
Browse files Browse the repository at this point in the history
…optional
  • Loading branch information
Wodann committed Jun 19, 2024
1 parent bd94c37 commit 9cb81da
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crates/primitives/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl<ChainSpecT: ChainSpec> Env<ChainSpecT> {
}

// Check that the transaction's nonce is correct
if let Some(tx) = self.tx.nonce() {
if let Some(tx) = self.tx.nonce_opt() {
let state = account.info.nonce;
match tx.cmp(&state) {
Ordering::Greater => {
Expand Down Expand Up @@ -639,7 +639,7 @@ impl Transaction for TxEnv {
}

#[inline]
fn nonce(&self) -> Option<u64> {
fn nonce_opt(&self) -> Option<u64> {
self.nonce
}

Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub trait Transaction {
/// Caution: If set to `None`, then nonce validation against the account's
/// nonce is skipped: [`crate::InvalidTransaction::NonceTooHigh`] and
/// [`crate::InvalidTransaction::NonceTooLow`]
fn nonce(&self) -> Option<u64>;
fn nonce_opt(&self) -> Option<u64>;
/// The chain ID of the transaction. If set to `None`, no checks are performed.
///
/// Incorporated as part of the Spurious Dragon upgrade via [EIP-155].
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ impl<ChainSpecT: ChainSpec, EXT, DB: Database> Evm<'_, ChainSpecT, EXT, DB> {
// get nonce from tx (if set) or from account (if not).
// Nonce for call is bumped in deduct_caller while
// for CREATE it is not (it is done inside exec handlers).
let nonce = ctx.evm.env.tx.nonce().unwrap_or_else(|| {
let nonce = ctx.evm.env.tx.nonce_opt().unwrap_or_else(|| {
let caller = *ctx.evm.env.tx.caller();
ctx.evm
.load_account(caller)
Expand Down
4 changes: 2 additions & 2 deletions crates/revm/src/optimism/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ impl Transaction for OptimismTransaction {
self.base.data()
}

fn nonce(&self) -> Option<u64> {
self.base.nonce()
fn nonce_opt(&self) -> Option<u64> {
self.base.nonce_opt()
}

fn chain_id(&self) -> Option<u64> {
Expand Down

0 comments on commit 9cb81da

Please sign in to comment.