Fix regtest mining smoke test

This commit is contained in:
root
2026-04-29 15:46:42 +00:00
parent 47495ff4cf
commit 52b7f4ce5b
6 changed files with 104 additions and 13 deletions
+2 -3
View File
@@ -528,10 +528,9 @@ std::string HelpMessage(HelpMessageMode mode)
if (GetBoolArg("-help-debug", false)) {
strUsage += HelpMessageOpt("-printpriority", strprintf(_("Log transaction priority and fee per kB when mining blocks (default: %u)"), 0));
strUsage += HelpMessageOpt("-privdb", strprintf(_("Sets the DB_PRIVATE flag in the wallet db environment (default: %u)"), 1));
strUsage += HelpMessageOpt("-regtest", _("Enter regression test mode, which uses a special chain in which blocks can be solved instantly.") + " " +
_("This is intended for regression testing tools and app development.") + " " +
_("In this mode -genproclimit controls how many blocks are generated immediately."));
}
strUsage += HelpMessageOpt("-regtest", _("Enter regression test mode, which uses a special chain in which blocks can be solved instantly.") + " " +
_("This is intended for regression testing tools and app development."));
strUsage += HelpMessageOpt("-shrinkdebugfile", _("Shrink debug.log file on client startup (default: 1 when no -debug)"));
strUsage += HelpMessageOpt("-testnet", _("Use the test network"));
strUsage += HelpMessageOpt("-litemode=<n>", strprintf(_("Disable all Agrarian specific functionality (Masternodes, Zerocoin, SwiftX, Budgeting) (0-1, default: %u)"), 0));
+1
View File
@@ -255,6 +255,7 @@ int64_t GetMasternodePayment(int nHeight, int64_t blockValue, int nMasternodeCou
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader* pblock, bool fProofOfStake);
bool ActivateBestChain(CValidationState& state, CBlock* pblock = NULL, bool fAlreadyChecked = false);
CAmount GetBlockValue(int nHeight, bool fProofOfStake);
CAmount GetBlockValue(int nHeight);
/** Create a new block index entry for a given block hash */
+2 -10
View File
@@ -113,20 +113,11 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
pindexPrev = chainActive.Tip();
}
const int nHeight = pindexPrev->nHeight + 1;
// Make sure to create the correct block version after zerocoin is enabled
bool fZerocoinActive = nHeight >= Params().Zerocoin_StartHeight();
pblock->nVersion = 5; // Supports CLTV activation
// -regtest only: allow overriding block.nVersion with
// -blockversion=N to test forking scenarios
if (Params().MineBlocksOnDemand()) {
if (fZerocoinActive)
pblock->nVersion = 5;
else
pblock->nVersion = 3;
pblock->nVersion = GetArg("-blockversion", pblock->nVersion);
}
@@ -458,7 +449,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
if (txNew.vout.size() > 1) {
pblock->payee = txNew.vout[1].scriptPubKey;
} else {
CAmount blockValue = nFees + GetBlockValue(pindexPrev->nHeight);
CAmount blockValue = nFees + GetBlockValue(nHeight, false);
txNew.vout[0].nValue = blockValue;
txNew.vin[0].scriptSig = CScript() << nHeight << OP_0;
}
@@ -483,6 +474,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
pblock->nNonce = 0;
//Calculate the accumulator checkpoint only if the previous cached checkpoint need to be updated
bool fZerocoinActive = nHeight >= Params().Zerocoin_StartHeight();
if (fZerocoinActive) {
uint256 nCheckpoint;
uint256 hashBlockLastAccumulated = chainActive[max(0, nHeight - (nHeight % 10) - 10)]->GetBlockHash();