core/txpool/legacypool: handle genesis state missing #28171 (#1919)

This commit is contained in:
Daniel Liu 2026-01-16 18:13:43 +08:00 committed by GitHub
parent dee0e37564
commit 86cbf4a897
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -310,7 +310,20 @@ func (pool *LegacyPool) Filter(tx *types.Transaction) bool {
func (pool *LegacyPool) Init(gasTip *big.Int, head *types.Header) error {
// Set the basic pool parameters
pool.gasTip.Store(gasTip)
pool.reset(nil, head)
// Initialize the state with head block, or fallback to empty one in
// case the head state is not available(might occur when node is not
// fully synced).
statedb, err := pool.chain.StateAt(head.Root)
if err != nil {
statedb, err = pool.chain.StateAt(types.EmptyRootHash)
}
if err != nil {
return err
}
pool.currentHead.Store(head)
pool.currentState = statedb
pool.pendingNonces = newNoncer(statedb)
// Start the reorg loop early, so it can handle requests generated during
// journal loading.