Skip to content

Commit 2a90f74

Browse files
Merge #7339: refactor: drop circular dependency over validation <-> masternode/payment
c75e64a refactor: freed CMNPaymentsProcessor from global chain-params access (Konstantin Akimov) 4543169 refactor: drop dependency of masternode/payment on Chainstate [validation.h] (Konstantin Akimov) 7f2058e refactor: use helper MnRewardEra for GetMasternodePayment (Konstantin Akimov) 54ea2cc refactor: remove forward declaration of PlatformShare from creditpool (Konstantin Akimov) 94f8c33 refactor: move helper GetMasternodePayment to masternode/payments (Konstantin Akimov) ee838dc refactor: introduce new enum MnRewardEra to use in masternode/payment helpers (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented There's an exception for existing circular dependency in test/lint/lint-circular-dependencies.py: - `"masternode/payments -> validation -> masternode/payments",` ## What was done? - introduced new enum `MnRewardEra` to use in masternode/payment helpers - removed dependency of masternode/payment on CChainManager (validation.h) - removed dependency of masternode/payment on global Params() (chainparams.h) ## How Has This Been Tested? Run unit & functional tests; run linter `test/lint/lint-circular-dependencies.py` Please note, that 2 other circular dependencies always had existed but had been hidden behind `masternode/payment <-> validation`: ``` + "evo/deterministicmns -> evo/providertx -> validation -> masternode/payments -> evo/deterministicmns", + "governance/superblock -> validation -> masternode/payments -> governance/superblock", ``` ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: PastaPastaPasta: utACK c75e64a Tree-SHA512: c847ebdb6deb82085bb0893bdd9f852ab9109adc34623d2f98d97aa6f422edc9e8fa3b4ab4dab9f0c4ffac13c76600f8bbabb726e292e958971c80e202537a4b
2 parents abc5516 + c75e64a commit 2a90f74

10 files changed

Lines changed: 168 additions & 126 deletions

File tree

src/evo/chainhelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ CChainstateHelper::CChainstateHelper(CEvoDB& evodb, CDeterministicMNManager& dmn
2727
m_chainlocks{chainlocks},
2828
ehf_manager{std::make_unique<CMNHFManager>(evodb, chainman, qman)},
2929
superblocks{std::make_unique<governance::SuperblockManager>()},
30-
mn_payments{std::make_unique<CMNPaymentsProcessor>(dmnman, *superblocks, chainman, consensus_params)},
30+
mn_payments{std::make_unique<CMNPaymentsProcessor>(dmnman, *superblocks, consensus_params)},
3131
special_tx{std::make_unique<CSpecialTxProcessor>(*credit_pool_manager, dmnman, *ehf_manager, qblockman, qsnapman,
3232
chainman, consensus_params, chainlocks, qman)}
3333
{}

src/evo/creditpool.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <consensus/validation.h>
1515
#include <deploymentstatus.h>
1616
#include <logging.h>
17+
#include <masternode/payments.h>
1718
#include <node/blockstorage.h>
1819
#include <validation.h>
1920

@@ -24,9 +25,6 @@
2425

2526
using node::ReadBlockFromDisk;
2627

27-
// Forward declaration to prevent a new circular dependencies through masternode/payments.h
28-
CAmount PlatformShare(const CAmount masternodeReward);
29-
3028
static const std::string DB_CREDITPOOL_SNAPSHOT = "cpm_S";
3129

3230
static bool GetDataFromUnlockTx(const CTransaction& tx, CAmount& toUnlock, uint64_t& index, TxValidationState& state)
@@ -253,7 +251,7 @@ CCreditPoolDiff::CCreditPoolDiff(CCreditPool starter, const CBlockIndex* pindexP
253251

254252
if (DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_MN_RR)) {
255253
// If credit pool exists, it means v20 is activated
256-
platformReward = PlatformShare(GetMasternodePayment(pindexPrev->nHeight + 1, blockSubsidy, /*fV20Active=*/ true));
254+
platformReward = PlatformShare(GetMasternodePayment(pindexPrev->nHeight + 1, blockSubsidy, consensusParams, MnRewardEra::EvoReward));
257255
}
258256
}
259257

src/masternode/payments.cpp

Lines changed: 89 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <primitives/block.h>
1717
#include <script/standard.h>
1818
#include <tinyformat.h>
19-
#include <validation.h>
2019

2120
#include <cassert>
2221
#include <ranges>
@@ -30,20 +29,88 @@ CAmount PlatformShare(const CAmount reward)
3029
return platformReward;
3130
}
3231

