refuse proposals with a round number that is too high

This commit is contained in:
Mark Spanbroek 2024-10-29 12:35:06 +01:00
parent 415a8fcc3f
commit 26234bec9c
2 changed files with 11 additions and 0 deletions

View File

@ -89,6 +89,8 @@ func check*(validator: Validator, signed: SignedBlock): auto =
return BlockCheck.invalid("block is not signed by a committee member")
if member != signed.blck.author:
return BlockCheck.invalid("block is not signed by its author")
if signed.blck.round > validator.round:
return BlockCheck.invalid("block has a round number that is too high")
for parent in signed.blck.parents:
if parent.round >= signed.blck.round:
return BlockCheck.invalid("block has a parent from an invalid round")

View File

@ -114,6 +114,7 @@ suite "Multiple Validators":
test "refuses proposals without >2/3 parents from the previous round":
let parents = exchangeProposals().mapIt(it.blck.id)
nextRound()
let blck = Block.new(
CommitteeMember(0),
round = 1,
@ -142,6 +143,14 @@ suite "Multiple Validators":
check checked.verdict == BlockVerdict.incomplete
check checked.missing == @[parents[0].blck.id]
test "refuses proposals with a round number that is too high":
discard exchangeProposals()
validators[0].nextRound()
let proposal = validators[0].propose(seq[Transaction].example)
let checked = validators[1].check(proposal)
check checked.verdict == BlockVerdict.invalid
check checked.reason == "block has a round number that is too high"
test "skips blocks that are ignored by >2f validators":
# first round: other validators do not receive proposal from first validator
let proposals = exchangeProposals {