mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-14 16:47:21 +00:00
dag: protect against finalized epoch moving before BlockRef cutoff (#3847)
This commit is contained in:
parent
9de2c6171f
commit
b00eac7a50
@ -152,11 +152,9 @@ proc init*(T: type AttestationPool, dag: ChainDAGRef,
|
||||
doAssert status.isOk(), "Error in preloading the fork choice: " & $status.error
|
||||
|
||||
info "Fork choice initialized",
|
||||
justified_epoch = getStateField(
|
||||
dag.headState, current_justified_checkpoint).epoch,
|
||||
finalized_epoch = getStateField(dag.headState, finalized_checkpoint).epoch,
|
||||
finalized_root = shortLog(dag.finalizedHead.blck.root)
|
||||
|
||||
justified = shortLog(getStateField(
|
||||
dag.headState, current_justified_checkpoint)),
|
||||
finalized = shortLog(getStateField(dag.headState, finalized_checkpoint))
|
||||
T(
|
||||
dag: dag,
|
||||
quarantine: quarantine,
|
||||
|
@ -1696,7 +1696,11 @@ proc updateHead*(
|
||||
let
|
||||
finalized_checkpoint =
|
||||
getStateField(dag.headState, finalized_checkpoint)
|
||||
finalizedSlot = max(finalized_checkpoint.epoch.start_slot(), dag.tail.slot)
|
||||
finalizedSlot =
|
||||
# finalized checkpoint may move back in the head state compared to what
|
||||
# we've seen in other forks - it does not move back in fork choice
|
||||
# however, so we'll use the last-known-finalized in that case
|
||||
max(finalized_checkpoint.epoch.start_slot(), dag.finalizedHead.slot)
|
||||
finalizedHead = newHead.atSlot(finalizedSlot)
|
||||
|
||||
doAssert (not finalizedHead.blck.isNil),
|
||||
|
Loading…
x
Reference in New Issue
Block a user