Commit Graph

943 Commits

Author SHA1 Message Date
merge-script
d7333ece15
Merge bitcoin/bitcoin#30590: build: Remove unused visibility checks
bbcba09cd5 build: remove check for __declspec(dllexport) (fanquake)
37c9abdc43 build: remove check for __attribute__((visibility.. (fanquake)

Pull request description:

  These are unused (since libbitcoinconsensus / #29648), and the current CMake port doesn't quite match behaviour, such that there's no real point in doing the check. So rather than port anything, just remove it. If these are needed again in future (i.e for kernel or similar), they can be revisted, and it might be the case that build-system level checks will not be wanted.

ACKs for top commit:
  hebasto:
    ACK bbcba09cd5. I've verified that neither `HAVE_DEFAULT_VISIBILITY_ATTRIBUTE` nor `HAVE_DLLEXPORT_ATTRIBUTE` are used or evaluated in the current codebase.
  TheCharlatan:
    ACK bbcba09cd5
  willcl-ark:
    ACK bbcba09cd5

Tree-SHA512: 332f018c50a159d2cbfd2f9ce018538fa11cf06a94e27ed42146945b86645af5881095df39cadd2f775a8ae348ebfc949d54f7eb4b62264bf48119c9f9952c20
2024-08-06 17:44:43 +01:00
fanquake
bbcba09cd5
build: remove check for __declspec(dllexport) 2024-08-05 14:54:56 +01:00
fanquake
37c9abdc43
build: remove check for __attribute__((visibility.. 2024-08-05 14:54:55 +01:00
fanquake
9ec776adff
Revert "build: pass --with-ecmult-gen-kb=86 to secp256k1"
This reverts commit a057869aa3.
2024-08-02 11:33:07 +01:00
merge-script
3679fa167f
Merge bitcoin/bitcoin#28893: Fix SSE4.1-related issues
d440f13db0 crypto: Guard code with `ENABLE_SSE41` macro (Hennadii Stepanov)
6ec1ca7c85 build: Fix test for SSE4.1 intrinsics (Hennadii Stepanov)

Pull request description:

  1. Fix the test for SSE4.1 intrinsics during build system configuration, which currently can be false positive, for example, when `CXXFLAGS="-mno-sse4.1"` provided.

  This PR fixes the test by adding the `_mm_blend_epi16` SSE4.1 function used in our codebase.

  2. Guard `sha_x86_shani.cpp` code with `ENABLE_SSE41` macro as it uses the `_mm_blend_epi16` function from
  the SSE4.1 instruction set.

  It is possible that SHA-NI is enabled even when SSE4.1 is disabled, which causes compile errors in the master branch.

  Closes https://github.com/bitcoin/bitcoin/issues/28864.

ACKs for top commit:
  sipa:
    utACK d440f13db0
  willcl-ark:
    tACK d440f13db0
  theuni:
    utACK d440f13db0

Tree-SHA512: a6e1e8c94e1b94874ff51846815ef445e6135cbdb01b08eb695b3548115f2340dd835ebe53673ae46a553fe6be4815e68d8642c34235dd7af5106c4b7c9ea6f3
2024-07-17 16:58:54 +01:00
merge-script
24dffdde7b
Merge bitcoin/bitcoin#29072: build: use -no_exported_symbols on macOS
81d4dc8e87 build: use -no_exported_symbols on macOS (fanquake)

Pull request description:

  This reduces the size of the binary by ~1% when building with `--enable-reduce-exports`.

  > -no_exported_symbols
  > Useful for main executable that don't have plugins and thus need no symbol exports.

  Can be tested with `dyld_info -exports src/bitcoind`. The only exported symbol should be `__mh_execute_header`.

ACKs for top commit:
  theuni:
    utACK 81d4dc8e87
  hebasto:
    ACK 81d4dc8e87.

Tree-SHA512: ae46065a05d190753ba807943c0734a06cfe6d2cf9eaf3c3aa93250bf8639da8bc53b81c6b0390e6d572a74c6bb31a695f8c5924810bfa358a3c9b08caff03f7
2024-07-16 15:49:12 +01:00
merge-script
d3d2bbf576
Merge bitcoin/bitcoin#30327: build: Drop redundant sys/sysctl.h header check
c0b5ea5901 build: Drop redundant `sys/sysctl.h` header check (Hennadii Stepanov)

Pull request description:

  The `AC_CHECK_HEADERS` macro defines `HAVE_SYS_SYSCTL_H` if the `sys/sysctl.h` header is found. However, in the source code, this header is guarded by `HAVE_SYSCTL` and `HAVE_SYSCTL_ARND` macros, which have their own checks. Since `HAVE_SYS_SYSCTL_H` is not used, we can skip the `AC_CHECK_HEADERS(... sys/sysctl.h ...)` check.

ACKs for top commit:
  laanwj:
    ACK c0b5ea5901
  fanquake:
    ACK c0b5ea5901 - we could got the other way, and add nested #defs, but that doesn't seem worthwhile.

Tree-SHA512: 73bc4bbfc5c457cd2c38e40f8e57d2a70c06ef661d76d4148d683d262be45b9405b8cda1958ac611c312ca7d9e2f9624cf2cac1b61f1008af0856875c62f0eac
2024-06-26 15:25:46 +01:00
Hennadii Stepanov
c0b5ea5901
build: Drop redundant sys/sysctl.h header check
The `AC_CHECK_HEADERS` macro defines `HAVE_SYS_SYSCTL_H` if the
`sys/sysctl.h` header is found. However, in the source code, this header
is guarded by `HAVE_SYSCTL` and `HAVE_SYSCTL_ARND` macros, which have
their own checks. Since `HAVE_SYS_SYSCTL_H` is not used, we can skip the
`AC_CHECK_HEADERS(... sys/sysctl.h ...)` check.
2024-06-24 14:28:23 +01:00
fanquake
e3dc64f499
build: add -Wundef
"Warn if an undefined identifier is evaluated in an #if directive. Such
identifiers are replaced with zero."
2024-06-21 09:43:48 +01:00
Ryan Ofsky
79e197b175
build: Suppress warnings from boost and capnproto in multiprocess code
Without this change there are errors from boost like:

/ci_container_base/depends/i686-pc-linux-gnu/include/boost/signals2/expired_slot.hpp:23:28: error: 'what' overrides a member function but is not marked 'override' [-Werror,-Wsuggest-override]
/ci_container_base/depends/i686-pc-linux-gnu/include/boost/signals2/detail/signal_template.hpp:750:32: error: 'lock_pimpl' overrides a member function but is not marked 'override' [-Werror,-Wsuggest-override]
/ci_container_base/depends/i686-pc-linux-gnu/include/boost/signals2/connection.hpp:150:22: error: 'connected' overrides a member function but is not marked 'override' [-Werror,-Wsuggest-override]

There do not seem to be errors from capnproto currently, but add a suppression
for it, too, to be consistent with other libraries.
2024-06-21 09:42:32 +01:00
fanquake
81d4dc8e87
build: use -no_exported_symbols on macOS
This reduces the size of the binary by 2-3% when building with
`--enable-reduce-exports`.
2024-06-18 13:03:32 +01:00
merge-script
cad127235e
Merge bitcoin/bitcoin#30257: build: Remove --enable-gprof
fa780e1c25 build: Remove --enable-gprof (MarcoFalke)

Pull request description:

  It is unclear what benefit this option has, given that:

  * `gprof` requires re-compilation (`perf` and other tools can instead be used on existing executables)
  * `gprof` requires hardening to be disabled
  * `gprof` doesn't work with `clang`
  * `perf` is documented in the dev-notes, and test notes, and embedded into the functional test framework; `gprof` isn't
  * Anyone really wanting to use it could pass the required flags to `./configure`
  * I couldn't find any mention of the use of `gprof` in the discussions in this repo, apart from the initial pull request adding it (cfaac2a60f)
  * Keeping it means that it needs to be maintained and ported to CMake

  Fix all issues by removing it.

ACKs for top commit:
  TheCharlatan:
    ACK fa780e1c25
  hebasto:
    ACK fa780e1c25, I have reviewed the code and it looks OK.
  willcl-ark:
    crACK fa780e1c25

Tree-SHA512: 0a9ff363ac2bec8b743878a4e3147f18bc16823d00c5007568432c36320bd0199b13b6d0ce828a9a83c2cc434c058afaa64eb2eccfbd93ed85b81ce10c41760c
2024-06-10 12:01:19 +01:00
MarcoFalke
fa780e1c25
build: Remove --enable-gprof
This reverts cfaac2a60f
2024-06-09 22:45:29 +02:00
Cory Fields
15796d4b61 build: warn on self-assignment
Belt-and suspenders after #30234. Self-assignment should be safe _and_
discouraged.

We used to opt out of this warning because something deep in our
serialization/byteswapping code could self-assign, but that doesn't appear to
be the case anymore.
2024-06-06 14:14:34 +00:00
Cory Fields
c3a5e8a063 build: re-enable deprecated warning copy
This was disabled in #18738 due to the combo of old gcc and qt, neither of
which are relevant to us anymore.
2024-06-05 21:06:44 +00:00
fanquake
cbd4640ede
build: remove --enable-lcov-branch-coverage
This supports lcov 2.x in the sense that we are no-longer hardcoding
version specific options, and instead will use the `LCOV_OPTS` variable
(which is the more correct/flexible thing to do in any case). It's also
quite likely that devs are already having to pass extra options to lcov
2.x, given it's more stringent in terms of coverage generation and error
checking. See this thread for an example:
https://github.com/linux-test-project/lcov/issues/238.

Added an example to the developer notes.

Tested on one machine (LCOV 2.0, gcc 13.2) with:
```bash
./autogen.sh
./configure --enable-lcov CXXFLAGS="-fprofile-update=prefer-atomic" LCOV_OPTS="--rc branch_coverage=1 --ignore-errors mismatch"
make
make cov
<snip>
Processing file src/netaddress.cpp
  lines=521 hit=480 functions=72 hit=72 branches=675 hit=499
Overall coverage rate:
  lines......: 81.8% (79362 of 97002 lines)
  functions......: 77.8% (10356 of 13310 functions)
  branches......: 49.6% (130628 of 263196 branches)
```

and another machine (LCOV 2.1, Clang 18.1.3) with:
```bash
./autogen.sh
./configure --enable-lcov CC=clang CXX=clang++ LCOV_OPTS="--rc branch_coverage=1 --ignore-errors mismatch,inconsistent"
make
make cov
<snip>
Processing file src/util/strencodings.cpp
  lines=315 hit=311 functions=38 hit=38 branches=425 hit=357
Overall coverage rate:
  source files: 622
  lines.......: 79.8% (70311 of 88132 lines)
  functions...: 78.1% (13968 of 17881 functions)
  branches....: 44.5% (157551 of 354317 branches)
Message summary:
  101 warning messages:
    count: 1
    inconsistent: 100
  3528 ignore messages:
    inconsistent: 3528
```
2024-05-30 10:36:55 +01:00
merge-script
f61ede574c
Merge bitcoin/bitcoin#30049: build, test, doc: Temporarily remove Android-related stuff
5deb0b024e build, test, doc: Temporarily remove Android-related stuff (Hennadii Stepanov)

Pull request description:

  Previously, our Android builds were geared towards generating APKs, which relied on Qt. However, after migrating to C++20, compiling for Android became unfeasible due to Qt 5.15's compatibility limitations with NDK only up to r25, which includes an outdated embedded libc++ (see https://github.com/bitcoin/bitcoin/issues/29360).

  All removed stuff will be reinstated after migrating the build system to CMake and upgrading Qt to version 6.x.

  This PR makes possible a clean migration to the CMake-based build system as it removes code, which is not used at this moment.

ACKs for top commit:
  vasild:
    ACK 5deb0b024e
  fanquake:
    ACK 5deb0b024e - given none of this is currently tested/wont compile. Can be revisted in future.

Tree-SHA512: 3bc2ccfe881e11cc1d78c27acd6f1d86cfba86821ef3bb5eca2e80d978fdfa13659ec82284dcaadc507e2394524dea91d4b8f81d0030c1cef9708df8be76bf07
2024-05-30 09:25:42 +01:00
merge-script
0388dd702b
Merge bitcoin/bitcoin#30120: Update libsecp256k1 subtree to current master
a057869aa3 build: pass --with-ecmult-gen-kb=86 to secp256k1 (fanquake)
ca3d945dc6 Squashed 'src/secp256k1/' changes from d8311688bd..06bff6dec8 (fanquake)

Pull request description:

  This includes changes from the 0.5.0 release: https://github.com/bitcoin-core/secp256k1/releases/tag/v0.5.0

  > New function secp256k1_ec_pubkey_sort that sorts public keys using lexicographic (of compressed serialization) order.

  > The implementation of the point multiplication algorithm used for signing and public key generation was changed, resulting in improved performance for those operations.
  >    The related configure option --ecmult-gen-precision was replaced with --ecmult-gen-kb (ECMULT_GEN_KB for CMake).
  >    This changes the supported precomputed table sizes for these operations. The new supported sizes are 2 KiB, 22 KiB, or 86 KiB (while the old supported sizes were 32 KiB, 64 KiB, or 512 KiB).

ACKs for top commit:
  hebasto:
    ACK a057869aa3, I've got a zero diff with my local branch, which reproduces the subtree update, and `ecmult gen table size   = 86 KiB` in the configure summary.
  jonasnick:
    utACK a057869aa3

Tree-SHA512: 907012b0d7e0a6bd68b245c238e968f2318d8ac5de5ec9070245de8391c996eb5ec6428184d028f6f0f54d3b2f5a8292ad7081177e1c331397879505436dc38e
2024-05-22 08:50:42 +01:00
fanquake
17fe948cce
build: remove --enable-threadlocal 2024-05-21 10:29:51 +01:00
Hennadii Stepanov
5bba43312c
build: Enable thread_local for MinGW-w64 builds
The assumption in the commit 188ca75e5f
about the broken `thread_local` implementation in GCC was misguided
because the initial failure was not due to GCC, but a bug in the Wine
runtime, as evidenced, for example, here:
 - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=917307
 - https://bugs.freedesktop.org/show_bug.cgi?id=108662

Consequently, it is safe to re-enable `thread_local` support for
MinGW-w64 builds.
2024-05-21 10:27:42 +01:00
fanquake
a057869aa3
build: pass --with-ecmult-gen-kb=86 to secp256k1 2024-05-18 11:12:25 +08:00
Vasil Dimov
d35ba1b3f1
util: avoid using thread_local variable that has a destructor
Store the thread name in a `thread_local` variable of type `char[]`
instead of `std::string`. This avoids calling the destructor when
the thread exits. This is a workaround for
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278701

For type-safety, return `std::string` from
`util::ThreadGetInternalName()` instead of `char[]`.

As a side effect of this change, we no longer store a reference
to a `thread_local` variable in `CLockLocation`. This was
dangerous because if the thread quits while the reference still
exists (in the global variable `lock_data`, see inside `GetLockData()`)
then the reference will become dangling.
2024-05-16 18:16:46 +02:00
fanquake
7f5ac4520d
build: swap otool for (llvm-)objdump
Similar to libtool, (llvm-)otool only exists with a version suffix
on some systems (Ubuntu), which makes it annoying to use/find. Avoid
this, by switching to objdump. Which is a drop-in replacement.

This is related to #21778, and the switchover to using vanilla LLVM for
macOS.
2024-05-08 16:36:41 +08:00
Hennadii Stepanov
5deb0b024e
build, test, doc: Temporarily remove Android-related stuff
Previously, our Android builds were geared towards generating APKs,
which relied on Qt. However, after migrating to C++20, compiling for
Android became unfeasible due to Qt 5.15's compatibility limitations
with NDK only up to r25, which includes an outdated embedded libc++.

All removed stuff will be reinstated after migrating the build system to
CMake and upgrading Qt to version 6.x."
2024-05-06 11:29:14 +01:00
fanquake
f0e22be69a
build: no-longer disable WARN_CXXFLAGS when CXXFLAGS is set
Now that CXXFLAGS are back in user control, I don't think there's a
reason to no-longer use our warning flags when CXXFLAGS has been
overriden (this includes when building from depends).

Anyone can suppress warnings from third-party code by
passing the relevant `-Wno-` options in CXXFLAGS.

Fixes: #18092.
2024-05-03 15:31:54 +08:00
Ryan Ofsky
16a6174613
Merge bitcoin/bitcoin#29904: refactor: Use our own implementation of urlDecode
992c714451 common: Don't terminate on null character in UrlDecode (Fabian Jahr)
099fa57151 scripted-diff: Modernize name of urlDecode function and param (Fabian Jahr)
8f39aaae41 refactor: Remove hooking code for urlDecode (Fabian Jahr)
650d43ec15 refactor: Replace libevent use in urlDecode with our own code (Fabian Jahr)
46bc6c2aaa test: Add unit tests for urlDecode (Fabian Jahr)

Pull request description:

  Fixes #29654 (as a side-effect)

  Removing dependencies is a general goal of the project and the xz backdoor has been an additional wake up call recently. Libevent shows many of the same symptoms, few maintainers and slow releases. While libevent can not be removed completely over night we should start removing it’s usage where it's possible, ideally with the end goal to removing it completely.

  This is a pretty easy win in that direction. The [`evhttp_uridecode` function from libevent](e0a4574ba2/http.c (L3542)) we were using in `urlDecode` could be easily emulated in fewer LOC. This also ports the [applicable test vectors over from libevent](https://github.com/libevent/libevent/blob/master/test/regress_http.c#L3430).

ACKs for top commit:
  achow101:
    ACK 992c714451
  theStack:
    Code-review ACK 992c714451
  maflcko:
    ACK 992c714451 👈
  stickies-v:
    ACK 992c714451

Tree-SHA512: 78f76ae7ab3b6710eab2aaac20f55eb0da7803e057eaa6220e865f328666a5399ef1a479702aaf630b2f974ad3aa15e2b6adac9c11bc8c3d4be21e8af1667fea
2024-04-25 13:02:43 -04:00
Fabian Jahr
650d43ec15
refactor: Replace libevent use in urlDecode with our own code 2024-04-24 23:23:34 +02:00
fanquake
1a9aa8d4ee
build: better scope usage of -Wl,-headerpad_max_install_names
If we aren't using install_name_tool when cross-compiling, we don't need
to test for / add it to LDFLAGS when that is the case.
2024-04-17 11:40:25 +01:00
fanquake
3bee51427a
build: don't use install_name_tool for macOS deploy when cross-compiling
This is only needed when compiling on macOS. This means we can also
better scope the usage of `-headerpad_max_install_names`.
2024-04-17 11:40:25 +01:00
fanquake
4722b7c715
build: remove minisketch clz check 2024-04-12 14:28:34 +02:00
merge-script
0a9cfd1752
Merge bitcoin/bitcoin#28981: Replace Boost.Process with cpp-subprocess
d5a715536e build: remove boost::process dependency for building external signer support (Sebastian Falbesoner)
70434b1c44 external_signer: replace boost::process with cpp-subprocess (Sebastian Falbesoner)
cc8b9875b1 Add `cpp-subprocess` header-only library (Hennadii Stepanov)

Pull request description:

  Closes https://github.com/bitcoin/bitcoin/issues/24907.

  This PR is based on **theStack**'s [work](https://github.com/bitcoin/bitcoin/issues/24907#issuecomment-1466087049).

  The `subprocess.hpp` header has been sourced from the [upstream repo](https://github.com/arun11299/cpp-subprocess) with the only modification being the removal of convenience functions, which are not utilized in our codebase.

  Windows-related changes will be addressed in subsequent follow-ups.

ACKs for top commit:
  achow101:
    reACK d5a715536e
  Sjors:
    re-tACK d5a715536e
  theStack:
    Light re-ACK d5a715536e
  fanquake:
    ACK d5a715536e - with the expectation that this code is going to be maintained as our own. Next PRs should:

Tree-SHA512: d7fb6fecc3f5792496204190afb7d85b3e207b858fb1a75efe483c05260843b81b27d14b299323bb667c990e87a07197059afea3796cf218ed8b614086bd3611
2024-04-10 12:03:06 +02:00
fanquake
0f0e36de5f
Merge bitcoin/bitcoin#29815: crypto: chacha20: always use our fallback timingsafe_bcmp rather than libc's
2d1819455c crypto: chacha20: always use our fallback timingsafe_bcmp rather than libc's (Cory Fields)

Pull request description:

  Looking at libc sources, apple and openbsd implementations match our naive fallback. Only FreeBSD (and only x86_64) seems to [implement an optimized version](https://github.com/freebsd/freebsd-src/blob/main/lib/libc/amd64/string/timingsafe_bcmp.S).

  It's not worth the hassle of using a platform-specific function for such little gain.

  Additionally, as mentioned below, this is the only case outside of sha2 that requires an autoconf check, and I have upcoming PRs to remove the sha2 ones.

  Apple's [impl is unoptimized](https://opensource.apple.com/source/Libc/Libc-1244.1.7/string/FreeBSD/timingsafe_bcmp.c.auto.html).

  As-is [OpenBSD's impl](https://github.com/openbsd/src/blob/master/lib/libc/string/timingsafe_bcmp.c).

  Relevant IRC conversation with sipa:

  > \<cfields\> sipa: chacha20poly1305.cpp uses libc's timingsafe_bcmp when possible. But looking around at apple/freebsd/openbsd, I don't see any impl that doesn't use the naive implementation that matches our fallback...
  > \<cfields\> is there any reason to belive there's an optimized impl somewhere that we're actually hitting?
  > \<cfields\> asking because after cleaning up sha2, timingsafe_bcmp is the last autoconf check that remains in all of crypto. It'd make life easy if we could just always use our internal one.
  > \<cfields\> *all of crypto/
  > \<sipa\> cfields: let's get rid of the dependency then
  > \<sipa\> it's a trivial function
  > \<sipa\> and if we need it for some platforms, no real reason not to use it on all

  After the above discusstion, I did end up finding the x86_64-optimized FreeBSD impl, but I don't think that's all that significant.

ACKs for top commit:
  sipa:
    utACK 2d1819455c
  fanquake:
    ACK 2d1819455c
  TheCharlatan:
    ACK 2d1819455c
  theStack:
    ACK 2d1819455c

Tree-SHA512: b9583e19ac2f77c5d572aa5b95bc4b53669d5717e5708babef930644980de7c5d06a9c7decd5c2b559d70b8597328ecfe513375e3d8c3ef523db80012dfe9266
2024-04-06 20:45:19 +01:00
fanquake
c3530254c9
Merge bitcoin/bitcoin#29081: refactor: Remove gmtime*
fa9f36baba build: Remove HAVE_GMTIME_R (MarcoFalke)
fa72dcbfa5 refactor: FormatISO8601* without gmtime* (MarcoFalke)
fa2c486afc Revert "time: add runtime sanity check" (MarcoFalke)

Pull request description:

  Now that the `ChronoSanityCheck` has passed for everyone with C++17 and is guaranteed by C++20 to always pass, remove it.

  Also, remove `gmtime_r` and `gmtime_s` and replace them with `year_month_day`+`hh_mm_ss` from C++20.

ACKs for top commit:
  sipa:
    utACK fa9f36baba
  fanquake:
    ACK fa9f36baba - more std lib & even less stuff to port.

Tree-SHA512: a9e7e805b757b7dade0bcc3f95273a7dc4f68622630d74838339789dd203ad7542d36b2e090a93b2bc5a7ecc383207dd7ec82c68147108bdac7ce44f088c8c9a
2024-04-05 17:02:00 +01:00
Cory Fields
2d1819455c crypto: chacha20: always use our fallback timingsafe_bcmp rather than libc's
Looking at apple/freebsd/openbsd sources, their implementations match our naive
fallback. It's not worth the hassle of using a platform-specific function for
no gain.
2024-04-05 15:44:21 +00:00
Sebastian Falbesoner
d5a715536e
build: remove boost::process dependency for building external signer support 2024-03-27 14:16:38 +00:00
fanquake
80f8b92f4f
remove libbitcoinconsensus
This was deprecated in v27.0, for removal in v28.0.
See discussion in PR #29189.
2024-03-18 16:59:39 +00:00
MarcoFalke
fa9f36baba
build: Remove HAVE_GMTIME_R 2024-03-18 16:01:28 +01:00
Ava Chow
0ed2c130e7
Merge bitcoin/bitcoin#27375: net: support unix domain sockets for -proxy and -onion
567cec9a05 doc: add release notes and help text for unix sockets (Matthew Zipkin)
bfe5192891 test: cover UNIX sockets in feature_proxy.py (Matthew Zipkin)
c65c0d0163 init: allow UNIX socket path for -proxy and -onion (Matthew Zipkin)
c3bd43142e gui: accomodate unix socket Proxy in updateDefaultProxyNets() (Matthew Zipkin)
a88bf9dedd i2p: construct Session with Proxy instead of CService (Matthew Zipkin)
d9318a37ec net: split ConnectToSocket() from ConnectDirectly() for unix sockets (Matthew Zipkin)
ac2ecf3182 proxy: rename randomize_credentials to m_randomize_credentials (Matthew Zipkin)
a89c3f59dc netbase: extend Proxy class to wrap UNIX socket as well as TCP (Matthew Zipkin)
3a7d6548ef net: move CreateSock() calls from ConnectNode() to netbase methods (Matthew Zipkin)
74f568cb6f netbase: allow CreateSock() to create UNIX sockets if supported (Matthew Zipkin)
bae86c8d31 netbase: refactor CreateSock() to accept sa_family_t (Matthew Zipkin)
adb3a3e51d configure: test for unix domain sockets (Matthew Zipkin)

Pull request description:

  Closes https://github.com/bitcoin/bitcoin/issues/27252

  UNIX domain sockets are a mechanism for inter-process communication that are faster than local TCP ports (because there is no need for TCP overhead) and potentially more secure because access is managed by the filesystem instead of serving an open port on the system.

  There has been work on [unix domain sockets before](https://github.com/bitcoin/bitcoin/pull/9979) but for now I just wanted to start on this single use-case which is enabling unix sockets from the client side, specifically connecting to a local Tor proxy (Tor can listen on unix sockets and even enforces strict curent-user-only access permission before binding) configured by `-onion=` or `-proxy=`

  I copied the prefix `unix:` usage from Tor. With this patch built locally you can test with your own filesystem path (example):

  `tor --SocksPort unix:/Users/matthewzipkin/torsocket/x`

  `bitcoind -proxy=unix:/Users/matthewzipkin/torsocket/x`

  Prep work for this feature includes:
  - Moving where and how we create `sockaddr` and `Sock` to accommodate `AF_UNIX` without disturbing `CService`
  - Expanding `Proxy` class to represent either a `CService` or a UNIX socket (by its file path)

  Future work:
  - Enable UNIX sockets for ZMQ (https://github.com/bitcoin/bitcoin/pull/27679)
  - Enable UNIX sockets for I2P SAM proxy (some code is included in this PR but not tested or exposed to user options yet)
  - Enable UNIX sockets on windows where supported
  - Update Network Proxies dialog in GUI to support UNIX sockets

ACKs for top commit:
  Sjors:
    re-ACK 567cec9a05
  tdb3:
    re ACK for 567cec9a05.
  achow101:
    ACK 567cec9a05
  vasild:
    ACK 567cec9a05

Tree-SHA512: de81860e56d5de83217a18df4c35297732b4ad491e293a0153d2d02a0bde1d022700a1131279b187ef219651487537354b9d06d10fde56225500c7e257df92c1
2024-03-13 06:53:07 -04:00
fanquake
8b7630cb1f
build: ignore deprecated-declaration warnings in objc++ macOS code
These come from GUI code, and haven't/aren't being fixed, see discussion
in https://github.com/bitcoin-core/gui/issues/112. For now, just ignore
them entirely. Note that this only applies to ObjCXX code, so will not
hide any relevant warnings coming from C or CXX code (and they would be
unlikely in any case).

Alternative to #29362, which disables all compiler warnings, for macOS
builds in the CI.

Relevant output:
```bash
qt/macnotificationhandler.mm:27:9: warning: 'NSUserNotification' is deprecated: first deprecated in macOS 11.0 - All NSUserNotifications API should be replaced with UserNotifications.frameworks API [-Wdeprecated-declarations]
        NSUserNotification* userNotification = [[NSUserNotification alloc] init];
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:24:12: note: 'NSUserNotification' has been explicitly marked deprecated here
@interface NSUserNotification : NSObject <NSCopying> {
           ^
qt/macnotificationhandler.mm:27:50: warning: 'NSUserNotification' is deprecated: first deprecated in macOS 11.0 - All NSUserNotifications API should be replaced with UserNotifications.frameworks API [-Wdeprecated-declarations]
        NSUserNotification* userNotification = [[NSUserNotification alloc] init];
                                                 ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:24:12: note: 'NSUserNotification' has been explicitly marked deprecated here
@interface NSUserNotification : NSObject <NSCopying> {
           ^
qt/macnotificationhandler.mm:30:11: warning: 'NSUserNotificationCenter' is deprecated: first deprecated in macOS 11.0 - All NSUserNotifications API should be replaced with UserNotifications.frameworks API [-Wdeprecated-declarations]
        [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: userNotification];
          ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:118:12: note: 'NSUserNotificationCenter' has been explicitly marked deprecated here
@interface NSUserNotificationCenter : NSObject {
           ^
3 warnings generated.
```
2024-03-07 13:07:17 +00:00
fanquake
fd4fe411d3
build: bump version to 27.99 2024-03-06 14:47:04 +00:00
Hennadii Stepanov
6ec1ca7c85
build: Fix test for SSE4.1 intrinsics
This change uses the `_mm_blend_epi16` SSE4.1 function used in our code
and fixes false-positive cases, for example, when CXXFLAGS="-mno-sse4.1"
provided.
2024-03-05 11:36:40 +00:00
Matthew Zipkin
adb3a3e51d
configure: test for unix domain sockets
Copied from https://github.com/bitcoin/bitcoin/pull/9979

Co-authored-by: laanwj <126646+laanwj@users.noreply.github.com>
2024-03-01 13:11:26 -05:00
fanquake
8da62a1041
Merge bitcoin/bitcoin#29263: serialization: c++20 endian/byteswap/clz modernization
86b7f28d6c serialization: use internal endian conversion functions (Cory Fields)
432b18ca8d serialization: detect byteswap builtins without autoconf tests (Cory Fields)
297367b3bb crypto: replace CountBits with std::bit_width (Cory Fields)
52f9bba889 crypto: replace non-standard CLZ builtins with c++20's bit_width (Cory Fields)

Pull request description:

  This replaces #28674, #29036, and #29057. Now ready for testing and review.

  Replaces platform-specific endian and byteswap functions. This is especially useful for kernel, as it means that our deep serialization code no longer requires bitcoin-config.h.

  I apologize for the size of the last commit, but it's hard to avoid making those changes at once.

  All platforms now use our internal functions rather than libc or platform-specific ones, with the exception of MSVC.

  Sadly, benchmarking showed that not all compilers are capable of detecting and optimizing byteswap functions, so compiler builtins are instead used where possible. However, they're now detected via macros rather than autoconf checks.

  This[ matches how libc++ implements std::byteswap for c++23](https://github.com/llvm/llvm-project/blob/main/libcxx/include/__bit/byteswap.h#L26).

  I suggest we move/rename `compat/endian.h`, but I left that out of this PR to avoid bikeshedding.

  #29057 pointed out some irregularities in benchmarks. After messing with various compilers and configs for a few weeks with these changes, I'm of the opinion that we can't win on every platform every time, so we should take the code that makes sense going forward. That said, if any real-world slowdowns are caused here, we should obviously investigate.

ACKs for top commit:
  maflcko:
    ACK 86b7f28d6c 📘
  fanquake:
    ACK 86b7f28d6c - we can finish pruning out the __builtin_clz* checks/usage once the minisketch code has been updated. This is more good cleanup pre-CMake & for the kernal.

Tree-SHA512: 715a32ec190c70505ffbce70bfe81fc7b6aa33e376b60292e801f60cf17025aabfcab4e8c53ebb2e28ffc5cf4c20b74fe3dd8548371ad772085c13aec8b7970e
2024-03-01 11:19:58 -05:00
Cory Fields
376f0f6d07 build: remove confusing and inconsistent disable-asm option
1. It didn't actually disable asm usage in our code. Regardless of the setting,
   asm is used in random.cpp and support/cleanse.cpp.
2. The value wasn't forwarded to libsecp as a user might have reasonably
   expected.
3. We now have the DISABLE_OPTIMIZED_SHA256 define which is what disable-asm
   actually did in practice.

If there is any desire, we can hook DISABLE_OPTIMIZED_SHA256 up to a new
configure option that actually does what it says.
2024-02-29 19:05:45 +00:00
fanquake
bbfddb3998
Merge bitcoin/bitcoin#29484: serialization: replace char-is-int8_t autoconf detection with c++20 concept
ad7584d8b6 serialization: replace char-is-int8_t autoconf detection with c++20 concept (Cory Fields)

Pull request description:

  Doesn't depend on #29263, but it's really only relevant after that one's merged.

  This removes the only remaining autoconf macro in our serialization code (after #29263), so it can now be used trivially and safely out-of-tree.

  ~Our code does not currently contain any concepts, but couldn't find any discussion or docs about avoiding them. I guess we'll see if this blows up our c-i.~
  Edit: Ignore this. ajtowns pointed out that we're already using a few concepts.

  This was introduced in #13580. Please check my logic on this as I'm unable to test on a SmartOS system. Even better would be a confirmation from someone who can build there.

ACKs for top commit:
  Empact:
    Code review ACK ad7584d8b6

Tree-SHA512: 1faf65c900700efb1cf3092c607a2230321b393cb2f029fbfb94bc8e50df1dabd7a9e4b91e3b34f0d2f3471aaf18ee7e56d91869db5c5f4bae84da95443e1120
2024-02-28 22:04:33 +00:00
Cory Fields
86b7f28d6c serialization: use internal endian conversion functions
These replace our platform-specific mess in favor of c++20 endian detection
via std::endian and internal byteswap functions when necessary.

They no longer rely on autoconf detection.
2024-02-28 13:42:38 +00:00
Cory Fields
432b18ca8d serialization: detect byteswap builtins without autoconf tests
Rather than a complicated set of tests to decide which bswap functions to
use, always prefer the compiler built-ins when available.

These builtins and fallbacks can all be removed once we're using c++23, which
adds std::byteswap.
2024-02-28 13:42:38 +00:00
Cory Fields
ad7584d8b6 serialization: replace char-is-int8_t autoconf detection with c++20 concept
This removes the only remaining autoconf macro in our serialization code,
so it can now be used trivially and safely out-of-tree.
2024-02-27 19:03:26 +00:00
fanquake
b052b2d1f2
build: remove -Wdocumentation conditional
Now that --enable-suppress-external-warnings is on by default, we can
drop it.
2024-02-27 09:53:42 +00:00
fanquake
e3b68b3b83
Merge bitcoin/bitcoin#28875: build: Pass sanitize flags to instrument libsecp256k1 code
cbea49c0d3 build: Pass sanitize flags to instrument `libsecp256k1` code (Hennadii Stepanov)

Pull request description:

  This PR is a revived https://github.com/bitcoin/bitcoin/pull/27991 with an addressed [comment](https://github.com/bitcoin/bitcoin/pull/27991#discussion_r1252148488).

  Fixes https://github.com/bitcoin/bitcoin/issues/27990.

  Might be tested as follows:
  ```
  $ ./autogen.sh && ./configure --enable-fuzz --with-sanitizers=fuzzer CC=clang-13 CXX=clang++-13
  $ make clean > /dev/null && make
  $ objdump --disassemble=secp256k1_xonly_pubkey_serialize src/test/fuzz/fuzz | grep __sanitizer_cov
   1953bd0:e8 bb c6 05 ff       call   9b0290 <__sanitizer_cov_trace_const_cmp8>
   1953d32:e8 69 c4 05 ff       call   9b01a0 <__sanitizer_cov_trace_pc_indir>
   1953d58:e8 43 c4 05 ff       call   9b01a0 <__sanitizer_cov_trace_pc_indir>
   1953d82:e8 19 c4 05 ff       call   9b01a0 <__sanitizer_cov_trace_pc_indir>
  ```

ACKs for top commit:
  fanquake:
    ACK cbea49c0d3
  dergoegge:
    reACK cbea49c0d3

Tree-SHA512: 801994e75b711d20eaf0d675f378da07d693f4a7de026efd93860f5f1deabed855a83eca3561725263e4fe605fcc5f91eb73c021ec91c831864e6deb575e3885
2024-01-26 11:31:34 +00:00