From 5e5c560d30d96ea86f4b7a0e0721f2e274720844 Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Wed, 13 Mar 2024 17:26:06 -0500 Subject: [PATCH] Switch to go-ethereum PoS API to write reorgs to blockchain --- core/blockchain_arbitrum.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/core/blockchain_arbitrum.go b/core/blockchain_arbitrum.go index 8468dda93b..55966e98cc 100644 --- a/core/blockchain_arbitrum.go +++ b/core/blockchain_arbitrum.go @@ -18,7 +18,7 @@ package core import ( - "errors" + "fmt" "time" "github.com/ethereum/go-ethereum/core/state" @@ -40,21 +40,9 @@ func (bc *BlockChain) WriteBlockAndSetHeadWithTime(block *types.Block, receipts func (bc *BlockChain) ReorgToOldBlock(newHead *types.Block) error { bc.wg.Add(1) defer bc.wg.Done() - locked := bc.chainmu.TryLock() - if !locked { - return errors.New("couldn't catch lock to reorg") + if _, err := bc.SetCanonical(newHead); err != nil { + return fmt.Errorf("error reorging to old block: %w", err) } - defer bc.chainmu.Unlock() - oldHead := bc.CurrentBlock() - if oldHead.Hash() == newHead.Hash() { - return nil - } - bc.writeHeadBlock(newHead) - err := bc.reorg(oldHead, newHead) - if err != nil { - return err - } - bc.chainHeadFeed.Send(ChainHeadEvent{Block: newHead}) return nil }