Skip to content

fix(bump): climb single-subtree compound BUMP to block root (#167)#168

Merged
galt-tr merged 1 commit into
bsv-blockchain:mainfrom
rafa-js:fix/issue-167-single-subtree-bump
May 26, 2026
Merged

fix(bump): climb single-subtree compound BUMP to block root (#167)#168
galt-tr merged 1 commit into
bsv-blockchain:mainfrom
rafa-js:fix/issue-167-single-subtree-bump

Conversation

@rafa-js
Copy link
Copy Markdown
Contributor

@rafa-js rafa-js commented May 25, 2026

What Changed

  • BuildCompoundBUMP's single-subtree path now folds the subtree root up to the true block-header merkle root using the coinbase BUMP's left-spine siblings (new extendSubtreeToBlockRoot helper in bump/bump.go).
  • Added a regression test (bump/issue167_test.go) plus the real captured inputs as fixtures (bump/issue167_fixtures_test.go) from mainnet block 950675.

Why It Was Necessary

  • A single-subtree block whose coinbase sits outside the subtree has a block tree taller than the subtree STUMP (for block 950675: block height 16 vs STUMP internal height 15, 39,657 txs). The old single-subtree shortcut treated the STUMP as the full block path and returned the subtree root instead of the block root.
  • ValidateCompoundRoot therefore rejected the compound (computed e0360bc5… ≠ header 32d293e3…), no BUMP was persisted, and the block's tracked transactions were stuck at SEEN_MULTIPLE_NODES and never reached MINED. The failure is deterministic, so /reprocess could not recover it.
  • Fixes [Bug] Compound BUMP for single-subtree blocks computes wrong merkle root → txs stuck at SEEN_MULTIPLE_NODES, never reach MINED #167.

Testing Performed

  • New test reproduces the production failure (computed e0360bc5… ≠ header 32d293e3…) before the fix and passes after; it also verifies every tracked tx's minimal path computes the canonical block-header merkle root 32d293e3….
  • go test ./bump/ and go test ./services/bump_builder/: pass. go build ./...: clean.
  • golangci-lint v2.12.2 (CI-pinned) on ./bump/: 0 issues. gofmt: clean.

Impact / Risk

  • Low. The new fold is a no-op when the coinbase BUMP is not taller than the STUMP, so power-of-two single-subtree blocks and all multi-subtree blocks are unaffected (the full bump suite still passes). Only previously-failing single-subtree blocks change behaviour — from "rejected, no BUMP" to a valid, header-reconciling compound BUMP.

Notifications

…kchain#167)

A single-subtree block whose coinbase sits outside the subtree has a block
tree taller than the subtree STUMP. BuildCompoundBUMP's single-subtree path
returned the subtree root instead of the block root, so ValidateCompoundRoot
rejected the compound and the block's tracked txs stayed at
SEEN_MULTIPLE_NODES instead of reaching MINED.

Fold the subtree root up to the block root using the coinbase BUMP's
left-spine siblings. No-op when the coinbase BUMP is not taller than the
STUMP, so power-of-two single-subtree blocks are unaffected. Reproduced with
real inputs from mainnet block 950675 (39,657 txs).
@rafa-js rafa-js requested a review from mrz1836 as a code owner May 25, 2026 21:42
@github-actions github-actions Bot added fork-pr PR originated from a forked repository requires-manual-review PR or issue requires manual review by a maintainer or security team labels May 25, 2026
@github-actions
Copy link
Copy Markdown

👋 Thanks, @rafa-js!

This pull request comes from a fork. For security, our CI runs in a restricted mode.
A maintainer will triage this shortly and run any additional checks as needed.

  • 🏷️ Labeled: fork-pr, requires-manual-review
  • 👀 We'll review and follow up here if anything else is needed.

Thanks for contributing to bsv-blockchain/arcade! 🚀

@galt-tr
Copy link
Copy Markdown
Contributor

galt-tr commented May 26, 2026

Thank you, good catch. I am surprised we didn't catch this before; I see many single subtree blocks on TTN where this isn't the case. Wondering if theres something unique about how teranode stores blocks from a legacy sv node?

regardless, I can confirm this is a real bug.

@galt-tr galt-tr merged commit 3201904 into bsv-blockchain:main May 26, 2026
45 checks passed
@rafa-js rafa-js deleted the fix/issue-167-single-subtree-bump branch May 26, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork-pr PR originated from a forked repository requires-manual-review PR or issue requires manual review by a maintainer or security team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Compound BUMP for single-subtree blocks computes wrong merkle root → txs stuck at SEEN_MULTIPLE_NODES, never reach MINED

3 participants