Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ bool IsBlockValueValid(int nHeight, CAmount& nExpectedValue, CAmount nMinted, CA
}
}

return nMinted >= 0 && nMinted <= nExpectedValue;
if (nMinted < 0 && consensus.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_V5_3)) {
return false;
}

return nMinted <= nExpectedValue;
}

bool IsBlockPayeeValid(const CBlock& block, const CBlockIndex* pindexPrev)
Expand Down Expand Up @@ -328,7 +332,6 @@ bool CMasternodePayments::GetLegacyMasternodeTxOut(int nHeight, std::vector<CTxO
CScript payee;
if (!GetBlockPayee(nHeight, payee)) {
//no masternode detected
const Consensus::Params& consensus = Params().GetConsensus();
const uint256& hash = mnodeman.GetHashAtHeight(nHeight - 1);
MasternodeRef winningNode = mnodeman.GetCurrentMasterNode(hash);
if (winningNode) {
Expand Down
14 changes: 11 additions & 3 deletions src/test/budget_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ BOOST_FIXTURE_TEST_CASE(block_value, TestnetSetup)
CAmount nExpectedRet = nBlockReward;
CAmount nBudgetAmtRet = 0;

// under-minting
BOOST_CHECK(!IsBlockValueValid(nHeight, nExpectedRet, -1, nBudgetAmtRet));

// regular block
BOOST_CHECK(IsBlockValueValid(nHeight, nExpectedRet, 0, nBudgetAmtRet));
BOOST_CHECK(IsBlockValueValid(nHeight, nExpectedRet, nBlockReward-1, nBudgetAmtRet));
Expand Down Expand Up @@ -132,6 +129,17 @@ BOOST_FIXTURE_TEST_CASE(block_value, TestnetSetup)
BOOST_CHECK_EQUAL(nBudgetAmtRet, 0);
}

BOOST_FIXTURE_TEST_CASE(block_value_undermint, RegTestingSetup)
{
int nHeight = 100;
CAmount nExpectedRet = GetBlockValue(nHeight);
CAmount nBudgetAmtRet = 0;
// under-minting blocks are invalid after v5.3
BOOST_CHECK(IsBlockValueValid(nHeight, nExpectedRet, -1, nBudgetAmtRet));
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_V5_3, Consensus::NetworkUpgrade::ALWAYS_ACTIVE);
BOOST_CHECK(!IsBlockValueValid(nHeight, nExpectedRet, -1, nBudgetAmtRet));
}

/**
* 1) Create two proposals and two budget finalizations with a different proposal payment order:
BudA pays propA and propB, BudB pays propB and propA.
Expand Down