Skip to content

Commit ffcf2d6

Browse files
committed
fix: beacon: validate drand change at nv16 correctly
1 parent 9c713ca commit ffcf2d6

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pkg/beacon/beacon.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,15 @@ func ValidateBlockValues(bSchedule Schedule, nv network.Version, h *types.BlockH
7878
return fmt.Errorf("expected final beacon entry in block to be at round %d, got %d", maxRound, last.Round)
7979
}
8080

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

0 commit comments

Comments
 (0)