Skip to content

Commit e053c8b

Browse files
Merge dashpay#6626: refactor: reduce references to masternode service, cleanup index code, consolidate ProTx versioning and make it friendlier to upgrades
86bec48 refactor: rearrange checks in ProTx RPC wrapper to bail out faster (Kittywhiskers Van Gogh) 14b7cf3 refactor: rename CPro*Tx::GetVersion() to GetMaxVersion(), increase use (Kittywhiskers Van Gogh) 714fb3a refactor: consolidate ProTx versioning, make logic friendly to upgrades (Kittywhiskers Van Gogh) 2f9d65d refactor: cleanup index code, style updates, deduplication (Kittywhiskers Van Gogh) eaca912 refactor: defer resolving masternode service in CoinJoin code (Kittywhiskers Van Gogh) e722272 chore: use ProTx hash to identify masternodes in logs when possible (Kittywhiskers Van Gogh) Pull request description: ## Additional Information * Dependency for dashpay#6627 * As [dash#6627](dashpay#6627) aims to abstract away masternode network information (so far stored as a `CService`) behind an interface in preparation for supporting multiple addresses of different types, it still needs to be exposed to networking logic that actively relies on the "primary" address (i.e. the address used by masternodes to connect to each other). This is done through `MnNetInfo::GetPrimary()`. To reduce the `GetPrimary()` invocations needed to a minimum in [dash#6627](dashpay#6627), debug log messages have been changed to identify masternodes using the ProTx hash instead of the primary address and `CPendingDsaRequest` has been refactored to delay resolving the primary address, tracking the ProTx hash instead. * Currently, valid versions of `CPro*Tx` are expressed as `CPro*Tx::*_VERSION`. This isn't necessary as the `*_VERSION` (currently `{BASIC,LEGACY}_BLS_VERSION`) are the same for all `CPro*Tx`es, so they have been consolidated into a namespaced enum `ProTxVersion`. * Additionally, some checks in the codebase assume that are only two versions ([source](https://github.com/dashpay/dash/blob/bcd14b05cec7d94986f114ca17bbdadbee701d9b/src/evo/providertx.cpp#L20), [source](https://github.com/dashpay/dash/blob/bcd14b05cec7d94986f114ca17bbdadbee701d9b/src/evo/providertx.h#L150)), which isn't conducive to adding new versions. Those checks have been modified to allow higher versions. * `CPro*Tx::GetVersion()` has been renamed to `CPro*Tx::GetMaxVersion()` as its actually used to check what is the highest _allowed_ version given a set of consensus rules. `GetMaxVersion()` has not been consolidated like `ProTxVersion` as any changes to `addr` (as intended in [dash#6627](dashpay#6627)) would only affect `CProRegTx` and `CProUpServTx` (i.e. the remaining ProTx transactions would not be getting a version upgrade). * In later PRs, the change to a multiple-address capable implementation is hidden away using a `shared_ptr` to the interface class. To decide _what_ implementation to use, we need to set the version of `CPro*Tx`, as early as possible so that the version can be used to determine the applicable implementation. This is easy enough to do in serialization code but requires additional care when constructing a `CPro*Tx` in-place as it will be initialized with an empty `shared_ptr` and the applicable implementation needs to be explicitly set. To avoid problems in those later PRs, some instances of `CPro*Tx` construction have been reshuffled to set `nVersion` as early as possible. ## Breaking Changes None expected. ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)** - [x] I have added or updated relevant unit/integration/functional/e2e tests **(note: N/A)** - [x] I have made corresponding changes to the documentation **(note: N/A)** - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK 86bec48 knst: utACK 86bec48 Tree-SHA512: 3439ea4c51bed09b6147bb0bc26580cbb960ba1856855827d1db01e5303d6d9dce654e87b2982794aa6349a560e73b4b3fd99ca3bb7402e1b95f24a852657ffb
2 parents 272c951 + 86bec48 commit e053c8b

17 files changed

+164
-210
lines changed

