Skip to content

Commit 67683f3

Browse files
Merge #7293: fix: keep sending ISDLOCK invs to non-MN peers with watchquorums
f6bb02d fix: keep sending ISDLOCK invs to non-MN peers that want recsigs (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented PR #6994 made masternodes skip ISDLOCK inv announcements to any peer with m_wants_recsigs set, on the premise that such peers can reconstruct the ISLOCK from the recsig. It works for MN peers but it does not work for quorum observers running with -watchquorums: those nodes also opt in to recsigs via QSENDRECSIGS but they don't have a signer worker running, so they cannot reconstruct an ISDLOCK from a recsig and they still need the inv. nodes[0] runs with -watchquorums and had progressively sent QSENDRECSIGS to all four MN peers; by the third call every MN saw nodes[0].m_wants_recsigs=true and skipped the inv to it. ## What was done? The ISDLOCK is skipped now only on the peer being verified masternode. Move the policy from PushInv (called for every inv type) to the three sites that actually relay MSG_ISDLOCK and have CNode in scope. ## How Has This Been Tested? Run functional test interface_dash_zmq.py multiple times. This PR drops failure rate from 50% to 0. ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone ACKs for top commit: PastaPastaPasta: utACK f6bb02d Tree-SHA512: 14be2cfaad6dd0cb359bedca9e65e176b3d52de109f1c9e606892ee284f8079860d01117d538efb19bcf695e5da0cae747f08dcb98c209624ca28d6cf7d1e34d
2 parents 2cc3836 + f6bb02d commit 67683f3

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

src/net_processing.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,16 @@ static uint16_t GetHeadersLimit(const CNode& pfrom, bool compressed)
11931193
return MAX_HEADERS_UNCOMPRESSED_RESULT;
11941194
}
11951195

1196+
// Returns true when peer is a verified masternode that has opted in to receive recsigs.
1197+
// Such peers participate in the signing flow that populates creatingInstantSendLocks, so
1198+
// they can reconstruct an ISDLOCK locally from the recsig and don't need the ISDLOCK inv.
1199+
// Non-MN peers (e.g. nodes running with -watchquorums) also opt in to recsigs via
1200+
// QSENDRECSIGS but still need ISDLOCK invs because they don't run the signing flow.
1201+
static bool PeerReconstructsISLockFromRecsig(const CNode& pnode, const Peer& peer)
1202+
{
1203+
return peer.m_wants_recsigs && !pnode.GetVerifiedProRegTxHash().IsNull();
1204+
}
1205+
11961206
static void PushInv(Peer& peer, const CInv& inv)
11971207
{
11981208
auto inv_relay = peer.GetInvRelay();
@@ -1204,13 +1214,6 @@ static void PushInv(Peer& peer, const CInv& inv)
12041214
return;
12051215
}
12061216

1207-
// Skip ISDLOCK inv announcements for peers that want recsigs, as they can reconstruct
1208-
// the islock from the recsig
1209-
if (inv.type == MSG_ISDLOCK && peer.m_wants_recsigs) {
1210-
LogPrint(BCLog::NET, "%s -- skipping ISDLOCK inv (peer wants recsigs): %s peer=%d\n", __func__, inv.ToString(), peer.m_id);
1211-
return;
1212-
}
1213-
12141217
LOCK(inv_relay->m_tx_inventory_mutex);
12151218
if (inv_relay->m_tx_inventory_known_filter.contains(inv.hash)) {
12161219
LogPrint(BCLog::NET, "%s -- skipping known inv: %s peer=%d\n", __func__, inv.ToString(), peer.m_id);
@@ -2541,6 +2544,11 @@ void PeerManagerImpl::RelayInvFiltered(const CInv& inv, const CTransaction& rela
25412544
return;
25422545
}
25432546
} // LOCK(tx_relay->m_bloom_filter_mutex)
2547+
if (inv.type == MSG_ISDLOCK && PeerReconstructsISLockFromRecsig(*pnode, *peer)) {
2548+
LogPrint(BCLog::NET, "%s -- skipping ISDLOCK inv (peer wants recsigs): %s peer=%d\n",
2549+
__func__, inv.ToString(), peer->m_id);
2550+
return;
2551+
}
25442552
PushInv(*peer, inv);
25452553
});
25462554
}
@@ -2566,6 +2574,11 @@ void PeerManagerImpl::RelayInvFiltered(const CInv& inv, const uint256& relatedTx
25662574
return;
25672575
}
25682576
} // LOCK(tx_relay->m_bloom_filter_mutex)
2577+
if (inv.type == MSG_ISDLOCK && PeerReconstructsISLockFromRecsig(*pnode, *peer)) {
2578+
LogPrint(BCLog::NET, "%s -- skipping ISDLOCK inv (peer wants recsigs): %s peer=%d\n",
2579+
__func__, inv.ToString(), peer->m_id);
2580+
return;
2581+
}
25692582
PushInv(*peer, inv);
25702583
});
25712584
}
@@ -6348,9 +6361,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
63486361
if (islock == nullptr) continue;
63496362
uint256 isLockHash{::SerializeHash(*islock)};
63506363
tx_relay->m_tx_inventory_known_filter.insert(isLockHash);
6351-
// Skip ISDLOCK inv announcements for peers that want recsigs, as they can reconstruct
6352-
// the islock from the recsig
6353-
if (!peer->m_wants_recsigs) {
6364+
if (!PeerReconstructsISLockFromRecsig(*pto, *peer)) {
63546365
queueAndMaybePushInv(CInv(MSG_ISDLOCK, isLockHash));
63556366
}
63566367
}

0 commit comments

Comments
 (0)