Fix #2595 - recompute wallSlot across async calls (#2650)

This commit is contained in:
Mamy Ratsimbazafy 2021-06-17 16:38:25 +02:00 committed by GitHub
parent 87ed9e62a1
commit 2adf54e44a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 9 deletions

View File

@ -206,9 +206,8 @@ proc attestationValidator*(
attestation = shortLog(attestation) attestation = shortLog(attestation)
subnet_id subnet_id
let let wallTime = self.getWallTime()
wallTime = self.getWallTime() var (afterGenesis, wallSlot) = wallTime.toSlot()
(afterGenesis, wallSlot) = wallTime.toSlot()
if not afterGenesis: if not afterGenesis:
notice "Attestation before genesis" notice "Attestation before genesis"
@ -225,9 +224,11 @@ proc attestationValidator*(
self.batchCrypto, attestation, wallTime, subnet_id, checkSignature) self.batchCrypto, attestation, wallTime, subnet_id, checkSignature)
if v.isErr(): if v.isErr():
debug "Dropping attestation", validationError = v.error debug "Dropping attestation", validationError = v.error
return v.error[0] return v.error[0]
# Due to async validation the wallSlot here might have changed
(afterGenesis, wallSlot) = self.getWallTime().toSlot()
beacon_attestations_received.inc() beacon_attestations_received.inc()
beacon_attestation_delay.observe(delay.toFloatSeconds()) beacon_attestation_delay.observe(delay.toFloatSeconds())
@ -248,9 +249,8 @@ proc aggregateValidator*(
aggregate = shortLog(signedAggregateAndProof.message.aggregate) aggregate = shortLog(signedAggregateAndProof.message.aggregate)
signature = shortLog(signedAggregateAndProof.signature) signature = shortLog(signedAggregateAndProof.signature)
let let wallTime = self.getWallTime()
wallTime = self.getWallTime() var (afterGenesis, wallSlot) = wallTime.toSlot()
(afterGenesis, wallSlot) = wallTime.toSlot()
if not afterGenesis: if not afterGenesis:
notice "Aggregate before genesis" notice "Aggregate before genesis"
@ -274,6 +274,9 @@ proc aggregateValidator*(
wallSlot wallSlot
return v.error[0] return v.error[0]
# Due to async validation the wallSlot here might have changed
(afterGenesis, wallSlot) = self.getWallTime().toSlot()
beacon_aggregates_received.inc() beacon_aggregates_received.inc()
beacon_aggregate_delay.observe(delay.toFloatSeconds()) beacon_aggregate_delay.observe(delay.toFloatSeconds())
@ -284,8 +287,7 @@ proc aggregateValidator*(
trace "Aggregate validated", trace "Aggregate validated",
aggregator_index = signedAggregateAndProof.message.aggregator_index, aggregator_index = signedAggregateAndProof.message.aggregator_index,
selection_proof = signedAggregateAndProof.message.selection_proof, selection_proof = signedAggregateAndProof.message.selection_proof
wallSlot
self.attestationPool[].addAttestation( self.attestationPool[].addAttestation(
signedAggregateAndProof.message.aggregate, attesting_indices, sig, wallSlot) signedAggregateAndProof.message.aggregate, attesting_indices, sig, wallSlot)