32+
CAmount GetMasternodePayment(int nHeight, CAmount blockValue, const Consensus::Params& consensus_params, MnRewardEra era)
33+
{
34+
CAmount ret = blockValue/5; // start at 20%
35+
36+
const int nMNPIBlock = consensus_params.nMasternodePaymentsIncreaseBlock;
37+
const int nMNPIPeriod = consensus_params.nMasternodePaymentsIncreasePeriod;
38+
const int nReallocActivationHeight = consensus_params.BRRHeight;
39+
40+
// mainnet:
41+
if(nHeight > nMNPIBlock) ret += blockValue / 20; // 158000 - 25.0% - 2014-10-24
42+
if(nHeight > nMNPIBlock+(nMNPIPeriod* 1)) ret += blockValue / 20; // 175280 - 30.0% - 2014-11-25
43+
if(nHeight > nMNPIBlock+(nMNPIPeriod* 2)) ret += blockValue / 20; // 192560 - 35.0% - 2014-12-26
44+
if(nHeight > nMNPIBlock+(nMNPIPeriod* 3)) ret += blockValue / 40; // 209840 - 37.5% - 2015-01-26
45+
if(nHeight > nMNPIBlock+(nMNPIPeriod* 4)) ret += blockValue / 40; // 227120 - 40.0% - 2015-02-27
46+
if(nHeight > nMNPIBlock+(nMNPIPeriod* 5)) ret += blockValue / 40; // 244400 - 42.5% - 2015-03-30
47+
if(nHeight > nMNPIBlock+(nMNPIPeriod* 6)) ret += blockValue / 40; // 261680 - 45.0% - 2015-05-01
48+
if(nHeight > nMNPIBlock+(nMNPIPeriod* 7)) ret += blockValue / 40; // 278960 - 47.5% - 2015-06-01
49+
if(nHeight > nMNPIBlock+(nMNPIPeriod* 9)) ret += blockValue / 40; // 313520 - 50.0% - 2015-08-03
50+
51+
if (nHeight < nReallocActivationHeight) {
52+
// Block Reward Realocation is not activated yet, nothing to do
53+
return ret;
54+
}
55+
56+
int nSuperblockCycle = consensus_params.nSuperblockCycle;
57+
// Actual realocation starts in the cycle next to one activation happens in
58+
int nReallocStart = nReallocActivationHeight - nReallocActivationHeight % nSuperblockCycle + nSuperblockCycle;
59+
60+
if (nHeight < nReallocStart) {
61+
// Activated but we have to wait for the next cycle to start realocation, nothing to do
62+
return ret;
63+
}
64+
65+
if (era != MnRewardEra::Classic) {
66+
// Once MNRewardReallocated activates, block reward is 80% of block subsidy (+ tx fees) since treasury is 20%
67+
// Since the MN reward needs to be equal to 60% of the block subsidy (according to the proposal), MN reward is set to 75% of the block reward.
68+
// Previous reallocation periods are dropped.
69+
return blockValue * 3 / 4;
70+
}
71+
72+
// Periods used to reallocate the masternode reward from 50% to 60%
73+
static std::vector<int> vecPeriods{
74+
513, // Period 1: 51.3%
75+
526, // Period 2: 52.6%
76+
533, // Period 3: 53.3%
77+
540, // Period 4: 54%
78+
546, // Period 5: 54.6%
79+
552, // Period 6: 55.2%
80+
557, // Period 7: 55.7%
81+
562, // Period 8: 56.2%
82+
567, // Period 9: 56.7%
83+
572, // Period 10: 57.2%
84+
577, // Period 11: 57.7%
85+
582, // Period 12: 58.2%
86+
585, // Period 13: 58.5%
87+
588, // Period 14: 58.8%
88+
591, // Period 15: 59.1%
89+
594, // Period 16: 59.4%
90+
597, // Period 17: 59.7%
91+
599, // Period 18: 59.9%
92+
600 // Period 19: 60%
93+
};
94+
95+
int nReallocCycle = nSuperblockCycle * 3;
96+
int nCurrentPeriod = std::min<int>((nHeight - nReallocStart) / nReallocCycle, vecPeriods.size() - 1);
97+
98+
return static_cast<CAmount>(blockValue * vecPeriods[nCurrentPeriod] / 1000);
99+
}
100+
33101
[[nodiscard]] bool CMNPaymentsProcessor::GetBlockTxOuts(const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward,
34-
std::vector<CTxOut>& voutMasternodePaymentsRet)
102+
MnRewardEra era, std::vector<CTxOut>& voutMasternodePaymentsRet)
35103
{
36104
voutMasternodePaymentsRet.clear();
37105

38106
const int nBlockHeight = pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1;
39107

40-
bool fV20Active = DeploymentActiveAfter(pindexPrev, m_consensus_params, Consensus::DEPLOYMENT_V20);
41-
CAmount masternodeReward = GetMasternodePayment(nBlockHeight, blockSubsidy + feeReward, fV20Active);
108+
CAmount masternodeReward = GetMasternodePayment(nBlockHeight, blockSubsidy + feeReward, m_consensus_params, era);
42109

43110
// Credit Pool doesn't exist before V20. If any part of reward will re-allocated to credit pool before v20
44111
// activation these fund will be just permanently lost. Applicable for devnets, regtest, testnet
45-
if (fV20Active && DeploymentActiveAfter(pindexPrev, m_consensus_params, Consensus::DEPLOYMENT_MN_RR)) {
46-
CAmount masternodeSubsidyReward = GetMasternodePayment(nBlockHeight, blockSubsidy, fV20Active);
112+
if (era == MnRewardEra::EvoReward) {
113+
CAmount masternodeSubsidyReward = GetMasternodePayment(nBlockHeight, blockSubsidy, m_consensus_params, era);
47114
const CAmount platformReward = PlatformShare(masternodeSubsidyReward);
48115
masternodeReward -= platformReward;
49116

@@ -96,12 +163,12 @@ CAmount PlatformShare(const CAmount reward)
96163
* Get masternode payment tx outputs
97164
*/
98165
[[nodiscard]] bool CMNPaymentsProcessor::GetMasternodeTxOuts(const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward,
99-
std::vector<CTxOut>& voutMasternodePaymentsRet)
166+
MnRewardEra era, std::vector<CTxOut>& voutMasternodePaymentsRet)
100167
{
101168
// make sure it's not filled yet
102169
voutMasternodePaymentsRet.clear();
103170

104-
if(!GetBlockTxOuts(pindexPrev, blockSubsidy, feeReward, voutMasternodePaymentsRet)) {
171+
if(!GetBlockTxOuts(pindexPrev, blockSubsidy, feeReward, era, voutMasternodePaymentsRet)) {
105172
LogPrintf("CMNPaymentsProcessor::%s -- ERROR Failed to get payee\n", __func__);
106173
return false;
107174
}
@@ -117,7 +184,7 @@ CAmount PlatformShare(const CAmount reward)
117184
}
118185

119186
[[nodiscard]] bool CMNPaymentsProcessor::IsTransactionValid(const CTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy,
120-
const CAmount feeReward)
187+
const CAmount feeReward, MnRewardEra era)
121188
{
122189
const int nBlockHeight = pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1;
123190
if (!DeploymentDIP0003Enforced(nBlockHeight, m_consensus_params)) {
@@ -126,7 +193,7 @@ CAmount PlatformShare(const CAmount reward)
126193
}
127194

128195
std::vector<CTxOut> voutMasternodePayments;
129-
if (!GetBlockTxOuts(pindexPrev, blockSubsidy, feeReward, voutMasternodePayments)) {
196+
if (!GetBlockTxOuts(pindexPrev, blockSubsidy, feeReward, era, voutMasternodePayments)) {
130197
LogPrintf("CMNPaymentsProcessor::%s -- ERROR! Failed to get payees for block at height %s\n", __func__, nBlockHeight);
131198
return true;
132199
}
@@ -193,7 +260,7 @@ CAmount PlatformShare(const CAmount reward)
193260
* - Other blocks are 10% lower in outgoing value, so in total, no extra coins are created
194261
* - When non-superblocks are detected, the normal schedule should be maintained
195262
*/
196-
bool CMNPaymentsProcessor::IsBlockValueValid(const CBlock& block, const CBlockIndex* pindexPrev, const CAmount blockReward, std::string& strErrorRet, const bool check_superblock)
263+
bool CMNPaymentsProcessor::IsBlockValueValid(const CChain& active_chain, const CBlock& block, const CBlockIndex* pindexPrev, const CAmount blockReward, std::string& strErrorRet, SuperBlockCheckType check_superblock)
197264
{
198265
const int nBlockHeight = pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1;
199266
bool isBlockRewardValueMet = (block.vtx[0]->GetValueOut() <= blockReward);
@@ -214,7 +281,7 @@ bool CMNPaymentsProcessor::IsBlockValueValid(const CBlock& block, const CBlockIn
214281

215282
LogPrint(BCLog::MNPAYMENTS, "block.vtx[0]->GetValueOut() %lld <= blockReward %lld\n", block.vtx[0]->GetValueOut(), blockReward);
216283

217-
CAmount nSuperblockMaxValue = blockReward + CSuperblock::GetPaymentsLimit(m_chainman.ActiveChain(), nBlockHeight);
284+
CAmount nSuperblockMaxValue = blockReward + CSuperblock::GetPaymentsLimit(active_chain, nBlockHeight);
218285
bool isSuperblockMaxValueMet = (block.vtx[0]->GetValueOut() <= nSuperblockMaxValue);
219286

220287
LogPrint(BCLog::GOBJECT, "block.vtx[0]->GetValueOut() %lld <= nSuperblockMaxValue %lld\n", block.vtx[0]->GetValueOut(), nSuperblockMaxValue);
@@ -242,7 +309,7 @@ bool CMNPaymentsProcessor::IsBlockValueValid(const CBlock& block, const CBlockIn
242309
return true;
243310
}
244311

245-
if (!check_superblock) return true;
312+
if (check_superblock == SuperBlockCheckType::NoCheck) return true;
246313

247314
// we are synced and possibly on a superblock now
248315

@@ -259,8 +326,8 @@ bool CMNPaymentsProcessor::IsBlockValueValid(const CBlock& block, const CBlockIn
259326
}
260327

261328
// this actually also checks for correct payees and not only amount
262-
const bool is_v24{DeploymentActiveAfter(pindexPrev, m_chainman, Consensus::DEPLOYMENT_V24)};
263-
if (!m_superblocks.IsValidSuperblock(m_chainman.ActiveChain(), tip_mn_list, *block.vtx[0], nBlockHeight, blockReward, is_v24)) {
329+
const bool is_v24{check_superblock == SuperBlockCheckType::DisallowDuplicates};
330+
if (!m_superblocks.IsValidSuperblock(active_chain, tip_mn_list, *block.vtx[0], nBlockHeight, blockReward, is_v24)) {
264331
// triggered but invalid? that's weird
265332
LogPrintf("CMNPaymentsProcessor::%s -- ERROR! Invalid superblock detected at height %d: %s", __func__, nBlockHeight, block.vtx[0]->ToString()); /* Continued */
266333
// should NOT allow invalid superblocks, when superblocks are enabled
@@ -272,12 +339,12 @@ bool CMNPaymentsProcessor::IsBlockValueValid(const CBlock& block, const CBlockIn
272339
return true;
273340
}
274341

275-
bool CMNPaymentsProcessor::IsBlockPayeeValid(const CTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward, const bool check_superblock)
342+
bool CMNPaymentsProcessor::IsBlockPayeeValid(const CChain& active_chain, const CTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward, MnRewardEra era, SuperBlockCheckType check_superblock)
276343
{
277344
const int nBlockHeight = pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1;
278345

279346
// Check for correct masternode payment
280-
if (IsTransactionValid(txNew, pindexPrev, blockSubsidy, feeReward)) {
347+
if (IsTransactionValid(txNew, pindexPrev, blockSubsidy, feeReward, era)) {
281348
LogPrint(BCLog::MNPAYMENTS, "CMNPaymentsProcessor::%s -- Valid masternode payment at height %d: %s", __func__, nBlockHeight, txNew.ToString()); /* Continued */
282349
} else {
283350
LogPrintf("CMNPaymentsProcessor::%s -- ERROR! Invalid masternode payment detected at height %d: %s", __func__, nBlockHeight, txNew.ToString()); /* Continued */
@@ -301,12 +368,12 @@ bool CMNPaymentsProcessor::IsBlockPayeeValid(const CTransaction& txNew, const CB
301368
}
302369

303370
// superblocks started
304-
if (!check_superblock) return true;
371+
if (check_superblock == SuperBlockCheckType::NoCheck) return true;
305372

306373
const auto tip_mn_list = m_dmnman.GetListAtChainTip();
307-
const bool is_v24{DeploymentActiveAfter(pindexPrev, m_chainman, Consensus::DEPLOYMENT_V24)};
374+
const bool is_v24{check_superblock == SuperBlockCheckType::DisallowDuplicates};
308375
if (m_superblocks.IsSuperblockTriggered(tip_mn_list, nBlockHeight)) {
309-
if (m_superblocks.IsValidSuperblock(m_chainman.ActiveChain(), tip_mn_list, txNew, nBlockHeight,
376+
if (m_superblocks.IsValidSuperblock(active_chain, tip_mn_list, txNew, nBlockHeight,
310377
blockSubsidy + feeReward, is_v24)) {
311378
LogPrint(BCLog::GOBJECT, "CMNPaymentsProcessor::%s -- Valid superblock at height %d: %s", /* Continued */
312379
__func__, nBlockHeight, txNew.ToString());
@@ -325,7 +392,7 @@ bool CMNPaymentsProcessor::IsBlockPayeeValid(const CTransaction& txNew, const CB
325392
}
326393

327394
void CMNPaymentsProcessor::FillBlockPayments(CMutableTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward,
328-
std::vector<CTxOut>& voutMasternodePaymentsRet, std::vector<CTxOut>& voutSuperblockPaymentsRet)
395+
MnRewardEra era, std::vector<CTxOut>& voutMasternodePaymentsRet, std::vector<CTxOut>& voutSuperblockPaymentsRet)
329396
{
330397
int nBlockHeight = pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1;
331398

@@ -336,7 +403,7 @@ void CMNPaymentsProcessor::FillBlockPayments(CMutableTransaction& txNew, const C
336403
m_superblocks.GetSuperblockPayments(tip_mn_list, nBlockHeight, voutSuperblockPaymentsRet);
337404
}
338405

339-
if (!GetMasternodeTxOuts(pindexPrev, blockSubsidy, feeReward, voutMasternodePaymentsRet)) {
406+
if (!GetMasternodeTxOuts(pindexPrev, blockSubsidy, feeReward, era, voutMasternodePaymentsRet)) {
340407
LogPrint(BCLog::MNPAYMENTS, "CMNPaymentsProcessor::%s -- No masternode to pay (MN list probably empty)\n", __func__);
341408
}
342409

src/masternode/payments.h

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
class CBlock;
1414
class CBlockIndex;
15+
class CChain;
1516
class CDeterministicMNManager;
16-
class ChainstateManager;
1717
class CTransaction;
1818
class CTxOut;
1919

@@ -30,37 +30,57 @@ namespace Consensus { struct Params; }
3030
*/
3131
CAmount PlatformShare(const CAmount masternodeReward);
3232

33+
/**
34+
* Masternode reward era for a given block, gating how the reward is computed.
35+
* Each era implies the previous one: EvoReward is only reachable once CreditPool
36+
* (V20) is active, so the ordering encodes that invariant. The era is computed by
37+
* the caller (which owns the block context) and passed in, keeping this module free
38+
* of deployment dependencies. Note this is orthogonal to DIP0003 enforcement, which
39+
* gates whether payees are validated at all and is handled separately.
40+
*/
41+
enum class MnRewardEra {
42+
Classic, // historical reward schedule, no credit pool
43+
CreditPool, // V20: credit pool active, no platform reallocation yet
44+
EvoReward, // MN_RR: platform share is reallocated from the masternode reward
45+
};
46+
47+
enum class SuperBlockCheckType {
48+
NoCheck, // for chainlocked blocks or during sync
49+
AllowDuplicates,
50+
DisallowDuplicates,
51+
};
52+
53+
CAmount GetMasternodePayment(int nHeight, CAmount blockValue, const Consensus::Params& consensus_params, MnRewardEra era);
54+
3355
class CMNPaymentsProcessor
3456
{
3557
private:
3658
CDeterministicMNManager& m_dmnman;
3759
governance::SuperblockManager& m_superblocks;
38-
const ChainstateManager& m_chainman;
3960
const Consensus::Params& m_consensus_params;
4061

4162
private:
4263
[[nodiscard]] bool GetBlockTxOuts(const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward,
43-
std::vector<CTxOut>& voutMasternodePaymentsRet);
64+
MnRewardEra era, std::vector<CTxOut>& voutMasternodePaymentsRet);
4465
[[nodiscard]] bool GetMasternodeTxOuts(const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward,
45-
std::vector<CTxOut>& voutMasternodePaymentsRet);
66+
MnRewardEra era, std::vector<CTxOut>& voutMasternodePaymentsRet);
4667
[[nodiscard]] bool IsTransactionValid(const CTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy,
47-
const CAmount feeReward);
68+
const CAmount feeReward, MnRewardEra era);
4869
[[nodiscard]] bool IsOldBudgetBlockValueValid(const CBlock& block, const int nBlockHeight, const CAmount blockReward, std::string& strErrorRet);
4970

5071
public:
5172
explicit CMNPaymentsProcessor(CDeterministicMNManager& dmnman, governance::SuperblockManager& superblocks,
52-
const ChainstateManager& chainman, const Consensus::Params& consensus_params) :
73+
const Consensus::Params& consensus_params) :
5374
m_dmnman{dmnman},
5475
m_superblocks{superblocks},
55-
m_chainman{chainman},
5676
m_consensus_params{consensus_params}
5777
{
5878
}
5979

60-
bool IsBlockValueValid(const CBlock& block, const CBlockIndex* pindexPrev, const CAmount blockReward, std::string& strErrorRet, const bool check_superblock);
61-
bool IsBlockPayeeValid(const CTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward, const bool check_superblock);
80+
bool IsBlockValueValid(const CChain& active_chain, const CBlock& block, const CBlockIndex* pindexPrev, const CAmount blockReward, std::string& strErrorRet, SuperBlockCheckType check_superblock);
81+
bool IsBlockPayeeValid(const CChain& active_chain, const CTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward, MnRewardEra era, SuperBlockCheckType check_superblock);
6282
void FillBlockPayments(CMutableTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward,
63-
std::vector<CTxOut>& voutMasternodePaymentsRet, std::vector<CTxOut>& voutSuperblockPaymentsRet);
83+
MnRewardEra era, std::vector<CTxOut>& voutMasternodePaymentsRet, std::vector<CTxOut>& voutSuperblockPaymentsRet);
6484
};
6585

6686
#endif // BITCOIN_MASTERNODE_PAYMENTS_H

src/node/miner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
319319

320320
// Update coinbase transaction with additional info about masternode and governance payments,
321321
// get some info back to pass to getblocktemplate
322-
m_chain_helper.mn_payments->FillBlockPayments(coinbaseTx, pindexPrev, blockSubsidy, nFees, pblocktemplate->voutMasternodePayments, pblocktemplate->voutSuperblockPayments);
322+
const MnRewardEra mn_reward_era{GetMnRewardEraAfter(pindexPrev, m_chainstate.m_chainman)};
323+
m_chain_helper.mn_payments->FillBlockPayments(coinbaseTx, pindexPrev, blockSubsidy, nFees, mn_reward_era, pblocktemplate->voutMasternodePayments, pblocktemplate->voutSuperblockPayments);
323324

324325
pblock->vtx[0] = MakeTransactionRef(std::move(coinbaseTx));
325326
pblocktemplate->vTxFees[0] = -nFees;

0 commit comments

Comments
 (0)