aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.qt.include88
-rw-r--r--src/Makefile.qt_locale.include87
-rw-r--r--src/chainparams.cpp3
-rw-r--r--src/coins.h10
-rw-r--r--src/consensus/params.h3
-rw-r--r--src/rpc/blockchain.cpp4
-rw-r--r--src/test/README.md42
-rw-r--r--src/validation.cpp3
8 files changed, 136 insertions, 104 deletions
diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include
index 7540122418..a8d3154107 100644
--- a/src/Makefile.qt.include
+++ b/src/Makefile.qt.include
@@ -6,93 +6,7 @@ bin_PROGRAMS += qt/bitcoin-qt
EXTRA_LIBRARIES += qt/libbitcoinqt.a
# bitcoin qt core #
-QT_TS = \
- qt/locale/bitcoin_af.ts \
- qt/locale/bitcoin_af_ZA.ts \
- qt/locale/bitcoin_ar.ts \
- qt/locale/bitcoin_be_BY.ts \
- qt/locale/bitcoin_bg_BG.ts \
- qt/locale/bitcoin_bg.ts \
- qt/locale/bitcoin_ca_ES.ts \
- qt/locale/bitcoin_ca.ts \
- qt/locale/bitcoin_ca@valencia.ts \
- qt/locale/bitcoin_cs.ts \
- qt/locale/bitcoin_cy.ts \
- qt/locale/bitcoin_da.ts \
- qt/locale/bitcoin_de.ts \
- qt/locale/bitcoin_el_GR.ts \
- qt/locale/bitcoin_el.ts \
- qt/locale/bitcoin_en_GB.ts \
- qt/locale/bitcoin_en.ts \
- qt/locale/bitcoin_eo.ts \
- qt/locale/bitcoin_es_AR.ts \
- qt/locale/bitcoin_es_CL.ts \
- qt/locale/bitcoin_es_CO.ts \
- qt/locale/bitcoin_es_DO.ts \
- qt/locale/bitcoin_es_ES.ts \
- qt/locale/bitcoin_es_MX.ts \
- qt/locale/bitcoin_es.ts \
- qt/locale/bitcoin_es_UY.ts \
- qt/locale/bitcoin_es_VE.ts \
- qt/locale/bitcoin_et_EE.ts \
- qt/locale/bitcoin_et.ts \
- qt/locale/bitcoin_eu_ES.ts \
- qt/locale/bitcoin_fa_IR.ts \
- qt/locale/bitcoin_fa.ts \
- qt/locale/bitcoin_fi.ts \
- qt/locale/bitcoin_fr_CA.ts \
- qt/locale/bitcoin_fr_FR.ts \
- qt/locale/bitcoin_fr.ts \
- qt/locale/bitcoin_gl.ts \
- qt/locale/bitcoin_he.ts \
- qt/locale/bitcoin_hi_IN.ts \
- qt/locale/bitcoin_hr.ts \
- qt/locale/bitcoin_hu.ts \
- qt/locale/bitcoin_id_ID.ts \
- qt/locale/bitcoin_it_IT.ts \
- qt/locale/bitcoin_it.ts \
- qt/locale/bitcoin_ja.ts \
- qt/locale/bitcoin_ka.ts \
- qt/locale/bitcoin_kk_KZ.ts \
- qt/locale/bitcoin_ko_KR.ts \
- qt/locale/bitcoin_ku_IQ.ts \
- qt/locale/bitcoin_ky.ts \
- qt/locale/bitcoin_la.ts \
- qt/locale/bitcoin_lt.ts \
- qt/locale/bitcoin_lv_LV.ts \
- qt/locale/bitcoin_mk_MK.ts \
- qt/locale/bitcoin_mn.ts \
- qt/locale/bitcoin_ms_MY.ts \
- qt/locale/bitcoin_nb.ts \
- qt/locale/bitcoin_ne.ts \
- qt/locale/bitcoin_nl.ts \
- qt/locale/bitcoin_pam.ts \
- qt/locale/bitcoin_pl.ts \
- qt/locale/bitcoin_pt_BR.ts \
- qt/locale/bitcoin_pt_PT.ts \
- qt/locale/bitcoin_ro_RO.ts \
- qt/locale/bitcoin_ro.ts \
- qt/locale/bitcoin_ru_RU.ts \
- qt/locale/bitcoin_ru.ts \
- qt/locale/bitcoin_sk.ts \
- qt/locale/bitcoin_sl_SI.ts \
- qt/locale/bitcoin_sq.ts \
- qt/locale/bitcoin_sr@latin.ts \
- qt/locale/bitcoin_sr.ts \
- qt/locale/bitcoin_sv.ts \
- qt/locale/bitcoin_ta.ts \
- qt/locale/bitcoin_th_TH.ts \
- qt/locale/bitcoin_tr_TR.ts \
- qt/locale/bitcoin_tr.ts \
- qt/locale/bitcoin_uk.ts \
- qt/locale/bitcoin_ur_PK.ts \
- qt/locale/bitcoin_uz@Cyrl.ts \
- qt/locale/bitcoin_vi.ts \
- qt/locale/bitcoin_vi_VN.ts \
- qt/locale/bitcoin_zh_CN.ts \
- qt/locale/bitcoin_zh_HK.ts \
- qt/locale/bitcoin_zh.ts \
- qt/locale/bitcoin_zh_TW.ts
+include Makefile.qt_locale.include
QT_FORMS_UI = \
qt/forms/addressbookpage.ui \
diff --git a/src/Makefile.qt_locale.include b/src/Makefile.qt_locale.include
new file mode 100644
index 0000000000..d9f23e8da2
--- /dev/null
+++ b/src/Makefile.qt_locale.include
@@ -0,0 +1,87 @@
+QT_TS = \
+ qt/locale/bitcoin_af.ts \
+ qt/locale/bitcoin_af_ZA.ts \
+ qt/locale/bitcoin_ar.ts \
+ qt/locale/bitcoin_be_BY.ts \
+ qt/locale/bitcoin_bg_BG.ts \
+ qt/locale/bitcoin_bg.ts \
+ qt/locale/bitcoin_ca_ES.ts \
+ qt/locale/bitcoin_ca.ts \
+ qt/locale/bitcoin_ca@valencia.ts \
+ qt/locale/bitcoin_cs.ts \
+ qt/locale/bitcoin_cy.ts \
+ qt/locale/bitcoin_da.ts \
+ qt/locale/bitcoin_de.ts \
+ qt/locale/bitcoin_el_GR.ts \
+ qt/locale/bitcoin_el.ts \
+ qt/locale/bitcoin_en_GB.ts \
+ qt/locale/bitcoin_en.ts \
+ qt/locale/bitcoin_eo.ts \
+ qt/locale/bitcoin_es_AR.ts \
+ qt/locale/bitcoin_es_CL.ts \
+ qt/locale/bitcoin_es_CO.ts \
+ qt/locale/bitcoin_es_DO.ts \
+ qt/locale/bitcoin_es_ES.ts \
+ qt/locale/bitcoin_es_MX.ts \
+ qt/locale/bitcoin_es.ts \
+ qt/locale/bitcoin_es_UY.ts \
+ qt/locale/bitcoin_es_VE.ts \
+ qt/locale/bitcoin_et_EE.ts \
+ qt/locale/bitcoin_et.ts \
+ qt/locale/bitcoin_eu_ES.ts \
+ qt/locale/bitcoin_fa_IR.ts \
+ qt/locale/bitcoin_fa.ts \
+ qt/locale/bitcoin_fi.ts \
+ qt/locale/bitcoin_fr_CA.ts \
+ qt/locale/bitcoin_fr_FR.ts \
+ qt/locale/bitcoin_fr.ts \
+ qt/locale/bitcoin_gl.ts \
+ qt/locale/bitcoin_he.ts \
+ qt/locale/bitcoin_hi_IN.ts \
+ qt/locale/bitcoin_hr.ts \
+ qt/locale/bitcoin_hu.ts \
+ qt/locale/bitcoin_id_ID.ts \
+ qt/locale/bitcoin_it_IT.ts \
+ qt/locale/bitcoin_it.ts \
+ qt/locale/bitcoin_ja.ts \
+ qt/locale/bitcoin_ka.ts \
+ qt/locale/bitcoin_kk_KZ.ts \
+ qt/locale/bitcoin_ko_KR.ts \
+ qt/locale/bitcoin_ku_IQ.ts \
+ qt/locale/bitcoin_ky.ts \
+ qt/locale/bitcoin_la.ts \
+ qt/locale/bitcoin_lt.ts \
+ qt/locale/bitcoin_lv_LV.ts \
+ qt/locale/bitcoin_mk_MK.ts \
+ qt/locale/bitcoin_mn.ts \
+ qt/locale/bitcoin_ms_MY.ts \
+ qt/locale/bitcoin_nb.ts \
+ qt/locale/bitcoin_ne.ts \
+ qt/locale/bitcoin_nl.ts \
+ qt/locale/bitcoin_pam.ts \
+ qt/locale/bitcoin_pl.ts \
+ qt/locale/bitcoin_pt_BR.ts \
+ qt/locale/bitcoin_pt_PT.ts \
+ qt/locale/bitcoin_ro_RO.ts \
+ qt/locale/bitcoin_ro.ts \
+ qt/locale/bitcoin_ru_RU.ts \
+ qt/locale/bitcoin_ru.ts \
+ qt/locale/bitcoin_sk.ts \
+ qt/locale/bitcoin_sl_SI.ts \
+ qt/locale/bitcoin_sq.ts \
+ qt/locale/bitcoin_sr@latin.ts \
+ qt/locale/bitcoin_sr.ts \
+ qt/locale/bitcoin_sv.ts \
+ qt/locale/bitcoin_ta.ts \
+ qt/locale/bitcoin_th_TH.ts \
+ qt/locale/bitcoin_tr_TR.ts \
+ qt/locale/bitcoin_tr.ts \
+ qt/locale/bitcoin_uk.ts \
+ qt/locale/bitcoin_ur_PK.ts \
+ qt/locale/bitcoin_uz@Cyrl.ts \
+ qt/locale/bitcoin_vi.ts \
+ qt/locale/bitcoin_vi_VN.ts \
+ qt/locale/bitcoin_zh_CN.ts \
+ qt/locale/bitcoin_zh_HK.ts \
+ qt/locale/bitcoin_zh.ts \
+ qt/locale/bitcoin_zh_TW.ts
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index ad766471dc..5964877eb8 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -71,6 +71,7 @@ public:
consensus.BIP66Height = 363725; // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931
consensus.CSVHeight = 419328; // 000000000000000004a1b34462cb8aeebd5799177f7a29cf28f2d1961716b5b5
consensus.SegwitHeight = 481824; // 0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893
+ consensus.MinBIP9WarningHeight = consensus.SegwitHeight + consensus.nMinerConfirmationWindow;
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
consensus.nPowTargetSpacing = 10 * 60;
@@ -177,6 +178,7 @@ public:
consensus.BIP66Height = 330776; // 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182
consensus.CSVHeight = 770112; // 00000000025e930139bac5c6c31a403776da130831ab85be56578f3fa75369bb
consensus.SegwitHeight = 834624; // 00000000002b980fcd729daaa248fd9316a5200e9b367f4ff2c42453e84201ca
+ consensus.MinBIP9WarningHeight = consensus.SegwitHeight + consensus.nMinerConfirmationWindow;
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
consensus.nPowTargetSpacing = 10 * 60;
@@ -261,6 +263,7 @@ public:
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in functional tests)
consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests)
consensus.SegwitHeight = 0; // SEGWIT is always activated on regtest unless overridden
+ consensus.MinBIP9WarningHeight = 0;
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
consensus.nPowTargetSpacing = 10 * 60;
diff --git a/src/coins.h b/src/coins.h
index dca1beabb6..d8135e0d9a 100644
--- a/src/coins.h
+++ b/src/coins.h
@@ -95,8 +95,16 @@ public:
* This *must* return size_t. With Boost 1.46 on 32-bit systems the
* unordered_map will behave unpredictably if the custom hasher returns a
* uint64_t, resulting in failures when syncing the chain (#4634).
+ *
+ * Having the hash noexcept allows libstdc++'s unordered_map to recalculate
+ * the hash during rehash, so it does not have to cache the value. This
+ * reduces node's memory by sizeof(size_t). The required recalculation has
+ * a slight performance penalty (around 1.6%), but this is compensated by
+ * memory savings of about 9% which allow for a larger dbcache setting.
+ *
+ * @see https://gcc.gnu.org/onlinedocs/gcc-9.2.0/libstdc++/manual/manual/unordered_associative.html
*/
- size_t operator()(const COutPoint& id) const {
+ size_t operator()(const COutPoint& id) const noexcept {
return SipHashUint256Extra(k0, k1, id.hash, id.n);
}
};
diff --git a/src/consensus/params.h b/src/consensus/params.h
index 8263b0fef4..2f8c490dc4 100644
--- a/src/consensus/params.h
+++ b/src/consensus/params.h
@@ -62,6 +62,9 @@ struct Params {
* Note that segwit v0 script rules are enforced on all blocks except the
* BIP 16 exception blocks. */
int SegwitHeight;
+ /** Don't warn about unknown BIP 9 activations below this height.
+ * This prevents us from warning about the CSV and segwit activations. */
+ int MinBIP9WarningHeight;
/**
* Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period,
* (nPowTargetTimespan / nPowTargetSpacing) which is also used for BIP9 deployments.
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 9513c2b9ac..02717fa80f 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -1159,7 +1159,7 @@ static void BIP9SoftForkDescPushBack(UniValue& softforks, const std::string &nam
{
bip9.pushKV("bit", consensusParams.vDeployments[id].bit);
}
- bip9.pushKV("startTime", consensusParams.vDeployments[id].nStartTime);
+ bip9.pushKV("start_time", consensusParams.vDeployments[id].nStartTime);
bip9.pushKV("timeout", consensusParams.vDeployments[id].nTimeout);
int64_t since_height = VersionBitsTipStateSinceHeight(consensusParams, id);
bip9.pushKV("since", since_height);
@@ -1213,7 +1213,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
" \"bip9\": { (object) status of bip9 softforks (only for \"bip9\" type)\n"
" \"status\": \"xxxx\", (string) one of \"defined\", \"started\", \"locked_in\", \"active\", \"failed\"\n"
" \"bit\": xx, (numeric) the bit (0-28) in the block version field used to signal this softfork (only for \"started\" status)\n"
- " \"startTime\": xx, (numeric) the minimum median time past of a block at which the bit gains its meaning\n"
+ " \"start_time\": xx, (numeric) the minimum median time past of a block at which the bit gains its meaning\n"
" \"timeout\": xx, (numeric) the median time past of a block at which the deployment is considered failed if not yet locked in\n"
" \"since\": xx, (numeric) height of the first block to which the status applies\n"
" \"statistics\": { (object) numeric statistics about BIP9 signalling for a softfork\n"
diff --git a/src/test/README.md b/src/test/README.md
index 8901fae7bd..96dcb072bc 100644
--- a/src/test/README.md
+++ b/src/test/README.md
@@ -1,3 +1,15 @@
+# Unit tests
+
+The sources in this directory are unit test cases. Boost includes a
+unit testing framework, and since Bitcoin Core already uses Boost, it makes
+sense to simply use this framework rather than require developers to
+configure some other framework (we want as few impediments to creating
+unit tests as possible).
+
+The build system is set up to compile an executable called `test_bitcoin`
+that runs all of the unit tests. The main source file is called
+`setup_common.cpp`.
+
### Compiling/running unit tests
Unit tests will be automatically compiled if dependencies were met in `./configure`
@@ -12,7 +24,7 @@ to run the bitcoind tests.
To add more bitcoind tests, add `BOOST_AUTO_TEST_CASE` functions to the existing
.cpp files in the `test/` directory or add new .cpp files that
-implement new BOOST_AUTO_TEST_SUITE sections.
+implement new `BOOST_AUTO_TEST_SUITE` sections.
To run the bitcoin-qt tests manually, launch `src/qt/test/test_bitcoin-qt`
@@ -32,20 +44,24 @@ example, to run just the getarg_tests verbosely:
Run `test_bitcoin --help` for the full list.
-### Note on adding test cases
-
-The sources in this directory are unit test cases. Boost includes a
-unit testing framework, and since bitcoin already uses boost, it makes
-sense to simply use this framework rather than require developers to
-configure some other framework (we want as few impediments to creating
-unit tests as possible).
+### Adding test cases
-The build system is setup to compile an executable called `test_bitcoin`
-that runs all of the unit tests. The main source file is called
-setup_common.cpp. To add a new unit test file to our test suite you need
+To add a new unit test file to our test suite you need
to add the file to `src/Makefile.test.include`. The pattern is to create
one test file for each class or source file for which you want to create
-unit tests. The file naming convention is `<source_filename>_tests.cpp`
+unit tests. The file naming convention is `<source_filename>_tests.cpp`
and such files should wrap their tests in a test suite
called `<source_filename>_tests`. For an example of this pattern,
-examine `uint256_tests.cpp`.
+see `uint256_tests.cpp`.
+
+### Logging and debugging in unit tests
+
+To write to logs from unit tests you need to use specific message methods
+provided by Boost. The simplest is `BOOST_TEST_MESSAGE`.
+
+For debugging you can launch the test_bitcoin executable with `gdb`or `lldb` and
+start debugging, just like you would with bitcoind:
+
+```bash
+gdb src/test/test_bitcoin
+```
diff --git a/src/validation.cpp b/src/validation.cpp
index 1e7b9c7e68..1faaa411c4 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -1821,7 +1821,8 @@ public:
bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const override
{
- return ((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) &&
+ return pindex->nHeight >= params.MinBIP9WarningHeight &&
+ ((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) &&
((pindex->nVersion >> bit) & 1) != 0 &&
((ComputeBlockVersion(pindex->pprev, params) >> bit) & 1) == 0;
}