From 474dd760e1eeb2ad6ae4d2a34137aba510049385 Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 3 Mar 2021 09:57:41 +0800 Subject: [PATCH 01/15] Merge #21333: build: set Unicode true for NSIS installer 9086e0dd3c924b6c9a5ad05799d30d97b9ced3be build: set Unicode true for NSIS installer (fanquake) Pull request description: Now that we are using Focal for gitian builds, and have [NSIS 3.0+ available](https://packages.ubuntu.com/focal/nsis) (also in Guix), we can create installers that [support unicode](https://nsis.sourceforge.io/Docs/Chapter4.html#aunicodetarget). Unicode is only becoming the NSIS default [beginning with the 3.07 release](https://nsis.sourceforge.io/Docs/AppendixF.html#v3.07-cl), so we need to set this attribute to get support. Should close: #13817 Gitian builds: ```bash b8553615b6b4be5e4459e03796e700b30b5d198a7f184f27be6983ff901b5592 bitcoin-9086e0dd3c92-win-unsigned.tar.gz a6b024a5a68e0196e8e118168c918285e820f2d0ffe9c38db680580459da8bf3 bitcoin-9086e0dd3c92-win64-debug.zip ff4003d4f61127c707e44b5235eaf924b30351f20cde27e775131982a1b4cf92 bitcoin-9086e0dd3c92-win64-setup-unsigned.exe 1876bee55fa9ea99b91203975c13d0ad8a046b4b58068bde41c977fd1d12de13 bitcoin-9086e0dd3c92-win64.zip 000f2778f8f166a89b4ab35f155156c1c34800be6e47d29b5308043c50128392 src/bitcoin-9086e0dd3c92.tar.gz d650a9b8f2dd1df777bf42439dfcbcf6bc358e30ec148b9992a18b39f76b1ecf bitcoin-core-win-22-res.yml ``` ACKs for top commit: laanwj: ACK 9086e0dd3c924b6c9a5ad05799d30d97b9ced3be hebasto: ACK 9086e0dd3c924b6c9a5ad05799d30d97b9ced3be, tested on Windows 10 Pro (20H2, build 19042.804): Tree-SHA512: cc7b7ca05877571d0a29a7d36e40279f54d886d8ab27facfa722c2ee95a1fc06c2bad8ef1eb1980d283ae981659d737021a46c8f4618e24d510b5ab384990e09 --- share/setup.nsi.in | 1 + 1 file changed, 1 insertion(+) diff --git a/share/setup.nsi.in b/share/setup.nsi.in index 8c8677b037a5..fce609cdde00 100644 --- a/share/setup.nsi.in +++ b/share/setup.nsi.in @@ -3,6 +3,7 @@ Name "@PACKAGE_NAME@ (64-bit)" RequestExecutionLevel highest SetCompressor /SOLID lzma SetDateSave off +Unicode true # Uncomment these lines when investigating reproducibility errors #SetCompress off From 62b47ddf261a40eb84e395396c277a1212f5328c Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 5 Mar 2021 10:42:32 +0800 Subject: [PATCH 02/15] Merge #21364: fuzz: Avoid -Wreturn-type warnings 3f3646855c4005670909c8e76de91ad07c559c66 fuzz: Avoid -Wreturn-type warnings (practicalswift) Pull request description: Avoid `-Wreturn-type` warnings. Closes #21355. ACKs for top commit: MarcoFalke: cr ACK 3f3646855c4005670909c8e76de91ad07c559c66 fanquake: ACK 3f3646855c4005670909c8e76de91ad07c559c66 - thanks for cleaning this up. Tree-SHA512: 6fa2640a26e64d2bea60e016ad14b5c434137fedc0b3bf2ac244f02f9b1cd303d1ebac4ac4e6791534560f8311c4cbe9395c2ce94d7ec022d3b192f1ea070809 --- src/test/fuzz/util.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index 765dfcffbf5b..5d3a7a2982fb 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -521,11 +522,13 @@ class FuzzedSock : public Sock SOCKET Get() const override { assert(false && "Not implemented yet."); + return INVALID_SOCKET; } SOCKET Release() override { assert(false && "Not implemented yet."); + return INVALID_SOCKET; } void Reset() override From 249d8a85d4cbcbd6784b787777f7ac3e52b69be8 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 8 Mar 2021 08:23:04 +0100 Subject: [PATCH 03/15] Merge #21371: fuzz: fix gcc Woverloaded-virtual build warnings 36aa2955b816c666f1c27cf6f3d43c75444fab48 fuzz: fix gcc Woverloaded-virtual build warnings (Jon Atack) Pull request description: Possible fixup to gcc build warnings since merge of b22d4c1607b. Closes #21369. ACKs for top commit: practicalswift: cr ACK 36aa2955b816c666f1c27cf6f3d43c75444fab48: patch looks correct achow101: ACK 36aa2955b816c666f1c27cf6f3d43c75444fab48 kristapsk: ACK 36aa2955b816c666f1c27cf6f3d43c75444fab48, this fixes compiler warnings for me with GCC 9.3.0. Tree-SHA512: b6c99690ff72b809ce8105696744546252691b618f54311a9d930d9975fc692071ef408450f618fbb4aa99ee5390028a6eabbc968e22b2e8d2bd56bbafef49f8 --- src/test/fuzz/util.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index 5d3a7a2982fb..8bbc32c7f5d0 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -519,6 +519,12 @@ class FuzzedSock : public Sock { } + FuzzedSock& operator=(Sock&& other) override + { + assert(false && "Not implemented yet."); + return *this; + } + SOCKET Get() const override { assert(false && "Not implemented yet."); From 6e6f7c5994d00e6de6b0dcc0a82479d00621f51a Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Fri, 19 Mar 2021 20:52:10 +0100 Subject: [PATCH 04/15] Merge #18335: bitcoin-cli: print useful error if bitcoind rpc work queue exceeded 8dd5946c0b7aa8f3976b14a5de4ce84b80a9c32a add functional test (Larry Ruane) b5a80fa7e487c37b7ac0e3874a2fabade41b9ca8 util: Handle HTTP_SERVICE_UNAVAILABLE in bitcoin-cli (Hennadii Stepanov) Pull request description: If `bitcoind` is processing 16 RPC requests, attempting to submit another request using `bitcoin-cli` produces this less-than-helpful error message: `error: couldn't parse reply from server`. This PR changes the error to: `error: server response: Work queue depth exceeded`. ACKs for top commit: fjahr: tACK 8dd5946c0b7aa8f3976b14a5de4ce84b80a9c32a luke-jr: utACK 8dd5946c0b7aa8f3976b14a5de4ce84b80a9c32a (no changes since previous utACK) hebasto: re-ACK 8dd5946c0b7aa8f3976b14a5de4ce84b80a9c32a, only suggested changes since my [previous](https://github.com/bitcoin/bitcoin/pull/18335#pullrequestreview-460621350) review. darosior: ACK 8dd5946c0b7aa8f3976b14a5de4ce84b80a9c32a Tree-SHA512: 33e25f6ff05d9b56fae2bdb68b132557bb8e995f5438ac4fbbc53c304c5152a98aa43c43600c31d8a6a2830cbd48bf8ec7d89dce50190b29ec00a43830126913 --- src/bitcoin-cli.cpp | 2 ++ src/httpserver.cpp | 2 +- test/functional/interface_rpc.py | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 944ca1344291..53ae2ed867ac 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -409,6 +409,8 @@ static UniValue CallRPC(BaseRequestHandler *rh, const std::string& strMethod, co } else { throw std::runtime_error("Authorization failed: Incorrect rpcuser or rpcpassword"); } + } else if (response.status == HTTP_SERVICE_UNAVAILABLE) { + throw std::runtime_error(strprintf("Server response: %s", response.body)); } else if (response.status >= 400 && response.status != HTTP_BAD_REQUEST && response.status != HTTP_NOT_FOUND && response.status != HTTP_INTERNAL_SERVER_ERROR) throw std::runtime_error(strprintf("server returned HTTP error %d", response.status)); else if (response.body.empty()) diff --git a/src/httpserver.cpp b/src/httpserver.cpp index d57a404683ed..be0c3ed0a803 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -267,7 +267,7 @@ static void http_request_cb(struct evhttp_request* req, void* arg) item.release(); /* if true, queue took ownership */ } else { LogPrintf("WARNING: request rejected because http work queue depth exceeded, it can be increased with the -rpcworkqueue= setting\n"); - item->req->WriteReply(HTTP_INTERNAL_SERVER_ERROR, "Work queue depth exceeded"); + item->req->WriteReply(HTTP_SERVICE_UNAVAILABLE, "Work queue depth exceeded"); } } else { hreq->WriteReply(HTTP_NOT_FOUND); diff --git a/test/functional/interface_rpc.py b/test/functional/interface_rpc.py index 6884b1b76074..467eb98ebde2 100755 --- a/test/functional/interface_rpc.py +++ b/test/functional/interface_rpc.py @@ -8,6 +8,9 @@ from test_framework.authproxy import JSONRPCException from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, assert_greater_than_or_equal +from threading import Thread +import subprocess + def expect_http_status(expected_http_status, expected_rpc_code, fcn, *args): @@ -18,6 +21,16 @@ def expect_http_status(expected_http_status, expected_rpc_code, assert_equal(exc.error["code"], expected_rpc_code) assert_equal(exc.http_status, expected_http_status) + +def test_work_queue_getblock(node, got_exceeded_error): + while not got_exceeded_error: + try: + node.cli('getrpcinfo').send_cli() + except subprocess.CalledProcessError as e: + assert_equal(e.output, 'error: Server response: Work queue depth exceeded\n') + got_exceeded_error.append(True) + + class RPCInterfaceTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 @@ -67,10 +80,23 @@ def test_http_status_codes(self): expect_http_status(404, -32601, self.nodes[0].invalidmethod) expect_http_status(500, -8, self.nodes[0].getblockhash, 42) + def test_work_queue_exceeded(self): + self.log.info("Testing work queue exceeded...") + self.restart_node(0, ['-rpcworkqueue=1', '-rpcthreads=1']) + got_exceeded_error = [] + threads = [] + for _ in range(3): + t = Thread(target=test_work_queue_getblock, args=(self.nodes[0], got_exceeded_error)) + t.start() + threads.append(t) + for t in threads: + t.join() + def run_test(self): self.test_getrpcinfo() self.test_batch_request() self.test_http_status_codes() + self.test_work_queue_exceeded() if __name__ == '__main__': From 5371147ea7433f0045a469e7c9e104b729f779a1 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 21 Mar 2021 07:51:08 +0100 Subject: [PATCH 05/15] Merge #21040: wallet: Fix already-loading message grammar ae9d26a8f0435e2f4b39ad1181473e6575ac67b5 wallet: Fix already-loading error message grammar (Fotis Koutoupas) Pull request description: ACKs for top commit: practicalswift: cr ACK ae9d26a8f0435e2f4b39ad1181473e6575ac67b5 prayank23: ACK https://github.com/bitcoin/bitcoin/pull/21040/commits/ae9d26a8f0435e2f4b39ad1181473e6575ac67b5 Tree-SHA512: 2f58d309dd33954f47e3ed339887b11bfdad4519f89ed3dd9bf3fb0db246d78b89653d553d02350ec84ce68bbb904db9fac00a2aad8d37f48df694d6782f35df --- src/wallet/wallet.cpp | 2 +- test/functional/wallet_multiwallet.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index bdef69003b9f..e020844d7830 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -257,7 +257,7 @@ std::shared_ptr LoadWallet(interfaces::Chain& chain, const std::string& { auto result = WITH_LOCK(g_loading_wallet_mutex, return g_loading_wallet_set.insert(name)); if (!result.second) { - error = Untranslated("Wallet already being loading."); + error = Untranslated("Wallet already loading."); status = DatabaseStatus::FAILED_LOAD; return nullptr; } diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py index 9ff85945a516..8b66a3c5e1cf 100755 --- a/test/functional/wallet_multiwallet.py +++ b/test/functional/wallet_multiwallet.py @@ -34,7 +34,7 @@ def test_load_unload(node, name): node.loadwallet(name) node.unloadwallet(name) except JSONRPCException as e: - if e.error['code'] == -4 and 'Wallet already being loading' in e.error['message']: + if e.error['code'] == -4 and 'Wallet already loading' in e.error['message']: got_loading_error = True return From 518582f375ad448a6a9bdff3af04a6b7411cba9d Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 21 Mar 2021 08:12:51 +0100 Subject: [PATCH 06/15] Merge #21488: test: add ParseUInt16() unit test and fuzz coverage 3d086f42ab58f0f5984101d5285d5a707e3dc8e7 test: add ParseUInt16() test coverage (Jon Atack) Pull request description: `ParseUInt16()` was just added in #21328. ACKs for top commit: practicalswift: cr ACK 3d086f42ab58f0f5984101d5285d5a707e3dc8e7: patch looks correct & more coverage is better than less coverage Tree-SHA512: bf7f96deb7c1531419565907f0ea8a8e32b368d4b823a3e80928b2c118edbf643ea06e357b4b5504a89f855caeed289daa9f823c740231ed6ad1b8ed00285ce8 --- src/test/fuzz/parse_numbers.cpp | 3 +++ src/test/util_tests.cpp | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/test/fuzz/parse_numbers.cpp b/src/test/fuzz/parse_numbers.cpp index aa9fea4beb6f..15151dc5e036 100644 --- a/src/test/fuzz/parse_numbers.cpp +++ b/src/test/fuzz/parse_numbers.cpp @@ -20,6 +20,9 @@ FUZZ_TARGET(parse_numbers) uint8_t u8; (void)ParseUInt8(random_string, &u8); + uint16_t u16; + (void)ParseUInt16(random_string, &u16); + int32_t i32; (void)ParseInt32(random_string, &i32); (void)LocaleIndependentAtoi(random_string); diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index e0699982557d..27954db3e93e 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -1525,6 +1525,42 @@ BOOST_AUTO_TEST_CASE(test_ParseUInt8) BOOST_CHECK(!ParseUInt8("256", nullptr)); } +BOOST_AUTO_TEST_CASE(test_ParseUInt16) +{ + uint16_t n; + // Valid values + BOOST_CHECK(ParseUInt16("1234", nullptr)); + BOOST_CHECK(ParseUInt16("0", &n) && n == 0); + BOOST_CHECK(ParseUInt16("1234", &n) && n == 1234); + BOOST_CHECK(ParseUInt16("01234", &n) && n == 1234); // no octal + BOOST_CHECK(ParseUInt16("65535", &n) && n == static_cast(65535)); + BOOST_CHECK(ParseUInt16("+65535", &n) && n == 65535); + BOOST_CHECK(ParseUInt16("00000000000000000012", &n) && n == 12); + BOOST_CHECK(ParseUInt16("00000000000000000000", &n) && n == 0); + // Invalid values + BOOST_CHECK(!ParseUInt16("-00000000000000000000", &n)); + BOOST_CHECK(!ParseUInt16("", &n)); + BOOST_CHECK(!ParseUInt16(" 1", &n)); // no padding inside + BOOST_CHECK(!ParseUInt16(" -1", &n)); + BOOST_CHECK(!ParseUInt16("++1", &n)); + BOOST_CHECK(!ParseUInt16("+-1", &n)); + BOOST_CHECK(!ParseUInt16("-+1", &n)); + BOOST_CHECK(!ParseUInt16("--1", &n)); + BOOST_CHECK(!ParseUInt16("-1", &n)); + BOOST_CHECK(!ParseUInt16("1 ", &n)); + BOOST_CHECK(!ParseUInt16("1a", &n)); + BOOST_CHECK(!ParseUInt16("aap", &n)); + BOOST_CHECK(!ParseUInt16("0x1", &n)); // no hex + BOOST_CHECK(!ParseUInt16("0x1", &n)); // no hex + BOOST_CHECK(!ParseUInt16(STRING_WITH_EMBEDDED_NULL_CHAR, &n)); + // Overflow and underflow + BOOST_CHECK(!ParseUInt16("-65535", &n)); + BOOST_CHECK(!ParseUInt16("65536", &n)); + BOOST_CHECK(!ParseUInt16("-123", &n)); + BOOST_CHECK(!ParseUInt16("-123", nullptr)); + BOOST_CHECK(!ParseUInt16("65536", nullptr)); +} + BOOST_AUTO_TEST_CASE(test_ParseUInt32) { uint32_t n; From 3ef6d5e8351c8ae4e9610c31e208e90133f295d5 Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 22 Mar 2021 11:30:25 +0800 Subject: [PATCH 07/15] Merge #21491: test: remove duplicate assertions in util_tests 7e3444805ed747db819d7bf630feafc31783e5de test: remove duplicate assertions in util_tests (Jon Atack) Pull request description: as noticed by Kiminuo in https://github.com/bitcoin/bitcoin/pull/21488#discussion_r598247676 ACKs for top commit: practicalswift: cr ACK 7e3444805ed747db819d7bf630feafc31783e5de: patch looks correct vasild: ACK 7e3444805ed747db819d7bf630feafc31783e5de Tree-SHA512: ad3d5983ad3a665155d766843dfda7178ced47e82154838331e428ed0828a467c1cf4bf99270aaf191e94156d485fafd0a7d5bc68248c4c1304a00ca5a2a9d2e --- src/test/util_tests.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 27954db3e93e..f4685c5b3b57 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -1306,7 +1306,6 @@ BOOST_AUTO_TEST_CASE(test_ParseInt32) BOOST_CHECK(!ParseInt32("1a", &n)); BOOST_CHECK(!ParseInt32("aap", &n)); BOOST_CHECK(!ParseInt32("0x1", &n)); // no hex - BOOST_CHECK(!ParseInt32("0x1", &n)); // no hex BOOST_CHECK(!ParseInt32(STRING_WITH_EMBEDDED_NULL_CHAR, &n)); // Overflow and underflow BOOST_CHECK(!ParseInt32("-2147483649", nullptr)); @@ -1515,7 +1514,6 @@ BOOST_AUTO_TEST_CASE(test_ParseUInt8) BOOST_CHECK(!ParseUInt8("1a", &n)); BOOST_CHECK(!ParseUInt8("aap", &n)); BOOST_CHECK(!ParseUInt8("0x1", &n)); // no hex - BOOST_CHECK(!ParseUInt8("0x1", &n)); // no hex BOOST_CHECK(!ParseUInt8(STRING_WITH_EMBEDDED_NULL_CHAR, &n)); // Overflow and underflow BOOST_CHECK(!ParseUInt8("-255", &n)); @@ -1551,7 +1549,6 @@ BOOST_AUTO_TEST_CASE(test_ParseUInt16) BOOST_CHECK(!ParseUInt16("1a", &n)); BOOST_CHECK(!ParseUInt16("aap", &n)); BOOST_CHECK(!ParseUInt16("0x1", &n)); // no hex - BOOST_CHECK(!ParseUInt16("0x1", &n)); // no hex BOOST_CHECK(!ParseUInt16(STRING_WITH_EMBEDDED_NULL_CHAR, &n)); // Overflow and underflow BOOST_CHECK(!ParseUInt16("-65535", &n)); @@ -1589,7 +1586,6 @@ BOOST_AUTO_TEST_CASE(test_ParseUInt32) BOOST_CHECK(!ParseUInt32("1a", &n)); BOOST_CHECK(!ParseUInt32("aap", &n)); BOOST_CHECK(!ParseUInt32("0x1", &n)); // no hex - BOOST_CHECK(!ParseUInt32("0x1", &n)); // no hex BOOST_CHECK(!ParseUInt32(STRING_WITH_EMBEDDED_NULL_CHAR, &n)); // Overflow and underflow BOOST_CHECK(!ParseUInt32("-2147483648", &n)); From d5e63ce249e2ee2f766035aea1ca0b76a5047b14 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 22 Mar 2021 06:42:01 +0100 Subject: [PATCH 08/15] Merge #21498: refactor: return std::nullopt instead of {} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5294f0d5a94cc7beaf692131fba0cad8beec9f13 refactor: return std::nullopt instead of {} (fanquake) Pull request description: In #21415 [we decided](https://github.com/bitcoin/bitcoin/pull/21415#issuecomment-800236640) to return `std::optional` rather than `{}` for uninitialized values. This PR replaces the two remaining usages of `{}` with `std::nullopt`. As a side-effect, this also quells the spurious GCC 10.2.x warning that we've had reported quite a few times. i.e #21318, #21248, #20797. ```bash txmempool.cpp: In member function ‘CTxMemPool::setEntries CTxMemPool::GetIterSet(const std::set&) const’: txmempool.cpp:898:13: warning: ‘’ may be used uninitialized in this function [-Wmaybe-uninitialized] 898 | return {}; | ^ ``` ACKs for top commit: hebasto: ACK 5294f0d5a94cc7beaf692131fba0cad8beec9f13, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: 5b776be79ab26e5a3a5fc2b463b394ea5ce6797ed5558424873fa4ecee2898170eff76d6da9d69394d28f8f98974117fc63b922a3e19c52f5294c83073e79bb0 --- src/txmempool.cpp | 2 +- src/validation.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index e033b595ff4b..569a7e89bb26 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -1387,7 +1387,7 @@ std::optional CTxMemPool::GetIter(const uint256& txid) const { auto it = mapTx.find(txid); if (it != mapTx.end()) return it; - return {}; + return std::nullopt; } CTxMemPool::setEntries CTxMemPool::GetIterSet(const std::set& hashes) const diff --git a/src/validation.cpp b/src/validation.cpp index b725cc1dd952..bb3e5154fc72 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5604,7 +5604,7 @@ std::optional ChainstateManager::SnapshotBlockhash() const { // If a snapshot chainstate exists, it will always be our active. return m_active_chainstate->m_from_snapshot_blockhash; } - return {}; + return std::nullopt; } std::vector ChainstateManager::GetAll() From dd80977ebb8fd6648d09740829dcdae64d7b83fe Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 24 Mar 2021 18:50:48 +0100 Subject: [PATCH 09/15] Merge #21516: remove unnecessary newline from initWarning() argument 804ac106313eb52d3a86f42c681b42acf90974c8 remove unnecessary newline from initWarning() argument (Larry Ruane) Pull request description: Run: `src/bitcoind -wallet=nosuchfile` Without this patch, `debug.log` contains: ``` 2021-03-23T21:19:16Z init message: Verifying wallet(s)... 2021-03-23T21:19:16Z Warning: Skipping -wallet path that doesn't exist. Failed to load database path '/home/larry/.bitcoin/wallets/nosuchfile'. Path does not exist. 2021-03-23T21:19:16Z init message: Loading banlist... ``` With this patch, the empty line isn't present. This PR fixes a similar problem with `src/bitcoind -conf=nosuchfile` ACKs for top commit: practicalswift: cr ACK 804ac106313eb52d3a86f42c681b42acf90974c8: patch looks correct! jarolrod: tACK 804ac106313eb52d3a86f42c681b42acf90974c8, nice catch! theStack: Code-review ACK 804ac106313eb52d3a86f42c681b42acf90974c8 Tree-SHA512: dfcbaaa72ca24ac40233ac56840cfba8827853711d3df6e229ce940686f2ebf8bf0560bafcaa73a4d82d179a5050af0d3cabdc47b3b1dfd6aaadf718a6635f11 --- src/init.cpp | 2 +- src/wallet/load.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index f2888ae7bbb9..a342859805ea 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1640,7 +1640,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc LogPrintf("Config file: %s\n", config_file_path.string()); } else if (args.IsArgSet("-conf")) { // Warn if no conf file exists at path provided by user - InitWarning(strprintf(_("The specified config file %s does not exist\n"), config_file_path.string())); + InitWarning(strprintf(_("The specified config file %s does not exist"), config_file_path.string())); } else { // Not categorizing as "Warning" because it's the default behavior LogPrintf("Config file: %s (not found, skipping)\n", config_file_path.string()); diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp index 33b71f34b0be..75a05fd01acd 100644 --- a/src/wallet/load.cpp +++ b/src/wallet/load.cpp @@ -79,7 +79,7 @@ bool VerifyWallets(interfaces::Chain& chain) bilingual_str error_string; if (!MakeWalletDatabase(wallet_file, options, status, error_string)) { if (status == DatabaseStatus::FAILED_NOT_FOUND) { - chain.initWarning(Untranslated(strprintf("Skipping -wallet path that doesn't exist. %s\n", error_string.original))); + chain.initWarning(Untranslated(strprintf("Skipping -wallet path that doesn't exist. %s", error_string.original))); } else { chain.initError(error_string); return false; From 346ae84acffd098cf68ea53140aeeda3eadeafb4 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 28 Apr 2021 21:13:36 +0200 Subject: [PATCH 10/15] Merge bitcoin/bitcoin#18847: compressor: use a prevector in CompressScript serialization [ZAP1] 83a425d25af033086744c1c8c892015014ed46bd compressor: use a prevector in compressed script serialization (William Casarin) Pull request description: This function was doing millions of unnecessary heap allocations during IBD. I'm start to catalog unnecessary heap allocations as a pet project of mine: as-zero-as-possible-alloc IBD. This is one small step. before: ![May01-174536](https://user-images.githubusercontent.com/45598/80850964-9a38de80-8bd3-11ea-8eec-08cd38ee1fa1.png) after: ![May01-174610](https://user-images.githubusercontent.com/45598/80850974-a91f9100-8bd3-11ea-94a1-e2077391f6f4.png) ~should I type alias this?~ *I type aliased it* This is a part of the Zero Allocations Project #18849 (ZAP1). This code came up as a place where many allocations occur. ACKs for top commit: Empact: ACK https://github.com/bitcoin/bitcoin/pull/18847/commits/83a425d25af033086744c1c8c892015014ed46bd elichai: tACK 83a425d25af033086744c1c8c892015014ed46bd sipa: utACK 83a425d25af033086744c1c8c892015014ed46bd Tree-SHA512: f0ffa6ab0ea1632715b0b76362753f9f6935f05cdcc80d85566774401155a3c57ad45a687942a1806d3503858f0bb698da9243746c8e2edb8fdf13611235b0e0 --- src/compressor.cpp | 4 ++-- src/compressor.h | 20 ++++++++++++++++---- src/test/compress_tests.cpp | 8 ++++---- src/test/fuzz/script.cpp | 8 +++++--- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/compressor.cpp b/src/compressor.cpp index 568b182f4c72..272aa08d5a02 100644 --- a/src/compressor.cpp +++ b/src/compressor.cpp @@ -52,7 +52,7 @@ static bool IsToPubKey(const CScript& script, CPubKey &pubkey) return false; } -bool CompressScript(const CScript& script, std::vector &out) +bool CompressScript(const CScript& script, CompressedScript& out) { CKeyID keyID; if (IsToKeyID(script, keyID)) { @@ -92,7 +92,7 @@ unsigned int GetSpecialScriptSize(unsigned int nSize) return 0; } -bool DecompressScript(CScript& script, unsigned int nSize, const std::vector &in) +bool DecompressScript(CScript& script, unsigned int nSize, const CompressedScript& in) { switch(nSize) { case 0x00: diff --git a/src/compressor.h b/src/compressor.h index aa6a2d5db984..22de2f693688 100644 --- a/src/compressor.h +++ b/src/compressor.h @@ -6,14 +6,26 @@ #ifndef BITCOIN_COMPRESSOR_H #define BITCOIN_COMPRESSOR_H +#include #include #include