Skip to content

fix(btc): re-anchor against canonical chain at verify time#207

Open
dripsmvcp wants to merge 1 commit intoentrius:testfrom
dripsmvcp:fix/issue-182-btc-reorg-canonical-check
Open

fix(btc): re-anchor against canonical chain at verify time#207
dripsmvcp wants to merge 1 commit intoentrius:testfrom
dripsmvcp:fix/issue-182-btc-reorg-canonical-check

Conversation

@dripsmvcp
Copy link
Copy Markdown
Contributor

Summary

Closes #182. verify_miner_fulfillment read BTC confirmations once and voted, in both the Core RPC path and the Blockstream path. Between the read and vote inclusion (12s+), a reorg can drop the tx — Core's confirmations updates on reorg but the validator has already voted; Blockstream's status.confirmed is self-reported by whichever instance answered.

After computing confirmations, fetch the canonical blockhash at the tx's height (getblockhash on RPC, GET /block-height/<h> on Blockstream) and compare to the tx's recorded blockhash. Mismatch → tx's block isn't on the canonical chain → drop to confirmed=False so the validator doesn't vote.

Test plan

  • Existing BTC verification tests pass
  • Unit test: canonical-match path keeps confirmed=True
  • Unit test: blockhash mismatch flips to confirmed=False and emits warning
  • Manual: simulate reorg in regtest, verify validator abstains

verify_miner_fulfillment read confirmations once and voted, both in the
RPC and Blockstream paths. Between the read and vote inclusion (12s+),
a reorg can drop the tx — Bitcoin Core's confirmations does update on
reorg but the validator has already voted. Blockstream's status.confirmed
is self-reported by whichever instance answered.

After computing confirmations, fetch getblockhash(height) (RPC) or
GET /block-height/<h> (Blockstream) and compare to the tx's recorded
block_hash. Mismatch → tx's block is not on the canonical chain → drop
to confirmed=False so the validator doesn't vote yet.

Closes entrius#182
@dripsmvcp
Copy link
Copy Markdown
Contributor Author

@anderdc @LandynDev ready for review

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.

No BTC reorg detection — single-point-in-time confirmation check

1 participant