Skip to content

Commit 863057d

Browse files
authored
Merge pull request #3301 from UdjinM6/bp15rc2_3
Backport remaining "candidates" from develop to v0.15.x
2 parents 6127f30 + 058872d commit 863057d

File tree

14 files changed

+205
-29
lines changed

14 files changed

+205
-29
lines changed

doc/release-notes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ modules were reorganized in separate folders to make navigation through code a b
223223

224224
See detailed [set of changes](https://github.com/dashpay/dash/compare/v0.14.0.5...dashpay:v0.15.0.0).
225225

226+
- [`546e69f1a`](https://github.com/dashpay/dash/commit/546e69f1a) Fix CActiveMasternodeManager::GetLocalAddress to prefer IPv4 if multiple local addresses are known (#3304)
227+
- [`e4ef7e8d0`](https://github.com/dashpay/dash/commit/e4ef7e8d0) Drop unused `invSet` in `CDKGSession` (#3303)
228+
- [`da7686c93`](https://github.com/dashpay/dash/commit/da7686c93) Update translations 2020-01-23 (#3302)
229+
- [`6b5d3edae`](https://github.com/dashpay/dash/commit/6b5d3edae) Fix dip4-coinbasemerkleroots.py race condition (#3297)
230+
- [`a8213cadb`](https://github.com/dashpay/dash/commit/a8213cadb) Various fixes for DSTX-es (#3295)
231+
- [`2c26bdf2d`](https://github.com/dashpay/dash/commit/2c26bdf2d) Update release-notes.md
226232
- [`1d9adbe63`](https://github.com/dashpay/dash/commit/1d9adbe63) Replace generic CScopedDBTransaction with specialized CEvoDBScopedCommitter (#3292)
227233
- [`8fd486c6b`](https://github.com/dashpay/dash/commit/8fd486c6b) Translations 2020-01 (#3192)
228234
- [`3c54f6527`](https://github.com/dashpay/dash/commit/3c54f6527) Bump copyright year to 2020 (#3290)

src/dsnotificationinterface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,5 @@ void CDSNotificationInterface::NotifyMasternodeListChanged(bool undo, const CDet
107107
void CDSNotificationInterface::NotifyChainLock(const CBlockIndex* pindex, const llmq::CChainLockSig& clsig)
108108
{
109109
llmq::quorumInstantSendManager->NotifyChainLock(pindex);
110+
CPrivateSend::NotifyChainLock(pindex);
110111
}

src/llmq/quorums_dkgsession.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ void CDKGSession::ReceiveMessage(const uint256& hash, const CDKGContribution& qc
280280
member->contributions.emplace(hash);
281281

282282
CInv inv(MSG_QUORUM_CONTRIB, hash);
283-
invSet.emplace(inv);
284283
RelayInvToParticipants(inv);
285284

286285
quorumDKGDebugManager->UpdateLocalMemberStatus(params.type, member->idx, [&](CDKGDebugMemberStatus& status) {
@@ -547,7 +546,6 @@ void CDKGSession::ReceiveMessage(const uint256& hash, const CDKGComplaint& qc, b
547546
member->complaints.emplace(hash);
548547

549548
CInv inv(MSG_QUORUM_COMPLAINT, hash);
550-
invSet.emplace(inv);
551549
RelayInvToParticipants(inv);
552550

553551
quorumDKGDebugManager->UpdateLocalMemberStatus(params.type, member->idx, [&](CDKGDebugMemberStatus& status) {
@@ -762,7 +760,6 @@ void CDKGSession::ReceiveMessage(const uint256& hash, const CDKGJustification& q
762760

763761
// we always relay, even if further verification fails
764762
CInv inv(MSG_QUORUM_JUSTIFICATION, hash);
765-
invSet.emplace(inv);
766763
RelayInvToParticipants(inv);
767764

768765
quorumDKGDebugManager->UpdateLocalMemberStatus(params.type, member->idx, [&](CDKGDebugMemberStatus& status) {
@@ -1130,7 +1127,6 @@ void CDKGSession::ReceiveMessage(const uint256& hash, const CDKGPrematureCommitm
11301127
validCommitments.emplace(hash);
11311128

11321129
CInv inv(MSG_QUORUM_PREMATURE_COMMITMENT, hash);
1133-
invSet.emplace(inv);
11341130
RelayInvToParticipants(inv);
11351131

11361132
quorumDKGDebugManager->UpdateLocalMemberStatus(params.type, member->idx, [&](CDKGDebugMemberStatus& status) {

src/llmq/quorums_dkgsession.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ class CDKGSession
274274
std::map<uint256, CDKGComplaint> complaints;
275275
std::map<uint256, CDKGJustification> justifications;
276276
std::map<uint256, CDKGPrematureCommitment> prematureCommitments;
277-
std::set<CInv> invSet;
278277

279278
std::vector<size_t> pendingContributionVerifications;
280279

src/masternode/activemasternode.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,15 @@ void CActiveMasternodeManager::UpdatedBlockTip(const CBlockIndex* pindexNew, con
177177

178178
bool CActiveMasternodeManager::GetLocalAddress(CService& addrRet)
179179
{
180-
// First try to find whatever local address is specified by externalip option
181-
bool fFoundLocal = GetLocal(addrRet) && IsValidNetAddr(addrRet);
180+
// First try to find whatever our own local address is known internally.
181+
// Addresses could be specified via externalip or bind option, discovered via UPnP
182+
// or added by TorController. Use some random dummy IPv4 peer to prefer the one
183+
// reachable via IPv4.
184+
CNetAddr addrDummyPeer;
185+
bool fFoundLocal{false};
186+
if (LookupHost("8.8.8.8", addrDummyPeer, false)) {
187+
fFoundLocal = GetLocal(addrRet, &addrDummyPeer) && IsValidNetAddr(addrRet);
188+
}
182189
if (!fFoundLocal && Params().NetworkIDString() == CBaseChainParams::REGTEST) {
183190
if (Lookup("127.0.0.1", addrRet, GetListenPort(), false)) {
184191
fFoundLocal = true;

src/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ class CNode
999999
void PushInventory(const CInv& inv)
10001000
{
10011001
LOCK(cs_inventory);
1002-
if (inv.type == MSG_TX) {
1002+
if (inv.type == MSG_TX || inv.type == MSG_DSTX) {
10031003
if (!filterInventoryKnown.contains(inv.hash)) {
10041004
LogPrint(BCLog::NET, "PushInventory -- inv: %s peer=%d\n", inv.ToString(), id);
10051005
setInventoryTxToSend.insert(inv.hash);

src/net_processing.cpp

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
10111011
switch (inv.type)
10121012
{
10131013
case MSG_TX:
1014+
case MSG_DSTX:
10141015
case MSG_LEGACY_TXLOCK_REQUEST: // we treat legacy IX messages as TX messages
10151016
{
10161017
assert(recentRejects);
@@ -1034,7 +1035,17 @@ bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
10341035
// and re-request the locked transaction (which did not make it into the mempool
10351036
// previously due to txn-mempool-conflict rule). This means that we must ignore
10361037
// recentRejects filter for such locked txes here.
1037-
return (recentRejects->contains(inv.hash) && !llmq::quorumInstantSendManager->IsLocked(inv.hash)) ||
1038+
// We also ignore recentRejects filter for DSTX-es because a malicious peer might
1039+
// relay a valid DSTX as a regular TX first which would skip all the specific checks
1040+
// but would cause such tx to be rejected by ATMP due to 0 fee. Ignoring it here
1041+
// should let DSTX to be propagated by honest peer later. Note, that a malicious
1042+
// masternode would not be able to exploit this to spam the network with specially
1043+
// crafted invalid DSTX-es and potentially cause high load cheaply, because
1044+
// corresponding checks in ProcessMessage won't let it to send DSTX-es too often.
1045+
bool fIgnoreRecentRejects = llmq::quorumInstantSendManager->IsLocked(inv.hash) || inv.type == MSG_DSTX;
1046+
1047+
return (!fIgnoreRecentRejects && recentRejects->contains(inv.hash)) ||
1048+
(inv.type == MSG_DSTX && static_cast<bool>(CPrivateSend::GetDSTX(inv.hash))) ||
10381049
mempool.exists(inv.hash) ||
10391050
pcoinsTip->HaveCoinInCache(COutPoint(inv.hash, 0)) || // Best effort: only try output 0 and 1
10401051
pcoinsTip->HaveCoinInCache(COutPoint(inv.hash, 1)) ||
@@ -1060,10 +1071,6 @@ bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
10601071
return sporkManager.GetSporkByHash(inv.hash, spork);
10611072
}
10621073

1063-
case MSG_DSTX: {
1064-
return static_cast<bool>(CPrivateSend::GetDSTX(inv.hash));
1065-
}
1066-
10671074
case MSG_GOVERNANCE_OBJECT:
10681075
case MSG_GOVERNANCE_OBJECT_VOTE:
10691076
return ! governance.ConfirmInventoryRequest(inv);
@@ -1274,17 +1281,29 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
12741281

12751282
// Send stream from relay memory
12761283
bool push = false;
1277-
if (inv.type == MSG_TX) {
1284+
if (inv.type == MSG_TX || inv.type == MSG_DSTX) {
1285+
CPrivateSendBroadcastTx dstx;
1286+
if (inv.type == MSG_DSTX) {
1287+
dstx = CPrivateSend::GetDSTX(inv.hash);
1288+
}
12781289
auto mi = mapRelay.find(inv.hash);
12791290
if (mi != mapRelay.end()) {
1280-
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::TX, *mi->second));
1291+
if (dstx) {
1292+
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::DSTX, dstx));
1293+
} else {
1294+
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::TX, *mi->second));
1295+
}
12811296
push = true;
12821297
} else if (pfrom->timeLastMempoolReq) {
12831298
auto txinfo = mempool.info(inv.hash);
12841299
// To protect privacy, do not answer getdata using the mempool when
12851300
// that TX couldn't have been INVed in reply to a MEMPOOL request.
12861301
if (txinfo.tx && txinfo.nTime <= pfrom->timeLastMempoolReq) {
1287-
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::TX, *txinfo.tx));
1302+
if (dstx) {
1303+
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::DSTX, dstx));
1304+
} else {
1305+
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::TX, *txinfo.tx));
1306+
}
12881307
push = true;
12891308
}
12901309
}
@@ -1298,14 +1317,6 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
12981317
}
12991318
}
13001319

1301-
if (!push && inv.type == MSG_DSTX) {
1302-
CPrivateSendBroadcastTx dstx = CPrivateSend::GetDSTX(inv.hash);
1303-
if(dstx) {
1304-
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::DSTX, dstx));
1305-
push = true;
1306-
}
1307-
}
1308-
13091320
if (!push && inv.type == MSG_GOVERNANCE_OBJECT) {
13101321
LogPrint(BCLog::NET, "ProcessGetData -- MSG_GOVERNANCE_OBJECT: inv = %s\n", inv.ToString());
13111322
CDataStream ss(SER_NETWORK, pfrom->GetSendVersion());
@@ -2452,7 +2463,19 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
24522463
return true; // not an error
24532464
}
24542465

2455-
auto dmn = deterministicMNManager->GetListAtChainTip().GetMNByCollateral(dstx.masternodeOutpoint);
2466+
const CBlockIndex* pindex{nullptr};
2467+
CDeterministicMNCPtr dmn{nullptr};
2468+
{
2469+
LOCK(cs_main);
2470+
pindex = chainActive.Tip();
2471+
}
2472+
// It could be that a MN is no longer in the list but its DSTX is not yet mined.
2473+
// Try to find a MN up to 24 blocks deep to make sure such dstx-es are relayed and processed correctly.
2474+
for (int i = 0; i < 24 && pindex; ++i) {
2475+
dmn = deterministicMNManager->GetListForBlock(pindex).GetMNByCollateral(dstx.masternodeOutpoint);
2476+
if (dmn) break;
2477+
pindex = pindex->pprev;
2478+
}
24562479
if(!dmn) {
24572480
LogPrint(BCLog::PRIVATESEND, "DSTX -- Can't find masternode %s to verify %s\n", dstx.masternodeOutpoint.ToStringShort(), hashTx.ToString());
24582481
return false;
@@ -2523,6 +2546,10 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
25232546
CInv _inv(MSG_TX, txin.prevout.hash);
25242547
pfrom->AddInventoryKnown(_inv);
25252548
if (!AlreadyHave(_inv)) pfrom->AskFor(_inv);
2549+
// We don't know if the previous tx was a regular or a mixing one, try both
2550+
CInv _inv2(MSG_DSTX, txin.prevout.hash);
2551+
pfrom->AddInventoryKnown(_inv2);
2552+
if (!AlreadyHave(_inv2)) pfrom->AskFor(_inv2);
25262553
}
25272554
AddOrphanTx(ptx, pfrom->GetId());
25282555

@@ -3785,7 +3812,11 @@ bool PeerLogicValidation::SendMessages(CNode* pto, std::atomic<bool>& interruptM
37853812

37863813
for (const auto& txinfo : vtxinfo) {
37873814
const uint256& hash = txinfo.tx->GetHash();
3788-
CInv inv(MSG_TX, hash);
3815+
int nInvType = MSG_TX;
3816+
if (CPrivateSend::GetDSTX(hash)) {
3817+
nInvType = MSG_DSTX;
3818+
}
3819+
CInv inv(nInvType, hash);
37893820
pto->setInventoryTxToSend.erase(hash);
37903821
if (pto->pfilter) {
37913822
if (!pto->pfilter->IsRelevantAndUpdate(*txinfo.tx)) continue;
@@ -3851,7 +3882,11 @@ bool PeerLogicValidation::SendMessages(CNode* pto, std::atomic<bool>& interruptM
38513882
}
38523883
if (pto->pfilter && !pto->pfilter->IsRelevantAndUpdate(*txinfo.tx)) continue;
38533884
// Send
3854-
vInv.push_back(CInv(MSG_TX, hash));
3885+
int nInvType = MSG_TX;
3886+
if (CPrivateSend::GetDSTX(hash)) {
3887+
nInvType = MSG_DSTX;
3888+
}
3889+
vInv.push_back(CInv(nInvType, hash));
38553890
nRelayedTransactions++;
38563891
{
38573892
// Expire old relay messages

src/privatesend/privatesend.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,13 @@ void CPrivateSend::UpdatedBlockTip(const CBlockIndex* pindex)
603603
}
604604
}
605605

606+
void CPrivateSend::NotifyChainLock(const CBlockIndex* pindex)
607+
{
608+
if (pindex && masternodeSync.IsBlockchainSynced()) {
609+
CheckDSTXes(pindex);
610+
}
611+
}
612+
606613
void CPrivateSend::UpdateDSTXConfirmedHeight(const CTransactionRef& tx, int nHeight)
607614
{
608615
AssertLockHeld(cs_mapdstx);

src/privatesend/privatesend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ class CPrivateSend
465465
static CPrivateSendBroadcastTx GetDSTX(const uint256& hash);
466466

467467
static void UpdatedBlockTip(const CBlockIndex* pindex);
468+
static void NotifyChainLock(const CBlockIndex* pindex);
468469

469470
static void UpdateDSTXConfirmedHeight(const CTransactionRef& tx, int nHeight);
470471
static void TransactionAddedToMempool(const CTransactionRef& tx);

src/qt/locale/dash_es.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,10 @@
13261326
<source>This amount acts as a threshold to turn off PrivateSend once it's reached.</source>
13271327
<translation>Esta cantidad actúa como un límite para desactivar PrivateSend una vez que se alcanza ese límite.</translation>
13281328
</message>
1329+
<message>
1330+
<source>Target PrivateSend balance</source>
1331+
<translation>Saldo objetivo de PrivateSend</translation>
1332+
</message>
13291333
<message>
13301334
<source>Automatically open the Dash Core client port on the router. This only works when your router supports UPnP and it is enabled.</source>
13311335
<translation>Abrir automáticamente el puerto del cliente Dash Core en el enrutador. Esto solo funciona cuando su enrutador admite UPnP y está habilitado.</translation>
@@ -1715,6 +1719,10 @@ https://www.transifex.com/projects/p/dash/</translation>
17151719
<source>Denominated</source>
17161720
<translation>Denominadas</translation>
17171721
</message>
1722+
<message>
1723+
<source>Partially mixed</source>
1724+
<translation>Parcialmente mezclado</translation>
1725+
</message>
17181726
<message>
17191727
<source>Mixed</source>
17201728
<translation>Mezcladas</translation>
@@ -2801,6 +2809,10 @@ https://www.transifex.com/projects/p/dash/</translation>
28012809
<source>&lt;b&gt;(%1 of %2 entries displayed)&lt;/b&gt;</source>
28022810
<translation>&lt;b&gt;(%1 de %2 registros mostrados)&lt;/b&gt;</translation>
28032811
</message>
2812+
<message>
2813+
<source>PrivateSend funds only</source>
2814+
<translation>Fondos de PrivateSend solamente</translation>
2815+
</message>
28042816
<message>
28052817
<source>any available funds</source>
28062818
<translation>cualquier fondo disponible</translation>
@@ -2817,6 +2829,10 @@ https://www.transifex.com/projects/p/dash/</translation>
28172829
<source>Fee rate: %1</source>
28182830
<translation>Tasa de comisión: %1</translation>
28192831
</message>
2832+
<message numerus="yes">
2833+
<source>This transaction will consume %n input(s)</source>
2834+
<translation><numerusform>Esta transacción consumirá %n entrada</numerusform><numerusform>Esta transacción consumirá %n entradas</numerusform></translation>
2835+
</message>
28202836
<message>
28212837
<source>Warning: Using PrivateSend with %1 or more inputs can harm your privacy and is not recommended</source>
28222838
<translation>Advertencia: el uso de PrivateSend con %1 o más entradas puede dañar tu privacidad y no se recomienda</translation>

0 commit comments

Comments
 (0)