Skip to content

btc(#744): wire sharechain won-block dispatch (make_on_block_found) - #820

Merged
frstrtr merged 1 commit into
masterfrom
btc/won-block-dispatch-744
Jul 23, 2026
Merged

btc(#744): wire sharechain won-block dispatch (make_on_block_found)#820
frstrtr merged 1 commit into
masterfrom
btc/won-block-dispatch-744

Conversation

@frstrtr

@frstrtr frstrtr commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Gate #744 — BTC won-block dispatch seam.

Problem

main_btc never assigned the sharechain\x27s m_on_block_found callback, so a won share that met the parent target was recorded in the sharechain and then silently dropped: neither the P2P broadcast_block_for_connect path nor the submitblock RPC fallback was ever invoked. DGB (#174/#176) already has this seam; BTC did not.

Change

  • new src/impl/btc/coin/won_block_dispatch.hppbtc::coin::make_on_block_found() builds the dispatch callback wiring sharechain m_on_block_found into broadcast_block_for_connect, mirroring the DGB shape.
  • won_share_dualpath_test.cpp — KAT covering both arms (P2P announce + RPC fallback) so a regression that drops one arm fails the suite.

Evidence this is load-bearing

G3b tuned-net rig (.121) shows won solutions at height 131 submitted and every one going STALE with the parent chain never advancing past 130. The reject-cause visibility half of that landed in #752; this PR is the dispatch half.

Scope

Additive: one new header + one new test, plus the test registration line. No existing BTC path is modified. Rebased onto master; CMakeLists conflict resolved as a union (kept rpc_conf_test.cpp/genesis_check_test.cpp from master, added won_share_dualpath_test.cpp).

I do not self-merge.

ShareTracker::m_on_block_found fires when a verified sharechain share crosses
the BTC network target (share_tracker.hpp L385/L540), but main_btc.cpp never
assigned it -- a peer-relayed won share was detected then silently dropped, the
full subsidy lost. This adds btc::coin::make_on_block_found: reconstruct the won
block (injected reconstructor) then dispatch connect-authoritative dual-path via
broadcast_block_for_connect (P2P relay best-effort + submitblock RPC always).

Reconstructor injected as std::function so the dispatch is build+run tested now;
the faithful share->block reassembly (data.py Share.as_block) is the next slice.

Adds won_share_dualpath_test.cpp (3 KATs: both-arms byte-identity, unassemblable
-> broadcast-nothing, P2P-fail-still-connects) riding the allowlisted
btc_share_test. Per-coin isolation: src/impl/btc/ only.
@frstrtr
frstrtr merged commit a56d138 into master Jul 23, 2026
26 checks passed
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