From 83605dfd95b1d9930ef1c026ee2e3bcbca5497fc Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Fri, 10 Jan 2020 09:57:58 -0800 Subject: [PATCH] check for duplicate candidates in block headers --- chain/sync.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chain/sync.go b/chain/sync.go index 16fb6278b..e5a79133c 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -545,7 +545,13 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err return xerrors.Errorf("no candidates") } + wins := make(map[uint64]bool) 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) { return xerrors.Errorf("miner created a block but was not a winner") }