17
17
#include < llmq/blockprocessor.h>
18
18
#include < llmq/commitment.h>
19
19
#include < primitives/block.h>
20
+ #include < validation.h>
20
21
21
- static bool CheckSpecialTxInner (CDeterministicMNManager& dmnman, const llmq::CQuorumManager& qman, const CTransaction& tx, const CBlockIndex* pindexPrev,
22
- const CCoinsViewCache& view, const std::optional<CRangesSet>& indexes, bool check_sigs, TxValidationState& state)
22
+ static bool CheckSpecialTxInner (CDeterministicMNManager& dmnman, const ChainstateManager& chainman, const llmq::CQuorumManager& qman, const CTransaction& tx,
23
+ const CBlockIndex* pindexPrev, const CCoinsViewCache& view, const std::optional<CRangesSet>& indexes, bool check_sigs,
24
+ TxValidationState& state)
23
25
{
24
26
AssertLockHeld (cs_main);
25
27
@@ -54,7 +56,7 @@ static bool CheckSpecialTxInner(CDeterministicMNManager& dmnman, const llmq::CQu
54
56
if (!DeploymentActiveAfter (pindexPrev, consensusParams, Consensus::DEPLOYMENT_V20)) {
55
57
return state.Invalid (TxValidationResult::TX_CONSENSUS, " assetlocks-before-v20" );
56
58
}
57
- return CheckAssetLockUnlockTx (qman, tx, pindexPrev, indexes, state);
59
+ return CheckAssetLockUnlockTx (chainman. m_blockman , qman, tx, pindexPrev, indexes, state);
58
60
case TRANSACTION_ASSET_UNLOCK:
59
61
if (Params ().NetworkIDString () == CBaseChainParams::REGTEST && !DeploymentActiveAfter (pindexPrev, consensusParams, Consensus::DEPLOYMENT_V20)) {
60
62
// 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
63
65
if (Params ().NetworkIDString () != CBaseChainParams::REGTEST && !DeploymentActiveAfter (pindexPrev, consensusParams, Consensus::DEPLOYMENT_MN_RR)) {
64
66
return state.Invalid (TxValidationResult::TX_CONSENSUS, " assetunlocks-before-mn_rr" );
65
67
}
66
- return CheckAssetLockUnlockTx (qman, tx, pindexPrev, indexes, state);
68
+ return CheckAssetLockUnlockTx (chainman. m_blockman , qman, tx, pindexPrev, indexes, state);
67
69
}
68
70
} catch (const std::exception & e) {
69
71
LogPrintf (" %s -- failed: %s\n " , __func__, e.what ());
@@ -76,7 +78,7 @@ static bool CheckSpecialTxInner(CDeterministicMNManager& dmnman, const llmq::CQu
76
78
bool CSpecialTxProcessor::CheckSpecialTx (const CTransaction& tx, const CBlockIndex* pindexPrev, const CCoinsViewCache& view, bool check_sigs, TxValidationState& state)
77
79
{
78
80
AssertLockHeld (cs_main);
79
- return CheckSpecialTxInner (m_dmnman, m_qman, tx, pindexPrev, view, std::nullopt, check_sigs, state);
81
+ return CheckSpecialTxInner (m_dmnman, m_chainman, m_qman, tx, pindexPrev, view, std::nullopt, check_sigs, state);
80
82
}
81
83
82
84
[[nodiscard]] bool CSpecialTxProcessor::ProcessSpecialTx (const CTransaction& tx, const CBlockIndex* pindex, TxValidationState& state)
@@ -155,7 +157,7 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB
155
157
TxValidationState tx_state;
156
158
// At this moment CheckSpecialTx() and ProcessSpecialTx() may fail by 2 possible ways:
157
159
// consensus failures and "TX_BAD_SPECIAL"
158
- if (!CheckSpecialTxInner (m_dmnman, m_qman, *ptr_tx, pindex->pprev , view, creditPool.indexes , fCheckCbTxMerkleRoots , tx_state)) {
160
+ if (!CheckSpecialTxInner (m_dmnman, m_chainman, m_qman, *ptr_tx, pindex->pprev , view, creditPool.indexes , fCheckCbTxMerkleRoots , tx_state)) {
159
161
assert (tx_state.GetResult () == TxValidationResult::TX_CONSENSUS || tx_state.GetResult () == TxValidationResult::TX_BAD_SPECIAL);
160
162
return state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, tx_state.GetRejectReason (),
161
163
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
273
275
274
276
bool CSpecialTxProcessor::CheckCreditPoolDiffForBlock (const CBlock& block, const CBlockIndex* pindex, const CAmount blockSubsidy, BlockValidationState& state)
275
277
{
278
+ AssertLockHeld (cs_main);
279
+
276
280
try {
277
281
if (!DeploymentActiveAt (*pindex, m_consensus_params, Consensus::DEPLOYMENT_V20)) return true ;
278
282
279
- auto creditPoolDiff = GetCreditPoolDiffForBlock (m_cpoolman, m_qman, block, pindex->pprev , m_consensus_params, blockSubsidy, state);
283
+ auto creditPoolDiff = GetCreditPoolDiffForBlock (m_cpoolman, m_chainman. m_blockman , m_qman, block, pindex->pprev , m_consensus_params, blockSubsidy, state);
280
284
if (!creditPoolDiff.has_value ()) return false ;
281
285
282
286
// If we get there we have v20 activated and credit pool amount must be included in block CbTx
0 commit comments