submitblock: Treat a duplicate reply as the block being accepted - #233
Open
jasonsopko wants to merge 1 commit into
Open
submitblock: Treat a duplicate reply as the block being accepted#233jasonsopko wants to merge 1 commit into
jasonsopko wants to merge 1 commit into
Conversation
The gateway hands a found block to the node twice: once inline from the share that found it and once from the submit thread. The second copy gets "duplicate" back, which BIP22 defines as "the node already has this block and it is valid", and both call sites logged it as "Upstream node rejected our block!" This morning that line landed right after a real mainnet block was accepted, which is the wrong moment to tell an operator their block was refused. Classify the reply in one place, datum_submitblock_reply_status(): NULL or a null result is accepted, "duplicate" is already accepted, anything else including "duplicate-invalid" is a rejection. Both call sites use datum_submitblock_log_reply(), which logs "duplicate" at INFO as already accepted and returns success for it, so the inline submit's return value now also counts a duplicate as a win. Ten cases in datum_submitblock_tests(); --test passes.
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.
What
A
submitblockreply ofduplicateis logged as "already accepted" at INFO instead of "Upstream node rejected our block!" at WARN, at both places the gateway submits a block. The reply classification lives in one function with tests.Why
The gateway submits a found block twice, inline from the share that found it and again from the submit thread. The node answers the second copy with
duplicate, which BIP22 defines as "already have it, and it is valid". This morning that warning was printed seconds after a real mainnet block had been accepted, right where an operator looks to see whether the block was good.duplicate-invalid,inconclusiveand thebad-*reasons are still rejections.How I tested
--testpasses with ten new assertions on the classifier (null result,duplicate,duplicate-invalid,duplicate-inconclusive,inconclusive, twobad-*reasons, and non-string results). The motivating log is from a gateway that found mainnet block 961672 on 2026-08-30:Block ... submitted to upstream node successfully!followed byUpstream node rejected our block! ({"result": "duplicate", ...})five milliseconds later.Risk and rollback
Log wording and the inline submit's return value for the duplicate case, which now counts as success. Revert the commit.