fix: beacon: validate drand change at nv16 correctly

This commit is contained in:
Aayush 2024-03-06 12:23:09 -05:00
parent 64b32ad632
commit daafe73462

View File

@ -89,6 +89,9 @@ func ValidateBlockValues(bSchedule Schedule, nv network.Version, h *types.BlockH
return xerrors.Errorf("expected final beacon entry in block to be at round %d, got %d", maxRound, last.Round) return xerrors.Errorf("expected final beacon entry in block to be at round %d, got %d", maxRound, last.Round)
} }
// 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 // Verify that all other entries' rounds are as expected for the epochs in between parentEpoch and h.Height
for i, e := range h.BeaconEntries { for i, e := range h.BeaconEntries {
correctRound := currBeacon.MaxBeaconRoundForEpoch(nv, parentEpoch+abi.ChainEpoch(i)+1) correctRound := currBeacon.MaxBeaconRoundForEpoch(nv, parentEpoch+abi.ChainEpoch(i)+1)
@ -96,6 +99,7 @@ func ValidateBlockValues(bSchedule Schedule, nv network.Version, h *types.BlockH
return xerrors.Errorf("unexpected beacon round %d, expected %d for epoch %d", e.Round, correctRound, parentEpoch+abi.ChainEpoch(i)) return xerrors.Errorf("unexpected beacon round %d, expected %d for epoch %d", e.Round, correctRound, parentEpoch+abi.ChainEpoch(i))
} }
} }
}
// Verify the beacon entries themselves // Verify the beacon entries themselves
for i, e := range h.BeaconEntries { for i, e := range h.BeaconEntries {