Merge pull request #1056 from filecoin-project/fix/candidate-dupe

check for duplicate candidates in block headers
This commit is contained in:
Whyrusleeping 2020-01-10 11:24:46 -08:00 committed by GitHub
commit fd4af3f7a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -545,7 +545,13 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
return xerrors.Errorf("no candidates") return xerrors.Errorf("no candidates")
} }
wins := make(map[uint64]bool)
for _, t := range h.EPostProof.Candidates { for _, t := range h.EPostProof.Candidates {
if wins[t.ChallengeIndex] {
return xerrors.Errorf("block had duplicate epost candidates")
}
wins[t.ChallengeIndex] = true
if !types.IsTicketWinner(t.Partial, ssize, snum.Uint64(), tpow) { if !types.IsTicketWinner(t.Partial, ssize, snum.Uint64(), tpow) {
return xerrors.Errorf("miner created a block but was not a winner") return xerrors.Errorf("miner created a block but was not a winner")
} }