Skip to content
Closed
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
19 changes: 6 additions & 13 deletions src/governance/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,12 @@ MessageProcessingResult CGovernanceManager::SyncObjects(CNode& peer, CConnman& c
}
m_netfulfilledman.AddFulfilledRequest(peer.addr, NetMsgType::MNGOVERNANCESYNC);

if (peer.nVersion < GOVSCRIPT_PROTO_VERSION) {
LogPrintf("CGovernanceManager::%s -- peer=%d does not support p2sh govobj, skipping sync\n", __func__,
peer.GetId());
return {};
}

// SYNC GOVERNANCE OBJECTS WITH OTHER CLIENT

LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s -- syncing all objects to peer=%d\n", __func__, peer.GetId());
Expand All @@ -1005,19 +1011,6 @@ MessageProcessingResult CGovernanceManager::SyncObjects(CNode& peer, CConnman& c
continue;
}

if (peer.nVersion < GOVSCRIPT_PROTO_VERSION && govobj.GetObjectType() == GovernanceObject::PROPOSAL) {
// We know this proposal is valid locally, otherwise we would not store it.
// But we don't want to relay it to pre-GOVSCRIPT_PROTO_VERSION peers if payment_address is p2sh
// because they won't accept it anyway and will simply ban us eventually.
CProposalValidator validator(govobj.GetDataAsHexString(), false /* no script */);
if (!validator.Validate(false /* ignore expiration */)) {
// The only way we could get here is when proposal is valid but payment_address is actually p2sh.
LogPrintf("CGovernanceManager::%s -- not syncing p2sh govobj to older node: %s, peer=%d\n", __func__,
strHash, peer.GetId());
continue;
}
}

// Push the inventory budget proposal message over to the other client
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s -- syncing govobj: %s, peer=%d\n", __func__, strHash, peer.GetId());
ret.m_inventory.emplace_back(MSG_GOVERNANCE_OBJECT, nHash);
Expand Down
18 changes: 4 additions & 14 deletions src/governance/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,21 +602,11 @@ void CGovernanceObject::Relay(PeerManager& peerman, const CMasternodeSync& mn_sy
return;
}

int minProtoVersion = MIN_PEER_PROTO_VERSION;
if (m_obj.type == GovernanceObject::PROPOSAL) {
// We know this proposal is valid locally, otherwise we would not get to the point we should relay it.
// But we don't want to relay it to pre-GOVSCRIPT_PROTO_VERSION peers if payment_address is p2sh
// because they won't accept it anyway and will simply ban us eventually.
CProposalValidator validator(GetDataAsHexString(), false /* no script */);
if (!validator.Validate(false /* ignore expiration */)) {
// The only way we could get here is when proposal is valid but payment_address is actually p2sh.
LogPrint(BCLog::GOBJECT, "CGovernanceObject::Relay -- won't relay %s to older peers\n", GetHash().ToString());
minProtoVersion = GOVSCRIPT_PROTO_VERSION;
}
}

CInv inv(MSG_GOVERNANCE_OBJECT, GetHash());
peerman.RelayInv(inv, minProtoVersion);

// We don't want to relay it to pre-GOVSCRIPT_PROTO_VERSION peers to avoid inconsistency
// because they won't accept p2sh payment_address anyway and will simply ban us eventually.
peerman.RelayInv(inv, GOVSCRIPT_PROTO_VERSION);
}

void CGovernanceObject::UpdateSentinelVariables(const CDeterministicMNList& tip_mn_list)
Expand Down
Loading