Skip to content

Commit 7e4c88d

Browse files
committed
core/txpool/legacypool: handle missing head in reset ethereum#27479
1 parent 614bab0 commit 7e4c88d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/txpool/legacypool/legacypool.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,14 @@ func (pool *LegacyPool) reset(oldHead, newHead *types.Header) {
13761376
"old", oldHead.Hash(), "oldnum", oldNum, "new", newHead.Hash(), "newnum", newNum)
13771377
// We still need to update the current state s.th. the lost transactions can be readded by the user
13781378
} else {
1379+
if add == nil {
1380+
// if the new head is nil, it means that something happened between
1381+
// the firing of newhead-event and _now_: most likely a
1382+
// reorg caused by sync-reversion or explicit sethead back to an
1383+
// earlier block.
1384+
log.Warn("Transaction pool reset with missing new head", "number", newHead.Number, "hash", newHead.Hash())
1385+
return
1386+
}
13791387
for rem.NumberU64() > add.NumberU64() {
13801388
discarded = append(discarded, rem.Transactions()...)
13811389
if rem = pool.chain.GetBlock(rem.ParentHash(), rem.NumberU64()-1); rem == nil {

0 commit comments

Comments
 (0)