From c6fedcf3ca84d3e8cbda76d5fad8677292c2823f Mon Sep 17 00:00:00 2001 From: frstrtr Date: Fri, 26 Jun 2026 04:59:12 +0000 Subject: [PATCH] dgb: delegate diagnostic lookbehind clamps onto chain_walk_window SSOT (#423 follow-on) Rewire the three DIAGNOSTIC-path lookbehind clamps in share_tracker.hpp (get_average_stale_prop, get_stale_counts, get_desired_version_counts flat-count) onto dgb::chain_walk_window_count / chain_walk_window_active (coin/chain_walk_window.hpp). Byte-identical: the helper returns the same std::min(lookbehind, height) value and the same (actual > 0) walk-activation guard; the static_cast stays at the call site exactly as before. The CONSENSUS-bearing get_desired_version_weights clamp (feeds the check()-phase 60%-by-work v36 switch gate, share_check step 2) is LEFT inline this slice and parked for a separate operator-surfaced tap, per the observation-only scope split. dgb_chain_walk_window_test 5/5 (incl. DelegationMatchesPreDelegationInline), dgb_share_test 34/34. --- src/impl/dgb/share_tracker.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/impl/dgb/share_tracker.hpp b/src/impl/dgb/share_tracker.hpp index dc1a5a17f..f404945ef 100644 --- a/src/impl/dgb/share_tracker.hpp +++ b/src/impl/dgb/share_tracker.hpp @@ -29,6 +29,7 @@ inline uint64_t mul128_shift(uint64_t a, uint64_t b, unsigned shift) { #include // SSOT: accumulate_version_weights / accumulate_version_counts (#429 follow-on) #include "coin/pool_attempts_per_second.hpp" // SSOT: compute_pool_attempts_per_second (#407 follow-on) #include "coin/tail_score_endpoints.hpp" // SSOT: score_* endpoint arithmetic (ShareTracker::score chain-walk, #411 follow-on) +#include "coin/chain_walk_window.hpp" // SSOT: lookbehind clamp (#423 diag follow-on); consensus get_desired_version_weights stays inline #include "config_pool.hpp" #include @@ -2059,8 +2060,8 @@ class ShareTracker float get_average_stale_prop(const uint256& share_hash, uint64_t lookbehind) { auto height = chain.get_height(share_hash); - auto actual_lookbehind = std::min(static_cast(lookbehind), height); - if (actual_lookbehind <= 0) + auto actual_lookbehind = dgb::chain_walk_window_count(height, static_cast(lookbehind)); + if (!dgb::chain_walk_window_active(actual_lookbehind)) return 0.0f; float stale_count = 0; @@ -2081,8 +2082,8 @@ class ShareTracker { StaleCounts counts; auto height = chain.get_height(share_hash); - auto actual_lookbehind = std::min(static_cast(lookbehind), height); - if (actual_lookbehind <= 0) + auto actual_lookbehind = dgb::chain_walk_window_count(height, static_cast(lookbehind)); + if (!dgb::chain_walk_window_active(actual_lookbehind)) return counts; auto view = chain.get_chain(share_hash, actual_lookbehind); @@ -2127,8 +2128,8 @@ class ShareTracker if (!chain.contains(share_hash)) return {}; auto height = chain.get_height(share_hash); - auto actual = std::min(lookbehind, height); - if (actual <= 0) + auto actual = dgb::chain_walk_window_count(height, lookbehind); + if (!dgb::chain_walk_window_active(actual)) return {}; std::vector window;