Skip to content

Commit

Permalink
core/txpool: check authoirization nonce is not stale
Browse files Browse the repository at this point in the history
  • Loading branch information
lightclient committed Feb 7, 2025
1 parent 0c0d6b3 commit 2dc72d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/txpool/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ var (
// signed by an address which already has in-flight transactions known to the
// pool.
ErrAuthorityReserved = errors.New("authority already reserved")

// ErrAuthorityNonce is returned if a transaction has an authorization with
// a nonce that is not currently valid for the authority.
ErrAuthorityNonceTooLow = errors.New("authority nonce too low")
)
9 changes: 9 additions & 0 deletions core/txpool/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,15 @@ func ValidateTransactionWithState(tx *types.Transaction, signer types.Signer, op
return fmt.Errorf("%w: authorization conflicts with other known tx", ErrAuthorityReserved)
}
}
// Verify the every authorization's nonce is not stale. This check is expensive.
for _, auth := range tx.SetCodeAuthorizations() {
if addr, err := auth.Authority(); err == nil {
next := opts.State.GetNonce(addr)
if auth.Nonce < next {
return fmt.Errorf("%w: next nonce %d, auth nonce %d", ErrAuthorityNonceTooLow, next, auth.Nonce)
}
}
}
}
return nil
}

0 comments on commit 2dc72d5

Please sign in to comment.