From 5084145c08a6528301dff66a2dc14b5f6cc90239 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 19 Oct 2026 17:18:21 +0000 Subject: [PATCH 1/3] LLMQ: skip Dandelion stem txs in IS/ChainLocks 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 Claude-Session: https://claude.ai/code/session_01KSBt691Ur4y5GQvdJ9VLiS --- qa/pull-tester/rpc-tests.py | 1 + qa/rpc-tests/llmq-is-dandelion.py | 69 +++++++++++++++++++++++++++++++ src/dsnotificationinterface.cpp | 4 ++ 3 files changed, 74 insertions(+) create mode 100644 qa/rpc-tests/llmq-is-dandelion.py diff --git a/qa/pull-tester/rpc-tests.py b/qa/pull-tester/rpc-tests.py index 42db7622c6..6beb9da1a3 100755 --- a/qa/pull-tester/rpc-tests.py +++ b/qa/pull-tester/rpc-tests.py @@ -187,6 +187,7 @@ 'llmq-cl-evospork.py', 'llmq-is-cl-conflicts.py', 'llmq-is-retroactive.py', + 'llmq-is-dandelion.py', # Unstable tests #, 'dip4-coinbasemerkleroots.py' diff --git a/qa/rpc-tests/llmq-is-dandelion.py b/qa/rpc-tests/llmq-is-dandelion.py new file mode 100644 index 0000000000..5e535c2893 --- /dev/null +++ b/qa/rpc-tests/llmq-is-dandelion.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +# Copyright (c) 2026 The Firo Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +from test_framework.mininode import * +from test_framework.test_framework import EvoZnodeTestFramework +from test_framework.util import * + +''' +llmq-is-dandelion.py + +A masternode must not vote on the InstantSend input locks of a Dandelion +stem-phase tx: its sig shares would tell the other quorum members that it holds +the tx before the tx is public. It votes once the tx is fluffed. + +"quorum sign" is the probe: it returns false if the masternode has already +voted on the input. +''' + +class LLMQ_IS_Dandelion(EvoZnodeTestFramework): + def __init__(self): + super().__init__(6, 5) + + def run_test(self): + self.mine_quorum() + + self.mn = self.mninfo[0].node + self.test_node = SingleNodeConnCB() + self.test_node.add_connection(NodeConn('127.0.0.1', p2p_port(self.mninfo[0].nodeIdx), self.mn, self.test_node)) + NetworkThread().start() + self.test_node.wait_for_verack() + + self.log.info("no vote while the tx is in the stem phase") + for _ in range(10): + tx = self.send_stem_tx() + voted = not self.mn.quorum("sign", 100, inlock_id(tx), tx.hash) + # A fluff (10% at once, else when the embargo ends) makes the vote legitimate: retry + if tx.hash not in self.mn.getrawmempool(): + break + else: + raise AssertionError("every tx was fluffed before the check") + assert(not voted) + + self.log.info("vote and lock once the tx is fluffed") + tx = self.send_stem_tx() + def fluffed(): + # Embargoes are only checked when the node processes a message + self.test_node.send_message(msg_ping()) + return tx.hash in self.mn.getrawmempool() + assert(wait_until(fluffed, timeout=30)) + self.wait_for_instantlock(tx.hash, self.mn, do_assert=True) + assert(not self.mn.quorum("sign", 100, inlock_id(tx), tx.hash)) + + def send_stem_tx(self): + raw = self.create_raw_tx(self.nodes[0], self.nodes[0], 1, 1, 1) + # node0 sees the tx only once it is fluffed, don't let it spend the input again + self.nodes[0].lockunspent(False, [{"txid": raw["vin"][0]["txid"], "vout": raw["vin"][0]["vout"]}]) + tx = FromHex(CTransaction(), raw["hex"]) + tx.rehash() + self.test_node.send_and_ping(msg_dandeliontx(tx)) + return tx + +def inlock_id(tx): + # SerializeHash(std::make_pair("inlock", outpoint)) of the first input + return encode(hash256(ser_string(b"inlock") + tx.vin[0].prevout.serialize())[::-1], 'hex_codec').decode('ascii') + +if __name__ == '__main__': + LLMQ_IS_Dandelion().main() diff --git a/src/dsnotificationinterface.cpp b/src/dsnotificationinterface.cpp index d3a38195f1..d424bfbd67 100644 --- a/src/dsnotificationinterface.cpp +++ b/src/dsnotificationinterface.cpp @@ -65,6 +65,10 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con void CDSNotificationInterface::SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock) { + // A Dandelion stem-phase tx is not public yet: signing its inputs would tell the other quorum members that we + // have it. Fluffing it accepts it into the mempool, which syncs it again. + if (!pindex && !mempool.exists(tx.GetHash()) && txpools.getStemTxPool().exists(tx.GetHash())) return; + llmq::quorumInstantSendManager->SyncTransaction(tx, pindex, posInBlock); llmq::chainLocksHandler->SyncTransaction(tx, pindex, posInBlock); } From feb66aa0dfd22c70674c33a93af3775900ec783c Mon Sep 17 00:00:00 2001 From: Reuben Yap Date: Mon, 2 Nov 2026 17:20:35 +0800 Subject: [PATCH 2/3] Tests: make Dandelion IS test executable Allow the RPC test runner to launch the registered test on Linux. --- qa/rpc-tests/llmq-is-dandelion.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 qa/rpc-tests/llmq-is-dandelion.py diff --git a/qa/rpc-tests/llmq-is-dandelion.py b/qa/rpc-tests/llmq-is-dandelion.py old mode 100644 new mode 100755 From 7cb081b8f6b638faede91ccfa4b008d0f9156ffb Mon Sep 17 00:00:00 2001 From: Reuben Yap Date: Wed, 4 Nov 2026 16:29:45 +0800 Subject: [PATCH 3/3] LLMQ: gate stem-pool accepts at the signal source 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 --- src/dsnotificationinterface.cpp | 4 ---- src/validation.cpp | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/dsnotificationinterface.cpp b/src/dsnotificationinterface.cpp index d424bfbd67..d3a38195f1 100644 --- a/src/dsnotificationinterface.cpp +++ b/src/dsnotificationinterface.cpp @@ -65,10 +65,6 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con void CDSNotificationInterface::SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock) { - // A Dandelion stem-phase tx is not public yet: signing its inputs would tell the other quorum members that we - // have it. Fluffing it accepts it into the mempool, which syncs it again. - if (!pindex && !mempool.exists(tx.GetHash()) && txpools.getStemTxPool().exists(tx.GetHash())) return; - llmq::quorumInstantSendManager->SyncTransaction(tx, pindex, posInBlock); llmq::chainLocksHandler->SyncTransaction(tx, pindex, posInBlock); } diff --git a/src/validation.cpp b/src/validation.cpp index a1b78689d9..307e403751 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1536,7 +1536,10 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C pwalletMain->sparkWallet->UpdateMintStateFromMempool(sparkMintCoins, hash); } #endif - GetMainSignals().SyncTransaction(tx, NULL, CMainSignals::SYNC_TRANSACTION_NOT_IN_BLOCK); + // Only the mempool is public: a Dandelion stem-pool accept must not reach the validation listeners (InstantSend + // would sign the inputs and tell its quorum about the tx before it is fluffed). Fluffing accepts the tx into the + // mempool, which notifies them. + if (&pool == &mempool) GetMainSignals().SyncTransaction(tx, NULL, CMainSignals::SYNC_TRANSACTION_NOT_IN_BLOCK); LogPrintf("AcceptToMemoryPoolWorker -> OK\n");