Skip to content

Commit

Permalink
Merge pull request #23 from stakefish/tweaks
Browse files Browse the repository at this point in the history
Fix an incompatibility in metrics calculation
  • Loading branch information
adaszko authored Dec 6, 2024
2 parents 1cade97 + f971532 commit c1c73b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func SaveCache(newCache *LocalCache) {

tmpfile, err := os.CreateTemp("", "stakefish-eth2-monitor-cache.*.json")
if err != nil {
log.Debug().Err(err).Msg("SaveCache: os.Open failed; skip")
log.Warn().Err(err).Msg("SaveCache: os.CreateTemp failed; skip")
return
}
defer os.Remove(tmpfile.Name())
Expand Down
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 validator for skipped slots
for s := earliestInclusionSlot; s < uint64(blockSlot); s++ {
if _, ok := epochBlocks[s]; !ok {
attestationDistance--
}
Expand Down

0 comments on commit c1c73b7

Please sign in to comment.