Skip to content

Commit

Permalink
Merge pull request #294 from OffchainLabs/nit-1280-switch-to-go-ether…
Browse files Browse the repository at this point in the history
…eum-pos-apis-to-write-new-blocks-and

Switch to go-ethereum PoS API to write reorgs to blockchain [NIT-1280]
  • Loading branch information
ganeshvanahalli authored Mar 26, 2024
2 parents 22399a7 + 4cf1b34 commit 39c3ff6
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions core/blockchain_arbitrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package core

import (
"errors"
"fmt"
"time"

"github.com/ethereum/go-ethereum/core/state"
Expand All @@ -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
}

Expand Down

0 comments on commit 39c3ff6

Please sign in to comment.