From f6499be2a287f55c591da113a32f6796c8c3a948 Mon Sep 17 00:00:00 2001 From: georgehao Date: Sun, 21 Jul 2024 14:38:51 +0800 Subject: [PATCH] dynamic batches of a bundle --- rollup/internal/controller/watcher/bundle_proposer.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rollup/internal/controller/watcher/bundle_proposer.go b/rollup/internal/controller/watcher/bundle_proposer.go index d975ea3320..4c8becc692 100644 --- a/rollup/internal/controller/watcher/bundle_proposer.go +++ b/rollup/internal/controller/watcher/bundle_proposer.go @@ -38,6 +38,8 @@ type BundleProposer struct { bundleBatchesNum prometheus.Gauge bundleFirstBlockTimeoutReached prometheus.Counter bundleBatchesProposeNotEnoughTotal prometheus.Counter + + lastBundleId uint64 } // NewBundleProposer creates a new BundleProposer instance. @@ -103,8 +105,10 @@ func (p *BundleProposer) updateDBBundleInfo(batches []*orm.Batch, codecVersion e } p.proposeBundleUpdateInfoTotal.Inc() + var bundle *orm.Bundle err := p.db.Transaction(func(dbTX *gorm.DB) error { - bundle, err := p.bundleOrm.InsertBundle(p.ctx, batches, codecVersion, dbTX) + var err error + bundle, err = p.bundleOrm.InsertBundle(p.ctx, batches, codecVersion, dbTX) if err != nil { log.Warn("BundleProposer.InsertBundle failed", "err", err) return err @@ -120,6 +124,7 @@ func (p *BundleProposer) updateDBBundleInfo(batches []*orm.Batch, codecVersion e log.Error("update chunk info in orm failed", "err", err) return err } + p.lastBundleId = bundle.Index return nil } @@ -130,7 +135,8 @@ func (p *BundleProposer) proposeBundle() error { } // select at most maxBlocksThisChunk blocks - maxBatchesThisBundle := p.maxBatchNumPerBundle + //maxBatchesThisBundle := p.maxBatchNumPerBundle + maxBatchesThisBundle := p.lastBundleId%p.maxBatchNumPerBundle + 1 batches, err := p.batchOrm.GetBatchesGEIndexGECodecVersion(p.ctx, firstUnbundledBatchIndex, encoding.CodecV3, int(maxBatchesThisBundle)) if err != nil { return err