Skip to content
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
2 changes: 1 addition & 1 deletion src/llmq/quorums_signing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ void CSigningManager::ProcessRecoveredSig(NodeId nodeId, const CRecoveredSig& re

CInv inv(MSG_QUORUM_RECOVERED_SIG, recoveredSig.GetHash());
g_connman->ForEachNode([&](CNode* pnode) {
if (pnode->nVersion >= LLMQS_PROTO_VERSION && pnode->fSendRecSigs) {
if (pnode->nVersion >= LLMQS_PROTO_VERSION && pnode->fSendRecSigs && !pnode->fMasternode) {
pnode->PushInventory(inv);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/masternode/masternode-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void CMasternodeUtils::ProcessMasternodeConnections(CConnman& connman)
}

connman.ForEachNode(CConnman::AllNodes, [&](CNode* pnode) {
if (pnode->fMasternode && !connman.IsMasternodeQuorumNode(pnode)) {
if (!pnode->fInbound && pnode->fMasternode && !connman.IsMasternodeQuorumNode(pnode)) {
#ifdef ENABLE_WALLET
bool fFound = false;
for (const auto& dmn : vecDmns) {
Expand Down
22 changes: 14 additions & 8 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ void CNode::copyStats(CNodeStats &stats)
LOCK(cs_mnauth);
X(verifiedProRegTxHash);
}
X(fMasternode);
}
#undef X

Expand Down Expand Up @@ -2944,22 +2945,26 @@ void CConnman::RelayTransaction(const CTransaction& tx)
LOCK(cs_vNodes);
for (CNode* pnode : vNodes)
{
if (pnode->fMasternode)
continue;
pnode->PushInventory(inv);
}
}

void CConnman::RelayInv(CInv &inv, const int minProtoVersion) {
void CConnman::RelayInv(CInv &inv, const int minProtoVersion, bool fAllowMasternodeConnections) {
LOCK(cs_vNodes);
for (const auto& pnode : vNodes)
if(pnode->nVersion >= minProtoVersion)
pnode->PushInventory(inv);
for (const auto& pnode : vNodes) {
if (pnode->nVersion < minProtoVersion || (pnode->fMasternode && !fAllowMasternodeConnections))
continue;
pnode->PushInventory(inv);
}
}

void CConnman::RelayInvFiltered(CInv &inv, const CTransaction& relatedTx, const int minProtoVersion)
void CConnman::RelayInvFiltered(CInv &inv, const CTransaction& relatedTx, const int minProtoVersion, bool fAllowMasternodeConnections)
{
LOCK(cs_vNodes);
for (const auto& pnode : vNodes) {
if(pnode->nVersion < minProtoVersion)
if (pnode->nVersion < minProtoVersion || (pnode->fMasternode && !fAllowMasternodeConnections))
continue;
{
LOCK(pnode->cs_filter);
Expand All @@ -2970,11 +2975,12 @@ void CConnman::RelayInvFiltered(CInv &inv, const CTransaction& relatedTx, const
}
}

void CConnman::RelayInvFiltered(CInv &inv, const uint256& relatedTxHash, const int minProtoVersion)
void CConnman::RelayInvFiltered(CInv &inv, const uint256& relatedTxHash, const int minProtoVersion, bool fAllowMasternodeConnections)
{
LOCK(cs_vNodes);
for (const auto& pnode : vNodes) {
if(pnode->nVersion < minProtoVersion) continue;
if (pnode->nVersion < minProtoVersion || (pnode->fMasternode && !fAllowMasternodeConnections))
continue;
{
LOCK(pnode->cs_filter);
if(pnode->pfilter && !pnode->pfilter->contains(relatedTxHash)) continue;
Expand Down
7 changes: 4 additions & 3 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ class CConnman
void ReleaseNodeVector(const std::vector<CNode*>& vecNodes);

void RelayTransaction(const CTransaction& tx);
void RelayInv(CInv &inv, const int minProtoVersion = MIN_PEER_PROTO_VERSION);
void RelayInvFiltered(CInv &inv, const CTransaction &relatedTx, const int minProtoVersion = MIN_PEER_PROTO_VERSION);
void RelayInv(CInv &inv, const int minProtoVersion = MIN_PEER_PROTO_VERSION, bool fAllowMasternodeConnections = false);
void RelayInvFiltered(CInv &inv, const CTransaction &relatedTx, const int minProtoVersion = MIN_PEER_PROTO_VERSION, bool fAllowMasternodeConnections = false);
// This overload will not update node filters, so use it only for the cases when other messages will update related transaction data in filters
void RelayInvFiltered(CInv &inv, const uint256 &relatedTxHash, const int minProtoVersion = MIN_PEER_PROTO_VERSION);
void RelayInvFiltered(CInv &inv, const uint256 &relatedTxHash, const int minProtoVersion = MIN_PEER_PROTO_VERSION, bool fAllowMasternodeConnections = false);
void RemoveAskFor(const uint256& hash);

// Addrman functions
Expand Down Expand Up @@ -707,6 +707,7 @@ class CNodeStats
CAddress addrBind;
// In case this is a verified MN, this value is the proTx of the MN
uint256 verifiedProRegTxHash;
bool fMasternode;
};


Expand Down
24 changes: 21 additions & 3 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ void PushNodeVersion(CNode *pnode, CConnman* connman, int64_t nTime)
}

connman->PushMessage(pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::VERSION, PROTOCOL_VERSION, (uint64_t)nLocalNodeServices, nTime, addrYou, addrMe,
nonce, strSubVersion, nNodeStartingHeight, ::fRelayTxes, mnauthChallenge));
nonce, strSubVersion, nNodeStartingHeight, ::fRelayTxes, mnauthChallenge, pnode->fMasternode));

if (fLogIPs) {
LogPrint(BCLog::NET, "send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", PROTOCOL_VERSION, nNodeStartingHeight, addrMe.ToString(), addrYou.ToString(), nodeid);
Expand Down Expand Up @@ -955,6 +955,7 @@ void PeerLogicValidation::UpdatedBlockTip(const CBlockIndex *pindexNew, const CB
}
// Relay inventory, but don't relay old inventory during initial block download.
connman->ForEachNode([nNewHeight, &vHashes](CNode* pnode) {
if (pnode->fMasternode) return;
if (nNewHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 0)) {
for (const uint256& hash : reverse_iterate(vHashes)) {
pnode->PushBlockHash(hash);
Expand Down Expand Up @@ -1870,6 +1871,21 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
LOCK(pfrom->cs_mnauth);
vRecv >> pfrom->receivedMNAuthChallenge;
}
if (!vRecv.empty()) {
bool fOtherMasternode = false;
vRecv >> fOtherMasternode;
if (pfrom->fInbound) {
pfrom->fMasternode = fOtherMasternode;
if (fOtherMasternode) {
LogPrint(BCLog::NET, "peer=%d is an inbound masternode connection, not relaying anything to it\n", pfrom->GetId());
if (!fMasternodeMode) {
LogPrint(BCLog::NET, "but we're not a masternode, disconnecting\n");
pfrom->fDisconnect = true;
return true;
}
}
}
}
// Disconnect if we connected to ourself
if (pfrom->fInbound && !connman->CheckIncomingNonce(nNonce))
{
Expand Down Expand Up @@ -2309,7 +2325,9 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
LogPrint(BCLog::NET, " getblocks stopping, pruned or too old block at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
break;
}
pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash()));
if (!pfrom->fMasternode) {
pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash()));
}
if (--nLimit <= 0)
{
// When this block is requested, we'll send an inv that'll
Expand Down Expand Up @@ -3606,7 +3624,7 @@ bool PeerLogicValidation::SendMessages(CNode* pto, std::atomic<bool>& interruptM
if (pindexBestHeader == nullptr)
pindexBestHeader = chainActive.Tip();
bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do.
if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) {
if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex && !pto->fMasternode) {
// Only actively request headers from a single peer, unless we're close to end of initial download.
if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - nMaxTipAge) {
state.fSyncStarted = true;
Expand Down
2 changes: 2 additions & 0 deletions src/rpc/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request)
" \"subver\": \"/Dash Core:x.x.x/\", (string) The string version\n"
" \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n"
" \"addnode\": true|false, (boolean) Whether connection was due to addnode/-connect or if it was an automatic/inbound connection\n"
" \"masternode\": true|false, (boolean) Whether connection was due to masternode connection attempt\n"
" \"startingheight\": n, (numeric) The starting height (block) of the peer\n"
" \"banscore\": n, (numeric) The ban score\n"
" \"synced_headers\": n, (numeric) The last header we have in common with this peer\n"
Expand Down Expand Up @@ -164,6 +165,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request)
obj.push_back(Pair("subver", stats.cleanSubVer));
obj.push_back(Pair("inbound", stats.fInbound));
obj.push_back(Pair("addnode", stats.m_manual_connection));
obj.push_back(Pair("masternode", stats.fMasternode));
obj.push_back(Pair("startingheight", stats.nStartingHeight));
if (fStateStats) {
obj.push_back(Pair("banscore", statestats.nMisbehavior));
Expand Down
7 changes: 7 additions & 0 deletions test/functional/llmq-chainlocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ def set_test_params(self):

def run_test(self):

# Connect all nodes to node1 so that we always have the whole network connected
# Otherwise only masternode connections will be established between nodes, which won't propagate TXs/blocks
# Usually node0 is the one that does this, but in this test we isolate it multiple times
for i in range(len(self.nodes)):
if i != 1:
connect_nodes(self.nodes[i], 1)

self.log.info("Wait for dip0008 activation")

while self.nodes[0].getblockchaininfo()["bip9_softforks"]["dip0008"]["status"] != "active":
Expand Down