mirror of
https://github.com/logos-storage/nim-mysticeti.git
synced 2026-01-07 16:13:11 +00:00
ignore parents that are too old to matter
This commit is contained in:
parent
26234bec9c
commit
09f7257bd3
@ -109,8 +109,9 @@ func check*(validator: Validator, signed: SignedBlock): auto =
|
|||||||
)
|
)
|
||||||
var missing: seq[BlockId]
|
var missing: seq[BlockId]
|
||||||
for parent in signed.blck.parents:
|
for parent in signed.blck.parents:
|
||||||
if validator.rounds.latest.find(parent).isNone:
|
if parent.round >= validator.rounds.oldest.number:
|
||||||
missing.add(parent)
|
if validator.rounds.latest.find(parent).isNone:
|
||||||
|
missing.add(parent)
|
||||||
if missing.len > 0:
|
if missing.len > 0:
|
||||||
return BlockCheck.incomplete(missing)
|
return BlockCheck.incomplete(missing)
|
||||||
BlockCheck.correct(signed)
|
BlockCheck.correct(signed)
|
||||||
|
|||||||
@ -143,6 +143,31 @@ suite "Multiple Validators":
|
|||||||
check checked.verdict == BlockVerdict.incomplete
|
check checked.verdict == BlockVerdict.incomplete
|
||||||
check checked.missing == @[parents[0].blck.id]
|
check checked.missing == @[parents[0].blck.id]
|
||||||
|
|
||||||
|
test "does not refuse proposals with an unknown parent block that is too old":
|
||||||
|
# first round: nobody receives proposal from validator 0
|
||||||
|
discard exchangeProposals {
|
||||||
|
0: @[],
|
||||||
|
1: @[0, 1, 2, 3],
|
||||||
|
2: @[0, 1, 2, 3],
|
||||||
|
3: @[0, 1, 2, 3]
|
||||||
|
}
|
||||||
|
# for the second to the sixth round, validator 0 is down
|
||||||
|
for _ in 2..6:
|
||||||
|
for validator in validators[1..3]:
|
||||||
|
validator.nextRound()
|
||||||
|
discard exchangeProposals {
|
||||||
|
1: @[1, 2, 3],
|
||||||
|
2: @[1, 2, 3],
|
||||||
|
3: @[1, 2, 3]
|
||||||
|
}
|
||||||
|
# validator 1 cleans up old blocks
|
||||||
|
discard toSeq(validators[1].committed())
|
||||||
|
# validator 0 comes back online and creates block for second round
|
||||||
|
validators[0].nextRound()
|
||||||
|
let proposal = validators[0].propose(seq[Transaction].example)
|
||||||
|
# validator 1 accepts block even though parent has already been cleaned up
|
||||||
|
check validators[1].check(proposal).verdict == BlockVerdict.correct
|
||||||
|
|
||||||
test "refuses proposals with a round number that is too high":
|
test "refuses proposals with a round number that is too high":
|
||||||
discard exchangeProposals()
|
discard exchangeProposals()
|
||||||
validators[0].nextRound()
|
validators[0].nextRound()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user