src/coinjoin/client.cpp

Lines changed: 35 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,9 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CConnm
106106
// if the queue is ready, submit if we can
107107
if (dsq.fReady &&
108108
m_walletman.ForAnyCJClientMan([this, &connman, &dmn](std::unique_ptr<CCoinJoinClientManager>& clientman) {
109-
return clientman->TrySubmitDenominate(dmn->pdmnState->addr, connman);
109+
return clientman->TrySubmitDenominate(dmn->proTxHash, connman);
110110
})) {
111-
LogPrint(BCLog::COINJOIN, "DSQUEUE -- CoinJoin queue (%s) is ready on masternode %s\n", dsq.ToString(),
112-
dmn->pdmnState->addr.ToStringAddrPort());
111+
LogPrint(BCLog::COINJOIN, "DSQUEUE -- CoinJoin queue is ready, masternode=%s, queue=%s\n", dmn->proTxHash.ToString(), dsq.ToString());
113112
return {};
114113
} else {
115114
int64_t nLastDsq = m_mn_metaman.GetMetaInfo(dmn->proTxHash)->GetLastDsq();
@@ -125,8 +124,7 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CConnm
125124

126125
m_mn_metaman.AllowMixing(dmn->proTxHash);
127126

128-
LogPrint(BCLog::COINJOIN, "DSQUEUE -- new CoinJoin queue (%s) from masternode %s\n", dsq.ToString(),
129-
dmn->pdmnState->addr.ToStringAddrPort());
127+
LogPrint(BCLog::COINJOIN, "DSQUEUE -- new CoinJoin queue, masternode=%s, queue=%s\n", dmn->proTxHash.ToString(), dsq.ToString());
130128

131129
m_walletman.ForAnyCJClientMan([&dsq](const std::unique_ptr<CCoinJoinClientManager>& clientman) {
132130
return clientman->MarkAlreadyJoinedQueueAsTried(dsq);
@@ -186,23 +184,15 @@ void CCoinJoinClientSession::ProcessMessage(CNode& peer, CChainState& active_cha
186184
if (!CCoinJoinClientOptions::IsEnabled()) return;
187185
if (!m_mn_sync.IsBlockchainSynced()) return;
188186

189-
if (msg_type == NetMsgType::DSSTATUSUPDATE) {
190-
if (!mixingMasternode) return;
191-
if (mixingMasternode->pdmnState->addr != peer.addr) {
192-
return;
193-
}
187+
if (!mixingMasternode) return;
188+
if (mixingMasternode->pdmnState->addr != peer.addr) return;
194189

190+
if (msg_type == NetMsgType::DSSTATUSUPDATE) {
195191
CCoinJoinStatusUpdate psssup;
196192
vRecv >> psssup;
197193

198194
ProcessPoolStateUpdate(psssup);
199-
200195
} else if (msg_type == NetMsgType::DSFINALTX) {
201-
if (!mixingMasternode) return;
202-
if (mixingMasternode->pdmnState->addr != peer.addr) {
203-
return;
204-
}
205-
206196
int nMsgSessionID;
207197
vRecv >> nMsgSessionID;
208198
CTransaction txNew(deserialize, vRecv);
@@ -216,15 +206,7 @@ void CCoinJoinClientSession::ProcessMessage(CNode& peer, CChainState& active_cha
216206

217207
// check to see if input is spent already? (and probably not confirmed)
218208
SignFinalTransaction(peer, active_chainstate, connman, mempool, txNew);
219-
220209
} else if (msg_type == NetMsgType::DSCOMPLETE) {
221-
if (!mixingMasternode) return;
222-
if (mixingMasternode->pdmnState->addr != peer.addr) {
223-
WalletCJLogPrint(m_wallet, "DSCOMPLETE -- message doesn't match current Masternode: infoMixingMasternode=%s addr=%s\n",
224-
mixingMasternode->pdmnState->addr.ToStringAddrPort(), peer.addr.ToStringAddrPort());
225-
return;
226-
}
227-
228210
int nMsgSessionID;
229211
PoolMessage nMsgMessageID;
230212
vRecv >> nMsgSessionID >> nMsgMessageID;
@@ -1126,22 +1108,19 @@ bool CCoinJoinClientSession::JoinExistingQueue(CAmount nBalanceNeedsAnonymized,
11261108

11271109
if (connman.IsMasternodeOrDisconnectRequested(dmn->pdmnState->addr)) {
11281110
WalletCJLogPrint(m_wallet, /* Continued */
1129-
"CCoinJoinClientSession::JoinExistingQueue -- skipping masternode connection, addr=%s\n",
1130-
dmn->pdmnState->addr.ToStringAddrPort());
1111+
"CCoinJoinClientSession::JoinExistingQueue -- skipping connection, masternode=%s\n", dmn->proTxHash.ToString());
11311112
continue;
11321113
}
11331114

11341115
nSessionDenom = dsq.nDenom;
11351116
mixingMasternode = dmn;
1136-
pendingDsaRequest = CPendingDsaRequest(dmn->pdmnState->addr, CCoinJoinAccept(nSessionDenom, txMyCollateral));
1117+
pendingDsaRequest = CPendingDsaRequest(dmn->proTxHash, CCoinJoinAccept(nSessionDenom, txMyCollateral));
11371118
connman.AddPendingMasternode(dmn->proTxHash);
11381119
SetState(POOL_STATE_QUEUE);
11391120
nTimeLastSuccessfulStep = GetTime();
11401121
WalletCJLogPrint(m_wallet, /* Continued */
1141-
"CCoinJoinClientSession::JoinExistingQueue -- pending connection (from queue): nSessionDenom: "
1142-
"%d (%s), addr=%s\n",
1143-
nSessionDenom, CoinJoin::DenominationToString(nSessionDenom),
1144-
dmn->pdmnState->addr.ToStringAddrPort());
1122+
"CCoinJoinClientSession::JoinExistingQueue -- pending connection, masternode=%s, nSessionDenom=%d (%s)\n",
1123+
dmn->proTxHash.ToString(), nSessionDenom, CoinJoin::DenominationToString(nSessionDenom));
11451124
strAutoDenomResult = _("Trying to connect…");
11461125
return true;
11471126
}
@@ -1192,23 +1171,22 @@ bool CCoinJoinClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, CCon
11921171
int64_t nDsqThreshold = m_mn_metaman.GetDsqThreshold(dmn->proTxHash, nMnCount);
11931172
if (nLastDsq != 0 && nDsqThreshold > m_mn_metaman.GetDsqCount()) {
11941173
WalletCJLogPrint(m_wallet, /* Continued */
1195-
"CCoinJoinClientSession::StartNewQueue -- Too early to mix on this masternode!" /* Continued */
1196-
" masternode=%s addr=%s nLastDsq=%d nDsqThreshold=%d nDsqCount=%d\n",
1197-
dmn->proTxHash.ToString(), dmn->pdmnState->addr.ToStringAddrPort(), nLastDsq,
1198-
nDsqThreshold, m_mn_metaman.GetDsqCount());
1174+
"CCoinJoinClientSession::StartNewQueue -- too early to mix with node," /* Continued */
1175+
" masternode=%s, nLastDsq=%d, nDsqThreshold=%d, nDsqCount=%d\n",
1176+
dmn->proTxHash.ToString(), nLastDsq, nDsqThreshold, m_mn_metaman.GetDsqCount());
11991177
nTries++;
12001178
continue;
12011179
}
12021180

12031181
if (connman.IsMasternodeOrDisconnectRequested(dmn->pdmnState->addr)) {
1204-
WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::StartNewQueue -- skipping masternode connection, addr=%s\n",
1205-
dmn->pdmnState->addr.ToStringAddrPort());
1182+
WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::StartNewQueue -- skipping connection, masternode=%s\n",
1183+
dmn->proTxHash.ToString());
12061184
nTries++;
12071185
continue;
12081186
}
12091187

1210-
WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::StartNewQueue -- attempt %d connection to Masternode %s\n",
1211-
nTries, dmn->pdmnState->addr.ToStringAddrPort());
1188+
WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::StartNewQueue -- attempting connection, masternode=%s, tries=%s\n",
1189+
dmn->proTxHash.ToString(), nTries);
12121190

