Skip to content

dash(underfill): port near-empty-template guard to DASH embedded GBT + KAT#724

Merged
frstrtr merged 2 commits into
masterfrom
fix/dash-underfill-guard
Jul 17, 2026
Merged

dash(underfill): port near-empty-template guard to DASH embedded GBT + KAT#724
frstrtr merged 2 commits into
masterfrom
fix/dash-underfill-guard

Conversation

@frstrtr

@frstrtr frstrtr commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Ports the block-underfill guard to DASH (exists on LTC/DOGE, not DASH) for the mining-hotel deployment. DASH has no template_builder class; the guard goes in build_embedded_workdata() (src/impl/dash/coin/embedded_gbt.hpp), after tx selection and BEFORE the platform-burn/MN-payee/CbTx section (masternode payment, CbTx, dashd submitblock fallback untouched). Behavior mirrors LTC/DOGE: 50kB fill pins; near-empty template + non-empty fee-paying mempool backlog => LOG_WARNING '[GBT-EMB] UNDERFILL:'. Log-only. Adds test/test_dash_underfill_guard.cpp (asserts the DIP-0027 MN-payment projection stays unchanged) + CMakeLists registration. NOTE: the new gtest must be added to the build.yml --target allowlist (workflow scope) or it shows '***Not Run'.

frstrtr and others added 2 commits July 17, 2026 06:31
Port the 'near-empty template on a non-empty mempool' guard from
ltc/doge template_builder.hpp into dash build_embedded_workdata()
(the DASH embedded template path), for the mining-hotel deployment.

- Same cross-coin pins as LTC/DOGE: UNDERFILL_MIN_FILL_BYTES /
  UNDERFILL_BACKLOG_SLACK = 50 kB (legacy p2pool near-empty floor).
- Trip condition factored into a pure predicate
  underfill_guard_trips(selected, mempool_bytes, known_fees) so the
  KAT pins the exact boolean without a log scraper.
- selected_bytes accumulated from SelectedTx.base_size (DASH has no
  witness; base_size IS the wire size the mempool byte cap counts).
- Log-only (WARNING, [GBT-EMB] UNDERFILL) exactly like LTC/DOGE:
  never mutates the template; masternode burn/payee projection and
  the dashd submitblock fallback path are untouched.
- SAFE-ADDITIVE trailing seam bool* underfill_tripped = nullptr
  (matches the existing curtime/version seam style); every existing
  caller is byte-for-byte unchanged.
- test_dash_underfill_guard.cpp: predicate boundary KATs (empty
  mempool never trips, fee-unknown backlog never trips, strict
  slack boundary) + build wiring KATs (fee-known backlog rejected by
  the stale-input window trips; drained small pool and empty pool do
  not; DASH payment projection asserted unchanged when tripped;
  default-seam call identical field-for-field).
…ists

Registered in test/CMakeLists.txt but absent from the Linux x86_64 and
ASan --target lists, so it showed ***Not Run and failed those two lanes.
Add it next to test_dash_embedded_gbt in both lists, mirroring the
test_stratum_hotel_interim fix.
@frstrtr
frstrtr merged commit c31add5 into master Jul 17, 2026
27 checks passed
@frstrtr
frstrtr deleted the fix/dash-underfill-guard branch July 17, 2026 04:23
frstrtr added a commit that referenced this pull request Jul 17, 2026
test_btc_underfill_guard + test_dgb_underfill_guard -> main-leg --target
lists (build_ci + build_asan); test_bch_underfill_guard -> BCH-leg lists
(build_bch build + run, COIN_BCH). Without these the new KATs register as
NOT_BUILT CTest sentinels and Not-Run on Linux/ASan. Same pattern as #721/#724.
frstrtr added a commit that referenced this pull request Jul 17, 2026
…728)

* btc/dgb/bch(underfill): port LTC/DOGE near-empty-template guard + KATs

Port the v36 template-underfill guard (near-empty template on a non-empty
fee-paying mempool, LOG-ONLY WARNING) from LTC/DOGE to the three coins that
were missing it, in the DASH free-predicate form (underfill_guard_trips +
50 kB UNDERFILL_MIN_FILL_BYTES / UNDERFILL_BACKLOG_SLACK pins):

- btc: guard inside TemplateBuilder::build_template (template_builder.hpp),
  SAFE-ADDITIVE trailing bool* underfill_tripped seam; GBT JSON untouched.
- bch: same, after the CTOR re-sort; ABLA budget / sizelimit untouched.
- dgb: build_work_template() is a pure shaper with no mempool access, so the
  guard evaluates in make_mempool_tx_source (embedded_tx_select.cpp) — the
  one mempool-visible point feeding BOTH template callers (stratum
  DGBWorkSource + EmbeddedCoinNode); predicate/thresholds pinned in
  coin/template_builder.hpp.

KATs per coin (test/test_{btc,dgb,bch}_underfill_guard.cpp, mirroring
test_dash_underfill_guard.cpp): threshold pins, boundary strictness,
empty/fee-unknown/drained no-trip, and real-build wiring via the seam
(stale-input-guard-emptied selection over a fee-paying backlog).
Registered in test/CMakeLists.txt (bch entry gated on COIN_BCH like
bch_coin). New targets still need the build.yml --target allowlist
(main leg: btc+dgb; BCH leg: bch) or CTest shows the NOT_BUILT sentinel.

* ci(build): allowlist btc/dgb/bch underfill-guard gtests (#728)

test_btc_underfill_guard + test_dgb_underfill_guard -> main-leg --target
lists (build_ci + build_asan); test_bch_underfill_guard -> BCH-leg lists
(build_bch build + run, COIN_BCH). Without these the new KATs register as
NOT_BUILT CTest sentinels and Not-Run on Linux/ASan. Same pattern as #721/#724.

---------

Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
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