Merge pull request #890 from filecoin-project/feat/fix-candidate-check

Fix candidate check
This commit is contained in:
Łukasz Magiera
2019-12-12 14:51:22 +01:00
committed by GitHub
2 changed files with 19 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
package build
const ForkCCM = 1750
+16
View File
@@ -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)