Skip to content

Commit a70620e

Browse files
committed
dgb: rewire ShareTracker::score onto coin/ tail_score SSOT (#411 follow-on)
Production byte-identical delegation of the six pure-arithmetic sites in ShareTracker::score() onto the KAT-pinned coin/tail_score_endpoints.hpp SSOT (landed header-only in #411). The chain walk stays inside the member (it needs the verified skip-list / TrackerView); only the integer endpoint/guard/span arithmetic is delegated: - short-chain guard -> score_head_too_short - 15/16 endpoint offset -> score_endpoint_offset - /16 tail walk count -> score_tail_walk_count - unresolved-block span -> score_resolved_block_span - span clamp -> score_time_span - work/span divide -> score_value Value-identical (same int32_t span type, same uint288 divide); chain_length is a positive net constant so signed/unsigned (CL*15)/16 and CL/16 coincide. Diagnostic tail-ranking arithmetic, fenced to src/impl/dgb/, no consensus value semantics changed. Closes the #411 SSOT drift-risk (header was not yet referenced by the live score path). dgb_share_test 34/34; dgb_tail_score_endpoints_test 8/8.
1 parent e07b2c4 commit a70620e

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/impl/dgb/share_tracker.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ inline uint64_t mul128_shift(uint64_t a, uint64_t b, unsigned shift) {
2727
#include "think_p1_walk_bounds.hpp" // SSOT: think_p1_walk_count / think_p1_in_pruning_zone
2828
#include "coin/naughty_propagation.hpp" // SSOT: propagate_naughty_from_parent (data.py:543-549)
2929
#include <impl/dgb/coin/desired_version_tally.hpp> // SSOT: accumulate_version_weights / accumulate_version_counts (#429 follow-on)
30+
#include "coin/tail_score_endpoints.hpp" // SSOT: score_* endpoint arithmetic (ShareTracker::score chain-walk, #411 follow-on)
3031
#include "config_pool.hpp"
3132

3233
#include <core/target_utils.hpp>
@@ -604,19 +605,19 @@ class ShareTracker
604605
// unverified shares, causing short verified chains to tie on
605606
// chain_len with long chains and win on hashrate tiebreak.
606607
auto head_height = verified.get_acc_height(share_hash);
607-
if (head_height < static_cast<int32_t>(PoolConfig::chain_length()))
608+
if (score_head_too_short(head_height, static_cast<int32_t>(PoolConfig::chain_length())))
608609
return {head_height, score_res};
609610

610611
// p2pool: end_point = self.verified.get_nth_parent_hash(
611612
// share_hash, self.net.CHAIN_LENGTH*15//16)
612613
// SubsetTracker delegates to parent's skip list (shared navigation).
613614
auto end_point = verified.get_nth_parent_via_skip(share_hash,
614-
(PoolConfig::chain_length() * 15) / 16);
615+
score_endpoint_offset(static_cast<int32_t>(PoolConfig::chain_length())));
615616

616617
// p2pool: self.verified.get_chain(end_point, self.net.CHAIN_LENGTH//16)
617618
std::optional<int32_t> block_height;
618-
auto tail_count = std::min(
619-
static_cast<int32_t>(PoolConfig::chain_length() / 16),
619+
auto tail_count = score_tail_walk_count(
620+
static_cast<int32_t>(PoolConfig::chain_length()),
620621
verified.get_acc_height(end_point));
621622
if (tail_count <= 0)
622623
return {static_cast<int32_t>(PoolConfig::chain_length()), score_res};
@@ -642,8 +643,8 @@ class ShareTracker
642643
// confirmation count so the score is tiny but non-zero, preventing
643644
// oscillation where short chains beat long chains simply because the
644645
// long chain's old blocks are unresolvable.
645-
if (!block_height.has_value() || block_height.value() <= 0)
646-
block_height = 1000000; // ~1M confirmations → time_span ≈ 75M seconds
646+
block_height = score_resolved_block_span(
647+
block_height.has_value(), block_height.value_or(0)); // ~1M conf when unresolved → time_span ≈ 75M seconds
647648

648649
// p2pool: self.verified.get_delta(share_hash, end_point).work
649650
auto total_work = verified.get_delta_work(share_hash, end_point);
@@ -652,11 +653,10 @@ class ShareTracker
652653
// c2pool confirmations: 1=tip → 75s, 4 → 300s (matches p2pool).
653654
// BLOCK_PERIOD sourced from the make_coin_params-populated CoinParams
654655
// (oracle PARENT.BLOCK_PERIOD, config_coin.hpp = 75s) — no hardcoded holdover.
655-
auto time_span = block_height.value() * static_cast<int32_t>(m_params->block_period);
656-
if (time_span <= 0)
657-
time_span = 1;
656+
auto time_span = score_time_span(
657+
block_height.value(), static_cast<int32_t>(m_params->block_period));
658658

659-
score_res = total_work / static_cast<uint32_t>(time_span);
659+
score_res = score_value(total_work, time_span);
660660
return {static_cast<int32_t>(PoolConfig::chain_length()), score_res};
661661
}
662662

0 commit comments

Comments
 (0)