Skip to content

Commit

Permalink
Interop: Rewind tests (#14289)
Browse files Browse the repository at this point in the history
* interop,fix: Treat missing L1 block as non-canonical.

* interop,tests: Add more Rewinder test cases.

* interop,tests: Remove unncessary error return.
  • Loading branch information
tyler-smith authored Mar 3, 2025
1 parent 4ba2eb0 commit d8b84ae
Show file tree
Hide file tree
Showing 2 changed files with 696 additions and 5 deletions.
10 changes: 8 additions & 2 deletions op-supervisor/supervisor/backend/rewinder/rewinder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/log"

"github.com/ethereum-optimism/optimism/op-node/rollup/event"
Expand Down Expand Up @@ -157,7 +158,7 @@ func (r *Rewinder) rewindL1ChainIfReorged(chainID eth.ChainID, newTip eth.BlockI

// Get the canonical L1 block at our local head's height
canonicalL1, err := r.l1Node.L1BlockRefByNumber(context.Background(), localSafeL1.Number)
if err != nil {
if err != nil && !errors.Is(err, ethereum.NotFound) {
return fmt.Errorf("failed to get canonical L1 block at height %d: %w", localSafeL1.Number, err)
}

Expand Down Expand Up @@ -189,9 +190,14 @@ func (r *Rewinder) rewindL1ChainIfReorged(chainID eth.ChainID, newTip eth.BlockI
currentL1 := localSafeL1.ID()
for currentL1.Number >= finalizedL1.Number {
// Get the canonical L1 block at this height from the node
// If it's not found we'll continue through the loop and try the previous block
remoteL1, err := r.l1Node.L1BlockRefByNumber(context.Background(), currentL1.Number)
if err != nil {
return fmt.Errorf("failed to get L1 block at height %d: %w", currentL1.Number, err)
if errors.Is(err, ethereum.NotFound) {
r.log.Debug("no L1 block at height", "chain", chainID, "height", currentL1.Number)
} else {
return fmt.Errorf("failed to get L1 block at height %d: %w", currentL1.Number, err)
}
}

// If hashes match, we found the common ancestor
Expand Down
Loading

0 comments on commit d8b84ae

Please sign in to comment.