From df52586252bde93da63cc3697ab5016ee64e43ad Mon Sep 17 00:00:00 2001 From: Adam Szkoda Date: Thu, 5 Dec 2024 11:45:26 +0100 Subject: [PATCH 1/2] Warn on cache write failure --- pkg/cache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cache.go b/pkg/cache.go index ba18a8e..83dd835 100644 --- a/pkg/cache.go +++ b/pkg/cache.go @@ -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()) From f9715323360dc7cbf3d2256529e0daba420fd0b5 Mon Sep 17 00:00:00 2001 From: Adam Szkoda Date: Thu, 5 Dec 2024 12:19:35 +0100 Subject: [PATCH 2/2] Fix off-by-one bug in attestation distance calculation --- pkg/monitoring.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/monitoring.go b/pkg/monitoring.go index 6b997b5..5814de5 100644 --- a/pkg/monitoring.go +++ b/pkg/monitoring.go @@ -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", @@ -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-- }