From 3fb6499fc975eb55a26098d93b7a5154e700ec5b Mon Sep 17 00:00:00 2001 From: maskpp Date: Wed, 2 Jul 2025 13:50:18 +0800 Subject: [PATCH] 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 --- eth/catalyst/simulated_beacon.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/eth/catalyst/simulated_beacon.go b/eth/catalyst/simulated_beacon.go index b84df9a4d6..0642d6a1ad 100644 --- a/eth/catalyst/simulated_beacon.go +++ b/eth/catalyst/simulated_beacon.go @@ -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