Skip to content

LLMQ: skip Dandelion stem txs in IS/ChainLocks - #2019

Merged
reubenyap merged 3 commits into
masterfrom
claude/dreamy-heisenberg-klco88
Nov 5, 2026
Merged

reubenyap merged 3 commits into
masterfrom
claude/dreamy-heisenberg-klco88

Conversation

@reubenyap

@reubenyap reubenyap commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

PR intention

Stop masternodes from signing InstantSend input locks for Dandelion stem-phase transactions.

Accepting a tx into the Dandelion stem pool fires SyncTransaction the same way a mempool accept does. CInstantSendManager::SyncTransaction treats "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, 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

  • AcceptToMemoryPoolWorker fires SyncTransaction only 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 fires SyncTransaction then. IS locks the tx once it is public, and the ChainLocks first-seen clock starts then.
  • Beyond IS and ChainLocks: the wallet and ZMQ (hashtx/rawtx, -walletnotify) learn about an inbound stem tx at fluff instead of at stem. The node's own wallet tx is still added by CommitTransaction's explicit AddToWallet, 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 plain tx message is no longer synced twice (once for the mempool accept, once for the stem-pool mirror accept).
  • Side effect: 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.
  • New functional test qa/rpc-tests/llmq-is-dandelion.py, added to rpc-tests.py. It sends a dandeliontx from a mininode to a masternode and uses quorum sign as 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 CDSNotificationInterface only; the third commit moves the filter to the signal source and removes the adapter guard.

Testing:

  • Local regtest build of the adapter-guard commit: llmq-is-dandelion.py fails 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.py and mempool_resurrect_test.py pass. That build used system libraries instead of depends and did not build the unit tests.
  • The source-level gate was not built locally; CI (unit tests and the full RPC suite, including the wallet and ZMQ dependent tests) is the authoritative check for it.

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

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
@codeant-ai

codeant-ai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

CodeAnt  CodeAnt Review Status

✅  Review completed

Status Commit Started (UTC) Finished (UTC)
✅  #47161 Incremental review completed 7cb081b Nov 04, 2026 · 08:31 08:31
✅  #ddc26 Incremental review completed feb66aa Nov 02, 2026 · 09:21 09:21
✅  #339d0 Reviewed your PR 5084145 Nov 02, 2026 · 08:09 08:14

@codeant-ai

codeant-ai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T08:11:47.012493Z 5084145 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary by CodeRabbit

  • Bug Fixes
    • Transaction synchronization notifications are now sent when a transaction enters the public mempool, not when it enters the Dandelion stem pool.
  • Tests
    • Added coverage for InstantSend quorum voting across Dandelion phases, including checks before and after a transaction appears in the mempool.
    • The new test is included in the default RPC test suite.

Walkthrough

AcceptToMemoryPoolWorker now calls SyncTransaction only for transactions accepted into the public mempool. A new RPC test checks masternode quorum voting across Dandelion stem and fluff phases, and the test runner includes it.

Changes

Dandelion quorum voting

Layer / File(s) Summary
Public-mempool notification guard
src/validation.cpp
AcceptToMemoryPoolWorker calls SyncTransaction for public-mempool acceptance, but not for stem-pool acceptance.
Voting test and test-runner registration
qa/rpc-tests/llmq-is-dandelion.py, qa/pull-tester/rpc-tests.py
The new RPC test checks for no vote while a transaction remains outside the masternode’s mempool, then checks for a vote after another transaction enters the mempool and receives an InstantSend lock. The default RPC test list includes the test.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: Minimal · up to 7cb08

The change stops masternodes from voting on InstantSend locks for transactions that are still in the Dandelion stem phase, and a new RPC test covers the stem and fluff phases. No concrete merge-blocking risk remains in the supplied evidence.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "LLMQ: skip Dandelion stem txs in IS/ChainLocks" matches the main change. The PR stops masternodes from signing InstantSend input locks for Dandelion stem-phase transactions. The source chan…
Description check Passed The description follows the template. It has a filled-in 'PR intention' section that explains the problem, the cause (SyncTransaction fired on stem-pool accepts), the observed effect (quorum members l…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "LLMQ: skip Dandelion stem txs in IS/ChainLocks" matches the main change. The PR stops masternodes from signing InstantSend input locks for Dandelion stem-phase transactions. The source change in validation.cpp limits SyncTransaction to mempool accepts, which is the mechanism behind the title. The title is specific and short. It does not name the validation.cpp change or the new test, but it does not need to cover every detail.

Full details: Description check

Explanation

The description follows the template. It has a filled-in 'PR intention' section that explains the problem, the cause (SyncTransaction fired on stem-pool accepts), the observed effect (quorum members logged sig-share announcements naming a stem txid), and the fix. It also has a filled-in 'Code changes brief' section that covers the validation.cpp change, the side effects on wallet, ZMQ, and DisconnectTip, and the new functional test. It includes testing details and a note on the related open issue. The template's 'DeleteMe' placeholder text has been removed from both sections. The description contains a generated-by footer, which is not part of the template, but this does not affect completeness.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 3 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 93a64721-6f58-4efb-b4da-4525073e282b
Commits

Reviewing files that changed from the base of the PR and between feb66aa and 7cb081b.

Files selected for processing: 1
  • src/validation.cpp

Included review availability: This review used your included allowance. 4 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files label Nov 2, 2026
@codeant-ai

codeant-ai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

CodeAnt-AI Description

Keep Dandelion stem transactions private until they are fluffed

What Changed

  • Stem-phase transactions no longer trigger validation notifications, so InstantSend quorum members do not vote on them before they become public.
  • Notifications resume when a transaction enters the public mempool, allowing InstantSend to vote and lock it.
  • Added a regression test for the stem and fluffed phases.

Impact

✅ Dandelion stem transactions stay hidden from InstantSend quorums
✅ InstantSend locks begin after transactions become public
✅ ChainLocks timing starts after transactions are fluffed

💡 Usage Guide

Checking Your Pull Request

Every 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 AI

Got 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:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You 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:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To 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.

@coderabbitai
coderabbitai Bot requested a review from psolstice November 2, 2026 08:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread qa/pull-tester/rpc-tests.py Resolved
@codeant-ai

codeant-ai Bot commented Nov 2, 2026

Copy link
Copy Markdown

CodeAnt  CodeAnt Nitpicks

1 code suggestion

1. quorum sign starts signing when no vote exists, so this check itself records a vote and sends shares for the stem transaction.

Api mismatch · qa/rpc-tests/llmq-is-dandelion.py:37

@codeant-ai

codeant-ai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 7cb081b8f6b6

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread qa/pull-tester/rpc-tests.py Resolved
reubenyap and others added 2 commits November 2, 2026 17:20
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>
@reubenyap
reubenyap merged commit 009276a into master Nov 5, 2026
26 of 27 checks passed
@reubenyap
reubenyap deleted the claude/dreamy-heisenberg-klco88 branch November 5, 2026 17:05
reubenyap added a commit that referenced this pull request Nov 5, 2026
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
reubenyap added a commit that referenced this pull request Nov 12, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants