From 520c9e3a388226395a1eddb1e6638900dbb46192 Mon Sep 17 00:00:00 2001 From: agnusmor <100322135+agnusmor@users.noreply.github.com> Date: Mon, 5 Aug 2024 15:42:54 +0200 Subject: [PATCH] fix invalid "updateGER" entry when updating datastream file on startup (#3748) --- state/datastream.go | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/state/datastream.go b/state/datastream.go index a9544d4e69..c3aa6c814f 100644 --- a/state/datastream.go +++ b/state/datastream.go @@ -436,29 +436,31 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre } if len(batch.L2Blocks) == 0 { - // Empty batch - // Check if there is a GER update - if batch.GlobalExitRoot != currentGER && batch.GlobalExitRoot != (common.Hash{}) { - updateGER := &datastream.UpdateGER{ - BatchNumber: batch.BatchNumber, - Timestamp: uint64(batch.Timestamp.Unix()), - GlobalExitRoot: batch.GlobalExitRoot.Bytes(), - Coinbase: batch.Coinbase.Bytes(), - ForkId: batch.ForkID, - ChainId: chainID, - StateRoot: batch.StateRoot.Bytes(), - } + if !batch.WIP && batch.ForkID < FORKID_ETROG { + // Empty batch + // Check if there is a GER update + if batch.GlobalExitRoot != currentGER && batch.GlobalExitRoot != (common.Hash{}) { + updateGER := &datastream.UpdateGER{ + BatchNumber: batch.BatchNumber, + Timestamp: uint64(batch.Timestamp.Unix()), + GlobalExitRoot: batch.GlobalExitRoot.Bytes(), + Coinbase: batch.Coinbase.Bytes(), + ForkId: batch.ForkID, + ChainId: chainID, + StateRoot: batch.StateRoot.Bytes(), + } - marshalledUpdateGER, err := proto.Marshal(updateGER) - if err != nil { - return err - } + marshalledUpdateGER, err := proto.Marshal(updateGER) + if err != nil { + return err + } - _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_UPDATE_GER), marshalledUpdateGER) - if err != nil { - return err + _, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_UPDATE_GER), marshalledUpdateGER) + if err != nil { + return err + } + currentGER = batch.GlobalExitRoot } - currentGER = batch.GlobalExitRoot } } else { for blockIndex, l2Block := range batch.L2Blocks {