btc: broadcaster-gate FILL — submitblock RPC FALLBACK + never-silent-drop - #162
Merged
Conversation
…drop won block
Closes the won-block broadcaster gate for BTC. Prior path was single-sink:
the stratum won-block lambda called submit_block_p2p_raw only, and node.hpp
had a bare `if (m_p2p)` with no else — a silent-drop hole on a found block.
FALLBACK semantics (P2P relay primary; submitblock RPC fires only when P2P
is unavailable or relay failed — NOT always-both / no double-broadcast):
- coin/block_broadcast.hpp (new): broadcast_block_with_fallback() seam —
pure, testable decision: try P2P; on null/fail fall back to RPC; returns
true iff at least one sink accepted.
- coin/node.hpp: submit_block_p2p_raw now returns bool; new submit_block_hex
(RPC sink via NodeRPC::submit_block_hex) and submit_block_with_fallback.
- coin/p2p_node.hpp: submit_block_raw / submit_block_full return bool
(false when no peer or relay failed) so failure — not just null — triggers
the fallback.
- stratum/work_source.{hpp,cpp}: SubmitBlockFn returns bool; the won-block
path logs a loud ERROR when a found block reaches NEITHER sink (or no fn is
wired). A won block can never be lost quietly.
- c2pool/main_btc.cpp: stratum_submit_fn returns the fallback outcome.
- test/block_broadcast_test.cpp (new): standalone gate harness, 13/13 PASS —
happy (P2P only, RPC does NOT fire), degraded/null-p2p (RPC fallback fires),
both-down (reaches neither -> won-block path screams).
BTC-only; build c2pool-btc GREEN.
frstrtr
added a commit
that referenced
this pull request
Jun 19, 2026
…lock (#223) Embedded NMC submit path now relays found aux-blocks through a settable BlockRelayFn sink (host wires it to CoinBroadcaster::submit_block_raw, decoded at the wiring site, mirroring the BTC on_block_relay seam). submit_block() no longer claims success unconditionally: an unwired relay or a 0-peer broadcast surfaces as failure (never-silent-drop, per BTC #162) while the hex is still cached for get_block_hex(). +3 KATs (relay exact-hex, no-relay fail, 0-peer fail); existing cache KAT updated to the new contract. Rides nmc_template_builder_test — no CMake/build.yml change. Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
frstrtr
added a commit
that referenced
this pull request
Jun 20, 2026
…nt success) (#253) The embedded submitauxblock RPC leg has no daemon to RPC and is not a same-process fallback like BTC submitblock-to-bitcoind, so it cannot itself broadcast and must not claim success. Return false, mirroring submit_block() never-silent-drop (#162); the P2P relay via submit_block() is the one authoritative embedded route. Updates the fallback-leg KAT to assert false (supersedes integrator note #3 per UID1610) while keeping the distinct no-cache invariant. Punch-list item (2) of the 2d broadcaster gate; item (1) host m_block_relay wiring + #251 won-block un-gate stay queued behind the #247/#251 tap. Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
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.
Broadcaster gate (BTC) — FILL (a)+(b)
Closes the won-block broadcaster gate for BTC. Implements the confirmed FALLBACK design (P2P relay primary;
submitblockRPC fires only on P2P-unavailable/relay-failed — NOT always-both / no double-broadcast), plus both hard tightenings.Tightening 1 — fallback on FAILURE, not only
m_p2p==nullcoin/p2p_node.hpp:submit_block_raw/submit_block_fullnow returnbool(false when no peer or relay failed).coin/node.hpp:submit_block_p2p_rawreturnsbool; newsubmit_block_hex(RPC sink) +submit_block_with_fallback.coin/block_broadcast.hpp(new):broadcast_block_with_fallback()seam — try P2P; fall back to RPC whenever P2P is null or relay did not succeed.Tightening 2 — never silent-drop
stratum/work_source.{hpp,cpp}:SubmitBlockFnreturnsbool; the won-block path logs a loud ERROR when a found block reaches NEITHER sink (or no fn is wired). Was aLOG_WARNINGat the old :818.c2pool/main_btc.cpp:stratum_submit_fnreturns the fallback outcome.Verify test (path 3)
test/block_broadcast_test.cpp(standalone harness, same style as the H5tx_data_memo_test): 13/13 PASS.Build:
c2pool-btcGREEN. BTC-only; no cross-coin files touched.NOTE on the test: it drives the new fallback seam with fakes that stand 1:1 for
message_block::make_raw(P2P sink) and thesubmitblockCallMethod(RPC sink), proving the decision matrix deterministically. Happy-path asserts RPC does NOT fire — under the confirmed FALLBACK design, asserting both fire would contradict the no-double-broadcast decision. Can wire a full network-level integration test (fake CoindProtocol peer + fake jsonrpc client) as a follow-up if the gate requires literal observation of those two primitives.BODY