From af455595d7565079dd3d7f8a98ec9351b567bee9 Mon Sep 17 00:00:00 2001 From: Kamen Stoykov <24619432+kstoykov@users.noreply.github.com> Date: Mon, 16 Sep 2024 17:23:00 +0300 Subject: [PATCH] sequenver-update-04-fix-ds-batch-end (#1179) --- zk/stages/stage_sequence_execute_data_stream.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/zk/stages/stage_sequence_execute_data_stream.go b/zk/stages/stage_sequence_execute_data_stream.go index 50159c15977..a1e3606cb09 100644 --- a/zk/stages/stage_sequence_execute_data_stream.go +++ b/zk/stages/stage_sequence_execute_data_stream.go @@ -110,9 +110,12 @@ func (sbc *SequencerBatchStreamWriter) writeBlockDetailsToDatastream(verifiedBun } func alignExecutionToDatastream(batchContext *BatchContext, batchState *BatchState, lastExecutedBlock uint64, u stagedsync.Unwinder) (bool, error) { - lastExecutedBatch := batchState.batchNumber - 1 + lastStartedDatastreamBatch, err := batchContext.cfg.datastreamServer.GetHighestBatchNumber() + if err != nil { + return false, err + } - lastDatastreamBatch, err := batchContext.cfg.datastreamServer.GetHighestClosedBatch() + lastClosedDatastreamBatch, err := batchContext.cfg.datastreamServer.GetHighestClosedBatch() if err != nil { return false, err } @@ -122,8 +125,8 @@ func alignExecutionToDatastream(batchContext *BatchContext, batchState *BatchSta return false, err } - if lastExecutedBatch != lastDatastreamBatch { - if err := finalizeLastBatchInDatastreamIfNotFinalized(batchContext, lastExecutedBatch, lastDatastreamBlock); err != nil { + if lastStartedDatastreamBatch != lastClosedDatastreamBatch { + if err := finalizeLastBatchInDatastreamIfNotFinalized(batchContext, lastStartedDatastreamBatch, lastDatastreamBlock); err != nil { return false, err } }