Skip to content

Commit

Permalink
fix forced batch query (#1630)
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniRamirezM authored Feb 3, 2023
1 parent 2b8d308 commit e25a5c7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions sequencer/closingsignalsmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 14 additions & 1 deletion sequencer/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion state/pgstatestorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e25a5c7

Please sign in to comment.