Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b946b7a

Browse files
authored
core, miner: drop transactions from the same sender when error occurs (ethereum#27038)
This PR unifies the error handling in miner. Whenever an error occur while applying a transaction, the transaction should be regarded as invalid and all following transactions from the same sender not executable because of the nonce restriction. The only exception is the `nonceTooLow` error which is handled separately.
1 parent 230df98 commit b946b7a

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

core/state_transition.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ type Message struct {
136136
Data []byte
137137
AccessList types.AccessList
138138

139-
// When SkipAccountCheckss is true, the message nonce is not checked against the
139+
// When SkipAccountChecks is true, the message nonce is not checked against the
140140
// account nonce in state. It also disables checking that the sender is an EOA.
141141
// This field will be set to true for operations like RPC eth_call.
142142
SkipAccountChecks bool

miner/worker.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -918,37 +918,22 @@ func (w *worker) commitTransactions(env *environment, txs *types.TransactionsByP
918918

919919
logs, err := w.commitTransaction(env, tx)
920920
switch {
921-
case errors.Is(err, core.ErrGasLimitReached):
922-
// Pop the current out-of-gas transaction without shifting in the next from the account
923-
log.Trace("Gas limit exceeded for current block", "sender", from)
924-
txs.Pop()
925-
926921
case errors.Is(err, core.ErrNonceTooLow):
927922
// New head notification data race between the transaction pool and miner, shift
928923
log.Trace("Skipping transaction with low nonce", "sender", from, "nonce", tx.Nonce())
929924
txs.Shift()
930925

931-
case errors.Is(err, core.ErrNonceTooHigh):
932-
// Reorg notification data race between the transaction pool and miner, skip account =
933-
log.Trace("Skipping account with hight nonce", "sender", from, "nonce", tx.Nonce())
934-
txs.Pop()
935-
936926
case errors.Is(err, nil):
937927
// Everything ok, collect the logs and shift in the next transaction from the same account
938928
coalescedLogs = append(coalescedLogs, logs...)
939929
env.tcount++
940930
txs.Shift()
941931

942-
case errors.Is(err, types.ErrTxTypeNotSupported):
943-
// Pop the unsupported transaction without shifting in the next from the account
944-
log.Trace("Skipping unsupported transaction type", "sender", from, "type", tx.Type())
945-
txs.Pop()
946-
947932
default:
948-
// Strange error, discard the transaction and get the next in line (note, the
949-
// nonce-too-high clause will prevent us from executing in vain).
933+
// Transaction is regarded as invalid, drop all consecutive transactions from
934+
// the same sender because of `nonce-too-high` clause.
950935
log.Debug("Transaction failed, account skipped", "hash", tx.Hash(), "err", err)
951-
txs.Shift()
936+
txs.Pop()
952937
}
953938
}
954939
if !w.isRunning() && len(coalescedLogs) > 0 {

0 commit comments

Comments
 (0)