aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoss Nicoll <[email protected]>2017-04-18 13:36:32 +0100
committerRoss Nicoll <[email protected]>2021-06-02 10:37:16 +0100
commit3afaf906f1d7b2717d3326d487a5daf77126ec24 (patch)
tree57c51934f9fa5537b80fca8431a7ed4fbf6a8ccc /src
parentcrypto: Add scrypt N=1024 PoW (diff)
downloaddiscoin-3afaf906f1d7b2717d3326d487a5daf77126ec24.tar.xz
discoin-3afaf906f1d7b2717d3326d487a5daf77126ec24.zip
Replace consensus values with Dogecoin equivalents
* Replace chain parameters with Dogecoin values * Update maximum coins to match Dogecoin * Disable version 2 block requirement * Update coinbase maturity to match Dogecoin
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/Makefile.bench.include4
-rw-r--r--src/bench/checkblock.cpp8
-rw-r--r--src/bench/data.cpp4
-rw-r--r--src/bench/data.h2
-rw-r--r--src/bench/data/block413567.rawbin999887 -> 0 bytes
-rw-r--r--src/bench/data/block41385.rawbin0 -> 102806 bytes
-rw-r--r--src/bench/rpc_blockchain.cpp2
-rw-r--r--src/chainparams.cpp82
-rw-r--r--src/net_processing.cpp2
-rw-r--r--src/qt/test/rpcnestedtests.cpp2
-rw-r--r--src/rpc/mining.cpp2
-rw-r--r--src/rpc/rawtransaction_util.cpp2
-rw-r--r--src/test/miner_tests.cpp76
-rw-r--r--src/test/util/mining.cpp2
-rw-r--r--src/test/util/setup_common.cpp2
-rw-r--r--src/validation.cpp4
-rw-r--r--src/version.h2
18 files changed, 111 insertions, 89 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index f80cabae8..16f7b5627 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -390,7 +390,7 @@ libbitcoin_wallet_tool_a_SOURCES = \
$(BITCOIN_CORE_H)
# crypto primitives library
-crypto_libbitcoin_crypto_base_a_CPPFLAGS = $(AM_CPPFLAGS) $(SSL_CFLAGS)
+crypto_libbitcoin_crypto_base_a_CPPFLAGS = $(AM_CPPFLAGS)
crypto_libbitcoin_crypto_base_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
crypto_libbitcoin_crypto_base_a_SOURCES = \
crypto/aes.cpp \
@@ -676,7 +676,7 @@ endif
libbitcoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1) $(CRYPTO_LIBS)
-libbitcoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL $(SSL_CFLAGS)
+libbitcoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
libbitcoinconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
endif
diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include
index 1bdfa9525..b8e0ec3a1 100644
--- a/src/Makefile.bench.include
+++ b/src/Makefile.bench.include
@@ -7,7 +7,7 @@ BENCH_SRCDIR = bench
BENCH_BINARY = bench/bench_dogecoin$(EXEEXT)
RAW_BENCH_FILES = \
- bench/data/block413567.raw
+ bench/data/block41385.raw
GENERATED_BENCH_FILES = $(RAW_BENCH_FILES:.raw=.raw.h)
bench_bench_dogecoin_SOURCES = \
@@ -81,7 +81,7 @@ CLEAN_BITCOIN_BENCH = bench/*.gcda bench/*.gcno $(GENERATED_BENCH_FILES)
CLEANFILES += $(CLEAN_BITCOIN_BENCH)
-bench/data.cpp: bench/data/block413567.raw.h
+bench/data.cpp: bench/data/block41385.raw.h
dogecoin_bench: $(BENCH_BINARY)
diff --git a/src/bench/checkblock.cpp b/src/bench/checkblock.cpp
index a9f3f5f84..aa7e5865b 100644
--- a/src/bench/checkblock.cpp
+++ b/src/bench/checkblock.cpp
@@ -16,21 +16,21 @@
static void DeserializeBlockTest(benchmark::Bench& bench)
{
- CDataStream stream(benchmark::data::block413567, SER_NETWORK, PROTOCOL_VERSION);
+ CDataStream stream(benchmark::data::block41385, SER_NETWORK, PROTOCOL_VERSION);
char a = '\0';
stream.write(&a, 1); // Prevent compaction
bench.unit("block").run([&] {
CBlock block;
stream >> block;
- bool rewound = stream.Rewind(benchmark::data::block413567.size());
+ bool rewound = stream.Rewind(benchmark::data::block41385.size());
assert(rewound);
});
}
static void DeserializeAndCheckBlockTest(benchmark::Bench& bench)
{
- CDataStream stream(benchmark::data::block413567, SER_NETWORK, PROTOCOL_VERSION);
+ CDataStream stream(benchmark::data::block41385, SER_NETWORK, PROTOCOL_VERSION);
char a = '\0';
stream.write(&a, 1); // Prevent compaction
@@ -40,7 +40,7 @@ static void DeserializeAndCheckBlockTest(benchmark::Bench& bench)
bench.unit("block").run([&] {
CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here
stream >> block;
- bool rewound = stream.Rewind(benchmark::data::block413567.size());
+ bool rewound = stream.Rewind(benchmark::data::block41385.size());
assert(rewound);
BlockValidationState validationState;
diff --git a/src/bench/data.cpp b/src/bench/data.cpp
index 0ae4c7cad..2280b3914 100644
--- a/src/bench/data.cpp
+++ b/src/bench/data.cpp
@@ -7,8 +7,8 @@
namespace benchmark {
namespace data {
-#include <bench/data/block413567.raw.h>
-const std::vector<uint8_t> block413567{block413567_raw, block413567_raw + sizeof(block413567_raw) / sizeof(block413567_raw[0])};
+#include <bench/data/block41385.raw.h>
+const std::vector<uint8_t> block41385{block41385_raw, block41385_raw + sizeof(block41385_raw) / sizeof(block41385_raw[0])};
} // namespace data
} // namespace benchmark
diff --git a/src/bench/data.h b/src/bench/data.h
index 5f13d766e..3f985e575 100644
--- a/src/bench/data.h
+++ b/src/bench/data.h
@@ -11,7 +11,7 @@
namespace benchmark {
namespace data {
-extern const std::vector<uint8_t> block413567;
+extern const std::vector<uint8_t> block41385;
} // namespace data
} // namespace benchmark
diff --git a/src/bench/data/block413567.raw b/src/bench/data/block413567.raw
deleted file mode 100644
index 67d2d5d38..000000000
--- a/src/bench/data/block413567.raw
+++ /dev/null
Binary files differ
diff --git a/src/bench/data/block41385.raw b/src/bench/data/block41385.raw
new file mode 100644
index 000000000..328f7e9af
--- /dev/null
+++ b/src/bench/data/block41385.raw
Binary files differ
diff --git a/src/bench/rpc_blockchain.cpp b/src/bench/rpc_blockchain.cpp
index 4b45264a3..5b08c30ed 100644
--- a/src/bench/rpc_blockchain.cpp
+++ b/src/bench/rpc_blockchain.cpp
@@ -13,7 +13,7 @@
static void BlockToJsonVerbose(benchmark::Bench& bench)
{
- CDataStream stream(benchmark::data::block413567, SER_NETWORK, PROTOCOL_VERSION);
+ CDataStream stream(benchmark::data::block41385, SER_NETWORK, PROTOCOL_VERSION);
char a = '\0';
stream.write(&a, 1); // Prevent compaction
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index f6b8324a6..9c8fdcbcc 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -5,6 +5,7 @@
#include <chainparams.h>
+#include <arith_uint256.h>
#include <chainparamsseeds.h>
#include <consensus/merkle.h>
#include <hash.h> // for signet block challenge hash
@@ -18,6 +19,25 @@
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
+bool CheckProofOfWorkSimplified(uint256 hash, unsigned int nBits)
+{
+ bool fNegative;
+ bool fOverflow;
+ arith_uint256 bnTarget;
+
+ bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
+
+ // Check range
+ if (fNegative || bnTarget == 0 || fOverflow)
+ return false;
+
+ // Check proof of work matches claimed amount
+ if (UintToArith256(hash) > bnTarget)
+ return false;
+
+ return true;
+}
+
static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
CMutableTransaction txNew;
@@ -44,7 +64,7 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesi
* transaction cannot be spent since it did not originally exist in the
* database.
*
- * CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
+ * CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1386325540, nBits=1e0ffff0, nNonce=99943, vtx=1)
* CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
* CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
* CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
@@ -52,8 +72,8 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesi
*/
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
- const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
- const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
+ const char* pszTimestamp = "Nintondo";
+ const CScript genesisOutputScript = CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG;
return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}
@@ -113,25 +133,18 @@ public:
m_assumed_blockchain_size = 350;
m_assumed_chain_state_size = 6;
- genesis = CreateGenesisBlock(1386325540, 1930484355, 0x1d00ffff, 1, 88 * COIN);
+ genesis = CreateGenesisBlock(1386325540, 99943, 0x1e0ffff0, 1, 88 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
- assert(consensus.hashGenesisBlock == uint256S("0x000000007610a818e726d4f943b5936e750de86c142a5f59606456c945350ec3"));
- assert(genesis.hashMerkleRoot == uint256S("0x13abc7dbaf8e00e9e128cb4977e3a9d15ea5d4ff249dd625ee607f6023cdb3df"));
+ assert(consensus.hashGenesisBlock == uint256S("0x1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691"));
+ assert(genesis.hashMerkleRoot == uint256S("0x5b2a3f53f605d62c53e62932dac6925e3d74afa5a4b459745c36d42d0ed26a69"));
// Note that of those which support the service bits prefix, most only support a subset of
// possible options.
// This is fine at runtime as we'll fall back to using them as an addrfetch if they don't support the
// service bits we want, but we should get them updated to support all service bits wanted by any
// release ASAP to avoid it where possible.
- vSeeds.emplace_back("seed.bitcoin.sipa.be"); // Pieter Wuille, only supports x1, x5, x9, and xd
- vSeeds.emplace_back("dnsseed.bluematt.me"); // Matt Corallo, only supports x9
- vSeeds.emplace_back("dnsseed.bitcoin.dashjr.org"); // Luke Dashjr
- vSeeds.emplace_back("seed.bitcoinstats.com"); // Christian Decker, supports x1 - xf
- vSeeds.emplace_back("seed.bitcoin.jonasschnelli.ch"); // Jonas Schnelli, only supports x1, x5, x9, and xd
- vSeeds.emplace_back("seed.btc.petertodd.org"); // Peter Todd, only supports x1, x5, x9, and xd
- vSeeds.emplace_back("seed.bitcoin.sprovoost.nl"); // Sjors Provoost
- vSeeds.emplace_back("dnsseed.emzy.de"); // Stephan Oeste
- vSeeds.emplace_back("seed.bitcoin.wiz.biz"); // Jason Maurice
+ vSeeds.emplace_back("seed.multidoge.org");
+ vSeeds.emplace_back("seed2.multidoge.org");
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,30);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,22);
@@ -232,19 +245,15 @@ public:
m_assumed_blockchain_size = 40;
m_assumed_chain_state_size = 2;
- // Dogecoin: Note timestamp is tweaked for SHA256 interim mining, will need correcting for Scrypt
- genesis = CreateGenesisBlock(1391503288, 1182687315, 0x1d00ffff, 1, 88 * COIN);
+ genesis = CreateGenesisBlock(1391503289, 997879, 0x1e0ffff0, 1, 88 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
- assert(consensus.hashGenesisBlock == uint256S("0x00000000543fd974f37140a6192f890d744f220bd82ae428dbe684c7588347ad"));
- assert(genesis.hashMerkleRoot == uint256S("0x13abc7dbaf8e00e9e128cb4977e3a9d15ea5d4ff249dd625ee607f6023cdb3df"));
+ assert(consensus.hashGenesisBlock == uint256S("0xbb0a78264637406b6360aad926284d544d7049f45189db5664f3c4d07350559e"));
+ assert(genesis.hashMerkleRoot == uint256S("0x5b2a3f53f605d62c53e62932dac6925e3d74afa5a4b459745c36d42d0ed26a69"));
vFixedSeeds.clear();
vSeeds.clear();
// nodes with support for servicebits filtering should be at the top
- vSeeds.emplace_back("testnet-seed.bitcoin.jonasschnelli.ch");
- vSeeds.emplace_back("seed.tbtc.petertodd.org");
- vSeeds.emplace_back("seed.testnet.bitcoin.sprovoost.nl");
- vSeeds.emplace_back("testnet-seed.bluematt.me"); // Just a static list of stable node(s), only supports x9
+ vSeeds.emplace_back("testseed.jrn.me.uk", true);
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,113);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
@@ -299,6 +308,7 @@ public:
vSeeds.clear();
if (!args.IsArgSet("-signetchallenge")) {
+ // Dogecoin: Replace these with new values
bin = ParseHex("512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be430210359ef5021964fe22d6f8e05b2463c9540ce96883fe3b278760f048f5189f2e6c452ae");
vSeeds.emplace_back("178.128.221.177");
vSeeds.emplace_back("2a01:7c8:d005:390::5");
@@ -356,7 +366,7 @@ public:
consensus.nRuleChangeActivationThreshold = 1900; // 95% of 2000
consensus.nMinerConfirmationWindow = 2000; // nPowTargetTimespan / nPowTargetSpacing
consensus.MinBIP9WarningHeight = 0;
- consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
+ consensus.powLimit = uint256S("0x0000f77ae0000000000000000000000000000000000000000000000000000000");
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
@@ -378,10 +388,20 @@ public:
nDefaultPort = 55556;
nPruneAfterHeight = 1000;
- genesis = CreateGenesisBlock(1598918400, 52613770, 0x1e0377ae, 1, 50 * COIN);
+ genesis = CreateGenesisBlock(1622364566, 81621, 0x1f00f77a, 1, 50 * COIN);
+ genesis.nBits = UintToArith256(consensus.powLimit).GetCompact();
+ printf("Bits: %x\n", genesis.nBits);
+ while (!CheckProofOfWorkSimplified(genesis.GetPoWHash(), genesis.nBits)) {
+ genesis.nNonce++;
+ if (genesis.nNonce % 100000 == 0) {
+ printf("Interim nonce: %d\n", genesis.nNonce);
+ }
+ }
+ printf("Nonce: %d\n", genesis.nNonce);
consensus.hashGenesisBlock = genesis.GetHash();
- assert(consensus.hashGenesisBlock == uint256S("0x00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6"));
- assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
+ printf("Hash: %s\n", consensus.hashGenesisBlock.ToString().c_str());
+ assert(consensus.hashGenesisBlock == uint256S("0xf21a2c00a3b58b3f1b245de5e30955c00784040a3e7042edb0d2eedd1fd085a5"));
+ assert(genesis.hashMerkleRoot == uint256S("0xb60e6a649c2c43248d6d8da2fb19daa337511fabfe3875f382adb686474fc021"));
vFixedSeeds.clear();
@@ -426,7 +446,7 @@ public:
consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fPowNoRetargeting = true;
consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
- consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
+ consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 10080)
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
@@ -454,8 +474,8 @@ public:
genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 88 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
- assert(consensus.hashGenesisBlock == uint256S("0x4ebcb24a7efa4e2050e74d6c95f1ee318ed2b4df2b6f28b0d6b8318cb43762e8"));
- assert(genesis.hashMerkleRoot == uint256S("0x13abc7dbaf8e00e9e128cb4977e3a9d15ea5d4ff249dd625ee607f6023cdb3df"));
+ assert(consensus.hashGenesisBlock == uint256S("0x3d2160a3b5dc4a9d62e7e66a295f70313ac808440ef7400d6c0772171ce973a5"));
+ assert(genesis.hashMerkleRoot == uint256S("0x5b2a3f53f605d62c53e62932dac6925e3d74afa5a4b459745c36d42d0ed26a69"));
vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
@@ -467,7 +487,7 @@ public:
checkpointData = {
{
- {0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")},
+ {0, uint256S("3d2160a3b5dc4a9d62e7e66a295f70313ac808440ef7400d6c0772171ce973a5")},
}
};
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index cbb448649..d2a0e6d91 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2469,6 +2469,8 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
AddTimeData(pfrom.addr, nTimeOffset);
// If the peer is old enough to have the old alert system, send it the final alert.
+ // TODO: Decide if we need to reintroduce alerts to Dogecoin
+ // https://github.com/dogecoin/dogecoin/issues/2231
if (greatest_common_version <= 70012) {
CDataStream finalAlert(ParseHex("60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50"), SER_NETWORK, PROTOCOL_VERSION);
m_connman.PushMessage(&pfrom, CNetMsgMaker(greatest_common_version).Make("alert", finalAlert));
diff --git a/src/qt/test/rpcnestedtests.cpp b/src/qt/test/rpcnestedtests.cpp
index a82adc251..b952d87e1 100644
--- a/src/qt/test/rpcnestedtests.cpp
+++ b/src/qt/test/rpcnestedtests.cpp
@@ -69,7 +69,7 @@ void RPCNestedTests::rpcNestedTests()
QVERIFY(result == result2);
RPCConsole::RPCExecuteCommandLine(*node, result, "getblock(getbestblockhash())[tx][0]", &filtered);
- QVERIFY(result == "13abc7dbaf8e00e9e128cb4977e3a9d15ea5d4ff249dd625ee607f6023cdb3df");
+ QVERIFY(result == "5b2a3f53f605d62c53e62932dac6925e3d74afa5a4b459745c36d42d0ed26a69");
QVERIFY(filtered == "getblock(getbestblockhash())[tx][0]");
RPCConsole::RPCParseCommandLine(nullptr, result, "importprivkey", false, &filtered);
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 6522c0d73..74e1c469b 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -116,7 +116,7 @@ static bool GenerateBlock(ChainstateManager& chainman, CBlock& block, uint64_t&
CChainParams chainparams(Params());
- while (max_tries > 0 && block.nNonce < std::numeric_limits<uint32_t>::max() && !CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus()) && !ShutdownRequested()) {
+ while (max_tries > 0 && block.nNonce < std::numeric_limits<uint32_t>::max() && !CheckProofOfWork(block.GetPoWHash(), block.nBits, chainparams.GetConsensus()) && !ShutdownRequested()) {
++block.nNonce;
--max_tries;
}
diff --git a/src/rpc/rawtransaction_util.cpp b/src/rpc/rawtransaction_util.cpp
index f004ecc20..b6b5b55f5 100644
--- a/src/rpc/rawtransaction_util.cpp
+++ b/src/rpc/rawtransaction_util.cpp
@@ -115,7 +115,7 @@ CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniVal
} else {
CTxDestination destination = DecodeDestination(name_);
if (!IsValidDestination(destination)) {
- throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Bitcoin address: ") + name_);
+ throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Dogecoin address: ") + name_);
}
if (!destinations.insert(destination).second) {
diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp
index 2a342fe70..3eefab9ef 100644
--- a/src/test/miner_tests.cpp
+++ b/src/test/miner_tests.cpp
@@ -51,34 +51,34 @@ constexpr static struct {
unsigned char extranonce;
unsigned int nonce;
} blockinfo[] = {
- {4, 0xa4a3e223}, {2, 0x15c32f9e}, {1, 0x0375b547}, {1, 0x7004a8a5},
- {2, 0xce440296}, {2, 0x52cfe198}, {1, 0x77a72cd0}, {2, 0xbb5d6f84},
- {2, 0x83f30c2c}, {1, 0x48a73d5b}, {1, 0xef7dcd01}, {2, 0x6809c6c4},
- {2, 0x0883ab3c}, {1, 0x087bbbe2}, {2, 0x2104a814}, {2, 0xdffb6daa},
- {1, 0xee8a0a08}, {2, 0xba4237c1}, {1, 0xa70349dc}, {1, 0x344722bb},
- {3, 0xd6294733}, {2, 0xec9f5c94}, {2, 0xca2fbc28}, {1, 0x6ba4f406},
- {2, 0x015d4532}, {1, 0x6e119b7c}, {2, 0x43e8f314}, {2, 0x27962f38},
- {2, 0xb571b51b}, {2, 0xb36bee23}, {2, 0xd17924a8}, {2, 0x6bc212d9},
- {1, 0x630d4948}, {2, 0x9a4c4ebb}, {2, 0x554be537}, {1, 0xd63ddfc7},
- {2, 0xa10acc11}, {1, 0x759a8363}, {2, 0xfb73090d}, {1, 0xe82c6a34},
- {1, 0xe33e92d7}, {3, 0x658ef5cb}, {2, 0xba32ff22}, {5, 0x0227a10c},
- {1, 0xa9a70155}, {5, 0xd096d809}, {1, 0x37176174}, {1, 0x830b8d0f},
- {1, 0xc6e3910e}, {2, 0x823f3ca8}, {1, 0x99850849}, {1, 0x7521fb81},
- {1, 0xaacaabab}, {1, 0xd645a2eb}, {5, 0x7aea1781}, {5, 0x9d6e4b78},
- {1, 0x4ce90fd8}, {1, 0xabdc832d}, {6, 0x4a34f32a}, {2, 0xf2524c1c},
- {2, 0x1bbeb08a}, {1, 0xad47f480}, {1, 0x9f026aeb}, {1, 0x15a95049},
- {2, 0xd1cb95b2}, {2, 0xf84bbda5}, {1, 0x0fa62cd1}, {1, 0xe05f9169},
- {1, 0x78d194a9}, {5, 0x3e38147b}, {5, 0x737ba0d4}, {1, 0x63378e10},
- {1, 0x6d5f91cf}, {2, 0x88612eb8}, {2, 0xe9639484}, {1, 0xb7fabc9d},
- {2, 0x19b01592}, {1, 0x5a90dd31}, {2, 0x5bd7e028}, {2, 0x94d00323},
- {1, 0xa9b9c01a}, {1, 0x3a40de61}, {1, 0x56e7eec7}, {5, 0x859f7ef6},
- {1, 0xfd8e5630}, {1, 0x2b0c9f7f}, {1, 0xba700e26}, {1, 0x7170a408},
- {1, 0x70de86a8}, {1, 0x74d64cd5}, {1, 0x49e738a1}, {2, 0x6910b602},
- {0, 0x643c565f}, {1, 0x54264b3f}, {2, 0x97ea6396}, {2, 0x55174459},
- {2, 0x03e8779a}, {1, 0x98f34d8f}, {1, 0xc07b2b07}, {1, 0xdfe29668},
- {1, 0x3141c7c1}, {1, 0xb3b595f4}, {1, 0x735abf08}, {5, 0x623bfbce},
- {2, 0xd351e722}, {1, 0xf4ca48c9}, {1, 0x5b19c670}, {1, 0xa164bf0e},
- {2, 0xbbbeb305}, {2, 0xfe1c810a},
+ {4, 0x127fad2d}, {2, 0x335d1b8f}, {1, 0x33d47094}, {2, 0x0b09ec28},
+ {1, 0x06cf723b}, {2, 0x039202bc}, {1, 0x0a2c9d46}, {2, 0x6225cb92},
+ {2, 0x6ea1513e}, {1, 0x4401bef3}, {1, 0x04d3a1d2}, {2, 0x1c512825},
+ {2, 0x54a03b14}, {1, 0x6048e27d}, {1, 0x1b926afc}, {2, 0x68c4afbd},
+ {2, 0x4439c313}, {1, 0x1263fceb}, {2, 0x834dee3e}, {2, 0xf21ed9dc},
+ {1, 0xdcdac434}, {2, 0x4c1945be}, {1, 0x6d42a594}, {3, 0x20927a30},
+ {3, 0xfd60f461}, {2, 0xd9ad2207}, {2, 0xe7f69d1a}, {1, 0x7fa9b932},
+ {2, 0xb0511080}, {1, 0xe7d24cd5}, {2, 0x3c57e668}, {2, 0x83bfdc2e},
+ {2, 0x6eeb4e10}, {2, 0x9cacbcfd}, {2, 0xb27ea98e}, {2, 0x6d57c5a7},
+ {1, 0x6deb4fa8}, {2, 0xabf625c6}, {2, 0x27e7c569}, {1, 0x89c6e991},
+ {2, 0xc359bc28}, {1, 0x6f25768d}, {2, 0x654a4c31}, {1, 0x5cd03bab},
+ {1, 0xda405f69}, {3, 0xfea453e5}, {2, 0x137d2c3a}, {5, 0xdee2f36e},
+ {1, 0xeccbcf26}, {5, 0x9237dbaa}, {1, 0xb7b9350b}, {1, 0xcd0c7eb2},
+ {1, 0xf5ea5a32}, {2, 0x3486a7f3}, {1, 0xd0a0f2be}, {1, 0xe1238144},
+ {1, 0x28b98a9b}, {1, 0xe79d02aa}, {5, 0xf4555d56}, {5, 0x74da0bb7},
+ {1, 0x18728b91}, {1, 0x07ed3a93}, {6, 0xd7a5e106}, {2, 0xba50b06c},
+ {2, 0x952c830d}, {1, 0xfbd1bb18}, {1, 0x36126967}, {1, 0xcce357d0},
+ {2, 0xff1ec2d6}, {2, 0xbed5dfc9}, {1, 0x0d21fdd7}, {1, 0xd744edea},
+ {1, 0xe09fc8f2}, {5, 0x2ad325c5}, {5, 0x466b6549}, {1, 0x10705d49},
+ {1, 0xf88478ce}, {2, 0xbfda6c4a}, {2, 0x731fe414}, {1, 0x6f1b362e},
+ {2, 0x6be709cf}, {1, 0x60553200}, {2, 0xf6a992f0}, {2, 0x1521f7f5},
+ {1, 0x8b440273}, {1, 0xe9ade0c8}, {1, 0x4d414618}, {5, 0x7b48070d},
+ {1, 0x1202ebae}, {1, 0xd23fe97e}, {1, 0x8d1d6505}, {1, 0xfafbaae3},
+ {1, 0xf200353e}, {1, 0xe77bd65e}, {1, 0x9fa32102}, {2, 0x68dfa747},
+ {0, 0x7c74d78e}, {1, 0x9b79cc6b}, {2, 0xad957cc2}, {2, 0x91acb818},
+ {1, 0x00024b92}, {1, 0x0002a868}, {1, 0x0000767a}, {1, 0x0003f818},
+ {1, 0x001e2f24}, {1, 0x001d43f5}, {1, 0x00074756}, {2, 0x0001cc72},
+ {0, 0x0002bb2c}, {1, 0x001a9616},
};
static CBlockIndex CreateBlockIndex(int nHeight) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
@@ -200,7 +200,8 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
// Note that by default, these tests run with size accounting enabled.
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
const CChainParams& chainparams = *chainParams;
- CScript scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
+ // changed this to dogecoin genesis pubkey script
+ CScript scriptPubKey = CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG;
std::unique_ptr<CBlockTemplate> pblocktemplate;
CMutableTransaction tx;
CScript script;
@@ -214,11 +215,6 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
// Simple block creation, nothing special yet:
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
- // Dogecoin: Disable tests which spend rewards, until we have 240+ blocks in the mining tests
- // TODO: Re-enable once we have Scrypt, Doge rewards and other early mining Dogecoin parameters in place,
- // and can calculate 240 blocks to put into blockinfo[] above.
- /*
-
// We can't make transactions until we have inputs
// Therefore, load 110 blocks :)
static_assert(sizeof(blockinfo) / sizeof(*blockinfo) == 110, "Should have 110 blocks to import");
@@ -230,7 +226,10 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
{
LOCK(cs_main);
pblock->nVersion = 1;
- pblock->nTime = ::ChainActive().Tip()->GetMedianTimePast()+1;
+ // Replaced ::ChainActive().Tip()->GetMedianTimePast()+1 with an actual 60 second block
+ // interval because median([1,2,2,3,3,3,4,4,4,4]) will eventually be problematic re:
+ // block timing. Tests should be more stable than that.
+ pblock->nTime = ::ChainActive().Tip()->GetBlockTime() + 60;
CMutableTransaction txCoinbase(*pblock->vtx[0]);
txCoinbase.nVersion = 1;
txCoinbase.vin[0].scriptSig = CScript();
@@ -420,7 +419,8 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
}
// non-final txs in mempool
- SetMockTime(::ChainActive().Tip()->GetMedianTimePast()+1);
+ // changed to 60 second block interval for consistency
+ SetMockTime(::ChainActive().Tip()->GetMedianTimePast()+60);
int flags = LOCKTIME_VERIFY_SEQUENCE|LOCKTIME_MEDIAN_TIME_PAST;
// height map
std::vector<int> prevheights;
@@ -506,7 +506,8 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++)
::ChainActive().Tip()->GetAncestor(::ChainActive().Tip()->nHeight - i)->nTime += 512; //Trick the MedianTimePast
::ChainActive().Tip()->nHeight++;
- SetMockTime(::ChainActive().Tip()->GetMedianTimePast() + 1);
+ // changed to 60 second block interval for consistency
+ SetMockTime(::ChainActive().Tip()->GetMedianTimePast() + 60);
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 5U);
@@ -517,7 +518,6 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
m_node.mempool->clear();
TestPackageSelection(chainparams, scriptPubKey, txFirst);
- */
fCheckpointsEnabled = true;
}
diff --git a/src/test/util/mining.cpp b/src/test/util/mining.cpp
index 74536ae74..ca4fa9f33 100644
--- a/src/test/util/mining.cpp
+++ b/src/test/util/mining.cpp
@@ -27,7 +27,7 @@ CTxIn MineBlock(const NodeContext& node, const CScript& coinbase_scriptPubKey)
{
auto block = PrepareBlock(node, coinbase_scriptPubKey);
- while (!CheckProofOfWork(block->GetHash(), block->nBits, Params().GetConsensus())) {
+ while (!CheckProofOfWork(block->GetPoWHash(), block->nBits, Params().GetConsensus())) {
++block->nNonce;
assert(block->nNonce);
}
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index f3428b7f8..405a51c92 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -219,7 +219,7 @@ CBlock TestChain240Setup::CreateAndProcessBlock(const std::vector<CMutableTransa
}
RegenerateCommitments(block);
- while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
+ while (!CheckProofOfWork(block.GetPoWHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(block);
Assert(m_node.chainman)->ProcessNewBlock(chainparams, shared_pblock, true, nullptr);
diff --git a/src/validation.cpp b/src/validation.cpp
index 4240f0c09..481eb0359 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -3526,8 +3526,8 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidatio
// Reject outdated version blocks when 95% (75% on testnet) of the network has upgraded:
// check for version 2, 3 and 4 upgrades
- if((block.nVersion < 2 && nHeight >= consensusParams.BIP34Height) ||
- (block.nVersion < 3 && nHeight >= consensusParams.BIP66Height) ||
+ // Dogecoin: Version 2 enforcement was never used
+ if((block.nVersion < 3 && nHeight >= consensusParams.BIP66Height) ||
(block.nVersion < 4 && nHeight >= consensusParams.BIP65Height))
return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, strprintf("bad-version(0x%08x)", block.nVersion),
strprintf("rejected nVersion=0x%08x block", block.nVersion));
diff --git a/src/version.h b/src/version.h
index 019c3a3ae..cdb18dcdf 100644
--- a/src/version.h
+++ b/src/version.h
@@ -15,7 +15,7 @@ static const int PROTOCOL_VERSION = 70016;
static const int INIT_PROTO_VERSION = 209;
//! disconnect from peers older than this proto version
-static const int MIN_PEER_PROTO_VERSION = 31800;
+static const int MIN_PEER_PROTO_VERSION = 70003;
//! BIP 0031, pong message, is enabled for all versions AFTER this one
static const int BIP0031_VERSION = 60000;