From 40a4e7159b02218d93dc78ed00d68baee329c029 Mon Sep 17 00:00:00 2001 From: frstrtr Date: Fri, 26 Jun 2026 08:13:29 +0000 Subject: [PATCH] dgb: route consensus get_desired_version_weights clamp onto chain_walk_window SSOT The 60%-by-work version-switch gate input (get_desired_version_weights) was the last consensus-surface accessor still clamping the lookbehind window inline (std::min(lookbehind, height) + actual<=0). Its diagnostic counts sibling already delegates to dgb::chain_walk_window_count/_active; this routes the consensus accessor through the same SSOT. Byte-identical (min(lookbehind, height) / >0), value-invariant by construction. Pinned non-circularly by the existing DgbChainWalkWindow.DelegationMatchesPreDelegationInline matrix KAT, which re-derives std::min/(<=0) verbatim and already cites this call site. KATs green: dgb_chain_walk_window_test 5/5, dgb_desired_version_tally_test 6/6. Fenced to src/impl/dgb/. No self-merge. --- src/impl/dgb/coin/chain_walk_window.hpp | 13 ++++++++----- src/impl/dgb/share_tracker.hpp | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/impl/dgb/coin/chain_walk_window.hpp b/src/impl/dgb/coin/chain_walk_window.hpp index de3ce9759..8327bb0c4 100644 --- a/src/impl/dgb/coin/chain_walk_window.hpp +++ b/src/impl/dgb/coin/chain_walk_window.hpp @@ -40,11 +40,14 @@ // // Per-coin isolation: dgb/ only. Header-only, additive, free functions over the // already-resolved (height, lookbehind) pair -- the get_chain skip-list walk -// stays in the forest. This slice does NOT rewire share_tracker.hpp; the four -// call sites keep their inline std::min/(actual<=0) guards. That byte-identity -// delegation is the follow-on (mirrors #414 redistribute rewire). The lifted -// body is a verbatim copy of the inline clamp (same int32_t height, same -// std::min, same <=0 comparison), so the follow-on is provably value-identical. +// stays in the forest. Delegation follow-on (mirrors #414 redistribute rewire): +// the two desired_version accessors -- get_desired_version_counts AND the +// consensus get_desired_version_weights (60%-by-work switch-gate input) -- now +// route their clamp through these helpers; get_average_stale_prop / +// get_stale_counts keep their inline std::min/(actual<=0) guards pending their +// own follow-on. The lifted body is a verbatim copy of the inline clamp (same +// int32_t height, same std::min, same <=0 comparison), proven value-identical by +// DgbChainWalkWindow.DelegationMatchesPreDelegationInline over a dense matrix. // Consensus-neutral: pure arithmetic, no value semantics changed. #include diff --git a/src/impl/dgb/share_tracker.hpp b/src/impl/dgb/share_tracker.hpp index f404945ef..94eb825f1 100644 --- a/src/impl/dgb/share_tracker.hpp +++ b/src/impl/dgb/share_tracker.hpp @@ -2168,8 +2168,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;