Skip to content

Commit

Permalink
Disable PoW check in testnet on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelusCH committed Feb 13, 2022
1 parent 5e659bd commit 70bda63
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 48 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BitcoinZ 2.1.0 | MANDO
# BitcoinZ 2.1.0 | MANDO | TU:2
**Keep running wallet to strengthen the BitcoinZ network. Backup your wallet in many locations & keep your coins wallet offline.**

### Ports:
Expand Down
25 changes: 14 additions & 11 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2020 The BitcoinZ community
// Copyright (c) 2022 The BitcoinZ community
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .

Expand Down Expand Up @@ -365,18 +365,19 @@ class CTestNetParams : public CChainParams {
Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nProtocolVersion = 770006;
consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = 1500;
//consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].hashActivationBlock =
// uint256S("0001bd0b788908fe416ac3c2909735bccb8c79b591e76a359ec657a97fb48a6d");
consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].hashActivationBlock =
uint256S("0002577930e1d2af95e6bb1ed894110874c961afb57db5fdfed63b2a7b4379e3");
consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nProtocolVersion = 770006;
consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = 1500;
//consensus.vUpgrades[Consensus::UPGRADE_SAPLING].hashActivationBlock =
// uint256S("0001bd0b788908fe416ac3c2909735bccb8c79b591e76a359ec657a97fb48a6d");
consensus.vUpgrades[Consensus::UPGRADE_SAPLING].hashActivationBlock =
uint256S("0002577930e1d2af95e6bb1ed894110874c961afb57db5fdfed63b2a7b4379e3");
consensus.vUpgrades[Consensus::UPGRADE_BLOSSOM].nProtocolVersion = 770009;
consensus.vUpgrades[Consensus::UPGRADE_BLOSSOM].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
consensus.vUpgrades[Consensus::UPGRADE_BLOSSOM].nActivationHeight =
Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;

// The best chain should have at least this much work.
//consensus.nMinimumChainWork = uint256S("000000000000000000000000000000000000000000000000000000000470fb4c");
consensus.nMinimumChainWork = uint256S("0x00");
consensus.nMinimumChainWork = uint256S("0000000000000000000000000000000000000000000000000000000000010894"); // blk 2100
//consensus.nMinimumChainWork = uint256S("0x00");

