-
Notifications
You must be signed in to change notification settings - Fork 1.2k
test: add CoinJoin functional mixing coverage #7407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -958,6 +958,13 @@ static int WinnersToSkip() | |
| ? 1 : 8; | ||
| } | ||
|
|
||
| static bool IsDisconnectRequested(const CConnman& connman, const CService& addr) | ||
| { | ||
| return connman.ForNode(addr, CConnman::AllNodes, [](const CNode* pnode) { | ||
| return pnode->fDisconnect.load(); | ||
| }); | ||
| } | ||
|
|
||
| bool CCoinJoinClientSession::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, CConnman& connman) | ||
| { | ||
| if (!CCoinJoinClientOptions::IsEnabled()) return false; | ||
|
|
@@ -997,7 +1004,7 @@ bool CCoinJoinClientSession::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, | |
|
|
||
| m_clientman.AddUsedMasternode(dmn->proTxHash); | ||
|
|
||
| if (connman.IsMasternodeOrDisconnectRequested(dmn->pdmnState->netInfo->GetPrimary())) { | ||
| if (IsDisconnectRequested(connman, dmn->pdmnState->netInfo->GetPrimary())) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a wallet receives a queue from a masternode it has already mixed with and the masternode connection is still open, this new check no longer filters it out; Useful? React with 👍 / 👎. |
||
| WalletCJLogPrint(m_wallet, /* Continued */ | ||
| "CCoinJoinClientSession::JoinExistingQueue -- skipping connection, masternode=%s\n", dmn->proTxHash.ToString()); | ||
| continue; | ||
|
|
@@ -1067,7 +1074,7 @@ bool CCoinJoinClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, CCon | |
| continue; | ||
| } | ||
|
|
||
| if (connman.IsMasternodeOrDisconnectRequested(dmn->pdmnState->netInfo->GetPrimary())) { | ||
| if (IsDisconnectRequested(connman, dmn->pdmnState->netInfo->GetPrimary())) { | ||
| WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::StartNewQueue -- skipping connection, masternode=%s\n", | ||
| dmn->proTxHash.ToString()); | ||
| nTries++; | ||
|
|
@@ -1782,4 +1789,3 @@ void CCoinJoinClientManager::GetJsonInfo(UniValue& obj) const | |
| } | ||
| obj.pushKV("sessions", arrSessions); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ static constexpr int MIN_COINJOIN_DENOMS_GOAL = 10; | |
| static constexpr int MIN_COINJOIN_DENOMS_HARDCAP = 10; | ||
| static constexpr int MAX_COINJOIN_SESSIONS = 10; | ||
| static constexpr int MAX_COINJOIN_ROUNDS = 16; | ||
| static constexpr int MIN_COINJOIN_RANDOM_ROUNDS = 0; | ||
| static constexpr int MAX_COINJOIN_DENOMS_GOAL = 100000; | ||
| static constexpr int MAX_COINJOIN_DENOMS_HARDCAP = 100000; | ||
| static constexpr int MAX_COINJOIN_AMOUNT = MAX_MONEY / COIN; | ||
|
|
@@ -49,6 +50,7 @@ static constexpr int COINJOIN_KEYS_THRESHOLD_WARNING = 100; | |
| static constexpr int COINJOIN_KEYS_THRESHOLD_STOP = 50; | ||
| // Pseudorandomly mix up to this many times in addition to base round count | ||
| static constexpr int COINJOIN_RANDOM_ROUNDS = 3; | ||
| static constexpr int MAX_COINJOIN_RANDOM_ROUNDS = COINJOIN_RANDOM_ROUNDS; | ||
|
Comment on lines
52
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 Nitpick: -coinjoinrandomrounds can only decrease the default; help text does not convey the cap is tied to the default
source: ['claude'] |
||
|
|
||
| /* Application wide mixing options */ | ||
| class CCoinJoinClientOptions | ||
|
|
@@ -65,6 +67,7 @@ class CCoinJoinClientOptions | |
| static void SetMultiSessionEnabled(bool fEnabled); | ||
| static void SetSessions(int sessions); | ||
| static void SetRounds(int nRounds); | ||
| static void SetRandomRounds(int nRandomRounds); | ||
| static void SetAmount(CAmount amount); | ||
| static void SetDenomsGoal(int denoms_goal); | ||
| static void SetDenomsHardCap(int denoms_hardcap); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Suggestion: New IsDisconnectRequested silently drops the m_masternode_connection guard on all networks
CConnman::IsMasternodeOrDisconnectRequested(src/net.cpp:4895-4900) returnspnode->m_masternode_connection || pnode->fDisconnect. This exact combined predicate is used consistently in net.cpp's own masternode-connection bookkeeping (src/net.cpp:3456 ingetPendingQuorumNodes, and the inverse at src/net.cpp:3528 ingetConnectToDmn) to avoid repurposing a connection already dedicated as a masternode/quorum/probe connection.This PR replaces the call sites in
JoinExistingQueue(src/coinjoin/client.cpp:1007) andStartNewQueue(src/coinjoin/client.cpp:1077) with a new local free functionIsDisconnectRequestedthat only checkspnode->fDisconnect, dropping them_masternode_connectionhalf. That is a real behavior change on mainnet/testnet/devnet, not just regtest:JoinExistingQueue/StartNewQueuewill now proceed toAddPendingMasternode()and setpendingDsaRequestagainst a masternode we already have an outboundm_masternode_connectionto (e.g. an LLMQ or probe connection).getConnectToDmn()still refuses to open a second socket to an already-connected address, so DSA/DSI/DSS/DSTX traffic will now be multiplexed over an existing LLMQ/probe connection instead of a dedicated CoinJoin one.This is also bundled under a
test:-prefixed commit (4b0da0a) with no rationale in the message or PR description beyond enabling the small regtest masternode set to reuse peers. Please either (a) restore them_masternode_connectionshort-circuit and address the regtest reuse constraint another way, or (b) split this hunk into its owncoinjoin:commit with a body explaining why dropping the guard is safe for message ordering, disconnect-on-session-end semantics, and PoSe accounting, and confirm with the CoinJoin owners.source: ['claude']