Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core Improvements and Bugfixes #89

Merged
merged 26 commits into from
May 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5f9876e
Fix: RPC (generatetoaddress): Wrong Parameter Index specified.
Dec 20, 2021
d96e6c2
Dandelion: Added Command Line option -dandelion
Jan 4, 2022
b603e17
Refactor: Removed dead code
Jan 17, 2022
206bda7
Fix: Removed duplicate lock statement
Jan 17, 2022
8197dcb
Fix-Functional: Added -easypow argument for regtest networks.
Jan 18, 2022
9be9458
fix: mempool-resurrection: fixed logic error and invalid reorg condition
Mar 19, 2022
d2ed56e
fix: wallet_multiwallet.py: adjusted block yield amounts and adapted …
Mar 19, 2022
e6ae490
fix: feature_assumevalid.py: adapted test parameters and expectations…
Mar 19, 2022
d7454f8
fix: feature_config_args.py: fixed non-existing config check
Mar 19, 2022
ea75594
fix: dandelion: do not reuse node's fee estimator to prevent 'tx alre…
Mar 20, 2022
21a2624
fix: easypow: easypow parameter introduced for regtest
Mar 21, 2022
8c6c2d0
refactor: pow.cpp: replaced tabs with spaces
Mar 21, 2022
657586f
fix: output all difficulties in the getinfo response
Mar 21, 2022
2ed32e4
fix: primitives/transaction.h: bumped default transaction version to …
Mar 21, 2022
5e3a8f8
fix: https:/bitcoin/bitcoin/issues/22670
Mar 23, 2022
344e306
fix: rounding issues: https:/bitcoin/bitcoin/pull/22949
Mar 23, 2022
dcc94aa
fix: testnet: removed invalid duplicate of powLimit
Mar 25, 2022
97a458e
testnet: added checkpoint
Mar 25, 2022
ba6d66d
testnet: selected block 546 as testnet checkpoint hash
Mar 25, 2022
6b18e3c
fix: dandelion and broken unbroadcast (non-final fix, dandelion needs…
Mar 26, 2022
c26be9d
fix: core: critical mempool bug fixed. All transactions entered the m…
Mar 29, 2022
8c9c565
fix: core: bumped protocol version so that wtxid relay becomes active
Mar 29, 2022
55aa6f2
fix: core: bumped high fee warning threshold to 1 DGB
Mar 29, 2022
48e17a8
fix: increased min relay fee of DigiByte
Mar 29, 2022
ebf8009
fix: core: net_processing.cpp: bumped required version for addrv2 pro…
Mar 29, 2022
ac2c332
Fixed linking error
SmartArray Apr 28, 2022
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
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@ endif
digibyte_cli_LDADD = \
$(LIBDIGIBYTE_CLI) \
$(LIBUNIVALUE) \
$(LIBDIGIBYTE_COMMON) \
$(LIBDIGIBYTE_CONSENSUS) \
$(LIBDIGIBYTE_UTIL) \
$(LIBDIGIBYTE_CRYPTO)

Expand Down
86 changes: 69 additions & 17 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class CMainParams : public CChainParams {
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
consensus.nPowTargetSpacing = 60 / 4;
consensus.fPowAllowMinDifficultyBlocks = false;
consensus.fEasyPow = false;
consensus.fPowNoRetargeting = false;
consensus.fRbfEnabled = false;

Expand Down Expand Up @@ -219,8 +220,8 @@ class CMainParams : public CChainParams {

// BEGIN OLD DGB Consensus Diff Timing Code

/*
/** Current DigiByte 2017 Difficulty Adjustment Code & Block Target. See explanation here:
/**
Current DigiByte 2017 Difficulty Adjustment Code & Block Target. See explanation here:
https:/digibyte/digibyte-old/pull/36
https:/digibyte/digibyte-old/pull/15

Expand Down Expand Up @@ -302,7 +303,6 @@ class CTestNetParams : public CChainParams {
consensus.OdoHeight = 600;

consensus.MinBIP9WarningHeight = 0;
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");

/** Current DigiByte 2017 Difficulty Adjustment Code & Block Target. See explanation here:
https:/digibyte/digibyte-old/pull/36
Expand Down Expand Up @@ -365,6 +365,7 @@ class CTestNetParams : public CChainParams {
consensus.algoSwapChangeTarget = 20000; // Block 9,000,000 Odo PoW Hard Fork

consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fEasyPow = false;
consensus.fPowNoRetargeting = true;
consensus.nRuleChangeActivationThreshold = 4032; // 4032 - 70% of 5760
consensus.nMinerConfirmationWindow = 5760; // 1 day of blocks on testnet
Expand Down Expand Up @@ -426,7 +427,7 @@ class CTestNetParams : public CChainParams {

checkpointData = {
{
{ 0, uint256S("0x308ea0711d5763be2995670dd9ca9872753561285a84da1d58be58acaa822252")},
{ 546, uint256S("0x08fa50178f4b4f9fe1bbaed3b0a2ee58d1c51cc8185f70c8089e4b95763d9cdb")},
}
};

Expand Down Expand Up @@ -507,6 +508,7 @@ class SigNetParams : public CChainParams {
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
consensus.nPowTargetSpacing = 10 * 60;
consensus.fPowAllowMinDifficultyBlocks = false;
consensus.fEasyPow = false;
consensus.fPowNoRetargeting = false;
consensus.nRuleChangeActivationThreshold = 1815; // 90% of 2016
consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
Expand Down Expand Up @@ -568,7 +570,7 @@ class CRegTestParams : public CChainParams {
strNetworkID = CBaseChainParams::REGTEST;
consensus.signet_blocks = false;
consensus.signet_challenge.clear();
consensus.nSubsidyHalvingInterval = 150;
consensus.nSubsidyHalvingInterval = 300;
consensus.BIP16Exception = uint256();
consensus.BIP34Height = 500; // BIP34 activated on regtest (Used in functional tests)
consensus.BIP34Hash = uint256();
Expand All @@ -581,12 +583,13 @@ class CRegTestParams : public CChainParams {
consensus.MinBIP9WarningHeight = 0;
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fEasyPow = false; // allow easy blocks on regtest (can be set with -easypow)
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
consensus.nPowTargetSpacing = 60 / 4;
consensus.nTargetTimespan = 0.10 * 24 * 60 * 60; // 2.4 hours
consensus.nTargetTimespan = 0.10 * 48 * 60 * 60; // 4.8 hours
consensus.nTargetSpacing = 60; // 60 seconds
consensus.nInterval = consensus.nTargetTimespan / consensus.nTargetSpacing;
consensus.nDiffChangeTarget = 167; // DigiShield Hard Fork Block BIP34Height 67,200
consensus.nDiffChangeTarget = 334; // DigiShield Hard Fork Block BIP34Height 67,200

// Old 1% monthly DGB Reward before 15 secon block change
consensus.patchBlockRewardDuration = 10; //10080; - No longer used
Expand Down Expand Up @@ -623,7 +626,7 @@ class CRegTestParams : public CChainParams {
consensus.BIP66Height = 1251;

// DigiByte Hard Fork Block Heights
consensus.multiAlgoDiffChangeTarget = 145; // Block 145,000 MultiAlgo Hard Fork
consensus.multiAlgoDiffChangeTarget = 290; // Block 145,000 MultiAlgo Hard Fork
consensus.alwaysUpdateDiffChangeTarget = 400; // Block 400,000 MultiShield Hard Fork
consensus.workComputationChangeTarget = 1430; // Block 1,430,000 DigiSpeed Hard Fork
consensus.algoSwapChangeTarget = 2000; // Block 9,000,000 Odo PoW Hard Fork
Expand Down Expand Up @@ -752,18 +755,67 @@ class CRegTestParams : public CChainParams {
void UpdateActivationParametersFromArgs(const ArgsManager& args);
};

void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args)
static void MaybeUpdateHeights(const ArgsManager& args, Consensus::Params& consensus)
{
if (args.IsArgSet("-segwitheight")) {
int64_t height = args.GetArg("-segwitheight", consensus.SegwitHeight);
if (height < -1 || height >= std::numeric_limits<int>::max()) {
throw std::runtime_error(strprintf("Activation height %ld for segwit is out of valid range. Use -1 to disable segwit.", height));
} else if (height == -1) {
LogPrintf("Segwit disabled for testing\n");
height = std::numeric_limits<int>::max();
for (const std::string& arg : args.GetArgs("-testactivationheight")) {
const auto found{arg.find('@')};
if (found == std::string::npos) {
throw std::runtime_error(strprintf("Invalid format (%s) for -testactivationheight=name@height.", arg));
}
const auto name{arg.substr(0, found)};
const auto value{arg.substr(found + 1)};
int32_t height;
if (!ParseInt32(value, &height) || height < 0 || height >= std::numeric_limits<int>::max()) {
throw std::runtime_error(strprintf("Invalid height value (%s) for -testactivationheight=name@height.", arg));
}
if (name == "segwit") {
consensus.SegwitHeight = int{height};
} else if (name == "bip34") {
consensus.BIP34Height = int{height};
} else if (name == "dersig") {
consensus.BIP66Height = int{height};
} else if (name == "cltv") {
consensus.BIP65Height = int{height};
} else if (name == "csv") {
consensus.CSVHeight = int{height};
} else {
throw std::runtime_error(strprintf("Invalid name (%s) for -testactivationheight=name@height.", arg));
}
consensus.SegwitHeight = static_cast<int>(height);
}
}

// This method was added to enable easy mining on regtest networks only.
// It will postpone the activation of MultiAlgo by 999999 blocks to make sure
// it will be easy to mine blocks in regtest network.
// This method can only be applied to RegTest networks by design and is called from
// `CRegTestParams::UpdateActivationParametersFromArgs`
static void MaybeEnableEasyMining(const ArgsManager& args, Consensus::Params& consensus)
{
if (!args.IsArgSet("-easypow")) return;

consensus.fEasyPow = true;
consensus.fPowAllowMinDifficultyBlocks = true;

// // Postpone MultiAlgo Activation to the 1-millionth block
consensus.multiAlgoDiffChangeTarget = 1000000;

// Delay new difficulty retargeting algorithm.
// This will also delay have fixed subsidy as follows:
// if (nHeight < 1440) 72000 * COIN;
// if (nHeight < 5760) 16000 * COIN;
// else nSubsidy = 8000 * COIN;
consensus.nDiffChangeTarget = 1000000;

// Delay softforks
consensus.BIP34Height = 1000000;
consensus.OdoHeight = 1000000;
consensus.CSVHeight = 1000000;
}

void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args)
{
MaybeEnableEasyMining(args, consensus);
MaybeUpdateHeights(args, consensus);

if (!args.IsArgSet("-vbparams")) return;

Expand Down
3 changes: 2 additions & 1 deletion src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
argsman.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: main, test, signet, regtest", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-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. Equivalent to -chain=regtest.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-segwitheight=<n>", "Set the activation height of segwit. -1 to disable. (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name' (segwit, bip34, dersig, cltv, csv). (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-testnet", "Use the test chain. Equivalent to -chain=test.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-vbparams=deployment:start:end[:min_activation_height]", "Use given start/end times and min_activation_height for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-signet", "Use the signet chain. Equivalent to -chain=signet. Note that the network is defined by the -signetchallenge parameter", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-signetchallenge", "Blocks must satisfy the given script to be considered valid (only for signet networks; defaults to the global default signet test network challenge)", ArgsManager::ALLOW_STRING, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-signetseednode", "Specify a seed node for the signet network, in the hostname[:port] format, e.g. sig.net:1234 (may be used multiple times to specify multiple seed nodes; defaults to the global default signet test network seed node(s))", ArgsManager::ALLOW_STRING, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-easypow", "Allow easy minable blocks in regtest (postpones the activation of MultiAlgo)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
}

static std::unique_ptr<CBaseChainParams> globalChainBaseParams;
Expand Down
1 change: 1 addition & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ struct Params {
uint256 powLimit;
std::map<int, uint256> initialTarget;
bool fPowAllowMinDifficultyBlocks;
bool fEasyPow;
bool fPowNoRetargeting;
bool fRbfEnabled;
int64_t nPowTargetSpacing;
Expand Down
12 changes: 10 additions & 2 deletions src/digibyte-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <util/system.h>
#include <util/translation.h>
#include <util/url.h>
#include <primitives/block.h>

#include <algorithm>
#include <cmath>
Expand Down Expand Up @@ -344,8 +345,8 @@ class GetinfoRequestHandler: public BaseRequestHandler
connections.pushKV("total", batch[ID_NETWORKINFO]["result"]["connections"]);
result.pushKV("connections", connections);

result.pushKV("difficulties", batch[ID_BLOCKCHAININFO]["result"]["difficulties"]);
result.pushKV("proxy", batch[ID_NETWORKINFO]["result"]["networks"][0]["proxy"]);
result.pushKV("difficulty", batch[ID_BLOCKCHAININFO]["result"]["difficulty"]);
result.pushKV("chain", UniValue(batch[ID_BLOCKCHAININFO]["result"]["chain"]));
if (!batch[ID_WALLETINFO]["result"].isNull()) {
result.pushKV("has_wallet", true);
Expand Down Expand Up @@ -928,7 +929,14 @@ static void ParseGetInfoResult(UniValue& result)
result_string += strprintf("Blocks: %s\n", result["blocks"].getValStr());
result_string += strprintf("Headers: %s\n", result["headers"].getValStr());
result_string += strprintf("Verification progress: %.4f%%\n", result["verificationprogress"].get_real() * 100);
result_string += strprintf("Difficulty: %s\n\n", result["difficulty"].getValStr());

for (int algo = 0; algo < NUM_ALGOS_IMPL; ++algo) {
std::string algoName = GetAlgoName(algo);

if (result["difficulties"].exists(algoName)) {
result_string += strprintf("Difficulty (%s): %s\n\n", algoName, result["difficulties"][algoName].getValStr());
}
}

result_string += strprintf(
"%sNetwork: in %s, out %s, total %s%s\n",
Expand Down
4 changes: 3 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ void SetupServerArgs(ArgsManager& argsman)
argsman.AddArg("-rpcworkqueue=<n>", strprintf("Set the depth of the work queue to service RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::RPC);
argsman.AddArg("-server", "Accept command line and JSON-RPC commands", ArgsManager::ALLOW_ANY, OptionsCategory::RPC);

argsman.AddArg("-dandelion", strprintf("Enable Dandelion Transaction Relay Protocol (default: %d)", DEFAULT_DANDELION), ArgsManager::ALLOW_BOOL, OptionsCategory::OPTIONS);

#if HAVE_DECL_FORK
argsman.AddArg("-daemon", strprintf("Run in the background as a daemon and accept commands (default: %d)", DEFAULT_DAEMON), ArgsManager::ALLOW_BOOL, OptionsCategory::OPTIONS);
argsman.AddArg("-daemonwait", strprintf("Wait for initialization to be finished before exiting. This implies -daemon (default: %d)", DEFAULT_DAEMONWAIT), ArgsManager::ALLOW_BOOL, OptionsCategory::OPTIONS);
Expand Down Expand Up @@ -1182,7 +1184,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
node.mempool = std::make_unique<CTxMemPool>(node.fee_estimator.get(), check_ratio);

assert(!node.stempool);
node.stempool = std::make_unique<CTxMemPool>(node.fee_estimator.get(), check_ratio);
node.stempool = std::make_unique<CTxMemPool>(nullptr, 0);

assert(!node.chainman);
node.chainman = std::make_unique<ChainstateManager>();
Expand Down
Loading