eth/catalyst: fix edge case in simulated backend (#31871)

geth cmd: `geth --dev --dev.period 5`
call: `debug.setHead` to rollback several blocks.

If the `debug.setHead` call is delayed, it will trigger a panic with a
small probability, due to using the null point of
`fcResponse.PayloadID`.

---------

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
This commit is contained in:
maskpp 2025-07-02 13:50:18 +08:00 committed by GitHub
parent 62a17fdb25
commit 3fb6499fc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -208,6 +208,12 @@ func (c *SimulatedBeacon) sealBlock(withdrawals []*types.Withdrawal, timestamp u
return errors.New("chain rewind prevented invocation of payload creation")
}
// If the payload was already known, we can skip the rest of the process.
// This edge case is possible due to a race condition between seal and debug.setHead.
if fcResponse.PayloadStatus.Status == engine.VALID && fcResponse.PayloadID == nil {
return nil
}
envelope, err := c.engineAPI.getPayload(*fcResponse.PayloadID, true)
if err != nil {
return err