Skip to content

Commit 480c893

Browse files
committed
feat: do not send any governance objects to old p2p clients
They can not accept governance objects with p2sh payment_address. To avoid inconsistency, do not send _any_ governance object to them.
1 parent 2148106 commit 480c893

File tree

2 files changed

+10
-27
lines changed

2 files changed

+10
-27
lines changed

src/governance/governance.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,12 @@ MessageProcessingResult CGovernanceManager::SyncObjects(CNode& peer, CConnman& c
984984
}
985985
m_netfulfilledman.AddFulfilledRequest(peer.addr, NetMsgType::MNGOVERNANCESYNC);
986986

987+
if (peer.nVersion < GOVSCRIPT_PROTO_VERSION) {
988+
LogPrintf("CGovernanceManager::%s -- peer=%d does not support p2sh govobj, skipping sync\n", __func__,
989+
peer.GetId());
990+
return {};
991+
}
992+
987993
// SYNC GOVERNANCE OBJECTS WITH OTHER CLIENT
988994

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

1008-
if (peer.nVersion < GOVSCRIPT_PROTO_VERSION && govobj.GetObjectType() == GovernanceObject::PROPOSAL) {
1009-
// We know this proposal is valid locally, otherwise we would not store it.
1010-
// But we don't want to relay it to pre-GOVSCRIPT_PROTO_VERSION peers if payment_address is p2sh
1011-
// because they won't accept it anyway and will simply ban us eventually.
1012-
CProposalValidator validator(govobj.GetDataAsHexString(), false /* no script */);
1013-
if (!validator.Validate(false /* ignore expiration */)) {
1014-
// The only way we could get here is when proposal is valid but payment_address is actually p2sh.
1015-
LogPrintf("CGovernanceManager::%s -- not syncing p2sh govobj to older node: %s, peer=%d\n", __func__,
1016-
strHash, peer.GetId());
1017-
continue;
1018-
}
1019-
}
1020-
10211014
// Push the inventory budget proposal message over to the other client
10221015
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s -- syncing govobj: %s, peer=%d\n", __func__, strHash, peer.GetId());
10231016
ret.m_inventory.emplace_back(MSG_GOVERNANCE_OBJECT, nHash);

src/governance/object.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -602,21 +602,11 @@ void CGovernanceObject::Relay(PeerManager& peerman, const CMasternodeSync& mn_sy
602602
return;
603603
}
604604

605-
int minProtoVersion = MIN_PEER_PROTO_VERSION;
606-
if (m_obj.type == GovernanceObject::PROPOSAL) {
607-
// We know this proposal is valid locally, otherwise we would not get to the point we should relay it.
608-
// But we don't want to relay it to pre-GOVSCRIPT_PROTO_VERSION peers if payment_address is p2sh
609-
// because they won't accept it anyway and will simply ban us eventually.
610-
CProposalValidator validator(GetDataAsHexString(), false /* no script */);
611-
if (!validator.Validate(false /* ignore expiration */)) {
612-
// The only way we could get here is when proposal is valid but payment_address is actually p2sh.
613-
LogPrint(BCLog::GOBJECT, "CGovernanceObject::Relay -- won't relay %s to older peers\n", GetHash().ToString());
614-
minProtoVersion = GOVSCRIPT_PROTO_VERSION;
615-
}
616-
}
617-
618605
CInv inv(MSG_GOVERNANCE_OBJECT, GetHash());
619-
peerman.RelayInv(inv, minProtoVersion);
606+
607+
// We don't want to relay it to pre-GOVSCRIPT_PROTO_VERSION peers to avoid inconsistency
608+
// because they won't accept p2sh payment_address anyway and will simply ban us eventually.
609+
peerman.RelayInv(inv, GOVSCRIPT_PROTO_VERSION);
620610
}
621611

622612
void CGovernanceObject::UpdateSentinelVariables(const CDeterministicMNList& tip_mn_list)

0 commit comments

Comments
 (0)