pchMessageStart[0] = 0xfa;
pchMessageStart[1] = 0x1a;
Expand Down Expand Up @@ -409,7 +410,7 @@ class CTestNetParams : public CChainParams {

vFixedSeeds.clear();
vSeeds.clear();
//vSeeds.push_back(CDNSSeedData("6be074a62041bb2bee54f8c48ef41bac55c44b0e1f49aef7c319d992844667c2.TZB", "test.seed.btcz.app"));
vSeeds.push_back(CDNSSeedData("6be074a62041bb2bee54f8c48ef41bac55c44b0e1f49aef7c319d992844667c2.TZB", "test.seed.btcz.app"));
//vSeeds.push_back(CDNSSeedData("rotorproject.org", "test-dnsseed.rotorproject.org")); // Zclassic

// guarantees the first 2 characters, when base58 encoded, are "tm"
Expand Down Expand Up @@ -440,6 +441,7 @@ class CTestNetParams : public CChainParams {
fRequireStandard = true;
fMineBlocksOnDemand = false;
fTestnetToBeDeprecatedFieldRPC = true;
bDisablePoWcheck = true;


checkpointData = (CCheckpointData) {
Expand All @@ -453,10 +455,11 @@ class CTestNetParams : public CChainParams {
// Hardcoded fallback value for the Sprout shielded value pool balance
// for nodes that have not reindexed since the introduction of monitoring
// in #2795.
//nSproutValuePoolCheckpointHeight = 21000;
//nSproutValuePoolCheckpointBalance = 825099960000;
nSproutValuePoolCheckpointHeight = 2100;
nSproutValuePoolCheckpointBalance = 0;
fZIP209Enabled = true;
//hashSproutValuePoolCheckpointBlock = uint256S("00360d4e02fbea84aa687722584e24bdc94dd7b768f35b095d453d81c0469d3a");
hashSproutValuePoolCheckpointBlock = uint256S("0000000000000000000000000000000000000000000000000000000000010894");

// Founders reward script expects a vector of 2-of-3 multisig addresses
vCommunityFeeAddress = {
Expand Down
7 changes: 6 additions & 1 deletion src/chainparams.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2020 The BitcoinZ community
// Copyright (c) 2022 The BitcoinZ community
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .

Expand Down Expand Up @@ -103,6 +103,9 @@ class CChainParams
int64_t MaxTipAge() const { return nMaxTipAge; }
int64_t PruneAfterHeight() const { return nPruneAfterHeight; }

/** */
bool DisablePoWcheck() const { return bDisablePoWcheck; }

EHparameters eh_epoch_1_params() const { return eh_epoch_1; }
EHparameters eh_epoch_2_params() const { return eh_epoch_2; }
unsigned long eh_epoch_1_end() const { return eh_epoch_1_endblock; }
Expand Down Expand Up @@ -168,6 +171,8 @@ class CChainParams
uint256 hashSproutValuePoolCheckpointBlock;
bool fZIP209Enabled = false;
int vRollingCheckpointStartHeight;

bool bDisablePoWcheck = false;
};

/**
Expand Down
5 changes: 3 additions & 2 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2022 The BitcoinZ community
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .

Expand Down Expand Up @@ -74,8 +75,8 @@ struct NetworkUpgrade {
};

/** ZIP208 block target interval in seconds. */
static const unsigned int PRE_BLOSSOM_POW_TARGET_SPACING = 5;
static const unsigned int POST_BLOSSOM_POW_TARGET_SPACING = 5;
static const unsigned int PRE_BLOSSOM_POW_TARGET_SPACING = 20;
static const unsigned int POST_BLOSSOM_POW_TARGET_SPACING = 20;
static_assert(POST_BLOSSOM_POW_TARGET_SPACING <= PRE_BLOSSOM_POW_TARGET_SPACING, "Blossom target spacing must be less than pre-Blossom target spacing.");
static const unsigned int PRE_BLOSSOM_HALVING_INTERVAL = 840000;
static const unsigned int PRE_BLOSSOM_REGTEST_HALVING_INTERVAL = 150;
Expand Down
5 changes: 5 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2022 The BitcoinZ community
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .

Expand Down Expand Up @@ -464,6 +465,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +
_("If <category> is not supplied or if <category> = 1, output all debugging information.") + " " + _("<category> can be:") + " " + debugCategories + ".");
strUsage += HelpMessageOpt("-experimentalfeatures", _("Enable use of experimental features"));
strUsage += HelpMessageOpt("-DisablePoWcheck", _("TESTNET ONLY ! Disable the PoW check and stop validation the block headers."));
strUsage += HelpMessageOpt("-help-debug", _("Show all debugging options (usage: --help -help-debug)"));
strUsage += HelpMessageOpt("-logips", strprintf(_("Include IP addresses in debug output (default: %u)"), 0));
strUsage += HelpMessageOpt("-logtimestamps", strprintf(_("Prepend debug output with timestamp (default: %u)"), 1));
Expand Down Expand Up @@ -837,6 +839,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// ********************************************************* Step 2: parameter interactions
const CChainParams& chainparams = Params();

// For testnet only. Disable the PoW check to be able to reindex after params changes.
fDisablePoWcheck = GetBoolArg("-DisablePoWcheck", false);

// Set this early so that experimental features are correctly enabled/disabled
fExperimentalMode = GetBoolArg("-experimentalfeatures", false);

Expand Down
1 change: 1 addition & 0 deletions src/init.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2022 The BitcoinZ community
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .

Expand Down
18 changes: 15 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2022 The BitcoinZ community
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .

Expand Down Expand Up @@ -79,6 +80,7 @@ bool fCoinbaseEnforcedProtectionEnabled = true;
size_t nCoinCacheUsage = 5000 * 300;
uint64_t nPruneTarget = 0;
bool fAlerts = DEFAULT_ALERTS;
bool fDisablePoWcheck = false;
/* If the tip is older than this (in seconds), the node is considered to be in initial block download.
*/
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE;
Expand Down Expand Up @@ -3971,10 +3973,20 @@ bool ContextualCheckBlockHeader(
REJECT_INVALID,"bad-equihash-solution-size");
}




// Check proof of work
if (block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams))
return state.DoS(100, error("%s: incorrect proof of work", __func__),
REJECT_INVALID, "bad-diffbits");
if (block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams) ) {

// Always check in mainet. Can only be disabled if specified.
if (!(chainParams.DisablePoWcheck() && fDisablePoWcheck) || chainParams.NetworkIDString() == "main" ) {
return state.DoS(100, error("%s: incorrect proof of work", __func__), REJECT_INVALID, "bad-diffbits");
}
}




