Skip to content

Commit

Permalink
Fix off-by-one bug in attestation distance calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
adaszko committed Dec 5, 2024
1 parent dff133f commit 31ee4d2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ func MonitorAttestationsAndProposals(ctx context.Context, beacon *beaconchain.Be
})
prometheus.MustRegister(totalDelayedAttestationsOverToleranceCounter)

// https://www.attestant.io/posts/defining-attestation-effectiveness/
canonicalAttestationDistances := prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: "ETH2",
Name: "canonicalAttestationDistances",
Expand Down Expand Up @@ -477,9 +478,11 @@ func MonitorAttestationsAndProposals(ctx context.Context, beacon *beaconchain.Be
continue
}

attestationDistance := blockSlot - phase0.Slot(attestedSlot)
// Take skipped slots into account
for s := attestedSlot; s < uint64(blockSlot); s++ {
// https://www.attestant.io/posts/defining-attestation-effectiveness/
earliestInclusionSlot := attestedSlot + 1
attestationDistance := blockSlot - phase0.Slot(earliestInclusionSlot)
// Do not penalize the validator for skipped slots
for s := earliestInclusionSlot; s < uint64(blockSlot); s++ {
if _, ok := epochBlocks[s]; !ok {
attestationDistance--
}
Expand Down

0 comments on commit 31ee4d2

Please sign in to comment.