-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Split PS into Manager and Session and allow running multiple mixing sessions in parallel (on client side) #2203
Conversation
src/privatesend-client.cpp
Outdated
@@ -40,13 +44,18 @@ void CPrivateSendClient::ProcessMessage(CNode* pfrom, const std::string& strComm | |||
CDarksendQueue dsq; | |||
vRecv >> dsq; | |||
|
|||
{ |
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.
Why are these brackets here? If there's a reason for them to be there shouldn't it's contents be indented?
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.
That's for cs_vecqueue
lock. Same logic for changes as in #2200 basically but since the block here is pretty small and there are a lot of changes anyway I guess I should probably add some whitespaces here. Will fix.
UnlockCoins(); | ||
keyHolderStorage.ReturnAll(); | ||
SetNull(); | ||
} | ||
|
||
void CPrivateSendClient::SetNull() | ||
void CPrivateSendClientManager::ResetPool() |
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.
Shouldn't we keep CPrivateSendClientSession
methods together and CPrivateSendClientManager
methods together and not intermingle?
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.
The idea for the split is to change the behaviour, so imo it's best to keep the logic that was split close to the original one in code to make it easier to review. I would create a separate move-only PR after this one is merged (there are quite a few other dash-specific modules which could also be refactored this way btw).
for (auto& session : vecSessions) { | ||
strSessionDenoms += (session.nSessionDenom ? CPrivateSend::GetDenominationsToString(session.nSessionDenom) : "N/A") + "; "; | ||
} | ||
return strSessionDenoms.empty() ? "N/A" : strSessionDenoms; |
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.
Is `"N/A" consistent to use? I don't recall seeing that elsewhere and it seems a little weird.
Also, in current there is no difference in return between having 1 session which has no denoms and having no sessions, which I would think sound be a problem
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.
Not sure I understand what you mean tbh. Any suggestions how to modify this?
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.
I'm not sure if "N/A"
is a good message to use. It seems very non-descriptive but since I don't really know what the overall use case is I can't say if it should be changed or if it's fine and dandy
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.
This basically reproduces current GUI behaviour https://github.com/dashpay/dash/pull/2203/files/78d913321f724b736842a6560abee679a25142d9#diff-59a80b7def583e0548abaca42dca0236L576 but for multiple sessions.
src/privatesend-client.cpp
Outdated
} | ||
|
||
void CPrivateSendClientManager::CheckTimeout() |
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.
add comment to remain consistent?
src/privatesend-client.cpp
Outdated
CheckQueue(); | ||
|
||
for (auto& session : vecSessions) { | ||
if (!session.CheckTimeout()) { |
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.
Why does false mean timedout and true means not timedout? I get that the normal thing is true means success false means failed, but this just isn't intuitive imo and confuses a reader
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.
Makes sense, will rewrite CPrivateSendClientSession::CheckTimeout()
a bit.
static const int MAX_PRIVATESEND_ROUNDS = 16; | ||
static const int MAX_PRIVATESEND_AMOUNT = MAX_MONEY / COIN; | ||
static const int MAX_PRIVATESEND_LIQUIDITY = 100; | ||
static const int DEFAULT_PRIVATESEND_SESSIONS = 4; |
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.
Is there any reasoning for this and MAX_PRIVATESEND_SESSIONS
or do you just love 4 and 10 😉 ?
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.
Don't want to keep too many connections open to avoid high bandwidth usage while still having some positive effect of using multiple sessions even with default settings. 4 and 10 seems like reasonable numbers for normal and extreme usage respectively IMO :)
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.
Alright, we probably want to put some documentation out about how much bandwidth it'll use, etc on different values and if that might affect privacy in any way. Although that might be more @strophy 's domain?
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.
Well, by default node keeps MAX_OUTBOUND_CONNECTIONS
(8) regular connections open, so each new connections adds some initial sync
bandwidth (should be negligible) and relay everything
one which depends on current network activity. Anyway, good that you asked - I realized that we should also bump MAX_OUTBOUND_MASTERNODE_CONNECTIONS
to make sure mixing sessions fit into the limit, see 213a080 🙂 👍
if (privateSendClient.GetMixingMasternodeInfo(mnInfo)) { | ||
obj.push_back(Pair("outpoint", mnInfo.outpoint.ToStringShort())); | ||
obj.push_back(Pair("addr", mnInfo.addr.ToString())); | ||
// TODO: |
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.
remove todo
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.
It's for state
and entries
- not sure if I want them to be removed or implemented in pprivateSendBaseManager
, so I just added TODO here as a reminder.
+10 for parallel mixing
utACK |
I'm a little bit concerned that by making the mixing speed faster you might end up mixing with fewer people thus reducing your privacy. Any thoughts? |
@Antti-Kaikkonen yes, that's a good point but it also could be that you will mix with more people because 1) when mixing is faster more people could be willing to mix and 2) you could mix with those you would miss if you were using one session only. So I guess it's hard to say what the final outcome will be but imo it's a balanced one. |
@Antti-Kaikkonen Also, while the default number of sessions is 4, you can override that and set it to anywhere between 1 and 10 so "legacy mode" is still available if you set it to 1. |
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.
utACK
4d0f297
to
4f50895
Compare
…eSendClientManager::GetMixingMasternodesInfo(). This should solve potential deadlock cs_vecqueue vs cs_vNodes.
No potential deadlocks or conflicting transactions (finally) for a couple of days of non-stop mixing and a bunch of restarts here. Pls (re-)review/test :) |
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.
ACK, slightly tested
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.
utACK, nothing stands out to me, but I'm not too familiar w/PS code currently
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.
utACK
…essions in parallel (client side) (dashpay#2203) * Split PS into Manager and Session * Adjust log messages accordingly * add -privatesendsessions cmd-line option * address review comments * bump MAX_OUTBOUND_MASTERNODE_CONNECTIONS to 30 +10 for parallel mixing * protect vecSessions * constructors * Rewrite CMasternodeMan::ProcessMasternodeConnections() to use CPrivateSendClientManager::GetMixingMasternodesInfo(). This should solve potential deadlock cs_vecqueue vs cs_vNodes. * Drop no longer used IsMixingMasternode() * lock cs_wallet when mixing uses balance related functions
This should considerably speed things up (when there are enough participants ofc). Should also mitigate mixing speed degradation which could happen if we introduce additional mixing denoms (i.e. fix #2198) and keep the rest of it as is.