From 9c3d6946b850b7f5a1efc2a60a2eb6131109147e Mon Sep 17 00:00:00 2001 From: agnusmor Date: Thu, 23 Mar 2023 20:30:34 +0100 Subject: [PATCH] Reprocess empty batch to update state root before sanity check (full batch) --- sequencer/finalizer.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sequencer/finalizer.go b/sequencer/finalizer.go index caee667de3..944607f981 100644 --- a/sequencer/finalizer.go +++ b/sequencer/finalizer.go @@ -281,6 +281,15 @@ func (f *finalizer) newWIPBatch(ctx context.Context) (*WipBatch, error) { return nil, errors.New("state root and local exit root must have value to close batch") } + // We need to process the batch to update the state root before closing the batch + if f.batch.initialStateRoot == f.batch.stateRoot { + log.Info("reprocessing batch because the state root has not changed...") + err := f.processTransaction(ctx, nil) + if err != nil { + return nil, err + } + } + // Reprocess full batch as sanity check processBatchResponse, err := f.reprocessFullBatch(ctx, f.batch.batchNumber, f.batch.stateRoot) if err != nil || !processBatchResponse.IsBatchProcessed { @@ -660,15 +669,6 @@ func (f *finalizer) openWIPBatch(ctx context.Context, batchNum uint64, ger, stat // closeBatch closes the current batch in the state func (f *finalizer) closeBatch(ctx context.Context) error { - // We need to process the batch to update the state root before closing the batch - if f.batch.initialStateRoot == f.batch.stateRoot { - log.Info("reprocessing batch because the state root has not changed...") - err := f.processTransaction(ctx, nil) - if err != nil { - return err - } - } - transactions, err := f.dbManager.GetTransactionsByBatchNumber(ctx, f.batch.batchNumber) if err != nil { return fmt.Errorf("failed to get transactions from transactions, err: %w", err)