From f47680424d80761859de33dde9c0cdc4762fa8f9 Mon Sep 17 00:00:00 2001 From: Brannon King Date: Thu, 18 Jul 2019 14:35:18 -0600 Subject: [PATCH] fix crash on cli help fix bech32 prefix bumped version improve trie read RAM use, fix a few compiler warnings open segwit window until Jan 2020 work around Windows ICU build issue upped the soft fork thresh length to a week open testnet soft forks window clarifying segwit to be manually enabled same for testnet --- configure.ac | 4 +-- depends/packages/icu.mk | 1 + packaging/build_darwin_64bit.sh | 3 ++ packaging/build_linux_64bit.sh | 3 ++ packaging/build_windows_32bit.sh | 3 ++ packaging/build_windows_64bit.sh | 3 ++ src/chainparams.cpp | 14 ++++---- src/claimtrie.cpp | 5 ++- src/claimtrie.h | 4 +-- src/rpc/claimtrie.cpp | 20 +++++------ src/test/data/key_io_valid.json | 58 ++++---------------------------- src/test/setup_common.h | 6 ++-- src/test/versionbits_tests.cpp | 28 ++++++++------- src/validation.cpp | 14 ++------ 14 files changed, 63 insertions(+), 103 deletions(-) diff --git a/configure.ac b/configure.ac index 6abe31645..1ffdbb849 100644 --- a/configure.ac +++ b/configure.ac @@ -2,9 +2,9 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 0) define(_CLIENT_VERSION_MINOR, 19) -define(_CLIENT_VERSION_REVISION, 2) +define(_CLIENT_VERSION_REVISION, 0) define(_CLIENT_VERSION_BUILD, 0) -define(_CLIENT_VERSION_RC, 0) +define(_CLIENT_VERSION_RC, 1) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2019) define(_COPYRIGHT_HOLDERS,[The %s developers]) diff --git a/depends/packages/icu.mk b/depends/packages/icu.mk index 696ececc2..9a8bb65a4 100644 --- a/depends/packages/icu.mk +++ b/depends/packages/icu.mk @@ -22,6 +22,7 @@ define $(package)_preprocess_cmds PKG_CONFIG_SYSROOT_DIR=/ \ PKG_CONFIG_LIBDIR=$(host_prefix)/lib/pkgconfig \ PKG_CONFIG_PATH=$(host_prefix)/share/pkgconfig \ + sed -i.old 's/^GEN_DEPS.cc.*/& $(CXXFLAGS)/' source/config/mh-mingw* && \ mkdir -p build && cd build && \ ../source/runConfigureICU Linux $($(package)_standard_opts) CXXFLAGS=-std=c++11 && \ $(MAKE) && cd .. diff --git a/packaging/build_darwin_64bit.sh b/packaging/build_darwin_64bit.sh index c69c78417..606dd51f8 100755 --- a/packaging/build_darwin_64bit.sh +++ b/packaging/build_darwin_64bit.sh @@ -29,6 +29,9 @@ if which ccache >/dev/null; then ccache -ps fi +export CXXFLAGS="${CXXFLAGS:--O2 -frecord-gcc-switches}" +echo "CXXFLAGS set to $CXXFLAGS" + pushd depends make -j`getconf _NPROCESSORS_ONLN` HOST=x86_64-apple-darwin14 NO_QT=1 V=1 popd diff --git a/packaging/build_linux_64bit.sh b/packaging/build_linux_64bit.sh index ba8330e38..e3f58dac3 100755 --- a/packaging/build_linux_64bit.sh +++ b/packaging/build_linux_64bit.sh @@ -16,6 +16,9 @@ if which ccache >/dev/null; then ccache -ps fi +export CXXFLAGS="${CXXFLAGS:--O2 -frecord-gcc-switches}" +echo "CXXFLAGS set to $CXXFLAGS" + cd depends make -j`getconf _NPROCESSORS_ONLN` HOST=x86_64-pc-linux-gnu NO_QT=1 V=1 cd .. diff --git a/packaging/build_windows_32bit.sh b/packaging/build_windows_32bit.sh index 8d9bcfbf9..c87e66593 100755 --- a/packaging/build_windows_32bit.sh +++ b/packaging/build_windows_32bit.sh @@ -20,6 +20,9 @@ if which ccache >/dev/null; then ccache -ps fi +export CXXFLAGS="${CXXFLAGS:--O2 -frecord-gcc-switches}" +echo "CXXFLAGS set to $CXXFLAGS" + pushd depends make -j`getconf _NPROCESSORS_ONLN` HOST=i686-w64-mingw32 NO_QT=1 V=1 popd diff --git a/packaging/build_windows_64bit.sh b/packaging/build_windows_64bit.sh index 121f4f206..13386e016 100755 --- a/packaging/build_windows_64bit.sh +++ b/packaging/build_windows_64bit.sh @@ -19,6 +19,9 @@ if which ccache >/dev/null; then ccache -ps fi +export CXXFLAGS="${CXXFLAGS:--O2 -frecord-gcc-switches}" +echo "CXXFLAGS set to $CXXFLAGS" + pushd depends make -j`getconf _NPROCESSORS_ONLN` HOST=x86_64-w64-mingw32 NO_QT=1 V=1 popd diff --git a/src/chainparams.cpp b/src/chainparams.cpp index a6697cd76..27fa20c3d 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -121,8 +121,8 @@ public: consensus.BIP34Height = 1; consensus.BIP34Hash = uint256S("0xdecb9e2cca03a419fd9cca0cb2b1d5ad11b088f22f8f38556d93ac4358b86c24"); // FIXME: adjust heights - consensus.BIP65Height = 600000; - consensus.BIP66Height = 600000; + consensus.BIP65Height = 200000; + consensus.BIP66Height = 200000; consensus.powLimit = uint256S("0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); consensus.nPowTargetTimespan = 150; //retarget every block consensus.CSVHeight = 419328; // 000000000000000004a1b34462cb8aeebd5799177f7a29cf28f2d1961716b5b5 @@ -139,8 +139,8 @@ public: consensus.nMaxTakeoverWorkaroundHeight = 10000000; consensus.fPowAllowMinDifficultyBlocks = false; consensus.fPowNoRetargeting = false; - consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016 - consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing + consensus.nRuleChangeActivationThreshold = 3830; // 95% of a week + consensus.nMinerConfirmationWindow = 4032; // week 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 @@ -191,7 +191,7 @@ public: vFixedSeeds = std::vector(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main)); - bech32_hrp = "bc"; + bech32_hrp = "lbc"; vFixedSeeds = std::vector(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main)); @@ -291,7 +291,7 @@ public: base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF}; base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; - bech32_hrp = "tb"; + bech32_hrp = "tlbc"; vFixedSeeds = std::vector(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test)); @@ -406,7 +406,7 @@ public: base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF}; base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; - bech32_hrp = "bcrt"; + bech32_hrp = "rlbc"; } /** diff --git a/src/claimtrie.cpp b/src/claimtrie.cpp index 7d4b7aec0..db6c53377 100644 --- a/src/claimtrie.cpp +++ b/src/claimtrie.cpp @@ -477,7 +477,7 @@ bool CClaimTrieCacheBase::ReadFromDisk(const CBlockIndex* tip) base->clear(); boost::scoped_ptr pcursor(base->db->NewIterator()); - std::unordered_map hashesOnEmptyNodes; + std::vector> hashesOnEmptyNodes; for (pcursor->SeekToFirst(); pcursor->Valid(); pcursor->Next()) { std::pair key; @@ -489,7 +489,7 @@ bool CClaimTrieCacheBase::ReadFromDisk(const CBlockIndex* tip) if (data.empty()) { // we have a situation where our old trie had many empty nodes // we don't want to automatically throw those all into our prefix trie - hashesOnEmptyNodes.emplace(key.second, data.hash); + hashesOnEmptyNodes.emplace_back(key.second, data.hash); continue; } @@ -514,7 +514,6 @@ bool CClaimTrieCacheBase::ReadFromDisk(const CBlockIndex* tip) } } - LogPrintf("Checking claim trie consistency... "); if (checkConsistency()) { LogPrintf("consistent\n"); diff --git a/src/claimtrie.h b/src/claimtrie.h index b57e0dcce..5c5af60fd 100644 --- a/src/claimtrie.h +++ b/src/claimtrie.h @@ -318,7 +318,7 @@ public: bool SyncToDisk(); friend class CClaimTrieCacheBase; - friend class ClaimTrieChainFixture; + friend struct ClaimTrieChainFixture; friend class CClaimTrieCacheExpirationFork; friend class CClaimTrieCacheNormalizationFork; }; @@ -532,7 +532,7 @@ private: typename expirationQueueType::value_type* getSupportExpirationQueueCacheRow(int nHeight, bool createIfNotExists = false); // for unit test - friend class ClaimTrieChainFixture; + friend struct ClaimTrieChainFixture; friend class CClaimTrieCacheTest; }; diff --git a/src/rpc/claimtrie.cpp b/src/rpc/claimtrie.cpp index 8857e880b..9a4e13c5d 100644 --- a/src/rpc/claimtrie.cpp +++ b/src/rpc/claimtrie.cpp @@ -137,18 +137,10 @@ bool validParams(const UniValue& params, uint8_t required, uint8_t optional) static UniValue getclaimsintrie(const JSONRPCRequest& request) { - if (!IsDeprecatedRPCEnabled("getclaimsintrie")) { - const auto msg = "getclaimsintrie is deprecated and will be removed in v0.18. To use this command, start with -deprecatedrpc=getclaimsintrie"; - if (request.fHelp) { - throw std::runtime_error(msg); - } - throw JSONRPCError(RPC_METHOD_DEPRECATED, msg); - } - if (request.fHelp || request.params.size() > 1) throw std::runtime_error( "getclaimsintrie\n" - "Return all claims in the name trie.\n" + "Return all claims in the name trie. Deprecated.\n" "Arguments:\n" "1. \"blockhash\" (string, optional) get claims in the trie\n" " at the block specified\n" @@ -174,6 +166,14 @@ static UniValue getclaimsintrie(const JSONRPCRequest& request) " }\n" "]\n"); + if (!IsDeprecatedRPCEnabled("getclaimsintrie")) { + const auto msg = "getclaimsintrie is deprecated and will be removed in v0.18. To use this command, start with -deprecatedrpc=getclaimsintrie"; + if (request.fHelp) { + throw std::runtime_error(msg); + } + throw JSONRPCError(RPC_METHOD_DEPRECATED, msg); + } + LOCK(cs_main); CCoinsViewCache coinsCache(pcoinsTip.get()); @@ -899,7 +899,7 @@ static const CRPCCommand commands[] = // --------------------- ------------------------ ----------------------- ---------- { "Claimtrie", "getclaimsintrie", &getclaimsintrie, { "blockhash" } }, { "Claimtrie", "getnamesintrie", &getnamesintrie, { "blockhash" } }, - { "Claimtrie", "getclaimtrie", &getclaimtrie, { "" } }, + { "hidden", "getclaimtrie", &getclaimtrie, { } }, { "Claimtrie", "getvalueforname", &getvalueforname, { "name","blockhash" } }, { "Claimtrie", "getclaimsforname", &getclaimsforname, { "name","blockhash" } }, { "Claimtrie", "gettotalclaimednames", &gettotalclaimednames, { "" } }, diff --git a/src/test/data/key_io_valid.json b/src/test/data/key_io_valid.json index 7bbaddfb9..e5a1193f0 100644 --- a/src/test/data/key_io_valid.json +++ b/src/test/data/key_io_valid.json @@ -459,8 +459,8 @@ } ], [ - "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4", - "0014751e76e8199196d454941c45d1b3a323f1433bd6", + "lbc1qxph5rn26f3ky6cxgkwgsz2x5uaga4muj4zfpvp", + "0014306f41cd5a4c6c4d60c8b3910128d4e751daef92", { "isPrivkey": false, "chain": "lbrycrd", @@ -468,17 +468,8 @@ } ], [ - "bcrt1qw508d6qejxtdg4y5r3zarvary0c5xw7kygt080", - "0014751e76e8199196d454941c45d1b3a323f1433bd6", - { - "isPrivkey": false, - "chain": "regtest", - "tryCaseFlip": true - } - ], - [ - "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7", - "00201863143c14c5166804bd19203356da136c985678cd4d27a1b8c6329604903262", + "tlbc1q7h2lv2hwl26eywahnl7ceyqtfsn0dt2vkag95n", + "0014f5d5f62aeefab5923bb79ffd8c900b4c26f6ad4c", { "isPrivkey": false, "chain": "lbrycrdtest", @@ -486,48 +477,13 @@ } ], [ - "bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx", - "5128751e76e8199196d454941c45d1b3a323f1433bd6751e76e8199196d454941c45d1b3a323f1433bd6", - { - "isPrivkey": false, - "chain": "lbrycrd", - "tryCaseFlip": true - } - ], - [ - "bc1sw50qa3jx3s", - "6002751e", - { - "isPrivkey": false, - "chain": "lbrycrd", - "tryCaseFlip": true - } - ], - [ - "bc1zw508d6qejxtdg4y5r3zarvaryvg6kdaj", - "5210751e76e8199196d454941c45d1b3a323", - { - "isPrivkey": false, - "chain": "lbrycrd", - "tryCaseFlip": true - } - ], - [ - "tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy", - "0020000000c4a5cad46221b2a187905e5266362b99d5e91c6ce24d165dab93e86433", - { - "isPrivkey": false, - "chain": "lbrycrdtest", - "tryCaseFlip": true - } - ], - [ - "bcrt1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvseswlauz7", - "0020000000c4a5cad46221b2a187905e5266362b99d5e91c6ce24d165dab93e86433", + "rlbc1q9rjqlxnxnyag659jvp90wxchu9sxsskcvgtqju", + "001428e40f9a66993a8d50b2604af71b17e1606842d8", { "isPrivkey": false, "chain": "regtest", "tryCaseFlip": true } ] + ] diff --git a/src/test/setup_common.h b/src/test/setup_common.h index b4b5e7779..eb2f3b68b 100644 --- a/src/test/setup_common.h +++ b/src/test/setup_common.h @@ -135,13 +135,13 @@ std::ostream& operator<<(std::ostream& os, const uint256& num); std::ostream& operator<<(std::ostream& os, const uint160& num); std::ostream& operator<<(std::ostream& os, const COutPoint& point); -class CClaimValue; +struct CClaimValue; std::ostream& operator<<(std::ostream& os, const CClaimValue& claim); -class CSupportValue; +struct CSupportValue; std::ostream& operator<<(std::ostream& os, const CSupportValue& support); -class CClaimTrieData; +struct CClaimTrieData; std::ostream& operator<<(std::ostream& os, const CClaimTrieData& data); #endif diff --git a/src/test/versionbits_tests.cpp b/src/test/versionbits_tests.cpp index 0ca3a1797..822a2fc96 100644 --- a/src/test/versionbits_tests.cpp +++ b/src/test/versionbits_tests.cpp @@ -268,15 +268,17 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion) // Start generating blocks before nStartTime int64_t nTime = nStartTime - 1; + const uint32_t period = mainnetParams.nMinerConfirmationWindow; + // Before MedianTimePast of the chain has crossed nStartTime, the bit // should not be set. CBlockIndex *lastBlock = nullptr; - lastBlock = firstChain.Mine(mainnetParams.nMinerConfirmationWindow, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip(); + lastBlock = firstChain.Mine(period, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip(); BOOST_CHECK_EQUAL(ComputeBlockVersion(lastBlock, mainnetParams) & (1< 0) { lastBlock = firstChain.Mine(nHeight+1, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip(); @@ -313,7 +315,7 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion) nTime = nTimeout; // FAILED is only triggered at the end of a period, so CBV should be setting // the bit until the period transition. - for (uint32_t i = 0; i < mainnetParams.nMinerConfirmationWindow - 1; i++) { + for (uint32_t i=0; i 0) { -// assert(undo.nHeight == txUndo.vprevout[i].nHeight); -// assert(undo.fCoinBase == txUndo.vprevout[i].fCoinBase); -// break; -// } -// } } // restore claim if applicable if (undo.fIsClaim && !undo.txout.scriptPubKey.empty()) { - int nValidHeight = static_cast(undo.nClaimValidHeight); + auto nValidHeight = undo.nClaimValidHeight; if (nValidHeight > 0 && nValidHeight >= undo.nHeight) { CClaimScriptUndoSpendOp undoSpend(COutPoint(out.hash, out.n), undo.txout.nValue, undo.nHeight, nValidHeight); ProcessClaim(undoSpend, trieCache, undo.txout.scriptPubKey); @@ -2340,7 +2330,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl if (i > 0 && !mClaimUndoHeights.empty()) { auto& txinUndos = blockundo.vtxundo.back().vprevout; - for (std::map::iterator itHeight = mClaimUndoHeights.begin(); itHeight != mClaimUndoHeights.end(); ++itHeight) + for (auto itHeight = mClaimUndoHeights.begin(); itHeight != mClaimUndoHeights.end(); ++itHeight) { txinUndos[itHeight->first].nClaimValidHeight = itHeight->second; txinUndos[itHeight->first].fIsClaim = true;