Skip to content

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

Closed
frstrtr wants to merge 1 commit into
masterfrom
fix/dash-underfill-guard-fable
Closed

dash(underfill): port near-empty-template guard to DASH embedded GBT + KAT#723
frstrtr wants to merge 1 commit into
masterfrom
fix/dash-underfill-guard-fable

Conversation

@frstrtr

@frstrtr frstrtr commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Ports the block-underfill guard to DASH — it exists on LTC and DOGE but not DASH, and is needed for the mining-hotel deployment.

DASH has no template_builder.hpp class; its template path is the free function build_embedded_workdata() in src/impl/dash/coin/embedded_gbt.hpp. The guard is placed there, after tx selection and before the platform-burn / MN-payee / CbTx section (masternode payment, CbTx payload, and the dashd submitblock fallback are untouched).

Behavior mirrors LTC/DOGE (src/impl/{ltc,doge}/coin/template_builder.hpp): same 50 kB pins (UNDERFILL_MIN_FILL_BYTES, UNDERFILL_BACKLOG_SLACK); if the selected template is near-empty (< 50 kB) and the mempool holds known fees > 0 with a real backlog, it emits a [GBT-EMB] UNDERFILL: LOG_WARNING. Log-only — no retry/reject; genuinely empty mempools never trip. Only covers the embedded template path (when it falls back to dashd GBT, dashd fills the template — same scoping as LTC/DOGE).

  • src/impl/dash/coin/embedded_gbt.hpp — namespace pins + pure predicate underfill_guard_trips(...); guard block using DASH's mempool.byte_size() / total_known_fees(); a defaulted additive bool* underfill_tripped out-param (test observation point, in this file's existing seam idiom — droppable for exact-mirror log-only). All existing callers unchanged (byte-for-byte).
  • test/test_dash_underfill_guard.cpp (new) — threshold + predicate-boundary KATs, plus end-to-end wiring through the real Mempool + build_embedded_workdata (a ~108 kB fee-known tx made unselectable via the stale-input window → guard trips, and the DIP-0027 MN-payment projection is asserted unchanged). First underfill test in the tree.
  • test/CMakeLists.txt — registers test_dash_underfill_guard (same link set as test_dash_embedded_gbt).

Note: not compile-checked by the author (no toolchain on that host) — CI validates the build here. The new gtest may need adding to the build.yml test-allowlist (workflow-scoped) to run in CI.

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).
@frstrtr

frstrtr commented Jul 17, 2026

Copy link
Copy Markdown
Owner Author

Superseded by a clean-named branch (the branch name tripped attribution-gate on the model-name token). Reopening as a new PR with identical commits.

@frstrtr frstrtr closed this Jul 17, 2026
@frstrtr
frstrtr deleted the fix/dash-underfill-guard-fable branch July 17, 2026 04:23
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