From e5700818ad253c2c52018379b8734ec4b78a9f62 Mon Sep 17 00:00:00 2001 From: Edmund Noble Date: Wed, 16 Apr 2025 11:14:44 -0400 Subject: [PATCH] Allow rewinds for Kadena chains --- eth/catalyst/api.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index e6f29c970b..6d14f86135 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -377,20 +377,16 @@ func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payl PayloadID: id, } } - if rawdb.ReadCanonicalHash(api.eth.ChainDb(), block.NumberU64()) != update.HeadBlockHash { + if api.eth.BlockChain().CurrentBlock().Hash() == update.HeadBlockHash { + // If the specified head matches with our local head, do nothing and keep + // generating the payload. It's a special corner case that a few slots are + // missing and we are requested to generate the payload in slot. + } + else { // Block is not canonical, set head. if latestValid, err := api.eth.BlockChain().SetCanonical(block); err != nil { return engine.ForkChoiceResponse{PayloadStatus: engine.PayloadStatusV1{Status: engine.INVALID, LatestValidHash: &latestValid}}, err } - } else if api.eth.BlockChain().CurrentBlock().Hash() == update.HeadBlockHash { - // If the specified head matches with our local head, do nothing and keep - // generating the payload. It's a special corner case that a few slots are - // missing and we are requested to generate the payload in slot. - } else { - // If the head block is already in our canonical chain, the beacon client is - // probably resyncing. Ignore the update. - log.Info("Ignoring beacon update to old head", "number", block.NumberU64(), "hash", update.HeadBlockHash, "age", common.PrettyAge(time.Unix(int64(block.Time()), 0)), "have", api.eth.BlockChain().CurrentBlock().Number) - return valid(nil), nil } api.eth.SetSynced()