// Check timestamp against prev
if (block.GetBlockTime() <= pindexPrev->GetMedianTimePast())
Expand Down
2 changes: 2 additions & 0 deletions src/main.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2022 The BitcoinZ community
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .

Expand Down Expand Up @@ -138,6 +139,7 @@ extern bool fImporting;
extern bool fReindex;
extern int nScriptCheckThreads;
extern bool fTxIndex;
extern bool fDisablePoWcheck;

// START insightexplorer
extern bool fInsightExplorer;
Expand Down
35 changes: 5 additions & 30 deletions src/metrics.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020 The BitcoinZ community
// Copyright (c) 2022 The BitcoinZ community
// Copyright (c) 2016 The Zcash developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
Expand Down Expand Up @@ -310,7 +310,9 @@ int printMetrics(size_t cols, bool mining)
lines += (strDuration.size() / cols);

int validatedCount = transactionsValidated.get();
if (validatedCount > 1) {
if (GetBoolArg("-DisablePoWcheck", false) && GetBoolArg("-testnet", false)) { // Disable validation if testnet and defined
std::cout << "- " << _("PoW check is disabled! You not validating any transaction!") << std::endl;
} else if (validatedCount > 1) {
std::cout << "- " << strprintf(_("You have validated %d transactions!"), validatedCount) << std::endl;
} else if (validatedCount == 1) {
std::cout << "- " << _("You have validated a transaction!") << std::endl;
Expand Down Expand Up @@ -472,40 +474,13 @@ void ThreadShowMetricsScreen()
// Thank you text
//std::cout << _("BTCZ Node Version 2.1.0 (MANDO) - Protocol 770009") << std::endl;
std::cout << strprintf(_("\n"
// "\n |~"
// "\n |.---. █▄▄ █ ▀█▀ █▀▀ █▀█ █ █▄░█ ▀█"
// "\n .'_____`. /\\ █▄█ █ ░█░ █▄▄ █▄█ █ █░▀█ █▄"
// "\n |~xxxxx~| ||"
// "\n |_ # _| || █▄█ █▀█ █░█ █▀█   █▀▀ █ █▄░█ ▄▀█ █▄░█ █▀▀ █ ▄▀█ █░░ "
// "\n .------`-#-'-----. ░█░ █▄█ █▄█ █▀▄   █▀░ █ █░▀█ █▀█ █░▀█ █▄▄ █ █▀█ █▄▄ "
// "\n (___|\\_________/|_.`."
// "\n / | _________ | | | █▀▀ █▀█ █▀▀ █▀▀ █▀▄ █▀█ █▀▄▀█"
// "\n / |/ _|_ \\| | | █▀░ █▀▄ ██▄ ██▄ █▄▀ █▄█ █░▀░█"
// "\n / /X| __|__ |/ `.|"
// "\n ( --< \\/ _\\//|_ |`."
// "\n `. ~----.-~=====,:======="
// "\n ~-._____/___:__(``/| |"
// "\n | | XX|~ | |"
// "\n \\__/======| /| `.|"
// "\n |_\\|\\ /|/_| )"
// "\n |_ \\__/ _| .-' %s "
// "\n | \\ .'||`. / |(_|"
// "\n | ||.'`.|| | ) BTCZ Node Version 2.1.0 "
// "\n | `'| |`' | / Protocol 770009"
// "\n | | | |\\/ MANDO"
// "\n"
// "\n"
// "\n In decentralization we trust."
// "\n You're helping to strengthen the network and contributing to a social good :)"
// "\n\n"

"\n |~"
"\n |.---. __ _ _____ ___ __ _ __ _ ___ "
"\n .'_____`. /\\ | \\ |_ _/ _//__\\| | \\| |_ | "
"\n |~xxxxx~| || | -< | | || \\_| \\/ | | | ' |/ / "
"\n |_ # _| || |__/_|_|_|_\\__/\\__/|_|_|\\__|___| "
"\n .------`-#-'-----. "
"\n (___|\\_________/|_.`. BTCZ Node Version 2.1.0 (MANDO)"
"\n (___|\\_________/|_.`. BTCZ Node Version 2.1.0 (MANDO) | TU:2"
"\n / | _________ | | | Protocol 770009"
"\n / |/ _|_ \\| | | Network: %s "
"\n"
Expand Down

0 comments on commit 70bda63

Please sign in to comment.