Skip to content

dgb: rewire heartbeat binomial-conf diag onto coin/ SSOT (#425 follow-on) - #507

Merged
frstrtr merged 1 commit into
masterfrom
dgb/binomial-conf-prod-rewire-425
Jun 25, 2026
Merged

dgb: rewire heartbeat binomial-conf diag onto coin/ SSOT (#425 follow-on)#507
frstrtr merged 1 commit into
masterfrom
dgb/binomial-conf-prod-rewire-425

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 25, 2026

Copy link
Copy Markdown
Owner

What

Rewire the two heartbeat diag formatters in node.cpp
(format_binomial_conf, format_binomial_conf_efficiency) onto the
oracle-faithful SSOT coin/binomial_conf_interval.hpp (#425). Removes the
last inline duplicate of the Wilson-score interval math.

Scope / safety

  • Diagnostics only — heartbeat-log stale-rate / efficiency display.
    Zero consensus surface, no block-reward path, no share validation.
  • FENCED: src/impl/dgb/ only (node.cpp). Header SSOT unchanged.
  • GPG-signed, no third-party attribution.

Divergence flag — NOT strictly byte-identical (read before tap)

The inline code used a hand-simplified z = 1.96 literal and plain [0,1]
clipping. The SSOT is oracle-faithful: z = sqrt(2)*ierf(conf) (≈1.959964)
plus add_to_range bracketing of the point estimate (p2pool util/math.py:133).

So at the double level the result changes slightly. However, rendered
output 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 a
bound 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-dgb target builds green against the SSOT.
  • Old-vs-new sample harness: 0/13 rendered cases differ.
  • #425 binomial-conf KAT unaffected (header untouched).

No self-merge — operator tap.

…-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
frstrtr merged commit ee8db65 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