From ccd3920d4071cdeea01d42968418b0e119ef8f05 Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 2 Oct 2023 12:49:17 +0200 Subject: [PATCH 01/16] Merge bitcoin/bitcoin#28556: doc: fix link to developer-notes.md file in multiprocess.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit d9b172cd00fc3a8de1308e4469b82f5da474ea33 doc: fix link to developer-notes.md file in multiprocess.md (David Álvarez Rosa) Pull request description: Fix link to `developer-notes.md` file in `multiprocess.md`. ACKs for top commit: fanquake: ACK d9b172cd00fc3a8de1308e4469b82f5da474ea33 Tree-SHA512: 55fffefb37c4d67acb1fa8b0660216ec1c7f2c2314d11e4d319cae40480ed59ef448909fa2ca334167c86d60d41932220dce4186e28fa300f4d03eb0b3c769d0 --- doc/multiprocess.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/multiprocess.md b/doc/multiprocess.md index 3106e57c2a..3463130110 100644 --- a/doc/multiprocess.md +++ b/doc/multiprocess.md @@ -38,7 +38,7 @@ Alternately, you can install [Cap'n Proto](https://capnproto.org/) and [libmulti Cross process Node, Wallet, and Chain interfaces are defined in [`src/interfaces/`](../src/interfaces/). These are C++ classes which follow -[conventions](developer-notes.md#internal-interface-guidelines), like passing +[conventions](../developer-notes.md#internal-interface-guidelines), like passing serializable arguments so they can be called from different processes, and making methods pure virtual so they can have proxy implementations that forward calls between processes. From c740264da8f57ed379363ee8cafe063551f626e8 Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 6 Oct 2023 10:20:08 +0100 Subject: [PATCH 02/16] Merge bitcoin/bitcoin#28532: qt: enable` -ltcg` for windows under LTO f0cebbdb2a1a3c2f0facd88963484ad6fd5851db qt: enable -ltcg for windows HOST (fanquake) Pull request description: Patch around multiple definition issues in Qt, and enable `-ltcg` when using `LTO=1`. Split from #25391. ACKs for top commit: hebasto: ACK f0cebbdb2a1a3c2f0facd88963484ad6fd5851db Tree-SHA512: 2d6e34779f360bf6dfea4f70fc9004a16e95da79716fcb3046afbf2b01317b7e16965cb51b967b7b5fb64549306c5f48cf59082884289c52016bc1e86949e062 --- depends/packages/qt.mk | 5 +++++ depends/patches/qt/windows_lto.patch | 31 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 depends/patches/qt/windows_lto.patch diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index ffb70e0d93..8545379f14 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -23,6 +23,7 @@ $(package)_patches += guix_cross_lib_path.patch $(package)_patches += fast_fixed_dtoa_no_optimize.patch $(package)_patches += fix-macos-linker.patch $(package)_patches += memory_resource.patch +$(package)_patches += windows_lto.patch $(package)_qttranslations_file_name=qttranslations-$($(package)_suffix) $(package)_qttranslations_sha256_hash=a31785948c640b7c66d9fe2db4993728ca07f64e41c560b3625ad191b276ff20 @@ -184,6 +185,9 @@ $(package)_config_opts_mingw32 += "QMAKE_LFLAGS = '$($(package)_ldflags)'" $(package)_config_opts_mingw32 += "QMAKE_LIB = '$($(package)_ar) rc'" $(package)_config_opts_mingw32 += -device-option CROSS_COMPILE="$(host)-" $(package)_config_opts_mingw32 += -pch +ifneq ($(LTO),) +$(package)_config_opts_mingw32 += -ltcg +endif $(package)_config_opts_android = -xplatform android-clang $(package)_config_opts_android += -android-sdk $(ANDROID_SDK) @@ -260,6 +264,7 @@ define $(package)_preprocess_cmds patch -p1 -i $($(package)_patch_dir)/qtbase-moc-ignore-gcc-macro.patch && \ patch -p1 -i $($(package)_patch_dir)/fast_fixed_dtoa_no_optimize.patch && \ patch -p1 -i $($(package)_patch_dir)/guix_cross_lib_path.patch && \ + patch -p1 -i $($(package)_patch_dir)/windows_lto.patch && \ mkdir -p qtbase/mkspecs/macx-clang-linux &&\ cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\ cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \ diff --git a/depends/patches/qt/windows_lto.patch b/depends/patches/qt/windows_lto.patch new file mode 100644 index 0000000000..ea379a60f1 --- /dev/null +++ b/depends/patches/qt/windows_lto.patch @@ -0,0 +1,31 @@ +Qt (for Windows) fails to build under LTO, due to multiple definition issues, i.e + +multiple definition of `QAccessibleLineEdit::~QAccessibleLineEdit()'; + +Possibly related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94156. + +diff --git a/qtbase/src/widgets/accessible/simplewidgets.cpp b/qtbase/src/widgets/accessible/simplewidgets.cpp +index 107fd729fe..0e61878f39 100644 +--- a/qtbase/src/widgets/accessible/simplewidgets.cpp ++++ b/qtbase/src/widgets/accessible/simplewidgets.cpp +@@ -109,6 +109,8 @@ QString qt_accHotKey(const QString &text); + \ingroup accessibility + */ + ++QAccessibleLineEdit::~QAccessibleLineEdit(){}; ++ + /*! + Creates a QAccessibleButton object for \a w. + */ +diff --git a/qtbase/src/widgets/accessible/simplewidgets_p.h b/qtbase/src/widgets/accessible/simplewidgets_p.h +index 73572e3059..658da86143 100644 +--- a/qtbase/src/widgets/accessible/simplewidgets_p.h ++++ b/qtbase/src/widgets/accessible/simplewidgets_p.h +@@ -155,6 +155,7 @@ class QAccessibleLineEdit : public QAccessibleWidget, public QAccessibleTextInte + public: + explicit QAccessibleLineEdit(QWidget *o, const QString &name = QString()); + ++ ~QAccessibleLineEdit(); + QString text(QAccessible::Text t) const override; + void setText(QAccessible::Text t, const QString &text) override; + QAccessible::State state() const override; From af8d12445afed3e0f2c1d49e2d31cef9dfab0531 Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 11 Oct 2023 12:35:39 +0200 Subject: [PATCH 03/16] Merge bitcoin/bitcoin#28624: docs: fix typo 57131bfa3cfd9e5826b5c557aba8aa03bf41f833 docs: fix typo (vuittont60) Pull request description: ACKs for top commit: maflcko: lgtm ACK 57131bfa3cfd9e5826b5c557aba8aa03bf41f833 hebasto: ACK 57131bfa3cfd9e5826b5c557aba8aa03bf41f833, the `codespell` is powerless to catch this typo. jarolrod: ACK 57131bfa3cfd9e5826b5c557aba8aa03bf41f833 Tree-SHA512: 816dfc5ff64531ea92acf35feca2286a71c75344df2524ff003a3d375e60100b8531e1678be0ed11863d03ab522d5733d8a0bf4b6f5f79c495a65246fe0b697f --- contrib/devtools/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/devtools/README.md b/contrib/devtools/README.md index 96c5481d5a..0090dc2959 100644 --- a/contrib/devtools/README.md +++ b/contrib/devtools/README.md @@ -83,7 +83,7 @@ A small script to automatically create manpages in ../../doc/man by running the This requires help2man which can be found at: https://www.gnu.org/software/help2man/ With in-tree builds this tool can be run from any directory within the -repostitory. To use this tool with out-of-tree builds set `BUILDDIR`. For +repository. To use this tool with out-of-tree builds set `BUILDDIR`. For example: ```bash From f007abd19d882d673575ba22148b49c55ffb5b44 Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 13 Oct 2023 10:49:04 +0200 Subject: [PATCH 04/16] Merge bitcoin/bitcoin#28459: build: add `-mbranch-protection=bti` (aarch64) to hardening flags 61a6c3b0e9a8dab5c5f845af4becde817539133c build: add `-mbranch-protection=bti` to aarch64 hardening flags (fanquake) Pull request description: This is a simpler (less hardening) version of https://github.com/bitcoin/bitcoin/pull/24123. You can inspect binaries using `readelf -n`, and look for BTI in a `.note.gnu.property`. i.e ```bash readelf -n src/bitcoin-cli Displaying notes found in: .note.gnu.property Owner Data size Description GNU 0x00000010NT_GNU_PROPERTY_TYPE_0 Properties: AArch64 feature: BTI ``` Related to https://github.com/bitcoin/bitcoin/issues/19075. ACKs for top commit: TheCharlatan: utACK 61a6c3b0e9a8dab5c5f845af4becde817539133c Tree-SHA512: 64504de44e91d853165daf4111dca905d8eb9ef3f4bfb0d447c677b02c9100dbd56f13e6fe6539fb06c2343a094229591ac5d1bd9e184b32b512c0ac3f9bac36 --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 50441b50fb..f1d37ee5bf 100644 --- a/configure.ac +++ b/configure.ac @@ -981,6 +981,11 @@ if test x$use_hardening != xno; then ;; esac + case $host in + *aarch64*) + AX_CHECK_COMPILE_FLAG([-mbranch-protection=bti], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -mbranch-protection=bti"]) + ;; + esac dnl When enable_debug is yes, all optimizations are disabled. dnl However, FORTIFY_SOURCE requires that there is some level of optimization, otherwise it does nothing and just creates a compiler warning. From 90a1fb0e8df00914f77517398e875582ec20418f Mon Sep 17 00:00:00 2001 From: fanquake Date: Sun, 15 Oct 2023 10:54:43 +0200 Subject: [PATCH 05/16] Merge bitcoin/bitcoin#28650: fuzz: Merge with -set_cover_merge=1 fa858d63a0a5d794aab38c26f60c593513fe08de fuzz: Merge with -set_cover_merge=1 (MarcoFalke) Pull request description: This should be less controversial than commit 151a2b189c3561dda2bb7de809306c1cfeb40e23. The overall size of the qa-assets repo is reduced further from 1.9GB to 1.6GB. Also, the runtime to iterate on the resulting folder is reduced further from ~1699s to ~1149s (N=1). ACKs for top commit: murchandamus: crACK fa858d63a0a5d794aab38c26f60c593513fe08de dergoegge: ACK fa858d63a0a5d794aab38c26f60c593513fe08de Tree-SHA512: e23fa93bd48f01d11c551b035004c678bd6d76bc24ac7d0d0a7883060804e6711763cbd0cd0ded3aad3e4c40da764decae81c2703388cc11961def3c89a4f9ba --- test/fuzz/test_runner.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/fuzz/test_runner.py b/test/fuzz/test_runner.py index 581fb36c53..c1d0c10b8b 100755 --- a/test/fuzz/test_runner.py +++ b/test/fuzz/test_runner.py @@ -224,7 +224,11 @@ def merge_inputs(*, fuzz_pool, corpus, test_list, src_dir, build_dir, merge_dir) for t in test_list: args = [ os.path.join(build_dir, 'src', 'test', 'fuzz', 'fuzz'), - '-merge=1', + '-set_cover_merge=1', + # set_cover_merge is used instead of -merge=1 to reduce the overall + # size of the qa-assets git repository a bit, but more importantly, + # to cut the runtime to iterate over all fuzz inputs [0]. + # [0] https://github.com/bitcoin-core/qa-assets/issues/130#issuecomment-1761760866 '-shuffle=0', '-prefer_small=1', '-use_value_profile=1', # Also done by oss-fuzz https://github.com/google/oss-fuzz/issues/1406#issuecomment-387790487 From 0278163aa3360a50379f9f2724b93dc9114040dc Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 23 Oct 2023 10:10:35 +0100 Subject: [PATCH 06/16] Merge bitcoin/bitcoin#28697: fuzz: Increase merge -rss_limit_mb fa21535551e300eaa988d209ad64cdc17fd7f66b fuzz: Increase merge -rss_limit_mb (MarcoFalke) Pull request description: For some reason, the limit is hit. (Presumably due to `-set_cover_merge=1` eating more memory, or by simply having more fuzz inputs). Fix it by increasing it for the merge operation. ACKs for top commit: dergoegge: ACK fa21535551e300eaa988d209ad64cdc17fd7f66b hebasto: ACK fa21535551e300eaa988d209ad64cdc17fd7f66b, considering the discussion in https://github.com/bitcoin-core/qa-assets/pull/155. Tree-SHA512: 4fed0f254eccc6fe0b53656bc345ff898b13811dc39387387317d34b521ab77cee03d82b0896dd92d253b7546b6a7e4bdcd478749f47064374ab44ad759ab9ff --- test/fuzz/test_runner.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/fuzz/test_runner.py b/test/fuzz/test_runner.py index c1d0c10b8b..f3ed3ac4e5 100755 --- a/test/fuzz/test_runner.py +++ b/test/fuzz/test_runner.py @@ -224,6 +224,7 @@ def merge_inputs(*, fuzz_pool, corpus, test_list, src_dir, build_dir, merge_dir) for t in test_list: args = [ os.path.join(build_dir, 'src', 'test', 'fuzz', 'fuzz'), + '-rss_limit_mb=8000', '-set_cover_merge=1', # set_cover_merge is used instead of -merge=1 to reduce the overall # size of the qa-assets git repository a bit, but more importantly, From f160e0dbb2c70524ac79eccd2d37c28b38b69266 Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 23 Oct 2023 10:37:15 +0100 Subject: [PATCH 07/16] Merge bitcoin/bitcoin#28691: refactor: Remove CBlockFileInfo::SetNull fac36b94ef32567c0f10b605a3a441d11559e56e refactor: Remove CBlockFileInfo::SetNull (MarcoFalke) Pull request description: Seems better to use C++11 member initializers and then let the compiler figure out how to construct objects of this class. ACKs for top commit: stickies-v: ACK fac36b94ef32567c0f10b605a3a441d11559e56e pablomartin4btc: ACK fac36b94ef32567c0f10b605a3a441d11559e56e theStack: LGTM ACK fac36b94ef32567c0f10b605a3a441d11559e56e Tree-SHA512: aee741c8f668f0e5b658fc83f4ebd196b43fead3dd437afdb0a2dafe092ae3d559332b3d9d61985c92e1a59982d8f24942606e6a98598c6ef7ff43697e858725 --- src/chain.h | 30 ++++++++---------------------- src/node/blockstorage.cpp | 2 +- src/node/blockstorage.h | 1 - 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/chain.h b/src/chain.h index 7e1296153a..2ed424c48e 100644 --- a/src/chain.h +++ b/src/chain.h @@ -40,13 +40,13 @@ extern RecursiveMutex cs_main; class CBlockFileInfo { public: - unsigned int nBlocks; //!< number of blocks stored in file - unsigned int nSize; //!< number of used bytes of block file - unsigned int nUndoSize; //!< number of used bytes in the undo file - unsigned int nHeightFirst; //!< lowest height of block in file - unsigned int nHeightLast; //!< highest height of block in file - uint64_t nTimeFirst; //!< earliest time of block in file - uint64_t nTimeLast; //!< latest time of block in file + unsigned int nBlocks{}; //!< number of blocks stored in file + unsigned int nSize{}; //!< number of used bytes of block file + unsigned int nUndoSize{}; //!< number of used bytes in the undo file + unsigned int nHeightFirst{}; //!< lowest height of block in file + unsigned int nHeightLast{}; //!< highest height of block in file + uint64_t nTimeFirst{}; //!< earliest time of block in file + uint64_t nTimeLast{}; //!< latest time of block in file SERIALIZE_METHODS(CBlockFileInfo, obj) { @@ -59,21 +59,7 @@ public: READWRITE(VARINT(obj.nTimeLast)); } - void SetNull() - { - nBlocks = 0; - nSize = 0; - nUndoSize = 0; - nHeightFirst = 0; - nHeightLast = 0; - nTimeFirst = 0; - nTimeLast = 0; - } - - CBlockFileInfo() - { - SetNull(); - } + CBlockFileInfo() {} std::string ToString() const; diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index 2c8cacccef..4aa9d0c993 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -164,7 +164,7 @@ void BlockManager::PruneOneBlockFile(const int fileNumber) } } - m_blockfile_info[fileNumber].SetNull(); + m_blockfile_info.at(fileNumber) = CBlockFileInfo{}; m_dirty_fileinfo.insert(fileNumber); } diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h index 1b919df908..a0c25f10d9 100644 --- a/src/node/blockstorage.h +++ b/src/node/blockstorage.h @@ -21,7 +21,6 @@ class CActiveMasternodeManager; class ArgsManager; class BlockValidationState; class CBlock; -class CBlockFileInfo; class CBlockUndo; class CChain; class CChainParams; From f4ea48e623b8a8b70ef981d23607c98d0256462e Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 23 Oct 2023 11:27:00 +0100 Subject: [PATCH 08/16] Merge bitcoin/bitcoin#28693: build: Include `config/bitcoin-config.h` explicitly in `util/trace.h` 6bdff429ec17eae4138c3af1e21de3ec46f4ab13 build: Include `config/bitcoin-config.h` explicitly in `util/trace.h` (Hennadii Stepanov) Pull request description: The `ENABLE_TRACING` macro is expected to be defined in the `config/bitcoin-config.h` header. Therefore, the current code is error-prone as it depends on whether the `config/bitcoin-config.h` header was included before or not. This bug was noticed while working on CMake [stuff](https://github.com/hebasto/bitcoin/pull/37). ACKs for top commit: fanquake: ACK 6bdff429ec17eae4138c3af1e21de3ec46f4ab13 Tree-SHA512: 22c4fdeb51628814050eb99a83db4268a4f3106207eeef918a07214bbc52f2b22490f6b05fcb96216f147afa4197c51102503738131e2583e750b6d195747a49 --- src/util/trace.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util/trace.h b/src/util/trace.h index 9c92cb10e7..f25ad42471 100644 --- a/src/util/trace.h +++ b/src/util/trace.h @@ -5,6 +5,10 @@ #ifndef BITCOIN_UTIL_TRACE_H #define BITCOIN_UTIL_TRACE_H +#if defined(HAVE_CONFIG_H) +#include +#endif + #ifdef ENABLE_TRACING #include From 95a8d8cfdced27b88158d1e5eff0445188e88db3 Mon Sep 17 00:00:00 2001 From: glozow Date: Thu, 2 Nov 2023 11:14:11 +0000 Subject: [PATCH 09/16] Merge bitcoin/bitcoin#21161: Fee estimation: extend bucket ranges consistently a5e39d325da4eeb9273fb7c919fcbfbc721ed75d Fee estimation: extend bucket ranges consistently (Anthony Towns) Pull request description: When calculating a median fee for a confirmation target at a particular threshold, we analyse buckets in ranges rather than individually in case some buckets have very little data. This patch ensures the breaks between ranges are independent of the the confirmation target. Fixes #20725 ACKs for top commit: ismaelsadeeq: Code review ACK a5e39d325da4eeb9273fb7c919fcbfbc721ed75d glozow: btw what I meant by [this](https://github.com/bitcoin/bitcoin/pull/21161#pullrequestreview-1350258467) was ACK a5e39d325da4eeb9273fb7c919fcbfbc721ed75d jonatack: Initial ACK a5e39d325da4eeb9273fb7c919fcbfbc721ed75d Tree-SHA512: 0edf4e56717c4ab8d4ab0bc0f1d7ab36a13b99de12f689e55c9142c6b81691367ffd8df2e8260c5e14335310b1a51770c6c22995db31109976239befcb558ef8 --- src/policy/fees.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index caf4f0b5f8..47e117a17f 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -243,6 +243,11 @@ double TxConfirmStats::EstimateMedianVal(int confTarget, double sufficientTxVal, unsigned int curFarBucket = maxbucketindex; unsigned int bestFarBucket = maxbucketindex; + // We'll always group buckets into sets that meet sufficientTxVal -- + // this ensures that we're using consistent groups between different + // confirmation targets. + double partialNum = 0; + bool foundAnswer = false; unsigned int bins = unconfTxs.size(); bool newBucketRange = true; @@ -258,6 +263,7 @@ double TxConfirmStats::EstimateMedianVal(int confTarget, double sufficientTxVal, } curFarBucket = bucket; nConf += confAvg[periodTarget - 1][bucket]; + partialNum += txCtAvg[bucket]; totalNum += txCtAvg[bucket]; failNum += failAvg[periodTarget - 1][bucket]; for (unsigned int confct = confTarget; confct < GetMaxConfirms(); confct++) @@ -267,7 +273,14 @@ double TxConfirmStats::EstimateMedianVal(int confTarget, double sufficientTxVal, // we can test for success // (Only count the confirmed data points, so that each confirmation count // will be looking at the same amount of data and same bucket breaks) - if (totalNum >= sufficientTxVal / (1 - decay)) { + + if (partialNum < sufficientTxVal / (1 - decay)) { + // the buckets we've added in this round aren't sufficient + // so keep adding + continue; + } else { + partialNum = 0; // reset for the next range we'll add + double curPct = nConf / (totalNum + failNum + extraNum); // Check to see if we are no longer getting confirmed at the success rate From 5aedcbfb43755af0646ecce8a29872b1e0f585df Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 3 Nov 2023 14:42:44 +0000 Subject: [PATCH 10/16] Merge bitcoin/bitcoin#28778: depends: drop -O1 workaround from arm64 apple Qt build 664c87354f9ec5df95346eab72a034296b83914d depends: drop -O1 workaround from arm64 apple Qt build (fanquake) Pull request description: Drop the workaround of setting optimization flags to -O1 for the `arm64-apple-darwin` builds. I no-longer see reproducibility issues when building across `x86_64` and `aarch64`: ```bash real7m21.192s user67m41.047s sys5m8.596s fedora-32gb-hel1-1 bitcoin]# find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum 62373549d2884e8ef8f46a77b9a93f64ebfc88603569e9d33b68fc67beaf2226 guix-build-664c87354f9e/output/arm64-apple-darwin/SHA256SUMS.part 597889f1908fdb67a6419177a98935b7119c637a962f03f47270893c5ba3fd6f guix-build-664c87354f9e/output/arm64-apple-darwin/bitcoin-664c87354f9e-arm64-apple-darwin-unsigned.tar.gz 289340354532a54a42b7235c831d13fdb28751c643f0fa0fc417ab195e9b5d90 guix-build-664c87354f9e/output/arm64-apple-darwin/bitcoin-664c87354f9e-arm64-apple-darwin-unsigned.zip 74f4ab3819a186d6c34ca0a4b9dda7c38fcb36bd9b22075a5d91df9bdd5df98a guix-build-664c87354f9e/output/arm64-apple-darwin/bitcoin-664c87354f9e-arm64-apple-darwin.tar.gz f0d0dad63057c7dddf6d6ccee244e7916ac0ee26b3bef8dd35f8430280043b38 guix-build-664c87354f9e/output/dist-archive/bitcoin-664c87354f9e.tar.gz fedora-32gb-hel1-1 bitcoin]# uname -m aarch64 ``` ```bash real18m10.759s user108m21.656s sys6m12.930s ubuntu-32gb-hel1-1:~/bitcoin# find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum 62373549d2884e8ef8f46a77b9a93f64ebfc88603569e9d33b68fc67beaf2226 guix-build-664c87354f9e/output/arm64-apple-darwin/SHA256SUMS.part 597889f1908fdb67a6419177a98935b7119c637a962f03f47270893c5ba3fd6f guix-build-664c87354f9e/output/arm64-apple-darwin/bitcoin-664c87354f9e-arm64-apple-darwin-unsigned.tar.gz 289340354532a54a42b7235c831d13fdb28751c643f0fa0fc417ab195e9b5d90 guix-build-664c87354f9e/output/arm64-apple-darwin/bitcoin-664c87354f9e-arm64-apple-darwin-unsigned.zip 74f4ab3819a186d6c34ca0a4b9dda7c38fcb36bd9b22075a5d91df9bdd5df98a guix-build-664c87354f9e/output/arm64-apple-darwin/bitcoin-664c87354f9e-arm64-apple-darwin.tar.gz f0d0dad63057c7dddf6d6ccee244e7916ac0ee26b3bef8dd35f8430280043b38 guix-build-664c87354f9e/output/dist-archive/bitcoin-664c87354f9e.tar.gz ubuntu-32gb-hel1-1:~/bitcoin# uname -m x86_64 ``` ACKs for top commit: hebasto: ACK 664c87354f9ec5df95346eab72a034296b83914d. TheCharlatan: ACK 664c87354f9ec5df95346eab72a034296b83914d Tree-SHA512: 79527df4181eb0a0c42fe526581479abcdeba8fb09e1faf52265d697d39a8f3a3532ee3c573579b9af00b7330a401e4b6f1686636f9bac6bf9839be8381a2033 --- depends/packages/qt.mk | 3 --- 1 file changed, 3 deletions(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 8545379f14..430e36b25e 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -133,9 +133,6 @@ $(package)_config_opts_darwin += -no-feature-corewlan $(package)_config_opts_darwin += -no-freetype $(package)_config_opts_darwin += QMAKE_MACOSX_DEPLOYMENT_TARGET=$(OSX_MIN_VERSION) -# Optimizing using > -O1 causes non-determinism when building across arches. -$(package)_config_opts_aarch64_darwin += "QMAKE_CFLAGS_OPTIMIZE_FULL = -O1" - ifneq ($(build_os),darwin) $(package)_config_opts_darwin += -xplatform macx-clang-linux $(package)_config_opts_darwin += -device-option MAC_SDK_PATH=$(OSX_SDK) From d5e15dfc5a3a85042bac5cee42967274af511c76 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Tue, 7 Nov 2023 15:00:12 -0500 Subject: [PATCH 11/16] Merge bitcoin/bitcoin#26839: Add support for RNDR/RNDRRS for AArch64 on Linux aee5404e02e203a256c1a97b629b9b107cc8bb07 Add support for RNDR/RNDRRS for aarch64 on Linux (John Moffett) Pull request description: This checks whether the ARMv8.5-A optional TRNG extensions [RNDR](https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers/RNDR--Random-Number) and [RNDRRS](https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers/RNDRRS--Reseeded-Random-Number) are available and, if they are, uses them for random entropy purposes. They are nearly functionally identical to the x86 RDRAND/RDSEED extensions and are used in a similar manner. Currently, there [appears to be](https://marcin.juszkiewicz.com.pl/download/tables/arm-socs.html) only one actual hardware implementation -- the Amazon Graviton 3. (See the `rnd` column in the link.) However, future hardware implementations may become available. It's not possible to directly query for the capability in userspace, but the Linux kernel [added support](https://github.com/torvalds/linux/commit/1a50ec0b3b2e9a83f1b1245ea37a853aac2f741c) for querying the extension via `getauxval` in version 5.6 (in 2020), so this is limited to Linux-only for now. Reviewers may want to launch any of the `c7g` instances from AWS to test the Graviton 3 hardware. Alternatively, QEMU emulates these opcodes for `aarch64` with CPU setting `max`. Output from Graviton 3 hardware: ``` ubuntu@ip:~/bitcoin$ src/bitcoind -regtest 2023-01-06T20:01:48Z Bitcoin Core version v24.99.0-3670266ce89a (release build) 2023-01-06T20:01:48Z Using the 'arm_shani(1way,2way)' SHA256 implementation 2023-01-06T20:01:48Z Using RNDR and RNDRRS as additional entropy sources 2023-01-06T20:01:48Z Default data directory /home/ubuntu/.bitcoin ``` Graviton 2 (doesn't support extensions): ``` ubuntu@ip:~/bitcoin$ src/bitcoind -regtest 2023-01-06T20:05:04Z Bitcoin Core version v24.99.0-3670266ce89a (release build) 2023-01-06T20:05:04Z Using the 'arm_shani(1way,2way)' SHA256 implementation 2023-01-06T20:05:04Z Default data directory /home/ubuntu/.bitcoin ``` This partially closes #26796. As noted in that issue, OpenSSL [added support](https://github.com/openssl/openssl/pull/15361) for these extensions a little over a year ago. ACKs for top commit: achow101: ACK aee5404e02e203a256c1a97b629b9b107cc8bb07 laanwj: Tested ACK aee5404e02e203a256c1a97b629b9b107cc8bb07 Tree-SHA512: 1c1eb345d6690f5307a87e9bac8f06a0d1fdc7ca35db38fa22192510a44289a03252e4677dc7cbf731a27e6e3a9a4e42b6eb4149fe063bc1c905eb2536cdb1d3 --- src/random.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/random.cpp b/src/random.cpp index 21c56c106a..e98a17a451 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -41,6 +41,9 @@ #ifdef HAVE_SYSCTL_ARND #include #endif +#if defined(HAVE_STRONG_GETAUXVAL) && defined(__aarch64__) +#include +#endif [[noreturn]] static void RandFailure() { @@ -176,6 +179,62 @@ static uint64_t GetRdSeed() noexcept #endif } +#elif defined(__aarch64__) && defined(HWCAP2_RNG) + +static bool g_rndr_supported = false; + +static void InitHardwareRand() +{ + if (getauxval(AT_HWCAP2) & HWCAP2_RNG) { + g_rndr_supported = true; + } +} + +static void ReportHardwareRand() +{ + // This must be done in a separate function, as InitHardwareRand() may be indirectly called + // from global constructors, before logging is initialized. + if (g_rndr_supported) { + LogPrintf("Using RNDR and RNDRRS as additional entropy sources\n"); + } +} + +/** Read 64 bits of entropy using rndr. + * + * Must only be called when RNDR is supported. + */ +static uint64_t GetRNDR() noexcept +{ + uint8_t ok; + uint64_t r1; + do { + // https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers/RNDR--Random-Number + __asm__ volatile("mrs %0, s3_3_c2_c4_0; cset %w1, ne;" + : "=r"(r1), "=r"(ok)::"cc"); + if (ok) break; + __asm__ volatile("yield"); + } while (true); + return r1; +} + +/** Read 64 bits of entropy using rndrrs. + * + * Must only be called when RNDRRS is supported. + */ +static uint64_t GetRNDRRS() noexcept +{ + uint8_t ok; + uint64_t r1; + do { + // https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers/RNDRRS--Reseeded-Random-Number + __asm__ volatile("mrs %0, s3_3_c2_c4_1; cset %w1, ne;" + : "=r"(r1), "=r"(ok)::"cc"); + if (ok) break; + __asm__ volatile("yield"); + } while (true); + return r1; +} + #else /* Access to other hardware random number generators could be added here later, * assuming it is sufficiently fast (in the order of a few hundred CPU cycles). @@ -194,6 +253,12 @@ static void SeedHardwareFast(CSHA512& hasher) noexcept { hasher.Write((const unsigned char*)&out, sizeof(out)); return; } +#elif defined(__aarch64__) && defined(HWCAP2_RNG) + if (g_rndr_supported) { + uint64_t out = GetRNDR(); + hasher.Write((const unsigned char*)&out, sizeof(out)); + return; + } #endif } @@ -219,6 +284,14 @@ static void SeedHardwareSlow(CSHA512& hasher) noexcept { } return; } +#elif defined(__aarch64__) && defined(HWCAP2_RNG) + if (g_rndr_supported) { + for (int i = 0; i < 4; ++i) { + uint64_t out = GetRNDRRS(); + hasher.Write((const unsigned char*)&out, sizeof(out)); + } + return; + } #endif } From a9021db4ecc85810200938067669963c29002d13 Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 13 Nov 2023 10:00:18 +0000 Subject: [PATCH 12/16] Merge bitcoin/bitcoin#28777: doc: update docs for `CHECK_ATOMIC` macro ebc7063c80135dd6f3e7b9418e8f4bf217bd8db7 doc: update docs for CHECK_ATOMIC macro (fanquake) Pull request description: Clarify that supported versions of GCC are not affected, and that Clang prior to version 15 still requires the explicit `-latomic` linking, when compiling for 32-bit. ACKs for top commit: hebasto: ACK ebc7063c80135dd6f3e7b9418e8f4bf217bd8db7. Tree-SHA512: 6044dc28547431cfde7e89b663b5f9a86a4cb801212a21c3dbb18a1c41a53640480c3e4e944050dc3ec4cded9bc4c1f8eae8dbb60596289fef49bb13a8b53b76 --- build-aux/m4/l_atomic.m4 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build-aux/m4/l_atomic.m4 b/build-aux/m4/l_atomic.m4 index 40639dfe61..c04a271a56 100644 --- a/build-aux/m4/l_atomic.m4 +++ b/build-aux/m4/l_atomic.m4 @@ -4,8 +4,10 @@ dnl permitted in any medium without royalty provided the copyright notice dnl and this notice are preserved. This file is offered as-is, without any dnl warranty. -# Some versions of gcc/libstdc++ require linking with -latomic if -# using the C++ atomic library. +# Clang prior to version 15, when building for 32-bit, +# and linking against libstdc++, requires linking with +# -latomic if using the C++ atomic library. +# Can be tested with: clang++ test.cpp -m32 # # Sourced from http://bugs.debian.org/797228 From 47f6126504b3d93b69cf3545b0f2ffa2b7628eb4 Mon Sep 17 00:00:00 2001 From: fanquake Date: Thu, 16 Nov 2023 09:39:29 +0000 Subject: [PATCH 13/16] Merge bitcoin/bitcoin#28881: doc: remove mention of missing bdb being a configure error 30bd4b1e4aee00edbe77da7c20bf80e28f0561cc doc: remove mention of missing bdb being a configure error (fanquake) Pull request description: This is no-longer the case, unless you're passing additional flags, which is not the case in this example. ACKs for top commit: maflcko: lgtm ACK 30bd4b1e4aee00edbe77da7c20bf80e28f0561cc TheCharlatan: ACK 30bd4b1e4aee00edbe77da7c20bf80e28f0561cc hebasto: ACK 30bd4b1e4aee00edbe77da7c20bf80e28f0561cc. Tree-SHA512: b3730546d7ff1f49854b88e710c72c4f6e4b6d238147599d4c4e4adeeb256424c2096635f6c51dcfe2e5a9c1155c1c9915fe03a09c5c38605bee2722756c8f6e --- doc/build-osx.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/build-osx.md b/doc/build-osx.md index 4bb04d0f17..2c020c2670 100644 --- a/doc/build-osx.md +++ b/doc/build-osx.md @@ -231,7 +231,6 @@ There are many ways to configure Dash Core, here are a few common examples: ##### Wallet (BDB + SQlite) Support, No GUI: If `berkeley-db@4` is installed, then legacy wallet support will be built. -If `berkeley-db@4` is not installed, then this will throw an error. If `sqlite` is installed, then descriptor wallet support will also be built. Additionally, this explicitly disables the GUI. From 685ee8a46f162eaf480b0ef36f43612dc78e6134 Mon Sep 17 00:00:00 2001 From: fanquake Date: Thu, 16 Nov 2023 09:41:14 +0000 Subject: [PATCH 14/16] Merge bitcoin/bitcoin#28884: doc: remove x86_64 build assumption from depends doc 821a8a11256ccf26fe8b0255cea4ec04dddd8f18 doc: remove x86_64 build assumption from depends doc (fanquake) Pull request description: This dates from the introduction of depends, and has not been the case for some time now. ACKs for top commit: maflcko: lgtm ACK 821a8a11256ccf26fe8b0255cea4ec04dddd8f18 hebasto: ACK 821a8a11256ccf26fe8b0255cea4ec04dddd8f18. theuni: ACK 821a8a11256ccf26fe8b0255cea4ec04dddd8f18 Tree-SHA512: 640967a3e6dfab495fd733d3379aa916ac7f67e89a92ef6a94c3bea0494dc7921a9d7485e1b90a1beab00548b575cdab8fb08eb9267dcc5e890cc796ae1b6875 --- depends/description.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/depends/description.md b/depends/description.md index c5791f29c7..cb69b81ae3 100644 --- a/depends/description.md +++ b/depends/description.md @@ -6,8 +6,7 @@ There are several features that make it different from most similar systems: In theory, binaries for any target OS/architecture can be created, from a builder running any OS/architecture. In practice, build-side tools must be specified when the defaults don't fit, and packages must be amended to work -on new hosts. For now, a build architecture of x86_64 is assumed, either on -Linux or macOS. +on new hosts. ### No reliance on timestamps From f670118cce8a6499f52f1de5f2c81c9cbacfb43b Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 1 Dec 2023 20:28:03 +0000 Subject: [PATCH 15/16] Merge bitcoin/bitcoin#28851: build: Patch Qt to handle minimum macOS version properly 05aca093819be276ac7d648472c6ed5c7d235cc5 build: Patch Qt to handle minimum macOS version properly (Hennadii Stepanov) Pull request description: This PR is: - required to [switch](https://github.com/bitcoin/bitcoin/pull/28622) to macOS 14 SDK (Xcode 15). - an alternative to https://github.com/bitcoin/bitcoin/pull/28732 and https://github.com/bitcoin/bitcoin/pull/28775. Qt relies on the `__MAC_OS_X_VERSION_MIN_REQUIRED` macro, which is set in the `AvailabilityInternal.h` SDK header to the value provided by the Clang driver from the `-mmacos-version-min` / `-mmacosx-version-min` option. Xcode 12 SDK expects the OS-specific `__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__` macro: ```c++ #ifndef __MAC_OS_X_VERSION_MIN_REQUIRED #ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ /* compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ */ #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ #endif #endif /* __MAC_OS_X_VERSION_MIN_REQUIRED*/ ``` In the other hand, Xcode 15 SDK expects a general `__ENVIRONMENT_OS_VERSION_MIN_REQUIRED__` macro: ```c++ #ifndef __MAC_OS_X_VERSION_MIN_REQUIRED #if defined(__has_builtin) && __has_builtin(__is_target_os) #if __is_target_os(macos) #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_14_0 #endif #elif __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_14_0 #endif /* __has_builtin(__is_target_os) && __is_target_os(macos) */ #endif /* __MAC_OS_X_VERSION_MIN_REQUIRED */ ``` The latter macro is not provided by LLVM Clang until https://github.com/llvm/llvm-project/commit/c8e2dd8c6f490b68e41fe663b44535a8a21dfeab, which is available in Clang 17. The suggested patch makes Qt "borrow" the `__MAC_OS_X_VERSION_MIN_REQUIRED` value from `MAC_OS_X_VERSION_MIN_REQUIRED`, which is set in the `AvailabilityMacros.h` SDK header. ACKs for top commit: maflcko: lgtm ACK 05aca093819be276ac7d648472c6ed5c7d235cc5 Tree-SHA512: 8891aefde4b8a48885abf0648f4ec71a22f7fcfca1e17ebb8c70ce1ef44751ea5db6b8b652de6ee8a716ca5f96f720fef01600bc23986162d0146c946e2e8743 --- depends/packages/qt.mk | 2 ++ depends/patches/qt/fix-minimum-macos.patch | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 depends/patches/qt/fix-minimum-macos.patch diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 430e36b25e..21609df1dd 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -24,6 +24,7 @@ $(package)_patches += fast_fixed_dtoa_no_optimize.patch $(package)_patches += fix-macos-linker.patch $(package)_patches += memory_resource.patch $(package)_patches += windows_lto.patch +$(package)_patches += fix-minimum-macos.patch $(package)_qttranslations_file_name=qttranslations-$($(package)_suffix) $(package)_qttranslations_sha256_hash=a31785948c640b7c66d9fe2db4993728ca07f64e41c560b3625ad191b276ff20 @@ -248,6 +249,7 @@ endef define $(package)_preprocess_cmds cp $($(package)_patch_dir)/qt.pro qt.pro && \ cp $($(package)_patch_dir)/qttools_src.pro qttools/src/src.pro && \ + patch -p1 -i $($(package)_patch_dir)/fix-minimum-macos.patch && \ patch -p1 -i $($(package)_patch_dir)/fix-macos-linker.patch && \ patch -p1 -i $($(package)_patch_dir)/dont_hardcode_pwd.patch && \ patch -p1 -i $($(package)_patch_dir)/fix_qt_pkgconfig.patch && \ diff --git a/depends/patches/qt/fix-minimum-macos.patch b/depends/patches/qt/fix-minimum-macos.patch new file mode 100644 index 0000000000..ecaa2ca308 --- /dev/null +++ b/depends/patches/qt/fix-minimum-macos.patch @@ -0,0 +1,18 @@ +Ensure that Qt handles the minimum macOS version properly + +This patch can be dropped for LLVM Clang 17+, after commit +https://github.com/llvm/llvm-project/commit/c8e2dd8c6f490b68e41fe663b44535a8a21dfeab + + +--- a/qtbase/src/corelib/global/qsystemdetection.h ++++ b/qtbase/src/corelib/global/qsystemdetection.h +@@ -220,6 +220,9 @@ + # include + # include + # ++# undef __MAC_OS_X_VERSION_MIN_REQUIRED ++# define __MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_MIN_REQUIRED ++# + # ifdef Q_OS_MACOS + # if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_6 + # undef __MAC_OS_X_VERSION_MIN_REQUIRED From c75a0d4c575edcc7288ec9423968921a6ad2ef58 Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 5 Jan 2024 10:51:05 +0000 Subject: [PATCH 16/16] Merge bitcoin/bitcoin#29177: build: Fix check whether `-latomic` needed f8ca1357c8205ceff732dcfb0d2bad79b40b611b build: Fix check whether `-latomic` needed (Hennadii Stepanov) Pull request description: Clang >=15 still might need linking against `libatomic`. We use `std::atomic::compare_exchange_strong` in `net_processing.cpp`. Addresses the https://github.com/bitcoin/bitcoin/pull/29165#discussion_r1440293694. ACKs for top commit: maflcko: lgtm ACK f8ca1357c8205ceff732dcfb0d2bad79b40b611b fanquake: ACK f8ca1357c8205ceff732dcfb0d2bad79b40b611b Tree-SHA512: ba8b6a88fd3471a206d068e8a000a053c99cb46d26bd04624418ddb066b3b9664a569ec8a1569af67c96b3e27f13dccbd5e24f985290ac072b6d74c92524e35d --- build-aux/m4/l_atomic.m4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build-aux/m4/l_atomic.m4 b/build-aux/m4/l_atomic.m4 index c04a271a56..9a9a31dd8a 100644 --- a/build-aux/m4/l_atomic.m4 +++ b/build-aux/m4/l_atomic.m4 @@ -4,7 +4,7 @@ dnl permitted in any medium without royalty provided the copyright notice dnl and this notice are preserved. This file is offered as-is, without any dnl warranty. -# Clang prior to version 15, when building for 32-bit, +# Clang, when building for 32-bit, # and linking against libstdc++, requires linking with # -latomic if using the C++ atomic library. # Can be tested with: clang++ test.cpp -m32 @@ -24,6 +24,8 @@ m4_define([_CHECK_ATOMIC_testbody], [[ std::atomic t{0s}; t.store(2s); + auto t1 = t.load(); + t.compare_exchange_strong(t1, 3s); std::atomic a{};