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
7 changes: 7 additions & 0 deletions qa/rpc-tests/sporks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]))
Expand Down Expand Up @@ -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()
Expand Down
16 changes: 12 additions & 4 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1793,16 +1793,24 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
MSG_MASTERNODE_PING,
MSG_MASTERNODE_VERIFY,
};
static std::set<int> 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
Expand Down