Skip to content

Commit

Permalink
fix: skipping because of local state exit root not changing
Browse files Browse the repository at this point in the history
  • Loading branch information
minhd-vu committed Dec 18, 2024
1 parent af33a86 commit 7d001dc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
5 changes: 2 additions & 3 deletions observer/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1125,9 +1125,8 @@ type RollupData struct {

TrustedSequencerBalances TokenBalances

ChainID *uint64
LastLocalExitRoot [32]byte
Pessimistic bool
ChainID *uint64
Pessimistic bool
}

type RollupManagerObserver struct {
Expand Down
21 changes: 15 additions & 6 deletions provider/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,6 @@ func (r *RPCProvider) refreshZkEVMEtrog(ctx context.Context, c *ethclient.Client
}

r.rollupManager.Rollups[rollupID].ChainID = &rollup.ChainID
r.rollupManager.Rollups[rollupID].LastLocalExitRoot = rollup.LastLocalExitRoot

lfb, err := contract.LastForceBatch(co)
if err != nil {
Expand Down Expand Up @@ -1528,11 +1527,21 @@ func (r *RPCProvider) refreshRollupVerifyBatchesTrustedAggregator(ctx context.Co
continue
}

pessimistic := event.NumBatch == 0 && event.StateRoot == [32]byte{}

if rollup.LastVerifiedBatch != nil {
// Here, the last local exit roots are checked instead of the last
// verified batch because some chains (pessimistic) don't have the last
// verified batch.
if rollup.LastLocalExitRoot == event.ExitRoot {
// Here, pessimistic chains have to be handle differently because the
// NumBatch will always be 0. The last verified timestamp is used to
// determine if the event has already been seen.
//
// There is an edge case here where if both events are included in the
// same block, there will be a missing time between verified batches
// event. This will be rare and won't significantly impact the metric.
if pessimistic && *rollup.LastVerifiedTimestamp >= time {
continue
}

if pessimistic && *rollup.LastVerifiedBatch >= event.NumBatch {
continue
}

Expand All @@ -1554,7 +1563,7 @@ func (r *RPCProvider) refreshRollupVerifyBatchesTrustedAggregator(ctx context.Co

rollup.LastVerifiedTimestamp = &time
rollup.LastVerifiedBatch = &event.NumBatch
rollup.Pessimistic = event.NumBatch == 0 && event.StateRoot == [32]byte{}
rollup.Pessimistic = pessimistic

receipt, err := c.TransactionReceipt(ctx, event.Raw.TxHash)
if err != nil {
Expand Down

0 comments on commit 7d001dc

Please sign in to comment.