Skip to content

dgb: rewire get_pool_attempts_per_second onto coin/ SSOT (#407 follow-on) - #503

Merged
frstrtr merged 1 commit into
masterfrom
dgb/pool-aps-rewire-407
Jun 25, 2026
Merged

dgb: rewire get_pool_attempts_per_second onto coin/ SSOT (#407 follow-on)#503
frstrtr merged 1 commit into
masterfrom
dgb/pool-aps-rewire-407

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Phase-B SSOT consolidation: production rewire of get_pool_attempts_per_second (#407 follow-on)

coin/pool_attempts_per_second.hpp was lifted in #407 as a KAT-pinned SSOT but left header-only -- ShareTracker::get_pool_attempts_per_second still inlined a duplicate of the same window arithmetic. This wires the member onto the SSOT so the inline copy can no longer drift from the oracle.

Change (byte-identical)

  • Member keeps the chain walk (skip-list far lookup, get_delta work/min_work sum, timestamp reads).
  • Resolved endpoints are handed to dgb::compute_pool_attempts_per_second(PoolAttemptsInputs), which owns the three guard returns (dist<2 / near absent / far unresolved -> 0) and the near_ts - far_ts span (clamped to 1) integer divide.
  • Same int32_t span type, same uint288 divide -- provably value-identical to the prior inline path.

Evidence

  • dgb_share_test 34/34 (exercises share-target derivation through the member at share_tracker.hpp:1439/1658).
  • dgb_pool_attempts_per_second_test 10/10.
  • Clean Debug build off master e07b2c4.

Scope

FENCED src/impl/dgb/ only; diagnostic/hashrate-estimation path; no consensus surface, no src/impl/doge edits, no node seam. NO self-merge -- integrator diffs value before tap.

…-on)

ShareTracker::get_pool_attempts_per_second performed the chain walk and then
inlined the window arithmetic (dist<2/near/far guards, near_ts-far_ts span
clamped to 1, integer attempts/span divide) -- a duplicate of the KAT-pinned
coin/pool_attempts_per_second.hpp SSOT lifted in #407.

Delegate the resolved-endpoint arithmetic to dgb::compute_pool_attempts_per_second:
the member still owns the chain walk (skip-list far lookup, get_delta work sum,
timestamp reads) and hands a PoolAttemptsInputs to the SSOT. Byte-identical to
the prior inline path -- same int32_t span type, same uint288 divide, same zero
returns on the three guard conditions.

Phase-B SSOT consolidation: turns the header-only lift into a live production
delegation so the inline copy can no longer drift from the oracle.

dgb_share_test 34/34 (exercises share-target derivation through the member);
dgb_pool_attempts_per_second_test 10/10. FENCED dgb/, no consensus change.
@frstrtr
frstrtr merged commit 67617d8 into master Jun 25, 2026
32 checks passed
frstrtr pushed a commit that referenced this pull request Jul 14, 2026
…n hardening)

Clears the 8 real CodeQL security alerts on frstrtr/c2pool. Triaged +
independently re-reviewed: 1 CRITICAL is a genuine fix, 2 HIGH get
defense-in-depth, 5 HIGH are getenv-rooted false positives (dismissed
separately with justification).

- #490 CRITICAL cpp/potentially-dangerous-function (src/core/log.cpp:163):
  std::gmtime returns a pointer into a shared static tm and is not
  reentrant. Replace with gmtime_r (POSIX) / gmtime_s (MSVC) into a local
  tm. Only gmtime/localtime call in src/.

- #502/#503 HIGH cpp/path-injection (coin_peer_manager.hpp db_path()):
  m_symbol is a hardcoded ticker literal at every production ctor site
  (traced through all callers; no network->filename path exists), but
  add an alphanumeric-only guard so a future caller cannot inject a path
  component. Legitimate tickers (LTC/DOGE/DGB/DASH/BTC/NMC/...) are all
  alnum -> no on-disk filename change.

- Rider: core::filesystem::config_path() dereferenced getenv() without a
  null check -> std::filesystem::path(nullptr) is UB if HOME/APPDATA is
  unset. Fall back to '.'.

The other 5 path-injection alerts (#507 node.cpp:2199, #506/#505/#504
payout_manager.cpp:224/261/284, #501 auto_ratchet.hpp:309) all build a
path from config_path() (getenv HOME/APPDATA) + a hardcoded basename,
never from network/peer/miner input -> dismissed as false positive.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant