refuse a proposal that was already received

This commit is contained in:
Mark Spanbroek 2024-10-29 13:05:38 +01:00
parent 09f7257bd3
commit 2a13ddffd4
2 changed files with 8 additions and 0 deletions

View File

@ -114,6 +114,8 @@ func check*(validator: Validator, signed: SignedBlock): auto =
missing.add(parent)
if missing.len > 0:
return BlockCheck.incomplete(missing)
if validator.rounds.latest.find(signed.blck.id).isSome:
return BlockCheck.invalid("block already received")
BlockCheck.correct(signed)
func receive*(validator: Validator, correct: CorrectBlock) =

View File

@ -176,6 +176,12 @@ suite "Multiple Validators":
check checked.verdict == BlockVerdict.invalid
check checked.reason == "block has a round number that is too high"
test "refuses a proposal that was already received":
let proposals = exchangeProposals()
let checked = validators[1].check(proposals[0])
check checked.verdict == BlockVerdict.invalid
check checked.reason == "block already received"
test "skips blocks that are ignored by >2f validators":
# first round: other validators do not receive proposal from first validator
let proposals = exchangeProposals {