Skip to content

[PrivateSend] Allow more than 3 mixing participants #2612

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ class CMainParams : public CChainParams {
fAllowMultipleAddressesFromGroup = false;
fAllowMultiplePorts = false;

nPoolMaxTransactions = 3;
nPoolMinParticipants = 3;
nPoolMaxParticipants = 5;
nFulfilledRequestExpireTime = 60*60; // fulfilled requests expire in 1 hour

vSporkAddresses = {"Xgtyuk76vhuFW2iT7UAiHgNdWXCf3J34wh"};
Expand Down Expand Up @@ -463,7 +464,8 @@ class CTestNetParams : public CChainParams {
fAllowMultipleAddressesFromGroup = false;
fAllowMultiplePorts = false;

nPoolMaxTransactions = 3;
nPoolMinParticipants = 3;
nPoolMaxParticipants = 5;
nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes

vSporkAddresses = {"yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"};
Expand Down Expand Up @@ -608,7 +610,8 @@ class CDevNetParams : public CChainParams {
fAllowMultipleAddressesFromGroup = true;
fAllowMultiplePorts = true;

nPoolMaxTransactions = 3;
nPoolMinParticipants = 3;
nPoolMaxParticipants = 5;
nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes

vSporkAddresses = {"yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"};
Expand Down
6 changes: 4 additions & 2 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class CChainParams
const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
const CCheckpointData& Checkpoints() const { return checkpointData; }
const ChainTxData& TxData() const { return chainTxData; }
int PoolMaxTransactions() const { return nPoolMaxTransactions; }
int PoolMinParticipants() const { return nPoolMinParticipants; }
int PoolMaxParticipants() const { return nPoolMaxParticipants; }
int FulfilledRequestExpireTime() const { return nFulfilledRequestExpireTime; }
const std::vector<std::string>& SporkAddresses() const { return vSporkAddresses; }
int MinSporkKeys() const { return nMinSporkKeys; }
Expand Down Expand Up @@ -116,7 +117,8 @@ class CChainParams
bool fAllowMultiplePorts;
CCheckpointData checkpointData;
ChainTxData chainTxData;
int nPoolMaxTransactions;
int nPoolMinParticipants;
int nPoolMaxParticipants;
int nFulfilledRequestExpireTime;
std::vector<std::string> vSporkAddresses;
int nMinSporkKeys;
Expand Down
4 changes: 2 additions & 2 deletions src/privatesend-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,14 @@ std::string CPrivateSendClientSession::GetStatus(bool fWaitForBlock)
return _("PrivateSend request complete:") + " " + _("Your transaction was accepted into the pool!");
} else {
if (nStatusMessageProgress % 70 <= 40)
return strprintf(_("Submitted following entries to masternode: %u / %d"), nEntriesCount, CPrivateSend::GetMaxPoolTransactions());
return strprintf(_("Submitted following entries to masternode: %u"), nEntriesCount);
else if (nStatusMessageProgress % 70 <= 50)
strSuffix = ".";
else if (nStatusMessageProgress % 70 <= 60)
strSuffix = "..";
else if (nStatusMessageProgress % 70 <= 70)
strSuffix = "...";
return strprintf(_("Submitted to masternode, waiting for more entries ( %u / %d ) %s"), nEntriesCount, CPrivateSend::GetMaxPoolTransactions(), strSuffix);
return strprintf(_("Submitted to masternode, waiting for more entries ( %u ) %s"), nEntriesCount, strSuffix);
}
case POOL_STATE_SIGNING:
if (nStatusMessageProgress % 70 <= 40)
Expand Down
10 changes: 6 additions & 4 deletions src/privatesend-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ void CPrivateSendServer::SetNull()
{
// MN side
vecSessionCollaterals.clear();
nSessionMaxParticipants = NULL;

CPrivateSendBaseSession::SetNull();
CPrivateSendBaseManager::SetNull();
Expand All @@ -295,7 +296,7 @@ void CPrivateSendServer::CheckPool(CConnman& connman)
LogPrint("privatesend", "CPrivateSendServer::CheckPool -- entries count %lu\n", GetEntriesCount());

// If entries are full, create finalized transaction
if (nState == POOL_STATE_ACCEPTING_ENTRIES && GetEntriesCount() >= CPrivateSend::GetMaxPoolTransactions()) {
if (nState == POOL_STATE_ACCEPTING_ENTRIES && GetEntriesCount() >= nSessionMaxParticipants) {
LogPrint("privatesend", "CPrivateSendServer::CheckPool -- FINALIZE TRANSACTIONS\n");
CreateFinalTransaction(connman);
return;
Expand Down Expand Up @@ -435,10 +436,10 @@ void CPrivateSendServer::ChargeFees(CConnman& connman)
if (vecOffendersCollaterals.empty()) return;

//mostly offending? Charge sometimes
if ((int)vecOffendersCollaterals.size() >= Params().PoolMaxTransactions() - 1 && GetRandInt(100) > 33) return;
if ((int)vecOffendersCollaterals.size() >= nSessionMaxParticipants - 1 && GetRandInt(100) > 33) return;

//everyone is an offender? That's not right
if ((int)vecOffendersCollaterals.size() >= Params().PoolMaxTransactions()) return;
if ((int)vecOffendersCollaterals.size() >= nSessionMaxParticipants) return;

//charge one of the offenders randomly
std::random_shuffle(vecOffendersCollaterals.begin(), vecOffendersCollaterals.end());
Expand Down Expand Up @@ -593,7 +594,7 @@ bool CPrivateSendServer::AddEntry(const CPrivateSendEntry& entryNew, PoolMessage
return false;
}

if (GetEntriesCount() >= CPrivateSend::GetMaxPoolTransactions()) {
if (GetEntriesCount() >= nSessionMaxParticipants) {
LogPrint("privatesend", "CPrivateSendServer::AddEntry -- entries is full!\n");
nMessageIDRet = ERR_ENTRIES_FULL;
return false;
Expand Down Expand Up @@ -722,6 +723,7 @@ bool CPrivateSendServer::CreateNewSession(const CPrivateSendAccept& dsa, PoolMes
nMessageIDRet = MSG_NOERR;
nSessionID = GetRandInt(999999) + 1;
nSessionDenom = dsa.nDenom;
nSessionMaxParticipants = CPrivateSend::GetMinPoolParticipants() + GetRandInt(CPrivateSend::GetMaxPoolParticipants() - CPrivateSend::GetMinPoolParticipants() + 1);

SetState(POOL_STATE_QUEUE);
nTimeLastSuccessfulStep = GetTime();
Expand Down
5 changes: 4 additions & 1 deletion src/privatesend-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class CPrivateSendServer : public CPrivateSendBaseSession, public CPrivateSendBa
// to behave honestly. If they don't it takes their money.
std::vector<CTransactionRef> vecSessionCollaterals;

// Maximum number of participants in a certain session, random between min and max.
int nSessionMaxParticipants;

bool fUnitTest;

/// Add a clients entry to the pool
Expand All @@ -45,7 +48,7 @@ class CPrivateSendServer : public CPrivateSendBaseSession, public CPrivateSendBa
bool CreateNewSession(const CPrivateSendAccept& dsa, PoolMessage& nMessageIDRet, CConnman& connman);
bool AddUserToExistingSession(const CPrivateSendAccept& dsa, PoolMessage& nMessageIDRet);
/// Do we have enough users to take entries?
bool IsSessionReady() { return (int)vecSessionCollaterals.size() >= CPrivateSend::GetMaxPoolTransactions(); }
bool IsSessionReady() { return (int)vecSessionCollaterals.size() >= nSessionMaxParticipants; }

/// Check that all inputs are signed. (Are all inputs signed?)
bool IsSignaturesComplete();
Expand Down
5 changes: 3 additions & 2 deletions src/privatesend.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,9 @@ class CPrivateSend

static std::string GetMessageByID(PoolMessage nMessageID);

/// Get the maximum number of transactions for the pool
static int GetMaxPoolTransactions() { return Params().PoolMaxTransactions(); }
/// Get the minimum/maximum number of participants for the pool
static int GetMinPoolParticipants() { return Params().PoolMinParticipants(); }
static int GetMaxPoolParticipants() { return Params().PoolMaxParticipants(); }

static CAmount GetMaxPoolAmount() { return vecStandardDenominations.empty() ? 0 : PRIVATESEND_ENTRY_MAX_SIZE * vecStandardDenominations.front(); }

Expand Down