delay pruning of cache for finalized epoch (fixes #2049)
This commit is contained in:
parent
316a19af5f
commit
dbcc0686ff
|
@ -902,7 +902,8 @@ proc updateHead*(
|
||||||
while tmp != dag.finalizedHead.blck:
|
while tmp != dag.finalizedHead.blck:
|
||||||
# leave the epoch cache in the last block of the epoch..
|
# leave the epoch cache in the last block of the epoch..
|
||||||
tmp = tmp.parent
|
tmp = tmp.parent
|
||||||
tmp.epochRefs = @[]
|
if tmp.parent != nil:
|
||||||
|
tmp.parent.epochRefs = @[]
|
||||||
|
|
||||||
dag.finalizedHead = finalizedHead
|
dag.finalizedHead = finalizedHead
|
||||||
|
|
||||||
|
|
|
@ -405,11 +405,9 @@ proc handleAttestations(node: BeaconNode, head: BlockRef, slot: Slot) =
|
||||||
proc handleProposal(node: BeaconNode, head: BlockRef, slot: Slot):
|
proc handleProposal(node: BeaconNode, head: BlockRef, slot: Slot):
|
||||||
Future[BlockRef] {.async.} =
|
Future[BlockRef] {.async.} =
|
||||||
## Perform the proposal for the given slot, iff we have a validator attached
|
## Perform the proposal for the given slot, iff we have a validator attached
|
||||||
## that is supposed to do so, given the shuffling in head
|
## that is supposed to do so, given the shuffling at that slot for the given
|
||||||
|
## head - to compute the proposer, we need to advance a state to the given
|
||||||
# TODO here we advance the state to the new slot, but later we'll be
|
## slot
|
||||||
# proposing for it - basically, we're selecting proposer based on an
|
|
||||||
# empty slot
|
|
||||||
|
|
||||||
let proposer = node.chainDag.getProposer(head, slot)
|
let proposer = node.chainDag.getProposer(head, slot)
|
||||||
if proposer.isNone():
|
if proposer.isNone():
|
||||||
|
|
|
@ -373,7 +373,9 @@ suiteReport "chain DAG finalization tests" & preset():
|
||||||
check:
|
check:
|
||||||
dag.heads.len() == 1
|
dag.heads.len() == 1
|
||||||
|
|
||||||
let headER = dag.heads[0].findEpochRef(dag.heads[0].slot.epoch)
|
let
|
||||||
|
headER = dag.heads[0].findEpochRef(dag.heads[0].slot.epoch)
|
||||||
|
finalER = dag.finalizedHead.blck.findEpochRef(dag.finalizedHead.slot.epoch)
|
||||||
check:
|
check:
|
||||||
|
|
||||||
# Epochrefs should share validator key set when the validator set is
|
# Epochrefs should share validator key set when the validator set is
|
||||||
|
@ -385,10 +387,14 @@ suiteReport "chain DAG finalization tests" & preset():
|
||||||
headER.validator_key_store[1] ==
|
headER.validator_key_store[1] ==
|
||||||
dag.heads[0].findEpochRef(dag.heads[0].slot.epoch - 1).validator_key_store[1]
|
dag.heads[0].findEpochRef(dag.heads[0].slot.epoch - 1).validator_key_store[1]
|
||||||
|
|
||||||
|
# The EpochRef for the finalized block is needed for eth1 voting, so we
|
||||||
|
# should never drop it!
|
||||||
|
not finalER.isNil
|
||||||
|
|
||||||
block:
|
block:
|
||||||
var cur = dag.heads[0]
|
var cur = dag.heads[0]
|
||||||
while cur != nil:
|
while cur != nil:
|
||||||
if cur.slot < dag.finalizedHead.blck.slot:
|
if cur.slot < dag.finalizedHead.blck.parent.slot:
|
||||||
# Cache should be cleaned on finalization
|
# Cache should be cleaned on finalization
|
||||||
check: cur.epochRefs.len == 0
|
check: cur.epochRefs.len == 0
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue