Skip to content

Commit

Permalink
handle empty batch fork ids in the datastream (#1164)
Browse files Browse the repository at this point in the history
  • Loading branch information
hexoscott committed Sep 13, 2024
1 parent 8a34cf9 commit 4068aea
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion zk/datastream/server/data_stream_server_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,26 @@ func getBatchTypeAndFork(batchNumber uint64, reader DbReader) (datastream.BatchT
} else {
batchType = datastream.BatchType_BATCH_TYPE_REGULAR
}

fork, err := reader.GetForkId(batchNumber)
return batchType, fork, err
if err != nil {
return datastream.BatchType_BATCH_TYPE_UNSPECIFIED, 0, err
}

if fork == 0 && batchNumber > 1 {
// iterate backwards, this only happens for empty batches pre etrog
for batchNumber > 1 {
batchNumber--
fork, err = reader.GetForkId(batchNumber)
if err != nil {
return datastream.BatchType_BATCH_TYPE_UNSPECIFIED, 0, err
}
if fork != 0 {
break
}
}
}
return batchType, fork, nil
}

func addBatchStartEntries(reader DbReader, batchNum, chainId uint64) ([]DataStreamEntryProto, error) {
Expand Down

0 comments on commit 4068aea

Please sign in to comment.