dgb: rewire heartbeat binomial-conf diag onto coin/ SSOT (#425 follow-on) - #507
Merged
Conversation
…-on)
node.cpp format_binomial_conf{,_efficiency} carried an inline z=1.96 +
plain-[0,1]-clip Wilson-score approximation that duplicated, and slightly
diverged from, the oracle-faithful coin/binomial_conf_interval.hpp SSOT
(z = sqrt(2)*ierf(conf), add_to_range bracketing; p2pool util/math.py:133).
Delegate both diag formatters onto the SSOT. Diagnostics only (heartbeat
log stale-rate/efficiency display) -- zero consensus surface, no block
reward path. Underlying math is now oracle-faithful; rendered output is
empirically byte-identical across 13 representative (x,n) cases (the
sub-integer-percent z/bracket delta washes out under floor/ceil-to-percent
rendering). NOT strictly double-level byte-identical -- see PR note.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Rewire the two heartbeat diag formatters in
node.cpp(
format_binomial_conf,format_binomial_conf_efficiency) onto theoracle-faithful SSOT
coin/binomial_conf_interval.hpp(#425). Removes thelast inline duplicate of the Wilson-score interval math.
Scope / safety
Zero consensus surface, no block-reward path, no share validation.
src/impl/dgb/only (node.cpp). Header SSOT unchanged.Divergence flag — NOT strictly byte-identical (read before tap)
The inline code used a hand-simplified
z = 1.96literal and plain[0,1]clipping. The SSOT is oracle-faithful:
z = sqrt(2)*ierf(conf)(≈1.959964)plus
add_to_rangebracketing of the point estimate (p2pool util/math.py:133).So at the
doublelevel the result changes slightly. However, renderedoutput is empirically byte-identical — across 13 representative
(x,n)cases the sub-integer-percent delta washes out under the floor/ceil-to-
integer-percent display (
~X.Y% (lo-hi%)): 0/13 differ. A ±1% shift on abound is theoretically possible at extreme edge inputs but none observed.
This is the intended convergence: diag display now tracks the oracle math
exactly. Flagging per the divergence-trap rule since it is not a pure
double-level byte-identical rewire like the tail_score (#504) lift.
Test
c2pool-dgbtarget builds green against the SSOT.#425binomial-conf KAT unaffected (header untouched).No self-merge — operator tap.