Skip to content

Commit 2dc72d5

Browse files
committed
core/txpool: check authoirization nonce is not stale
1 parent 0c0d6b3 commit 2dc72d5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

core/txpool/errors.go

+4
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,8 @@ var (
6565
// signed by an address which already has in-flight transactions known to the
6666
// pool.
6767
ErrAuthorityReserved = errors.New("authority already reserved")
68+
69+
// ErrAuthorityNonce is returned if a transaction has an authorization with
70+
// a nonce that is not currently valid for the authority.
71+
ErrAuthorityNonceTooLow = errors.New("authority nonce too low")
6872
)

core/txpool/validation.go

+9
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,15 @@ func ValidateTransactionWithState(tx *types.Transaction, signer types.Signer, op
284284
return fmt.Errorf("%w: authorization conflicts with other known tx", ErrAuthorityReserved)
285285
}
286286
}
287+
// Verify the every authorization's nonce is not stale. This check is expensive.
288+
for _, auth := range tx.SetCodeAuthorizations() {
289+
if addr, err := auth.Authority(); err == nil {
290+
next := opts.State.GetNonce(addr)
291+
if auth.Nonce < next {
292+
return fmt.Errorf("%w: next nonce %d, auth nonce %d", ErrAuthorityNonceTooLow, next, auth.Nonce)
293+
}
294+
}
295+
}
287296
}
288297
return nil
289298
}

0 commit comments

Comments
 (0)