Skip to content

Commit

Permalink
add more check to DS correcness
Browse files Browse the repository at this point in the history
  • Loading branch information
kstoykov committed Aug 28, 2024
1 parent bd14081 commit 0e0374d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions zk/debug_tools/datastream-correctness-check/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func main() {
var lastBlockRoot common.Hash
progressBatch := uint64(0)
progressBlock := uint64(0)
lastSeenBatch := uint64(0)
lastSeenBlock := uint64(0)

function := func(file *types.FileEntry) error {
switch file.EntryType {
Expand Down Expand Up @@ -65,6 +67,10 @@ func main() {
if err != nil {
return err
}
if lastSeenBatch+1 != batchStart.Number {
return fmt.Errorf("unexpected batch %d, expected %d", batchStart.Number, lastSeenBatch+1)
}
lastSeenBatch = batchStart.Number
progressBatch = batchStart.Number
if previousFile != nil {
if previousFile.EntryType != types.BookmarkEntryType {
Expand Down Expand Up @@ -106,6 +112,10 @@ func main() {
if err != nil {
return err
}
if l2Block.L2BlockNumber > 0 && lastSeenBlock+1 != l2Block.L2BlockNumber {
return fmt.Errorf("unexpected block %d, expected %d", l2Block.L2BlockNumber, lastSeenBlock+1)
}
lastSeenBlock = l2Block.L2BlockNumber
progressBlock = l2Block.L2BlockNumber
if previousFile != nil {
if previousFile.EntryType != types.BookmarkEntryType && !previousFile.IsL2BlockEnd() {
Expand Down

0 comments on commit 0e0374d

Please sign in to comment.