Skip to content

Commit 16455e0

Browse files
committed
[BUG] Miner not paying valid finalized budget if <20 active masternodes
Verifier: (`CheckBlock` --> `IsBlockPayeeValid` --> `IsBudgetPaymentBlock`) expects a payment to a budget even with the case of N<20 active masternodes on the network, provided that all N voted on the finalized budget (the threshold is N-1). Also remove the extra call to `IsBudgetPaymentBlock` directly from `FillBlockPayee` (it is already called by `CBudgetManager::FillBlockPayee` --> `GetPayeeAndAmount`).
1 parent dc7eb08 commit 16455e0

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/budget/budgetmanager.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -401,17 +401,12 @@ int CBudgetManager::GetHighestVoteCount(int chainHeight) const
401401

402402
bool CBudgetManager::GetPayeeAndAmount(int chainHeight, CScript& payeeRet, CAmount& nAmountRet) const
403403
{
404-
const CFinalizedBudget* pfb = GetBudgetWithHighestVoteCount(chainHeight);
405-
if (!pfb) return false;
406-
407-
// Check that there are enough votes
408-
int mnCount = mnodeman.CountEnabled(ActiveProtocol());
409-
int nFivePercent = mnCount / 20;
410-
if ((nFivePercent == 0 && !(Params().IsRegTestNet() && mnCount > 0) ) ||
411-
pfb->GetVoteCount() < nFivePercent)
404+
int nCountThreshold;
405+
if (!IsBudgetPaymentBlock(chainHeight, nCountThreshold))
412406
return false;
413407

414-
return pfb->GetPayeeAndAmount(chainHeight, payeeRet, nAmountRet);
408+
const CFinalizedBudget* pfb = GetBudgetWithHighestVoteCount(chainHeight);
409+
return pfb && pfb->GetPayeeAndAmount(chainHeight, payeeRet, nAmountRet) && pfb->GetVoteCount() > nCountThreshold;
415410
}
416411

417412
bool CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, const int nHeight, bool fProofOfStake) const

src/masternode-payments.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,9 @@ void FillBlockPayee(CMutableTransaction& txNew, const int nHeight, bool fProofOf
295295
{
296296
if (nHeight == 0) return;
297297

298-
if (!sporkManager.IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) || // if superblocks are not enabled
299-
!g_budgetman.IsBudgetPaymentBlock(nHeight) || // or this is not a superblock
300-
!g_budgetman.FillBlockPayee(txNew, nHeight, fProofOfStake) ) { // or there's no budget with enough votes
301-
// pay a masternode
298+
if (!sporkManager.IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) || // if superblocks are not enabled
299+
!g_budgetman.FillBlockPayee(txNew, nHeight, fProofOfStake) ) { // or this is not a superblock,
300+
// ... or there's no budget with enough votes, then pay a masternode
302301
masternodePayments.FillBlockPayee(txNew, nHeight, fProofOfStake);
303302
}
304303
}

0 commit comments

Comments
 (0)