12131191
// try to get a single random denom out of setAmounts
12141192
while (nSessionDenom == 0) {
@@ -1221,12 +1199,12 @@ bool CCoinJoinClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, CCon
12211199

12221200
mixingMasternode = dmn;
12231201
connman.AddPendingMasternode(dmn->proTxHash);
1224-
pendingDsaRequest = CPendingDsaRequest(dmn->pdmnState->addr, CCoinJoinAccept(nSessionDenom, txMyCollateral));
1202+
pendingDsaRequest = CPendingDsaRequest(dmn->proTxHash, CCoinJoinAccept(nSessionDenom, txMyCollateral));
12251203
SetState(POOL_STATE_QUEUE);
12261204
nTimeLastSuccessfulStep = GetTime();
12271205
WalletCJLogPrint( /* Continued */
1228-
m_wallet, "CCoinJoinClientSession::StartNewQueue -- pending connection, nSessionDenom: %d (%s), addr=%s\n",
1229-
nSessionDenom, CoinJoin::DenominationToString(nSessionDenom), dmn->pdmnState->addr.ToStringAddrPort());
1206+
m_wallet, "CCoinJoinClientSession::StartNewQueue -- pending connection, masternode=%s, nSessionDenom=%d (%s)\n",
1207+
dmn->proTxHash.ToString(), nSessionDenom, CoinJoin::DenominationToString(nSessionDenom));
12301208
strAutoDenomResult = _("Trying to connect…");
12311209
return true;
12321210
}
@@ -1238,7 +1216,17 @@ bool CCoinJoinClientSession::ProcessPendingDsaRequest(CConnman& connman)
12381216
{
12391217
if (!pendingDsaRequest) return false;
12401218

1241-
bool fDone = connman.ForNode(pendingDsaRequest.GetAddr(), [this, &connman](CNode* pnode) {
1219+
CService mn_addr;
1220+
if (auto dmn = m_dmnman.GetListAtChainTip().GetMN(pendingDsaRequest.GetProTxHash())) {
1221+
mn_addr = Assert(dmn->pdmnState)->addr;
1222+
} else {
1223+
WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::%s -- cannot find address to connect, masternode=%s\n", __func__,
1224+
pendingDsaRequest.GetProTxHash().ToString());
1225+
WITH_LOCK(cs_coinjoin, SetNull());
1226+
return false;
1227+
}
1228+
1229+
bool fDone = connman.ForNode(mn_addr, [this, &connman](CNode* pnode) {
12421230
WalletCJLogPrint(m_wallet, "-- processing dsa queue for addr=%s\n", pnode->addr.ToStringAddrPort());
12431231
nTimeLastSuccessfulStep = GetTime();
12441232
CNetMsgMaker msgMaker(pnode->GetCommonVersion());
@@ -1249,8 +1237,8 @@ bool CCoinJoinClientSession::ProcessPendingDsaRequest(CConnman& connman)
12491237
if (fDone) {
12501238
pendingDsaRequest = CPendingDsaRequest();
12511239
} else if (pendingDsaRequest.IsExpired()) {
1252-
WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::%s -- failed to connect to %s\n", __func__,
1253-
pendingDsaRequest.GetAddr().ToStringAddrPort());
1240+
WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::%s -- failed to connect, masternode=%s\n", __func__,
1241+
pendingDsaRequest.GetProTxHash().ToString());
12541242
WITH_LOCK(cs_coinjoin, SetNull());
12551243
}
12561244

@@ -1268,13 +1256,13 @@ void CCoinJoinClientManager::ProcessPendingDsaRequest(CConnman& connman)
12681256
}
12691257
}
12701258

