Commit Graph

27479 Commits

Author SHA1 Message Date
MarcoFalke
fa461d7a43
fuzz: Limit wallet_notifications iterations 2024-11-06 21:30:32 +01:00
Hennadii Stepanov
ffda355b5a
cmake, refactor: Move HAVE_EVHTTP_... to libevent interface 2024-11-06 15:40:42 +00:00
Hennadii Stepanov
b619bdc330
cmake: Revamp FindLibevent module
This change generalizes the use of `find_package` / `pkg_check_modules`,
prioritizing the former.
2024-11-06 15:40:34 +00:00
glozow
5dc94d13d4 fuzz fix: assert MAX_PEER_TX_ANNOUNCEMENTS is not exceeded
Previously this assertion checked MAX_PEER_TX_REQUEST_IN_FLIGHT was not
exceeded. However, this property is not actually enforced; it is just
used to determine when a peer is overloaded.
2024-11-06 09:29:11 -03:00
merge-script
45e2f8f87d
Merge bitcoin/bitcoin#31173: cmake: Add FindQRencode module and enable libqrencode package for MSVC
9e5089dbb0 build, msvc: Enable `libqrencode` vcpkg package (Hennadii Stepanov)
30089b0cb6 cmake: Add `FindQRencode` module (Hennadii Stepanov)

