mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-28 07:15:57 +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
|
doAssert status.isOk(), "Error in preloading the fork choice: " & $status.error
|
||||||
|
|
||||||
info "Fork choice initialized",
|
info "Fork choice initialized",
|
||||||
justified_epoch = getStateField(
|
justified = shortLog(getStateField(
|
||||||
dag.headState, current_justified_checkpoint).epoch,
|
dag.headState, current_justified_checkpoint)),
|
||||||
finalized_epoch = getStateField(dag.headState, finalized_checkpoint).epoch,
|
finalized = shortLog(getStateField(dag.headState, finalized_checkpoint))
|
||||||
finalized_root = shortLog(dag.finalizedHead.blck.root)
|
|
||||||
|
|
||||||
T(
|
T(
|
||||||
dag: dag,
|
dag: dag,
|
||||||
quarantine: quarantine,
|
quarantine: quarantine,
|
||||||
|
@ -1696,7 +1696,11 @@ proc updateHead*(
|
|||||||
let
|
let
|
||||||
finalized_checkpoint =
|
finalized_checkpoint =
|
||||||
getStateField(dag.headState, 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)
|
finalizedHead = newHead.atSlot(finalizedSlot)
|
||||||
|
|
||||||
doAssert (not finalizedHead.blck.isNil),
|
doAssert (not finalizedHead.blck.isNil),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user