From c4f117566b3d5733d2fc2ffb3bc8a72d15d6aa43 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Thu, 5 Jun 2025 08:11:37 +0000 Subject: [PATCH 1/8] evo: cleanup CDeterministicMN{,List,ListDiff,StateDiff} ser logic Co-authored-by: Konstantin Akimov There isn't any code left to report `format_version`, making the specializations vestigial, so we can remove it. Done to avoid potential conflict with OverrideStream usage. --- src/evo/deterministicmns.h | 113 +++++++++++++++---------------------- src/evo/dmnstate.h | 8 +-- 2 files changed, 50 insertions(+), 71 deletions(-) diff --git a/src/evo/deterministicmns.h b/src/evo/deterministicmns.h index 5b0c246a0242..e3af150bba1f 100644 --- a/src/evo/deterministicmns.h +++ b/src/evo/deterministicmns.h @@ -62,47 +62,26 @@ class CDeterministicMN // only non-initial values assert(_internalId != std::numeric_limits::max()); } - template - CDeterministicMN(deserialize_type, Stream& s, const uint8_t format_version) - { - SerializationOp(s, CSerActionUnserialize(), format_version); - } + CDeterministicMN(deserialize_type, Stream& s) { s >> *this; } - template - inline void SerializationOp(Stream& s, Operation ser_action, const uint8_t format_version) + SERIALIZE_METHODS(CDeterministicMN, obj) { - // We no longer support EvoDB formats below MN_VERSION_FORMAT - if (format_version < MN_VERSION_FORMAT) { - throw std::ios_base::failure("EvoDb too old, run Dash Core with -reindex to rebuild"); - } - READWRITE(proTxHash); - READWRITE(VARINT(internalId)); - READWRITE(collateralOutpoint); - READWRITE(nOperatorReward); - READWRITE(pdmnState); + READWRITE(obj.proTxHash); + READWRITE(VARINT(obj.internalId)); + READWRITE(obj.collateralOutpoint); + READWRITE(obj.nOperatorReward); + READWRITE(obj.pdmnState); // We can't know if we are serialising for the Disk or for the Network here (s.GetType() is not accessible) // Therefore if s.GetVersion() == CLIENT_VERSION -> Then we know we are serialising for the Disk // Otherwise, we can safely check with protocol versioning logic so we won't break old clients if (s.GetVersion() == CLIENT_VERSION || s.GetVersion() >= DMN_TYPE_PROTO_VERSION) { - READWRITE(nType); + READWRITE(obj.nType); } else { - nType = MnType::Regular; + SER_READ(obj, obj.nType = MnType::Regular); } } - template - void Serialize(Stream& s) const - { - const_cast(this)->SerializationOp(s, CSerActionSerialize(), MN_CURRENT_FORMAT); - } - - template - void Unserialize(Stream& s, const uint8_t format_version = MN_CURRENT_FORMAT) - { - SerializationOp(s, CSerActionUnserialize(), format_version); - } - [[nodiscard]] uint64_t GetInternalId() const; [[nodiscard]] std::string ToString() const; @@ -193,27 +172,36 @@ class CDeterministicMNList void Serialize(Stream& s) const { const_cast(this)->SerializationOpBase(s, CSerActionSerialize()); + // Serialize the map as a vector WriteCompactSize(s, mnMap.size()); - for (const auto& p : mnMap) { - s << *p.second; + for (const auto& [_, dmn] : mnMap) { + s << *dmn; } } template - void Unserialize(Stream& s, const uint8_t format_version = CDeterministicMN::MN_CURRENT_FORMAT) { - mnMap = MnMap(); - mnUniquePropertyMap = MnUniquePropertyMap(); - mnInternalIdMap = MnInternalIdMap(); + void Unserialize(Stream& s) + { + Clear(); SerializationOpBase(s, CSerActionUnserialize()); - size_t cnt = ReadCompactSize(s); - for (size_t i = 0; i < cnt; i++) { - AddMN(std::make_shared(deserialize, s, format_version), false); + for (size_t to_read = ReadCompactSize(s); to_read > 0; --to_read) { + AddMN(std::make_shared(deserialize, s), /*fBumpTotalCount=*/false); } } + void Clear() + { + blockHash = uint256{}; + nHeight = -1; + nTotalRegisteredCount = 0; + mnMap = MnMap(); + mnUniquePropertyMap = MnUniquePropertyMap(); + mnInternalIdMap = MnInternalIdMap(); + } + [[nodiscard]] size_t GetAllMNsCount() const { return mnMap.size(); @@ -483,46 +471,39 @@ class CDeterministicMNListDiff void Serialize(Stream& s) const { s << addedMNs; + WriteCompactSize(s, updatedMNs.size()); - for (const auto& p : updatedMNs) { - WriteVarInt(s, p.first); - s << p.second; + for (const auto& [internalId, pdmnState] : updatedMNs) { + WriteVarInt(s, internalId); + s << pdmnState; } + WriteCompactSize(s, removedMns.size()); - for (const auto& p : removedMns) { - WriteVarInt(s, p); + for (const auto& internalId : removedMns) { + WriteVarInt(s, internalId); } } template - void Unserialize(Stream& s, const uint8_t format_version = CDeterministicMN::MN_CURRENT_FORMAT) + void Unserialize(Stream& s) { updatedMNs.clear(); removedMns.clear(); - size_t tmp; - uint64_t tmp2; - tmp = ReadCompactSize(s); - for (size_t i = 0; i < tmp; i++) { - CDeterministicMN mn(0); - mn.Unserialize(s, format_version); - auto dmn = std::make_shared(mn); - addedMNs.push_back(dmn); + for (size_t to_read = ReadCompactSize(s); to_read > 0; --to_read) { + addedMNs.push_back(std::make_shared(deserialize, s)); } - tmp = ReadCompactSize(s); - for (size_t i = 0; i < tmp; i++) { - CDeterministicMNStateDiff diff; - // CDeterministicMNState hold new fields {nConsecutivePayments, platformNodeID, platformP2PPort, platformHTTPPort} but no migration is needed here since: - // CDeterministicMNStateDiff is always serialised using a bitmask. - // Because the new field have a new bit guide value then we are good to continue - tmp2 = ReadVarInt(s); - s >> diff; - updatedMNs.emplace(tmp2, std::move(diff)); + + for (size_t to_read = ReadCompactSize(s); to_read > 0; --to_read) { + uint64_t internalId = ReadVarInt(s); + // CDeterministicMNState can have newer fields but doesn't need migration logic here as CDeterministicMNStateDiff + // is always serialised using a bitmask and new fields have a new bit guide value, so we are good to continue. + updatedMNs.emplace(internalId, CDeterministicMNStateDiff(deserialize, s)); } - tmp = ReadCompactSize(s); - for (size_t i = 0; i < tmp; i++) { - tmp2 = ReadVarInt(s); - removedMns.emplace(tmp2); + + for (size_t to_read = ReadCompactSize(s); to_read > 0; --to_read) { + uint64_t internalId = ReadVarInt(s); + removedMns.emplace(internalId); } } diff --git a/src/evo/dmnstate.h b/src/evo/dmnstate.h index 49a3b4745d55..d6572094d91a 100644 --- a/src/evo/dmnstate.h +++ b/src/evo/dmnstate.h @@ -76,12 +76,8 @@ class CDeterministicMNState platformHTTPPort(proTx.platformHTTPPort) { } - template - CDeterministicMNState(deserialize_type, Stream& s) - { - s >> *this; - } + CDeterministicMNState(deserialize_type, Stream& s) { s >> *this; } SERIALIZE_METHODS(CDeterministicMNState, obj) { @@ -230,6 +226,8 @@ class CDeterministicMNStateDiff fields |= Field_nVersion; } } + template + CDeterministicMNStateDiff(deserialize_type, Stream& s) { s >> *this; } [[nodiscard]] UniValue ToJson(MnType nType) const; From 0a4e72613d6e52ed5339c751cc6e9379c85416bd Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Thu, 12 Jun 2025 17:03:08 +0000 Subject: [PATCH 2/8] util: add deep comparison helpers for shared_ptr --- src/Makefile.am | 1 + src/evo/deterministicmns.h | 2 +- src/util/pointer.h | 38 +++++++++++++++++++++++++++++++ test/util/data/non-backported.txt | 1 + 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/util/pointer.h diff --git a/src/Makefile.am b/src/Makefile.am index 74db920908d0..daa4a2568587 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -365,6 +365,7 @@ BITCOIN_CORE_H = \ util/moneystr.h \ util/overflow.h \ util/overloaded.h \ + util/pointer.h \ util/ranges.h \ util/readwritefile.h \ util/underlying.h \ diff --git a/src/evo/deterministicmns.h b/src/evo/deterministicmns.h index e3af150bba1f..b84a5e36b55f 100644 --- a/src/evo/deterministicmns.h +++ b/src/evo/deterministicmns.h @@ -180,7 +180,7 @@ class CDeterministicMNList } } - template + template void Unserialize(Stream& s) { Clear(); diff --git a/src/util/pointer.h b/src/util/pointer.h new file mode 100644 index 000000000000..71ec60e0217b --- /dev/null +++ b/src/util/pointer.h @@ -0,0 +1,38 @@ +// Copyright (c) 2025 The Dash Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_UTIL_POINTER_H +#define BITCOIN_UTIL_POINTER_H + +#include + +namespace util { +/* Deep equality comparison helper for std::shared_ptr */ +template +bool shared_ptr_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs) + requires requires { *lhs == *rhs; } +{ + /* Same object or both blank */ + if (lhs == rhs) return true; + /* Inequal initialization state */ + if (!lhs || !rhs) return false; + /* Deep comparison */ + return *lhs == *rhs; +} + +/* Deep inequality comparison helper for std::shared_ptr */ +template +bool shared_ptr_not_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs) + requires requires { *lhs != *rhs; } +{ + /* Same object or both blank */ + if (lhs == rhs) return false; + /* Inequal initialization state */ + if (!lhs || !rhs) return true; + /* Deep comparison */ + return *lhs != *rhs; +} +} // namespace util + +#endif // BITCOIN_UTIL_POINTER_H diff --git a/test/util/data/non-backported.txt b/test/util/data/non-backported.txt index 023444a0e690..a12d04314384 100644 --- a/test/util/data/non-backported.txt +++ b/test/util/data/non-backported.txt @@ -42,6 +42,7 @@ src/unordered_lru_cache.h src/util/edge.* src/util/enumerate.h src/util/irange.h +src/util/pointer.h src/util/ranges.h src/util/ranges_set.* src/util/wpipe.* From 0b04978d5f98f3201f47e7a2db6b66798a0bafa1 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Thu, 5 Jun 2025 08:33:44 +0000 Subject: [PATCH 3/8] evo: make `netInfo` a shared pointer --- src/coinjoin/client.cpp | 12 +++---- src/evo/core_write.cpp | 4 +-- src/evo/deterministicmns.cpp | 34 +++++++++++--------- src/evo/dmnstate.cpp | 6 ++-- src/evo/dmnstate.h | 19 ++++++++--- src/evo/netinfo.h | 10 ++++++ src/evo/providertx.cpp | 10 +++--- src/evo/providertx.h | 4 +-- src/evo/simplifiedmns.cpp | 4 +-- src/evo/simplifiedmns.h | 5 +-- src/llmq/utils.cpp | 4 +-- src/masternode/node.cpp | 4 +-- src/masternode/utils.cpp | 2 +- src/net.cpp | 16 ++++----- src/qt/masternodelist.cpp | 4 +-- src/rpc/evo.cpp | 4 +-- src/rpc/masternode.cpp | 4 +-- src/rpc/quorums.cpp | 2 +- src/test/block_reward_reallocation_tests.cpp | 2 +- src/test/evo_deterministicmns_tests.cpp | 14 ++++---- src/test/evo_simplifiedmns_tests.cpp | 2 +- src/txmempool.cpp | 16 ++++----- 22 files changed, 102 insertions(+), 80 deletions(-) diff --git a/src/coinjoin/client.cpp b/src/coinjoin/client.cpp index 025823f9b9bd..d5f5185e4b28 100644 --- a/src/coinjoin/client.cpp +++ b/src/coinjoin/client.cpp @@ -193,7 +193,7 @@ void CCoinJoinClientSession::ProcessMessage(CNode& peer, CChainState& active_cha if (!m_mn_sync.IsBlockchainSynced()) return; if (!mixingMasternode) return; - if (mixingMasternode->pdmnState->netInfo.GetPrimary() != peer.addr) return; + if (mixingMasternode->pdmnState->netInfo->GetPrimary() != peer.addr) return; if (msg_type == NetMsgType::DSSTATUSUPDATE) { CCoinJoinStatusUpdate psssup; @@ -1113,7 +1113,7 @@ bool CCoinJoinClientSession::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, m_clientman.AddUsedMasternode(dsq.masternodeOutpoint); - if (connman.IsMasternodeOrDisconnectRequested(dmn->pdmnState->netInfo.GetPrimary())) { + if (connman.IsMasternodeOrDisconnectRequested(dmn->pdmnState->netInfo->GetPrimary())) { WalletCJLogPrint(m_wallet, /* Continued */ "CCoinJoinClientSession::JoinExistingQueue -- skipping connection, masternode=%s\n", dmn->proTxHash.ToString()); continue; @@ -1185,7 +1185,7 @@ bool CCoinJoinClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, CCon continue; } - if (connman.IsMasternodeOrDisconnectRequested(dmn->pdmnState->netInfo.GetPrimary())) { + if (connman.IsMasternodeOrDisconnectRequested(dmn->pdmnState->netInfo->GetPrimary())) { WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::StartNewQueue -- skipping connection, masternode=%s\n", dmn->proTxHash.ToString()); nTries++; @@ -1225,7 +1225,7 @@ bool CCoinJoinClientSession::ProcessPendingDsaRequest(CConnman& connman) CService mn_addr; if (auto dmn = m_dmnman.GetListAtChainTip().GetMN(pendingDsaRequest.GetProTxHash())) { - mn_addr = Assert(dmn->pdmnState)->netInfo.GetPrimary(); + mn_addr = Assert(dmn->pdmnState)->netInfo->GetPrimary(); } else { WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::%s -- cannot find address to connect, masternode=%s\n", __func__, pendingDsaRequest.GetProTxHash().ToString()); @@ -1827,7 +1827,7 @@ void CCoinJoinClientSession::RelayIn(const CCoinJoinEntry& entry, CConnman& conn { if (!mixingMasternode) return; - connman.ForNode(mixingMasternode->pdmnState->netInfo.GetPrimary(), [&entry, &connman, this](CNode* pnode) { + connman.ForNode(mixingMasternode->pdmnState->netInfo->GetPrimary(), [&entry, &connman, this](CNode* pnode) { WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::RelayIn -- found master, relaying message to %s\n", pnode->addr.ToStringAddrPort()); CNetMsgMaker msgMaker(pnode->GetCommonVersion()); @@ -1883,7 +1883,7 @@ void CCoinJoinClientSession::GetJsonInfo(UniValue& obj) const assert(mixingMasternode->pdmnState); obj.pushKV("protxhash", mixingMasternode->proTxHash.ToString()); obj.pushKV("outpoint", mixingMasternode->collateralOutpoint.ToStringShort()); - obj.pushKV("service", mixingMasternode->pdmnState->netInfo.GetPrimary().ToStringAddrPort()); + obj.pushKV("service", mixingMasternode->pdmnState->netInfo->GetPrimary().ToStringAddrPort()); } obj.pushKV("denomination", ValueFromAmount(CoinJoin::DenominationToAmount(nSessionDenom))); obj.pushKV("state", GetStateString()); diff --git a/src/evo/core_write.cpp b/src/evo/core_write.cpp index 55af0bf50352..91ffc5c2270f 100644 --- a/src/evo/core_write.cpp +++ b/src/evo/core_write.cpp @@ -67,7 +67,7 @@ ret.pushKV("type", ToUnderlying(nType)); ret.pushKV("collateralHash", collateralOutpoint.hash.ToString()); ret.pushKV("collateralIndex", (int)collateralOutpoint.n); - ret.pushKV("service", netInfo.GetPrimary().ToStringAddrPort()); + ret.pushKV("service", netInfo->GetPrimary().ToStringAddrPort()); ret.pushKV("ownerAddress", EncodeDestination(PKHash(keyIDOwner))); ret.pushKV("votingAddress", EncodeDestination(PKHash(keyIDVoting))); if (CTxDestination dest; ExtractDestination(scriptPayout, dest)) { @@ -114,7 +114,7 @@ ret.pushKV("version", nVersion); ret.pushKV("type", ToUnderlying(nType)); ret.pushKV("proTxHash", proTxHash.ToString()); - ret.pushKV("service", netInfo.GetPrimary().ToStringAddrPort()); + ret.pushKV("service", netInfo->GetPrimary().ToStringAddrPort()); if (CTxDestination dest; ExtractDestination(scriptOperatorPayout, dest)) { ret.pushKV("operatorPayoutAddress", EncodeDestination(dest)); } diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index e38e699f5270..8579ec8bf5a0 100644 --- a/src/evo/deterministicmns.cpp +++ b/src/evo/deterministicmns.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -409,7 +410,7 @@ void CDeterministicMNList::AddMN(const CDeterministicMNCPtr& dmn, bool fBumpTota throw(std::runtime_error(strprintf("%s: Can't add a masternode %s with a duplicate collateralOutpoint=%s", __func__, dmn->proTxHash.ToString(), dmn->collateralOutpoint.ToStringShort()))); } - for (const NetInfoEntry& entry : dmn->pdmnState->netInfo.GetEntries()) { + for (const NetInfoEntry& entry : dmn->pdmnState->netInfo->GetEntries()) { if (const auto& service_opt{entry.GetAddrPort()}; service_opt.has_value()) { const CService& service{service_opt.value()}; if (!AddUniqueProperty(*dmn, service)) { @@ -459,13 +460,13 @@ void CDeterministicMNList::UpdateMN(const CDeterministicMN& oldDmn, const std::s // Using this temporary map as a checkpoint to roll back to in case of any issues. decltype(mnUniquePropertyMap) mnUniquePropertyMapSaved = mnUniquePropertyMap; - auto updateNetInfo = [this](const CDeterministicMN& dmn, const MnNetInfo& oldInfo, - const MnNetInfo& newInfo) -> std::string { - if (oldInfo != newInfo) { + auto updateNetInfo = [this](const CDeterministicMN& dmn, const std::shared_ptr& oldInfo, + const std::shared_ptr& newInfo) -> std::string { + if (util::shared_ptr_not_equal(oldInfo, newInfo)) { // We track each individual entry in netInfo as opposed to netInfo itself (preventing us from // using UpdateUniqueProperty()), so we need to successfully purge all old entries and insert // new entries to successfully update. - for (const NetInfoEntry& old_entry : oldInfo.GetEntries()) { + for (const NetInfoEntry& old_entry : oldInfo->GetEntries()) { if (const auto& service_opt{old_entry.GetAddrPort()}) { const CService& service{service_opt.value()}; if (!DeleteUniqueProperty(dmn, service)) { @@ -475,7 +476,7 @@ void CDeterministicMNList::UpdateMN(const CDeterministicMN& oldDmn, const std::s return "invalid address"; } } - for (const NetInfoEntry& new_entry : newInfo.GetEntries()) { + for (const NetInfoEntry& new_entry : newInfo->GetEntries()) { if (const auto& service_opt{new_entry.GetAddrPort()}) { const CService& service{service_opt.value()}; if (!AddUniqueProperty(dmn, service)) { @@ -489,6 +490,7 @@ void CDeterministicMNList::UpdateMN(const CDeterministicMN& oldDmn, const std::s return ""; }; + assert(oldState->netInfo && pdmnState->netInfo); if (auto err = updateNetInfo(*dmn, oldState->netInfo, pdmnState->netInfo); !err.empty()) { mnUniquePropertyMap = mnUniquePropertyMapSaved; throw(std::runtime_error(strprintf("%s: Can't update masternode %s with addresses, reason=%s", __func__, @@ -549,7 +551,7 @@ void CDeterministicMNList::RemoveMN(const uint256& proTxHash) throw(std::runtime_error(strprintf("%s: Can't delete a masternode %s with a collateralOutpoint=%s", __func__, proTxHash.ToString(), dmn->collateralOutpoint.ToStringShort()))); } - for (const NetInfoEntry& entry : dmn->pdmnState->netInfo.GetEntries()) { + for (const NetInfoEntry& entry : dmn->pdmnState->netInfo->GetEntries()) { if (const auto& service_opt{entry.GetAddrPort()}; service_opt.has_value()) { const CService& service{service_opt.value()}; if (!DeleteUniqueProperty(*dmn, service)) { @@ -777,7 +779,7 @@ bool CDeterministicMNManager::BuildNewListFromBlock(const CBlock& block, gsl::no } } - for (const NetInfoEntry& entry : proTx.netInfo.GetEntries()) { + for (const NetInfoEntry& entry : proTx.netInfo->GetEntries()) { if (const auto& service_opt{entry.GetAddrPort()}; service_opt.has_value()) { const CService& service{service_opt.value()}; if (newList.HasUniqueProperty(service)) { @@ -795,7 +797,7 @@ bool CDeterministicMNManager::BuildNewListFromBlock(const CBlock& block, gsl::no auto dmnState = std::make_shared(proTx); dmnState->nRegisteredHeight = nHeight; - if (proTx.netInfo.IsEmpty()) { + if (proTx.netInfo->IsEmpty()) { // start in banned pdmnState as we need to wait for a ProUpServTx dmnState->BanIfNotBanned(nHeight); } @@ -813,7 +815,7 @@ bool CDeterministicMNManager::BuildNewListFromBlock(const CBlock& block, gsl::no return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-protx-payload"); } - for (const NetInfoEntry& entry : opt_proTx->netInfo.GetEntries()) { + for (const NetInfoEntry& entry : opt_proTx->netInfo->GetEntries()) { if (const auto& service_opt{entry.GetAddrPort()}; service_opt.has_value()) { const CService& service{service_opt.value()}; if (newList.HasUniqueProperty(service) && @@ -1175,7 +1177,7 @@ void CDeterministicMNManager::CleanupCache(int nHeight) template static bool CheckService(const ProTx& proTx, TxValidationState& state) { - switch (proTx.netInfo.Validate()) { + switch (proTx.netInfo->Validate()) { case NetInfoStatus::BadAddress: return state.Invalid(TxValidationResult::TX_BAD_SPECIAL, "bad-protx-netinfo-addr"); case NetInfoStatus::BadPort: @@ -1228,8 +1230,8 @@ static bool CheckPlatformFields(const ProTx& proTx, TxValidationState& state) return state.Invalid(TxValidationResult::TX_BAD_SPECIAL, "bad-protx-platform-http-port"); } - if (proTx.platformP2PPort == proTx.platformHTTPPort || proTx.platformP2PPort == proTx.netInfo.GetPrimary().GetPort() || - proTx.platformHTTPPort == proTx.netInfo.GetPrimary().GetPort()) { + if (proTx.platformP2PPort == proTx.platformHTTPPort || proTx.platformP2PPort == proTx.netInfo->GetPrimary().GetPort() || + proTx.platformHTTPPort == proTx.netInfo->GetPrimary().GetPort()) { return state.Invalid(TxValidationResult::TX_BAD_SPECIAL, "bad-protx-platform-dup-ports"); } @@ -1294,7 +1296,7 @@ bool CheckProRegTx(CDeterministicMNManager& dmnman, const CTransaction& tx, gsl: // It's allowed to set addr to 0, which will put the MN into PoSe-banned state and require a ProUpServTx to be issues later // If any of both is set, it must be valid however - if (!opt_ptx->netInfo.IsEmpty() && !CheckService(*opt_ptx, state)) { + if (!opt_ptx->netInfo->IsEmpty() && !CheckService(*opt_ptx, state)) { // pass the state returned by the function above return false; } @@ -1354,7 +1356,7 @@ bool CheckProRegTx(CDeterministicMNManager& dmnman, const CTransaction& tx, gsl: auto mnList = dmnman.GetListForBlock(pindexPrev); // only allow reusing of addresses when it's for the same collateral (which replaces the old MN) - for (const NetInfoEntry& entry : opt_ptx->netInfo.GetEntries()) { + for (const NetInfoEntry& entry : opt_ptx->netInfo->GetEntries()) { if (const auto& service_opt{entry.GetAddrPort()}; service_opt.has_value()) { const CService& service{service_opt.value()}; if (mnList.HasUniqueProperty(service) && @@ -1432,7 +1434,7 @@ bool CheckProUpServTx(CDeterministicMNManager& dmnman, const CTransaction& tx, g } // don't allow updating to addresses already used by other MNs - for (const NetInfoEntry& entry : opt_ptx->netInfo.GetEntries()) { + for (const NetInfoEntry& entry : opt_ptx->netInfo->GetEntries()) { if (const auto& service_opt{entry.GetAddrPort()}; service_opt.has_value()) { const CService& service{service_opt.value()}; if (mnList.HasUniqueProperty(service) && mnList.GetUniquePropertyMN(service)->proTxHash != opt_ptx->proTxHash) { diff --git a/src/evo/dmnstate.cpp b/src/evo/dmnstate.cpp index df09e2d4611c..dd95a8b5ee4d 100644 --- a/src/evo/dmnstate.cpp +++ b/src/evo/dmnstate.cpp @@ -32,14 +32,14 @@ std::string CDeterministicMNState::ToString() const " %s", nVersion, nRegisteredHeight, nLastPaidHeight, nPoSePenalty, nPoSeRevivedHeight, nPoSeBanHeight, nRevocationReason, EncodeDestination(PKHash(keyIDOwner)), pubKeyOperator.ToString(), - EncodeDestination(PKHash(keyIDVoting)), payoutAddress, operatorPayoutAddress, netInfo.ToString()); + EncodeDestination(PKHash(keyIDVoting)), payoutAddress, operatorPayoutAddress, netInfo->ToString()); } UniValue CDeterministicMNState::ToJson(MnType nType) const { UniValue obj(UniValue::VOBJ); obj.pushKV("version", nVersion); - obj.pushKV("service", netInfo.GetPrimary().ToStringAddrPort()); + obj.pushKV("service", netInfo->GetPrimary().ToStringAddrPort()); obj.pushKV("registeredHeight", nRegisteredHeight); obj.pushKV("lastPaidHeight", nLastPaidHeight); obj.pushKV("consecutivePayments", nConsecutivePayments); @@ -73,7 +73,7 @@ UniValue CDeterministicMNStateDiff::ToJson(MnType nType) const obj.pushKV("version", state.nVersion); } if (fields & Field_netInfo) { - obj.pushKV("service", state.netInfo.GetPrimary().ToStringAddrPort()); + obj.pushKV("service", state.netInfo->GetPrimary().ToStringAddrPort()); } if (fields & Field_nRegisteredHeight) { obj.pushKV("registeredHeight", state.nRegisteredHeight); diff --git a/src/evo/dmnstate.h b/src/evo/dmnstate.h index d6572094d91a..b6f82581e2bd 100644 --- a/src/evo/dmnstate.h +++ b/src/evo/dmnstate.h @@ -11,6 +11,7 @@ #include #include #include