Repository navigation
fix(chain): track spends and conflicts on null prevout for non-coinbase txs - #2435
AlphaSparrow wants to merge 2 commits into
Conversation
…se txs TxGraph::insert_tx previously skipped every null previous output unconditionally when indexing spends, under the assumption that any null prevout implied the transaction was a coinbase. However, under Bitcoin consensus rules, a transaction is only a coinbase if it has exactly one input and that input has a null outpoint (tx.is_coinbase()). A malformed transaction with a null prevout and another input is not a coinbase, yet its null input was skipped. Two such transactions sharing only the null prevout were therefore not recorded in spends, missed by direct_conflicts, and both erroneously admitted to CanonicalView. This change: - Updates TxGraph::insert_tx to skip indexing spends only if tx.is_coinbase(). Non-coinbase transactions have all their inputs indexed, including null prevouts. - Updates TxGraph::direct_conflicts to ignore coinbases, as valid coinbases have no previous outputs and cannot conflict on inputs. - Adds regression tests covering null prevout conflicts on non-coinbase txs, conflict pruning in CanonicalView, and isolation from valid coinbases. Fixes bitcoindevkit#2286 Signed-off-by: Sparrow <theaayushsakariya@gmail.com>
…heck-wasm Drop yoke-derive pin from ci/pin-msrv.sh now that yoke-derive 0.8.4 has been released with rust-version 1.82 and fixes compatibility with Rust 1.85.0. Pin check-wasm runner to ubuntu-22.04 to prevent apt-key missing error and package restart hangs on newer Ubuntu releases. Signed-off-by: Sparrow <theaayushsakariya@gmail.com>
|
@AlphaSparrow can you explain how a valid non-coinbase tx will have a null prevout? |
|
@evanlinjin yeah you're right, it can't, as per the bitcoin consensus rules ( I picked up #2286 to fix the internal conflict tracking inside Given it's redundant in the real world, I'm completely fine closing this PR and #2286 . |
Description
Fixes #2286.
TxGraph::insert_txpreviously skipped every null previous output (OutPoint::null()) unconditionally when indexing spends, under the assumption that any null prevout implied the transaction was a coinbase.However, under Bitcoin consensus rules, a transaction is only a coinbase if it has exactly one input and that input has a null outpoint (
tx.is_coinbase()). A malformed transaction with a null prevout and another input is not a coinbase, yet its null input was skipped. Two such transactions sharing only the null prevout were therefore not recorded inspends, missed bydirect_conflicts, and both erroneously admitted toCanonicalView.This PR:
TxGraph::insert_txto skip indexing spends only iftx.is_coinbase(). Non-coinbase transactions have all their inputs indexed, including null prevouts.TxGraph::direct_conflictsto ignore coinbases, as valid coinbases have no previous outputs and cannot conflict on inputs.crates/chain/tests/test_null_outpoint.rsverifying conflict detection on null prevouts, eviction inCanonicalView, and isolation from valid coinbases.yoke-derivepin drop) andcheck-wasmrunner pin (ubuntu-22.04).Notes to the reviewers
Valid coinbases remain strictly isolated from conflict tracking. Non-coinbase transactions (even malformed consensus-invalid ones) now have their spends indexed consistently so
direct_conflictsandCanonicalViewcorrectly detect conflicts.Changelog notice
Fixed
bdk_chain: Track spends and conflicts on null prevouts for non-coinbase transactions so conflicting consensus-invalid transactions are detected and pruned fromCanonicalView. TxGraph doesn't index null-prevout spends of non-coinbase txs, so their conflicts go undetected #2286Checklists
All Submissions:
Bugfixes: