33// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44
55#include < evo/deterministicmns.h>
6+
67#include < evo/dmn_types.h>
78#include < evo/dmnstate.h>
89#include < evo/evodb.h>
910#include < evo/providertx.h>
1011#include < evo/simplifiedmns.h>
1112#include < evo/specialtx.h>
13+ #include < masternode/meta.h>
14+ #include < messagesigner.h>
15+ #include < stats/client.h>
16+ #include < util/irange.h>
17+ #include < util/pointer.h>
1218
1319#include < chainparams.h>
1420#include < coins.h>
1521#include < consensus/validation.h>
1622#include < deploymentstatus.h>
1723#include < index/txindex.h>
18- #include < masternode/meta.h>
19- #include < messagesigner.h>
2024#include < node/blockstorage.h>
2125#include < script/standard.h>
22- #include < stats/client.h>
2326#include < uint256.h>
24- #include < univalue.h>
25- #include < util/irange.h>
26- #include < util/pointer.h>
27+ #include < validation.h>
2728
2829#include < functional>
2930#include < optional>
3031#include < memory>
3132
33+ #include < univalue.h>
34+
3235static const std::string DB_LIST_SNAPSHOT = " dmn_S3" ;
3336static const std::string DB_LIST_DIFF = " dmn_D4" ; // Bumped for nVersion-first format
3437static const std::string DB_LIST_DIFF_LEGACY = " dmn_D3" ; // Legacy format key
@@ -1035,8 +1038,9 @@ static bool CheckHashSig(const ProTx& proTx, const CBLSPublicKey& pubKey, TxVali
10351038 return true ;
10361039}
10371040
1038- template <typename ProTx>
1039- static std::optional<ProTx> GetValidatedPayload (const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, TxValidationState& state)
1041+ template <typename ProTx>
1042+ static std::optional<ProTx> GetValidatedPayload (const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev,
1043+ const ChainstateManager& chainman, TxValidationState& state)
10401044{
10411045 if (tx.nType != ProTx::SPECIALTX_TYPE) {
10421046 state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-type" );
@@ -1048,7 +1052,7 @@ static std::optional<ProTx> GetValidatedPayload(const CTransaction& tx, gsl::not
10481052 state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-payload" );
10491053 return std::nullopt ;
10501054 }
1051- if (!opt_ptx->IsTriviallyValid (pindexPrev, state)) {
1055+ if (!opt_ptx->IsTriviallyValid (pindexPrev, chainman, state)) {
10521056 // pass the state returned by the function above
10531057 return std::nullopt ;
10541058 }
@@ -1065,9 +1069,10 @@ static std::optional<ProTx> GetValidatedPayload(const CTransaction& tx, gsl::not
10651069 * @returns true if version change is valid or DEPLOYMENT_V24 is not active
10661070 */
10671071bool IsVersionChangeValid (gsl::not_null<const CBlockIndex*> pindexPrev, const uint16_t tx_type,
1068- const uint16_t state_version, const uint16_t tx_version, TxValidationState& state)
1072+ const uint16_t state_version, const uint16_t tx_version, const ChainstateManager& chainman,
1073+ TxValidationState& state)
10691074{
1070- if (!DeploymentActiveAfter (pindexPrev, Params (). GetConsensus () , Consensus::DEPLOYMENT_V24)) {
1075+ if (!DeploymentActiveAfter (pindexPrev, chainman , Consensus::DEPLOYMENT_V24)) {
10711076 // New restrictions only apply after v24 deployment
10721077 return true ;
10731078 }
@@ -1090,15 +1095,17 @@ bool IsVersionChangeValid(gsl::not_null<const CBlockIndex*> pindexPrev, const ui
10901095 return true ;
10911096}
10921097
1093- bool CheckProRegTx (CDeterministicMNManager& dmnman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, TxValidationState& state, const CCoinsViewCache& view, bool check_sigs)
1098+ bool CheckProRegTx (const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev,
1099+ CDeterministicMNManager& dmnman, const CCoinsViewCache& view, const ChainstateManager& chainman,
1100+ TxValidationState& state, bool check_sigs)
10941101{
1095- const auto opt_ptx = GetValidatedPayload<CProRegTx>(tx, pindexPrev, state);
1102+ const auto opt_ptx = GetValidatedPayload<CProRegTx>(tx, pindexPrev, chainman, state);
10961103 if (!opt_ptx) {
10971104 // pass the state returned by the function above
10981105 return false ;
10991106 }
11001107
1101- const bool is_v24_active{DeploymentActiveAfter (pindexPrev, Params (). GetConsensus () , Consensus::DEPLOYMENT_V24)};
1108+ const bool is_v24_active{DeploymentActiveAfter (pindexPrev, chainman , Consensus::DEPLOYMENT_V24)};
11021109
11031110 // No longer allow legacy scheme masternode registration
11041111 if (is_v24_active && opt_ptx->nVersion < ProTxVersion::BasicBLS) {
@@ -1223,9 +1230,10 @@ bool CheckProRegTx(CDeterministicMNManager& dmnman, const CTransaction& tx, gsl:
12231230 return true ;
12241231}
12251232
1226- bool CheckProUpServTx (CDeterministicMNManager& dmnman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, TxValidationState& state, bool check_sigs)
1233+ bool CheckProUpServTx (const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, CDeterministicMNManager& dmnman,
1234+ const ChainstateManager& chainman, TxValidationState& state, bool check_sigs)
12271235{
1228- const auto opt_ptx = GetValidatedPayload<CProUpServTx>(tx, pindexPrev, state);
1236+ const auto opt_ptx = GetValidatedPayload<CProUpServTx>(tx, pindexPrev, chainman, state);
12291237 if (!opt_ptx) {
12301238 // pass the state returned by the function above
12311239 return false ;
@@ -1248,7 +1256,7 @@ bool CheckProUpServTx(CDeterministicMNManager& dmnman, const CTransaction& tx, g
12481256 return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-hash" );
12491257 }
12501258
1251- if (!IsVersionChangeValid (pindexPrev, tx.nType , dmn->pdmnState ->nVersion , opt_ptx->nVersion , state)) {
1259+ if (!IsVersionChangeValid (pindexPrev, tx.nType , dmn->pdmnState ->nVersion , opt_ptx->nVersion , chainman, state)) {
12521260 // pass the state returned by the function above
12531261 return false ;
12541262 }
@@ -1299,9 +1307,11 @@ bool CheckProUpServTx(CDeterministicMNManager& dmnman, const CTransaction& tx, g
12991307 return true ;
13001308}
13011309
1302- bool CheckProUpRegTx (CDeterministicMNManager& dmnman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, TxValidationState& state, const CCoinsViewCache& view, bool check_sigs)
1310+ bool CheckProUpRegTx (const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev,
1311+ CDeterministicMNManager& dmnman, const CCoinsViewCache& view, const ChainstateManager& chainman,
1312+ TxValidationState& state, bool check_sigs)
13031313{
1304- const auto opt_ptx = GetValidatedPayload<CProUpRegTx>(tx, pindexPrev, state);
1314+ const auto opt_ptx = GetValidatedPayload<CProUpRegTx>(tx, pindexPrev, chainman, state);
13051315 if (!opt_ptx) {
13061316 // pass the state returned by the function above
13071317 return false ;
@@ -1319,7 +1329,7 @@ bool CheckProUpRegTx(CDeterministicMNManager& dmnman, const CTransaction& tx, gs
13191329 return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-hash" );
13201330 }
13211331
1322- if (!IsVersionChangeValid (pindexPrev, tx.nType , dmn->pdmnState ->nVersion , opt_ptx->nVersion , state)) {
1332+ if (!IsVersionChangeValid (pindexPrev, tx.nType , dmn->pdmnState ->nVersion , opt_ptx->nVersion , chainman, state)) {
13231333 // pass the state returned by the function above
13241334 return false ;
13251335 }
@@ -1369,9 +1379,10 @@ bool CheckProUpRegTx(CDeterministicMNManager& dmnman, const CTransaction& tx, gs
13691379 return true ;
13701380}
13711381
1372- bool CheckProUpRevTx (CDeterministicMNManager& dmnman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, TxValidationState& state, bool check_sigs)
1382+ bool CheckProUpRevTx (const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, CDeterministicMNManager& dmnman,
1383+ const ChainstateManager& chainman, TxValidationState& state, bool check_sigs)
13731384{
1374- const auto opt_ptx = GetValidatedPayload<CProUpRevTx>(tx, pindexPrev, state);
1385+ const auto opt_ptx = GetValidatedPayload<CProUpRevTx>(tx, pindexPrev, chainman, state);
13751386 if (!opt_ptx) {
13761387 // pass the state returned by the function above
13771388 return false ;
@@ -1383,7 +1394,7 @@ bool CheckProUpRevTx(CDeterministicMNManager& dmnman, const CTransaction& tx, gs
13831394 return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-hash" );
13841395 }
13851396
1386- if (!IsVersionChangeValid (pindexPrev, tx.nType , dmn->pdmnState ->nVersion , opt_ptx->nVersion , state)) {
1397+ if (!IsVersionChangeValid (pindexPrev, tx.nType , dmn->pdmnState ->nVersion , opt_ptx->nVersion , chainman, state)) {
13871398 // pass the state returned by the function above
13881399 return false ;
13891400 }
0 commit comments