Skip to content

submitblock: Treat a duplicate reply as the block being accepted - #233

Open
jasonsopko wants to merge 1 commit into
OCEAN-xyz:masterfrom
jasonsopko:submitblock-duplicate-reply
Open

submitblock: Treat a duplicate reply as the block being accepted#233
jasonsopko wants to merge 1 commit into
OCEAN-xyz:masterfrom
jasonsopko:submitblock-duplicate-reply

Conversation

@jasonsopko

Copy link
Copy Markdown

What

A submitblock reply of duplicate is 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, inconclusive and the bad-* reasons are still rejections.

How I tested

--test passes with ten new assertions on the classifier (null result, duplicate, duplicate-invalid, duplicate-inconclusive, inconclusive, two bad-* 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 by Upstream 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.

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.
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