Pull request description:

  This PR introduces the `FindQRencode` CMake module, following the official CMake [guidelines](https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#find-modules) for managing [upstream libraries](https://github.com/fukuchi/libqrencode) that lack a config file package. This module enhances flexibility in locating the `libqrencode` library by making the use of `pkg-config` optional.

  With this update, `libqrencode` can be detected on systems where either `pkg-config` or the `libqrencode.pc` file is unavailable, such as Windows environments using the vcpkg package manager. However, if `libqrencode.pc` is available, it remains beneficial as the only direct source of the library's version information.

  Additionally, the `libqrencode` vcpkg package is enabled for MSVC builds.

  Here is a diff for configuration output on Ubuntu 24.10:
  ```diff
   -- Detecting CXX compile features - done
   -- Found SQLite3: /usr/include (found suitable version "3.46.1", minimum required is "3.7.17")
   -- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.1")
  --- Checking for module 'libqrencode'
  ---   Found libqrencode, version 4.1.1
  +-- Found QRencode: /usr/lib/x86_64-linux-gnu/libqrencode.so (found version "4.1.1")
   -- Found Qt: /usr/lib/x86_64-linux-gnu/cmake/Qt5 (found suitable version "5.15.15", minimum required is "5.11.3")
   -- Performing Test CXX_SUPPORTS__WERROR
   -- Performing Test CXX_SUPPORTS__WERROR - Success
  ```

ACKs for top commit:
  fanquake:
    ACK 9e5089dbb0

Tree-SHA512: bb9baca64386772f2f4752b1cbff1230792562ca6b2e37c56ad28580b55b1ae6ff65c2cf0d8ab026111d7b5a056d7ac672496a3cfd1a81e4fdd2b84c8cf75fff
2024-11-06 12:11:39 +00:00
merge-script
80cb630bd9
Merge bitcoin/bitcoin#31216: Update secp256k1 subtree to v0.6.0
97235c446e build: Disable secp256k1 musig module (Ava Chow)
2d46a89386 Squashed 'src/secp256k1/' changes from 2f2ccc46954..0cdc758a563 (Ava Chow)

Pull request description:

  v0.6.0 was just released, main change is that it has the musig module which #29675 needs.

ACKs for top commit:
  hebasto:
    ACK 97235c446e, verified by updating the secp256k1 subtree locally.
  laanwj:
    ACK 97235c446e

Tree-SHA512: af92da26fc9afb55399b73d80198c0d2aa1adfae7b91f0ad20ffeb519135baf7e78243049b9bd45a2027943931b2d657c944f93151e5200d95a6f3c90b831f31
2024-11-06 11:15:23 +00:00
Ava Chow
97235c446e build: Disable secp256k1 musig module
The musig module is currently unused so disable it.
2024-11-05 15:08:49 -05:00
Hennadii Stepanov
30089b0cb6
cmake: Add FindQRencode module 2024-11-05 16:38:19 +00:00
marcofleon
fa327c77e3 util: Add ConsumeArithUInt256InRange fuzzing helper 2024-11-05 15:01:29 +00:00
Ryan Ofsky
03cff2c142
Merge bitcoin/bitcoin#31191: build: Make G_FUZZING constexpr, require -DBUILD_FOR_FUZZING=ON to fuzz
fafbf8acf4 Make G_FUZZING constexpr, require -DBUILD_FOR_FUZZING=ON to execute a fuzz target (MarcoFalke)
fae3cf0ffa ci: Temporarily disable macOS/Windows fuzz step (MarcoFalke)

Pull request description:

  `g_fuzzing` is used inside `Assume` at runtime, causing significant overhead in hot paths. See https://github.com/bitcoin/bitcoin/issues/31178

  One could simply remove the `g_fuzzing` check from the `Assume`, but this would make fuzzing a bit less useful. Also, it would be unclear if `g_fuzzing` adds a runtime overhead in other code paths today or in the future.

  Fix all issues by making `G_FUZZING` equal to the build option `BUILD_FOR_FUZZING`, and for consistency in fuzzing, require it to be set when executing any fuzz target.

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

  Temporarily this drops fuzzing from two CI tasks, but they can be re-added in a follow-up with something like https://github.com/bitcoin/bitcoin/pull/31073

ACKs for top commit:
  marcofleon:
    Tested ACK fafbf8acf4
  davidgumberg:
    I still ACK fafbf8acf4 for fixing the regression measured in #31178.
  ryanofsky:
    Code review ACK fafbf8acf4 but approach -0, because this approach means libraries built for fuzz testing do not function correctly if used in a release, and libraries built for releases are mostly useless for fuzz testing. So I would like to at least consider other solutions to this problem even if we go with this one.
  dergoegge:
    utACK fafbf8acf4

Tree-SHA512: 124fc2e8b35e0c4df414436556a7a0a36cd1bec4b3000b40dcf2ab8c85f32e0610bf7f70d2fd79223d62f3c3665b6c09da21241654c7b9859461b8ca340d5421
2024-11-05 06:05:27 -05:00
Ava Chow
05aebe3790
Merge bitcoin/bitcoin#30930: netinfo: add peer services column and outbound-only option
87532fe558 netinfo: allow setting an outbound-only peer list (Jon Atack)
681ebcceca netinfo: rename and hoist max level constant to use in top-level help (Jon Atack)
e7d307ce8c netinfo: clarify relaytxes and addr_relay_enabled help docs (Jon Atack)
eef2a9d406 netinfo: add peer services column (Jon Atack)

Pull request description:

  Been using this since May 2023.

  - add a peer services column (considered displaying the p2p_v2 flag as "p" or "2"; proposing "2" here for continuity with the "v" column, but "p" is fine for me as well)
  - clarify in the help that "relaytxes" and "addr_relay_enabled" are from getpeerinfo
  - hoist (and rename) the max level constant to use in top-level help, to avoid overlooking to update the top-level help if the value of the constant changes (as caught by Larry Ruane in review below)
  - add an optional "outonly" (or "o") argument for an outbound-only peer list, as suggested by Vasil Dimov in his review below. Several people have requested this, to keep the output within screen limits when running netinfo as a live dashboard (i.e. with `watch`) on a node with many peers. While doing this, also permit passing "h" for the help in addition to "help".

ACKs for top commit:
  achow101:
    ACK 87532fe558
  rkrux:
    tACK 87532fe558
  tdb3:
    cr re ACK 87532fe558
  brunoerg:
    crACK 87532fe558

Tree-SHA512: 35b1b0de28dfecaad58bf5af194757a5e0f563553cf69ea4d76f2e1963f8d662717254df2549114c7bba4a041bf5282d5cb3fba8d436b2807f2a00560787d64c
2024-11-04 15:50:59 -05:00
Ava Chow
0ba680d41b Update secp256k1 subtree to v0.6.0 2024-11-04 14:59:46 -05:00
Ava Chow
2d46a89386 Squashed 'src/secp256k1/' changes from 2f2ccc46954..0cdc758a563
0cdc758a563 Merge bitcoin-core/secp256k1#1631: release: prepare for 0.6.0
39d5dfd542a release: prepare for 0.6.0
df2eceb2790 build: add ellswift.md and musig.md to release tarball
a306bb7e903 tools: fix check-abi.sh after cmake out locations were changed
145868a84d2 Do not export `secp256k1_musig_nonce_gen_internal`
b161bffb8bf Merge bitcoin-core/secp256k1#1579: Clear sensitive memory without getting optimized out (revival of #636)
a38d879a1a6 Merge bitcoin-core/secp256k1#1628: Name public API structs
7d48f5ed02e Merge bitcoin-core/secp256k1#1581: test, ci: Lower default iteration count to 16
694342fdb71 Name public API structs
0f73caf7c62 test, ci: Lower default iteration count to 16
9a8db52f4e9 Merge bitcoin-core/secp256k1#1582: cmake, test: Add `secp256k1_` prefix to test names
765ef53335a Clear _gej instances after point multiplication to avoid potential leaks
349e6ab916b Introduce separate _clear functions for hash module
99cc9fd6d01 Don't rely on memset to set signed integers to 0
97c57f42ba8 Implement various _clear() functions with secp256k1_memclear()
9bb368d1466 Use secp256k1_memclear() to clear stack memory instead of memset()
e3497bbf001 Separate between clearing memory and setting to zero in tests
d79a6ccd43a Separate secp256k1_fe_set_int( . , 0 ) from secp256k1_fe_clear()
1c081262227 Add secp256k1_memclear() for clearing secret data
1464f15c812 Merge bitcoin-core/secp256k1#1625: util: Remove unused (u)int64_t formatting macros
980c08df80a util: Remove unused (u)int64_t formatting macros
9b7c59cbb90 Merge bitcoin-core/secp256k1#1624: ci: Update macOS image
096e3e23f63 ci: Update macOS image
e7d384488e8 Don't clear secrets in pippenger implementation
68b55209f1b Merge bitcoin-core/secp256k1#1619: musig: ctimetests: fix _declassify range for generated nonce points
f0868a9b3d8 Merge bitcoin-core/secp256k1#1595: build: 45839th attempt to fix symbol visibility on Windows
1fae76f50c0 Merge bitcoin-core/secp256k1#1620: Remove unused scratch space from API
8be3839fb2e Remove unused scratch space from API
57eda3ba300 musig: ctimetests: fix _declassify range for generated nonce points
87384f5c0f2 cmake, test: Add `secp256k1_` prefix to test names
e59158b6eb7 Merge bitcoin-core/secp256k1#1553: cmake: Set top-level target output locations
18f9b967c25 Merge bitcoin-core/secp256k1#1616: examples: do not retry generating seckey randomness in musig
5bab8f6d3c4 examples: make key generation doc consistent
e8908221a45 examples: do not retry generating seckey randomness in musig
70b6be1834e extrakeys: improve doc of keypair_create (don't suggest retry)
01b5893389e Merge bitcoin-core/secp256k1#1599: #1570 improve examples: remove key generation loop
cd4f84f3ba8 Improve examples/documentation: remove key generation loops
a88aa935063 Merge bitcoin-core/secp256k1#1603: f can never equal -m
3660fe5e2a9 Merge bitcoin-core/secp256k1#1479: Add module "musig" that implements MuSig2 multi-signatures (BIP 327)
168c92011f5 build: allow enabling the musig module in cmake
f411841a46b Add module "musig" that implements MuSig2 multi-signatures (BIP 327)
0be79660f38 util: add constant-time is_zero_array function
c8fbdb1b972 group: add ge_to_bytes_ext and ge_from_bytes_ext
ef7ff03407f f can never equal -m
c232486d84e Revert "cmake: Set `ENVIRONMENT` property for examples on Windows"
26e4a7c2146 cmake: Set top-level target output locations
4c57c7a5a95 Merge bitcoin-core/secp256k1#1554: cmake: Clean up testing code
447334cb06d include: Avoid visibility("default") on Windows
472faaa8ee6 Merge bitcoin-core/secp256k1#1604: doc: fix typos in `secp256k1_ecdsa_{recoverable_,}signature` API description
292310fbb24 doc: fix typos in `secp256k1_ecdsa_{recoverable_,}signature` API description
85e224dd97f group: add ge_to_bytes and ge_from_bytes
7c987ec89e6 cmake: Call `enable_testing()` unconditionally
6aa576515ef cmake: Delete `CTest` module

git-subtree-dir: src/secp256k1
git-subtree-split: 0cdc758a56360bf58a851fe91085a327ec97685a
2024-11-04 14:59:46 -05:00
laanwj
d22a234ed2 net: Use actual memory size in receive buffer accounting
Add a method CNetMessage::GetMemoryUsage and use this for accounting of
the size of the process receive queue instead of the raw message size.

This ensures that allocation and deserialization overhead is taken into
account.
2024-11-04 18:46:40 +01:00
laanwj
047b5e2af1 streams: add DataStream::GetMemoryUsage 2024-11-04 18:46:40 +01:00
laanwj
c3a6722f34 net: Use DynamicUsage(m_type) in CSerializedNetMsg::GetMemoryUsage
Now that memusage correctly computes the dynamic size of a string, there
is no need for special handling here.
2024-11-04 18:46:40 +01:00
laanwj
c6594c0b14 memusage: Add DynamicUsage for std::string
Add DynamicUsage(std::string) which Returns the dynamic allocation of a std::string,
or 0 if none (in case of small string optimization).
2024-11-04 18:46:40 +01:00
laanwj
7596282a55 memusage: Allow counting usage of vectors with different allocators 2024-11-04 17:04:08 +01:00
Lőrinc
42066f45ff Refactor SipHash_32b benchmark to improve accuracy and avoid optimization issues
- Modify `SipHash_32b` benchmark to use `FastRandomContext` for generating initial values.
- Cycle through and modify each byte of the `uint256` value to ensure no part of it can be optimized away.

The lack of "recursion" (where the method call overwrites the used inputs partially) and the systematic modification of each input byte makes the benchmark usage more reliable and thorough.
2024-11-03 12:36:49 +01:00
Ava Chow
975b115e1a
Merge bitcoin/bitcoin#31198: init: warn, don't error, when '-upnp' is set
a1b3ccae4b init: warn, don't error, when '-upnp' is set (Antoine Poinsot)

Pull request description:

  It prevented the GUI from starting when its settings.json had the -upnp option set. This also doesn't prevent the node from running, so this error didn't need to be fatal.

  Thanks to Sjors for bringing attention to what i broke and to Maflcko for suggesting a simple short term fix.

  Fixes https://github.com/bitcoin-core/gui/issues/843.

ACKs for top commit:
  maflcko:
    lgtm ACK a1b3ccae4b
  kevkevinpal:
    Concept ACK [a1b3cca](a1b3ccae4b)
  achow101:
    ACK a1b3ccae4b
  tdb3:
    ACK a1b3ccae4b

Tree-SHA512: ceb1513bf532698e5143d64430a065f39626ef0d2708103ffc8ab7f81e8393f488af2350c5a299bc80f966add82a3951b4d81ae8b0e3070c0d15c94e8db4badd
2024-11-01 17:15:26 -04:00
brunoerg
5a26cf7773 fuzz: fix implicit-integer-sign-change in wallet_create_transaction 2024-11-01 10:58:44 -03:00
Antoine Poinsot
a1b3ccae4b init: warn, don't error, when '-upnp' is set
It prevented the GUI from starting when its settings.json had the -upnp option set. This also doesn't
prevent the node from running, so this error didn't need to be fatal.

Thanks to Sjors for bringing attention to what i broke and to Maflcko for suggestion a simple short
term fix.
2024-10-31 14:05:50 -04:00
Greg Sanders
d47297c6aa rpc: Mark fullrbf and bip125-replaceable as deprecated 2024-10-31 13:19:31 -04:00
MarcoFalke
fafbf8acf4
Make G_FUZZING constexpr, require -DBUILD_FOR_FUZZING=ON to execute a fuzz target 2024-10-31 13:51:37 +01:00
glozow
8351562bec [fuzz] allow negative time jumps in txdownloadman_impl 2024-10-30 21:16:23 -04:00
glozow
917ab810d9 [doc] comment fixups from n30110 2024-10-30 21:13:01 -04:00
Ava Chow
f07a533dfc
Merge bitcoin/bitcoin#24214: Fix unsigned integer overflows in interpreter
bbbbaa0d9a Fix unsigned integer overflows in interpreter (MarcoFalke)

Pull request description:

  Unsigned integer overflow is well defined by the language and in some cases even useful or necessary. However, I think that it should be avoided in interpreter, as it makes the code harder to read and requires the whole file to be suppressed in the sanitizer. This puts more burden on reviewers to check that any changes to interpreter that involve unsigned integer overflow are sane.

  This patch involves a few changes:
  * Evaluate the addition in 64-bit "space". Previously, the first argument was `size_t` (unsigned, 32-bit or 64-bit, depending on platform) and the second was `int` (32-bit on all supported platforms). Thus the addition was done in 32-bit or 64-bit "unsigned space". Now the addition is done in 64-bit "signed space" on all platforms. This is safe because signed integer overflow (UB) isn't expected here with 64-bit integers.
  * Clarify that the value passed to the "stack macros" always fits in an `int64_t`. This is done with the C++11 syntax `int64_t{i}`, which fails to compile if `i` needs to be narrowed to fit into `int64_t`.
  * Explicitly convert the result of the addition to `size_t`. This isn't needed, because the called function already converts the value (see https://en.cppreference.com/w/cpp/container/vector/operator_at), however I have a slight preference for the explicit cast. (Happy to remove if reviewers prefer without)

  The patch does not change the bitcoind binary on my 64-bit system with `clang++ -O2`. However, it does change with gcc.

ACKs for top commit:
  achow101:
    ACK bbbbaa0d9a
  ismaelsadeeq:
    Code review ACK bbbbaa0d9a
  hebasto:
    ACK bbbbaa0d9a, I have reviewed the code and it looks OK.

Tree-SHA512: 0e9cbc6a0afd3db0d1d9489fd5e32ff856217604abde370add1f01c2cae8c526f2afedeb372997217c3a70ab0f8f56442e8230f87456f8e21c9abcb7c6578f7c
2024-10-30 17:37:39 -04:00
Ava Chow
4a31f8ccc9
Merge bitcoin/bitcoin#31156: test: Don't enforce BIP94 on regtest unless specified by arg
e60cecc811 doc: add release note for 31156 (Martin Zumsande)
fc7dfb3df5 test: Don't enforce BIP94 on regtest unless specified by arg (Martin Zumsande)

Pull request description:

  The added arg `-test=bip94` is only used in a functional test for BIP94. This is done because the default regtest consensus rules should follow mainnet, not testnet.

  Fixes #31137.

ACKs for top commit:
  achow101:
    ACK e60cecc811
  tdb3:
    cr and light test ACK e60cecc811
  rkrux:
    tACK e60cecc811
  BrandonOdiwuor:
    utACK e60cecc811
  laanwj:
    Code review ACK e60cecc811

Tree-SHA512: ca2f322f89d8808dfc3565fe020d2615cfcc110e188a02128ad7108fef51c735b33d55b5e6a70c505d78f7291f3c635dc7dfbcd78be1348d4d6e483883be4216
2024-10-30 17:00:14 -04:00
Ava Chow
02be3dced7
Merge bitcoin/bitcoin#31166: key: clear out secret data in DecodeExtKey
559a8dd9c0 key: clear out secret data in `DecodeExtKey` (Sebastian Falbesoner)

Pull request description:

  Same as in `DecodeSecret`, we should also clear out the secret data from the vector resulting from the Base58Check parsing for xprv keys. Note that the if condition is needed in order to avoid UB, see #14242 (commit d855e4cac8).

ACKs for top commit:
  davidgumberg:
    utACK 559a8dd9c0
  achow101:
    ACK 559a8dd9c0
  tdb3:
    cr ACK 559a8dd9c0
  laanwj:
    Code review ACK 559a8dd9c0

Tree-SHA512: c22499fe2899a9a5a58159ec55e94cf961570d8af06358d4a6d1943d567be9b88657af90d060d3083985ea957886a4f91bb762a2fcf3311007e7a535b42b0fde
2024-10-30 16:51:11 -04:00
willcl-ark
47f50c7af5
doc: add bitcoin-qt man description 2024-10-30 10:18:43 +00:00
willcl-ark
40b82e3ab0
doc: add bitcoin-util man description 2024-10-30 10:18:41 +00:00
willcl-ark
a7bf80f3a2
doc: add bitcoin-tx man description 2024-10-30 10:18:40 +00:00
willcl-ark
3f9a516832
doc: add bitcoin-wallet man description 2024-10-30 10:18:39 +00:00
willcl-ark
d8c0bb23ef
doc: add bitcoin-cli man description 2024-10-30 10:18:37 +00:00
willcl-ark
09abccfa77
doc: add bitcoind man description 2024-10-30 10:18:36 +00:00
Ava Chow
6b73eb9a1a
Merge bitcoin/bitcoin#31064: init: Correct coins db cache size setting
3a4a788ee0 init: Correct coins db cache size setting (TheCharlatan)

Pull request description:

  The chainstate caches are currently re-balanced on startup even in the non-assumeutxo case, leading to the database being needlessly re-opened and its cache re-allocated.

  Similar to `InitCoinsCache` and `m_coinstip_cache_size_bytes`, the `m_coinsdb_cache_size_bytes` should be set in `InitCoinsDB`.

  Together with only conservatively setting the cache values when a assumeutxo chainstate is present, this allows for skipping the cache re-balance during initialization in the normal non-assumeutxo case.

  Before:
  ```
  2024-10-09T21:22:17Z Checking all blk files are present...
  2024-10-09T21:22:17Z Initializing chainstate Chainstate [ibd] @ height -1 (null)
  2024-10-09T21:22:17Z Opening LevelDB in /home/drgrid/.bitcoin/signet/chainstate
  2024-10-09T21:22:17Z Opened LevelDB successfully
  2024-10-09T21:22:17Z Using obfuscation key for /home/drgrid/.bitcoin/signet/chainstate: b0a6f4e95fd05c92
  2024-10-09T21:22:17Z Loaded best chain: hashBestChain=0000000e119967d4937dad58456885ae43fb1761db686947e2f8e168c9a39a4f height=216852 date=2024-10-09T21:06:16Z progress=0.999989
  2024-10-09T21:22:17Z Opening LevelDB in /home/drgrid/.bitcoin/signet/chainstate
  2024-10-09T21:22:17Z Opened LevelDB successfully
  2024-10-09T21:22:17Z Using obfuscation key for /home/drgrid/.bitcoin/signet/chainstate: b0a6f4e95fd05c92
  2024-10-09T21:22:17Z [Chainstate [ibd] @ height 216852 (0000000e119967d4937dad58456885ae43fb1761db686947e2f8e168c9a39a4f)] resized coinsdb cache to 8.0 MiB
  2024-10-09T21:22:17Z [Chainstate [ibd] @ height 216852 (0000000e119967d4937dad58456885ae43fb1761db686947e2f8e168c9a39a4f)] resized coinstip cache to 440.0 MiB
  2024-10-09T21:22:17Z init message: Verifying blocks…
  ```

  After:
  ```
  2024-10-09T21:21:37Z Checking all blk files are present...
  2024-10-09T21:21:37Z Initializing chainstate Chainstate [ibd] @ height -1 (null)
  2024-10-09T21:21:37Z Opening LevelDB in /home/drgrid/.bitcoin/signet/chainstate
  2024-10-09T21:21:37Z Opened LevelDB successfully
  2024-10-09T21:21:37Z Using obfuscation key for /home/drgrid/.bitcoin/signet/chainstate: b0a6f4e95fd05c92
  2024-10-09T21:21:37Z Loaded best chain: hashBestChain=0000012c12b48011a7d9150ce96ed6a44bbf32b09eeecaff4a667789dda2a566 height=216850 date=2024-10-09T20:37:05Z progress=0.999971
  2024-10-09T21:21:37Z init message: Verifying blocks…
  ```

  The change may also be verified by looking at the `feature_assumeutxo.py` functional test debug logs.

ACKs for top commit:
  fjahr:
    utACK 3a4a788ee0
  achow101:
    ACK 3a4a788ee0
  laanwj:
    Code review ACK 3a4a788ee0
  BrandonOdiwuor:
    Code Review ACK 3a4a788ee0

Tree-SHA512: 87878d0d196bb426370d4b4bd180ca52a34017a0799ecea651c2532461fd2927b0f7cc8182276a7d9bb1fe0ede7d0ad677e3714ca22f321917d711c643acc578
2024-10-29 15:12:41 -04:00
Ava Chow
27d12cf17f
Merge bitcoin/bitcoin#31043: rpc: getorphantxs follow-up
0ea84bc362 test: explicitly check boolean verbosity is disallowed (tdb3)
7a2e6b68cd doc: add rpc guidance for boolean verbosity avoidance (tdb3)
698f302df8 rpc: disallow boolean verbosity in getorphantxs (tdb3)
63f5e6ec79 test: add entry and expiration time checks (tdb3)
808a708107 rpc: add entry time to getorphantxs (tdb3)
56bf302714 refactor: rename rpc_getorphantxs to rpc_orphans (tdb3)
7824f6b077 test: check that getorphantxs is hidden (tdb3)
ac68fcca70 rpc: disallow undefined verbosity in getorphantxs (tdb3)

Pull request description:

  Implements follow-up suggestions from #30793.

  - Now disallows undefined verbosity levels (below and above valid values) (https://github.com/bitcoin/bitcoin/pull/30793#discussion_r1786093549)
  - Disallows boolean verbosity (https://github.com/bitcoin/bitcoin/pull/30793#discussion_r1788273274) and adds guidance to developer-notes
  - Checks that `getorphantxs` is a hidden rpc (https://github.com/bitcoin/bitcoin/pull/30793#discussion_r1786107786)
  - Adds a test for `expiration` time
  - Adds `entry` time to the returned orphan objects (verbosity >=1) to relieve the user from having to calculate it from `expiration`.  Also adds associated test. (https://github.com/bitcoin/bitcoin/pull/30793#discussion_r1743687732)
  - Minor cleanup (blank line removal and log message move) (https://github.com/bitcoin/bitcoin/pull/30793#discussion_r1786092641)

  Included a commit to rename the test to a more generic `get_orphans` to better accommodate future orphanage-related RPCs (e.g. `getorphanangeinfo`).  Can drop the refactor commit from this PR if people feel strongly about it.

ACKs for top commit:
  achow101:
    ACK 0ea84bc362
  glozow:
    utACK 0ea84bc362
  rkrux:
    tACK 0ea84bc362
  itornaza:
    tACK 0ea84bc362

Tree-SHA512: e48a088f333ebde132923072da58e970461e74362d0acebbc799c3043d5727cdf5f28e82b43cb38bbed27c603df6710695dba91ff0695e623ad168e985dce08e
2024-10-29 14:49:19 -04:00
Ava Chow
7b66815b16
Merge bitcoin/bitcoin#30110: refactor: TxDownloadManager + fuzzing
0f4bc63585 [fuzz] txdownloadman and txdownload_impl (glozow)
699643f23a [unit test] MempoolRejectedTx (glozow)
fa584cbe72 [p2p] add TxDownloadOptions bool to make TxRequestTracker deterministic (glozow)
f803c8ce8d [p2p] filter 1p1c for child txid in recent rejects (glozow)
5269d57e6d [p2p] don't process orphan if in recent rejects (glozow)
2266eba43a [p2p] don't find 1p1cs for reconsiderable txns that are AlreadyHaveTx (glozow)
fa7027d0fc [refactor] add CheckIsEmpty and GetOrphanTransactions, remove access to TxDownloadMan internals (glozow)
969b07237b [refactor] wrap {Have,Get}TxToReconsider in txdownload (glozow)
f150fb94e7 [refactor] make AlreadyHaveTx and Find1P1CPackage private to TxDownloadImpl (glozow)
1e08195135 [refactor] move new tx logic to txdownload (glozow)
257568eab5 [refactor] move invalid package processing to TxDownload (glozow)
c4ce0c1218 [refactor] move invalid tx processing to TxDownload (glozow)
c6b21749ca [refactor] move valid tx processing to TxDownload (glozow)
a8cf3b6e84 [refactor] move Find1P1CPackage to txdownload (glozow)
f497414ce7 [refactor] put peerman tasks at the end of ProcessInvalidTx (glozow)
6797bc42a7 [p2p] restrict RecursiveDynamicUsage of orphans added to vExtraTxnForCompact (glozow)
798cc8f5aa [refactor] move Find1P1CPackage into ProcessInvalidTx (glozow)
416fbc952b [refactor] move new orphan handling to ProcessInvalidTx (glozow)
c8e67b9169 [refactor] move ProcessInvalidTx and ProcessValidTx definitions down (glozow)
3a41926d1b [refactor] move notfound processing to txdownload (glozow)
042a97ce7f [refactor] move tx inv/getdata handling to txdownload (glozow)
58e09f244b [p2p] don't log tx invs when in IBD (glozow)
288865338f [refactor] rename maybe_add_extra_compact_tx to first_time_failure (glozow)
f48d36cd97 [refactor] move peer (dis)connection logic to TxDownload (glozow)
f61d9e4b4b [refactor] move AlreadyHaveTx to TxDownload (glozow)
84e4ef843d [txdownload] add read-only reference to mempool (glozow)
af918349de [refactor] move ValidationInterface functions to TxDownloadManager (glozow)
f6c860efb1 [doc] fix typo in m_lazy_recent_confirmed_transactions doc (glozow)
5f9004e155 [refactor] add TxDownloadManager wrapping TxOrphanage, TxRequestTracker, and bloom filters (glozow)

Pull request description:

  Part of #27463.

  This PR does 3 things:

  (1) It modularizes transaction download logic into a `TxDownloadManager`. Transaction download logic refers to the process of deciding what transactions to request, download, and validate.[1] There should be no behavior changes. Using `--color_moved=dimmed_zebra -w` may help.
  (2) It adds unit and fuzz (🪄) testing for transaction download.
  (3) It makes a few small behavioral changes:
  - Stop (debug-only) logging tx invs during IBD
  - Just like all other transactions, require orphans have RecursiveDynamicUsage < 100k before adding to vExtraTxnForCompact
  - Don't return a 1p1c that contains a parent or child in recent rejects. Don't process any orphan already in recent rejects. These cases should not happen in actual node operation; it's just to allow tighter sanity checks during fuzzing.

  There are several benefits to this interface, such as:
  - Unit test coverage and fuzzing for logic that currently isn't feasible to test as thoroughly (without lots of overhead) and/or currently only lightly tested through `assert_debug_log` (not good) in functional tests.
  - When we add more functionality (e.g. package relay messages, more robust orphan handling), the vast majority of it will be within `TxDownloadManager` instead of `PeerManager`, making it easier to review and test. See #28031 for what this looks like.
  - `PeerManager` will no longer know anything about / have access to `TxOrphanage`, `TxRequestTracker` or the rejection caches. Its primary interface with `TxDownloadManager` would be much simpler:
      - Passing on  `ValidationInterface` callbacks
      - Telling `txdownloadman` when a peer {connects, disconnects}
      - Telling `txdownloadman`when a {transaction, package} is {accepted, rejected} from mempool
      - Telling `txdownloadman` when invs, notfounds, and txs are received.
      - Getting instructions on what to download.
      - Getting instructions on what {transactions, packages, orphans} to validate.
      - Get whether a peer `HaveMoreWork` for the `ProessMessages` loop
  - (todo) Thread-safety can be handled internally.

  [1]: This module is concerned with tx *download*, not upload. It excludes transaction announcements/gossip which happens after we download/accept a transaction. Txreconciliation (erlay) is excluded from this module, as it only relates to deciding which `inv`s to send or helping the other peer decide which `inv`s to send. It is independent from this logic.

ACKs for top commit:
  achow101:
    light ACK 0f4bc63585
  theStack:
    ACK 0f4bc63585
  instagibbs:
    reACK 0f4bc63585
  naumenkogs:
    ACK 0f4bc63585

Tree-SHA512: 84ab8ef8a0fc705eb829d7f7d6885f28944aaa42b03172f256a42605677b3e783919bb900d4e3b8589f85a0c387dfbd972bcd61d252d44a88c6aaa90e4bf920f
2024-10-29 14:41:12 -04:00
merge-script
dc97e7f6db
Merge bitcoin/bitcoin#30903: cmake: Add FindZeroMQ module
915640e191 depends: zeromq: don't install .pc files and remove patches for them (Cory Fields)
6b8a74463b cmake: Add `FindZeroMQ` module (Hennadii Stepanov)

Pull request description:

  This PR introduces the `FindZeroMQ` module, which first attempts to find the `libzmq` library using CMake's `find_package()` and falls back to `pkg_check_modules()` if unsuccessful.

  Addresses https://github.com/bitcoin/bitcoin/issues/30876 for the ZeroMQ package.

ACKs for top commit:
  fanquake:
    ACK 915640e191

Tree-SHA512: 2f17bae21be5d3f280a13425d22f5d1b2e23837a8aaf5ec89c433767509de030a42d598b261e102bdb5b860d8ede98013c124c3d25e081e956d4ee3a81b2584f
2024-10-29 16:21:07 +00:00
Ryan Ofsky
fe39acf88f tinyformat: Add compile-time checking for literal format strings
Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
2024-10-28 19:13:46 -04:00
Ryan Ofsky
184f34f2d0 util: Support dynamic width & precision in ConstevalFormatString
This is needed in the next commit to add compile-time checking to strprintf
calls, because bitcoin-cli.cpp uses dynamic width in many format strings.

This change is easiest to review ignoring whitespace.

Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
Co-authored-by: l0rinc <pap.lorinc@gmail.com>
2024-10-28 19:11:16 -04:00
Greg Sanders
111a23d9b3 Remove -mempoolfullrbf option 2024-10-28 11:53:20 -04:00
Martin Zumsande
fc7dfb3df5 test: Don't enforce BIP94 on regtest unless specified by arg
The added regtest option -test=bip94 is only used in the functional
test for BIP94.
This is done because the default regtest consensus rules
should aim to follow to mainnet, not testnet.
2024-10-28 11:38:38 -04:00
0xb10c
411c6cfc6c
tracing: only prepare tracepoint args if attached
Before this commit, we would always prepare tracepoint arguments
regardless of the tracepoint being used or not. While we already made
sure not to include expensive arguments in our tracepoints, this
commit introduces gating to make sure the arguments are only prepared
if the tracepoints are actually used. This is a win-win improvement
to our tracing framework. For users not interested in tracing, the
overhead is reduced to a cheap 'greater than 0' compare. As the
semaphore-gating technique used here is available in bpftrace, bcc,
and libbpf, users interested in tracing don't have to change their
tracing scripts while profiting from potential future tracepoints
passing slightly more expensive arguments. An example are mempool
tracepoints that pass serialized transactions. We've avoided the
serialization in the past as it was too expensive.

Under the hood, the semaphore-gating works by placing a 2-byte
semaphore in the '.probes' ELF section. The address of the semaphore
is contained in the ELF note providing the tracepoint information
(`readelf -n ./src/bitcoind | grep NT_STAPSDT`). Tracing toolkits
like bpftrace, bcc, and libbpf increase the semaphore at the address
upon attaching to the tracepoint. We only prepare the arguments and
reach the tracepoint if the semaphore is greater than zero. The
semaphore is decreased when detaching from the tracepoint.

This also extends the "Adding a new tracepoint" documentation to
include information about the semaphores and updated step-by-step
instructions on how to add a new tracepoint.
2024-10-28 14:27:47 +01:00
0xb10c
d524c1ec06
tracing: dedup TRACE macros & rename to TRACEPOINT
This deduplicates the TRACEx macros by using systemtaps STAP_PROBEV[0]
variadic macro instead of the DTrace compability DTRACE_PROBE[1] macros.
Bitcoin Core never had DTrace tracepoints, so we don't need to use the
drop-in replacement for it. As noted in pr25541[2], these macros aren't
compatibile with DTrace on macOS anyway.

This also renames the TRACEx macro to TRACEPOINT to clarify what the
macro does: inserting a tracepoint vs tracing (logging) something.

[0]: https://sourceware.org/git/?p=systemtap.git;a=blob;f=includes/sys/sdt.h;h=24d5e01c37805e55c36f7202e5d4e821b85167a1;hb=ecab2afea46099b4e7dfd551462689224afdbe3a#l407
[1]: https://sourceware.org/git/?p=systemtap.git;a=blob;f=includes/sys/sdt.h;h=24d5e01c37805e55c36f7202e5d4e821b85167a1;hb=ecab2afea46099b4e7dfd551462689224afdbe3a#l490
[2]: https://github.com/bitcoin/bitcoin/pull/25541/files#diff-553886c5f808e01e3452c7b21e879cc355da388ef7680bf310f6acb926d43266R30-R31

Co-authored-by: Martin Leitner-Ankerl <martin.ankerl@gmail.com>
2024-10-28 14:23:47 +01:00
Hennadii Stepanov
70713303b6
scripted-diff: Rename PACKAGE_* variables to CLIENT_*
This change ensures consistent use of the `CLIENT_` namespace everywhere
in the repository.

-BEGIN VERIFY SCRIPT-

ren() { sed -i "s/\<$1\>/$2/g" $( git grep -l "$1" ./cmake ./src :\(exclude\)./src/secp256k1 ./test ) ; }

ren PACKAGE_NAME      CLIENT_NAME
ren PACKAGE_VERSION   CLIENT_VERSION_STRING
ren PACKAGE_URL       CLIENT_URL
ren PACKAGE_BUGREPORT CLIENT_BUGREPORT

-END VERIFY SCRIPT-
2024-10-28 12:36:19 +00:00
Hennadii Stepanov
e6e29e3c94
scripted-diff: Clarify "user agent" variable name
This change allows to the use of the `CLIENT_` namespace without
potential name clashes.

-BEGIN VERIFY SCRIPT-
sed -i "s/\<CLIENT_NAME\>/UA_NAME/g" $( git grep -l "CLIENT_NAME" ./src)
-END VERIFY SCRIPT-
2024-10-28 12:35:49 +00:00
merge-script
1c7ca6e64d
Merge bitcoin/bitcoin#31093: Introduce g_fuzzing global for fuzzing checks
9f243cd7fa Introduce `g_fuzzing` global for fuzzing checks (dergoegge)

Pull request description:

  This PR introduces a global `g_fuzzing` that indicates if we are fuzzing.

  If `g_fuzzing` is `true` then:

  * Assume checks are enabled
  * Special fuzzing paths are taken (e.g. pow check is reduced to one bit)

  Closes #30950 #31057

ACKs for top commit:
  maflcko:
    review ACK 9f243cd7fa 🗜
  brunoerg:
    crACK 9f243cd7fa
  marcofleon:
    Tested ACK 9f243cd7fa

Tree-SHA512: 56e4cad0555dec0c565ea5ecc529628ee4f37d20dc660c647fdc6948fbeed8291e6fe290de514bd4c2c7089654d9ce1add607dc9855462828b62be9ee45e4999
2024-10-28 11:05:50 +00:00
merge-script
6e21dedbf2
Merge bitcoin/bitcoin#31130: Drop miniupnp dependency
40e5f26a3f mapport: remove dead code in DispatchMapPort (Antoine Poinsot)
38fdf7c1fb mapport: drop outdated comments (Antoine Poinsot)
b7b2435290 doc: add release note for #31130 (Antoine Poinsot)
1b6dec98da depends: drop miniupnpc (Antoine Poinsot)
953533d021 doc: remove mentions of UPnP (Antoine Poinsot)
94ad614482 ci: remove UPnP options (Antoine Poinsot)
a9598e5eaa build: drop miniupnpc dependency (Antoine Poinsot)
a5fcfb7385 interfaces: remove now unused 'use_upnp' arg from 'mapPort' (Antoine Poinsot)
038bbe7b20 daemon: remove UPnP support (Antoine Poinsot)
844770b05e qt: remove UPnP settings (Antoine Poinsot)

Pull request description:

  This PR removes UPnP IGD support and drops our [miniupnp](https://github.com/miniupnp/miniupnp) dependency.

  Miniupnpc is a C library (somewhat) maintained by a single person which had several vulnerabilities in the past (a couple dozens are listed [here](https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=miniupnp)), some of which directly affected our software ([RCE in 2015](https://bitcoincore.org/en/2024/07/03/disclose_upnp_rce/), [OOM in 2020](https://bitcoincore.org/en/2024/07/31/disclose-upnp-oom/)).

  The main purpose of this functionality is to have more (non-data-center) reachable nodes on the network. For a non-technical user running Bitcoin Core at home, the software would automatically open a port on their router to receive incoming connections. This way, users not able to manually open a port on their router would still provide the network with more resources and enhance its diversity.

  However, due to past vulnerabilities (and a worry about unknown future ones) in miniupnpc this feature was disabled by default in https://github.com/bitcoin/bitcoin/pull/6795. Having it disabled by default kills (most of?) the purpose of having this functionality in the first place: someone technical enough to understand the `-upnp` startup option or the "enable UPnP" setting is most likely able to open a port on his box in the first place.

  In addition, laanwj implemented PCP with a NAT-PMP fallback directly in Bitcoin Core in https://github.com/bitcoin/bitcoin/pull/30043. If we ever want to re-enable automatic NAT traversal by default in Bitcoin Core, this is the best option (and in my opinion the only sane one). The NAT-PMP fallback makes it so compatibility shouldn't be (much of) an issue.

  On balance, i believe that keeping this functionality and this barely maintained C dependency has higher costs than benefits. Therefore i propose that we get rid of it.

ACKs for top commit:
  jarolrod:
    ACK 40e5f26a3f
  1440000bytes:
    Code Review ACK 40e5f26a3f
  laanwj:
    Code review ACK 40e5f26a3f
  i-am-yuvi:
    Tested ACK 40e5f26a3f

Tree-SHA512: 9ea48662775510f5ec6de7af65790f7c8d211603398e9d8c634a86387be81b28081419a95b4d6680d3d7fe6a9f16cec99f16516548201dc7e49781909899a657
2024-10-28 10:47:34 +00:00
Sebastian Falbesoner
559a8dd9c0 key: clear out secret data in DecodeExtKey
Same as in `DecodeSecret`, we should also clear out the secret data from
the vector resulting from the Base58Check parsing for xprv keys. Note
that the if condition is needed in order to avoid UB, see #14242 (commit
d855e4cac8).
2024-10-27 15:38:54 +01:00
Sebastian Falbesoner
4120c7543e scripted-diff: get rid of remaining "command" terminology in protocol.{h,cpp}
-BEGIN VERIFY SCRIPT-
sed -i s/COMMAND_SIZE/MESSAGE_TYPE_SIZE/g $(git grep -l COMMAND_SIZE)
sed -i s/pszCommand/msg_type/g $(git grep -l pszCommand)
sed -i s/pchCommand/m_msg_type/g $(git grep -l pchCommand)
sed -i s/GetCommand/GetMessageType/g ./src/net.cpp ./src/protocol.cpp ./src/protocol.h ./src/test/fuzz/protocol.cpp
sed -i s/IsCommandValid/IsMessageTypeValid/g $(git grep -l IsCommandValid)
sed -i "s/command/message type/g" ./src/protocol.h ./src/protocol.cpp
-END VERIFY SCRIPT-
2024-10-26 23:44:15 +02:00
tdb3
698f302df8
rpc: disallow boolean verbosity in getorphantxs
Updates ParseVerbosity() to support disallowing
boolean verbosity.  Removes boolean verbosity
for getorphantxs to encourage integer verbosity
usage
2024-10-25 17:53:48 -04:00
tdb3
808a708107
rpc: add entry time to getorphantxs 2024-10-25 17:11:26 -04:00
tdb3
ac68fcca70
rpc: disallow undefined verbosity in getorphantxs 2024-10-25 17:06:12 -04:00
Antoine Poinsot
40e5f26a3f
mapport: remove dead code in DispatchMapPort
Since there is now only two options in the MapPortProtoFlag enum, the
four possible combinations of current and enabled are already covered in
the four `if` branches.
2024-10-25 15:02:07 -04:00
Antoine Poinsot
38fdf7c1fb
mapport: drop outdated comments 2024-10-25 14:39:03 -04:00
Hennadii Stepanov
6b8a74463b
cmake: Add FindZeroMQ module 2024-10-25 18:09:36 +01:00
merge-script
9a7206a34e
Merge bitcoin/bitcoin#29536: fuzz: fuzz connman with non-empty addrman + ASMap
552cae243a fuzz: cover `ASMapHealthCheck` in connman target (brunoerg)
33b0f3ae96 fuzz: use `ConsumeNetGroupManager` in connman target (brunoerg)
18c8a0945b fuzz: move `ConsumeNetGroupManager` to util (brunoerg)
fe624631ae fuzz: fuzz `connman` with a non-empty addrman (brunoerg)
0a12cff2a8 fuzz: move `AddrManDeterministic` to util (brunoerg)

Pull request description:

  ### Motivation

  Currently, we fuzz connman with an addrman from `NodeContext`. However,
  fuzzing connman with only empty addrman might not be effective, especially
  for functions like `GetAddresses` and other ones that plays with addrman. Also,
  we do not fuzz connman with ASMap, what would be good for functions that need
  `GetGroup`, or even for addrman. Without it, I do not see how effective would be
   fuzzing `ASMapHealthCheck`, for example.

  ### Changes

  - Move `AddrManDeterministic` and `ConsumeNetGroupManager` to util.
  - Use `ConsumeNetGroupManager` in connman target to construct a netgroupmanager
  and use it for `ConnmanTestMsg`.
  - Use `AddrManDeterministic` in connman target to create an addrman. It does
   not slow down as "filling" the addrman (e.g. with `FillAddrman`).
  - Add coverage for `ASMapHealthCheck`.

ACKs for top commit:
  maflcko:
    review ACK 552cae243a 🏀
  dergoegge:
    Code review ACK 552cae243a
  marcofleon:
    Code review ACK 552cae243a. Changes match the PR description.

Tree-SHA512: ba861c839602054077e4bf3649763eeb48357cda83ca3ddd32b02a1b61f4e44a0c5070182f001f9bf531d0d64717876279a7de3ddb9de028b343533b89233851
2024-10-25 15:18:54 +01:00
merge-script
d4abaf8c9d
Merge bitcoin/bitcoin#29608: optimization: Preallocate addresses in GetAddr based on nNodes
66082ca348 Preallocate addresses in GetAddr based on nNodes (Lőrinc)

Pull request description:

  The reserve method optimizes memory allocation by preallocating space for the expected number of elements (nNodes), reducing reallocations and improving performance. The upper bound ensures efficient memory usage based on the input constraints.

  before:
  ```
  |               ns/op |                op/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |           76,852.79 |           13,011.89 |    0.4% |      1.07 | `AddrManGetAddr`
  |           76,598.21 |           13,055.14 |    0.2% |      1.07 | `AddrManGetAddr`
  |           76,296.32 |           13,106.79 |    0.1% |      1.07 | `AddrManGetAddr`
  ```

  after:
  ```
  |               ns/op |                op/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |           65,966.97 |           15,159.10 |    0.3% |      1.07 | `AddrManGetAddr`
  |           66,075.40 |           15,134.23 |    0.2% |      1.06 | `AddrManGetAddr`
  |           66,306.34 |           15,081.51 |    0.3% |      1.06 | `AddrManGetAddr`
  ```

ACKs for top commit:
  stickies-v:
    ACK 66082ca348
  vasild:
    ACK 66082ca348

Tree-SHA512: 1175cff250d9c52ed042e8807ddc2afd64a806e6f2195b5c648752869ff3beec0be8a8cbd7ab6ba35cd7077d79b88a380da6c6e244f5549f98cdd472808b6d8f
2024-10-25 14:45:42 +01:00
Jon Atack
87532fe558 netinfo: allow setting an outbound-only peer list
by passing an additional argument of "outonly" or "o".

This has been requested in order to keep the output within screen limits when running -netinfo
as a live dashboard, i.e. with `watch`.

Also allow passing "h" in addition to "help" to see the help documentation.
2024-10-25 07:22:15 -06:00
dergoegge
9f243cd7fa Introduce g_fuzzing global for fuzzing checks 2024-10-25 13:12:55 +01:00
merge-script
b95adf057a
Merge bitcoin/bitcoin#31150: util: Treat Assume as Assert when evaluating at compile-time
fa69a5f4b7 util: Treat Assume as Assert when evaluating at compile-time (MarcoFalke)

Pull request description:

  There is no downside or cost of treating an `Assume` at compile-time as an `Assert` and it may even help to find bugs while compiling without `ABORT_ON_FAILED_ASSUME`.

  This is also required for https://github.com/bitcoin/bitcoin/pull/31093

ACKs for top commit:
  dergoegge:
    ACK fa69a5f4b7
  brunoerg:
    ACK fa69a5f4b7
  marcofleon:
    ACK fa69a5f4b7

Tree-SHA512: 17604403f841343a6d5b6e5d777e1760d38e0c27dc1fd4479e3741894fba40cdb1fb659cf24519a51d051bd5884a75992d1227ec9fa40fbf53bc619fbfb304ad
2024-10-25 13:10:19 +01:00
merge-script
8c12fe828d
Merge bitcoin/bitcoin#29936: fuzz: wallet: add target for CreateTransaction
c495731a31 fuzz: wallet: add target for `CreateTransaction` (brunoerg)
3db68e29ec wallet: move `ImportDescriptors`/`FuzzedWallet` to util (brunoerg)

Pull request description:

  This PR adds a fuzz target for the `CreateTransaction` function. It is a regression target for https://github.com/bitcoin/bitcoin/pull/27271 and can be testing by applying:
  ```diff
  @@ -1110,7 +1110,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
       // This can only happen if feerate is 0, and requested destinations are value of 0 (e.g. OP_RETURN)
       // and no pre-selected inputs. This will result in 0-input transaction, which is consensus-invalid anyways
       if (selection_target == 0 && !coin_control.HasSelected()) {
  -        return util::Error{_("Transaction requires one destination of non-0 value, a non-0 feerate, or a pre-selected input")};
  +       // return util::Error{_("Transaction requires one destination of non-0 value, a non-0 feerate, or a pre-selected input")};
       }
  ```

  Also, it moves `ImportDescriptors` function to `src/wallet/test/util.h` to avoid to duplicate same code.

ACKs for top commit:
  marcofleon:
    ACK c495731a31
  maflcko:
    ACK c495731a31 🏻

Tree-SHA512: a439f947b91b01e327e18cd18e63d5ce49f2cb9ca16ca9d56fe337b8cff239b3af4db18fe89478fe5faa5549d37ca935bd321913db7646fbf6818f825cb5d878
2024-10-25 09:17:31 +01:00
glozow
0f4bc63585 [fuzz] txdownloadman and txdownload_impl
The txdownload_impl is similar but allows us to check specific
invariants within its implementation. It will also change a lot more
than the external interface (txdownloadman) will, so we will add more to
this target later.
2024-10-24 21:23:56 -04:00
glozow
699643f23a [unit test] MempoolRejectedTx 2024-10-24 21:23:56 -04:00
glozow
fa584cbe72 [p2p] add TxDownloadOptions bool to make TxRequestTracker deterministic
Forward this bool to the TxRequestTracker ctor. This is needed for
stablity in TxDownloadManager fuzzers
2024-10-24 21:23:56 -04:00
glozow
f803c8ce8d [p2p] filter 1p1c for child txid in recent rejects
Avoid the fuzzer situation where:
1. Orphanage has 2 transactions with the same txid, one with witness,
   one without witness.
2. The transaction with witness is found to have
   `TX_INPUTS_NOT_STANDARD` error. The txid is added to recent rejects
filter, and the tx with witness is deleted from orphanage.
3. A low feerate parent is found. Find1P1CPackage finds the transaction
   with no witness in orphanage, and returns the package.
4. net_processing has just been handed a package in which the child is
   already in recent rejects.
2024-10-24 21:23:56 -04:00
glozow
5269d57e6d [p2p] don't process orphan if in recent rejects
This should never happen normally, but just in case.
2024-10-24 21:23:56 -04:00
glozow
2266eba43a [p2p] don't find 1p1cs for reconsiderable txns that are AlreadyHaveTx
This is a slight behavior change: if a transaction is in both
reconsiderable rejects and AlreadyHaveTx in another way, we don't try to
return a 1p1c package. This is the correct thing to do, as we don't want
to reconsider transactions that have multiple things wrong with them.
For example, if a transaction is low feerate, and then later found to
have a bad signature, we shouldn't try it again in a package.
2024-10-24 21:23:56 -04:00
glozow
fa7027d0fc [refactor] add CheckIsEmpty and GetOrphanTransactions, remove access to TxDownloadMan internals 2024-10-24 21:23:56 -04:00
glozow
969b07237b [refactor] wrap {Have,Get}TxToReconsider in txdownload 2024-10-24 21:23:56 -04:00
glozow
f150fb94e7 [refactor] make AlreadyHaveTx and Find1P1CPackage private to TxDownloadImpl 2024-10-24 21:23:56 -04:00
glozow
1e08195135 [refactor] move new tx logic to txdownload
Also delete external RecentRejectsReconsiderableFilter() access since it
is no longer necessary.
2024-10-24 21:23:56 -04:00
glozow
257568eab5 [refactor] move invalid package processing to TxDownload 2024-10-24 21:23:56 -04:00
glozow
c4ce0c1218 [refactor] move invalid tx processing to TxDownload
Move-only. Also delete external RecentRejectsFilter() access since it is
no longer necessary.
2024-10-24 21:23:56 -04:00
glozow
c6b21749ca [refactor] move valid tx processing to TxDownload 2024-10-24 21:23:56 -04:00
glozow
a8cf3b6e84 [refactor] move Find1P1CPackage to txdownload
Move-only.
2024-10-24 21:23:56 -04:00
glozow
f497414ce7 [refactor] put peerman tasks at the end of ProcessInvalidTx 2024-10-24 21:23:56 -04:00
glozow
6797bc42a7 [p2p] restrict RecursiveDynamicUsage of orphans added to vExtraTxnForCompact
There does not appear to be any reason why orphan transactions should be
given special treatment.
2024-10-24 21:23:56 -04:00
glozow
798cc8f5aa [refactor] move Find1P1CPackage into ProcessInvalidTx 2024-10-24 21:23:56 -04:00
glozow
416fbc952b [refactor] move new orphan handling to ProcessInvalidTx 2024-10-24 21:23:56 -04:00
glozow
c8e67b9169 [refactor] move ProcessInvalidTx and ProcessValidTx definitions down
ProcessInvalidTx will return a PackageToValidate, so it needs to be
defined afterward.
2024-10-24 21:23:56 -04:00
glozow
3a41926d1b [refactor] move notfound processing to txdownload 2024-10-24 21:23:56 -04:00
glozow
042a97ce7f [refactor] move tx inv/getdata handling to txdownload 2024-10-24 21:23:56 -04:00
glozow
58e09f244b [p2p] don't log tx invs when in IBD
These invs are ignored anyway, and this allows us to more easily move
the inv handling to TxDownloadManager in the next commit.
2024-10-24 21:23:56 -04:00
glozow
288865338f [refactor] rename maybe_add_extra_compact_tx to first_time_failure
The usage of this bool will increase in scope in the next commit.
For this commit, the value of this bool is accurate at each
ProcessInvalidTx callsite:
- ProcessOrphanTx -> this tx is an orphan i.e. has been rejected before
- ProcessPackageResult -> 1p1c only, each transaction is either an
  orphan or in m_lazy_recent_rejects_reconsiderable
- ProcessMessage -> tx was received over p2p and validated for the first
  time
2024-10-24 21:23:56 -04:00
glozow
f48d36cd97 [refactor] move peer (dis)connection logic to TxDownload
The information stored in TxDownloadConnectionInfo isn't used until the
next commit.
2024-10-24 21:23:56 -04:00
glozow
f61d9e4b4b [refactor] move AlreadyHaveTx to TxDownload
This is move-only.
Also delete external RecentConfirmedTransactionsFilter() access since it
is no longer necessary.
2024-10-24 21:23:56 -04:00
glozow
84e4ef843d [txdownload] add read-only reference to mempool
This will become necessary in later commits that query mempool. We also
introduce the TxDownloadOptions in this commit to make the later diff
easier to review.
2024-10-24 21:23:56 -04:00
glozow
af918349de [refactor] move ValidationInterface functions to TxDownloadManager
This is move-only.
2024-10-24 21:23:56 -04:00
glozow
f6c860efb1 [doc] fix typo in m_lazy_recent_confirmed_transactions doc 2024-10-24 21:23:56 -04:00
glozow
5f9004e155 [refactor] add TxDownloadManager wrapping TxOrphanage, TxRequestTracker, and bloom filters
This module is going to be responsible for managing everything related
to transaction download, including txrequest, orphan transactions and
package relay. It will be responsible for managing usage of the
TxOrphanage and instructing PeerManager:
- what tx or package-related messages to send to which peer
- whether a tx or package-related message is allowed or useful
- what transactions are available to try accepting to mempool

Future commits will consolidate the interface and re-delegate
interactions from PeerManager to TxDownloadManager.
2024-10-24 21:23:55 -04:00
Ava Chow
947f2925d5
Merge bitcoin/bitcoin#31124: util: Remove RandAddSeedPerfmon
9bb92c0e7f util: Remove RandAddSeedPerfmon (Hodlinator)

Pull request description:

  `RegQueryValueExA(HKEY_PERFORMANCE_DATA, ...)` sometimes hangs *bitcoind.exe* on Windows during startup, at least on CI.

  We have other sources of entropy to seed randomness with on Windows, so should be alright removing this. Might resurrect if less drastic fix is found.

  Hopefully sufficient to fix #30390.

  CI debugged with temporary Windows stack trace dumping + Symbols in #30956.

ACKs for top commit:
  achow101:
    ACK 9bb92c0e7f
  fanquake:
    ACK 9bb92c0e7f
  hebasto:
    ACK 9bb92c0e7f, I have reviewed the code and it looks OK.
  laanwj:
    Code review ACK  9bb92c0e7f

Tree-SHA512: d3f26b4dd0519ef957f23abaffc6be1fed339eae756aed18042422fc6f0bba4e8fa9a44bf903e54f72747e2d0108146c18fd80576d95fc20690a2daf9c83689d
2024-10-24 18:08:12 -04:00
Ava Chow
7640cfdd62
Merge bitcoin/bitcoin#31118: doc: replace -? with -h and -help
33a28e252a Change default help arg to `-help` and mention `-h` and `-?` as alternatives (Lőrinc)
f0130ab1a1 doc: replace `-?` with `-h` for bench_bitcoin help (Lőrinc)

Pull request description:

  The question mark is interpreted as a wildcard for any single character in Zsh (see https://www.techrepublic.com/article/globbing-wildcard-characters-with-zsh), so `bench_bitcoin -?` will not show the help message on systems using Zsh, such as macOS.

  Since `-h` provides equivalent help functionality (as defined in https://github.com/bitcoin/bitcoin/blob/master/src/common/args.cpp#L684-L693), the `benchmarking.md` documentation has been updated to ensure compatibility with macOS.

  ----

  ### -?
  > % cmake -B build -DBUILD_BENCH=ON && cmake --build build && build/src/bench/bench_bitcoin -?
  zsh: no matches found: -?

  ### -h
  > % cmake -B build -DBUILD_BENCH=ON && cmake --build build && build/src/bench/bench_bitcoin -h
  Usage:  bench_bitcoin [options]
  Options:
  ...

  ----

  Based on the comments the args help default was also changed to `-help`, mentioning `-h` and `-?` (instead of `-?` being the default)

ACKs for top commit:
  edilmedeiros:
    tACK 33a28e252a
  maflcko:
    lgtm ACK 33a28e252a
  achow101:
    ACK 33a28e252a
  rkrux:
    tACK 33a28e252a
  laanwj:
    Code review ACK 33a28e252a

Tree-SHA512: 8c6e27488462be9ba9186b34abe6249c1d93026b3963acc0f42c75496f39407563766ae518cf1839156039cc0047e29d91f70d191cfb97e0fbde85665e88c71e
2024-10-24 18:01:41 -04:00
Ava Chow
74fb19317a
Merge bitcoin/bitcoin#30849: refactor: migrate bool GetCoin to return optional<Coin>
4feaa28728 refactor: Rely on returned value of GetCoin instead of parameter (Lőrinc)
46dfbf169b refactor: Return optional of Coin in GetCoin (Lőrinc)
e31bfb26c2 refactor: Remove unrealistic simulation state (Lőrinc)

Pull request description:

  While reviewing [the removal of the unreachable combinations from the Coin cache logic](https://github.com/bitcoin/bitcoin/pull/30673#discussion_r1721727681), we've noticed that the related tests often [reflect impossible states](https://github.com/bitcoin/bitcoin/pull/30673/files#r1740154464).

  Browsing the Coin cache refactoring history revealed that migrating `bool GetCoin` to `optional<Coin> GetCoin` was [already proposed a few times before](https://github.com/bitcoin/bitcoin/pull/18746#issuecomment-842393167).

  This refactor makes certain invalid states impossible, reducing the possibility of errors and making the code easier to understand. This will let us remove test code that exercises the impossible states as well.
  The PR is done in multiple small steps, first swapping the new `optional` return value, slowly strangling out the usages of the return parameter, followed by the removal of the parameter.

  Most of the invalid test states were still kept, except for https://github.com/bitcoin/bitcoin/pull/30673/files#r1748087322, where the new design prohibits invalid usage and https://github.com/bitcoin/bitcoin/pull/30673/files#r1749350258 was just marked with a TODO, will be removed in a follow-up PR.

ACKs for top commit:
  andrewtoth:
    re-ACK 4feaa28728
  achow101:
    ACK 4feaa28728
  laanwj:
    Code review ACK 4feaa28728
  theStack:
    Code-review ACK 4feaa28728

Tree-SHA512: 818d60b2e97f58c489a61120fe761fb67a08dffbefe7a3fce712d362fc9eb8c2cced23074f1bec55fe71c616a3561b5a8737919ad6ffb2635467ec4711683df7
2024-10-24 13:52:47 -04:00
Ava Chow
c16e909b3e
Merge bitcoin/bitcoin#28574: wallet: optimize migration process, batch db transactions
c98fc36d09 wallet: migration, consolidate external wallets db writes (furszy)
7c9076a2d2 wallet: migration, consolidate main wallet db writes (furszy)
9ef20e86d7 wallet: provide WalletBatch to 'SetupDescriptorScriptPubKeyMans' (furszy)
34bf0795fc wallet: refactor ApplyMigrationData to return util::Result<void> (furszy)
aacaaaa0d3 wallet: provide WalletBatch to 'RemoveTxs' (furszy)
57249ff669 wallet: introduce active db txn listeners (furszy)
91e065ec17 wallet: remove post-migration signals connection (furszy)
055c0532fc wallet: provide WalletBatch to 'DeleteRecords' (furszy)
122d103ca2 wallet: introduce 'SetWalletFlagWithDB' (furszy)
6052c7891d wallet: decouple default descriptors creation from external signer setup (furszy)
f2541d09e1 wallet: batch MigrateToDescriptor() db transactions (furszy)
66c9936455 bench: add coverage for wallet migration process (furszy)

Pull request description:

  Last step in a chain of PRs (#26836, #28894, #28987, #29403).

  #### Detailed Description:
  The current wallet migration process performs only individual db writes. Accessing disk to
  delete all legacy records, clone and clean each address book entry for every created wallet,
  create each new descriptor (with their corresponding master key, caches and key pool), and
  also clone and delete each transaction that requires to be transferred to a different wallet.

  This work consolidates all individual disk writes into two batch operations. One for the descriptors
  creation from the legacy data and a second one for the execution of the migration process itself.
  Efficiently dumping all the information to disk at once atomically at the end of each process.

  This represent a speed up and also a consistency improvement. During migration, we either
  want to succeed or fail. No other outcomes should be accepted. We should never leave a
  partially migrated wallet on disk and request the user to manually restore the previous wallet from
  a backup (at least not if we can avoid it).

  Since the speedup depends on the storage device, benchmark results can vary significantly.
  Locally, I have seen a 15% speedup on a USB 3.2 pendrive.

  #### Note for Testers:
  The first commit introduces a benchmark for the migration process. This one can be
  cherry-picked on top of master to compare results pre and post changes.

  Please note that the benchmark setup may take some time (~70 seconds here) due to the absence
  of a batching mechanism for the address generation process (`GetNewDestination()` calls).

ACKs for top commit:
  achow101:
    ACK c98fc36d09
  theStack:
    re-ACK c98fc36d09
  pablomartin4btc:
    re-ACK c98fc36d09

Tree-SHA512: a52d5f2eef27811045d613637c0a9d0b7e180256ddc1c893749d98ba2882b570c45f28cc7263cadd4710f2c10db1bea33d88051f29c6b789bc6180c85b5fd8f6
2024-10-24 13:30:47 -04:00
Antoine Poinsot
a9598e5eaa
build: drop miniupnpc dependency 2024-10-24 18:23:31 +02:00
Antoine Poinsot
a5fcfb7385
interfaces: remove now unused 'use_upnp' arg from 'mapPort' 2024-10-24 18:23:30 +02:00
Antoine Poinsot
038bbe7b20
daemon: remove UPnP support
Keep the "-upnp" option as a hidden arg for one major version in order
to show a more user friendly error to people who had this option set in
their config file.
2024-10-24 18:23:30 +02:00
Antoine Poinsot
844770b05e
qt: remove UPnP settings 2024-10-24 18:23:29 +02:00
MarcoFalke
fa69a5f4b7
util: Treat Assume as Assert when evaluating at compile-time 2024-10-24 17:18:46 +02:00
merge-script
0c79c343a9
Merge bitcoin/bitcoin#31147: cmake, qt, test: Remove problematic code
fb46d57d4e cmake, qt, test: Remove problematic code (Hennadii Stepanov)

Pull request description:

  Split from https://github.com/bitcoin/bitcoin/pull/30997.

  The removed code aimed to make Qt's minimal integration plugin DLL available for `test_bitcoin-qt.exe` on Windows.

  However, there are two issues:
  1. The code is broken because the destination directory must end with a trailing slash (`/`).
  2. It is unnecessary because Qt's minimal integration plugin is not used on Windows. For more details, please refer to the following code:fb46d57d4e/src/qt/test/CMakeLists.txt (L38-L44)

  As a side effect, this PR fixes https://github.com/bitcoin-core/gui/issues/842.

ACKs for top commit:
  fanquake:
    ACK fb46d57d4e
  TheCharlatan:
    ACK fb46d57d4e

Tree-SHA512: b44d1c5e352e9bbfbba3c263ee03838cd490435da0490d9c8a152e60515520772c8a87aca08d4510f50c2e46b64ac92c666fa81accf43758af2e896693c44ffa
2024-10-24 14:56:29 +01:00
Lőrinc
6c6b2442ed build: Replace MAC_OSX macro with existing __APPLE__
Adopting `__APPLE__` aligns our project with broader industry practices, including those in prominent projects such as the Linux kernel (and even our own code).

See: https://sourceforge.net/p/predef/wiki/OperatingSystems/#macos
2024-10-24 12:29:26 +02:00
Hennadii Stepanov
fb46d57d4e
cmake, qt, test: Remove problematic code
The removed code aimed to make Qt's minimal integration plugin DLL
available for `test_bitcoin-qt.exe` on Windows.

However, there are two issues:
1. The code is broken because the destination directory must end with a
   trailing slash (`/`).
2. It is unnecessary because Qt's minimal integration plugin is not
   used on Windows. For more details, please refer to the following
   code.
2024-10-24 11:27:16 +01:00
merge-script
d94adc7270
Merge bitcoin/bitcoin#29702: fees: Remove CLIENT_VERSION serialization
fa1c5cc9df fees: Log non-fatal errors as [warning], instead of info-level (MarcoFalke)
ddddbac9c1 fees: Pin required version to 149900 (MarcoFalke)
fa5126adcb fees: Pin "version that wrote" to 0 (MarcoFalke)

Pull request description:

  Coupling the fees serialization with CLIENT_VERSION is problematic, because:

  * `CLIENT_VERSION` may change, even though the serialization format does not change. This is harmless, but still confusing.
  * If a serialization format change was backported (unlikely), it may lead to incorrect results.
  * `CLIENT_VERSION` is changed at a different time during the release process than any serialization format change. This is harmless for releases of Bitcoin Core, but may be confusing when using the development branch.
  * It is harder to reason about a global `CLIENT_VERSION` when changing the format, than to reason about a versioning local to the module.

  Fix all issues by pinning the current version number in the module locally. In the future it can then be modified locally to the module, if needed.

ACKs for top commit:
  hodlinator:
    re-ACK fa1c5cc9df
  TheCharlatan:
    Re-ACK fa1c5cc9df

Tree-SHA512: 93870176ed50cc5a734576d66398a6036b31632228a9e05db1fa5452229e35ba4126f003e7db246aeb9891764ed47bde4470c674ec2bce7fd3ddd97e43944627
2024-10-24 10:09:36 +01:00
merge-script
7290bc61c0
Merge bitcoin/bitcoin#31078: build: Fix kernel static lib component install
82e16e6983 cmake: Refactor install kernel dependencies (Hennadii Stepanov)
42e6277987 build: Add static libraries to Kernel install component (TheCharlatan)

Pull request description:

  Fixes the installation of the pkgconfig file and the static library when installing only the `Kernel` component.

  This is a followup to fix #30835 and #30814, which were merged shortly after one another, but are interrelated. Can be tested with:
  ```
  cmake -B build -DBUILD_SHARED_LIBS=OFF -DBUILD_KERNEL_LIB=ON
  cmake --build build --target bitcoinkernel
  cmake --install build --component Kernel
  ```

ACKs for top commit:
  hebasto:
    ACK 82e16e6983, tested on Ubuntu 23.10.
  fanquake:
    ACK 82e16e6983

Tree-SHA512: 07c18a341d4464e489c28fb262600338f1711248309ffb2af0ef3ab1abf06f10873c435895b63010e0be8e44af77046324896dfd872479792aa049831606dc45
2024-10-24 09:55:19 +01:00
Ava Chow
e9b95665ee
Merge bitcoin/bitcoin#31046: init: Some small chainstate load improvements
31cc5006c3 init: Return fatal failure on snapshot validation failure (Martin Zumsande)
8f1246e833 init: Improve chainstate init db error messages (TheCharlatan)
cd093049dd init: Remove incorrect comment about shutdown condition (MarcoFalke)
635e9f85d7 init: Remove misleading log line when user chooses not to retry (TheCharlatan)
720ce880a3 init: Improve comment describing chainstate load retry behaviour (Martin Zumsande)
baea842ff1 init: Remove unneeded argument for mempool_opts checks (stickies-v)

Pull request description:

  These are mostly followups from #30968, making the code, log lines, error messages, and comments more consistent.

  The last commit is an attempt at improving the error reporting when loading the chainstate. It aims to more cleanly distinguish between errors arising from a specific database, and errors where the culprit may be less clear.

ACKs for top commit:
  achow101:
    ACK 31cc5006c3
  mzumsande:
    Code Review / lightly tested ACK 31cc5006c3
  BrandonOdiwuor:
    Code Review ACK 31cc5006c3.
  stickies-v:
    ACK 31cc5006c3

Tree-SHA512: 59fba4845ee45a3d91bf55807ae6b1c81458463b96bf664c8b1badfac503f6b01efd52a915fc399294e68a3f69985362a5a10a3844fa23f7707145ebe9ad349b
2024-10-23 18:33:31 -04:00
MarcoFalke
fa1c5cc9df
fees: Log non-fatal errors as [warning], instead of info-level
Also, remove not needed and possibly redundant function name and class
names from the log string. Also, minimally reword the log messages.
Also, remove redundant trailing newlines from log messages, while
touching.
2024-10-23 18:43:32 +02:00
merge-script
28ce159bc3
Merge bitcoin/bitcoin#30183: rpc: net: follow-ups for #30062
a16917fb59 rpc, net: improve `mapped_as` doc for getrawaddrman/getpeerinfo (brunoerg)
bdad0243be rpc, net: getrawaddrman "mapped_as" follow-ups (brunoerg)

Pull request description:

  - Change `addrman` to reference to const since it isn't modified (https://github.com/bitcoin/bitcoin/pull/30062#discussion_r1612272793).
  - Improve documentation of `mapped_as`/`source_mapped_as` in `getrawaddrman` RPC by mentioning that both fields will be only available if asmap flag is set. It is the same message for `mapped_as` field in `getpeerinfo`.

ACKs for top commit:
  fjahr:
    re-ACK a16917fb59
  0xB10C:
    re-ACK a16917fb59
  laanwj:
    re-ACK  a16917fb59

Tree-SHA512: c66b2ee9d24da93d443be83f6ef3b2d39fd5bf3f73e2974574cad238ffb82035704cf4fbf1bac22a63734948e285e8e091c2884bb640202efdb473315e770233
2024-10-22 09:49:57 +01:00
Hodlinator
9bb92c0e7f
util: Remove RandAddSeedPerfmon
RegQueryValueExA(HKEY_PERFORMANCE_DATA, ...) sometimes hangs bitcoind.exe on Windows during startup, at least on CI.

We have other sources of entropy to seed randomness with on Windows, so should be alright removing this. Might resurrect if less drastic fix is found.
2024-10-21 23:24:17 +02:00
merge-script
684873931b
Merge bitcoin/bitcoin#26334: Add Signet and testnet4 launch shortcuts for Windows
cfd03de965 Add Testnet4 launch shortcut for Windows (Sjors Provoost)
77b2923f87 Add Signet launch shortcut for Windows (Sjors Provoost)

Pull request description:

  This makes it easier to launch Signet and testnet4 on Windows. Follows the same pattern as testnet.

  Before:

  <img width="766" alt="testnet" src="https://user-images.githubusercontent.com/10217/196468934-ee29d129-871b-4612-bde4-842f191403a7.png">

  After:
  <img width="500" alt="signet1" src="https://user-images.githubusercontent.com/10217/220358057-d9efc532-272c-45e7-81fa-3a52f58a0f29.png">
  <img width="527" alt="signet2" src="https://user-images.githubusercontent.com/10217/220358067-62b3b76f-604a-4163-9d35-c903fff29df0.png">

  (the testnet4 icon is the same as testnet3, not in the above screenshot)

ACKs for top commit:
  achow101:
    ACK cfd03de965
  laanwj:
    ACK cfd03de965
  TheCharlatan:
    ACK cfd03de965

Tree-SHA512: 9a43ab55b341cacbfc4e891bf192946ee808f776c622906a2e5628e2b59cb3dd87b089dc3a8d08717d01ff136063ed35f3049d516c7f477047f8f3f620fc8b2e
2024-10-21 15:00:32 +01:00
merge-script
d9f8dc6453
Merge bitcoin/bitcoin#31097: validation: Improve input script check error reporting
86e2a6b749 [test] A non-standard transaction which is also consensus-invalid should return the consensus error (Antoine Poinsot)
f859ff8a4e [validation] Improve script check error reporting (dergoegge)

Pull request description:

  An input script might be invalid for multiple reasons. For example, it might fail both a standardness check and a consensus check, which can lead to a `mandatory-script-verify-flag-failed` error being reported that includes the script error string from the standardness failure (e.g. `mandatory-script-verify-flag-failed (Using OP_CODESEPARATOR in non-witness script)`), which is confusing.

ACKs for top commit:
  darosior:
    re-ACK 86e2a6b749
  ariard:
    Re-Code Review ACK 86e2a6b7
  instagibbs:
    ACK 86e2a6b749

Tree-SHA512: 053939107c0bcd6643e9006b2518ddc3a6de47d2c6c66af71a04e8af5cf9ec207f19e54583b7a056efd77571edf5fd4f36c31ebe80d1f0777219c756c055eb42
2024-10-21 14:58:44 +01:00
TheCharlatan
192dac1d33
[refactor] Cleanup BlockAssembler mempool usage
The `addPackageTxs` method of the `BlockAssembler` currently has access
to two mempool variables, as an argument and as a member. Clean this up
and clarify that they both are the same mempool instance by removing the
argument and instead only using the member variable in the method.

Co-Authored-By: Anthony Towns <aj@erisian.com.au>
Co-authored-by: stickies-v <stickies-v@protonmail.com>
2024-10-21 15:55:35 +02:00
brunoerg
a16917fb59 rpc, net: improve mapped_as doc for getrawaddrman/getpeerinfo
Before, we did not explicity say that both fields
`{source_}mapped_as` (that are optional in getrawaddrman)
will be only available if the asmap config flag is set.

Co-authored-by: Jon Atack <jon@atack.com>
2024-10-21 10:14:56 -03:00
furszy
c98fc36d09
wallet: migration, consolidate external wallets db writes
Perform a single db write operation for each external wallet
(watch-only and solvables) for the entire migration procedure.
2024-10-21 08:29:23 -03:00
furszy
7c9076a2d2
wallet: migration, consolidate main wallet db writes
Perform a single db write operation for the entire
migration procedure.
2024-10-21 08:29:23 -03:00
furszy
9ef20e86d7
wallet: provide WalletBatch to 'SetupDescriptorScriptPubKeyMans'
So it can be used within an external db txn context.
2024-10-21 08:29:23 -03:00
furszy
34bf0795fc
wallet: refactor ApplyMigrationData to return util::Result<void> 2024-10-21 08:29:23 -03:00
furszy
aacaaaa0d3
wallet: provide WalletBatch to 'RemoveTxs'
Preparing it to be used within a broader db txn procedure.
2024-10-21 08:29:23 -03:00
furszy
57249ff669
wallet: introduce active db txn listeners
Useful to ensure that the in-memory state is updated only
after successfully committing the data to disk.
2024-10-21 08:29:22 -03:00
furszy
91e065ec17
wallet: remove post-migration signals connection
The wallet is isolated during migration and reloaded at the end
of the process. There is no benefit on connecting the signals
few lines before unloading the wallet.
2024-10-21 08:29:22 -03:00
furszy
055c0532fc
wallet: provide WalletBatch to 'DeleteRecords'
So it can be used within an external db txn context.
2024-10-21 08:29:22 -03:00
furszy
122d103ca2
wallet: introduce 'SetWalletFlagWithDB' 2024-10-21 08:29:22 -03:00
furszy
6052c7891d
wallet: decouple default descriptors creation from external signer setup
This will be useful in the following-up commit to batch the entire
wallet migration process.
2024-10-21 08:29:22 -03:00
furszy
f2541d09e1
wallet: batch MigrateToDescriptor() db transactions
Grouping all db writes into a single atomic write operation.
Speeding up the flow and preventing inconsistent states.
2024-10-21 08:29:22 -03:00
furszy
66c9936455
bench: add coverage for wallet migration process 2024-10-21 08:29:22 -03:00
merge-script
563c4d2926
Merge bitcoin/bitcoin#31105: Update libmultiprocess library
90b405516f Update libmultiprocess library (Ryan Ofsky)

Pull request description:

  Add recent changes and fixes for shutdown bugs.

  https://github.com/chaincodelabs/libmultiprocess/pull/111: doc: Add internal design section
  https://github.com/chaincodelabs/libmultiprocess/pull/113: Add missing include to util.h
  https://github.com/chaincodelabs/libmultiprocess/pull/116: shutdown bugfix: destroy RPC system before running cleanup callbacks
  https://github.com/chaincodelabs/libmultiprocess/pull/118: shutdown bugfix: Prevent segfault in server if connection is broken during long function call
  https://github.com/chaincodelabs/libmultiprocess/pull/119: cmake: avoid libatomic not found error on debian

ACKs for top commit:
  fanquake:
    ACK 90b405516f
  TheCharlatan:
    ACK 90b405516f

Tree-SHA512: 2c256667f0c16e00bb5a81b2c6d3db103fae211844e32b111bbed673ab2612ad1478e6b3ecd3a867a4e425cfa6e778b67388343626597a8fac800a15cea5e53a
2024-10-21 10:54:38 +01:00
Lőrinc
33a28e252a Change default help arg to -help and mention -h and -? as alternatives
% build/src/bench/bench_bitcoin -h
[...]
  -help
       Print this help message and exit (also -h or -?)
2024-10-21 11:08:51 +02:00
Jon Atack
681ebcceca netinfo: rename and hoist max level constant to use in top-level help
to avoid overlooking to update the top-level help if the value of the constant changes.
2024-10-17 15:04:27 -06:00
Jon Atack
e7d307ce8c netinfo: clarify relaytxes and addr_relay_enabled help docs 2024-10-17 15:04:17 -06:00
Jon Atack
eef2a9d406 netinfo: add peer services column 2024-10-17 15:04:06 -06:00
merge-script
e8f72aefd2
Merge bitcoin/bitcoin#29877: tracing: explicitly cast block_connected duration to nanoseconds
cd0edf26c0 tracing: cast block_connected duration to nanoseconds (0xb10c)

Pull request description:

  When the `validation:block_connected` tracepoint was introduced in 8f37f5c2a5, the connect block duration was passed in microseconds `µs`. By starting to use steady clock in fabf1cdb20 this changed to nanoseconds `ns`. As the test only checked if the duration value is `> 0` as a plausibility check, this went unnoticed. This was detected this when setting up monitoring for block validation time as part of the Great Consensus Cleanup Revival discussion.

  This change casts the duration explicitly to nanoseconds, updates the documentation, and adds a check for an upper bound to the tracepoint interface tests. The upper bound is quite lax as mining the block takes much longer than connecting the empty test block. It's however able to detect a duration passed in an incorrect unit (1000x off).

  A previous version of this PR casted the duration to microseconds `µs` - however, as the last three major releases have had the duration as nanoseconds (and this went unnoticed), we assume that this is the API now and changeing it back to microseconds would break the API again. See also https://github.com/bitcoin/bitcoin/pull/29877#issuecomment-2067867597

ACKs for top commit:
  maflcko:
    re-lgtm ACK cd0edf26c0
  laanwj:
    re-ACK cd0edf26c0

Tree-SHA512: 54a1eea0297e01c07c2d071ffafbf97dbd080f763e1dc0014ff086a913b739637c1634b1cf87c90b94a3c2f66006acfaada0414a15769cac761e03bc4aab2a77
2024-10-17 16:30:12 +01:00
Ryan Ofsky
90b405516f Update libmultiprocess library
Add recent changes and fixes for shutdown bugs.

https://github.com/chaincodelabs/libmultiprocess/pull/111: doc: Add internal design section
https://github.com/chaincodelabs/libmultiprocess/pull/113: Add missing include to util.h
https://github.com/chaincodelabs/libmultiprocess/pull/116: shutdown bugfix: destroy RPC system before running cleanup callbacks
https://github.com/chaincodelabs/libmultiprocess/pull/118: shutdown bugfix: Prevent segfault in server if connection is broken during long function call
https://github.com/chaincodelabs/libmultiprocess/pull/119: cmake: avoid libatomic not found error on debian
2024-10-16 12:13:27 -04:00
Ava Chow
dea9fb9a8b
Merge bitcoin/bitcoin#30093: optimization: reserve memory allocation for transaction inputs/outputs
ec585f11c3 Reserve space for transaction inputs in CreateTransactionInternal (Lőrinc)
c76aaaf900 Reserve space for transaction outputs in CreateTransactionInternal (Lőrinc)

Pull request description:

  Reserved memory for the transaction inputs and outputs.

  Split out of https://github.com/bitcoin/bitcoin/pull/30050/files#r1597631104

ACKs for top commit:
  achow101:
    ACK ec585f11c3
  TheCharlatan:
    ACK ec585f11c3
  stickies-v:
    ACK ec585f11c3

Tree-SHA512: de399fb19824423467f48af64aa57f41a23cdd00eb17461e0131e4deafdd15e0d2daebf6a0a7ac7728b2fb486b2a54f1a7ef26bbe823c56b2a09f892f6b9a581
2024-10-16 09:20:23 -04:00
dergoegge
f859ff8a4e [validation] Improve script check error reporting 2024-10-16 10:18:48 +01:00
MarcoFalke
ddddbac9c1
fees: Pin required version to 149900
There is no need to compare the field to CLIENT_VERSION. Either the
format remains compatible and the value can be left unchanged, or it is
incompatible and the value needs to be increased to at least 289900+1.
2024-10-16 11:17:33 +02:00
MarcoFalke
fa5126adcb
fees: Pin "version that wrote" to 0
The field is unused and there is no need to tie it to CLIENT_VERSION and
increase it, if the format does not change.
2024-10-16 11:12:53 +02:00
willcl-ark
1fe1b3ba8e doc: doxygen comment for m_args usage in tests
Closes: #25055

Add doxygen comment to the m_args member in the unit test framework,
clarifying its purpose.
2024-10-13 09:05:21 +01:00
Hennadii Stepanov
82e16e6983
cmake: Refactor install kernel dependencies 2024-10-12 16:54:08 +02:00
TheCharlatan
42e6277987
build: Add static libraries to Kernel install component 2024-10-12 16:48:42 +02:00
merge-script
48cf3da636
Merge bitcoin/bitcoin#30970: build: Add missing USDT header dependency to kernel
ccd10fdb97 build: Add missing USDT header dependency to kernel (Cory Fields)

Pull request description:

  Noticed while testing a branch that replaces `boost::multi_index` with a custom replacement.

  Currently depends builds pick up usdt and boost from the same path, and because boost always exists, the usdt path is implicitly included. So without boost, USDT isn't found.

  An alternative to this would be to disable USDT for the kernel. I'd be open to either approach.

ACKs for top commit:
  hebasto:
    ACK ccd10fdb97, the diff looks correct.
  fanquake:
    ACK ccd10fdb97

Tree-SHA512: 2f91b8d5c8b169f7b72323d9163b5201f606ccdab95de7085847d2a672d10f940f69642c2528226a5efa4c589af24ca3bb9dd909eed0993e4cecd9689b4bed2f
2024-10-11 13:46:40 +01:00
glozow
489e5aa3a2
Merge bitcoin/bitcoin#30857: cluster mempool: extend DepGraph functionality
0b3ec8c59b clusterlin: remove Cluster type (Pieter Wuille)
1c24c62510 clusterlin: merge two DepGraph fuzz tests into simulation test (Pieter Wuille)
0606e66fdb clusterlin: add DepGraph::RemoveTransactions and support for holes in DepGraph (Pieter Wuille)
75b5d42419 clusterlin: make DepGraph::AddDependency support multiple dependencies at once (Pieter Wuille)
abf50649d1 clusterlin: simplify DepGraphFormatter::Ser (Pieter Wuille)
eaab55ffc8 clusterlin: rework DepGraphFormatter::Unser (Pieter Wuille)
5901cf7100 clusterlin: abstract out DepGraph::GetReduced{Parents,Children} (Pieter Wuille)

Pull request description:

  Part of cluster mempool: #30289

  This adds:
  * `DepGraph::AddDependencies` to add 0 or more dependencies to a single transaction at once (identical to calling `DepGraph::AddDependency` once for each, but more efficient).
  * `DepGraph::RemoveTransactions` to remove 0 or more transactions from a depgraph.
  * `DepGraph::GetReducedParents` (and `DepGraph::GetReducedChildren`) to get the (reduced) direct parents and children of a transaction in a depgraph.

  After which, the `Cluster` type is removed.

  This is the result of fleshing out the design for the "intermediate layer" ("TxGraph", no PR yet) between the cluster linearization layer and the mempool layer. My earlier thinking was that TxGraph would store `Cluster` objects (vectors of pairs of `FeeFrac`s and sets of parents), and convert them to `DepGraph` on the fly whenever needed. However, after more consideration, it seems better to have TxGraph store `DepGraph` objects, and manipulate them directly without constantly re-creating them. This requires `DepGraph` to have some additional functionality.

  The bulk of the complexity here is the addition of `DepGraph::RemoveTransactions`, which leaves the remaining transactions' positions within the `DepGraph` untouched (we want existing identifiers to remain valid), so this implies that graphs can now have "holes" (positions that are unused, but followed by positions that are used). To enable that, an extension of the fuzz/test serialization format `DepGraphFormatter` is included to deal with such holes.

ACKs for top commit:
  sdaftuar:
    reACK 0b3ec8c59b
  instagibbs:
    reACK 0b3ec8c59b
  ismaelsadeeq:
    reACK 0b3ec8c59b
  glozow:
    ACK 0b3ec8c59b, reviewed range-diff from  aab53ddcd8fcbc3c0be0da9383f8e06abe5badda and `clusterlin_depgraph_sim`

Tree-SHA512: a804b7f26d544c5cb0847322e235c810525cb0607737be6116c3156d582da3ba3352af8ea48e74eed5268f9c3eca63b30181d01b23a6dd0be1b99191f81cceb0
2024-10-10 10:40:44 -04:00
Sebastian Falbesoner
1786be7b4a scripted-diff: drop config/ subdir for bitcoin-config.h, rename to bitcoin-build-config.h
Follow-up for PR #30856, commit 0dd66251.

-BEGIN VERIFY SCRIPT-
sed -i "s|config/bitcoin-config\.h|bitcoin-build-config.h|g" $(git grep -l config/bitcoin-config\.h)
sed -i "s|bitcoin-config\.h|bitcoin-build-config.h|g" $(git grep -l "bitcoin-config\.h" ./src ./test ./cmake)
git mv ./cmake/bitcoin-config.h.in ./cmake/bitcoin-build-config.h.in
-END VERIFY SCRIPT-
2024-10-10 12:22:12 +02:00
TheCharlatan
3a4a788ee0
init: Correct coins db cache size setting
The chainstate caches are currently re-balanced on startup
even in the non-assumeutxo case, leading to the database being
needlessly re-opened and its cache re-allocated.

Similar to `InitCoinsCache` and `m_coinstip_cache_size_bytes` the
`m_coinsdb_cache_size_bytes` should be set in `InitCoinsDB`.

Together with only conservatively setting the cache values when a
assumeutxo chainstate is present, this allows for skipping the cache
re-balance during initialization in the normal non-assumeutxo case.
2024-10-10 11:27:41 +02:00
Ava Chow
0c2c3bb3f5
Merge bitcoin/bitcoin#30955: Mining interface: getCoinbaseMerklePath() and submitSolution()
525e9dcba0 Add submitSolution to BlockTemplate interface (Sjors Provoost)
47b4875ef0 Add getCoinbaseMerklePath() to Mining interface (Sjors Provoost)
63d6ad7c89 Move BlockMerkleBranch back to merkle.{h,cpp} (Sjors Provoost)

Pull request description:

  The new `BlockTemplate` interface introduced in #30440 allows for a more efficient way for a miner to submit the block solution. Instead of having the send the full block, it only needs to provide the nonce, timestamp, version fields and coinbase transaction.

  This PR introduces `submitSolution()` for that. It's currently unused.

  #29432 and https://github.com/Sjors/bitcoin/pull/48 use it to process the Stratum v2 message [SubmitSolution](https://github.com/stratum-mining/sv2-spec/blob/main/07-Template-Distribution-Protocol.md#77-submitsolution-client---server). The method should be sufficiently generic to work with alternative mining protocols (none exist that I'm aware off).

  This PR also introduces `getCoinbaseMerklePath()`, which is needed in Stratum v2 to construct the `merkle_path` field of the `NewTemplate` message (see [spec](https://github.com/stratum-mining/sv2-spec/blob/main/07-Template-Distribution-Protocol.md#72-newtemplate-server---client)). The coinbase merkle path is also used in Stratum "v1", see e.g. https://bitcoin.stackexchange.com/questions/109820/questions-on-merkle-root-hashing-for-stratum-pools

  This last function uses `BlockMerkleBranch` which was moved to the test code in #13191. The reason back then for moving it was that it was no longer used. This PR moves it back.

  This PR does not change behaviour since both methods are unused.

ACKs for top commit:
  achow101:
    ACK 525e9dcba0
  itornaza:
    Code review ACK 525e9dcba0
  tdb3:
    Code review and light test ACK 525e9dcba0
  ryanofsky:
    Code review ACK 525e9dcba0. Left minor suggestions but none are important, and looks like this could be merged as-is

Tree-SHA512: 2a6a8f5d409ff4926643193cb67702240c7c687615414371e53383d2c13c485807f65e21e8ed98515b5456eca3d9fca13cec04675814a4081467d88b849c5653
2024-10-09 20:20:09 -04:00
merge-script
5fb9455063
Merge bitcoin/bitcoin#31058: refactor: include the proper header rather than forward-declaring RemovalReasonToString
ca2e4ba352 refactor: include the proper header rather than forward-declaring RemovalReasonToString (Cory Fields)

Pull request description:

  Trivial no-op fixup.

  This was pointed out by #31053, which causes the include order to be shuffled around:

  ```
  [21:49:26.130] /ci_container_base/src/validationinterface.cpp:22:13: error: redundant 'RemovalReasonToString' declaration [readability-redundant-declaration,-warnings-as-errors]
  [21:49:26.130]    22 | std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept;
  [21:49:26.130]       | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  [21:49:26.130] /ci_container_base/src/kernel/mempool_removal_reason.h:22:13: note: previously declared here
  [21:49:26.130]    22 | std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept;
  [21:49:26.130]       |             ^
  ```

  I don't see any reason why the include shouldn't just be used.

ACKs for top commit:
  maflcko:
    lgtm ACK ca2e4ba352
  hebasto:
    ACK ca2e4ba352, IWYU seems [agree](https://cirrus-ci.com/task/6170839912022016):
  TheCharlatan:
    ACK ca2e4ba352

Tree-SHA512: e3584cae4f50bf2bc6c824bfaddfe683ef6a17d16138d0cbcc544b98bd64d5d7353b0826b1e8cf16e12410e27b0fcedde27100d4241b7cc194cd4465c8175a5b
2024-10-09 10:08:50 +01:00
Ava Chow
e569eb8d91
Merge bitcoin/bitcoin#30885: scripted-diff: Modernize nLocalServices naming
33381ea530 scripted-diff: Modernize nLocalServices to m_local_services (Fabian Jahr)

Pull request description:

  The type of the `nLocalServices` variable was changed to `std::atomic<ServiceFlags>` in #30807 and I suggested the variable name to get updated with a scripted diff along with it. It wasn't included in the PR but I am still suggesting to do it as a follow-up since I had already prepared the commit.

ACKs for top commit:
  sipa:
    utACK 33381ea530
  achow101:
    ACK 33381ea530
  furszy:
    utACK 33381ea530
  jonatack:
    ACK 33381ea530
  theStack:
    ACK 33381ea530

Tree-SHA512: 407ea9eac694f079aa5b5c1611b5874d7a0897ba6bc3aa0570be94afe1bf3a826657b6890b6597c03c063e95b9dc868f0bdfbfc41e77ec7e06f5b045bf065c71
2024-10-08 20:41:37 -04:00
Martin Zumsande
31cc5006c3
init: Return fatal failure on snapshot validation failure
A general reindex won't typically help in this case, and there is
already some action being taken with the call to
`InvalidateCoinsDBOnDisk`.
2024-10-08 22:45:06 +02:00
TheCharlatan
8f1246e833
init: Improve chainstate init db error messages
They should name the correct source of an error, or be generic if no
clear source can be ascertained.
2024-10-08 22:45:02 +02:00
Ryan Ofsky
5837e3463f
Merge bitcoin/bitcoin#30967: refactor: Replace g_genesis_wait_cv with m_tip_block_cv
fa22e5c430 refactor: Remove dead code that assumed tip == nullptr (MarcoFalke)
fa2e443965 refactor: Replace g_genesis_wait_cv with m_tip_block_cv (MarcoFalke)
fa7f52af1a refactor: Use wait_for predicate to check for interrupt (MarcoFalke)
5ca28ef28b refactor: Split up NodeContext shutdown_signal and shutdown_request (Ryan Ofsky)
fad8e7fba7 bugfix: Mark m_tip_block_cv as guarded by m_tip_block_mutex (MarcoFalke)
fa18586c29 refactor: Add missing GUARDED_BY(m_tip_block_mutex) (MarcoFalke)
fa4c075033 doc: Clarify waitTipChanged docs (MarcoFalke)

Pull request description:

  `g_genesis_wait_cv` is similar to `m_tip_block_cv` but shuffling everything through a redundant `boost::signals2`.

  So remove it, along with some other dead code, as well as minor fixups.

ACKs for top commit:
  ryanofsky:
    Code review ACK fa22e5c430 (just rebased since last review)
  Sjors:
    ACK fa22e5c430
  TheCharlatan:
    ACK fa22e5c430

Tree-SHA512: a2cb59b651aaf85a3574723adfe403487566788ad945933b0458816ccc841fce08ca77b31afbd2d6adb5bf1deed7229c028bee74fb4bbaf6576e9edcfa0ad817
2024-10-08 12:01:12 -04:00
Cory Fields
ca2e4ba352 refactor: include the proper header rather than forward-declaring RemovalReasonToString
This was not in its own header when it was added, but now that it is the
forward-declare makes no sense.
2024-10-08 15:25:47 +00:00
merge-script
bb47b5a657
Merge bitcoin/bitcoin#31038: test: Fix copy-paste in wallet/test/db_tests ostream operator
f50557f5d3 test: Fix copy-paste in db_tests ostream operator (Hodlinator)

Pull request description:

  Fix accidentally remaining copy-pasted variable name.

  Example output when intentionally adding `expected.erase(expected.begin());` before `BOOST_CHECK_EQUAL_COLLECTIONS` in *db_tests.cpp*/`CheckPrefix`:

  Before fix:
  ```
  src/wallet/test/db_tests.cpp(61): error: in "db_tests/db_cursor_prefix_byte_test": check { actual.begin(), actual.end() } == { expected.begin(), expected.end() } has failed.
  Mismatch at position 0: ("�", "�") != ("�suffix", "�suffix")
  Mismatch at position 1: ("�suffix", "�suffix") != ("��", "��")
  Mismatch at position 2: ("��", "��") != ("��suffix", "��suffix")
  Collections size mismatch: 4 != 3
  ```

  After fix:
  ```
  src/wallet/test/db_tests.cpp(61): error: in "db_tests/db_cursor_prefix_byte_test": check { actual.begin(), actual.end() } == { expected.begin(), expected.end() } has failed.
  Mismatch at position 0: ("�", "f") != ("�suffix", "fs")
  Mismatch at position 1: ("�suffix", "fs") != ("��", "ff")
  Mismatch at position 2: ("��", "ff") != ("��suffix", "ffs")
  Collections size mismatch: 4 != 3
  ```

  Super-minor issue only uncovered when tests fail, but might as well correct it.

ACKs for top commit:
  maflcko:
    lgtm ACK f50557f5d3
  tdb3:
    code review ACK f50557f5d3

Tree-SHA512: d36e9bc36f82f2c39e9c7585ae9e5c63f7fd07665d1d3c625709bc90168ced2f83ac7d577b4914dae2f0f101c415bf0c1ed6de98a20c96c8c0383a701cbdbe99
2024-10-08 15:27:10 +01:00
Pieter Wuille
0b3ec8c59b clusterlin: remove Cluster type 2024-10-07 13:49:36 -04:00
Pieter Wuille
1c24c62510 clusterlin: merge two DepGraph fuzz tests into simulation test
This combines the clusterlin_add_dependency and clusterlin_cluster_serialization
fuzz tests into a single clusterlin_depgraph_sim fuzz test. This tests starts
from an empty DepGraph and performs a arbitrary number of AddTransaction,
AddDependencies, and RemoveTransactions operations on it, and compares the
resulting state with a naive reimplementation.
2024-10-07 13:49:36 -04:00
Pieter Wuille
0606e66fdb clusterlin: add DepGraph::RemoveTransactions and support for holes in DepGraph
This commits introduces support in DepGraph for the transaction positions to be
non-continuous. Specifically, it adds:
* DepGraph::RemoveTransactions which removes 0 or more positions from a DepGraph.
* DepGraph::Positions() to get a set of which positions are in use.
* DepGraph::PositionRange() to get the highest used position in a DepGraph + 1.

In addition, it extends the DepGraphFormatter format to support holes in a
compatible way (it serializes non-holey DepGraphs identically to the old code,
and deserializes them the same way)
2024-10-07 13:49:35 -04:00
Pieter Wuille
75b5d42419 clusterlin: make DepGraph::AddDependency support multiple dependencies at once
This changes DepGraph::AddDependency into DepGraph::AddDependencies, which takes
in a single child, but a set of parent transactions, making them all dependencies
at once.

This is important for performance. N transactions can have O(N^2) parents combined,
so constructing a full DepGraph using just AddDependency (which is O(N) on its own)
could take O(N^3) time, while doing the same with AddDependencies (also O(N) on its
own) only takes O(N^2).

Notably, this matters for DepGraphFormatter::Unser, which goes from O(N^3) to O(N^2).

Co-Authored-By: Greg Sanders <gsanders87@gmail.com>
2024-10-07 13:47:52 -04:00
Pieter Wuille
abf50649d1 clusterlin: simplify DepGraphFormatter::Ser
This does not change the serialization format.

It turns out that it is unnecessary to keep track of the order of transactions
in the so-far reconstructed DepGraph to decide how far from the end to insert
a new transaction.
2024-10-07 13:47:52 -04:00
Pieter Wuille
eaab55ffc8 clusterlin: rework DepGraphFormatter::Unser
This commit does not change the serialization format. Its purpose is making a
few changes already in order to reduce the diff size of the later commit that
introduces support for holes in DepGraph.

The previous approach was to immediately construct a transaction as soon as its
feerate was known in a preliminary position, and then undo that, and place it
in the correct position once the position information is known (such that a
deserialization error in between would not result in an inconsistent state).

The new approach is to delay the actual transaction creation until all its
information is known, avoiding the need to undo and redo. This requires a
different means of determining whether dependencies are redundant, but that has
the advantage that a later commit can apply all dependencies at once, reducing
the complexity of deserialization.
2024-10-07 13:47:52 -04:00
Pieter Wuille
5901cf7100 clusterlin: abstract out DepGraph::GetReduced{Parents,Children}
A fuzz test already relies on these operations, and a future commit will need
the same logic too. Therefore, abstract them out into proper member functions,
with proper testing.
2024-10-07 13:46:48 -04:00
fanquake
e0287bc4b2
test: remove unused code from script_tests
This has been unused since #29648.
Noticed while running a newer version of clang-tidy (19.1.1):
```bash
[127/391][6.2s] /opt/homebrew/opt/llvm/bin/clang-tidy -p=build -quiet --config-file=/bitcoin/src/.clang-tidy /bitcoin/src/test/script_tests.cpp
bitcoin/src/test/script_tests.cpp:126:25: error: local copy 'tx2' of the variable 'tx' is never modified and never used; consider removing the statement [performance-unnecessary-copy-initialization,-warnings-as-errors]
  126 |     CMutableTransaction tx2 = tx;
      |     ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
  127 |     BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, &scriptWitness, flags, MutableTransactionSignatureChecker(&tx, 0, txCredit.vout[0].nValue, MissingDataBehavior::ASSERT_FAIL), &err) == expect, message);
512 warnings generated.
```
2024-10-07 16:31:12 +01:00
MarcoFalke
cd093049dd
init: Remove incorrect comment about shutdown condition
Shutdown is indeed called, and it being overkill does not make sense
either.
2024-10-07 12:30:36 +02:00
TheCharlatan
635e9f85d7
init: Remove misleading log line when user chooses not to retry
It is bad, because it is both printed for non-GUI users and does not
convey additional information.

Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
2024-10-07 12:30:12 +02:00
Hennadii Stepanov
1b70714671
Merge bitcoin-core/gui#840: qt6: Handle different signatures of QANEF::nativeEventFilter
80761afced qt6: Handle different signatures of `QANEF::nativeEventFilter` (Hennadii Stepanov)

Pull request description:

  Split from https://github.com/bitcoin/bitcoin/pull/30997.

  This PR ensures compatibility across all supported Qt versions.

  For more details, please refer to 3b38c73c7f.

  No behaviour change.

ACKs for top commit:
  maflcko:
    lgtm ACK 80761afced
  promag:
    Code review ACK 80761afced.

Tree-SHA512: a265e1c33cc7da37003bb0e6fd40950acb5e948ca9ec63a59a79c5e2a1894334f48d5565539c91d4d777b48a589366958df1498eaa6935e3b7fb534493adb51a
2024-10-07 10:27:55 +01:00
Martin Zumsande
720ce880a3
init: Improve comment describing chainstate load retry behaviour 2024-10-07 11:05:22 +02:00
stickies-v
baea842ff1
init: Remove unneeded argument for mempool_opts checks 2024-10-07 11:03:02 +02:00
Hennadii Stepanov
5fe6878b5f
Merge bitcoin-core/gui#836: Fix display issues for IPv6 proxy setup in Options Dialog (UI only, no functionality impact)
fee4cba484 gui: Fix proxy details display in Options Dialog (pablomartin4btc)

Pull request description:

  Currently, setting up a proxy (whether SOCKS5 or Tor) with an IPv6 address works correctly via the command line or configuration file in both `bitcoind` and `bitcoin-qt` (also from the UI the ipv6 address gets saved properly in `settings.json`). However, the UI does not reflect this properly, which can create confusion. Since some ISPs and VPNs still experience issues with IPv6, users may mistakenly think there is a problem with Bitcoin Core, when in fact the proxy setup is functioning as expected.

  So this PR ensures that the proxy IP is displayed correctly in the UI when using an IPv6 address.

  No functionality impact; changes only affect UI display.

  <details>
  <summary>Click her to see <b>before</b> and <b>after</b> screenshots.</summary>

  - Before:

    ![image](https://github.com/user-attachments/assets/073d9022-3174-4eef-8e0c-8c1b73b17226)

  - After:

    ![image](https://github.com/user-attachments/assets/293e4e07-83e5-44ec-8ab3-df9d1f601a6f)

  </details>

  ---

  <details>
  <summary>Test instructions</summary>

  (Ubuntu 22.04)

  1. Start ssh service on localhost.

     `ssh -D [::1]:1080 -f -C -q -N localhost`

  2. Check that the service is up and running.

     ```
     ps aux | grep ssh
     pepe    2860289  0.0  0.0  20456  5576 ?        Ss   06:59   0:00 ssh -D [::1]:1080 -f -C -q -N localhost
     ```

  3. Check with `bitcoind` if it works correctly.

     `bitcoind -onlynet=ipv6 -proxy=[::1]:1080`

  4. Check for established connections.

     ```
     netstat -natl |grep 1080
     tcp6       0      0 ::1:1080                :::*                    LISTEN
     tcp6       0      0 ::1:47610               ::1:1080                ESTABLISHED
     tcp6       0      0 ::1:1080                ::1:47610               ESTABLISHED
     tcp6       0      0 ::1:1080                ::1:47606               TIME_WAIT
     ```

     ```./build/src/bitcoin-cli getpeerinfo
     [
        {
          "id": 0,
          "addr": "[2a01:4f9:4a:2a07::2]:8333",
          "addrbind": "[::1]:47638",
          "network": "ipv6",
     ...
     ```

  5. Stop `bitcoind` and run `bitcoin-qt` adding the corresponding configuration in `settings.json`.

      ```
     {
         "onlynet": "ipv6",
         "proxy": "[::1]:1080",
     }
     ```

  6. Open the Peers window to check available connections or run `getpeerinfo` on the rpc-console window.

  7. Same can be done for Tor setting up `tor` service (I'll add instructions later) and configuring on its default port 9050 and forcing `"onlynet": "onion"` to verify easily the net traffic.

  </details>

  ---

  Thanks jarolrod and vasild for your help on validating ipv6 was not broken.

ACKs for top commit:
  vasild:
    ACK fee4cba484
  promag:
    Code review ACK fee4cba484.
  hebasto:
    ACK fee4cba484, I have reviewed the code and it looks OK.

Tree-SHA512: 4be9052569ccb1e17ce94fb15691debf0651fa172ed1a83d60696d10f20d469b19d70a979b65322951f5783cd7582d55b39b669edb588e20404d8d10e767c49a
2024-10-06 19:26:45 +01:00
Hodlinator
f50557f5d3
test: Fix copy-paste in db_tests ostream operator 2024-10-05 23:58:16 +02:00
glozow
5ea335a97f
Merge bitcoin/bitcoin#30793: rpc: add getorphantxs
98c1536852 test: add getorphantxs tests (tdb3)
93f48fceb7 test: add tx_in_orphanage() (tdb3)
34a9c10e8c rpc: add getorphantxs (tdb3)
f511ff3654 refactor: move verbosity parsing to rpc/util (tdb3)
532491faf1 net: add GetOrphanTransactions() to PeerManager (tdb3)
91b65adff2 refactor: add OrphanTxBase for external use (tdb3)

Pull request description:

  This PR adds a new hidden rpc, `getorphantxs`, that provides the caller with a list of orphan transactions.  This rpc may be helpful when checking orphan behavior/scenarios (e.g. in tests like `p2p_orphan_handling`) or providing additional data for statistics/visualization.

  ```
  getorphantxs ( verbosity )

  Shows transactions in the tx orphanage.

  EXPERIMENTAL warning: this call may be changed in future releases.

  Arguments:
  1. verbosity    (numeric, optional, default=0) 0 for an array of txids (may contain duplicates), 1 for an array of objects with tx details, and 2 for details from (1) and tx hex

  Result (for verbose = 0):
  [           (json array)
    "hex",    (string) The transaction hash in hex
    ...
  ]

  Result (for verbose = 1):
  [                          (json array)
    {                        (json object)
      "txid" : "hex",        (string) The transaction hash in hex
      "wtxid" : "hex",       (string) The transaction witness hash in hex
      "bytes" : n,           (numeric) The serialized transaction size in bytes
      "vsize" : n,           (numeric) The virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted.
      "weight" : n,          (numeric) The transaction weight as defined in BIP 141.
      "expiration" : xxx,    (numeric) The orphan expiration time expressed in UNIX epoch time
      "from" : [             (json array)
        n,                   (numeric) Peer ID
        ...
      ]
    },
    ...
  ]

  Result (for verbose = 2):
  [                          (json array)
    {                        (json object)
      "txid" : "hex",        (string) The transaction hash in hex
      "wtxid" : "hex",       (string) The transaction witness hash in hex
      "bytes" : n,           (numeric) The serialized transaction size in bytes
      "vsize" : n,           (numeric) The virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted.
      "weight" : n,          (numeric) The transaction weight as defined in BIP 141.
      "expiration" : xxx,    (numeric) The orphan expiration time expressed in UNIX epoch time
      "from" : [             (json array)
        n,                   (numeric) Peer ID
        ...
      ],
      "hex" : "hex"          (string) The serialized, hex-encoded transaction data
    },
    ...
  ]

  Examples:
  > bitcoin-cli getorphantxs 2
  > curl --user myusername --data-binary '{"jsonrpc": "2.0", "id": "curltest", "method": "getorphantxs", "params": [2]}' -H 'content-type: application/json' http://127.0.0.1:8332/
  ```
  ```
  $ build/src/bitcoin-cli getorphantxs 2
  [
    {
      "txid": "50128aac5deab548228d74d846675ad4def91cd92453d81a2daa778df12a63f2",
      "wtxid": "bb61659336f59fcf23acb47c05dc4bbea63ab533a98c412f3a12cb813308d52c",
      "bytes": 133,
      "vsize": 104,
      "weight": 415,
      "expiration": 1725663854,
      "from": [
        1
      ],
      "hex": "020000000001010b992959eaa2018bbf31a4a3f9aa30896a8144dbd5cfaf263bf07c0845a3a6620000000000000000000140fe042a010000002251202913b252fe537830f843bfdc5fa7d20ba48639a87c86ff837b92d083c55ad7c102015121c0000000000000000000000000000000000000000000000000000000000000000100000000"
    },
    {
      "txid": "330bb7f701604a40ade20aa129e9a3eb8a7bf024e599084ca1026d3222b9f8a1",
      "wtxid": "b7651f7d4c1a40c4d01f6a1e43a121967091fa0f56bb460146c1c5c068e824f6",
      "bytes": 133,
      "vsize": 104,
      "weight": 415,
      "expiration": 1725663854,
      "from": [
        2
      ],
      "hex": "020000000001013600adfe41e0ebd2454838963d270916d2b47239c9eebb93a992b720d3589a080000000000000000000140fe042a010000002251202913b252fe537830f843bfdc5fa7d20ba48639a87c86ff837b92d083c55ad7c102015121c0000000000000000000000000000000000000000000000000000000000000000100000000"
    }
  ]
  ```

ACKs for top commit:
  glozow:
    reACK 98c1536852
  hodlinator:
    re-ACK 98c1536852
  danielabrozzoni:
    ACK 98c1536852
  pablomartin4btc:
    tACK 98c1536852
  itornaza:
    reACK 98c1536852

Tree-SHA512: 66075f9faa83748350b87397302100d08af92cbef5fadb27f2b4903f028c08020bf34a23e17262b41abb3f379ca9f46cf6cd5459b8681f2b83bffbbaf3c03ff9
2024-10-05 11:20:06 -04:00
Hennadii Stepanov
80761afced
qt6: Handle different signatures of QANEF::nativeEventFilter
This change ensures compatibility across all supported Qt versions.
2024-10-04 12:58:04 +01:00
Hennadii Stepanov
51c698161b
Merge bitcoin-core/gui#837: qt6: Fix linking when configured with -DENABLE_WALLET=OFF
5be34bacf6 qt: Fix linking when configured with `-DENABLE_WALLET=OFF` (Hennadii Stepanov)

Pull request description:

  Split from https://github.com/bitcoin/bitcoin/pull/30997.

  When building with Qt 6 in my dev branch, I encountered a linker error when configured with `-DENABLE_WALLET=OFF`:
  ```
  $ cmake -B build -DENABLE_WALLET=OFF -DBUILD_GUI=ON
  $ cmake --build build -t bitcoin-qt
  <snip>
  [100%] Linking CXX executable bitcoin-qt
  /usr/bin/ld: libbitcoinqt.a(rpcconsole.cpp.o): in function `QtPrivate::MetaObjectForType<WalletModel const*, void>::metaObjectFunction(QtPrivate::QMetaTypeInterface const*)':
  /usr/include/x86_64-linux-gnu/qt6/QtCore/qmetatype.h:903:(.text._ZN9QtPrivate17MetaObjectForTypeIPK11WalletModelvE18metaObjectFunctionEPKNS_18QMetaTypeInterfaceE[_ZN9QtPrivate17MetaObjectForTypeIPK11WalletModelvE18metaObjectFunctionEPKNS_18QMetaTypeInterfaceE]+0x2b): undefined reference to `WalletModel::staticMetaObject'
  /usr/bin/ld: libbitcoinqt.a(rpcconsole.cpp.o): in function `QMetaTypeIdQObject<WalletModel const*, 8>::qt_metatype_id()':
  /usr/include/x86_64-linux-gnu/qt6/QtCore/qmetatype.h:1313:(.text._ZZN9QtPrivate16QMetaTypeForTypeIPK11WalletModelE17getLegacyRegisterEvENUlvE_4_FUNEv[_ZZN9QtPrivate16QMetaTypeForTypeIPK11WalletModelE17getLegacyRegisterEvENUlvE_4_FUNEv]+0x53): undefined reference to `WalletModel::staticMetaObject'
  collect2: error: ld returned 1 exit status
  gmake[3]: *** [src/qt/CMakeFiles/bitcoin-qt.dir/build.make:154: src/qt/bitcoin-qt] Error 1
  gmake[2]: *** [CMakeFiles/Makefile2:2107: src/qt/CMakeFiles/bitcoin-qt.dir/all] Error 2
  gmake[1]: *** [CMakeFiles/Makefile2:2114: src/qt/CMakeFiles/bitcoin-qt.dir/rule] Error 2
  gmake: *** [Makefile:998: bitcoin-qt] Error 2
  ```

  This PR resolves the issue.

ACKs for top commit:
  promag:
    ACK 5be34bacf6, all other changes in 33657e1c958146312e4c68765a92871920401396 are not required, makes the code harder to read.
  pablomartin4btc:
    tACK 5be34bacf6

Tree-SHA512: d10da665384e6539b8e9106dc905ba30e9e57cd4603fc7e5eb893fc899f55f26889c570687fa5daf55c6fc5bf4fcfcfcd9b70822cfe637f31f9151bb653b7941
2024-10-04 11:21:44 +01:00
Hennadii Stepanov
4be785b3e3
Merge bitcoin-core/gui#839: qt6, test: Handle deprecated code
5625840c11 qt6, test: Handle deprecated `QVERIFY_EXCEPTION_THROWN` (Hennadii Stepanov)
cb750b4b40 qt6, test: Use `qWarning()` instead of `QWARN()` macro (Hennadii Stepanov)

Pull request description:

  Split from https://github.com/bitcoin/bitcoin/pull/30997.

  This PR ensures compatibility across all supported Qt versions.

  ---

  This PR can be tested on macOS using the first commit from https://github.com/bitcoin/bitcoin/pull/30997 and Homebrew's `qt` package.

ACKs for top commit:
  promag:
    Code review ACK 5625840c11.
  Sjors:
    tACK 5625840c11

Tree-SHA512: e7307eaf0027c6addc9481ba91ed31b81554ffb0d2ba77938e68915c9d490a7962e55a330f97ea31d49bbfb30f92773c3af3afc867a4215d00752405d7e3bb6d
2024-10-04 10:04:50 +01:00
Hennadii Stepanov
f117f3f747
Merge bitcoin-core/gui#838: qt6: Handle deprecated QLocale::nativeCountryName
9123a286e9 qt6: Handle deprecated `QLocale::nativeCountryName` (Hennadii Stepanov)

Pull request description:

  Split from https://github.com/bitcoin/bitcoin/pull/30997.

  [`QLocale::nativeCountryName()`](https://doc.qt.io/qt-6/qlocale-obsolete.html#nativeCountryName) has been deprecated since Qt 6.6.

  [`QLocale::nativeTerritoryName()`](https://doc.qt.io/qt-6/qlocale.html#nativeTerritoryName) was introduced in Qt 6.2.

  This PR ensures compatibility across all supported Qt versions.

  No behaviour change for the current codebase, which uses Qt 5.

  ---

  This PR can be tested on macOS using the first commit from https://github.com/bitcoin/bitcoin/pull/30997 and Homebrew's `qt` package.

ACKs for top commit:
  promag:
    Code review ACK 9123a286e9.
  jarolrod:
    ACK 9123a286e9

Tree-SHA512: 937258ab90f41077b0c9b1489e05104e3558b5da522b9dcd07fe373826aa671b2388539425f38c43fcde22419cdb8694cdcb04574d92b773acdb80f9a4fb1c02
2024-10-03 20:19:08 +01:00
Hennadii Stepanov
5625840c11
qt6, test: Handle deprecated QVERIFY_EXCEPTION_THROWN
This change ensures compatibility across all supported Qt versions.

Co-Authored-By: João Barbosa <joao.paulo.barbosa@gmail.com>
2024-10-03 19:56:50 +01:00
glozow
cfb59da4b3
Merge bitcoin/bitcoin#30980: fuzz: fix bug in p2p_headers_presync harness
a7498cc7e2 Fix bug in p2p_headers_presync harness (marcofleon)

Pull request description:

  The calculation for the test chain's work (`total_work`) should be outside of the loop. Previously, `total_work` was being miscalculated due to multiple additions of work from the same headers. Now, each header's work is only counted once, providing an accurate total.

  https://github.com/bitcoin/bitcoin/pull/30918 followup

ACKs for top commit:
  dergoegge:
    utACK a7498cc7e2
  instagibbs:
    ACK a7498cc7e2
  glozow:
    makes sense, utACK a7498cc7e2
  mzumsande:
    ACK a7498cc7e2

Tree-SHA512: b95f25dcf7ace220e30f1d72f50d85ee18777467927c0cc1ed8582b390cb7185ffc0e2f127309eb083044fb41f5a13fce5ebb15b7952718a899bafff26921be8
2024-10-02 21:20:26 -04:00
Ava Chow
dda2613239
Merge bitcoin/bitcoin#30929: log: Enforce trailing newline
fa2b7d8d6b Remove redundant unterminated-logprintf tidy check (MarcoFalke)
bbbb2e43ee log: Enforce trailing newline, Remove redundant m_started_new_line (MarcoFalke)

Pull request description:

  There are many problems around missing a trailing newline while logging:

  * All log lines are currently terminated by a trailing newline. This means any runtime code trying to handle a "missing" newline is currently dead code.
  * Leaving a line unterminated is racy and can cause content corruption by mixing log lines from different sources.
  * It requires extra code like `m_started_new_line` to keep track of, which is annoying and pointless to maintain, because it is currently dead code, see https://github.com/bitcoin/bitcoin/pull/30386#discussion_r1684380835.
  * It requires a standalone `unterminated-logprintf` clang-tidy plugin, which is unmaintained (no one updated it for the new log function names), probably harder to maintain than normal C++ code (because it requires clang AST matcher knowledge), brittle (it can fail to detect issues at any time, if it goes out-of-sync, or be explicitly disabled via `NOLINT`), and annoying for devs (it is slow and intricate to run locally and thus only effectively run on CI or via the CI scripts).

  Fix all issues by enforcing the trailing newline in logs directly in the code. Then remove all the other stuff.

  This refactor does not change behavior.

ACKs for top commit:
  stickies-v:
    re-ACK fa2b7d8d6b
  achow101:
    ACK fa2b7d8d6b
  ryanofsky:
    Code review ACK fa2b7d8d6b. Just comment and test cleanup since last review

Tree-SHA512: 10ed420f6c2fdb0f491d6c880be8dd2e8beef628f510adebadf4c3849d9f5e28906519d5cbaeb295f4c7c1b07c4c88a9905b3cfe30fee3a2c91ac9fd24ae6755
2024-10-02 19:05:34 -04:00
tdb3
34a9c10e8c
rpc: add getorphantxs
Adds an rpc to obtain data about the
transactions currently in the orphanage.
Hidden and marked as experimental
2024-10-02 18:23:18 -04:00
tdb3
f511ff3654
refactor: move verbosity parsing to rpc/util
Provides a common way for rpcs to obtain
verbosity from an rpc parameter
2024-10-02 18:16:06 -04:00
tdb3
532491faf1
net: add GetOrphanTransactions() to PeerManager
Updates PeerManager (and Impl) to provide
orphans with metadata
2024-10-01 21:55:18 -04:00
tdb3
91b65adff2
refactor: add OrphanTxBase for external use
Enables external entities to obtain orphan
information
2024-10-01 21:55:12 -04:00
Ryan Ofsky
d51edecddc common: move pcp.cpp and netif.cpp files from util to common library since they depend on netaddress.cpp
Prevents check-deps.sh errors reported by fanquake
https://github.com/bitcoin/bitcoin/pull/30415#issuecomment-2385475097
2024-10-01 09:28:31 -04:00
MarcoFalke
bbbb2e43ee
log: Enforce trailing newline, Remove redundant m_started_new_line
All log lines already have a trailing newline, but enforcing it allows
to delete unused code.
2024-10-01 11:31:39 +02:00
MarcoFalke
bbbbaa0d9a
Fix unsigned integer overflows in interpreter 2024-10-01 10:45:44 +02:00
MarcoFalke
fa22e5c430
refactor: Remove dead code that assumed tip == nullptr
The tip is set after waiting for the genesis block.
2024-10-01 09:12:32 +02:00
MarcoFalke
fa2e443965
refactor: Replace g_genesis_wait_cv with m_tip_block_cv
They achieve the same, but the extra indirection over boost::signals2 is
not needed.
2024-10-01 09:12:05 +02:00
MarcoFalke
fa7f52af1a
refactor: Use wait_for predicate to check for interrupt
Also use uint256::ZERO where appropriate for self-documenting code.
2024-10-01 09:11:08 +02:00
Ryan Ofsky
5ca28ef28b refactor: Split up NodeContext shutdown_signal and shutdown_request
Instead of having a single NodeContext::shutdown member that is used both to
request shutdowns and check if they have been requested, use separate members
for each. Benefits of this change:

1. Should make code a little clearer and easier to search because it is easier
   to see which parts of code are triggering shutdowns and which parts are just
   checking to see if they were triggered.

2. Makes it possible for init.cpp to specify additional code to run when a
   shutdown is requested, like signalling the m_tip_block_cv condition variable.

Motivation for this change was to remove hacky NodeContext argument and
m_tip_block_cv access from the StopRPC function, so StopRPC can just be
concerned with RPC functionality, not other node functionality.
2024-10-01 09:10:54 +02:00
MarcoFalke
fad8e7fba7
bugfix: Mark m_tip_block_cv as guarded by m_tip_block_mutex
This is not strictly required, but all places using m_tip_block_cv
(except shutdown) already take the lock. The annotation makes it easier
to catch potential deadlocks before review.

Adding the missing lock to the shutdown sequence is a bugfix.

An alternative would be to take the lock and release it before
notifying, see
https://github.com/bitcoin/bitcoin/pull/30967#discussion_r1778899716
2024-10-01 09:10:54 +02:00
MarcoFalke
fa18586c29
refactor: Add missing GUARDED_BY(m_tip_block_mutex)
Found by Cory Fields in
https://github.com/bitcoin/bitcoin/pull/30409#discussion_r1774001261
2024-10-01 09:10:01 +02:00
MarcoFalke
fa4c075033
doc: Clarify waitTipChanged docs
It should be obvious that a wait is not needed if the tip does not
match.

Also, remove a comment that the blockTip notification was only meant for
the "UI". (It is used by other stuff for a long time)
2024-10-01 09:08:37 +02:00
Ava Chow
d7f956a309
Merge bitcoin/bitcoin#30968: init: Remove retry for loop
e9d60af988 refactor: Replace init retry for loop with if statement (TheCharlatan)
c1d8870ea4 refactor: Move most of init retry for loop to a function (TheCharlatan)
781c01f580 init: Check mempool arguments in AppInitParameterInteractions (TheCharlatan)

Pull request description:

  The for loop around the chain loading logic in `init.cpp` allows users of the GUI to retry once on failure with reindexing without having to manually set the reindex flag on startup. However this current mechanism has problems:

  * It is badly documented and has led to confusion among developers and bugs making it into master. Examples:
      * https://github.com/bitcoin/bitcoin/pull/28830/files#r1598392660
      * https://github.com/bitcoin/bitcoin/pull/30132#issuecomment-2120741121
  * It can only ever iterate once, making the choice of a for loop questionable.
  * With its large scope it is easy for re-entry bugs to sneak in. Example:
      * https://github.com/bitcoin/bitcoin/pull/28830#discussion_r1601589963

  Attempt to fix this by moving the bulk of the logic into a separate function and replacing the for loop with a simpler `if` statement.

  The diff's in this pull request are best reviewed with `--color-moved-ws=ignore-all-space --color-moved=dimmed-zebra`. The error behaviour can be tested by either manually making `LoadChainstate` return a failure, or deleting some of the block index database files.

ACKs for top commit:
  maflcko:
    review ACK e9d60af988 🚸
  josibake:
    crACK e9d60af988
  achow101:
    ACK e9d60af988
  ryanofsky:
    Code review ACK e9d60af988. Nice change to make AppInitMain shorter and more understandable.

Tree-SHA512: 5e5c0a5fd1b32225346450f8482f0ae8792e1557cdab1518112c1a3ec3a4400b64f5796692245cc5bf2f9010bb97b3a9558f07626a285ccd6ae525dd671ead13
2024-09-30 17:01:05 -04:00
Ava Chow
c33eb2360e
Merge bitcoin/bitcoin#30043: net: Replace libnatpmp with built-in PCP+NATPMP implementation
5c7cacf649 ci: Remove natpmp build option and libnatpmp dependency (laanwj)
7e7ec984da doc: Remove mention of natpmp build options (laanwj)
061c3e32a2 depends: Drop natpmp and associated option from depends (laanwj)
20a18bf6aa build: Drop libnatpmp from build system (laanwj)
7b04709862 qt: Changes for built-in PCP+NAT-PMP (laanwj)
52f8ef66c6 net: Replace libnatpmp with built-in NATPMP+PCP implementation in mapport (laanwj)
97c97177cd net: Add PCP and NATPMP implementation (laanwj)
d72df63d16 net: Use GetLocalAddresses in Discover (laanwj)
e02030432b net: Add netif utility (laanwj)
754e425438 crypto: Add missing WriteBE16 function (laanwj)

Pull request description:

  Continues #30005. Closes #17012..

  This PR adds PCP (Port Control Protocol) from [RFC6887](https://datatracker.ietf.org/doc/html/rfc6887).  This adds, in addition to the existing IPv4 port mapping (which now uses PCP, with fallback to NAT-PMP), support for IPv6 pinholing-that is, opening a port on the firewall to make it reachable.

  PCP, like NAT-PMP is a simple UDP-based protocol, and the implementation is self-contained, so this gets rid of lthe libnatpnp dependency without adding a new one. It should otherwise be a drop-in replacement. NAT-PMP fallback is implemented so this will not make router support worse.

  For now it is disabled by default, though in the future (not in this PR) we could consider enable it by default to increase the number of connectable nodes without adding significant attack surface.

  To test:
  ```bash
  bitcoind -regtest -natpmp=1 -debug=net
  ```

  (most of the changes in this PR are, ironically, removing the libnatpmp dependency and associated build system and build docs)

  ## TODO

  - [x] Default gateway discovery on Linux / FreeBSD
  - [x] Default gateway discovery on Windows
  - [x] Default gateway discovery on MacOS
  - [x] Either solve FreeBSD compile issue (probably upstream issue) or remove FreeBSD support

  ## Things to consider for follow-up PRs

  - https://github.com/bitcoin/bitcoin/pull/30043#discussion_r1658764974 avoid unreachable nets (not given to -onlynet=)

  - https://github.com/bitcoin/bitcoin/pull/30043#discussion_r1658949236 could announce an addr:port where we do not listen (no -bind)

  - https://github.com/bitcoin/bitcoin/pull/30043#discussion_r1684368824 could announce the wrong port because it uses GetListenPort()

  - https://github.com/bitcoin/bitcoin/pull/30043#discussion_r1679709347 if we requested one port but another was assigned, then which one to use in the renewal?

  - https://github.com/bitcoin/bitcoin/pull/30043#discussion_r1772017020 Use `GetAdapterAddresses` to discover local addresses for Windows

ACKs for top commit:
  Sjors:
    ACK 5c7cacf649
  achow101:
    ACK 5c7cacf649
  vasild:
    ACK 5c7cacf649

Tree-SHA512: e35b69e56d5f5449a3d48a799f9b7b65107c65eeb3e245c2c1e9d42221e469ca5ead90afae423160601cd664dd553a51c859e04f4492f335b064aae3bf23e3bc
2024-09-30 16:27:47 -04:00
laanwj
20a18bf6aa build: Drop libnatpmp from build system 2024-09-30 11:37:55 +02:00
laanwj
7b04709862 qt: Changes for built-in PCP+NAT-PMP
Change option help, and remove conditionals.
2024-09-30 11:37:55 +02:00
laanwj
52f8ef66c6 net: Replace libnatpmp with built-in NATPMP+PCP implementation in mapport 2024-09-30 11:37:55 +02:00
laanwj
97c97177cd net: Add PCP and NATPMP implementation
Add a RFC 6886 NATPMP and RFC 6887 Port Control Protocol (PCP)
implementation, to replace libnatpmp.
2024-09-30 11:37:55 +02:00
Hennadii Stepanov
cb750b4b40
qt6, test: Use qWarning() instead of QWARN() macro
The `QWARN()` macro internally uses `QTest::qWarn()`, which has been
deprecated since Qt 6.3. Replacing it with `qWarning()` ensures
compatibility across all Qt versions.
2024-09-29 14:20:08 +01:00
Hennadii Stepanov
9123a286e9
qt6: Handle deprecated QLocale::nativeCountryName
This change ensures compatibility across all supported Qt versions.
2024-09-29 12:05:12 +01:00
brunoerg
c495731a31 fuzz: wallet: add target for CreateTransaction 2024-09-27 13:53:53 -03:00
brunoerg
3db68e29ec wallet: move ImportDescriptors/FuzzedWallet to util 2024-09-27 13:53:52 -03:00
merge-script
18d4c43cab
Merge bitcoin/bitcoin#30921: test: generalize HasReason and use it in FailFmtWithError
6c3c619b35 test: generalize HasReason and use it in FailFmtWithError (Lőrinc)

Pull request description:

  Standardized boost exception checking in recent tests introduced in https://github.com/bitcoin/bitcoin/pull/30546#discussion_r1756493521 by extending `HasReason` to accept `const char*` through `string_view` in `operator()`.

  Note that `HasReason` only checks partial matches - but since we're specifying the whole error string, it doesn't affect us in this case.

ACKs for top commit:
  maflcko:
    review ACK 6c3c619b35
  hodlinator:
    ACK 6c3c619b35

Tree-SHA512: 740fb18b8fea78e4eb9740ceb0fe75d37246c28cfa2638b9d093e9514dd6d7926cc5be9ec57f8027cca3aa9d616e8c54322d2401cfa67fd25282f7816e63532d
2024-09-27 10:56:57 +01:00