Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit a15dcc2

Browse files
authored
fix invalid "updateGER" entry when updating datastream file on startup (#3748) (#3766)
1 parent 8d67cb9 commit a15dcc2

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

state/datastream.go

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -493,29 +493,31 @@ func GenerateDataStreamFile(ctx context.Context, streamServer *datastreamer.Stre
493493
}
494494

495495
if len(batch.L2Blocks) == 0 {
496-
// Empty batch
497-
// Check if there is a GER update
498-
if batch.GlobalExitRoot != currentGER && batch.GlobalExitRoot != (common.Hash{}) {
499-
updateGER := &datastream.UpdateGER{
500-
BatchNumber: batch.BatchNumber,
501-
Timestamp: uint64(batch.Timestamp.Unix()),
502-
GlobalExitRoot: batch.GlobalExitRoot.Bytes(),
503-
Coinbase: batch.Coinbase.Bytes(),
504-
ForkId: batch.ForkID,
505-
ChainId: chainID,
506-
StateRoot: batch.StateRoot.Bytes(),
507-
}
496+
if !batch.WIP && batch.ForkID < FORKID_ETROG {
497+
// Empty batch
498+
// Check if there is a GER update
499+
if batch.GlobalExitRoot != currentGER && batch.GlobalExitRoot != (common.Hash{}) {
500+
updateGER := &datastream.UpdateGER{
501+
BatchNumber: batch.BatchNumber,
502+
Timestamp: uint64(batch.Timestamp.Unix()),
503+
GlobalExitRoot: batch.GlobalExitRoot.Bytes(),
504+
Coinbase: batch.Coinbase.Bytes(),
505+
ForkId: batch.ForkID,
506+
ChainId: chainID,
507+
StateRoot: batch.StateRoot.Bytes(),
508+
}
508509

509-
marshalledUpdateGER, err := proto.Marshal(updateGER)
510-
if err != nil {
511-
return err
512-
}
510+
marshalledUpdateGER, err := proto.Marshal(updateGER)
511+
if err != nil {
512+
return err
513+
}
513514

514-
_, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_UPDATE_GER), marshalledUpdateGER)
515-
if err != nil {
516-
return err
515+
_, err = streamServer.AddStreamEntry(datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_UPDATE_GER), marshalledUpdateGER)
516+
if err != nil {
517+
return err
518+
}
519+
currentGER = batch.GlobalExitRoot
517520
}
518-
currentGER = batch.GlobalExitRoot
519521
}
520522
} else {
521523
for blockIndex, l2Block := range batch.L2Blocks {

0 commit comments

Comments
 (0)