Skip to content

Commit

Permalink
ask chain-monitor to check all batches within a bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Jul 3, 2024
1 parent f92402d commit 1602759
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions rollup/internal/controller/relayer/l2_relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,16 +672,23 @@ func (r *Layer2Relayer) finalizeBundle(bundle *orm.Bundle, withProof bool) error

// Check batch status before sending `finalizeBundle` tx.
if r.cfg.ChainMonitor.Enabled {
batchStatus, getErr := r.getBatchStatusByIndex(dbBatch)
if getErr != nil {
r.metrics.rollupL2ChainMonitorLatestFailedCall.Inc()
log.Warn("failed to get batch status, please check chain_monitor api server", "batch_index", dbBatch.Index, "err", getErr)
return err
}
if !batchStatus {
r.metrics.rollupL2ChainMonitorLatestFailedBatchStatus.Inc()
log.Error("the batch status is not right, stop finalize batch and check the reason", "batch_index", dbBatch.Index)
return err
for batchIndex := bundle.StartBatchIndex; batchIndex <= bundle.EndBatchIndex; batchIndex++ {
tmpBatch, err := r.batchOrm.GetBatchByIndex(r.ctx, batchIndex)
if err != nil {
log.Error("failed to get batch by index", "batch index", batchIndex, "error", err)
return err
}
batchStatus, getErr := r.getBatchStatusByIndex(tmpBatch)
if getErr != nil {
r.metrics.rollupL2ChainMonitorLatestFailedCall.Inc()
log.Error("failed to get batch status, please check chain_monitor api server", "batch_index", tmpBatch.Index, "err", getErr)
return err
}
if !batchStatus {
r.metrics.rollupL2ChainMonitorLatestFailedBatchStatus.Inc()
log.Error("the batch status is not right, stop finalize batch and check the reason", "batch_index", tmpBatch.Index)
return err
}
}
}

Expand Down

0 comments on commit 1602759

Please sign in to comment.