fix: broadcast fan-out waits for first success instead of first result#42
Merged
fix: broadcast fan-out waits for first success instead of first result#42
Conversation
When multiple teranode endpoints are configured, the broadcast now returns on the first successful response (ACCEPTED/SENT). Rejections from one endpoint no longer short-circuit if another endpoint may accept the transaction. Status is only persisted and published once after the final result is determined.
4xx responses from teranode are genuine rejections (invalid tx) and return immediately. 5xx responses are service errors — other endpoints may still accept the transaction. Fan-out only waits on service errors, not rejections.
fetchBlockSubtrees was downloading the full block binary from the datahub but only extracting subtree hashes, discarding the coinbase transaction. The coinbase txid is needed to replace the all-FF placeholder at subtree index 0 — without it, every hash on the left side of the merkle tree is computed incorrectly, producing invalid proofs. Renamed fetchBlockSubtrees to fetchBlock, now returns a blockData struct with both SubtreeHashes and CoinbaseTxID. processBlockTransactions uses the coinbase from block data directly instead of relying on the P2P BlockMessage.Coinbase field, which may not always be set (e.g. during catch-up processing). Removed parseCoinbaseTxID as it's no longer needed.
Collaborator
Author
|
Nancy flags CVE-2026-34986 in |
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.
Summary
SERVICE_ERRORstatus lets callers distinguish between the two.fetchBlockSubtreeswas downloading the full block binary but only extracting subtree hashes, discarding the coinbase transaction. Without the coinbase txid, the all-FF placeholder at subtree index 0 was never replaced, producing invalid merkle proofs for any transaction whose proof path crosses the left side of the tree. Renamed tofetchBlock, now parses the coinbase and returns it alongside subtree hashes. Both P2P and catch-up paths now get the coinbase from the block data directly.Test plan