Skip to content

Commit

Permalink
do not sequence empty batches (#1686)
Browse files Browse the repository at this point in the history
* do not sequence empty batches

* do not sequence empty batches

* do not sequence empty batches

* disable db logs

* fix

* fix test

* linter
  • Loading branch information
ToniRamirezM committed Feb 23, 2023
1 parent 17b8a03 commit 27b65d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions sequencer/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,24 +754,21 @@ func (f *finalizer) isDeadlineEncountered() bool {
// Forced batch deadline
if f.nextForcedBatchDeadline != 0 && now().Unix() >= f.nextForcedBatchDeadline {
log.Infof("Closing batch: %d, forced batch deadline encountered.", f.batch.batchNumber)
f.setNextSendingToL1Deadline()
return true
}
// Global Exit Root deadline
if f.nextGERDeadline != 0 && now().Unix() >= f.nextGERDeadline {
log.Infof("Closing batch: %d, Global Exit Root deadline encountered.", f.batch.batchNumber)
f.setNextSendingToL1Deadline()
return true
}
// Delayed batch deadline
if f.nextSendingToL1Deadline != 0 && now().Unix() >= f.nextSendingToL1Deadline {
if f.batch.isEmpty() {
f.setNextSendingToL1Deadline()
} else {
log.Infof("Closing batch: %d, Sending to L1 deadline encountered.", f.batch.batchNumber)
}

if f.nextSendingToL1Deadline != 0 && now().Unix() >= f.nextSendingToL1Deadline && !f.batch.isEmpty() {
log.Infof("Closing batch: %d, Sending to L1 deadline encountered.", f.batch.batchNumber)
f.setNextSendingToL1Deadline()
return true
}

return false
}

Expand Down
2 changes: 1 addition & 1 deletion sequencer/finalizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ func TestFinalizer_isDeadlineEncountered(t *testing.T) {
nextForcedBatch: 0,
nextGER: 0,
nextDelayedBatch: now().Add(time.Second).Unix(),
expected: true,
expected: false,
},
}

Expand Down

0 comments on commit 27b65d9

Please sign in to comment.