fix: use proper pindex/pindex->pprev in credit pool code during v20/mn_rr activations

This commit is contained in:
Konstantin Akimov 2023-12-04 16:52:09 +07:00 committed by PastaPastaPasta
parent f3d2f2da26
commit bacaa805ea
3 changed files with 10 additions and 9 deletions

View File

@ -218,16 +218,16 @@ CCreditPoolManager::CCreditPoolManager(CEvoDB& _evoDb)
{
}
CCreditPoolDiff::CCreditPoolDiff(CCreditPool starter, const CBlockIndex *pindex, const Consensus::Params& consensusParams, const CAmount blockSubsidy) :
CCreditPoolDiff::CCreditPoolDiff(CCreditPool starter, const CBlockIndex *pindexPrev, const Consensus::Params& consensusParams, const CAmount blockSubsidy) :
pool(std::move(starter)),
pindex(pindex),
pindexPrev(pindexPrev),
params(consensusParams)
{
assert(pindex);
assert(pindexPrev);
if (llmq::utils::IsMNRewardReallocationActive(pindex)) {
if (llmq::utils::IsMNRewardReallocationActive(pindexPrev)) {
// We consider V20 active if mn_rr is active
platformReward = MasternodePayments::PlatformShare(GetMasternodePayment(pindex->nHeight, blockSubsidy, /*fV20Active=*/ true));
platformReward = MasternodePayments::PlatformShare(GetMasternodePayment(pindexPrev->nHeight + 1, blockSubsidy, /*fV20Active=*/ true));
}
}
@ -274,7 +274,7 @@ bool CCreditPoolDiff::ProcessLockUnlockTransaction(const CTransaction& tx, TxVal
if (tx.nVersion != 3) return true;
if (tx.nType != TRANSACTION_ASSET_LOCK && tx.nType != TRANSACTION_ASSET_UNLOCK) return true;
if (!CheckAssetLockUnlockTx(tx, pindex, pool.indexes, state)) {
if (!CheckAssetLockUnlockTx(tx, pindexPrev, pool.indexes, state)) {
// pass the state returned by the function above
return false;
}

View File

@ -70,10 +70,10 @@ private:
CAmount sessionUnlocked{0};
CAmount platformReward{0};
const CBlockIndex *pindex{nullptr};
const CBlockIndex *pindexPrev{nullptr};
const Consensus::Params& params;
public:
explicit CCreditPoolDiff(CCreditPool starter, const CBlockIndex *pindex,
explicit CCreditPoolDiff(CCreditPool starter, const CBlockIndex *pindexPrev,
const Consensus::Params& consensusParams,
const CAmount blockSubsidy);

View File

@ -6,6 +6,7 @@
#include <chainparams.h>
#include <consensus/validation.h>
#include <deploymentstatus.h>
#include <evo/cbtx.h>
#include <evo/creditpool.h>
#include <evo/deterministicmns.h>
@ -276,7 +277,7 @@ bool CheckCreditPoolDiffForBlock(const CBlock& block, const CBlockIndex* pindex,
const CAmount blockSubsidy, BlockValidationState& state)
{
try {
if (!llmq::utils::IsV20Active(pindex)) return true;
if (!DeploymentActiveAt(*pindex, consensusParams, Consensus::DEPLOYMENT_V20)) return true;
auto creditPoolDiff = GetCreditPoolDiffForBlock(block, pindex->pprev, consensusParams, blockSubsidy, state);
if (!creditPoolDiff.has_value()) return false;