From 1f2a36b31688f72c6abc3f00dfe8f179da0bfbba Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Tue, 31 Mar 2026 13:43:57 +0100 Subject: [PATCH] fix(telemetry): fix ValidationTracker grace period boundary and hard trim - Use >= instead of > for grace period comparison to reconcile at exactly 8 seconds rather than skipping the boundary - Two-pass hard trim: first remove entries past late-repair window, then any reconciled entry, to avoid sabotaging late repairs Co-Authored-By: Claude Opus 4.6 (1M context) --- src/xrpld/telemetry/detail/ValidationTracker.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/xrpld/telemetry/detail/ValidationTracker.cpp b/src/xrpld/telemetry/detail/ValidationTracker.cpp index cd8133d24c..c5dfae2d27 100644 --- a/src/xrpld/telemetry/detail/ValidationTracker.cpp +++ b/src/xrpld/telemetry/detail/ValidationTracker.cpp @@ -48,7 +48,7 @@ ValidationTracker::reconcile() for (auto& [hash, evt] : pending_) { - if (!evt.reconciled && (now - evt.recordTime) > kGracePeriod) + if (!evt.reconciled && (now - evt.recordTime) >= kGracePeriod) { // Initial reconciliation after grace period. evt.reconciled = true; @@ -106,9 +106,21 @@ ValidationTracker::evictOldPending(TimePoint now) ++it; } - // Hard trim if still over limit -- remove oldest reconciled entries. + // Hard trim if still over limit -- remove reconciled entries that are + // past the late-repair window first, then any reconciled entry as a + // last resort. if (pending_.size() > kMaxPendingEvents) { + // Pass 1: only entries past late-repair window. + for (auto it = pending_.begin(); + it != pending_.end() && pending_.size() > kMaxPendingEvents;) + { + if (it->second.reconciled && it->second.recordTime < cutoff) + it = pending_.erase(it); + else + ++it; + } + // Pass 2: any reconciled entry if still over limit. for (auto it = pending_.begin(); it != pending_.end() && pending_.size() > kMaxPendingEvents;) {