Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid "updateGER" entry when updating datastream file on startup #3748

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions state/datastream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading