diff --git a/sequencer/closingsignalsmanager.go b/sequencer/closingsignalsmanager.go index 72e0976f11..bc3b0b7cae 100644 --- a/sequencer/closingsignalsmanager.go +++ b/sequencer/closingsignalsmanager.go @@ -46,6 +46,7 @@ func (c *closingSignalsManager) checkGERUpdate() { func (c *closingSignalsManager) checkForcedBatches() { for { time.Sleep(c.cfg.ClosingSignalsManagerWaitForL1OperationsInSec.Duration) + log.Debug(time.Now()) latestSentForcedBatchNumber, err := c.dbManager.GetLastTrustedForcedBatchNumber(c.ctx, nil) if err != nil { diff --git a/sequencer/finalizer.go b/sequencer/finalizer.go index fa988ced66..fca1ee3143 100644 --- a/sequencer/finalizer.go +++ b/sequencer/finalizer.go @@ -143,7 +143,11 @@ func (f *finalizer) listenForClosingSignals(ctx context.Context) { // Forced batch ch case fb := <-f.closingSignalCh.ForcedBatchCh: f.nextForcedBatchesMux.Lock() - f.nextForcedBatches = append(f.nextForcedBatches, fb) // TODO: change insert sort if not exists + + if !containsForcedBatch(f.nextForcedBatches, fb) { + f.nextForcedBatches = append(f.nextForcedBatches, fb) // TODO: change insert sort if not exists + } + if f.nextForcedBatchDeadline == 0 { f.setNextForcedBatchDeadline() } @@ -180,6 +184,15 @@ func (f *finalizer) listenForClosingSignals(ctx context.Context) { } } +func containsForcedBatch(nextForcedBatches []state.ForcedBatch, fb state.ForcedBatch) bool { + for _, f := range nextForcedBatches { + if f.ForcedBatchNumber == fb.ForcedBatchNumber { + return true + } + } + return false +} + // finalizeBatches runs the endless loop for processing transactions finalizing batches. func (f *finalizer) finalizeBatches(ctx context.Context) { for { diff --git a/state/pgstatestorage.go b/state/pgstatestorage.go index b7768d1cfc..71eadeedb8 100644 --- a/state/pgstatestorage.go +++ b/state/pgstatestorage.go @@ -782,7 +782,7 @@ func scanForcedBatch(row pgx.Row) (ForcedBatch, error) { coinbaseStr string ) if err := row.Scan( - &forcedBatch.BlockNumber, + &forcedBatch.ForcedBatchNumber, &gerStr, &forcedBatch.ForcedAt, &forcedBatch.RawTxsData,