diff --git a/qa/rpc-tests/sporks.py b/qa/rpc-tests/sporks.py index ceae32914d2f..f556468df08e 100755 --- a/qa/rpc-tests/sporks.py +++ b/qa/rpc-tests/sporks.py @@ -19,6 +19,7 @@ def __init__(self): self.is_network_split = False def setup_network(self): + disable_mocktime() self.nodes = [] self.nodes.append(start_node(0, self.options.tmpdir, ["-debug", "-sporkkey=cP4EKFyJsHT39LDqgdcB43Y3YXjNyjb5Fuas1GQSeAtjnZWmZEQK"])) @@ -69,6 +70,12 @@ def run_test(self): assert(not self.get_test_spork_state(self.nodes[0])) assert(not self.get_test_spork_state(self.nodes[1])) + # Force finish mnsync node as otherwise it will never send out headers to other peers + wait_to_sync(self.nodes[1], fast_mnsync=True) + + # Generate one block to kick off masternode sync, which also starts sporks syncing for node2 + self.nodes[1].generate(1) + # connect new node and check spork propagation after restoring from cache connect_nodes(self.nodes[1], 2) start = time() diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 71fc8e0b77f5..bc506e8da008 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1793,16 +1793,24 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr MSG_MASTERNODE_PING, MSG_MASTERNODE_VERIFY, }; + static std::set allowWhileInIBDObjs = { + MSG_SPORK + }; if (legacyMNObjs.count(inv.type) && deterministicMNManager->IsDeterministicMNsSporkActive()) { LogPrint("net", "ignoring (%s) inv of legacy type %d peer=%d\n", inv.hash.ToString(), inv.type, pfrom->id); continue; } pfrom->AddInventoryKnown(inv); - if (fBlocksOnly) - LogPrint("net", "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->id); - else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload()) - pfrom->AskFor(inv); + if (fBlocksOnly) { + LogPrint("net", "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), + pfrom->id); + } else if (!fAlreadyHave) { + bool allowWhileInIBD = allowWhileInIBDObjs.count(inv.type); + if (allowWhileInIBD || (!fImporting && !fReindex && !IsInitialBlockDownload())) { + pfrom->AskFor(inv); + } + } } // Track requests for our stuff