Skip to content

Commit

Permalink
fix invalid "updateGER" entry when updating datastream file on startup (
Browse files Browse the repository at this point in the history
  • Loading branch information
agnusmor authored Aug 14, 2024
1 parent 8d67cb9 commit a15dcc2
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions state/datastream.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,29 +493,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 {
Expand Down

0 comments on commit a15dcc2

Please sign in to comment.