refactor: drop usage of chainstate globals in asset locks logic

This commit is contained in:
Kittywhiskers Van Gogh 2024-06-26 13:50:48 +00:00
parent 21cc12c62a
commit fa20718b4f
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
11 changed files with 73 additions and 61 deletions

View File

@ -22,13 +22,13 @@
/**
* Common code for Asset Lock and Asset Unlock
*/
bool CheckAssetLockUnlockTx(const llmq::CQuorumManager& qman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, const std::optional<CRangesSet>& indexes, TxValidationState& state)
bool CheckAssetLockUnlockTx(const BlockManager& blockman, const llmq::CQuorumManager& qman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, const std::optional<CRangesSet>& indexes, TxValidationState& state)
{
switch (tx.nType) {
case TRANSACTION_ASSET_LOCK:
return CheckAssetLockTx(tx, state);
case TRANSACTION_ASSET_UNLOCK:
return CheckAssetUnlockTx(qman, tx, pindexPrev, indexes, state);
return CheckAssetUnlockTx(blockman, qman, tx, pindexPrev, indexes, state);
default:
return state.Invalid(TxValidationResult::TX_BAD_SPECIAL, "bad-not-asset-locks-at-all");
}
@ -141,7 +141,7 @@ bool CAssetUnlockPayload::VerifySig(const llmq::CQuorumManager& qman, const uint
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-assetunlock-not-verified");
}
bool CheckAssetUnlockTx(const llmq::CQuorumManager& qman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, const std::optional<CRangesSet>& indexes, TxValidationState& state)
bool CheckAssetUnlockTx(const BlockManager& blockman, const llmq::CQuorumManager& qman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, const std::optional<CRangesSet>& indexes, TxValidationState& state)
{
// Some checks depends from blockchain status also, such as `known indexes` and `withdrawal limits`
// They are omitted here and done by CCreditPool
@ -171,7 +171,7 @@ bool CheckAssetUnlockTx(const llmq::CQuorumManager& qman, const CTransaction& tx
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-assetunlock-duplicated-index");
}
if (LOCK(cs_main); g_chainman.m_blockman.LookupBlockIndex(assetUnlockTx.getQuorumHash()) == nullptr) {
if (LOCK(cs_main); blockman.LookupBlockIndex(assetUnlockTx.getQuorumHash()) == nullptr) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-assetunlock-quorum-hash");
}

View File

@ -14,6 +14,7 @@
#include <optional>
class BlockManager;
class CBlockIndex;
class CRangesSet;
class TxValidationState;
@ -172,8 +173,8 @@ public:
};
bool CheckAssetLockTx(const CTransaction& tx, TxValidationState& state);
bool CheckAssetUnlockTx(const llmq::CQuorumManager& qman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, const std::optional<CRangesSet>& indexes, TxValidationState& state);
bool CheckAssetLockUnlockTx(const llmq::CQuorumManager& qman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, const std::optional<CRangesSet>& indexes, TxValidationState& state);
bool CheckAssetUnlockTx(const BlockManager& blockman, const llmq::CQuorumManager& qman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, const std::optional<CRangesSet>& indexes, TxValidationState& state);
bool CheckAssetLockUnlockTx(const BlockManager& blockman, const llmq::CQuorumManager& qman, const CTransaction& tx, gsl::not_null<const CBlockIndex*> pindexPrev, const std::optional<CRangesSet>& indexes, TxValidationState& state);
bool GetAssetUnlockFee(const CTransaction& tx, CAmount& txfee, TxValidationState& state);
#endif // BITCOIN_EVO_ASSETLOCKTX_H

View File

@ -13,7 +13,7 @@ CChainstateHelper::CChainstateHelper(CCreditPoolManager& cpoolman, CDeterministi
const CMasternodeSync& mn_sync, const CSporkManager& sporkman, const llmq::CChainLocksHandler& clhandler,
const llmq::CQuorumManager& qman)
: mn_payments{std::make_unique<CMNPaymentsProcessor>(dmnman, govman, chainman, consensus_params, mn_sync, sporkman)},
special_tx{std::make_unique<CSpecialTxProcessor>(cpoolman, dmnman, mnhfman, qblockman, consensus_params, clhandler, qman)}
special_tx{std::make_unique<CSpecialTxProcessor>(cpoolman, dmnman, mnhfman, qblockman, chainman, consensus_params, clhandler, qman)}
{}
CChainstateHelper::~CChainstateHelper() = default;

View File

@ -267,12 +267,12 @@ bool CCreditPoolDiff::Unlock(const CTransaction& tx, TxValidationState& state)
return true;
}
bool CCreditPoolDiff::ProcessLockUnlockTransaction(const llmq::CQuorumManager& qman, const CTransaction& tx, TxValidationState& state)
bool CCreditPoolDiff::ProcessLockUnlockTransaction(const BlockManager& blockman, const llmq::CQuorumManager& qman, const CTransaction& tx, TxValidationState& state)
{
if (!tx.IsSpecialTxVersion()) return true;
if (tx.nType != TRANSACTION_ASSET_LOCK && tx.nType != TRANSACTION_ASSET_UNLOCK) return true;
if (!CheckAssetLockUnlockTx(qman, tx, pindexPrev, pool.indexes, state)) {
if (!CheckAssetLockUnlockTx(blockman, qman, tx, pindexPrev, pool.indexes, state)) {
// pass the state returned by the function above
return false;
}
@ -292,8 +292,9 @@ bool CCreditPoolDiff::ProcessLockUnlockTransaction(const llmq::CQuorumManager& q
}
}
std::optional<CCreditPoolDiff> GetCreditPoolDiffForBlock(CCreditPoolManager& cpoolman, const llmq::CQuorumManager& qman, const CBlock& block, const CBlockIndex* pindexPrev,
const Consensus::Params& consensusParams, const CAmount blockSubsidy, BlockValidationState& state)
std::optional<CCreditPoolDiff> GetCreditPoolDiffForBlock(CCreditPoolManager& cpoolman, const BlockManager& blockman, const llmq::CQuorumManager& qman,
const CBlock& block, const CBlockIndex* pindexPrev, const Consensus::Params& consensusParams,
const CAmount blockSubsidy, BlockValidationState& state)
{
try {
const CCreditPool creditPool = cpoolman.GetCreditPool(pindexPrev, consensusParams);
@ -302,7 +303,7 @@ std::optional<CCreditPoolDiff> GetCreditPoolDiffForBlock(CCreditPoolManager& cpo
for (size_t i = 1; i < block.vtx.size(); ++i) {
const auto& tx = *block.vtx[i];
TxValidationState tx_state;
if (!creditPoolDiff.ProcessLockUnlockTransaction(qman, tx, tx_state)) {
if (!creditPoolDiff.ProcessLockUnlockTransaction(blockman, qman, tx, tx_state)) {
assert(tx_state.GetResult() == TxValidationResult::TX_CONSENSUS);
state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, tx_state.GetRejectReason(),
strprintf("Process Lock/Unlock Transaction failed at Credit Pool (tx hash %s) %s", tx.GetHash().ToString(), tx_state.GetDebugMessage()));

View File

@ -20,6 +20,7 @@
#include <optional>
#include <unordered_set>
class BlockManager;
class CBlockIndex;
class BlockValidationState;
class TxValidationState;
@ -83,7 +84,7 @@ public:
* to change amount of credit pool
* @return true if transaction can be included in this block
*/
bool ProcessLockUnlockTransaction(const llmq::CQuorumManager& qman, const CTransaction& tx, TxValidationState& state);
bool ProcessLockUnlockTransaction(const BlockManager& blockman, const llmq::CQuorumManager& qman, const CTransaction& tx, TxValidationState& state);
/**
* this function returns total amount of credits for the next block
@ -135,7 +136,8 @@ private:
CCreditPool ConstructCreditPool(const CBlockIndex* block_index, CCreditPool prev, const Consensus::Params& consensusParams);
};
std::optional<CCreditPoolDiff> GetCreditPoolDiffForBlock(CCreditPoolManager& cpoolman, const llmq::CQuorumManager& qman, const CBlock& block, const CBlockIndex* pindexPrev,
const Consensus::Params& consensusParams, const CAmount blockSubsidy, BlockValidationState& state);
std::optional<CCreditPoolDiff> GetCreditPoolDiffForBlock(CCreditPoolManager& cpoolman, const BlockManager& blockman, const llmq::CQuorumManager& qman,
const CBlock& block, const CBlockIndex* pindexPrev, const Consensus::Params& consensusParams,
const CAmount blockSubsidy, BlockValidationState& state);
#endif

View File

@ -17,9 +17,11 @@
#include <llmq/blockprocessor.h>
#include <llmq/commitment.h>
#include <primitives/block.h>
#include <validation.h>
static bool CheckSpecialTxInner(CDeterministicMNManager& dmnman, const llmq::CQuorumManager& qman, const CTransaction& tx, const CBlockIndex* pindexPrev,
const CCoinsViewCache& view, const std::optional<CRangesSet>& indexes, bool check_sigs, TxValidationState& state)
static bool CheckSpecialTxInner(CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const llmq::CQuorumManager& qman, const CTransaction& tx,
const CBlockIndex* pindexPrev, const CCoinsViewCache& view, const std::optional<CRangesSet>& indexes, bool check_sigs,
TxValidationState& state)
{
AssertLockHeld(cs_main);
@ -54,7 +56,7 @@ static bool CheckSpecialTxInner(CDeterministicMNManager& dmnman, const llmq::CQu
if (!DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_V20)) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "assetlocks-before-v20");
}
return CheckAssetLockUnlockTx(qman, tx, pindexPrev, indexes, state);
return CheckAssetLockUnlockTx(chainman.m_blockman, qman, tx, pindexPrev, indexes, state);
case TRANSACTION_ASSET_UNLOCK:
if (Params().NetworkIDString() == CBaseChainParams::REGTEST && !DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_V20)) {
// TODO: adjust functional tests to make it activated by MN_RR on regtest too
@ -63,7 +65,7 @@ static bool CheckSpecialTxInner(CDeterministicMNManager& dmnman, const llmq::CQu
if (Params().NetworkIDString() != CBaseChainParams::REGTEST && !DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_MN_RR)) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "assetunlocks-before-mn_rr");
}
return CheckAssetLockUnlockTx(qman, tx, pindexPrev, indexes, state);
return CheckAssetLockUnlockTx(chainman.m_blockman, qman, tx, pindexPrev, indexes, state);
}
} catch (const std::exception& e) {
LogPrintf("%s -- failed: %s\n", __func__, e.what());
@ -76,7 +78,7 @@ static bool CheckSpecialTxInner(CDeterministicMNManager& dmnman, const llmq::CQu
bool CSpecialTxProcessor::CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, const CCoinsViewCache& view, bool check_sigs, TxValidationState& state)
{
AssertLockHeld(cs_main);
return CheckSpecialTxInner(m_dmnman, m_qman, tx, pindexPrev, view, std::nullopt, check_sigs, state);
return CheckSpecialTxInner(m_dmnman, m_chainman, m_qman, tx, pindexPrev, view, std::nullopt, check_sigs, state);
}
[[nodiscard]] bool CSpecialTxProcessor::ProcessSpecialTx(const CTransaction& tx, const CBlockIndex* pindex, TxValidationState& state)
@ -155,7 +157,7 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB
TxValidationState tx_state;
// At this moment CheckSpecialTx() and ProcessSpecialTx() may fail by 2 possible ways:
// consensus failures and "TX_BAD_SPECIAL"
if (!CheckSpecialTxInner(m_dmnman, m_qman, *ptr_tx, pindex->pprev, view, creditPool.indexes, fCheckCbTxMerkleRoots, tx_state)) {
if (!CheckSpecialTxInner(m_dmnman, m_chainman, m_qman, *ptr_tx, pindex->pprev, view, creditPool.indexes, fCheckCbTxMerkleRoots, tx_state)) {
assert(tx_state.GetResult() == TxValidationResult::TX_CONSENSUS || tx_state.GetResult() == TxValidationResult::TX_BAD_SPECIAL);
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, tx_state.GetRejectReason(),
strprintf("Special Transaction check failed (tx hash %s) %s", ptr_tx->GetHash().ToString(), tx_state.GetDebugMessage()));
@ -273,10 +275,12 @@ bool CSpecialTxProcessor::UndoSpecialTxsInBlock(const CBlock& block, const CBloc
bool CSpecialTxProcessor::CheckCreditPoolDiffForBlock(const CBlock& block, const CBlockIndex* pindex, const CAmount blockSubsidy, BlockValidationState& state)
{
AssertLockHeld(cs_main);
try {
if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_V20)) return true;
auto creditPoolDiff = GetCreditPoolDiffForBlock(m_cpoolman, m_qman, block, pindex->pprev, m_consensus_params, blockSubsidy, state);
auto creditPoolDiff = GetCreditPoolDiffForBlock(m_cpoolman, m_chainman.m_blockman, m_qman, block, pindex->pprev, m_consensus_params, blockSubsidy, state);
if (!creditPoolDiff.has_value()) return false;
// If we get there we have v20 activated and credit pool amount must be included in block CbTx

View File

@ -17,6 +17,7 @@ class CBlockIndex;
class CCoinsViewCache;
class CCreditPoolManager;
class CDeterministicMNManager;
class ChainstateManager;
class CMNHFManager;
class TxValidationState;
struct MNListUpdates;
@ -37,6 +38,7 @@ private:
CDeterministicMNManager& m_dmnman;
CMNHFManager& m_mnhfman;
llmq::CQuorumBlockProcessor& m_qblockman;
const ChainstateManager& m_chainman;
const Consensus::Params& m_consensus_params;
const llmq::CChainLocksHandler& m_clhandler;
const llmq::CQuorumManager& m_qman;
@ -46,10 +48,11 @@ private:
[[nodiscard]] bool UndoSpecialTx(const CTransaction& tx, const CBlockIndex* pindex);
public:
explicit CSpecialTxProcessor(CCreditPoolManager& cpoolman, CDeterministicMNManager& dmnman, CMNHFManager& mnhfman, llmq::CQuorumBlockProcessor& qblockman,
const Consensus::Params& consensus_params, const llmq::CChainLocksHandler& clhandler, const llmq::CQuorumManager& qman) :
m_cpoolman(cpoolman), m_dmnman{dmnman}, m_mnhfman{mnhfman}, m_qblockman{qblockman}, m_consensus_params{consensus_params}, m_clhandler{clhandler},
m_qman{qman} {}
explicit CSpecialTxProcessor(CCreditPoolManager& cpoolman, CDeterministicMNManager& dmnman, CMNHFManager& mnhfman,
llmq::CQuorumBlockProcessor& qblockman, const ChainstateManager& chainman, const Consensus::Params& consensus_params,
const llmq::CChainLocksHandler& clhandler, const llmq::CQuorumManager& qman) :
m_cpoolman(cpoolman), m_dmnman{dmnman}, m_mnhfman{mnhfman}, m_qblockman{qblockman}, m_chainman(chainman), m_consensus_params{consensus_params},
m_clhandler{clhandler}, m_qman{qman} {}
bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, const CCoinsViewCache& view, bool check_sigs, TxValidationState& state)
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
@ -58,7 +61,8 @@ public:
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
bool UndoSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, std::optional<MNListUpdates>& updatesRet)
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
bool CheckCreditPoolDiffForBlock(const CBlock& block, const CBlockIndex* pindex, const CAmount blockSubsidy, BlockValidationState& state);
bool CheckCreditPoolDiffForBlock(const CBlock& block, const CBlockIndex* pindex, const CAmount blockSubsidy, BlockValidationState& state)
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
};
#endif // BITCOIN_EVO_SPECIALTXMAN_H

View File

@ -63,18 +63,19 @@ BlockAssembler::Options::Options() {
}
BlockAssembler::BlockAssembler(CChainState& chainstate, const NodeContext& node, const CTxMemPool& mempool, const CChainParams& params, const Options& options) :
chainparams(params),
m_mempool(mempool),
m_chainstate(chainstate),
m_dmnman(*Assert(node.dmnman)),
m_blockman(Assert(node.chainman)->m_blockman),
m_cpoolman(*Assert(node.cpoolman)),
m_chain_helper(*Assert(node.chain_helper)),
m_chainstate(chainstate),
m_dmnman(*Assert(node.dmnman)),
m_evoDb(*Assert(node.evodb)),
m_mnhfman(*Assert(node.mnhf_manager)),
m_quorum_block_processor(*Assert(Assert(node.llmq_ctx)->quorum_block_processor)),
m_qman(*Assert(Assert(node.llmq_ctx)->qman)),
m_clhandler(*Assert(Assert(node.llmq_ctx)->clhandler)),
m_isman(*Assert(Assert(node.llmq_ctx)->isman)),
m_evoDb(*Assert(node.evodb))
chainparams(params),
m_mempool(mempool),
m_quorum_block_processor(*Assert(Assert(node.llmq_ctx)->quorum_block_processor)),
m_qman(*Assert(Assert(node.llmq_ctx)->qman))
{
blockMinFeeRate = options.blockMinFeeRate;
nBlockMaxSize = options.nBlockMaxSize;
@ -221,7 +222,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
cbTx.nHeight = nHeight;
BlockValidationState state;
if (!CalcCbTxMerkleRootMNList(*pblock, pindexPrev, cbTx.merkleRootMNList, m_dmnman, state, ::ChainstateActive().CoinsTip())) {
if (!CalcCbTxMerkleRootMNList(*pblock, pindexPrev, cbTx.merkleRootMNList, m_dmnman, state, m_chainstate.CoinsTip())) {
throw std::runtime_error(strprintf("%s: CalcCbTxMerkleRootMNList failed: %s", __func__, state.ToString()));
}
if (fDIP0008Active_context) {
@ -236,7 +237,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
LogPrintf("CreateNewBlock() h[%d] CbTx failed to find best CL. Inserting null CL\n", nHeight);
}
BlockValidationState state;
const auto creditPoolDiff = GetCreditPoolDiffForBlock(m_cpoolman, m_qman, *pblock, pindexPrev, chainparams.GetConsensus(), blockSubsidy, state);
const auto creditPoolDiff = GetCreditPoolDiffForBlock(m_cpoolman, m_blockman, m_qman, *pblock, pindexPrev, chainparams.GetConsensus(), blockSubsidy, state);
if (creditPoolDiff == std::nullopt) {
throw std::runtime_error(strprintf("%s: GetCreditPoolDiffForBlock failed: %s", __func__, state.ToString()));
}
@ -472,7 +473,7 @@ void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpda
// `state` is local here because used only to log info about this specific tx
TxValidationState state;
if (!creditPoolDiff->ProcessLockUnlockTransaction(m_qman, iter->GetTx(), state)) {
if (!creditPoolDiff->ProcessLockUnlockTransaction(m_blockman, m_qman, iter->GetTx(), state)) {
if (fUsingModified) {
mapModifiedTx.get<ancestor_score>().erase(modit);
failedTx.insert(iter);

View File

@ -16,13 +16,14 @@
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
class BlockManager;
class CBlockIndex;
class CChainParams;
class CChainstateHelper;
class CConnman;
class CCreditPoolManager;
class CDeterministicMNManager;
class CEvoDB;
class CChainstateHelper;
class CMNHFManager;
class CScript;
struct LLMQContext;
@ -159,18 +160,20 @@ private:
// Chain context for the block
int nHeight;
int64_t nLockTimeCutoff;
const CChainParams& chainparams;
const CTxMemPool& m_mempool;
CChainState& m_chainstate;
CDeterministicMNManager& m_dmnman;
BlockManager& m_blockman;
CCreditPoolManager& m_cpoolman;
CChainstateHelper& m_chain_helper;
CChainState& m_chainstate;
CDeterministicMNManager& m_dmnman;
CEvoDB& m_evoDb;
CMNHFManager& m_mnhfman;
const llmq::CQuorumBlockProcessor& m_quorum_block_processor;
const llmq::CQuorumManager& m_qman;
llmq::CChainLocksHandler& m_clhandler;
llmq::CInstantSendManager& m_isman;
CEvoDB& m_evoDb;
const CChainParams& chainparams;
const CTxMemPool& m_mempool;
const llmq::CQuorumBlockProcessor& m_quorum_block_processor;
const llmq::CQuorumManager& m_qman;
public:
struct Options {

View File

@ -313,10 +313,11 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
BOOST_CHECK_MESSAGE(CheckTransaction(CTransaction(tx), tx_state), strTest);
BOOST_CHECK(tx_state.IsValid());
auto& blockman = Assert(m_node.chainman)->m_blockman;
auto& qman = *Assert(m_node.llmq_ctx)->qman;
const CBlockIndex *block_index = ::ChainActive().Tip();
BOOST_CHECK(!CheckAssetUnlockTx(qman, CTransaction(tx), block_index, std::nullopt, tx_state));
BOOST_CHECK(!CheckAssetUnlockTx(blockman, qman, CTransaction(tx), block_index, std::nullopt, tx_state));
BOOST_CHECK(tx_state.GetRejectReason() == "bad-assetunlock-quorum-hash");
{
@ -334,7 +335,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
std::string reason;
BOOST_CHECK(IsStandardTx(CTransaction(tx), reason));
BOOST_CHECK(!CheckAssetUnlockTx(qman, CTransaction(txNonemptyInput), block_index, std::nullopt, tx_state));
BOOST_CHECK(!CheckAssetUnlockTx(blockman, qman, CTransaction(txNonemptyInput), block_index, std::nullopt, tx_state));
BOOST_CHECK(tx_state.GetRejectReason() == "bad-assetunlocktx-have-input");
}
@ -349,7 +350,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
// Wrong type "Asset Lock TX" instead "Asset Unlock TX"
CMutableTransaction txWrongType(tx);
txWrongType.nType = TRANSACTION_ASSET_LOCK;
BOOST_CHECK(!CheckAssetUnlockTx(qman, CTransaction(txWrongType), block_index, std::nullopt, tx_state));
BOOST_CHECK(!CheckAssetUnlockTx(blockman, qman, CTransaction(txWrongType), block_index, std::nullopt, tx_state));
BOOST_CHECK(tx_state.GetRejectReason() == "bad-assetunlocktx-type");
// Check version of tx and payload
@ -364,10 +365,10 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
CMutableTransaction txWrongVersion(tx);
SetTxPayload(txWrongVersion, unlockPayload_tmp);
if (payload_version != 1) {
BOOST_CHECK(!CheckAssetUnlockTx(qman, CTransaction(txWrongVersion), block_index, std::nullopt, tx_state));
BOOST_CHECK(!CheckAssetUnlockTx(blockman, qman, CTransaction(txWrongVersion), block_index, std::nullopt, tx_state));
BOOST_CHECK(tx_state.GetRejectReason() == "bad-assetunlocktx-version");
} else {
BOOST_CHECK(!CheckAssetUnlockTx(qman, CTransaction(txWrongVersion), block_index, std::nullopt, tx_state));
BOOST_CHECK(!CheckAssetUnlockTx(blockman, qman, CTransaction(txWrongVersion), block_index, std::nullopt, tx_state));
BOOST_CHECK(tx_state.GetRejectReason() == "bad-assetunlock-quorum-hash");
}
}
@ -383,15 +384,15 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
out.scriptPubKey = GetScriptForDestination(PKHash(key.GetPubKey()));
}
BOOST_CHECK(!CheckAssetUnlockTx(qman, CTransaction(txManyOutputs), block_index, std::nullopt, tx_state));
BOOST_CHECK(!CheckAssetUnlockTx(blockman, qman, CTransaction(txManyOutputs), block_index, std::nullopt, tx_state));
BOOST_CHECK(tx_state.GetRejectReason() == "bad-assetunlock-quorum-hash");
// Basic checks for CRangesSet
CRangesSet indexes;
BOOST_CHECK(!CheckAssetUnlockTx(qman, CTransaction(txManyOutputs), block_index, indexes, tx_state));
BOOST_CHECK(!CheckAssetUnlockTx(blockman, qman, CTransaction(txManyOutputs), block_index, indexes, tx_state));
BOOST_CHECK(tx_state.GetRejectReason() == "bad-assetunlock-quorum-hash");
BOOST_CHECK(indexes.Add(0x001122334455667788L));
BOOST_CHECK(!CheckAssetUnlockTx(qman, CTransaction(txManyOutputs), block_index, indexes, tx_state));
BOOST_CHECK(!CheckAssetUnlockTx(blockman, qman, CTransaction(txManyOutputs), block_index, indexes, tx_state));
BOOST_CHECK(tx_state.GetRejectReason() == "bad-assetunlock-duplicated-index");
@ -399,7 +400,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
txManyOutputs.vout.resize(outputsLimit + 1);
txManyOutputs.vout.back().nValue = CENT;
txManyOutputs.vout.back().scriptPubKey = GetScriptForDestination(PKHash(key.GetPubKey()));
BOOST_CHECK(!CheckAssetUnlockTx(qman, CTransaction(txManyOutputs), block_index, std::nullopt, tx_state));
BOOST_CHECK(!CheckAssetUnlockTx(blockman, qman, CTransaction(txManyOutputs), block_index, std::nullopt, tx_state));
BOOST_CHECK(tx_state.GetRejectReason() == "bad-assetunlocktx-too-many-outs");
}

View File

@ -68,12 +68,6 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
"evo/deterministicmns -> llmq/utils -> llmq/snapshot -> evo/simplifiedmns -> evo/deterministicmns"
"evo/deterministicmns -> llmq/utils -> net -> evo/deterministicmns"
"policy/policy -> policy/settings -> policy/policy"
"evo/assetlocktx -> validation -> evo/specialtxman -> evo/assetlocktx"
"evo/cbtx -> validation -> evo/specialtxman -> evo/cbtx"
"evo/creditpool -> validation -> evo/specialtxman -> evo/creditpool"
"evo/deterministicmns -> validation -> evo/specialtxman -> evo/deterministicmns"
"evo/mnhftx -> validation -> evo/specialtxman -> evo/mnhftx"
"evo/specialtxman -> llmq/blockprocessor -> validation -> evo/specialtxman"
"consensus/tx_verify -> evo/assetlocktx -> validation -> consensus/tx_verify"
"consensus/tx_verify -> evo/assetlocktx -> llmq/signing -> net_processing -> txmempool -> consensus/tx_verify"
"evo/assetlocktx -> llmq/signing -> net_processing -> txmempool -> evo/assetlocktx"
@ -88,7 +82,8 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
"llmq/signing -> masternode/node -> validationinterface -> llmq/signing"
"evo/mnhftx -> validation -> evo/mnhftx"
"evo/deterministicmns -> validation -> evo/deterministicmns"
"evo/chainhelper -> masternode/payments -> validation -> evo/chainhelper"
"evo/specialtxman -> validation -> evo/specialtxman"
"evo/chainhelper -> evo/specialtxman -> validation -> evo/chainhelper"
"evo/deterministicmns -> validationinterface -> evo/deterministicmns"
"logging -> util/system -> sync -> logging/timer -> logging"