diff --git a/build/forks.go b/build/forks.go new file mode 100644 index 000000000..35990bfbf --- /dev/null +++ b/build/forks.go @@ -0,0 +1,3 @@ +package build + +const ForkCCM = 1750 diff --git a/chain/sync.go b/chain/sync.go index b65341825..2ed52cdc5 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -513,6 +513,14 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err snum := types.BigDiv(mpow, types.NewInt(ssize)) + // FORK START + if h.Height > build.ForkCCM { + if len(h.EPostProof.Candidates) == 0 { + return xerrors.Errorf("no candidates") + } + } + // FORK END + for _, t := range h.EPostProof.Candidates { if !types.IsTicketWinner(t.Partial, ssize, snum.Uint64(), tpow) { return xerrors.Errorf("miner created a block but was not a winner") @@ -634,6 +642,13 @@ func (syncer *Syncer) VerifyElectionPoStProof(ctx context.Context, h *types.Bloc SectorChallengeIndex: t.ChallengeIndex, }) } + // FORK START + if h.Height > build.ForkCCM { + if len(winners) == 0 { + return xerrors.Errorf("no candidates") + } + } + // FORK END sectorInfo, err := stmgr.GetSectorsForElectionPost(ctx, syncer.sm, baseTs, h.Miner) if err != nil { @@ -647,6 +662,7 @@ func (syncer *Syncer) VerifyElectionPoStProof(ctx context.Context, h *types.Bloc return xerrors.Errorf("[TESTING] election post was invalid") } hvrf := sha256.Sum256(h.EPostProof.PostRand) + ok, err := sectorbuilder.VerifyElectionPost(ctx, ssize, *sectorInfo, hvrf[:], h.EPostProof.Proof, winners, h.Miner) if err != nil { return xerrors.Errorf("failed to verify election post: %w", err)