Skip to content

Commit

Permalink
only validate root snapshot when loading file (#6057)
Browse files Browse the repository at this point in the history
Currently, we validate the root snapshot every time we startup, meaning
that for all startups after the first, we are validating the same thing
that we wrote to disk.

This causes a problem on v0.33, because some parts of the software
expect a sealing segment of length 590+, and others expect a sealing
segment of length 600+. In particular, this can cause a node to accept a
root snapshot file when bootstrapping, then reject the root snapshot
DB-backed object on subsequent startups, because the DB-backed snapshot
is returning an invalid sealing segment.
  • Loading branch information
jordanschalm authored Jun 7, 2024
1 parent 6537b67 commit 5acf995
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,13 @@ func (fnb *FlowNodeBuilder) initState() error {
return fmt.Errorf("failed to read protocol snapshot from disk: %w", err)
}
}
// apply any extra validation steps to the root snapshot prior to bootstrapping
if fnb.extraRootSnapshotCheck != nil {
err = fnb.extraRootSnapshotCheck(rootSnapshot)
if err != nil {
return fmt.Errorf("failed validate root snapshot from disk: %w", err)
}
}
// set root snapshot fields
if err := fnb.setRootSnapshot(rootSnapshot); err != nil {
return err
Expand Down Expand Up @@ -1412,14 +1419,6 @@ func (fnb *FlowNodeBuilder) setRootSnapshot(rootSnapshot protocol.Snapshot) erro
return fmt.Errorf("failed to validate root snapshot QCs: %w", err)
}

// perform extra checks requested by specific node types
if fnb.extraRootSnapshotCheck != nil {
err = fnb.extraRootSnapshotCheck(rootSnapshot)
if err != nil {
return fmt.Errorf("failed to perform extra checks on root snapshot: %w", err)
}
}

fnb.RootSnapshot = rootSnapshot
// cache properties of the root snapshot, for convenience
fnb.RootResult, fnb.RootSeal, err = fnb.RootSnapshot.SealedResult()
Expand Down

0 comments on commit 5acf995

Please sign in to comment.