Repository navigation
LLMQ: skip Dandelion stem txs in IS/ChainLocks - #2019
Conversation
Accepting a tx into the Dandelion stem pool fires SyncTransaction the same way a mempool accept does. CInstantSendManager reads "no block, not in mempool" as a tx to (re)sign, so a masternode that receives a dandeliontx from an inbound peer records input-lock votes and, if it is in the quorum for an input, sends sig shares naming the txid to the other quorum members while the tx is still in the stem phase. Masternodes force -dandelion=0 but still accept stem txs from inbound peers, so any peer that picks a masternode as its stem destination triggers this. Don't forward that notification to IS and ChainLocks while the tx is only in the stem pool. Fluffing accepts it into the mempool, which notifies them again, so IS still locks it once it is public and the ChainLocks first-seen clock starts then. DisconnectTip resurrects txs into the stem pool before the mempool, so IS used to see them once with allowReSigning set. It now sees them on the mempool accept only, as upstream Dash does. llmq-is-dandelion.py checks that a masternode has not voted on a stem-only tx's input, and that it votes and locks once fluffed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KSBt691Ur4y5GQvdJ9VLiS
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
CodeAnt-AI DescriptionKeep Dandelion stem transactions private until they are fluffed What Changed
Impact
💡 Usage GuideChecking Your Pull RequestEvery time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later. Talking to CodeAnt AIGot a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask: This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code. ExamplePreserve Org Learnings with CodeAntYou can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input: This helps CodeAnt AI learn and adapt to your team's coding style and standards. ExampleRetrigger reviewAsk CodeAnt AI to review the PR again, by typing: Check Your Repository HealthTo analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5084145c08
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Allow the RPC test runner to launch the registered test on Linux.
AcceptToMemoryPoolWorker fired SyncTransaction for Dandelion stem-pool accepts exactly like mempool accepts, so every validation listener saw a tx that is not public yet. The previous commit filtered that in the LLMQ adapter only; fire the signal from the worker only when the pool is the mempool instead. Same effect for InstantSend and ChainLocks: a stem-only tx is not synced until it is fluffed into the mempool. Beyond them: the wallet and ZMQ no longer learn about inbound stem txs before the fluff, and a tx that arrives as a plain tx message is no longer synced twice (once for the mempool accept, once for the stem-pool mirror accept). The node's own wallet tx is still added by CommitTransaction's explicit AddToWallet, and Spark pool state is updated inside the worker before the signal, so neither depends on the stem notification. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Connect a conflicting regtest block through validation notifications and check that the mined winner receives the input vote. Cover mined and disconnected transaction tracking, duplicate removals, and fixture cleanup. The five InstantSend cases pass with the fix and the #2019 notification gate applied. Reverting only the fix reproduces the leaked tracking and vote for the evicted transaction. Six LLMQ suites pass (15 cases). refs #2023
* LLMQ: untrack txs evicted by block conflicts MemPoolConflictRemovalTracker reports a tx that a connected block evicted from the mempool with SyncTransaction(tx, NULL, SYNC_TRANSACTION_NOT_IN_BLOCK). CInstantSendManager::SyncTransaction only recognised a conflict removal when pindex was set (the DisconnectTip emission), a regression inherited verbatim from Dash #2951 (bb83fc4), so an evicted tx fell through to the mined-tx path instead: - ProcessTx(tx, allowReSigning=true) re-signed and re-announced the input lock shares of a tx whose inputs the block had just spent, and a member that had not voted yet voted for the dead tx and then rejected the mined tx as conflicting with its previous vote. - AddNonLockedTx tracked it with pindexMined unset, which nothing ever removes, so nonLockedTxs and nonLockedTxsByInputs grew until restart. Treat a tx that is not in a block and in neither the mempool nor the Dandelion stem pool as gone and route it to RemoveConflictedTx, which is a no-op for a tx that was never tracked. The stem pool check keeps stem-phase accepts, which are also reported without a block index, out of that path. Add a unit test for the accept/evict sequence. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * LLMQ: fix IS conflict-removal comment The comment above the conflict-removal branch claimed that RemoveConflictedTx forgets the input votes held for the tx. Its inputRequestIds erase hashes the whole CTxIn and so never matches the ids ProcessTx records from in.prevout. That mismatch is pre-existing (identical in Dash through v21) and left alone: making the erase effective would also stop a member that voted for the losing tx from acting on the mined winner's recovered input locks, which is a behaviour change for a separate PR. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Tests: cover InstantSend conflict notifications Connect a conflicting regtest block through validation notifications and check that the mined winner receives the input vote. Cover mined and disconnected transaction tracking, duplicate removals, and fixture cleanup. The five InstantSend cases pass with the fix and the #2019 notification gate applied. Reverting only the fix reproduces the leaked tracking and vote for the evicted transaction. Six LLMQ suites pass (15 cases). refs #2023 * Tests: document InstantSend test helpers Add Doxygen comments to the test-access helpers, the fixture and the test cases in llmq_instantsend_tests.cpp. CodeRabbit's docstring coverage check on #2023 flagged them as undocumented. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * LLMQ: document IS SyncTransaction contract Describe in the header which (pindex, posInBlock) shapes validation sends and what each one means, since the fix hinges on them. Switch the test helpers' //! comments to /** */ blocks, the style the header and the other test files use. Both are comment-only changes; CodeRabbit's docstring coverage check still flagged the PR after b1367ba. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
PR intention
Stop masternodes from signing InstantSend input locks for Dandelion stem-phase transactions.
Accepting a tx into the Dandelion stem pool fires
SyncTransactionthe same way a mempool accept does.CInstantSendManager::SyncTransactiontreats "no block, not in mempool" as a tx to (re)sign. So a masternode that receives adandeliontxfrom an inbound peer records input-lock votes, and if it is in the quorum for an input, it sends sig shares naming the txid to the other quorum members while the tx is still in the stem phase. Quorum members then know which masternode held the tx before it was public, which defeats the stem phase.This happens in practice. Masternodes force
-dandelion=0, but they still accept stem txs from inbound peers and answer Dandelion service discovery, so regular nodes use them as stem destinations.Reproduced on regtest: for a stem tx that could never be fluffed (a double spend was made public on every node), the other four quorum members logged sig-share session announcements naming its txid, and the non-masternode logged nothing. With this change, no other node sees the txid.
Code changes brief
AcceptToMemoryPoolWorkerfiresSyncTransactiononly when the pool it accepted into is the mempool. A Dandelion stem-pool accept no longer reaches any validation listener. Fluffing (CNode::RelayDandelionTransaction,CNode::CheckDandelionEmbargoes) accepts the tx into the mempool, which firesSyncTransactionthen. IS locks the tx once it is public, and the ChainLocks first-seen clock starts then.hashtx/rawtx,-walletnotify) learn about an inbound stem tx at fluff instead of at stem. The node's own wallet tx is still added byCommitTransaction's explicitAddToWallet, and Spark pool and wallet state are updated inside the worker before the signal, so neither depends on the stem notification. A tx that arrives as a plaintxmessage is no longer synced twice (once for the mempool accept, once for the stem-pool mirror accept).DisconnectTipresurrects txs into the stem pool before the mempool, so IS used to see them once withallowReSigningset. It now sees them on the mempool accept only, as upstream Dash does.qa/rpc-tests/llmq-is-dandelion.py, added torpc-tests.py. It sends adandeliontxfrom a mininode to a masternode and usesquorum signas a probe to check that the masternode has not voted on the input while the tx is stem-only. It then checks that the masternode votes and the tx gets IS-locked once fluffed.Commit history: the first commit filtered the notification in
CDSNotificationInterfaceonly; the third commit moves the filter to the signal source and removes the adapter guard.Testing:
llmq-is-dandelion.pyfails on unpatched master (5 of 5 runs, at the stem-phase check) and passes with the change (7 of 7);llmq-is-cl-conflicts.py,llmq-is-retroactive.py,llmq-chainlocks.py,llmq-is-spark.py,mempool_reorg.pyandmempool_resurrect_test.pypass. That build used system libraries instead ofdependsand did not build the unit tests.This is independent of #1954 (a crash on the same path), which is still needed.
Not addressed here: masternodes have no stem destinations, so they hold a received stem tx until their embargo expires. That races the sender's own embargo, which uses the same mainnet timings.
Generated by Claude Code