1271-
bool CCoinJoinClientManager::TrySubmitDenominate(const CService& mnAddr, CConnman& connman)
1259+
bool CCoinJoinClientManager::TrySubmitDenominate(const uint256& proTxHash, CConnman& connman)
12721260
{
12731261
AssertLockNotHeld(cs_deqsessions);
12741262
LOCK(cs_deqsessions);
12751263
for (auto& session : deqSessions) {
12761264
CDeterministicMNCPtr mnMixing;
1277-
if (session.GetMixingMasternodeInfo(mnMixing) && mnMixing->pdmnState->addr == mnAddr && session.GetState() == POOL_STATE_QUEUE) {
1265+
if (session.GetMixingMasternodeInfo(mnMixing) && mnMixing->proTxHash == proTxHash && session.GetState() == POOL_STATE_QUEUE) {
12781266
session.SubmitDenominate(connman);
12791267
return true;
12801268
}

src/coinjoin/client.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,27 @@ class CPendingDsaRequest
3939
private:
4040
static constexpr int TIMEOUT = 15;
4141

42-
CService addr;
42+
uint256 proTxHash;
4343
CCoinJoinAccept dsa;
4444
int64_t nTimeCreated{0};
4545

4646
public:
4747
CPendingDsaRequest() = default;
4848

49-
CPendingDsaRequest(CService addr_, CCoinJoinAccept dsa_) :
50-
addr(std::move(addr_)),
49+
CPendingDsaRequest(uint256 proTxHash_, CCoinJoinAccept dsa_) :
50+
proTxHash(std::move(proTxHash_)),
5151
dsa(std::move(dsa_)),
5252
nTimeCreated(GetTime())
5353
{
5454
}
5555

56-
[[nodiscard]] CService GetAddr() const { return addr; }
56+
[[nodiscard]] uint256 GetProTxHash() const { return proTxHash; }
5757
[[nodiscard]] CCoinJoinAccept GetDSA() const { return dsa; }
5858
[[nodiscard]] bool IsExpired() const { return GetTime() - nTimeCreated > TIMEOUT; }
5959

6060
friend bool operator==(const CPendingDsaRequest& a, const CPendingDsaRequest& b)
6161
{
62-
return a.addr == b.addr && a.dsa == b.dsa;
62+
return a.proTxHash == b.proTxHash && a.dsa == b.dsa;
6363
}
6464
friend bool operator!=(const CPendingDsaRequest& a, const CPendingDsaRequest& b)
6565
{
@@ -336,7 +336,7 @@ class CCoinJoinClientManager
336336
bool DoAutomaticDenominating(ChainstateManager& chainman, CConnman& connman, const CTxMemPool& mempool,
337337
bool fDryRun = false) EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
338338

339-
bool TrySubmitDenominate(const CService& mnAddr, CConnman& connman) EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
339+
bool TrySubmitDenominate(const uint256& proTxHash, CConnman& connman) EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
340340
bool MarkAlreadyJoinedQueueAsTried(CCoinJoinQueue& dsq) const EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
341341

342342
void CheckTimeout() EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);

src/coinjoin/server.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,12 @@ PeerMsgRet CCoinJoinServer::ProcessDSQUEUE(const CNode& peer, CDataStream& vRecv
174174
LogPrint(BCLog::COINJOIN, "DSQUEUE -- nLastDsq: %d nDsqThreshold: %d nDsqCount: %d\n", nLastDsq, nDsqThreshold, m_mn_metaman.GetDsqCount());
175175
//don't allow a few nodes to dominate the queuing process
176176
if (nLastDsq != 0 && nDsqThreshold > m_mn_metaman.GetDsqCount()) {
177-
LogPrint(BCLog::COINJOIN, "DSQUEUE -- Masternode %s is sending too many dsq messages\n",
178-
dmn->pdmnState->addr.ToStringAddrPort());
177+
LogPrint(BCLog::COINJOIN, "DSQUEUE -- node sending too many dsq messages, masternode=%s\n", dmn->proTxHash.ToString());
179178
return {};
180179
}
181180
m_mn_metaman.AllowMixing(dmn->proTxHash);
182181

183-
LogPrint(BCLog::COINJOIN, "DSQUEUE -- new CoinJoin queue (%s) from masternode %s\n", dsq.ToString(),
184-
dmn->pdmnState->addr.ToStringAddrPort());
182+
LogPrint(BCLog::COINJOIN, "DSQUEUE -- new CoinJoin queue, masternode=%s, queue=%s\n", dmn->proTxHash.ToString(), dsq.ToString());
185183

186184
TRY_LOCK(cs_vecqueue, lockRecv);
187185
if (!lockRecv) return {};

src/evo/dmnstate.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class CDeterministicMNState
3333
friend class CDeterministicMNStateDiff;
3434

3535
public:
36-
int nVersion{CProRegTx::LEGACY_BLS_VERSION};
36+
int nVersion{ProTxVersion::LegacyBLS};
3737

3838
int nRegisteredHeight{-1};
3939
int nLastPaidHeight{0};
@@ -94,7 +94,7 @@ class CDeterministicMNState
9494
obj.confirmedHash,
9595
obj.confirmedHashWithProRegTxHash,
9696
obj.keyIDOwner);
97-
READWRITE(CBLSLazyPublicKeyVersionWrapper(const_cast<CBLSLazyPublicKey&>(obj.pubKeyOperator), obj.nVersion == CProRegTx::LEGACY_BLS_VERSION));
97+
READWRITE(CBLSLazyPublicKeyVersionWrapper(const_cast<CBLSLazyPublicKey&>(obj.pubKeyOperator), obj.nVersion == ProTxVersion::LegacyBLS));
9898
READWRITE(
9999
obj.keyIDVoting,
100100
obj.addr,
@@ -107,7 +107,7 @@ class CDeterministicMNState
107107

108108
void ResetOperatorFields()
109109
{
110-
nVersion = CProRegTx::LEGACY_BLS_VERSION;
110+
nVersion = ProTxVersion::LegacyBLS;
111111
pubKeyOperator = CBLSLazyPublicKey();
112112
addr = CService();
113113
scriptOperatorPayout = CScript();
@@ -219,14 +219,14 @@ class CDeterministicMNStateDiff
219219
#define DMN_STATE_DIFF_LINE(f) \
220220
if (strcmp(#f, "pubKeyOperator") == 0 && (obj.fields & Field_pubKeyOperator)) {\
221221
SER_READ(obj, read_pubkey = true); \
222-
READWRITE(CBLSLazyPublicKeyVersionWrapper(const_cast<CBLSLazyPublicKey&>(obj.state.pubKeyOperator), obj.state.nVersion == CProRegTx::LEGACY_BLS_VERSION)); \
222+
READWRITE(CBLSLazyPublicKeyVersionWrapper(const_cast<CBLSLazyPublicKey&>(obj.state.pubKeyOperator), obj.state.nVersion == ProTxVersion::LegacyBLS)); \
223223
} else if (obj.fields & Field_##f) READWRITE(obj.state.f);
224224

225225
DMN_STATE_DIFF_ALL_FIELDS
226226
#undef DMN_STATE_DIFF_LINE
227227
if (read_pubkey) {
228228
SER_READ(obj, obj.fields |= Field_nVersion);
229-
SER_READ(obj, obj.state.pubKeyOperator.SetLegacy(obj.state.nVersion == CProRegTx::LEGACY_BLS_VERSION));
229+
SER_READ(obj, obj.state.pubKeyOperator.SetLegacy(obj.state.nVersion == ProTxVersion::LegacyBLS));
230230
}
231231
}
232232

src/evo/providertx.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
bool CProRegTx::IsTriviallyValid(bool is_basic_scheme_active, TxValidationState& state) const
1616
{
17-
if (nVersion == 0 || nVersion > GetVersion(is_basic_scheme_active)) {
17+
if (nVersion == 0 || nVersion > GetMaxVersion(is_basic_scheme_active)) {
1818
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-version");
1919
}
20-
if (nVersion != BASIC_BLS_VERSION && nType == MnType::Evo) {
20+
if (nVersion < ProTxVersion::BasicBLS && nType == MnType::Evo) {
2121
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-evo-version");
2222
}
2323
if (!IsValidMnType(nType)) {
@@ -30,7 +30,7 @@ bool CProRegTx::IsTriviallyValid(bool is_basic_scheme_active, TxValidationState&
3030
if (keyIDOwner.IsNull() || !pubKeyOperator.Get().IsValid() || keyIDVoting.IsNull()) {
3131
return state.Invalid(TxValidationResult::TX_BAD_SPECIAL, "bad-protx-key-null");
3232
}
33-
if (pubKeyOperator.IsLegacy() != (nVersion == LEGACY_BLS_VERSION)) {
33+
if (pubKeyOperator.IsLegacy() != (nVersion == ProTxVersion::LegacyBLS)) {
3434
return state.Invalid(TxValidationResult::TX_BAD_SPECIAL, "bad-protx-operator-pubkey");
3535
}
3636
if (!scriptPayout.IsPayToPublicKeyHash() && !scriptPayout.IsPayToScriptHash()) {
@@ -98,10 +98,10 @@ std::string CProRegTx::ToString() const
9898

9999
bool CProUpServTx::IsTriviallyValid(bool is_basic_scheme_active, TxValidationState& state) const
100100
{
101-
if (nVersion == 0 || nVersion > GetVersion(is_basic_scheme_active)) {
101+
if (nVersion == 0 || nVersion > GetMaxVersion(is_basic_scheme_active)) {
102102
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-version");
103103
}
104-
if (nVersion != BASIC_BLS_VERSION && nType == MnType::Evo) {
104+
if (nVersion < ProTxVersion::BasicBLS && nType == MnType::Evo) {
105105
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-evo-version");
106106
}
107107

@@ -124,7 +124,7 @@ std::string CProUpServTx::ToString() const
124124

125125
bool CProUpRegTx::IsTriviallyValid(bool is_basic_scheme_active, TxValidationState& state) const
126126
{
127-
if (nVersion == 0 || nVersion > GetVersion(is_basic_scheme_active)) {
127+
if (nVersion == 0 || nVersion > GetMaxVersion(is_basic_scheme_active)) {
128128
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-version");
129129
}
130130
if (nMode != 0) {
@@ -134,7 +134,7 @@ bool CProUpRegTx::IsTriviallyValid(bool is_basic_scheme_active, TxValidationStat
134134
if (!pubKeyOperator.Get().IsValid() || keyIDVoting.IsNull()) {
135135
return state.Invalid(TxValidationResult::TX_BAD_SPECIAL, "bad-protx-key-null");
136136
}
137-
if (pubKeyOperator.IsLegacy() != (nVersion == LEGACY_BLS_VERSION)) {
137+
if (pubKeyOperator.IsLegacy() != (nVersion == ProTxVersion::LegacyBLS)) {
138138
return state.Invalid(TxValidationResult::TX_BAD_SPECIAL, "bad-protx-operator-pubkey");
139139
}
140140
if (!scriptPayout.IsPayToPublicKeyHash() && !scriptPayout.IsPayToScriptHash()) {
@@ -157,7 +157,7 @@ std::string CProUpRegTx::ToString() const
157157

158158
bool CProUpRevTx::IsTriviallyValid(bool is_basic_scheme_active, TxValidationState& state) const
159159
{
160-
if (nVersion == 0 || nVersion > GetVersion(is_basic_scheme_active)) {
160+
if (nVersion == 0 || nVersion > GetMaxVersion(is_basic_scheme_active)) {
161161
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-version");
162162
}
163163

0 commit comments

Comments
 (0)