Skip to content

Commit 5aba960

Browse files
committed
some debug changes (WIP)
1 parent bd5563f commit 5aba960

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

src/evo/creditpool.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,9 @@ bool CCreditPoolDiff::setTarget(const CTransaction& tx, TxValidationState& state
272272
CAmount blockReward = 0;
273273
for (const CTxOut& txout : tx.vout) {
274274
blockReward += txout.nValue;
275+
LogPrintf("CreditPool: next output in tx: %lld\n", txout.nValue);
275276
}
276-
masternodeReward = GetMasternodePayment(cbTx.nHeight, blockReward, params.BRRHeight);
277+
masternodeReward = 0.375 * GetMasternodePayment(cbTx.nHeight, blockReward, params.BRRHeight);
277278
LogPrintf("CreditPool: set target to %lld with MN reward %lld\n", *targetLocked, masternodeReward);
278279

279280
return true;

src/evo/deterministicmns.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ std::vector<CDeterministicMNCPtr> CDeterministicMNList::GetProjectedMNPayees(int
224224

225225
auto remaining_hpmn_payments = 0;
226226
CDeterministicMNCPtr hpmn_to_be_skipped = nullptr;
227-
bool isMNRewardReallocated = llmq::utils::IsMNRewardReallocationActive(pIndex);
227+
// TODO GetProjectedMNPayees should work correctly for v20+ too - no quadruple Evo MN
228+
bool isMNRewardReallocated = false ; // llmq::utils::IsMNRewardReallocationActive(pIndex);
228229
ForEachMNShared(true, [&](const CDeterministicMNCPtr& dmn) {
229230
if (dmn->pdmnState->nLastPaidHeight == nHeight) {
230231
// We found the last MN Payee.

src/masternode/payments.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,15 +280,18 @@ bool CMasternodePayments::GetBlockTxOuts(int nBlockHeight, CAmount blockReward,
280280

281281
CAmount masternodeReward = GetMasternodePayment(nBlockHeight, blockReward, Params().GetConsensus().BRRHeight);
282282

283-
bool fMNRewardReallocated = llmq::utils::IsMNRewardReallocationActive(::ChainActive().Tip());
283+
const CBlockIndex* pindex = WITH_LOCK(cs_main, return ::ChainActive()[nBlockHeight - 1]);
284+
bool fMNRewardReallocated = llmq::utils::IsMNRewardReallocationActive(pindex);
284285

285286
if (fMNRewardReallocated) {
286-
LogPrintf("CMasternodePayments::%s -- MN reward %lld reallocated to credit pool\n", __func__, masternodeReward);
287+
constexpr double platformShare = 0.375;
288+
CAmount platformReward = masternodeReward * platformShare;
289+
assert(MoneyRange(platformReward));
290+
masternodeReward -= platformReward;
291+
LogPrintf("CMasternodePayments::%s -- MN reward %lld goes to credit pool, %lld to masternode\n", __func__, platformReward, masternodeReward);
287292
voutMasternodePaymentsRet.emplace_back(masternodeReward, CScript() << OP_RETURN);
288-
return true;
289293
}
290294

291-
const CBlockIndex* pindex = WITH_LOCK(cs_main, return ::ChainActive()[nBlockHeight - 1]);
292295
auto dmnPayee = deterministicMNManager->GetListForBlock(pindex).GetMNPayee(pindex);
293296
if (!dmnPayee) {
294297
return false;

src/miner.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,21 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
234234
assert(creditPoolDiff);
235235

236236
bool fMNRewardReallocated = llmq::utils::IsMNRewardReallocationActive(pindexPrev);
237-
if (fMNRewardReallocated) {
237+
if (true || fMNRewardReallocated) {
238238
if (!CMasternodePayments::GetMasternodeTxOuts(nHeight, blockReward, pblocktemplate->voutMasternodePayments)) {
239-
LogPrint(BCLog::MNPAYMENTS, "%s -- no masternode to pay (MN list probably empty)\n", __func__);
239+
// LogPrint(BCLog::MNPAYMENTS, "%s -- no masternode to pay (MN list probably empty)\n", __func__);
240240
}
241+
LogPrintf("CreateNewBlock() %d realloc: %lld\n", fMNRewardReallocated, blockReward * 0.375);
242+
if (pblocktemplate->voutMasternodePayments.size() > 2) {
243+
/*
241244
for (const auto& txout : pblocktemplate->voutMasternodePayments) {
242245
LogPrintf("CreateNewBlock() add MN reward %lld to credit pool\n", txout.nValue);
243246
creditPoolDiff->addRewardRealloced(txout.nValue);
244247
}
248+
*/
249+
LogPrintf("CreateNewBlock() realloc: %lld\n", blockReward * 0.375);
250+
creditPoolDiff->addRewardRealloced(blockReward * 0.375);
251+
}
245252
}
246253
cbTx.assetLockedAmount = creditPoolDiff->getTotalLocked();
247254
}

src/test/block_reward_reallocation_tests.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
#include <llmq/blockprocessor.h>
2525
#include <llmq/chainlocks.h>
2626
#include <llmq/context.h>
27+
#include <llmq/utils.h>
2728
#include <llmq/instantsend.h>
2829
#include <util/enumerate.h>
2930
#include <util/irange.h>
3031

3132
#include <boost/test/unit_test.hpp>
3233

34+
#include <logging.h>
3335
#include <map>
3436
#include <vector>
3537

@@ -248,6 +250,11 @@ BOOST_FIXTURE_TEST_CASE(block_reward_reallocation, TestChainBRRBeforeActivationS
248250
for ([[maybe_unused]] auto i : irange::range(10)) {
249251
for ([[maybe_unused]] auto k : irange::range(10)) {
250252
CreateAndProcessBlock({}, coinbaseKey);
253+
bool isv19Active = llmq::utils::IsV19Active(::ChainActive().Tip());
254+
bool isv20Active = llmq::utils::IsV20Active(::ChainActive().Tip());
255+
bool isMNRewardReallocated = llmq::utils::IsMNRewardReallocationActive(::ChainActive().Tip());
256+
LogPrintf("height: %lld feature activation: v19: %d v20: %d mnrr: %d\n",::ChainActive().Height(),
257+
isv19Active, isv20Active, isMNRewardReallocated);
251258
}
252259
LOCK(cs_main);
253260
auto masternode_payment = GetMasternodePayment(::ChainActive().Height(), GetBlockSubsidy(::ChainActive().Tip()->nBits, ::ChainActive().Height(), consensus_params), 2500);

0 commit comments

Comments
 (0)