diff --git a/rollup/internal/controller/relayer/l2_relayer.go b/rollup/internal/controller/relayer/l2_relayer.go index 119b0c2bf7..22c6528d8b 100644 --- a/rollup/internal/controller/relayer/l2_relayer.go +++ b/rollup/internal/controller/relayer/l2_relayer.go @@ -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 + } } }