From 56f3e90eae7845381ab4234cd271ff55ef95480f Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Tue, 21 Apr 2026 16:16:21 +0800 Subject: [PATCH] core, eth/catalyst: polish --- core/blockchain.go | 9 +++++++-- eth/catalyst/api.go | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 296ef6bc16..5d27ba0888 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2594,8 +2594,13 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Header) error blockReorgAddMeter.Mark(int64(len(newChain))) } else { // len(newChain) == 0 && len(oldChain) > 0 - // rewind the canonical chain to a lower point. - log.Error("Impossible reorg, please file an issue", "oldnum", oldHead.Number, "oldhash", oldHead.Hash(), "oldblocks", len(oldChain), "newnum", newHead.Number, "newhash", newHead.Hash(), "newblocks", len(newChain)) + // Rewind the canonical chain to a lower point. In EPBs we can reorg to + // a parent of the head within 32 blocks. + if len(oldChain) > 32 { + log.Error("Impossible reorg, please file an issue", "oldnum", oldHead.Number, "oldhash", oldHead.Hash(), "oldblocks", len(oldChain)) + } else { + log.Info("Shorten chain", "del", len(oldChain), "number", oldHead.Number, "hash", oldHead.Hash()) + } } // Acquire the tx-lookup lock before mutation. This step is essential // as the txlookups should be changed atomically, and all subsequent diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index cd57720f40..371e88b5de 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -237,6 +237,7 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV4(ctx context.Context, update engine. func (api *ConsensusAPI) forkchoiceUpdated(ctx context.Context, update engine.ForkchoiceStateV1, payloadAttributes *engine.PayloadAttributes, payloadVersion engine.PayloadVersion, payloadWitness bool) (result engine.ForkChoiceResponse, err error) { ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.forkchoiceUpdated") defer spanEnd(&err) + api.forkchoiceLock.Lock() defer api.forkchoiceLock.Unlock()