Skip to content

Commit

Permalink
Merge pull request #6280 from filecoin-project/fix/drand-skyr
Browse files Browse the repository at this point in the history
fix: beacon: validate drand change at nv16 correctly
  • Loading branch information
simlecode authored Mar 7, 2024
2 parents 9c713ca + ffcf2d6 commit 838a5bf
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/beacon/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ func ValidateBlockValues(bSchedule Schedule, nv network.Version, h *types.BlockH
return fmt.Errorf("expected final beacon entry in block to be at round %d, got %d", maxRound, last.Round)
}

// Verify that all other entries' rounds are as expected for the epochs in between parentEpoch and h.Height
for i, e := range h.BeaconEntries {
correctRound := currBeacon.MaxBeaconRoundForEpoch(nv, parentEpoch+abi.ChainEpoch(i)+1)
if e.Round != correctRound {
return fmt.Errorf("unexpected beacon round %d, expected %d for epoch %d", e.Round, correctRound, parentEpoch+abi.ChainEpoch(i))
// If the beacon is UNchained, verify that the block only includes the rounds we want for the epochs in between parentEpoch and h.Height
// For chained beacons, you must have all the rounds forming a valid chain with prevEntry, so we can skip this step
if !currBeacon.IsChained() {
// Verify that all other entries' rounds are as expected for the epochs in between parentEpoch and h.Height
for i, e := range h.BeaconEntries {
correctRound := currBeacon.MaxBeaconRoundForEpoch(nv, parentEpoch+abi.ChainEpoch(i)+1)
if e.Round != correctRound {
return fmt.Errorf("unexpected beacon round %d, expected %d for epoch %d", e.Round, correctRound, parentEpoch+abi.ChainEpoch(i))
}
}
}

Expand Down

0 comments on commit 838a5bf

Please sign in to comment.