count attestations from blocks while syncing (#1244)
* count attestations from blocks while syncing * check for resolved old attestations
This commit is contained in:
parent
c78486240e
commit
ea57852359
|
@ -61,7 +61,7 @@ proc slotIndex(
|
|||
|
||||
doAssert attestationSlot >= pool.startingSlot,
|
||||
"""
|
||||
We should have checked in validate that attestation is newer than
|
||||
We should have checked in addResolved that attestation is newer than
|
||||
finalized_slot and we never prune things before that, per below condition!
|
||||
""" &
|
||||
", attestationSlot: " & $shortLog(attestationSlot) &
|
||||
|
@ -145,6 +145,16 @@ proc addResolved(pool: var AttestationPool, blck: BlockRef, attestation: Attesta
|
|||
attestation = shortLog(attestation),
|
||||
blockSlot = shortLog(blck.slot)
|
||||
return
|
||||
|
||||
if attestation.data.slot < pool.startingSlot:
|
||||
# It can happen that attestations in blocks for example are included even
|
||||
# though they no longer are relevant for finalization - let's clear
|
||||
# these out
|
||||
debug "Old attestation",
|
||||
attestation = shortLog(attestation),
|
||||
startingSlot = pool.startingSlot
|
||||
return
|
||||
|
||||
# if not isValidAttestationSlot(attestation.data.slot, blck.slot):
|
||||
# # Logging in isValidAttestationSlot
|
||||
# return
|
||||
|
@ -161,8 +171,6 @@ proc addResolved(pool: var AttestationPool, blck: BlockRef, attestation: Attesta
|
|||
# on the state and those that don't to cheaply
|
||||
# discard invalid attestations before rewinding state.
|
||||
|
||||
# TODO: stateCache usage
|
||||
var stateCache = get_empty_per_epoch_cache()
|
||||
if not isValidAttestationTargetEpoch(state, attestation.data):
|
||||
notice "Invalid attestation",
|
||||
attestation = shortLog(attestation),
|
||||
|
|
|
@ -329,11 +329,12 @@ proc storeBlock(
|
|||
|
||||
# The block we received contains attestations, and we might not yet know about
|
||||
# all of them. Let's add them to the attestation pool.
|
||||
let currentSlot = node.beaconClock.now.toSlot
|
||||
if currentSlot.afterGenesis and
|
||||
signedBlock.message.slot.epoch + 1 >= currentSlot.slot.epoch:
|
||||
for attestation in signedBlock.message.body.attestations:
|
||||
node.onAttestation(attestation)
|
||||
for attestation in signedBlock.message.body.attestations:
|
||||
debug "Attestation from block",
|
||||
attestation = shortLog(attestation),
|
||||
cat = "consensus" # Tag "consensus|attestation"?
|
||||
|
||||
node.attestationPool.add(attestation)
|
||||
ok()
|
||||
|
||||
proc onBeaconBlock(node: BeaconNode, signedBlock: SignedBeaconBlock) =
|
||||
|
|
Loading…
Reference in New Issue