Accepting a transaction to the mempool only succeeds if this transaction isn’t already present. This check operating on txid, it prevents new submissions of the transaction with identical non-witness data but smaller valid witnesses. Therefore, overall mempool feerate won’t improve even if such higher-feerate mempool candidate is learnt through wtxid-relay.
This commit changes mempool and transaction broadcast already-present checks from transaction’s txid to its wtxid.
A new-wtxid submission may still fail due to replacement rules in function of local policy settings. @jnewbery RE: #18044 (review) I think we agree on the “same txid, different txids” nonsense, I didn’t mean to track multiple witnesses for one txid rather to accept and rebroadcast “the best mempool candidate known for a given txid”. A script may have alternatives solvable branches and witnesses to spend them might be different in weight thus creating wtxid with divergent feerates. A best known candidate with regards to a txid is defined as a higher-feerate witness (a smaller one) transaction than our current in mempool one, with identical non-witness data.
You might submit a txidA:wtxid1 to your local node, and schedule it for initial-broadcast reattempt. Few minutes, latter you announce to your node a higher-feerate txidA:wtxid2, which effectively replace wtxid1. At ReattemptInitialBroadcast
, only wtxid2 will be rebroadcast if needed, as best known candidate for txidA. According to me, that’s where unbroadcast semantic is unclear, to which wtxid the user should expect seeing “broadcast-reattempt” property guarantee ?
Given our current relay policy default, I concede this is rather a marginal case, beyond illustrating another limit of our mempool replacement rules. In the future, it’s likely to worsen as taproot make it far easier to create witnesses with divergent feerates (e.g a 1-of-1 tapscript compared to a 15-of-15 one). In case of concurrent broadcast, the mempool won’t necessary learn the best-feerate candidate. That said, IMO, it’s worthy to fix because “txn-already-in-mempool” isn’t accurate anymore in a wtxid-relay context.