From d516949f390c5a0617a45e50ca58d0872a1f164a Mon Sep 17 00:00:00 2001 From: georgehao Date: Thu, 18 Jul 2024 11:38:14 +0800 Subject: [PATCH] fix ProcessPendingBundles record not found (#1444) --- rollup/internal/controller/relayer/l2_relayer.go | 4 ++++ rollup/internal/orm/bundle.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/rollup/internal/controller/relayer/l2_relayer.go b/rollup/internal/controller/relayer/l2_relayer.go index 13c7234dc5..5be2aec345 100644 --- a/rollup/internal/controller/relayer/l2_relayer.go +++ b/rollup/internal/controller/relayer/l2_relayer.go @@ -505,10 +505,14 @@ func (r *Layer2Relayer) ProcessPendingBundles() { r.metrics.rollupL2RelayerProcessPendingBundlesTotal.Inc() bundle, err := r.bundleOrm.GetFirstPendingBundle(r.ctx) + if bundle == nil && err == nil { + return + } if err != nil { log.Error("Failed to fetch first pending L2 bundle", "err", err) return } + status := types.ProvingStatus(bundle.ProvingStatus) switch status { case types.ProvingTaskUnassigned, types.ProvingTaskAssigned: diff --git a/rollup/internal/orm/bundle.go b/rollup/internal/orm/bundle.go index afd861729d..28ed3209bd 100644 --- a/rollup/internal/orm/bundle.go +++ b/rollup/internal/orm/bundle.go @@ -126,6 +126,9 @@ func (o *Bundle) GetFirstPendingBundle(ctx context.Context) (*Bundle, error) { var pendingBundle Bundle if err := db.First(&pendingBundle).Error; err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return nil, nil + } return nil, fmt.Errorf("Bundle.GetFirstPendingBundle error: %w", err) } return &pendingBundle, nil