Commit 900f44a3 authored by OptimismBot's avatar OptimismBot Committed by GitHub

Merge pull request #5720 from ethereum-optimism/feat/better-rollover-check

op-chain-ops: better rollover checks
parents 63a6436f 8ac1bd79
...@@ -2,7 +2,6 @@ package main ...@@ -2,7 +2,6 @@ package main
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"math/big" "math/big"
"os" "os"
...@@ -112,6 +111,7 @@ func main() { ...@@ -112,6 +111,7 @@ func main() {
} }
log.Info("Searching backwards for final deposit", "start", blockNumber) log.Info("Searching backwards for final deposit", "start", blockNumber)
// Walk backards through the blocks until we find the final deposit.
for { for {
bn := new(big.Int).SetUint64(blockNumber) bn := new(big.Int).SetUint64(blockNumber)
log.Info("Checking L2 block", "number", bn) log.Info("Checking L2 block", "number", bn)
...@@ -131,18 +131,35 @@ func main() { ...@@ -131,18 +131,35 @@ func main() {
if err != nil { if err != nil {
return err return err
} }
// If the queue origin is l1, then it is a deposit.
if json.QueueOrigin == "l1" { if json.QueueOrigin == "l1" {
if json.QueueIndex == nil { if json.QueueIndex == nil {
// This should never happen // This should never happen.
return errors.New("queue index is nil") return fmt.Errorf("queue index is nil for tx %s at height %d", hash.Hex(), blockNumber)
} }
queueIndex := uint64(*json.QueueIndex) queueIndex := uint64(*json.QueueIndex)
// Check to see if the final deposit was ingested. Subtract 1 here to handle zero
// indexing.
if queueIndex == queueLength.Uint64()-1 { if queueIndex == queueLength.Uint64()-1 {
log.Info("Found final deposit in l2geth", "queue-index", queueIndex) log.Info("Found final deposit in l2geth", "queue-index", queueIndex)
break break
} }
// If the queue index is less than the queue length, then not all deposits have
// been ingested by l2geth yet. This means that we need to reset the blocknumber
// to the latest block number to restart walking backwards to find deposits that
// have yet to be ingested.
if queueIndex < queueLength.Uint64() { if queueIndex < queueLength.Uint64() {
return errors.New("missed final deposit") log.Info("Not all deposits ingested", "queue-index", queueIndex, "queue-length", queueLength.Uint64())
time.Sleep(time.Second * 3)
blockNumber, err = clients.L2Client.BlockNumber(context.Background())
if err != nil {
return err
}
continue
}
// The queueIndex should never be greater than the queue length.
if queueIndex > queueLength.Uint64() {
log.Warn("Queue index is greater than queue length", "queue-index", queueIndex, "queue-length", queueLength.Uint64())
} }
} }
blockNumber-- blockNumber--
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment