2020-04-09 16:15:00 +00:00
|
|
|
# beacon_chain
|
2023-01-20 14:14:37 +00:00
|
|
|
# Copyright (c) 2018-2023 Status Research & Development GmbH
|
2020-04-09 16:15:00 +00:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2023-01-20 14:14:37 +00:00
|
|
|
{.push raises: [].}
|
2022-07-06 10:33:02 +00:00
|
|
|
|
2021-04-28 16:41:02 +00:00
|
|
|
# import ../interpreter # included to be able to use "suite"
|
2020-04-09 16:15:00 +00:00
|
|
|
|
2021-08-25 14:51:52 +00:00
|
|
|
func setup_finality_02(): tuple[fork_choice: ForkChoiceBackend, ops: seq[Operation]] =
|
2022-02-20 20:13:06 +00:00
|
|
|
let balances = @[Gwei(1), Gwei(1)]
|
2020-04-09 16:15:00 +00:00
|
|
|
let GenesisRoot = fakeHash(0)
|
|
|
|
|
|
|
|
# Initialize the fork choice context
|
2020-08-18 14:56:32 +00:00
|
|
|
result.fork_choice = ForkChoiceBackend.init(
|
2022-07-06 10:33:02 +00:00
|
|
|
FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: GenesisRoot, epoch: Epoch(1)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(1))))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# ----------------------------------
|
|
|
|
|
|
|
|
# Head should be genesis
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: FindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: GenesisRoot, epoch: Epoch(1)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(1))),
|
2020-04-09 16:15:00 +00:00
|
|
|
justified_state_balances: balances,
|
2022-07-06 10:33:02 +00:00
|
|
|
expected_head: GenesisRoot)
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Build the following tree.
|
|
|
|
#
|
|
|
|
# 0
|
|
|
|
# / \
|
|
|
|
# just: 0, fin: 0 -> 1 2 <- just: 0, fin: 0
|
|
|
|
# | |
|
|
|
|
# just: 1, fin: 0 -> 3 4 <- just: 0, fin: 0
|
|
|
|
# | |
|
|
|
|
# just: 1, fin: 0 -> 5 6 <- just: 0, fin: 0
|
|
|
|
# | |
|
|
|
|
# just: 1, fin: 0 -> 7 8 <- just: 1, fin: 0
|
|
|
|
# | |
|
|
|
|
# just: 2, fin: 0 -> 9 10 <- just: 2, fin: 0
|
|
|
|
|
|
|
|
# Left branch
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: ProcessBlock,
|
2023-01-31 12:35:01 +00:00
|
|
|
bid: BlockId(
|
|
|
|
slot: Slot(1),
|
|
|
|
root: fakeHash(1)),
|
2020-04-09 16:15:00 +00:00
|
|
|
parent_root: GenesisRoot,
|
2022-07-06 10:33:02 +00:00
|
|
|
blk_checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: GenesisRoot, epoch: Epoch(0)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))))
|
|
|
|
|
2020-04-09 16:15:00 +00:00
|
|
|
result.ops.add Operation(
|
|
|
|
kind: ProcessBlock,
|
2023-01-31 12:35:01 +00:00
|
|
|
bid: BlockId(
|
|
|
|
slot: Epoch(2).start_slot,
|
|
|
|
root: fakeHash(3)),
|
2020-04-09 16:15:00 +00:00
|
|
|
parent_root: fakeHash(1),
|
2022-07-06 10:33:02 +00:00
|
|
|
blk_checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: fakeHash(1), epoch: Epoch(1)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))))
|
|
|
|
|
2020-04-09 16:15:00 +00:00
|
|
|
result.ops.add Operation(
|
|
|
|
kind: ProcessBlock,
|
2023-01-31 12:35:01 +00:00
|
|
|
bid: BlockId(
|
|
|
|
slot: Epoch(2).start_slot + 2,
|
|
|
|
root: fakeHash(5)),
|
2020-04-09 16:15:00 +00:00
|
|
|
parent_root: fakeHash(3),
|
2022-07-06 10:33:02 +00:00
|
|
|
blk_checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: fakeHash(1), epoch: Epoch(1)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))))
|
|
|
|
|
2020-04-09 16:15:00 +00:00
|
|
|
result.ops.add Operation(
|
|
|
|
kind: ProcessBlock,
|
2023-01-31 12:35:01 +00:00
|
|
|
bid: BlockId(
|
|
|
|
slot: Epoch(2).start_slot + 4,
|
|
|
|
root: fakeHash(7)),
|
2020-04-09 16:15:00 +00:00
|
|
|
parent_root: fakeHash(5),
|
2022-07-06 10:33:02 +00:00
|
|
|
blk_checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: fakeHash(1), epoch: Epoch(1)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))))
|
|
|
|
|
2020-04-09 16:15:00 +00:00
|
|
|
result.ops.add Operation(
|
|
|
|
kind: ProcessBlock,
|
2023-01-31 12:35:01 +00:00
|
|
|
bid: BlockId(
|
|
|
|
slot: Epoch(3).start_slot,
|
|
|
|
root: fakeHash(9)),
|
2020-04-09 16:15:00 +00:00
|
|
|
parent_root: fakeHash(7),
|
2022-07-06 10:33:02 +00:00
|
|
|
blk_checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: fakeHash(3), epoch: Epoch(2)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Build the following tree.
|
|
|
|
#
|
|
|
|
# 0
|
|
|
|
# / \
|
|
|
|
# just: 0, fin: 0 -> 1 2 <- just: 0, fin: 0
|
|
|
|
# | |
|
|
|
|
# just: 1, fin: 0 -> 3 4 <- just: 0, fin: 0
|
|
|
|
# | |
|
|
|
|
# just: 1, fin: 0 -> 5 6 <- just: 0, fin: 0
|
|
|
|
# | |
|
|
|
|
# just: 1, fin: 0 -> 7 8 <- just: 1, fin: 0
|
|
|
|
# | |
|
|
|
|
# just: 2, fin: 0 -> 9 10 <- just: 2, fin: 0
|
|
|
|
|
|
|
|
# Right branch
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: ProcessBlock,
|
2023-01-31 12:35:01 +00:00
|
|
|
bid: BlockId(
|
|
|
|
slot: Slot(2),
|
|
|
|
root: fakeHash(2)),
|
2020-04-09 16:15:00 +00:00
|
|
|
parent_root: GenesisRoot,
|
2022-07-06 10:33:02 +00:00
|
|
|
blk_checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: GenesisRoot, epoch: Epoch(0)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))))
|
|
|
|
|
2020-04-09 16:15:00 +00:00
|
|
|
result.ops.add Operation(
|
|
|
|
kind: ProcessBlock,
|
2023-01-31 12:35:01 +00:00
|
|
|
bid: BlockId(
|
|
|
|
slot: Epoch(1).start_slot + 1,
|
|
|
|
root: fakeHash(4)),
|
2020-04-09 16:15:00 +00:00
|
|
|
parent_root: fakeHash(2),
|
2022-07-06 10:33:02 +00:00
|
|
|
blk_checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: GenesisRoot, epoch: Epoch(0)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))))
|
|
|
|
|
2020-04-09 16:15:00 +00:00
|
|
|
result.ops.add Operation(
|
|
|
|
kind: ProcessBlock,
|
2023-01-31 12:35:01 +00:00
|
|
|
bid: BlockId(
|
|
|
|
slot: Epoch(2).start_slot + 3,
|
|
|
|
root: fakeHash(6)),
|
2020-04-09 16:15:00 +00:00
|
|
|
parent_root: fakeHash(4),
|
2022-07-06 10:33:02 +00:00
|
|
|
blk_checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: GenesisRoot, epoch: Epoch(0)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))))
|
|
|
|
|
2020-04-09 16:15:00 +00:00
|
|
|
result.ops.add Operation(
|
|
|
|
kind: ProcessBlock,
|
2023-01-31 12:35:01 +00:00
|
|
|
bid: BlockId(
|
|
|
|
slot: Epoch(3).start_slot + 1,
|
|
|
|
root: fakeHash(8)),
|
2020-04-09 16:15:00 +00:00
|
|
|
parent_root: fakeHash(6),
|
2022-07-06 10:33:02 +00:00
|
|
|
blk_checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: fakeHash(2), epoch: Epoch(1)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))))
|
|
|
|
|
2020-04-09 16:15:00 +00:00
|
|
|
result.ops.add Operation(
|
|
|
|
kind: ProcessBlock,
|
2023-01-31 12:35:01 +00:00
|
|
|
bid: BlockId(
|
|
|
|
slot: Epoch(5).start_slot + 1,
|
|
|
|
root: fakeHash(10)),
|
2020-04-09 16:15:00 +00:00
|
|
|
parent_root: fakeHash(8),
|
2022-07-06 10:33:02 +00:00
|
|
|
blk_checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: fakeHash(4), epoch: Epoch(2)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Ensure that if we start at 0 we find 10 (just: 0, fin: 0).
|
|
|
|
#
|
|
|
|
# 0 <-- start
|
|
|
|
# / \
|
|
|
|
# 1 2
|
|
|
|
# | |
|
|
|
|
# 3 4
|
|
|
|
# | |
|
|
|
|
# 5 6
|
|
|
|
# | |
|
|
|
|
# 7 8
|
|
|
|
# | |
|
|
|
|
# 9 10 <-- head
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: FindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: GenesisRoot, epoch: Epoch(0)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
2020-04-09 16:15:00 +00:00
|
|
|
justified_state_balances: balances,
|
2022-07-06 10:33:02 +00:00
|
|
|
expected_head: fakeHash(10))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Same with justified_epoch 2
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: FindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: fakeHash(4), epoch: Epoch(2)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
2020-04-09 16:15:00 +00:00
|
|
|
justified_state_balances: balances,
|
2022-07-06 10:33:02 +00:00
|
|
|
expected_head: fakeHash(10))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Justified epoch 3 is invalid
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: InvalidFindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: fakeHash(4), epoch: Epoch(3)), # < Wrong epoch
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
|
|
|
justified_state_balances: balances)
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Add a vote to 1.
|
|
|
|
#
|
|
|
|
# 0
|
|
|
|
# / \
|
|
|
|
# +1 vote -> 1 2
|
|
|
|
# | |
|
|
|
|
# 3 4
|
|
|
|
# | |
|
|
|
|
# 5 6
|
|
|
|
# | |
|
|
|
|
# 7 8
|
|
|
|
# | |
|
|
|
|
# 9 10
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: ProcessAttestation,
|
|
|
|
validator_index: ValidatorIndex(0),
|
2022-04-14 10:47:14 +00:00
|
|
|
block_root: fakeHash(1),
|
2022-07-06 10:33:02 +00:00
|
|
|
target_epoch: Epoch(0))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Ensure that if we start at 0 we find 9 (just: 0, fin: 0).
|
|
|
|
#
|
|
|
|
# 0 <-- start
|
|
|
|
# / \
|
|
|
|
# 1 2
|
|
|
|
# | |
|
|
|
|
# 3 4
|
|
|
|
# | |
|
|
|
|
# 5 6
|
|
|
|
# | |
|
|
|
|
# 7 8
|
|
|
|
# | |
|
|
|
|
# head -> 9 10
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: FindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: GenesisRoot, epoch: Epoch(0)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
2020-04-09 16:15:00 +00:00
|
|
|
justified_state_balances: balances,
|
2022-07-06 10:33:02 +00:00
|
|
|
expected_head: fakeHash(9))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Same with justified_epoch 2
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: FindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: fakeHash(3), epoch: Epoch(2)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
2020-04-09 16:15:00 +00:00
|
|
|
justified_state_balances: balances,
|
2022-07-06 10:33:02 +00:00
|
|
|
expected_head: fakeHash(9))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Justified epoch 3 is invalid
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: InvalidFindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: GenesisRoot, epoch: Epoch(3)), # < Wrong epoch
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
|
|
|
justified_state_balances: balances)
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Add a vote to 2.
|
|
|
|
#
|
|
|
|
# 0
|
|
|
|
# / \
|
|
|
|
# 1 2 <- +1 vote
|
|
|
|
# | |
|
|
|
|
# 3 4
|
|
|
|
# | |
|
|
|
|
# 5 6
|
|
|
|
# | |
|
|
|
|
# 7 8
|
|
|
|
# | |
|
|
|
|
# 9 10
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: ProcessAttestation,
|
|
|
|
validator_index: ValidatorIndex(1),
|
2022-04-14 10:47:14 +00:00
|
|
|
block_root: fakeHash(2),
|
2022-07-06 10:33:02 +00:00
|
|
|
target_epoch: Epoch(0))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Ensure that if we start at 0 we find 10 again (just: 0, fin: 0).
|
|
|
|
#
|
|
|
|
# 0 <-- start
|
|
|
|
# / \
|
|
|
|
# 1 2
|
|
|
|
# | |
|
|
|
|
# 3 4
|
|
|
|
# | |
|
|
|
|
# 5 6
|
|
|
|
# | |
|
|
|
|
# 7 8
|
|
|
|
# | |
|
|
|
|
# 9 10 <-- head
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: FindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: GenesisRoot, epoch: Epoch(0)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
2020-04-09 16:15:00 +00:00
|
|
|
justified_state_balances: balances,
|
2022-07-06 10:33:02 +00:00
|
|
|
expected_head: fakeHash(10))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Same with justified_epoch 2
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: FindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: fakeHash(4), epoch: Epoch(2)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
2020-04-09 16:15:00 +00:00
|
|
|
justified_state_balances: balances,
|
2022-07-06 10:33:02 +00:00
|
|
|
expected_head: fakeHash(10))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Justified epoch 3 is invalid
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: InvalidFindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: GenesisRoot, epoch: Epoch(3)), # < Wrong epoch
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
|
|
|
justified_state_balances: balances)
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Ensure that if we start at 1 (instead of 0) we find 9 (just: 0, fin: 0).
|
|
|
|
#
|
|
|
|
# 0
|
|
|
|
# / \
|
|
|
|
# start-> 1 2
|
|
|
|
# | |
|
|
|
|
# 3 4
|
|
|
|
# | |
|
|
|
|
# 5 6
|
|
|
|
# | |
|
|
|
|
# 7 8
|
|
|
|
# | |
|
|
|
|
# head -> 9 10
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: FindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
# Justified: In production the root/epoch mismatch isn't used.
|
|
|
|
justified: Checkpoint(root: fakeHash(1), epoch: Epoch(0)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
2020-04-09 16:15:00 +00:00
|
|
|
justified_state_balances: balances,
|
2022-07-06 10:33:02 +00:00
|
|
|
expected_head: fakeHash(9))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Same with justified_epoch 2
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: FindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: fakeHash(3), epoch: Epoch(2)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
2020-04-09 16:15:00 +00:00
|
|
|
justified_state_balances: balances,
|
2022-07-06 10:33:02 +00:00
|
|
|
expected_head: fakeHash(9))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Justified epoch 3 is invalid
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: InvalidFindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: fakeHash(5), epoch: Epoch(3)), # < Wrong epoch
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
|
|
|
justified_state_balances: balances)
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Ensure that if we start at 2 (instead of 0) we find 10 (just: 0, fin: 0).
|
|
|
|
#
|
|
|
|
# 0
|
|
|
|
# / \
|
|
|
|
# 1 2 <- start
|
|
|
|
# | |
|
|
|
|
# 3 4
|
|
|
|
# | |
|
|
|
|
# 5 6
|
|
|
|
# | |
|
|
|
|
# 7 8
|
|
|
|
# | |
|
|
|
|
# 9 10 <- head
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: FindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
# Justified: In production this can't happen
|
|
|
|
justified: Checkpoint(root: fakeHash(2), epoch: Epoch(0)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
2020-04-09 16:15:00 +00:00
|
|
|
justified_state_balances: balances,
|
2022-07-06 10:33:02 +00:00
|
|
|
expected_head: fakeHash(10))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Same with justified_epoch 2
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: FindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: fakeHash(4), epoch: Epoch(2)),
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
2020-04-09 16:15:00 +00:00
|
|
|
justified_state_balances: balances,
|
2022-07-06 10:33:02 +00:00
|
|
|
expected_head: fakeHash(10))
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
# Justified epoch 3 is invalid
|
|
|
|
result.ops.add Operation(
|
|
|
|
kind: InvalidFindHead,
|
2022-07-06 10:33:02 +00:00
|
|
|
checkpoints: FinalityCheckpoints(
|
|
|
|
justified: Checkpoint(root: fakeHash(4), epoch: Epoch(3)), # < Wrong epoch
|
|
|
|
finalized: Checkpoint(root: GenesisRoot, epoch: Epoch(0))),
|
|
|
|
justified_state_balances: balances)
|
2020-04-09 16:15:00 +00:00
|
|
|
|
|
|
|
proc test_ffg02() =
|
2021-04-28 16:41:02 +00:00
|
|
|
test "fork_choice - testing finality #02":
|
2020-04-09 16:15:00 +00:00
|
|
|
# for i in 0 ..< 12:
|
|
|
|
# echo " block (", i, ") hash: ", fakeHash(i)
|
|
|
|
# echo " ------------------------------------------------------"
|
|
|
|
|
|
|
|
var (ctx, ops) = setup_finality_02()
|
|
|
|
ctx.run(ops)
|
|
|
|
|
|
|
|
test_ffg02()
|