fix block pool finalization point init

This commit is contained in:
Jacek Sieka 2020-01-23 13:23:57 +01:00 committed by zah
parent 7781536576
commit d9c98b15c8
2 changed files with 15 additions and 1 deletions

View File

@ -206,7 +206,7 @@ proc init*(T: type BlockPool, db: BeaconChainDB): BlockPool =
tmpState[] = db.getState(latestStateRoot.get().stateRoot)
let
finalizedSlot =
tmpState[].get().current_justified_checkpoint.epoch.compute_start_slot_at_epoch()
tmpState[].get().finalized_checkpoint.epoch.compute_start_slot_at_epoch()
finalizedHead = headRef.findAncestorBySlot(finalizedSlot)
justifiedSlot =
tmpState[].get().current_justified_checkpoint.epoch.compute_start_slot_at_epoch()

View File

@ -221,3 +221,17 @@ when const_preset == "minimal": # Too much stack space used on mainnet
pool.heads.len() == 1
pool.head.justified.slot.compute_epoch_at_slot() == 5
pool.tail.children.len == 1
let
pool2 = BlockPool.init(db)
# check that the state reloaded from database resembles what we had before
check:
pool2.tail.root == pool.tail.root
pool2.head.blck.root == pool.head.blck.root
pool2.finalizedHead.blck.root == pool.finalizedHead.blck.root
pool2.finalizedHead.slot == pool.finalizedHead.slot
hash_tree_root(pool2.headState.data.data) ==
hash_tree_root(pool.headState.data.data)
hash_tree_root(pool2.justifiedState.data.data) ==
hash_tree_root(pool.justifiedState.data.data)