Merge pull request #890 from filecoin-project/feat/fix-candidate-check
Fix candidate check
This commit is contained in:
commit
e1acacaa95
3
build/forks.go
Normal file
3
build/forks.go
Normal file
@ -0,0 +1,3 @@
|
||||
package build
|
||||
|
||||
const ForkCCM = 1750
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user