dgb(#82): reconstruct won block from captured GBT template, not share refs - #271
Merged
Merged
Conversation
… refs The won-block broadcast tx set is the GBT template snapshot the miner was handed at job hand-out (current_work transactions[]), NOT the share's transaction_hash_refs. Confirmed against p2pool-merged-v36/p2pool/work.py @ 42ccca53 (transactions=current_work.value[transactions]; other_transactions from tx_map; submit txs=[gentx]+[tx.data]). The ref-walk path is a share-chain peer-propagation mechanism, never the block source -- which makes assembly version-agnostic (pre-v34 vs v34+/v36 irrelevant; the share never carried the block tx set), dissolving the v34+ m_tx_info reconstruct concern. Add reconstruct_won_block_from_template(small_header, merkle_link, gentx, gentx_hash, template_other_txs) framing [gentx]++template_other_txs via the assemble_won_block SSOT. Empty template (today's embedded path until mempool tx-selection wires) yields a valid coinbase-only block, not a fail-closed nullopt. +2 KATs: template-path == ref-path for the same tx set (pure source swap), and empty-template gentx-only. dgb_reconstruct_won_block_test 7/7.
frstrtr
added a commit
that referenced
this pull request
Jun 20, 2026
…ed-template) Implements the integrator-decided PE-2e won-block seam: a test-only forced-won-share trigger + captured-GBT-template reconstruct, mirroring dgb #271. No BTC --regtest CLI / production surface added. - coin/block_assembly.hpp: assemble_won_block SSOT (reconstruct_block_header recomputes merkle_root via the aux_merkle_root branch walk; [gentx]++others; BlockType TX_WITH_WITNESS codec == live submitblock path). - coin/reconstruct_won_block.hpp: reconstruct_won_block_from_template, the version-agnostic broadcast source (current_work transactions[], not a share ref-walk). - test/reconstruct_won_block_test.cpp: forced-won-share seam drives the reconstruct; 4 KATs (seam fires faithful parent block / template is tx source in order / empty template => coinbase-only / non-empty branch recomputes root via SSOT). bytes round-trip, hex==HexStr. - build.yml: new target into BOTH allowlists (#143 NOT_BUILT trap). Per-coin isolation: src/impl/nmc/ only. p2pool-merged-v36 surface: NONE. Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
This was referenced Jun 20, 2026
frstrtr
added a commit
that referenced
this pull request
Jun 21, 2026
…der (#271) The won-block reconstructor frames the broadcast block as [gentx] ++ other_txs, where other_txs is the captured-GBT template the won share was mined against. The into that seam but defers the provider itself to the run-loop. main_dgb installs an interim mempool RE-SELECTION lambda, merkle-consistent ONLY while the mempool is static across the won window (regtest); in prod any mempool mutation between job hand-out and won-block diverges the set -> wrong merkle root -> daemon-rejected block -> lost reward. coin/template_capture.hpp removes that race: TemplateCapture retains each handed-out template transactions[] keyed by the resulting share_hash and replays it verbatim at won-block. provider() yields the captured_template_txs_fn make_template_other_txs_fn consumes. Miss -> empty array -> a VALID coinbase-only block (the reconstructor empty contract), NOT fail-closed: a missing template must not forfeit the subsidy. Bounded FIFO so memory is O(capacity), not O(jobs). Thread-safe (capture on the job/mint path, provide on the COMPUTE thread inside the closure). dgb_template_capture_test (5/5): capture->provide json round-trip; miss replays empty; composed through the #299 bridge a HIT decodes byte-faithfully to the MutableTransaction vector deserialize_template_other_txs yields directly and a MISS to empty; overwrite- same-hash keeps one entry; FIFO eviction drops the oldest. Stacks on #299. Fenced to src/impl/dgb/; no p2pool-merged-v36 surface. Both build.yml allowlists updated (#143).
frstrtr
added a commit
that referenced
this pull request
Jun 21, 2026
dgb: per-job template-retention seam — captured_template_txs_fn provider (#271)
This was referenced Jun 21, 2026
frstrtr
added a commit
that referenced
this pull request
Jun 22, 2026
…rkers ci(P0): resolve committed conflict markers in build.yml test allowlist (master CI red since #271)
frstrtr
added a commit
that referenced
this pull request
Jun 23, 2026
…osure builder Compose the run-loop WonBlockReconstructor from the captured-GBT template source (#271) instead of the share tx_hash_refs: won_share_inputs (#279, small_header + merkle_link) ++ unpack_gentx_coinbase(gentx) ++ template_other_txs -> reconstruct_won_block_from_template. Version-agnostic (dissolves the v34+ no-m_tx_info concern) and fail-closed (any error -> nullopt, announce + audit, RPC submitblock fallback still attempts). Seam-injected so it is unit-tested with no live ShareTracker/mempool. +5 KAT into dgb_reconstruct_closure_test (existing target, no new allowlist entry): success==reconstruct_won_block_from_template, empty-template=>valid coinbase-only (not nullopt), unknown-share / malformed-gentx / template-throw each fail closed. 11/11 PASS. src/impl/dgb/ only; p2pool-merged-v36 surface NONE. This is the builder the main_dgb run-loop installs in place of the nullopt stub (next slice).
frstrtr
added a commit
that referenced
this pull request
Jun 23, 2026
… nullopt stub) main_dgb.cpp --run binds tracker().m_on_block_found to the FAITHFUL make_reconstruct_closure_from_template (#280) in place of the interim nullopt stub. The three version-agnostic won-block inputs are bound to the live sharechain tracker: - won_share_fields_fn: share.m_min_header + m_merkle_link (#279) - gentx_bytes_fn: generate_share_transaction(...).GentxCoinbase.bytes (#173 SSOT); v36_active re-derived from the share compile-time version inside GST, byte-identical to the verify-path invocation - template_other_txs_fn: captured-GBT non-coinbase set (#271), empty today (no per-job template retention + unfed embedded mempool => coinbase-only), correct-and-empty, NOT fail-closed Fires on the compute thread already holding the tracker lock, so the fns read tracker().chain directly (no read_tracker(), no self-deadlock). Fail-closed end to end: any builder error -> nullopt (announce + audit; RPC submitblock fallback still fires). Fenced to main_dgb.cpp; build EXIT=0; selftest OK. #82 OPEN pending a live UpdateTip won-block test.
frstrtr
added a commit
that referenced
this pull request
Jun 23, 2026
…e won-block reconstructor other_txs
The won-block reconstructor (make_reconstruct_closure_from_template) frames the
broadcast block as [gentx] ++ other_txs, where other_txs is the captured GBT
template's non-coinbase set. make_mempool_tx_source already shapes that template
(transactions[] of {data,txid,hash,fee}); the reconstructor consumes deserialized
MutableTransaction. This adds the missing deserialize wire between them:
* deserialize_template_other_txs(json) -- pure transactions[] -> txs[] SSOT;
throws on malformed data (bad hex/trailing bytes) so the closure fails the
won block CLOSED rather than broadcasting a half-decoded tx set.
* make_template_other_txs_fn(captured_template_txs_fn) -- adapts a per-share
captured-transactions[] provider into the template_other_txs_fn the run-loop
installs (per-job capture provider is the run-loop integration, #271).
dgb_template_other_txs_test (5/5): round-trips the PRODUCTION make_mempool_tx_source
output byte-faithfully, proves the funded template txs land in the reconstructed
block ([gentx]++other_txs byte-identical to reconstruct_won_block_from_template),
and proves a bad provider fails closed. Fenced to src/impl/dgb/; no p2pool-merged-v36
surface (decodes the conformant GBT shape back into the in-memory tx). Both
build.yml allowlists updated (#143 NOT_BUILT trap).
frstrtr
added a commit
that referenced
this pull request
Jun 23, 2026
…der (#271) The won-block reconstructor frames the broadcast block as [gentx] ++ other_txs, where other_txs is the captured-GBT template the won share was mined against. The into that seam but defers the provider itself to the run-loop. main_dgb installs an interim mempool RE-SELECTION lambda, merkle-consistent ONLY while the mempool is static across the won window (regtest); in prod any mempool mutation between job hand-out and won-block diverges the set -> wrong merkle root -> daemon-rejected block -> lost reward. coin/template_capture.hpp removes that race: TemplateCapture retains each handed-out template transactions[] keyed by the resulting share_hash and replays it verbatim at won-block. provider() yields the captured_template_txs_fn make_template_other_txs_fn consumes. Miss -> empty array -> a VALID coinbase-only block (the reconstructor empty contract), NOT fail-closed: a missing template must not forfeit the subsidy. Bounded FIFO so memory is O(capacity), not O(jobs). Thread-safe (capture on the job/mint path, provide on the COMPUTE thread inside the closure). dgb_template_capture_test (5/5): capture->provide json round-trip; miss replays empty; composed through the #299 bridge a HIT decodes byte-faithfully to the MutableTransaction vector deserialize_template_other_txs yields directly and a MISS to empty; overwrite- same-hash keeps one entry; FIFO eviction drops the oldest. Stacks on #299. Fenced to src/impl/dgb/; no p2pool-merged-v36 surface. Both build.yml allowlists updated (#143).
frstrtr
added a commit
that referenced
this pull request
Jun 23, 2026
dgb: per-job template-retention seam — captured_template_txs_fn provider (#271)
frstrtr
added a commit
that referenced
this pull request
Jun 23, 2026
Replace the interim coinbase-only template_other_txs_fn stub in the #82 forced-won live seam with the production capture->bridge path: - declare a run-loop-scoped dgb::coin::TemplateCapture (#300/#271) that outlives every tracker callback the provider() is installed into - feed it through make_template_other_txs_fn (#299) as the reconstruct closure template_other_txs_fn, so a won block replays the EXACT non-coinbase set the share committed to (merkle-consistent) instead of reconstructing coinbase-only - seed_forced_from_gbt captures the node-B GBT transactions[] keyed by the forced share hash; coinbasevalue already includes those fees so the regenerated gentx subsidy stays balanced A capture MISS still decodes to an empty set -> a valid coinbase-only block (never fail-closed). Per-coin: src/impl/dgb + main_dgb only.
frstrtr
added a commit
that referenced
this pull request
Jun 23, 2026
Commit b4126e8 (#271 merge) landed unresolved git conflict markers (<<<<<<< / ======= / >>>>>>>) inside the Build tests --target allowlist at both the Release and ASan+UBSan jobs, breaking the cmake --build line and turning the build.yml workflow red on master since that merge. Both conflict sides are dgb test targets; resolve as the token union: keep dgb_aux_parent_coinbase_parity_test (#298) AND add the dgb_template_capture_test (#271) target. Drift-guard passes (59 targets); YAML parses; diff fenced to .github/workflows/build.yml only.
frstrtr
added a commit
that referenced
this pull request
Jun 23, 2026
…rkers ci(P0): resolve committed conflict markers in build.yml test allowlist (master CI red since #271)
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.
Re-scope of dgb/82-txref-reconstruct-v34 per integrator audit (work.py @ 42ccca53): the won-block broadcast tx set is the captured GBT template snapshot (current_work transactions[]), NOT the share transaction_hash_refs. The ref-walk is a share-chain peer-propagation mechanism, never the block source -> assembly is version-agnostic (dissolves the v34+ m_tx_info concern; nothing to source from the share for any version).
Adds reconstruct_won_block_from_template() framing [gentx]++template_other_txs via the assemble_won_block SSOT. Empty template (today, until embedded mempool tx-selection wires) => valid coinbase-only block, NOT fail-closed nullopt.