mirror of
https://github.com/logos-storage/nim-mysticeti.git
synced 2026-05-14 21:59:38 +00:00
refuse proposals with a round number that is too high
This commit is contained in:
parent
415a8fcc3f
commit
26234bec9c
@ -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")
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user