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,
|
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!
|
finalized_slot and we never prune things before that, per below condition!
|
||||||
""" &
|
""" &
|
||||||
", attestationSlot: " & $shortLog(attestationSlot) &
|
", attestationSlot: " & $shortLog(attestationSlot) &
|
||||||
|
@ -145,6 +145,16 @@ proc addResolved(pool: var AttestationPool, blck: BlockRef, attestation: Attesta
|
||||||
attestation = shortLog(attestation),
|
attestation = shortLog(attestation),
|
||||||
blockSlot = shortLog(blck.slot)
|
blockSlot = shortLog(blck.slot)
|
||||||
return
|
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):
|
# if not isValidAttestationSlot(attestation.data.slot, blck.slot):
|
||||||
# # Logging in isValidAttestationSlot
|
# # Logging in isValidAttestationSlot
|
||||||
# return
|
# return
|
||||||
|
@ -161,8 +171,6 @@ proc addResolved(pool: var AttestationPool, blck: BlockRef, attestation: Attesta
|
||||||
# on the state and those that don't to cheaply
|
# on the state and those that don't to cheaply
|
||||||
# discard invalid attestations before rewinding state.
|
# discard invalid attestations before rewinding state.
|
||||||
|
|
||||||
# TODO: stateCache usage
|
|
||||||
var stateCache = get_empty_per_epoch_cache()
|
|
||||||
if not isValidAttestationTargetEpoch(state, attestation.data):
|
if not isValidAttestationTargetEpoch(state, attestation.data):
|
||||||
notice "Invalid attestation",
|
notice "Invalid attestation",
|
||||||
attestation = shortLog(attestation),
|
attestation = shortLog(attestation),
|
||||||
|
|
|
@ -329,11 +329,12 @@ proc storeBlock(
|
||||||
|
|
||||||
# The block we received contains attestations, and we might not yet know about
|
# The block we received contains attestations, and we might not yet know about
|
||||||
# all of them. Let's add them to the attestation pool.
|
# all of them. Let's add them to the attestation pool.
|
||||||
let currentSlot = node.beaconClock.now.toSlot
|
for attestation in signedBlock.message.body.attestations:
|
||||||
if currentSlot.afterGenesis and
|
debug "Attestation from block",
|
||||||
signedBlock.message.slot.epoch + 1 >= currentSlot.slot.epoch:
|
attestation = shortLog(attestation),
|
||||||
for attestation in signedBlock.message.body.attestations:
|
cat = "consensus" # Tag "consensus|attestation"?
|
||||||
node.onAttestation(attestation)
|
|
||||||
|
node.attestationPool.add(attestation)
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
proc onBeaconBlock(node: BeaconNode, signedBlock: SignedBeaconBlock) =
|
proc onBeaconBlock(node: BeaconNode, signedBlock: SignedBeaconBlock) =
|
||||||
|
|
Loading…
Reference in New Issue