From 27b65d9fb1861dc6f52c0993773fb6700f400b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Ram=C3=ADrez?= <58293609+ToniRamirezM@users.noreply.github.com> Date: Thu, 23 Feb 2023 14:53:50 +0100 Subject: [PATCH] do not sequence empty batches (#1686) * do not sequence empty batches * do not sequence empty batches * do not sequence empty batches * disable db logs * fix * fix test * linter --- sequencer/finalizer.go | 13 +++++-------- sequencer/finalizer_test.go | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/sequencer/finalizer.go b/sequencer/finalizer.go index 65e969bd1d..a04cf7d918 100644 --- a/sequencer/finalizer.go +++ b/sequencer/finalizer.go @@ -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 } diff --git a/sequencer/finalizer_test.go b/sequencer/finalizer_test.go index 2509685560..78e479eb77 100644 --- a/sequencer/finalizer_test.go +++ b/sequencer/finalizer_test.go @@ -952,7 +952,7 @@ func TestFinalizer_isDeadlineEncountered(t *testing.T) { nextForcedBatch: 0, nextGER: 0, nextDelayedBatch: now().Add(time.Second).Unix(), - expected: true, + expected: false, }, }