Commit graph

26304 commits

Author SHA1 Message Date
Hennadii Stepanov
85f50a46c5
refactor: Fix "error C2248: cannot access private member" on MSVC 2024-04-28 07:11:24 +01:00
merge-script
3aaf7328eb
Merge bitcoin/bitcoin#29774: build: Enable fuzz binary in MSVC
18fd522ca9 ci, msvc: Add "Run fuzz binaries" step (Hennadii Stepanov)
52933d7283 fuzz: Pass `SystemRoot` environment variable to subprocess (Hennadii Stepanov)
23cb8207cd ci, msvc: Add "Clone fuzz corpus" step (Hennadii Stepanov)
19dceddf4b build, msvc: Build `fuzz.exe` binary (Hennadii Stepanov)
4c078d7bd2 build, msvc: Enable preprocessor conformance mode (Hennadii Stepanov)
09f5a74198 fuzz: Re-implement `read_stdin` in portable way (Hennadii Stepanov)

Pull request description:

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

  Suggested in https://github.com/bitcoin/bitcoin/pull/29758#issuecomment-2025593572.

ACKs for top commit:
  maflcko:
    lgtm ACK 18fd522ca9 🔍
  sipsorcery:
    tACK 18fd522ca9
  sipa:
    utACK 18fd522ca9

Tree-SHA512: 672ed6926ee9091f68f13780e77b60fc1d48731f16e847d849374f8426ffe1dafd9bcab06a27af62e8052ba345bb57f20f40579d6be8540c12ef85c23a6eec8b
2024-04-28 10:55:01 +08:00
Martin Zumsande
5bc2077e8f validation: allow to specify frequency for -checkblockindex
This makes it similar to -checkaddrman and -checkmempool, which
also allow to run the check occasionally instead of always / never.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2024-04-26 13:31:28 -04:00
Martin Zumsande
d5a631b959 validation: improve performance of CheckBlockIndex
by not saving all indexes in a std::multimap, but only
those that are not part of the best header chain.
The indexes of the best header chain are stored in a vector,
which, in the typical case of a mostly linear chain with
a few forks, results in a much smaller multimap, and increases
performance noticeably for long chains.

This does not change the actual consistency checks that are being
performed for each index, just the way the block index tree is
stored and traversed.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2024-04-26 13:31:28 -04:00
Sergi Delgado Segura
a8d9a0edc7 test: adds outbound eviction functional tests, updates comment in ConsiderEviction 2024-04-26 11:14:20 -04:00
glozow
87c5c524d6 [p2p] opportunistically accept 1-parent-1-child packages 2024-04-26 11:27:37 +01:00
glozow
6c51e1d7d0 [p2p] add separate rejections cache for reconsiderable txns 2024-04-26 10:28:27 +01:00
glozow
410ebd6efa [fuzz] break out parent functions and add GetChildrenFrom* coverage
It's very hard to randomly construct a transaction that would be the
parent of an existing orphanage tx. For functions like
AddChildrenToWorkSet and GetChildren that take orphan parents, use a tx
that was previously constructed.
2024-04-26 10:28:27 +01:00
glozow
d095316c1c [unit test] TxOrphanage::GetChildrenFrom* 2024-04-26 10:28:27 +01:00
glozow
2f51cd680f [txorphanage] add method to get all orphans spending a tx 2024-04-26 10:28:27 +01:00
glozow
092c978a42 [txpackages] add canonical way to get hash of package 2024-04-26 10:28:27 +01:00
MarcoFalke
fa55972a75
test: Add two more urlDecode tests 2024-04-26 08:33:56 +02:00
Ryan Ofsky
6a8b2befea refactor: Avoid copying util::Result values
Copying util::Result values is less efficient than moving them because they
allocate memory and contain strings. Also this is needed to avoid compile
errors in https://github.com/bitcoin/bitcoin/pull/25722 which adds a
std::unique_ptr member to util::Result which implicity disables copying.
2024-04-25 16:08:24 -04:00
Ava Chow
2eff198f49
Merge bitcoin/bitcoin#28834: net: attempts to connect to all resolved addresses when connecting to a node
fd81a37239 net: attempts to connect to all resolved addresses when connecting to a node (Sergi Delgado Segura)

Pull request description:

  This is a follow-up of #28155 motivated by https://github.com/bitcoin/bitcoin/pull/28155#discussion_r1362677038

  ## Rationale

  Prior to this, when establishing a network connection via `CConnman::ConnectNode`, if the connection needed address resolution, a single address would be picked at random from the resolved addresses and our node would try to connect to it. However, this would lead to the behavior of `ConnectNode` being unpredictable when the address was resolved to various ips (e.g. the address resolving to IPv4 and IPv6, but we only support one of them).

  This patches the aforementioned behavior by going over all resolved IPs until a valid one is found or until we
  exhaust them.

ACKs for top commit:
  mzumsande:
    re-ACK fd81a37239 (just looked at diff, only small logging change)
  achow101:
    ACK fd81a37239
  vasild:
    ACK fd81a37239

Tree-SHA512: fa1ebc5c84fe61dd0a7fe1113ae2d594a75ad661c43ed8984a31fc9bc50f166b2759b0d8d84ee5dc247691eff78c8156fac970af797bbcbf67492eec0353fb58
2024-04-25 16:08:24 -04:00
Ryan Ofsky
834f65e824 refactor: Drop util::Result operator=
`util::Result` objects are aggregates that can hold multiple fields with
different information. Currently Result objects can only hold a success value
of an arbitrary type or a single bilingual_str error message. In followup PR
https://github.com/bitcoin/bitcoin/pull/25722, Result objects may be able to
hold both success and failure values of different types, plus error and warning
messages.

Having a Result::operator= assignment operator that completely erases all
existing Result information before assigning new information is potentially
dangerous in this case. For example, code that looks like it is assigning a
warning value could erase previously-assigned success or failure values.
Conversely, code that looks like it is just assigning a success or failure
value could erase previously assigned error and warning messages.

To prevent potential bugs like this, disable Result::operator= assignment
operator.

It is possible in the future we may want to re-enable operator= in limited
cases (such as when implicit conversions are not used) or add a Replace() or
Reset() method that mimicks default operator= behavior. Followup PR
https://github.com/bitcoin/bitcoin/pull/25722 also adds a Result::Update()
method providing another way to update an existing Result object.

Co-authored-by: stickies-v <stickies-v@protonmail.com>
2024-04-25 16:08:24 -04:00
Ava Chow
0e2e7d1a35
Merge bitcoin/bitcoin#29867: index: race fix, lock cs_main while 'm_synced' is subject to change
65951e0418 index: race fix, lock cs_main while 'm_synced' is subject to change (Ryan Ofsky)

Pull request description:

  Fixes #29831 and #29863. Thanks to Marko for the detailed description of the issue.

  The race occurs because a block could be connected and its event signaled in-between reading the 'next block' and setting `m_synced` during the index initial synchronization. This is because `cs_main` is not locked through the process of determining the final index sync state.
  To address the issue, the `m_synced` flag set has been moved under `cs_main` guard.

ACKs for top commit:
  fjahr:
    Code review ACK 65951e0418
  achow101:
    ACK 65951e0418
  ryanofsky:
    Code review ACK 65951e0418

Tree-SHA512: 77286e22de164a27939d2681b7baa6552eb75e99c541d3b9631f4340d7dd01742667c86899b6987fd2d97799d959e0a913a7749b2b69d9e50505128cd3ae0e69
2024-04-25 14:12:13 -04:00
Ryan Ofsky
16a6174613
Merge bitcoin/bitcoin#29904: refactor: Use our own implementation of urlDecode
992c714451 common: Don't terminate on null character in UrlDecode (Fabian Jahr)
099fa57151 scripted-diff: Modernize name of urlDecode function and param (Fabian Jahr)
8f39aaae41 refactor: Remove hooking code for urlDecode (Fabian Jahr)
650d43ec15 refactor: Replace libevent use in urlDecode with our own code (Fabian Jahr)
46bc6c2aaa test: Add unit tests for urlDecode (Fabian Jahr)

Pull request description:

  Fixes #29654 (as a side-effect)

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

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

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

Tree-SHA512: 78f76ae7ab3b6710eab2aaac20f55eb0da7803e057eaa6220e865f328666a5399ef1a479702aaf630b2f974ad3aa15e2b6adac9c11bc8c3d4be21e8af1667fea
2024-04-25 13:02:43 -04:00
Sebastian Falbesoner
908c51fe4a remove commented out code in cpp-subprocess 2024-04-25 17:44:39 +02:00
Brandon Odiwuor
e504b1fa1f test: Add test case for spending bare multisig
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2024-04-25 16:22:58 +03:00
Sebastian Falbesoner
ff79adbe05 remove unused templates from cpp-subprocess
The templates `is_ready`, `param_pack`, and `has_type` are not used
anywhere, so let's remove them.
2024-04-25 02:04:31 +02:00
Fabian Jahr
992c714451
common: Don't terminate on null character in UrlDecode
The previous behavior was the result of casting the result returned from the libevent function evhttp_uridecode to std:string but this was probably not intended.
2024-04-24 23:27:50 +02:00
Fabian Jahr
099fa57151
scripted-diff: Modernize name of urlDecode function and param
-BEGIN VERIFY SCRIPT-
sed -i 's/urlDecode/UrlDecode/g' $(git grep -l 'urlDecode' ./src)
sed -i 's/urlEncoded/url_encoded/g' $(git grep -l 'urlEncoded' ./src)
-END VERIFY SCRIPT-
2024-04-24 23:26:24 +02:00
Fabian Jahr
8f39aaae41
refactor: Remove hooking code for urlDecode
The point of this was to be able to build bitcoin-tx and bitcoin-wallet without libevent, see #18504.

Now that we use our own implementation of urlDecode this is not needed anymore.

Co-authored-by: stickies-v <stickies-v@protonmail.com>
2024-04-24 23:23:38 +02:00
Fabian Jahr
650d43ec15
refactor: Replace libevent use in urlDecode with our own code 2024-04-24 23:23:34 +02:00
Fabian Jahr
46bc6c2aaa
test: Add unit tests for urlDecode
Co-authored-by: Lőrinc <pap.lorinc@gmail.com>
2024-04-24 22:21:06 +02:00
glozow
2a07c4662d
Merge bitcoin/bitcoin#29757: feefrac: avoid explicitly computing diagram; compare based on chunks
b22901dfa9 Avoid explicitly computing diagram; compare based on chunks (Pieter Wuille)

Pull request description:

  This merges the `BuildDiagramFromChunks` and `CompareFeeRateDiagram` introduced in #29242 into a single `CompareChunks` function, which operates on sorted chunk data rather than diagrams, instead computing the diagram on the fly.

  This avoids the need for the construction of an intermediary diagram object, and removes the slightly arbitrary "all diagrams must start at (0, 0)" requirement.

  Not a big deal, but I think the result is a bit cleaner and not really more complicated.

ACKs for top commit:
  glozow:
    reACK b22901d
  instagibbs:
    reACK b22901dfa9

Tree-SHA512: ca37bdf61d9a9cb5435f4da73e97ead33bf65828ad9af49b87336b1ece70db8ced1c21f517fc6eb6d616311c91f3da75ecae6b9bd42547133e3a3c5320b7816d
2024-04-24 16:51:56 +01:00
merge-script
50729c0609
Merge bitcoin/bitcoin#29910: refactor: Rename subprocess.hpp to follow our header name conventions
08f756bd37 Replace locale-dependent `std::strerror` with `SysErrorString` (Hennadii Stepanov)
d8e4ba4d05 refactor: Rename `subprocess.hpp` to follow our header name conventions (Hennadii Stepanov)

Pull request description:

  This PR renames the header `*.hpp` --> `*.h` and adjusts the header guard name, which makes it available for processing by linters.

  Fixed the following linter warning:
  ```
  The locale dependent function strerror(...) appears to be used:
  src/util/subprocess.h:    std::runtime_error( err_msg + ": " + std::strerror(err_code) )

  Unnecessary locale dependence can cause bugs that are very tricky to isolate and fix. Please avoid using locale-dependent functions if possible.

  Advice not applicable in this specific case? Add an exception by updating the ignore list in /bitcoin/test/lint/lint-locale-dependence.py
  ^---- failure generated from lint-locale-dependence.py
  ```

ACKs for top commit:
  TheCharlatan:
    ACK 08f756bd37

Tree-SHA512: 57a2f01c20eb9552481e428a4969bd59e9ada9f784fe1a45cb62aa9c9152c8e950d336854f45af0e2e5dc7c7b2a1fb216c8f832e3d6ccfb457ad71b6e423231e
2024-04-24 22:57:50 +08:00
merge-script
c143244ce3
Merge bitcoin/bitcoin#29853: sign: don't assume we are parsing a sane TapMiniscript
4d8d21320e sign: don't assume we are parsing a sane Miniscript (Antoine Poinsot)

Pull request description:

  The script provided for signature might be externally provided, for instance by way of 'finalizepsbt'. Therefore the script might be ill-crafted, so don't assume pubkeys are always 32 bytes.

  Thanks to Niklas for finding this.

  FIxes https://github.com/bitcoin/bitcoin/issues/29851.

ACKs for top commit:
  achow101:
    ACK 4d8d21320e
  furszy:
    ACK 4d8d21320e with a small nuance that could be tackled in a follow-up by someone else (or never).

Tree-SHA512: 29b7948b56e6dc05eac1014d684f2129ab1d19cb1e5d304216c826b7057c0e1d84ceb18731b91124b680e17d90e38de9f9a5526e4f6ecc3ea816881a6599bb47
2024-04-24 21:14:26 +08:00
merge-script
9e0e51b1d9
Merge bitcoin/bitcoin#29870: rpc: Reword SighashFromStr error message
fa6ab0d020 rpc: Reword SighashFromStr error message (MarcoFalke)

Pull request description:

  Put quotes around the parameter. In theory, `std::quoted` should be used, but that seems overkill.

  This should avoid error messages such as `A valid sighash parameter is not a valid sighash parameter. (code -8)`.

  Also, it should fix fuzz false positives when searching for internal bugs in the `rpc` fuzz target. For example, `ZGVzY3JpcHRvcnByb2Nlc3Nwc2J0XP9ce1tdXOVJbnRlcm5hbCBidWcgZGV0ZWN0ZWQAXQ0AHfcAXQ1p7TJv`.

ACKs for top commit:
  dergoegge:
    ACK fa6ab0d020
  brunoerg:
    utACK fa6ab0d020

Tree-SHA512: e2c0cc0126de61873a863af38b7b0a23d2dadd596ca0418dae2ad091e8acfb6a9d657c376d59187bb008989dc78c6b44fe518590e5217e4049a867b220c9fb18
2024-04-24 20:55:27 +08:00
merge-script
19d59c9cc6
Merge bitcoin/bitcoin#29882: netbase: clean up Proxy logging
fb4cc5f423 netbase: clean up Proxy logging (Matthew Zipkin)

Pull request description:

  Follow up to #27375 and see https://github.com/bitcoin/bitcoin/pull/29649#issuecomment-2057456834

  This removes an extra log message when we can't connect to our own proxy, and another when the proxy is invalid.

  ## Before #27375 if proxy is unreachable

  ```
  2024-04-15T17:54:51Z connect() to 127.0.0.1:9999 failed after wait: Connection refused (61)
  2024-04-15T17:54:52Z connect() to 127.0.0.1:9999 failed after wait: Connection refused (61)
  2024-04-15T17:54:52Z connect() to 127.0.0.1:9999 failed after wait: Connection refused (61)
  2024-04-15T17:54:53Z connect() to 127.0.0.1:9999 failed after wait: Connection refused (61)
  2024-04-15T17:54:53Z connect() to 127.0.0.1:9999 failed after wait: Connection refused (61)
  ```

  ## After #27375 if unix proxy is unreachable:

  ```
  2024-04-15T17:54:03Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2)
  2024-04-15T17:54:03Z Cannot connect to socket for /Users/matthewzipkin/Desktop/tor
  2024-04-15T17:54:04Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2)
  2024-04-15T17:54:04Z Cannot connect to socket for /Users/matthewzipkin/Desktop/tor
  2024-04-15T17:54:04Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2)
  2024-04-15T17:54:04Z Cannot connect to socket for /Users/matthewzipkin/Desktop/tor
  2024-04-15T17:54:05Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2)
  2024-04-15T17:54:05Z Cannot connect to socket for /Users/matthewzipkin/Desktop/tor
  ```

  ## After this PR:

  ```
  2024-04-15T18:18:51Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2)
  2024-04-15T18:18:51Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2)
  2024-04-15T18:18:52Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2)
  2024-04-15T18:18:52Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2)
  ```

ACKs for top commit:
  tdb3:
    CR ACK for fb4cc5f423
  laanwj:
    ACK fb4cc5f423

Tree-SHA512: f07b9f7f2ea9f4bc01780c09f0b076547108294a1fa7d158a0dd48d6d7351569e461e5cccf232b7b1413ce2e3679668e523e5a7c89cd58c909da76d3dcbc34de
2024-04-24 19:14:48 +08:00
Ava Chow
a7129f827c
Merge bitcoin/bitcoin#24313: Improve display address handling for external signer
4357158c47 wallet: return and display signer error (Sjors Provoost)
dc55531087 wallet: compare address returned by displayaddress (Sjors Provoost)
6c1a2cc09a test: use h marker for external signer mock (Sjors Provoost)

Pull request description:

  * HWI returns the requested address: as a sanity check, we now compare that to what we expected
     * external signer documentation now reflects that HWI alternatives must implement this check
  * both RPC and GUI will now return an error text, rather than just fail (the GUI even failed silently in some cases)

ACKs for top commit:
  brunoerg:
    ACK 4357158c47
  achow101:
    ACK 4357158c47

Tree-SHA512: 4f56edf3846745c8e7d08ef55cf29e8bb468256457149377c5f02da097931f9ca0c06bdbd856dc2385cde4fd11e4dc3b634c5a48814ff27f5562c8a25d43da93
2024-04-23 17:20:54 -04:00
Hennadii Stepanov
08f756bd37
Replace locale-dependent std::strerror with SysErrorString 2024-04-23 18:22:58 +01:00
Hennadii Stepanov
d8e4ba4d05
refactor: Rename subprocess.hpp to follow our header name conventions 2024-04-23 18:22:58 +01:00
Ava Chow
2cecbbb986
Merge bitcoin/bitcoin#29865: util: remove unused cpp-subprocess options
13adbf733f remove unneeded environment option from cpp-subprocess (Sebastian Falbesoner)
2088777ba0 remove unneeded cwd option from cpp-subprocess (Sebastian Falbesoner)
03ffb09c31 remove unneeded bufsize option from cpp-subprocess (Sebastian Falbesoner)
79c3036373 remove unneeded close_fds option from cpp-subprocess (Sebastian Falbesoner)
62db8f8e5a remove unneeded session_leader option from cpp-subprocess (Sebastian Falbesoner)
80d008c66d remove unneeded defer_spawn option from cpp-subprocess (Sebastian Falbesoner)
cececad7b2 remove unneeded preexec function option from cpp-subprocess (Sebastian Falbesoner)
633e45b2e2 remove unneeded shell option from cpp-subprocess (Sebastian Falbesoner)

Pull request description:

  The newly introduced cpp-subprocess library provides a good number of options for the `Popen` class:
  0de63b8b46/src/util/subprocess.hpp (L1009-L1020)
  Some of them are either not fully implemented (`shell`, missing an implementation on Windows), implemented in an ugly way (e.g. using "Impoverished, meager, needy, truly needy version of type erasure" for `preexec_func` according to the author's own words) or simply unlikely to be ever needed for our external signer use-case (`defer_spawn`). Instead of maintaining incomplete and/or unneeded code, I'd suggest to get rid of it and only keep support for options if there is a strong reason for it.

ACKs for top commit:
  achow101:
    ACK 13adbf733f
  hebasto:
    re-ACK 13adbf733f.

Tree-SHA512: 8270da27891cb659da2ef6062a23f4b86331859b15ac27b79ae7433b14f5bd7efaba621f2b3ba1953708d0f38377a8bd23ef1cc0f28b9c152ac8958dd9eec6b0
2024-04-23 13:04:25 -04:00
Sebastian Falbesoner
13adbf733f remove unneeded environment option from cpp-subprocess 2024-04-23 15:10:19 +02:00
Ava Chow
dec74c035b
Merge bitcoin/bitcoin#29657: Bugfix: bitcoin-cli: Check length of peer.transport_protocol_type
c3e632b441 Bugfix: bitcoin-cli: Check length of peer.transport_protocol_type (Luke Dashjr)

Pull request description:

  "v" would dereference beyond the string length, and "v10" would show as '1'

  Turn both of these cases into a blank, like anything else unexpected currently is.

ACKs for top commit:
  sipa:
    utACK c3e632b441.
  hernanmarino:
    utACK c3e632b441
  alfonsoromanz:
    ACK c3e632b441
  achow101:
    ACK c3e632b441

Tree-SHA512: f641e4412521adae7c8c8e1f268bdaaa223d9048d8286e3df4b13905faaa0d601155ce581cd649f760cab2acc4122356fa94a44714f1f190845552100105eda0
2024-04-22 18:04:27 -04:00
tdb3
82f41d76f1 Added seednode prioritization message to help output 2024-04-22 14:07:14 -04:00
Sergi Delgado Segura
3120a4678a Gives seednode priority over dnsseed if both are provided 2024-04-22 14:07:12 -04:00
Antoine Poinsot
4d8d21320e
sign: don't assume we are parsing a sane Miniscript
The script provided for signature might be externally provided, for
instance by way of 'finalizepsbt'. Therefore the script might be
ill-crafted, so don't assume pubkeys are always 32 bytes.

Thanks to Niklas for finding this.
2024-04-22 18:24:35 +02:00
Ava Chow
3310a965bd
Merge bitcoin/bitcoin#29850: net: Decrease nMaxIPs when learning from DNS seeds
f2e3662e57 net: Decrease nMaxIPs when learning from DNS seeds (laanwj)

Pull request description:

  Limit number of IPs learned from a single DNS seed to 32, to prevent the results from one DNS seed from dominating AddrMan. Note that the number of results from a UDP DNS query is bounded to 33 already, but it is possible for it to use TCP where a larger number of results can be returned.

  Closes #16070.

ACKs for top commit:
  Sjors:
    utACK f2e3662e57
  achow101:
    ACK f2e3662e57
  1440000bytes:
    utACK f2e3662e57
  mzumsande:
    utACK f2e3662e57

Tree-SHA512: 3f108c2baba7adfedb8019daaf60aa00e628b38d3942e1319c7183a4683670be01929ced9e6372c8e983c902e8633f81fbef12d7cdcaadd7f77ed729c1019942
2024-04-22 12:16:15 -04:00
Ava Chow
04c90f1059
Merge bitcoin/bitcoin#27679: ZMQ: Support UNIX domain sockets
21d0e6c7b7 doc: release notes for PR 27679 (Matthew Zipkin)
791dea204e test: cover unix sockets in zmq interface (Matthew Zipkin)
c87b0a0ff4 zmq: accept unix domain socket address for notifier (Matthew Zipkin)

Pull request description:

  This is a follow-up to https://github.com/bitcoin/bitcoin/pull/27375, allowing ZMQ notifications to be published to a UNIX domain socket.

  Fortunately, libzmq handles unix sockets already, all we really have to do to support it is allow the format in the actual option.

  [libzmq](https://libzmq.readthedocs.io/en/latest/zmq_ipc.html) uses the prefix `ipc://` as opposed to `unix:` which is [used by Tor](https://gitlab.torproject.org/tpo/core/tor/-/blob/main/doc/man/tor.1.txt?ref_type=heads#L1475) and now also by [bitcoind](a85e5a7c9a/doc/release-notes-27375.md (L5)) so we need to switch that internally.

  As far as I can tell, [LND](d20a764486/zmq.go (L38)) supports `ipc://` and `unix://` (notice the double slashes).

  With this patch, LND can connect to bitcoind using unix sockets:

  Example:

  *bitcoin.conf*:
  ```
  zmqpubrawblock=unix:/tmp/zmqsb
  zmqpubrawtx=unix:/tmp/zmqst
  ```

  *lnd.conf*:
  ```
  bitcoind.zmqpubrawblock=ipc:///tmp/zmqsb
  bitcoind.zmqpubrawtx=ipc:///tmp/zmqst
  ```

ACKs for top commit:
  laanwj:
    Code review ACK 21d0e6c7b7
  tdb3:
    crACK for 21d0e6c7b7.  Changes lgtm. Will follow up with some testing within the next few days as time allows.
  achow101:
    ACK 21d0e6c7b7
  guggero:
    Tested and code review ACK 21d0e6c7b7

Tree-SHA512: ffd50222e80dd029d903e5ddde37b83f72dfec1856a3f7ce49da3b54a45de8daaf80eea1629a30f58559f4b8ded0b29809548c0638cd1c2811b2736ad8b73030
2024-04-22 11:24:43 -04:00
Pieter Wuille
b22901dfa9 Avoid explicitly computing diagram; compare based on chunks 2024-04-22 09:36:36 -04:00
glozow
ba7c67f609
Merge bitcoin/bitcoin#29879: fuzz: explicitly cap the vsize of RBFs for diagram checks
016ed248ba fuzz: explicitly cap the vsize of RBFs for diagram checks (Greg Sanders)

Pull request description:

  In master we are hitting a case where vsize transactions much larger than max standard size are causing an overflow in not-yet-exposed RBF diagram checking code: https://github.com/bitcoin/bitcoin/pull/29757#issuecomment-2049220195

  `ConsumeTxMemPoolEntry` is creating entries with tens of thousands of sigops cost, causing the resulting RBFs to be "overly large".

  To fix this I cause the fuzz test to stop adding transactions to the mempool when we reach a potential overflow of `int32_t`.

ACKs for top commit:
  glozow:
    ACK 016ed248ba
  marcofleon:
    ACK 016ed248ba. I ran libFuzzer on `package_rbf` on the current master branch until the overflow was encountered. Then I built the PR branch and ran the fuzzer using the crash input.

Tree-SHA512: b3ffc98d2c4598eb3010edd58b9370aab1441aafbb1044c83b2b90c17dfe9135b8de9dba475dd0108863c1ffedede443cd978e95231a41cf1f0715629197fa51
2024-04-22 12:33:06 +01:00
Sergi Delgado Segura
fd81a37239 net: attempts to connect to all resolved addresses when connecting to a node
Prior to this, when establishing a network connection via CConnman::ConnectNode,
if the connection needed address resolution, a single address would be picked
at random from the resolved addresses and our node will try to connect to it. However,
this would lead to the behavior of ConnectNode being unpredictable when the address
was resolved to various ips (e.g. the address resolving to IPv4 and IPv6, but we only
support one of them).

This patches the aforementioned behavior by going over all resolved IPs until we find one
we can connect to or until we exhaust them.
2024-04-18 10:05:57 -04:00
Hennadii Stepanov
976e5d8f7b
test: Fix test/streams_tests.cpp compilation on SunOS / illumos
On systems where `int8_t` is defined as `char`, the
`{S,Uns}erialize(Stream&, signed char)` functions become undefined.

This change resolves the issue by testing
`{S,Uns}erialize(Stream&, int8_t)` instead.

No behavior change on systems where `int8_t` is defined as
`signed char`, which is the case for most other systems.
2024-04-18 10:53:32 +01:00
Hennadii Stepanov
19dceddf4b
build, msvc: Build fuzz.exe binary 2024-04-18 10:27:25 +01:00
Hennadii Stepanov
09f5a74198
fuzz: Re-implement read_stdin in portable way 2024-04-18 10:18:44 +01:00
merge-script
c05c214f2e
Merge bitcoin-core/gui#808: Change example address from legacy (P2PKH) to bech32m (P2TR)
c6d1b8de89 gui: change example address from legacy (P2PKH) to bech32m (P2TR) (Sebastian Falbesoner)

Pull request description:

  Legacy addresses are less and less common these days and not recommended to use, so it seems senseful to also reflect that in the example addresses and update to the most recent address / output type (bech32m / P2TR). Also, as I couldn't see any value in computing these at runtime, they are pre-generated. This was done with the following Python script, executed in `./test/functional` (it's also included in the commit body, though without the she-bang):
  ```python
  #!/usr/bin/env python3
  from test_framework.segwit_addr import CHARSET, decode_segwit_address, encode_segwit_address
  from test_framework.messages import sha256

  output_key = sha256(b'bitcoin dummy taproot output key')
  for network, hrp in [('mainnet', 'bc'), ('signet', 'tb'), ('testnet', 'tb'), ('regtest', 'bcrt')]:
      dummy_address = encode_segwit_address(hrp, 1, output_key)
      while decode_segwit_address(hrp, dummy_address) != (None, None):
          last_char = CHARSET[(CHARSET.index(dummy_address[-1]) + 1) % 32]
          dummy_address = dummy_address[:-1] + last_char
      print(f'{network:7} example address: {dummy_address}')
  ```

  Note that the last bech32 character is modified in order to make the checksum fail.

  master (mainnet):

  ![image](https://github.com/bitcoin-core/gui/assets/91535/8c94cc1e-5649-47ed-8b2d-33b18654f6a2)

  PR (mainnet):

  ![image](https://github.com/bitcoin-core/gui/assets/91535/1ce208a6-1218-4850-93e0-5323c73e9049)

ACKs for top commit:
  maflcko:
    lgtm ACK c6d1b8de89
  pablomartin4btc:
    tACK c6d1b8de89

Tree-SHA512: a53c267a3e0d29b9c41bf043b123e7152fbf297e2322d74ce047ba2582b54768187162d462cc334e91a84874731c2e0793726ad44d9970c10ecfe70a1d4f3f1c
2024-04-18 10:05:05 +01:00
merge-script
aaab5fb3c5
Merge bitcoin-core/gui#806: refactor: Misc int sign change fixes
05416422d3 refactor: Avoid implicit-integer-sign-change in processNewTransaction (MarcoFalke)
321f105d08 refactor: Avoid implicit-signed-integer-truncation-or-sign-change in FreedesktopImage (MarcoFalke)
6d8eecd33a refactor: Avoid implicit-integer-sign-change in createTransaction (MarcoFalke)

Pull request description:

  This is allowed by the language. However, the `integer` sanitizer complains about it. Thus, fix it, so that the `integer` sanitizer can be used in the future to catch unintended sign changes.

  Fixes #805.

ACKs for top commit:
  pablomartin4btc:
    tACK 05416422d3
  hebasto:
    ACK 05416422d3, I have reviewed the code and it looks OK.

Tree-SHA512: eaa941479bd7bee196eb8b31d93b8e1db122410cf62e8ec4cbbec35cfd14cc766081c3df5dd14a228e21ad2678d8b8ba0d2649e5934c994a90ae96d8b264b4ce
2024-04-18 09:46:04 +01:00
Ryan Ofsky
65951e0418
index: race fix, lock cs_main while 'm_synced' is subject to change
This ensures that the index does not miss any 'new block' signals
occurring in-between reading the 'next block' and setting 'm_synced'.
Because, if this were to happen, the ignored blocks would never be
indexed, thus stalling the index forever.
2024-04-17 17:24:05 -03:00
merge-script
5562f698b7
Merge bitcoin/bitcoin#29875: chore: fix some typos in comments
b1ee4a557b chore: fix some typos in comments (StevenMia)

Pull request description:

  Fixes typos.

ACKs for top commit:
  fanquake:
    ACK b1ee4a557b

Tree-SHA512: 29a93db2091337ac6fd1e403f12b2c96be4c22e783a60dbf5b3e3988b962246b58705ca3c1274ed1ad2623f7632ac7eb90ca1e8b7e7992bc9d2f046f73cdf4d6
2024-04-17 14:02:22 +01:00
merge-script
c8e3b94744
Merge bitcoin/bitcoin#29892: test: Fix failing univalue float test
fa4c69669e test: Fix failing univalue float test (MarcoFalke)

Pull request description:

  Currently the test may fail for some compilers, because `1e-8` may not be possible to represent exactly/consistently.

  ```
  $ ./src/univalue/test/object
  object: univalue/test/object.cpp:424: void univalue_readwrite(): Assertion `v.read("0.00000000000000000000000000000000000001e+30 ") && v.get_real() == 1e-8' failed.
  Aborted (core dumped)
  ```

  Fixes https://github.com/bitcoin/bitcoin/pull/27256#discussion_r1567356943

ACKs for top commit:
  laanwj:
    ACK fa4c69669e
  stickies-v:
    ACK fa4c69669e , thanks for fixing!

Tree-SHA512: dea4f4f843381d5e8ffaa812b2290a11e081b29f8777d041751c4aa9942e60f1f8d2d1a652d9a52b41dec470a490c9fe26ca9bc762dd593c3521b328a8af2826
2024-04-17 08:57:34 +01:00
Matthew Zipkin
c87b0a0ff4
zmq: accept unix domain socket address for notifier 2024-04-16 14:14:37 -04:00
Ryan Ofsky
312f54278f
Merge bitcoin/bitcoin#29726: assumeutxo: Fix -reindex before snapshot was validated
b7ba60f81a test: add coverage for -reindex and assumeutxo (Martin Zumsande)
e57f951805 init, validation: Fix -reindex option with an existing snapshot (Martin Zumsande)

Pull request description:

  In c711ca186f logic was introduced that `-reindex` and `-reindex-chainstate` will delete the snapshot chainstate.
  This doesn't work currently, instead of deleting the snapshot chainstate the node crashes with an assert (this can be triggered by applying the added test commit on master).
  Fix this, and another bug that would prevent the new active chainstate from having a mempool after `-reindex` has deleted the snapshot (also covered by the test).

ACKs for top commit:
  fjahr:
    re-ACK b7ba60f81a
  hernanmarino:
    crACK b7ba60f81a . Good fix
  BrandonOdiwuor:
    re-ACK b7ba60f81a
  byaye:
    Tested ACK b7ba60f81a

Tree-SHA512: c168f36997d7677d590af37b10427870f5d30123abf1c76032a16661e486735373bfa7e049e6aca439526fbcb6d619f970bf9d042196c851bf058a75a32fafdc
2024-04-16 13:03:23 -04:00
Sjors Provoost
4357158c47
wallet: return and display signer error
Both RPC and GUI now render a useful error message instead of (silently) failing.

Replace bool with util::Result<void> to clarify that this either succeeds or returns an error message.
2024-04-16 17:47:43 +02:00
Sjors Provoost
dc55531087
wallet: compare address returned by displayaddress
Update external signer documentation to reflect this requirement, which HWI already implements.
2024-04-16 17:47:43 +02:00
Greg Sanders
016ed248ba fuzz: explicitly cap the vsize of RBFs for diagram checks 2024-04-16 11:27:59 -04:00
MarcoFalke
fa4c69669e
test: Fix failing univalue float test 2024-04-16 16:35:12 +02:00
Matthew Zipkin
fb4cc5f423
netbase: clean up Proxy logging 2024-04-16 10:24:02 -04:00
Sebastian Falbesoner
2088777ba0 remove unneeded cwd option from cpp-subprocess 2024-04-16 14:25:00 +02:00
Sebastian Falbesoner
03ffb09c31 remove unneeded bufsize option from cpp-subprocess 2024-04-16 14:25:00 +02:00
Sebastian Falbesoner
79c3036373 remove unneeded close_fds option from cpp-subprocess 2024-04-16 14:25:00 +02:00
Sebastian Falbesoner
62db8f8e5a remove unneeded session_leader option from cpp-subprocess 2024-04-16 14:25:00 +02:00
Sebastian Falbesoner
80d008c66d remove unneeded defer_spawn option from cpp-subprocess
For our use-case, there doesn't seem to be any need for this.
2024-04-16 14:25:00 +02:00
Sebastian Falbesoner
cececad7b2 remove unneeded preexec function option from cpp-subprocess
We don't seem to ever need this, so remove it.
2024-04-16 14:25:00 +02:00
Sebastian Falbesoner
633e45b2e2 remove unneeded shell option from cpp-subprocess
We don't use this option and it's not supported on Windows anyways,
so we can get as well rid of it.
2024-04-16 14:25:00 +02:00
glozow
c3c1e15831 [doc] restore comment about why we check if ptx HasWitness before caching rejected txid 2024-04-16 10:11:01 +01:00
glozow
6f4da19cc3 guard against MempoolAcceptResult::m_replaced_transactions
It should never be a nullopt when the transaction result is valid -
Assume() this is the case. However, as a belt-and-suspenders just in
case it is nullopt, use an empty list.
2024-04-16 10:09:45 +01:00
glozow
07720b1cdd
Merge bitcoin/bitcoin#29869: rpc, bugfix: Enforce maximum value for setmocktime
c2e0489b71 [rpc, bugfix] Enforce maximum value for setmocktime (dergoegge)

Pull request description:

  The maximum value for our mocktime must be representable in nanoseconds, otherwise we end up with negative values returned from `NodeClock::now()`.

  Found through fuzzing:

  ```
  $ echo "c2V0bW9ja3RpbWVcZTptYf9w/3NldG3///////////////9p////ZP///ymL//////89////Nv9L////////LXkBAABpAA==" | base64 --decode > rpc-8cab9148ab4418ebd1923c213e9d3fe9c9b49b39.crash
  $ FUZZ=rpc ./src/test/fuzz/fuzz rpc-8cab9148ab4418ebd1923c213e9d3fe9c9b49b39.crash
  fuzz_libfuzzer: util/time.cpp:28: static NodeClock::time_point NodeClock::now(): Assertion `ret > 0s' failed.
  ```

ACKs for top commit:
  maflcko:
    re-ACK c2e0489b71
  brunoerg:
    crACK c2e0489b71
  glozow:
    ACK c2e0489b71

Tree-SHA512: d7e237ca37bedd74a6b085fb6e726a142705371044c77488f593f35afe70aeca756fdba86920294b1d322c7a9b2cde9ce4e1b7d410a6ccc1fd7c6f3a6e77200a
2024-04-15 15:06:17 +01:00
StevenMia
b1ee4a557b chore: fix some typos in comments
Signed-off-by: StevenMia <flite@foxmail.com>
2024-04-15 20:12:54 +08:00
merge-script
58446e1d92
Merge bitcoin/bitcoin#28874: doc: fixup help output for -upnp and -natpmp
92f88a9629 doc: fixup NAT-PMP help doc (fanquake)
02395edca9 init: remove redundant upnp #ifdef (fanquake)

Pull request description:

  This is a very belated followup to #26896 (which removed the configure options for setting the upnp and natpmp runtime default) and corrects the `-help` docs for `-upnp` and `-natpmp`.

ACKs for top commit:
  davidgumberg:
    ACK 92f88a9629
  hernanmarino:
    ACK 92f88a9629

Tree-SHA512: 795dc8a8703bf322b5831d845de85f2428ee0dd45d3064b48ff47d147147381af26c0a9d00c596db12009b254763844b209989daf4e7470d20e8a1753b640966
2024-04-15 13:10:18 +01:00
MarcoFalke
fae0db555c
refactor: Use chrono type for g_mock_time
This avoids verbose casts in the lines where the symbol is used.
2024-04-15 13:34:31 +02:00
MarcoFalke
fa382d3dd0
test: Add missing Assert(mock_time_in >= 0s) to SetMockTime
Also, inline the deprecated alias to avoid having the two go out of sync
again in the future.
2024-04-15 13:34:27 +02:00
dergoegge
c2e0489b71 [rpc, bugfix] Enforce maximum value for setmocktime 2024-04-15 09:51:06 +01:00
MarcoFalke
fa6ab0d020
rpc: Reword SighashFromStr error message 2024-04-15 10:01:15 +02:00
fanquake
4722b7c715
build: remove minisketch clz check 2024-04-12 14:28:34 +02:00
fanquake
1eea10a6d2 Squashed 'src/minisketch/' changes from a571ba20f9..3472e2f5ec
3472e2f5ec Merge sipa/minisketch#81: Avoid overflowing shift by special casing inverse of 1
653d8b2e26 Avoid overflowing shift by special casing inverse of 1
33b7c200b9 Merge sipa/minisketch#80: Add c++20 version of CountBits
4a48f31a37 Merge sipa/minisketch#83: ci: Fix "s390x (big-endian)" task
82b6488acb Add c++20 version of CountBits
0498084d31 ci: Fix "s390x (big-endian)" task
71709dca9e Merge sipa/minisketch#82: ci: Fix `x86_64-w64-mingw32` task
9e6127fa98 Merge sipa/minisketch#74: Avoid >> above type width in BitWriter
ed420bc170 ci: Fix `x86_64-w64-mingw32` task
fe1040f227 Drop -Wno-shift-count-overflow compile flag
154bcd43bd Avoid >> above type width in BitWriter
67b87acdb6 Merge sipa/minisketch#78: ci: Update macOS image for CI
7de7250416 ci: Update macOS image for CI
83d812ea9f Merge sipa/minisketch#73: ci: Use correct variable to designate C++ compiler
e051a7d690 ci: Install wine32 package for Windows tests
2d2c695d78 build: Drop unused `CC` variable
1810fcbd11 ci: Use correct variable to designate C++ compiler
022b959049 Merge sipa/minisketch#77: Add missing include
08443c4892 Add missing include

git-subtree-dir: src/minisketch
git-subtree-split: 3472e2f5ec75ace39ce9243af6b3fee233a67492
2024-04-12 14:27:45 +02:00
fanquake
e58e1323a8
Update minisketch subtree to latest master 2024-04-12 14:27:45 +02:00
merge-script
0de63b8b46
Merge bitcoin/bitcoin#29849: Fix typos in subprocess.hpp
13f5391bbb Fix typos in `subprocess.hpp` (Hennadii Stepanov)

Pull request description:

  Resolves one item in the https://github.com/bitcoin/bitcoin/pull/28981#pullrequestreview-1991272752:
  >    - Remove linter exclusions and fix all issues.

  Based on upstream https://github.com/arun11299/cpp-subprocess/pull/101.

ACKs for top commit:
  fanquake:
    ACK 13f5391bbb

Tree-SHA512: 2ee27a5b7d1ba6f47a5148add155c918eadaaffb94a4b5dd3edea00e63440b87291c559361bf25a8db1567debff78cf7e9466dc34f14331ca1d426994837df93
2024-04-11 16:18:39 +02:00
glozow
bdb33ec519
Merge bitcoin/bitcoin#29735: AcceptMultipleTransactions: Fix workspace not being set as client_maxfeerate failure
4ba1d0b553 fuzz: Add coverage for client_maxfeerate (Greg Sanders)
91d7d8f22a AcceptMultipleTransactions: Fix workspace client_maxfeerate (Greg Sanders)
f3aa5bd5eb fill_mempool: assertions and docsctring update (Greg Sanders)
a3da63e8fe Move fill_mempool to util function (Greg Sanders)
73b68bd8b4 fill_mempool: remove subtest-specific comment (Greg Sanders)

Pull request description:

  Bug causes an `Assume()` failure due to the expectation that the individual result should be invalid when done over `submitpackage` via rpc.

  Bug introduced by https://github.com/bitcoin/bitcoin/pull/28950 , and I discovered it rebasing https://github.com/bitcoin/bitcoin/pull/28984 since it's easier to hit in that test scenario.

  Tests in place were only checking `AcceptSingleTransaction`-level checks due to package evaluation only triggering when minfee is too high for the parent transaction.

  Added test along with fix, moving the fill_mempool utility into a common area for re-use.

ACKs for top commit:
  glozow:
    reACK 4ba1d0b553
  theStack:
    ACK 4ba1d0b553
  ismaelsadeeq:
    re-ACK 4ba1d0b553  via [diff](4fe7d150eb..4ba1d0b553)

Tree-SHA512: 3729bdf7f25d04e232f173ccee04ddbb2afdaafa3d04292a01cecf58fb11b3b2bc133e8490277f1a67622b62d17929c242dc980f9bb647896beea4332ee35306
2024-04-11 14:46:52 +02:00
laanwj
f2e3662e57 net: Decrease nMaxIPs when learning from DNS seeds
Limit number of IPs learned from a single DNS seed to 32, to prevent the results from
one DNS seed from dominating AddrMan. Note that the number of results from a UDP DNS query is
bounded to 33 already, but it is possible for it to use TCP where a potentially enormous
number of results can be returned.

Closes #16070.
2024-04-11 14:43:30 +02:00
Hennadii Stepanov
13f5391bbb
Fix typos in subprocess.hpp 2024-04-11 14:03:37 +02:00
stickies-v
c6be144c4b
Remove timedata
With the introduction and usage of TimeOffsets, there is no more need
for this file. Remove it.
2024-04-10 17:01:27 +02:00
dergoegge
92e72b5d0d
[net processing] Move IgnoresIncomingTxs to PeerManagerInfo 2024-04-10 17:01:27 +02:00
dergoegge
7d9c3ec622
[net processing] Introduce PeerManagerInfo
For querying statistics/info from PeerManager. The median outbound time
offset is the only initial field.
2024-04-10 17:01:27 +02:00
stickies-v
ee178dfcc1
Add TimeOffsets helper class
This helper class is an alternative to CMedianFilter, but without a
lot of the special logic and exceptions that we needed while it was
still used for consensus.
2024-04-10 17:01:27 +02:00
stickies-v
55361a15d1
[net processing] Use std::chrono for type-safe time offsets 2024-04-10 16:15:46 +02:00
dergoegge
038fd979ef
[net processing] Move nTimeOffset to net_processing 2024-04-10 16:15:46 +02:00
merge-script
0a9cfd1752
Merge bitcoin/bitcoin#28981: Replace Boost.Process with cpp-subprocess
d5a715536e build: remove boost::process dependency for building external signer support (Sebastian Falbesoner)
70434b1c44 external_signer: replace boost::process with cpp-subprocess (Sebastian Falbesoner)
cc8b9875b1 Add `cpp-subprocess` header-only library (Hennadii Stepanov)

Pull request description:

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

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

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

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

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

Tree-SHA512: d7fb6fecc3f5792496204190afb7d85b3e207b858fb1a75efe483c05260843b81b27d14b299323bb667c990e87a07197059afea3796cf218ed8b614086bd3611
2024-04-10 12:03:06 +02:00
merge-script
e31956980e
Merge bitcoin/bitcoin#29820: refactor, bench, fuzz: Drop unneeded UCharCast calls
56e1e5dd10 refactor, bench, fuzz: Drop unneeded `UCharCast` calls (Hennadii Stepanov)

Pull request description:

  The `CKey::Set()` template function handles `std::byte` just fine: b5d21182e5/src/key.h (L105)

  Noticed in https://github.com/bitcoin/bitcoin/pull/29774#discussion_r1546288181.

ACKs for top commit:
  maflcko:
    lgtm ACK 56e1e5dd10
  laanwj:
    Seems fine, code review ACK 56e1e5dd10
  hernanmarino:
    ACK 56e1e5dd10

Tree-SHA512: 0f6b6e66692e70e083c7768aa4859c7db11aa034f555d19df0e5d33b18c0367ba1c886bcb6be3fdea78248a3cf8285576120812da55b995ef5e6c94a9dbd9f7c
2024-04-09 22:16:28 +02:00
merge-script
0b4218e43c
Merge bitcoin/bitcoin#29834: build: Change MAC_OSX macro to __APPLE__ in crypto
a71eadf66b Change MAC_OSX macro to __APPLE__ in crypto package (Lőrinc)

Pull request description:

  Split out from https://github.com/bitcoin/bitcoin/pull/29450#issuecomment-2044405345 to avoid the uncertainties and simplify review.

ACKs for top commit:
  theuni:
    ACK a71eadf66b
  fanquake:
    ACK a71eadf66b

Tree-SHA512: b6a7bd7ca95585dd9110cefe7c1213f4a1a72bdfc88670abf4a0d9a8bbc12e093544524adce46aa9ca714c472d417f74ca4a678af682ed2488053059434eaa02
2024-04-09 17:09:02 +02:00
Greg Sanders
4ba1d0b553 fuzz: Add coverage for client_maxfeerate 2024-04-09 14:53:34 +02:00
Greg Sanders
91d7d8f22a AcceptMultipleTransactions: Fix workspace client_maxfeerate
If we do not set the Failure for the workspace when
there is a client_maxfeerate related error, we hit
an Assume() to the contrary. Properly set it.
2024-04-09 14:53:34 +02:00
glozow
bf031a517c
Merge bitcoin/bitcoin#29752: refactor: Use typesafe Wtxid in compact block encodings
a8203e9412 refactor: Simplify `extra_txn` to be a vec of CTransactionRef instead of a vec of pair<Wtxid, CTransactionRef> (AngusP)
c3c18433ae refactor: Use typesafe Wtxid in compact block encoding message, instead of ambiguous uint256. (AngusP)

Pull request description:

  The first commit replaces `uint256` with typesafe `Wtxid` (or `Txid`) types introduced in #28107.

  The second commit then simplifies the extra tx `vector` to just be of `CTransactionRef`s instead of a `std::pair<Wtxid, CTransactionRef>`, as it's easy to get a `Wtxid` from a transaction ref.

ACKs for top commit:
  glozow:
    ACK a8203e9412
  dergoegge:
    ACK a8203e9412

Tree-SHA512: b4ba1423a8059f9fc118782bd8a668213d229c822f22b01267de74d6ea97fe4f2aad46b5da7c0178ecc9905293e9a0eafba1d75330297c055e27fd53c8c8ebfd
2024-04-09 14:17:28 +02:00
Lőrinc
a71eadf66b Change MAC_OSX macro to __APPLE__ in crypto package 2024-04-09 11:21:57 +02:00
fanquake
71f96c274f
Merge bitcoin/bitcoin#29786: Drop Windows Socket dependency for randomenv.cpp
03b87a3e64 Drop Windows Socket dependency for `randomenv.cpp` (Hennadii Stepanov)

Pull request description:

  This change drops a dependency on the ws2_32 library for our libbitcoinkernel by switching to [`GetComputerName`](https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcomputernamew) function.

ACKs for top commit:
  sipsorcery:
    utACK 03b87a3e64.
  laanwj:
    Code review ACK 03b87a3e64.
  fanquake:
    ACK 03b87a3e64

Tree-SHA512: a4abd5499176634d5f3fbf4e794a7504c40232fb73bd7f41955fbfb2cc7c44bc7ea4518c5203836e52f552c30414c6c3e1b24f0922641dbf1c8377981c0ffaf0
2024-04-09 10:21:27 +02:00
fanquake
34a299f9ee
Merge bitcoin/bitcoin#29691: Change Luke Dashjr seed to dashjr-list-of-p2p-nodes.us
4f273ab436 Change Luke Dashjr seed to dashjr-list-of-p2p-nodes.us (Luke Dashjr)

Pull request description:

  To avoid issues with DNS blacklisting, I've setup a separate domain for my DNS seed.

  (This time, without a potentially alarming name)

ACKs for top commit:
  kevkevinpal:
    Concept ACK [4f273ab](4f273ab436), name looks good to me
  petertodd:
    ACK 4f273ab436
  mzumsande:
    ACK 4f273ab436
  fanquake:
    ACK 4f273ab436

Tree-SHA512: 689698e3c735df3ed0c2756a9d4adb5644bb9d8a6954e23d66bfa9d94ee10954f77fb241d9593f750054d731aa1532368a0fc8277884f6c2a98ac47cd0bdeeb7
2024-04-08 17:36:12 +02:00
dergoegge
78407b99ed [clang-tidy] Enable the misc-no-recursion check
Co-authored-by: stickies-v <stickies-v@protonmail.com>
Co-authored-by: Gloria Zhao <gloriajzhao@gmail.com>
2024-04-07 14:04:45 +01:00
fanquake
0f0e36de5f
Merge bitcoin/bitcoin#29815: crypto: chacha20: always use our fallback timingsafe_bcmp rather than libc's
2d1819455c crypto: chacha20: always use our fallback timingsafe_bcmp rather than libc's (Cory Fields)

Pull request description:

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

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

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

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

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

  Relevant IRC conversation with sipa:

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

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

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

Tree-SHA512: b9583e19ac2f77c5d572aa5b95bc4b53669d5717e5708babef930644980de7c5d06a9c7decd5c2b559d70b8597328ecfe513375e3d8c3ef523db80012dfe9266
2024-04-06 20:45:19 +01:00
AngusP
a8203e9412
refactor: Simplify extra_txn to be a vec of CTransactionRef instead of a vec of pair<Wtxid, CTransactionRef>
All `CTransactionRef` have `.GetWitnessHash()` that returns a cached `const Wtxid` (since fac1223a56),
so we don't need to pass transaction refs around with their IDs as they're easy to get from a ref.
2024-04-06 19:17:20 +01:00
Hennadii Stepanov
56e1e5dd10
refactor, bench, fuzz: Drop unneeded UCharCast calls
The `CKey::Set()` template function handles `std::byte` just fine.
2024-04-06 15:46:53 +01:00
fanquake
b5d21182e5
Merge bitcoin/bitcoin#29803: Update libsecp256k1 subtree to latest master
53eec53dca Squashed 'src/secp256k1/' changes from efe85c70a2..d8311688bd (fanquake)

Pull request description:

  Updates the libsecp256k1 subtree to d8311688bd.

  Part of #29742. See that PR for more details, the particularly relevant changes are:
  * https://github.com/bitcoin-core/secp256k1/pull/1496
  * https://github.com/bitcoin-core/secp256k1/pull/1512

ACKs for top commit:
  theuni:
    ACK 4654cc3224
  jonasnick:
    utACK 4654cc3224

Tree-SHA512: 84e711e9245ced6cc679e082f597d096361d8824c6ff7de2d4d7f59adb3316464b3643ffa588a899345cb88532672a66968b6c66c51b1924adf4441f54427277
2024-04-06 09:39:20 +01:00
fanquake
8f1185feec
Merge bitcoin/bitcoin#29805: test: Fix debug recommendation in argsman_tests
561a650e0f test: Fix debug recommendation in argsman_tests (Fabian Jahr)

Pull request description:

  There are recommendations in the `argsman_tests` comments on how to re-run and debug a test failure to see if it reflects an expected or unexpected change. The command tries to run a test in `util_tests` but this is in `argsman_tests` so the command doesn't work with just copy+paste. I didn't investigate further but I suspect that these tests were moved between files.

ACKs for top commit:
  fanquake:
    ACK 561a650e0f

Tree-SHA512: b3bb94ba1635c9455149b455f2b30ee37a8067a6242339531ab54d428177a288da29a4a10702652305eb34aa7638f51dad35fa6b0e7b74617e445327b8c4c053
2024-04-05 17:25:38 +01:00
fanquake
c3530254c9
Merge bitcoin/bitcoin#29081: refactor: Remove gmtime*
fa9f36baba build: Remove HAVE_GMTIME_R (MarcoFalke)
fa72dcbfa5 refactor: FormatISO8601* without gmtime* (MarcoFalke)
fa2c486afc Revert "time: add runtime sanity check" (MarcoFalke)

Pull request description:

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

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

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

Tree-SHA512: a9e7e805b757b7dade0bcc3f95273a7dc4f68622630d74838339789dd203ad7542d36b2e090a93b2bc5a7ecc383207dd7ec82c68147108bdac7ce44f088c8c9a
2024-04-05 17:02:00 +01:00
Cory Fields
2d1819455c crypto: chacha20: always use our fallback timingsafe_bcmp rather than libc's
Looking at apple/freebsd/openbsd sources, their implementations match our naive
fallback. It's not worth the hassle of using a platform-specific function for
no gain.
2024-04-05 15:44:21 +00:00
willcl-ark
10c5275ba4
gui: don't permit port in proxy IP option
Fixes: #809

Previously it was possible through the GUI to enter an IP address:port
into the "Proxy IP" configuration box. After the node was restarted the
errant setting would prevent the node starting back up until manually
removed from settings.json.
2024-04-04 21:08:38 +01:00
Ryan Ofsky
5a5ab1d544
Merge bitcoin/bitcoin#29776: ThreadSanitizer: Fix #29767
bbe82c116e Fix #29767, set m_synced = true after Commit() (nanlour)

Pull request description:

  I think this problem https://github.com/bitcoin/bitcoin/issues/29767#issue-2216373048 is because of
  in BaseIndex::Sync
  61de64df67/src/index/base.cpp (L163-L168)
  Setup m_synced = true; before Commit();
  So this may cause a race condition window to BaseIndex::BlockConnected
  61de64df67/src/index/base.cpp (L271-L274)
  So i try to fix it with move m_synced = true after Commit().
  Also see comment of Sync():
  61de64df67/src/index/base.h (L151-L156)
  I am a newcomer interested in Bitcoin, trying to become a member of the Bitcoin Core development team. Please give me some feedback if you could, as I may be doing something wrong. Thank you!

ACKs for top commit:
  fjahr:
    Code review ACK bbe82c116e
  ryanofsky:
    Code review ACK bbe82c116e

Tree-SHA512: 89a09498a232c87ef1e083d4cc4ed9bb15f045ad0624d5d150a87187b2b8a48a41137974dbc7ea5c37f73da90742c43259f5aa7f84b4179eb8d62033e44fa479
2024-04-04 09:25:16 -04:00
Fabian Jahr
561a650e0f
test: Fix debug recommendation in argsman_tests 2024-04-04 14:55:46 +02:00
fanquake
53eec53dca Squashed 'src/secp256k1/' changes from efe85c70a2..d8311688bd
d8311688bd Merge bitcoin-core/secp256k1#1515: ci: Note affected clangs in comment on ASLR quirk
a85e2233e7 ci: Note affected clangs in comment on ASLR quirk
4b77fec67a Merge bitcoin-core/secp256k1#1512: msan: notate more variable assignments from assembly code
f7f0184ba1 msan: notate more variable assignments from assembly code
a61339149f change inconsistent array param to pointer
05bfab69ae Merge bitcoin-core/secp256k1#1507: ci: Add workaround for ASLR bug in sanitizers
a5e8ab2484 ci: Add sanitizer env variables to debug output
84a93de4d2 ci: Add workaround for ASLR bug in sanitizers
427e86b9ed Merge bitcoin-core/secp256k1#1490: tests: improve fe_sqr test (issue #1472)
2028069df2 doc: clarify input requirements for secp256k1_fe_mul
11420a7a28 tests: improve fe_sqr test
cdc9a6258e Merge bitcoin-core/secp256k1#1489: tests: add missing fe comparison checks for inverse field test cases
d926510cf7 Merge bitcoin-core/secp256k1#1496: msan: notate variable assignments from assembly code
31ba404944 msan: notate variable assignments from assembly code
e7ea32e30a msan: Add SECP256K1_CHECKMEM_MSAN_DEFINE which applies to memory sanitizer and not valgrind
e7bdddd9c9 refactor: rename `check_fe_equal` -> `fe_equal`
00111c9c56 tests: add missing fe comparison checks for inverse field test cases
0653a25d50 Merge bitcoin-core/secp256k1#1486: ci: Update cache action
94a14d5290 ci: Update cache action
2483627299 Merge bitcoin-core/secp256k1#1483: cmake: Recommend native CMake commands in README
5ad3aa3dcd Merge bitcoin-core/secp256k1#1484: tests: Drop redundant _scalar_check_overflow calls
51df2d9ab3 tests: Drop redundant _scalar_check_overflow calls
3777e3f36a cmake: Recommend native CMake commands in README
e4af41c61b Merge bitcoin-core/secp256k1#1249: cmake: Add `SECP256K1_LATE_CFLAGS` configure option
3bf4d68fc0 Merge bitcoin-core/secp256k1#1482: build: Clean up handling of module dependencies
e6822678ea build: Error if required module explicitly off
89ec583ccf build: Clean up handling of module dependencies
44378867a0 Merge bitcoin-core/secp256k1#1468: v0.4.1 release aftermath
a9db9f2d75 Merge bitcoin-core/secp256k1#1480: Get rid of untested sizeof(secp256k1_ge_storage) == 64 code path
74b7c3b53e Merge bitcoin-core/secp256k1#1476: include: make docs more consistent
b37fdb28ce check-abi: Minor UI improvements
ad5f589a94 check-abi: Default to HEAD for new version
9fb7e2f156 release process: Style and formatting nits
ba5d72d626 assumptions: Use new STATIC_ASSERT macro
e53c2d9ffc Require that sizeof(secp256k1_ge_storage) == 64
d0ba2abbff util: Add STATIC_ASSERT macro
da7bc1b803 include: in doc, remove article in front of "pointer"
aa3dd5280b include: make doc about ctx more consistent
e3f690015a include: remove obvious "cannot be NULL" doc
d373bf6d08 Merge bitcoin-core/secp256k1#1474: tests: restore scalar_mul test
79e094517c Merge bitcoin-core/secp256k1#1473: Fix typos
3dbfb48946 tests: restore scalar_mul test
d77170a88d Fix typos
e7053d065b release process: Add email step
429d21dc79 release process: Run sanity checks on release PR
42f8c51402 cmake: Add `SECP256K1_LATE_CFLAGS` configure option

git-subtree-dir: src/secp256k1
git-subtree-split: d8311688bd383d3a923a1b11789cded3cc8e5e03
2024-04-04 12:05:16 +01:00
fanquake
4654cc3224
Update secp256k1 subtree to latest master 2024-04-04 12:05:16 +01:00
Ryan Ofsky
3b987d03a4
Merge bitcoin/bitcoin#29419: log: deduplicate category names and improve logging.cpp
b0344c219a logging: remove unused BCLog::UTIL (Vasil Dimov)
d3b3af9034 log: deduplicate category names and improve logging.cpp (Vasil Dimov)

Pull request description:

  The code in `logging.cpp` needs to:
  * Get the category name given the flag (e.g. `BCLog::PRUNE` -> `"prune"`)
  * Get the flag given the category name (e.g. `"prune"` -> `BCLog::PRUNE`)
  * Get the list of category names sorted in alphabetical order

  Achieve this by using the proper std containers. The result is
  * less code (the diff of the first commit is +62 / -129)
  * faster code (to linear search and no copy+sort)
  * more maintainable code (the categories are no longer duplicated in `LogCategories[]` and `LogCategoryToStr()`)

  This behavior is preserved:
  `BCLog::NONE` -> `""` (lookup by `LogCategoryToStr()`)
  `""` -> `BCLog::ALL` (lookup by `GetLogCategory("")`)

  ---

  Also remove unused `BCLog::UTIL`.

  ---

  These changes (modulo the `BCLog::UTIL` removal) are part of https://github.com/bitcoin/bitcoin/pull/29415 but they make sense on their own and would be good to have them, regardless of the fate of https://github.com/bitcoin/bitcoin/pull/29415. Also, if this is merged, that would reduce the size of https://github.com/bitcoin/bitcoin/pull/29415, thus the current standalone PR.

ACKs for top commit:
  davidgumberg:
    crACK b0344c219a
  pinheadmz:
    ACK b0344c219a
  ryanofsky:
    Code review ACK b0344c219a. Nice cleanup! Having to maintain multiple copies of the same mapping seemed messy and a like a possible footgun. I checked old and new mappings in both directions and confirmed no behavior should be changing.

Tree-SHA512: 57f87a090932f9b33dc8e075d1855dba9b71a3243a0758511745483dec2d9c46d3b532eadab297e78164c9b7caba370986ee380696a45f0778a841082f8e21a7
2024-04-02 10:47:05 -04:00
Hennadii Stepanov
03b87a3e64
Drop Windows Socket dependency for randomenv.cpp
This change drops a dependency on the ws2_32 library for our
libbitcoinkernel, which may not be desirable.
2024-04-02 14:29:24 +01:00
fanquake
c407caa297
Merge bitcoin/bitcoin#29687: cli: improve bitcoin-cli error when not connected
69d6fd676e cli: improve bitcoin-cli error when not connected (willcl-ark)

Pull request description:

  Closes: #29555

  Simply adds an additional suggestion to check `bitcoin-cli -help`.

ACKs for top commit:
  maflcko:
    lgtm ACK 69d6fd676e
  itornaza:
    tested ACK 69d6fd676e
  tdb3:
    ACK for 69d6fd676e

Tree-SHA512: af0c712bcc9b1267f81a8316d015bef99ab788ef43e3b450cdc4a9cb74004727d757d48f50d3af2b28b01be2931578623311677a79f1b148a53f364bd4279a0c
2024-04-02 11:20:38 +01:00
Ava Chow
ca18aea5c4 Add AutoFile::seek and tell
It's useful to be able to seek to a specific position in a file. Allow
AutoFile to seek by using fseek.

It's also useful to be able to get the current position in a file.
Allow AutoFile to tell by using ftell.
2024-04-01 14:37:24 -04:00
fanquake
948ecf181e
Merge bitcoin/bitcoin#29648: Remove libbitcoinconsensus
80f8b92f4f remove libbitcoinconsensus (fanquake)

Pull request description:

  This was deprecated in `v27.0`, for removal in `v28.0`. See discussion in PR #29189.

ACKs for top commit:
  theuni:
    Concept ACK and light review ACK 80f8b92f4f. My only hesitation here is that (afaics?) there's now nothing keeping undesired features like threading or globals from working their way into the interpreter in future commits.
  m3dwards:
    Concept ACK 80f8b92f4f
  TheCharlatan:
    ACK 80f8b92f4f
  hebasto:
    ACK 80f8b92f4f, I have reviewed the code and it looks OK.

Tree-SHA512: 17a62118aeb088f2695c892bb32794dfea3061e3cb7d9e8e9f1c06c3ff6f63a7587fa532e37edbb91fbc5a19b12c9a0f8e05fa9e8864aa07f92665375d847e80
2024-04-01 17:53:31 +02:00
fanquake
8d19d688f4
Merge bitcoin/bitcoin#29738: doc: fix typos
601edd8ee8 ci: use codespell 2.2.6 (fanquake)
52fa0d285f doc: fix some typos (crazeteam)
b5ed13a240 doc: Fix typos (RoboSchmied)

Pull request description:

  Combines the recent PRs to fix typos so they can be merged.

ACKs for top commit:
  brunoerg:
    crACK 601edd8ee8
  tdb3:
    crACK 601edd8ee8
  kristapsk:
    cr utACK 601edd8ee8

Tree-SHA512: d054b1dad1336d6b9291cc5d5252d4debf6424a993d4edd6a97d7c15055a7fc48a333d30967f72e7dc9c6c1d9a9038ca8bb5e219c529f4c2365ea48404a508d0
2024-04-01 15:54:45 +02:00
nanlour
bbe82c116e Fix #29767, set m_synced = true after Commit() 2024-04-01 14:13:06 +11:00
Hennadii Stepanov
31a15f0aff
bench: Disable WalletCreate* benchmarks when building with MSVC 2024-03-31 10:33:58 +01:00
Ava Chow
61de64df67
Merge bitcoin/bitcoin#29724: 29242 Diagram check followups
ee1b9b231a CalculateFeerateDiagramsForRBF: update misleading description of old diagram contents (Greg Sanders)
a9d42b9aa5 CompareFeerateDiagram: short-circuit comparison when detected as incomparable (Greg Sanders)
cebcced65e remove erroneous CompareFeerateDiagram comment about slope (Greg Sanders)
a0376e1061 unit test: clarify unstated assumption for calc_feerate_diagram_rbf chunking (Greg Sanders)
890cb015f3 s/effected/affected/ (Greg Sanders)
d9391ec095 CalculateFeerateDiagramsForRBF: remove size tie-breaking from chunking conflicts (Greg Sanders)
b684d82d7e fuzz: Add more invariant checks for package_rbf (Greg Sanders)
2a3ada8b21 fuzz: finer grained ImprovesFeerateDiagram check on error result (Greg Sanders)
c377ae9ba0 unit test: improve ImprovesFeerateDiagram coverage with one less vb case (Greg Sanders)
d2bf923eb1 unit test: make calc_feerate_diagram_rbf less brittle (Greg Sanders)
defe023f6e fuzz: add PrioritiseTransaction coverage in diagram checks (Greg Sanders)
216d5ff162 unit test: add coverage showing priority affects diagram check results (Greg Sanders)
a80d80936a unit test: add CheckConflictTopology case for not the only child (Greg Sanders)
69bd18ca80 unit test: check tx4 conflict error message (Greg Sanders)
c0c37f07eb unit test: have CompareFeerateDiagram tested with diagrams both ways (Greg Sanders)
b62e2c0fa5 ImprovesFeerateDiagram: Spelling fix and removal of unused diagram vectors (Greg Sanders)
bb42402945 doc: fix comment about non-existing CompareFeeFrac (Greg Sanders)

Pull request description:

  Follow-ups to https://github.com/bitcoin/bitcoin/pull/29242

ACKs for top commit:
  glozow:
    ACK ee1b9b231a, reviewed the changes and package_rbf fuzzer seems to run fine
  murchandamus:
    crACK ee1b9b231a
  ismaelsadeeq:
    Code review ACK ee1b9b231a
  willcl-ark:
    ACK ee1b9b231a

Tree-SHA512: 8399fe12064fb49b0e4c73258968b57be1d9c2e35701b2d3b0bb67e2e4052e44216358238f92508e4697d0fb6176518d5b885474054d3deda242f669e99262a7
2024-03-29 19:52:50 -04:00
furszy
671b7a3251
gui: fix create unsigned transaction fee bump 2024-03-29 11:44:04 -03:00
Ryan Ofsky
4373414d26
Merge bitcoin/bitcoin#29130: wallet: Add createwalletdescriptor and gethdkeys RPCs for adding new automatically generated descriptors
746b6d8839 test: Add test for createwalletdescriptor (Ava Chow)
2402b63062 wallet: Test upgrade of pre-taproot wallet to have tr() descriptors (Ava Chow)
460ae1bf67 wallet, rpc: Add createwalletdescriptor RPC (Ava Chow)
8e1a475062 wallet: Be able to retrieve single key from descriptors (Ava Chow)
85b1fb19dd wallet: Add GetActiveHDPubKeys to retrieve xpubs from active descriptors (Ava Chow)
73926f2d31 wallet, descspkm: Refactor wallet descriptor generation to standalone func (Andrew Chow)
54e74f46ea wallet: Refactor function for single DescSPKM setup (Andrew Chow)
3b09d0eb7f tests: Test for gethdkeys (Ava Chow)
5febe28c9e wallet, rpc: Add gethdkeys RPC (Ava Chow)
66632e5c24 wallet: Add IsActiveScriptPubKeyMan (Ava Chow)
fa6a259985 desc spkm: Add functions to retrieve specific private keys (Ava Chow)
fe67841464 descriptor: Be able to get the pubkeys involved in a descriptor (Ava Chow)
ef6745879d key: Add constructor for CExtKey that takes CExtPubKey and CKey (Ava Chow)

Pull request description:

  This PR adds a `createwalletdescriptor` RPC which allows users to add new automatically generated descriptors to their wallet, e.g. to upgrade a 0.21.x wallet to contain a taproot descriptor. This RPC takes 3 arguments: the output type to create a descriptor for, whether the descriptor will be internal or external, and the HD key to use if the user wishes to use a specific key. The HD key is an optional parameter. If it is not specified, the wallet will use the key shared by the active descriptors, if they are all single key. For most users in the expected upgrade scenario, this should be sufficient. In more advanced cases, the user must specify the HD key to use.

  Currently, specified HD keys must already exist in the wallet. To make it easier for the user to know, `gethdkeys` is also added to list out the HD keys in use by all of the descriptors in the wallet. This will include all HD keys, whether we have the private key, for it, which descriptors use it and their activeness, and optionally the extended private key. In this way, users with more complex wallets will be still be able to get HD keys from their wallet for use in other scenarios, and if they want to use `createwalletdescriptor`, they can easily get the keys that they can specify to it.

  See also https://github.com/bitcoin/bitcoin/pull/26728#issuecomment-1866961865

ACKs for top commit:
  Sjors:
    re-utACK 746b6d8839
  furszy:
    ACK 746b6d8
  ryanofsky:
    Code review ACK 746b6d8839, and this looks ready to merge. There were various suggested changes since last review where main change seems to be switching `gethdkeys` output to use normalized descriptors (removing hardened path components).

Tree-SHA512: f2849101e6fbf1f59cb031eaaaee97af5b1ae92aaab54c5716940d210f08ab4fc952df2725b636596cd5747b8f5beb1a7a533425bc10d09da02659473516fbda
2024-03-29 06:39:57 -04:00
AngusP
c3c18433ae
refactor: Use typesafe Wtxid in compact block encoding message, instead of ambiguous uint256.
Wtxid/Txid types introduced in #28107
2024-03-28 23:29:57 +01:00
glozow
d1e9a02126
Merge bitcoin/bitcoin#29402: mempool: Log added for dumping mempool transactions to disk
4d5b55735b log: renamed disk to file so wording was more accurate (kevkevin)
b9f04be870 mempool: Log added for dumping mempool transactions to disk (kevkevin)

Pull request description:

  Sometimes when shutting off bitcoind it can take a while to dump the mempool transaction onto the disk so
  this change adds additional logging to the `DumpMempool` method in `kernel/mempool_persist.cpp`

  Motivated by https://github.com/bitcoin/bitcoin/pull/29227 this change
   - adds a single new line for the amount of transactions being dumped and the amount of memory being dumped to file

  This is in response to https://github.com/bitcoin/bitcoin/pull/29227#issuecomment-1893375082

  The logs will now look like this
  ```
  2024-02-09T23:41:52Z DumpAnchors: Flush 2 outbound block-relay-only peer addresses to anchors.dat completed (0.02s)
  2024-02-09T23:41:52Z scheduler thread exit
  2024-02-09T23:41:52Z Writing 29 mempool transactions to file...
  2024-02-09T23:41:52Z Writing 0 unbroadcast transactions to file.
  2024-02-09T23:41:52Z Dumped mempool: 0.000s to copy, 0.022s to dump, 0.015 MB dumped to file
  2024-02-09T23:41:52Z Flushed fee estimates to fee_estimates.dat.
  2024-02-09T23:41:53Z Shutdown: done
  ```

ACKs for top commit:
  maflcko:
    cr-ACK 4d5b55735b
  glozow:
    reACK 4d5b557

Tree-SHA512: 049191e140d00c1ea57debe0138f1c9eb0f9bb0ef8138e2568e6d89e64f45a5d5853ce3b9cc0b28566aab97555b47ddfb0f9199fc8cea6b81e53f50592d5ae6a
2024-03-28 11:43:10 +00:00
Sebastian Falbesoner
c6d1b8de89 gui: change example address from legacy (P2PKH) to bech32m (P2TR)
The dummy addresses have been computed with the following Python script
(executed under ./test/functional):

--------------------------------------------------------------------------------------------------------
from test_framework.segwit_addr import CHARSET, decode_segwit_address, encode_segwit_address
from test_framework.messages import sha256

output_key = sha256(b'bitcoin dummy taproot output key')
for network, hrp in [('mainnet', 'bc'), ('signet', 'tb'), ('testnet', 'tb'), ('regtest', 'bcrt')]:
    dummy_address = encode_segwit_address(hrp, 1, output_key)
    while decode_segwit_address(hrp, dummy_address) != (None, None):
        last_char = CHARSET[(CHARSET.index(dummy_address[-1]) + 1) % 32]
        dummy_address = dummy_address[:-1] + last_char
    print(f'{network:7} example address: {dummy_address}')
--------------------------------------------------------------------------------------------------------

Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
2024-03-28 11:22:23 +01:00
Andrew Toth
4a6d1d1e3b
validation: don't clear cache on periodic flush 2024-03-27 14:06:22 -04:00
Ryan Ofsky
c8e3978114
Merge bitcoin/bitcoin#27307: wallet: track mempool conflicts with wallet transactions
5952292133 wallet, rpc: show mempool conflicts in `gettransaction` result (ishaanam)
54e07ee22f wallet: track mempool conflicts (ishaanam)
d64922b590 wallet refactor: use CWalletTx member functions to determine tx state (ishaanam)
ffe5ff1fb6 scripted-diff: wallet: s/TxStateConflicted/TxStateBlockConflicted (ishaanam)
180973a941 test: Add tests for wallet mempool conflicts (ishaanam)

Pull request description:

  The `mempool_conflicts` variable is added to `CWalletTx`, it is a set of txids of txs in the mempool conflicting with the wallet tx or a wallet tx's parent. This PR only changes how mempool-conflicted txs are dealt with in memory.

  `IsSpent` now returns false for an output being spent by a mempool conflicted transaction where it previously returned true.

  A txid is added to `mempool_conflicts` during  `transactionAddedToMempool`. A txid is removed from `mempool_conflicts` during  `transactionRemovedFromMempool`.

  This PR also adds a `mempoolconflicts` field to the `gettransaction` wallet RPC result.

  Builds on #27145
  Second attempt at #18600

ACKs for top commit:
  achow101:
    ACK 5952292133
  ryanofsky:
    Code review ACK 5952292133. Just small suggested changes since last review
  furszy:
    ACK 59522921

Tree-SHA512: 615779606723dbb6c2e302681d8e58ae2052ffee52d721ee0389746ddbbcf4b4c4afacf01ddf42b6405bc6f883520524186a955bf6b628fe9b3ae54cffc56a29
2024-03-27 12:45:08 -04:00
Sebastian Falbesoner
70434b1c44
external_signer: replace boost::process with cpp-subprocess
This primarily affects the `RunCommandParseJSON` utility function.
2024-03-27 14:16:37 +00:00
Hennadii Stepanov
cc8b9875b1
Add cpp-subprocess header-only library
Upstream repo: https://github.com/arun11299/cpp-subprocess
Commit: 4025693decacaceb9420efedbf4967a04cb028e7

The "Convenience Functions" section is unused in our codebase, so it has
been removed.
2024-03-27 14:16:32 +00:00
kevkevin
4d5b55735b
log: renamed disk to file so wording was more accurate 2024-03-27 07:19:46 -05:00
kevkevin
b9f04be870
mempool: Log added for dumping mempool transactions to disk 2024-03-27 07:18:49 -05:00
crazeteam
52fa0d285f
doc: fix some typos
Signed-off-by: crazeteam <lilujing@outlook.com>
2024-03-26 16:51:46 +00:00
RoboSchmied
b5ed13a240
doc: Fix typos
Fix three typos.
2024-03-26 16:51:37 +00:00
Greg Sanders
ee1b9b231a CalculateFeerateDiagramsForRBF: update misleading description of old diagram contents 2024-03-26 11:42:42 -04:00
Greg Sanders
a9d42b9aa5 CompareFeerateDiagram: short-circuit comparison when detected as incomparable 2024-03-26 08:41:06 -04:00
Greg Sanders
cebcced65e remove erroneous CompareFeerateDiagram comment about slope 2024-03-26 08:20:30 -04:00
Greg Sanders
a0376e1061 unit test: clarify unstated assumption for calc_feerate_diagram_rbf chunking 2024-03-26 08:20:30 -04:00
Greg Sanders
890cb015f3 s/effected/affected/ 2024-03-26 08:20:30 -04:00
Greg Sanders
d9391ec095 CalculateFeerateDiagramsForRBF: remove size tie-breaking from chunking conflicts 2024-03-26 08:20:30 -04:00
Greg Sanders
b684d82d7e fuzz: Add more invariant checks for package_rbf 2024-03-26 08:20:30 -04:00
Greg Sanders
2a3ada8b21 fuzz: finer grained ImprovesFeerateDiagram check on error result 2024-03-26 08:20:30 -04:00
Greg Sanders
c377ae9ba0 unit test: improve ImprovesFeerateDiagram coverage with one less vb case 2024-03-26 08:20:30 -04:00
Greg Sanders
d2bf923eb1 unit test: make calc_feerate_diagram_rbf less brittle 2024-03-26 08:20:30 -04:00
Greg Sanders
defe023f6e fuzz: add PrioritiseTransaction coverage in diagram checks 2024-03-26 08:20:30 -04:00
Greg Sanders
216d5ff162 unit test: add coverage showing priority affects diagram check results 2024-03-26 08:20:30 -04:00
Greg Sanders
a80d80936a unit test: add CheckConflictTopology case for not the only child 2024-03-26 08:20:30 -04:00
Greg Sanders
69bd18ca80 unit test: check tx4 conflict error message 2024-03-26 08:05:22 -04:00
Greg Sanders
c0c37f07eb unit test: have CompareFeerateDiagram tested with diagrams both ways 2024-03-26 08:05:22 -04:00
Greg Sanders
b62e2c0fa5 ImprovesFeerateDiagram: Spelling fix and removal of unused diagram vectors 2024-03-26 08:05:22 -04:00
Greg Sanders
bb42402945 doc: fix comment about non-existing CompareFeeFrac 2024-03-26 08:05:22 -04:00
glozow
19b968f743
Merge bitcoin/bitcoin#29722: 28950 followups
7b29119d79 use const ref for client_maxfeerate (Greg Sanders)
f10fd07320 scripted-diff: Rename max_sane_feerate to client_maxfeerate (Greg Sanders)

Pull request description:

  Follow-ups to https://github.com/bitcoin/bitcoin/pull/28950

ACKs for top commit:
  glozow:
    utACK 7b29119d79
  stickies-v:
    ACK 7b29119d79

Tree-SHA512: b9e13509c6e9d7c08aa9d4e759f9707004c1c7b8f3e521fe2ec0037160b87c7fb02528966b9f26eaca6291621df9300e84b5aec66dbc2e97d13bf2f3cd7f979c
2024-03-26 08:56:44 +00:00
glozow
c2dbbc35b9
Merge bitcoin/bitcoin#29242: Mempool util: Add RBF diagram checks for single chunks against clusters of size 2
7295986778 Unit tests for CalculateFeerateDiagramsForRBF (Greg Sanders)
b767e6bd47 test: unit test for ImprovesFeerateDiagram (Greg Sanders)
7e89b659e1 Add fuzz test for FeeFrac (Greg Sanders)
4d6528a3d6 fuzz: fuzz diagram creation and comparison (Greg Sanders)
e9c5aeb11d test: Add tests for CompareFeerateDiagram and CheckConflictTopology (Greg Sanders)
588a98dccc fuzz: Add fuzz target for ImprovesFeerateDiagram (Greg Sanders)
2079b80854 Implement ImprovesFeerateDiagram (Greg Sanders)
66d966dcfa Add FeeFrac unit tests (Greg Sanders)
ce8e22542e Add FeeFrac utils (Greg Sanders)

Pull request description:

  This is a smaller piece of https://github.com/bitcoin/bitcoin/pull/28984 broken off for easier review.

  Up to date explanation of diagram checks are here: https://delvingbitcoin.org/t/mempool-incentive-compatibility/553

  This infrastructure has two near term applications prior to cluster mempool:
  1) Limited Package RBF(https://github.com/bitcoin/bitcoin/pull/28984): We want to allow package RBF only when we know it improves the mempool. This narrowly scoped functionality allows use with v3-like topologies, and will be expanded at some point post-cluster mempool when diagram checks can be done efficiently against bounded cluster sizes.
  2) Replacement for single tx RBF(in a cluster size of up to two) against conflicts of up to cluster size two. `ImprovesFeerateDiagram` interface will have to change for this use-case, which is a future direction to solve certain pins and improve mempool incentive compatibility: https://delvingbitcoin.org/t/ephemeral-anchors-and-mev/383#diagram-checks-fix-this-3

  And longer-term, this would be the proposed way we would compute incentive compatibility for all conflicts, post-cluster mempool.

ACKs for top commit:
  sipa:
    utACK 7295986778
  glozow:
    code review ACK 7295986778
  murchandamus:
    utACK 7295986778
  ismaelsadeeq:
    Re-ACK 7295986778
  willcl-ark:
    crACK 7295986778
  sdaftuar:
    ACK 7295986778

Tree-SHA512: 79593e5a087801c06f06cc8b73aa3e7b96ab938d3b90f5d229c4e4bfca887a77b447605c49aa5eb7ddcead85706c534ac5eb6146ae2396af678f4beaaa5bea8e
2024-03-26 08:48:37 +00:00
Martin Zumsande
e57f951805 init, validation: Fix -reindex option with an existing snapshot
This didn't work for two reasons:
1.) GetSnapshotCoinsDBPath() was used to retrieve the path.
    This requires coins_views to exist, but the initialisation only happens later
    (in CompleteChainstateInitialization) so the node hits an assert in
    CCoinsViewDB& CoinsDB() and crashes.

2.) The snapshot was already activated, so it has the mempool attached.
    Therefore, the mempool needs to be transferred back to the ibd
    chainstate before deleting the snapshot chainstate.
2024-03-25 14:49:06 -04:00
Greg Sanders
7b29119d79 use const ref for client_maxfeerate 2024-03-25 11:52:12 -04:00
Greg Sanders
f10fd07320 scripted-diff: Rename max_sane_feerate to client_maxfeerate
-BEGIN VERIFY SCRIPT-
git grep -l 'max_sane_feerate' | xargs sed -i 's/max_sane_feerate/client_maxfeerate/g'
-END VERIFY SCRIPT-
2024-03-25 11:48:18 -04:00
0xb10c
9a44a20fb7
init: clarify -test error
See https://github.com/bitcoin/bitcoin/pull/29007#discussion_r1469388717
2024-03-23 15:33:50 +01:00
0xb10c
3047c3e3a9
addrman: drop /*deterministic=*/ comment
Just having deterministic is enough. See https://github.com/bitcoin/bitcoin/pull/29007#discussion_r1488241966
2024-03-23 15:33:47 +01:00
Ava Chow
c1223188e0
Merge bitcoin/bitcoin#29672: validation: Make translations of fatal errors consistent
824f47294a node: Use log levels in noui_ThreadSafeMessageBox (TheCharlatan)
ddc7872c08 node: Make translations of fatal errors consistent (TheCharlatan)

Pull request description:

  The extra `bilingual_str` argument of the fatal error notifications and `node::AbortNode()` is often unused and when used usually contains the same string as the message argument. It also seems to be confusing, since it is not consistently used for errors requiring user action. For example some assumeutxo fatal errors require the user to do something, but are not translated.

  So simplify the fatal error and abort node interfaces by only passing a translated string. This slightly changes the fatal errors displayed to the user.

ACKs for top commit:
  stickies-v:
    re-ACK 824f47294a
  maflcko:
    ACK 824f47294a 🔎
  achow101:
    ACK 824f47294a
  hebasto:
    re-ACK 824f47294a.

Tree-SHA512: 2868ee7b045fe7f3ac582ce5039141b398480b7627734976201dafaaef7544b8461635a7292fee4a7f32ff1bfc26f9bd4d0c292dca424ba42fb7fc4483d7ce8d
2024-03-22 14:50:58 -04:00
Ava Chow
2795e89cc5
Merge bitcoin/bitcoin#28998: rpc: "addpeeraddress tried" return error on failure
99954f914f test: fix test to ensure hidden RPC is present in detailed help (stratospher)
0d01f6f0c6 test: remove unused mocktime in test_addpeeraddress (0xb10c)
6205466512 rpc: "addpeeraddress tried" return error on failure (0xb10c)

Pull request description:

  When trying to add an address to the IP address manager tried table, it's first added to the new table and then moved to the tried table. Previously, adding a conflicting address to the address manager's tried table with test-only `addpeeraddress tried=true` RPC would return `{ "success": true }`. However, the address would not be added to the tried table, but would remain in the new table. This caused, e.g., issue #28964.

  This is fixed by new returning `{ "success":  false, "error": "..." }` for failed tried table additions. Since the address remaining in the new table can't be removed (the address manager interface does not support removing addresses at the moment and adding this seems to be a bigger effort), an error message is returned. This indicates to a user why the RPC failed and allows accounting for the extra address in the new table. This is done in the functional test for the `getrawaddrman` RPC.

  Fixes #28964

ACKs for top commit:
  achow101:
    ACK 99954f914f
  stratospher:
    reACK 99954f9. 🚀
  brunoerg:
    utACK 99954f914f

Tree-SHA512: 2f1299410c0582ebc2071271ba789a8abed905f9a510821f77afbcf2a555ec31397578ea55cbcd162fb828be27afedd3246c7b13ad8883f2f745bb8e04364a76
2024-03-22 14:14:30 -04:00
Ava Chow
85c8a5ec48
Merge bitcoin/bitcoin#29647: Avoid divide-by-zero in header sync logs when NodeClock is behind
fa4d98b3c8 Avoid divide-by-zero in header sync logs when NodeClock is behind (MarcoFalke)
fa58550317 refactor: Modernize header sync logs (MarcoFalke)

Pull request description:

  The log may be confusing, when the NodeClock is behind the current header tip.

  Fix it, by assuming the NodeClock is never behind the current header tip.

ACKs for top commit:
  sipa:
    utACK fa4d98b3c8
  sr-gi:
    tACK [fa4d98b](fa4d98b3c8)
  achow101:
    ACK fa4d98b3c8
  tdb3:
    ACK fa4d98b3c8

Tree-SHA512: 3c5aee4030af387695918c5238012c972ebf850b52e956b5f74590cd7fd4eff0b3e593d411e3eb2a0bb12294af8dc6fbe320f90e4c261399b65a404ff3c3cbd9
2024-03-22 13:18:30 -04:00
MarcoFalke
05416422d3 refactor: Avoid implicit-integer-sign-change in processNewTransaction 2024-03-21 19:40:55 +01:00
MarcoFalke
321f105d08 refactor: Avoid implicit-signed-integer-truncation-or-sign-change in FreedesktopImage 2024-03-21 19:33:10 +01:00
MarcoFalke
6d8eecd33a refactor: Avoid implicit-integer-sign-change in createTransaction 2024-03-21 19:32:12 +01:00
TheCharlatan
824f47294a
node: Use log levels in noui_ThreadSafeMessageBox 2024-03-21 16:41:16 +01:00
TheCharlatan
ddc7872c08
node: Make translations of fatal errors consistent
The extra `bilingual_str` argument of the fatal error notifications and
`node::AbortNode()` is often unused and when used usually contains the
same string as the message argument. It also seems to be confusing,
since it is not consistently used for errors requiring user action. For
example some assumeutxo fatal errors require the user to do something,
but are not translated.

So simplify the fatal error and abort node interfaces by only passing a
translated string. This slightly changes the fatal errors displayed to
the user.

Also de-duplicate the abort error log since it is repeated in noui.cpp.
2024-03-21 16:40:22 +01:00
Luke Dashjr
4f273ab436 Change Luke Dashjr seed to dashjr-list-of-p2p-nodes.us
To avoid issues with DNS blacklisting, I've setup a separate domain for my DNS seed.
2024-03-21 15:26:20 +00:00
willcl-ark
69d6fd676e
cli: improve bitcoin-cli error when not connected
Adds a string suggestion `bitcoin-cli -help` as an additional source of
information.
2024-03-21 10:29:43 +00:00
Ava Chow
bf1b6383db
Merge bitcoin/bitcoin#29671: index: avoid "failed to commit" errors on initialization
f65b0f6401 index: Move last_locator_write_time and logging to end of threadsync loop (Fabian Jahr)

Pull request description:

  In the index sync thread, when initializing an index for the first time, stop callng BaseIndex::Commit when m_best_block_index is null, to avoid a spurious "failed to commit" error from that function. This error started happening in commit 7878f97bf1 from https://github.com/bitcoin/bitcoin/pull/25494 and was reported by pstratem in https://github.com/bitcoin/bitcoin/pull/26903 with an alternate fix.

ACKs for top commit:
  achow101:
    ACK f65b0f6401
  ryanofsky:
    Code review ACK f65b0f6401. Just moved log "Syncing" log line since last commit to avoid having to call now() twice.
  furszy:
    ACK f65b0f6401
  TheCharlatan:
    ACK f65b0f6401

Tree-SHA512: afa8f05786318d36346d167ff53ea0b3bc8abdb0ad04465d199dc3eb91e9f837369e24fcb7e24b5757b02d698ec504e61da6ac365eaf006c874fc07a424a7e20
2024-03-20 16:38:32 -04:00
Martin Zumsande
32c80413fd bench: add benchmark for checkblockindex 2024-03-20 16:30:04 -04:00
Ava Chow
460ae1bf67 wallet, rpc: Add createwalletdescriptor RPC 2024-03-20 16:15:43 -04:00
Ava Chow
8e1a475062 wallet: Be able to retrieve single key from descriptors
Adds CWallet::GetKey which retrieves a single key from the descriptors
stored in the wallet.
2024-03-20 16:15:43 -04:00
Ava Chow
85b1fb19dd wallet: Add GetActiveHDPubKeys to retrieve xpubs from active descriptors 2024-03-20 16:15:43 -04:00
Andrew Chow
73926f2d31 wallet, descspkm: Refactor wallet descriptor generation to standalone func 2024-03-20 16:15:43 -04:00
Andrew Chow
54e74f46ea wallet: Refactor function for single DescSPKM setup
We will need access to a function that sets up a singular
DescriptorSPKM, so refactor this out of the multiple DescriptorSPKM
setup function.
2024-03-20 16:15:43 -04:00
Ava Chow
5febe28c9e wallet, rpc: Add gethdkeys RPC
gethdkeys retrieves all HD keys stored in the wallet's descriptors.
2024-03-20 16:15:43 -04:00
ishaanam
5952292133 wallet, rpc: show mempool conflicts in gettransaction result 2024-03-20 15:05:37 -04:00
ishaanam
54e07ee22f wallet: track mempool conflicts
Behavior changes are:
- if a tx has a mempool conflict, the wallet will not attempt to
  rebroadcast it
- if a txo is spent by a mempool-conflicted tx, that txo is no
  longer considered spent
2024-03-20 15:05:34 -04:00
Ava Chow
b50554babd
Merge bitcoin/bitcoin#29370: assumeutxo: Get rid of faked nTx and nChainTx values
9d9a7458a2 assumeutxo: Remove BLOCK_ASSUMED_VALID flag (Ryan Ofsky)
ef174e9ed2 test: assumeutxo snapshot block CheckBlockIndex crash test (Ryan Ofsky)
0391458d76 test: assumeutxo stale block CheckBlockIndex crash test (Ryan Ofsky)
ef29c8b662 assumeutxo: Get rid of faked nTx and nChainTx values (Ryan Ofsky)
9b97d5bbf9 doc: Improve comments describing setBlockIndexCandidates checks (Ryan Ofsky)
0fd915ee6b validation: Check GuessVerificationProgress is not called with disconnected block (Ryan Ofsky)
63e8fc912c ci: add getchaintxstats ubsan suppressions (Ryan Ofsky)
f252e687ec assumeutxo test: Add RPC test for fake nTx and nChainTx values (Ryan Ofsky)

Pull request description:

  The `PopulateAndValidateSnapshot` function introduced in f6e2da5fb7 from #19806 has been setting fake `nTx` and `nChainTx` values that can show up in RPC results (https://github.com/bitcoin/bitcoin/issues/29328) and make `CBlockIndex` state hard to reason about, because it is difficult to know whether the values are real or fake.

  Revert to previous behavior of setting `nTx` and `nChainTx` to 0 when the values are unknown, instead of faking them. Also drop no-longer needed `BLOCK_ASSUMED_VALID` flag.

  Dropping the faked values also fixes assert failures in the `CheckBlockIndex` `(pindex->nChainTx == pindex->nTx + prev_chain_tx)` check that could happen previously if forked or out-of-order blocks before the snapshot got submitted while the snapshot was being validated. The PR includes two commits adding tests for these failures and describing them in detail.

  Compatibility note: This change could cause new `-checkblockindex` failures if a snapshot was loaded by a previous version of Bitcoin Core and not fully validated, because fake `nTx` values will have been saved to the block index. It would be pretty easy to avoid these failures by adding some compatibility code to `LoadBlockIndex` and changing `nTx` values from 1 to 0 when they are fake (when `(pindex->nStatus & BLOCK_VALID_MASK) < BLOCK_VALID_TRANSACTIONS`), but a little simpler not to worry about being compatible in this case.

ACKs for top commit:
  Sjors:
    re-ACK 9d9a7458a2
  achow101:
    ACK 9d9a7458a2
  mzumsande:
    Tested ACK 9d9a7458a2
  maflcko:
    ACK 9d9a7458a2 🎯

Tree-SHA512: b1e1e2731ec36be30d5f5914042517219378fc31486674030c29d9c7488ed83fb60ba7095600f469dc32f0d8ba79c49ff7706303006507654e1762f26ee416e0
2024-03-20 12:56:49 -04:00
Ava Chow
69ddee6f39
Merge bitcoin/bitcoin#27039: blockstorage: do not flush block to disk if it is already there
dfcef536d0 blockstorage: do not flush block to disk if it is already there (Matthew Zipkin)

Pull request description:

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

  When reindexing from flat-file block storage there is no need to write anything back to disk, since the block data is already there. This PR skips flushing to disk those blocks that already have a known position in the datastore. Skipping this means that users can write-protect the `blk` files on disk which may be useful for security or even safely sharing that data between multiple bitcoind instances.

  `FindBlockPos()` may also flush the undo data file, but again this is skipped if the corresponding block position is known, like during the initial stage of a reindex when block data is being indexed. Once the block index is complete the validation mechanism will call `ConnectBlock()` which will save undo data at that time.

  The call stack looks like this:

  ```
  init()
  ThreadImport() <-- process fReindex flag
  LoadExternalBlockFile()
  AcceptBlock()
  SaveBlockToDisk()
  FindBlockPos()
  FlushBlockFile() <-- unnecessary if block is already on disk
  ```

  A larger refactor of this part of the code was started by mzumsande here:  https://github.com/mzumsande/bitcoin/tree/202207_refactor_findblockpos including this fix, reviewers can let me know if the changes should be combined.

ACKs for top commit:
  sipa:
    utACK dfcef536d0
  mzumsande:
    re-ACK dfcef536d0
  achow101:
    ACK dfcef536d0
  furszy:
    Rebase diff ACK dfcef53.

Tree-SHA512: 385c5ac1288b325135398d0ddd3ab788fa98cc0ca19bd2474c74039f2ce70d5088c1d1c9d4dd10aefcbd4c757767ec5805d07ba8cee9289a66f96e6f9eaa5279
2024-03-20 12:41:33 -04:00
Ava Chow
0b96a1925e
Merge bitcoin/bitcoin#28955: index: block filters sync, reduce disk read operations by caching last header
99afb9d15a refactor: init, simplify index shutdown code (furszy)
0faafb57f8 index: decrease ThreadSync cs_main contention (furszy)
f1469eb454 index: cache last block filter header (furszy)
a6756ecdb2 index: blockfilter, decouple header lookup into its own function (furszy)
331f044e3b index: blockfilter, decouple Write into its own function (furszy)
bcbd7eb8d4 bench: basic block filter index initial sync (furszy)

Pull request description:

  Work decoupled from #26966 per request.

  The aim is to remove an unnecessary disk read operation that currently takes place with every new arriving block (or scanned block during background sync). Instead of reading the last filter header from disk merely to access its hash for constructing the next filter, this work caches it, occupying just 32 more bytes in memory.

  Also, reduces `cs_main` lock contention during the index initial sync process. And, simplifies the indexes initialization and shutdown procedure.

  Testing Note:
  To compare the changes, added a pretty basic benchmark in the second commit. Alternatively, could also test the changes by timing the block filter sync from scratch on any network; start the node with `-blockfilterindex` and monitor the logs until the syncing process finish.

  Local Benchmark Results:

  *Master (c252a0fc0f):
  |               ns/op |                op/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |      132,042,516.60 |                7.57 |    0.3% |      7.79 | `BlockFilterIndexSync`

  *PR (43a212cfdac6c64e82b601c664443d022f191520):
  |               ns/op |                op/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |      126,915,841.60 |                7.88 |    0.6% |      7.51 | `BlockFilterIndexSync`

ACKs for top commit:
  Sjors:
    re-ACK 99afb9d15a
  achow101:
    ACK 99afb9d15a
  TheCharlatan:
    Re-ACK 99afb9d15a
  andrewtoth:
    ACK 99afb9d15a

Tree-SHA512: 927daadd68f4ee1ca781a89519539b895f5185a76ebaf525fbc246ea8dcf40d44a82def00ac34b188640802844b312270067f1b33e65a2479e06be9169c616de
2024-03-20 12:30:38 -04:00
Fabian Jahr
f65b0f6401
index: Move last_locator_write_time and logging to end of threadsync loop
This avoids having commit print a needless error message during init.

Co-authored-by: furszy <mfurszy@protonmail.com>
2024-03-19 18:20:39 +01:00
fanquake
479ecc0515
Merge bitcoin/bitcoin#29192: Weaken serfloat tests
6e873df347 serfloat: improve/simplify tests (Pieter Wuille)
b45f1f5658 serfloat: do not test encode(bits)=bits anymore (Pieter Wuille)

Pull request description:

  Closes #28941.

  Our current tests for serfloat verify two distinct properties:
  1. Whether they roundtrip `double`->`uint64_t`->`double` (excluding NaN values) on all systems.
  2. Whether on systems with a typical floating point unit that encoding matches the hardware representation, as before v22.0, we would dump the hardware representation directly to disk and we wanted to retain compatibility with that.

  #28941 seems to show that the second property doesn't always hold, but just for "subnormal" numbers (below $2^{-1021}$). Since we don't care about encoding these numbers, we could exclude such subnormal numbers from the hardware-identical representation test, but this PR goes further and just drops the second property entirely, as I don't think we care about edge-case compatibility with pre-v22.0 code for fee_estimates.dat (the only place it is used).

ACKs for top commit:
  glozow:
    ACK 6e873df347
  fanquake:
    ACK 6e873df347 - It's not as much of a priority, but I think we could still backport this.

Tree-SHA512: e18ceee0753a7ee7e999fdfa10b014dc5bb67b6ef79522a0f8c76b889adcfa785772fc26ed7559bcb5a09a9938e243bb54eedd9549bc59080a2c8090155e2267
2024-03-19 17:09:07 +00:00
0xb10c
6205466512
rpc: "addpeeraddress tried" return error on failure
When trying to add an address to the IP address manager tried table,
it's first added to the new table and then moved to the tried table.
Previously, adding a conflicting address to the address manager's
tried table with test-only `addpeeraddress tried=true` RPC would
return `{ "success": true }`. However, the address would not be added
to the tried table, but would remain in the new table. This caused,
e.g., issue 28964.

This is fixed by returning `{ "success": false, "error":
"failed-adding-to-tried" }` for failed tried table additions. Since
the address remaining in the new table can't be removed (the address
manager interface does not support removing addresses at the moment
and adding this seems to be a bigger effort), an error message is
returned. This indicates to a user why the RPC failed and allows
accounting for the extra address in the new table.

Also:
To check the number of addresses in each addrman table,
the addrman checks were re-run and the log output of this check
was asserted. Ideally, logs shouldn't be used as an interface
in automated tests. To avoid asserting the logs, use the getaddrmaninfo
and getrawaddrman RPCs (which weren't implemented when the test was added).
Removing the "getnodeaddress" calls would also remove the addrman checks
from the test, which could reduce the test coverage. To avoid this,
these are kept.
2024-03-19 17:38:33 +01:00
fanquake
0f89e86516
Merge bitcoin/bitcoin#29667: fuzz: actually test garbage >64b in p2p transport test
626f8e398e fuzz: actually test garbage >64b in p2p transport test (Pieter Wuille)

Pull request description:

  This fixes an oversight from #28196: in the `p2p_transport_bidirectional_v2` fuzz test, when the desired garbage length is over 64 bytes, the code would actually use garbage length 0. Fix this.

ACKs for top commit:
  instagibbs:
    ACK 626f8e398e
  brunoerg:
    crACK 626f8e398e

Tree-SHA512: f6346367adb10464b6c9d20aef43625531d2a4d8110887ad03214b8c1907b83560f2dd5b5415e2180a40b4cd276d51881b32b60c740471b5c6bb218aa19848d8
2024-03-19 12:20:33 +00:00
glozow
5d045c31a5
Merge bitcoin/bitcoin#28950: RPC: Add maxfeerate and maxburnamount args to submitpackage
38f70ba6ac RPC: Add maxfeerate and maxburnamount args to submitpackage (Greg Sanders)

Pull request description:

  Resolves https://github.com/bitcoin/bitcoin/issues/28949

  I couldn't manage to do it very cleanly outside of (sub)package evaluation itself, since it would change the current interface very heavily. Instead I threaded through the max fee argument and used that directly via ATMPArgs. From that perspective, this is somewhat a reversion from https://github.com/bitcoin/bitcoin/pull/19339. In a post-cluster mempool world, these checks could be consolidated to right after the given (ancestor) package is linearized/chunked, by just checking the feerate of the top chunk and rejecting the submission entirely if the top chunk is too high.

  The implication here is that subpackages can be submitted to the mempool prior to hitting this new fee-based error condition.

ACKs for top commit:
  ismaelsadeeq:
    Re-ACK 38f70ba6ac 👍🏾
  glozow:
    ACK 38f70ba6ac with some non-blocking nits
  murchandamus:
    LGTM, code review ACK 38f70ba6ac

Tree-SHA512: 38212aa9de25730944cee58b0806a3d37097e42719af8dd7de91ce86bb5d9770b6f7c37354bf418bd8ba571c52947da1dcdbb968bf429dd1dbdf8715315af18f
2024-03-18 18:24:06 +00:00
fanquake
80f8b92f4f
remove libbitcoinconsensus
This was deprecated in v27.0, for removal in v28.0.
See discussion in PR #29189.
2024-03-18 16:59:39 +00:00
Ryan Ofsky
9d9a7458a2 assumeutxo: Remove BLOCK_ASSUMED_VALID flag
Flag adds complexity and is not currently used for anything.
2024-03-18 11:28:40 -05:00
Ryan Ofsky
ef29c8b662 assumeutxo: Get rid of faked nTx and nChainTx values
The `PopulateAndValidateSnapshot` function introduced in
f6e2da5fb7 from #19806 has been setting fake
`nTx` and `nChainTx` values that can show up in RPC results (see #29328) and
make `CBlockIndex` state hard to reason about, because it is difficult to know
whether the values are real or fake.

Revert to previous behavior of setting `nTx` and `nChainTx` to 0 when the
values are unknown, instead of faking them.

This commit fixes at least two assert failures in the (pindex->nChainTx ==
pindex->nTx + prev_chain_tx) check that would happen previously. Tests for
these failures are added separately in the next two commits.

Compatibility note: This change could result in -checkblockindex failures if a
snapshot was loaded by a previous version of Bitcoin Core and not fully
validated, because fake nTx values will have been saved to the block index. It
would be pretty easy to avoid these failures by adding some compatibility code
to `LoadBlockIndex` and changing `nTx` values from 1 to 0 when they are fake
(when `(pindex->nStatus & BLOCK_VALID_MASK) < BLOCK_VALID_TRANSACTIONS`), but a
little simpler not to worry about being compatible in this case.
2024-03-18 11:28:40 -05:00
Ryan Ofsky
9b97d5bbf9 doc: Improve comments describing setBlockIndexCandidates checks
The checks are changing slightly in the next commit, so try to explains the
ones that exist to avoid confusion
(https://github.com/bitcoin/bitcoin/pull/29370#discussion_r1499519079)
2024-03-18 11:28:40 -05:00
Ryan Ofsky
0fd915ee6b validation: Check GuessVerificationProgress is not called with disconnected block
Use Assume macro as suggested https://github.com/bitcoin/bitcoin/pull/29370#discussion_r1479427801
2024-03-18 11:28:40 -05:00
Ava Chow
66632e5c24 wallet: Add IsActiveScriptPubKeyMan
Given a ScriptPubKeyMan, it's useful to ask the wallet whether it is
currently active.
2024-03-18 11:53:23 -04:00
Ava Chow
fa6a259985 desc spkm: Add functions to retrieve specific private keys 2024-03-18 11:53:20 -04:00
fanquake
aba9024c0c
Merge bitcoin/bitcoin#29659: ci: Bump TIDY_LLVM_V
636c9862cf ci: Bump `TIDY_LLVM_V` (Hennadii Stepanov)

Pull request description:

  This PR switches to the latest [IWYU 0.22](https://github.com/include-what-you-use/include-what-you-use/releases/tag/0.22), which is compatible with Clang 18.

ACKs for top commit:
  fanquake:
    ACK 636c9862cf

Tree-SHA512: 78ce89244c5e487dd1be8b4bd2ca6f06d19b04b78289ebc21985110574053545dcce5eb622edf2bede2cf7bb58360170e976d30a4484a127d34dd17b1c604e9c
2024-03-18 15:10:31 +00:00
MarcoFalke
fa72dcbfa5
refactor: FormatISO8601* without gmtime* 2024-03-18 16:01:24 +01:00
MarcoFalke
fa2c486afc
Revert "time: add runtime sanity check"
This reverts commit 3c2e16be22.
2024-03-18 16:01:08 +01:00
Greg Sanders
7295986778 Unit tests for CalculateFeerateDiagramsForRBF 2024-03-18 10:32:00 -04:00
Greg Sanders
b767e6bd47 test: unit test for ImprovesFeerateDiagram 2024-03-18 10:32:00 -04:00
Greg Sanders
7e89b659e1 Add fuzz test for FeeFrac 2024-03-18 10:32:00 -04:00
Greg Sanders
4d6528a3d6 fuzz: fuzz diagram creation and comparison
Co-authored-by: Suhas Daftuar <sdaftuar@chaincode.com>
Co-authored-by: Pieter Wuille <pieter.wuille@gmail.com>
2024-03-18 10:32:00 -04:00
Greg Sanders
e9c5aeb11d test: Add tests for CompareFeerateDiagram and CheckConflictTopology 2024-03-18 10:32:00 -04:00
Greg Sanders
588a98dccc fuzz: Add fuzz target for ImprovesFeerateDiagram
Co-authored-by: Suhas Daftuar <sdaftuar@chaincode.com>
2024-03-18 10:32:00 -04:00
Greg Sanders
2079b80854 Implement ImprovesFeerateDiagram
This new function takes the populated sets of
direct and all conflicts computed in the current
mempool, assuming the replacements are a single
chunk, and computes a diagram check.

The diagram check only works against cluster
sizes of 2 or less, and fails if it encounters
a different topology.

Co-authored-by: Suhas Daftuar <sdaftuar@chaincode.com>
2024-03-18 10:32:00 -04:00
Greg Sanders
66d966dcfa Add FeeFrac unit tests
Co-authored-by: Suhas Daftuar <sdaftuar@chaincode.com>
2024-03-18 10:32:00 -04:00
Greg Sanders
ce8e22542e Add FeeFrac utils
Co-authored-by: Suhas Daftuar <sdaftuar@chaincode.com>
Co-authored-by: Pieter Wuille <pieter.wuille@gmail.com>
2024-03-18 10:32:00 -04:00
Pieter Wuille
626f8e398e fuzz: actually test garbage >64b in p2p transport test 2024-03-17 11:35:01 -04:00
ishaanam
d64922b590 wallet refactor: use CWalletTx member functions to determine tx state 2024-03-15 18:03:42 -04:00
Hennadii Stepanov
636c9862cf
ci: Bump TIDY_LLVM_V
This change switches to the latest IWYU 0.22, which is compatible with
Clang 18.
2024-03-15 13:34:05 +00:00
Luke Dashjr
d1ed09a764 Bugfix: GUI: Help messages already have a trailing newline, so don't add an extra one 2024-03-15 00:38:33 +00:00
Luke Dashjr
c3e632b441 Bugfix: bitcoin-cli: Check length of peer.transport_protocol_type 2024-03-15 00:32:49 +00:00
ishaanam
ffe5ff1fb6 scripted-diff: wallet: s/TxStateConflicted/TxStateBlockConflicted
-BEGIN VERIFY SCRIPT-
sed -i 's/TxStateConflicted/TxStateBlockConflicted/g' src/wallet/wallet.cpp src/wallet/interfaces.cpp src/wallet/transaction.h src/wallet/transaction.cpp
sed -i 's/isConflicted/isBlockConflicted/g' src/wallet/transaction.h src/wallet/wallet.cpp
-END VERIFY SCRIPT-
2024-03-14 17:38:39 -04:00
MarcoFalke
fa5844f06d
Remove unused g++-10 workaround
This reverts d4999d40b9
2024-03-14 15:53:43 +01:00
Matthew Zipkin
c70e4fc9a3
netbase: remove unnecessary log message
see https://github.com/bitcoin/bitcoin/pull/27375#issuecomment-1994498888
2024-03-13 14:09:50 -04:00
MarcoFalke
fa4d98b3c8
Avoid divide-by-zero in header sync logs when NodeClock is behind 2024-03-13 16:17:08 +01:00
MarcoFalke
fa58550317
refactor: Modernize header sync logs
No change in behavior, only the modern aliases and types are used.
2024-03-13 16:16:35 +01:00
Ava Chow
ef6329f052
Merge bitcoin/bitcoin#28193: test: add script compression coverage for not-on-curve P2PK outputs
28287cfbe1 test: add script compression coverage for not-on-curve P2PK outputs (Sebastian Falbesoner)

Pull request description:

  This PR adds unit test coverage for the script compression functions `{Compress,Decompress}Script` in the special case of uncompressed P2PK outputs (scriptPubKey: OP_PUSH65 <0x04 ....> OP_CHECKSIG) with [pubkeys that are not fully valid](44b05bf3fe/src/pubkey.cpp (L297-L302)), i.e. where the encoded point is not on the secp256k1 curve. For those outputs, script compression is not possible, as the y coordinate of the pubkey can't be recovered (see also call-site of `IsToPubKey`):

  44b05bf3fe/src/compressor.cpp (L49-L50)

  Likewise, for a compressed script of an uncompressed P2PK script (i.e. compression ids 4 and 5) where the x coordinate is not on the curve, decompression fails:

  44b05bf3fe/src/compressor.cpp (L122-L129)

  Note that the term "compression" is used here in two different meanings (though they are related), which might be a little confusing. The encoding of a pubkey can either be compressed (33-bytes with 0x02/0x03 prefixes) or uncompressed (65-bytes with 0x04 prefix). On the other hand there is also compression for whole output scripts, which is used for storing scriptPubKeys in the UTXO set in a compact way (and also for the `dumptxoutset` result, accordingly). P2PK output scripts with uncompressed pubkeys get compressed by storing only the x-coordinate and the sign as a prefix (0x04 = even, 0x05 = odd). Was diving deeper into the subject while working on https://github.com/bitcoin/bitcoin/pull/27432, where the script decompression of uncompressed P2PK needed special handling (see also https://github.com/bitcoin/bitcoin/issues/24628#issuecomment-1108798536).

  Trivia: as of now (block 801066), there are 13 uncompressed P2PK outputs in the UTXO set with a pubkey not on the curve (which obviously means they are unspendable).

ACKs for top commit:
  achow101:
    ACK 28287cfbe1
  tdb3:
    ACK for 28287cfbe1.
  cbergqvist:
    ACK 28287cf!
  marcofleon:
    Nicely done, ACK 28287cfbe1. Built the PR branch, ran the unit and functional tests, everything passed.

Tree-SHA512: 777b6c3065654fbfa1ce94926f4cadb91a9ca9dc4dd4af6008ad77bd1da5416f156ad0dfa880d26faab2e168bf9b27e0a068abc9a2be2534d82bee61ee055c65
2024-03-13 11:02:23 -04:00
Greg Sanders
38f70ba6ac RPC: Add maxfeerate and maxburnamount args to submitpackage
And thread the feerate value through ProcessNewPackage to
reject individual transactions that exceed the given
feerate. This allows subpackage processing, and is
compatible with future package RBF work.
2024-03-13 09:45:43 -04:00
Ava Chow
c38157b9b9
Merge bitcoin/bitcoin#29606: refactor: Reserve memory for ToLower/ToUpper conversions
6f2f4a4d09 Reserve memory for ToLower/ToUpper conversions (Lőrinc)

Pull request description:

  Similarly to https://github.com/bitcoin/bitcoin/pull/29458, we're preallocating the result string based on the input string's length.
  The methods were already [covered by tests](https://github.com/bitcoin/bitcoin/blob/master/src/test/util_tests.cpp#L1250-L1276).

ACKs for top commit:
  tdb3:
    ACK for 6f2f4a4d09
  maflcko:
    lgtm ACK 6f2f4a4d09
  achow101:
    ACK 6f2f4a4d09
  Empact:
    Code Review ACK 6f2f4a4d09
  stickies-v:
    ACK 6f2f4a4d09

Tree-SHA512: e3ba7af77decdc73272d804c94fef0b11028a85f3c0ea1ed6386672611b1c35fce151f02e64f5bb5acb5ba506aaa54577719b07925b9cc745143cf5c7e5eb262
2024-03-13 08:18:06 -04:00
Ava Chow
264ca9db24
Merge bitcoin/bitcoin#29619: refactor: consolidate MempoolAcceptResult processing
07cd510ffe [refactor] consolidate invalid MempoolAcceptResult processing (glozow)
9353aa4066 [refactor] consolidate valid MempoolAcceptResult processing (glozow)

Pull request description:

  Every time we try to `ProcessTransaction` (i.e. submit a tx to mempool), we use the result to update a few net processing data structures. For example, after a failure, the {wtxid, txid, both, neither} (depending on reason) should be cached in `m_recent_rejects` so we don't try to download/validate it again.

  There are 2 current places and at least 1 future place where we need to process `MempoolAcceptResult`:
  - In the `ProcessMessage` logic after receiving and validating a tx
  - In `ProcessOrphanTx` where we retry orphans
  - With #28970, after processing a package of transactions, we should do these updates for each tx in the package.

  Consolidate this code so it isn't repeated in 2 places and so we can reuse it in a future PR.

ACKs for top commit:
  instagibbs:
    ACK 07cd510ffe
  achow101:
    ACK 07cd510ffe
  dergoegge:
    Code review ACK 07cd510ffe
  TheCharlatan:
    ACK 07cd510ffe

Tree-SHA512: c4e74cb65e4f52882fca52e6682efa5dcf1562d98418454e09be256ffd026caae642a90aa5b9cccaae214be240d6f4be9d87b516953b2ee69a655f16ea569ed9
2024-03-13 07:26:34 -04:00
Ava Chow
0ed2c130e7
Merge bitcoin/bitcoin#27375: net: support unix domain sockets for -proxy and -onion
567cec9a05 doc: add release notes and help text for unix sockets (Matthew Zipkin)
bfe5192891 test: cover UNIX sockets in feature_proxy.py (Matthew Zipkin)
c65c0d0163 init: allow UNIX socket path for -proxy and -onion (Matthew Zipkin)
c3bd43142e gui: accomodate unix socket Proxy in updateDefaultProxyNets() (Matthew Zipkin)
a88bf9dedd i2p: construct Session with Proxy instead of CService (Matthew Zipkin)
d9318a37ec net: split ConnectToSocket() from ConnectDirectly() for unix sockets (Matthew Zipkin)
ac2ecf3182 proxy: rename randomize_credentials to m_randomize_credentials (Matthew Zipkin)
a89c3f59dc netbase: extend Proxy class to wrap UNIX socket as well as TCP (Matthew Zipkin)
3a7d6548ef net: move CreateSock() calls from ConnectNode() to netbase methods (Matthew Zipkin)
74f568cb6f netbase: allow CreateSock() to create UNIX sockets if supported (Matthew Zipkin)
bae86c8d31 netbase: refactor CreateSock() to accept sa_family_t (Matthew Zipkin)
adb3a3e51d configure: test for unix domain sockets (Matthew Zipkin)

Pull request description:

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

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

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

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

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

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

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

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

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

Tree-SHA512: de81860e56d5de83217a18df4c35297732b4ad491e293a0153d2d02a0bde1d022700a1131279b187ef219651487537354b9d06d10fde56225500c7e257df92c1
2024-03-13 06:53:07 -04:00
fanquake
1105aa46dd
Merge bitcoin/bitcoin#29633: log: Remove error() reference
d0e6564240 log: Remove error() reference (Fabian Jahr)

Pull request description:

  Mini-followup to #29236 that was just merged. Removes a reference to `error()` that was missed in a comment.

ACKs for top commit:
  ryanofsky:
    Code review ACK d0e6564240. Just dropped LogPrintf reference since last review
  stickies-v:
    ACK d0e6564240
  Empact:
    ACK d0e6564240

Tree-SHA512: 8abe4895951013c2ceca9a57743aacabaf8af831d07eee9ae8372c121c16e88b7226f0e537200c3464792e19ac7e03b57ba0be31f43add8802753972b0aefc48
2024-03-12 18:44:39 +00:00
Ava Chow
bde3db40f6
Merge bitcoin/bitcoin#26415: rpc,rest,zmq: faster getblock, NotifyBlock and rest_block by reading raw block
e710cefd57 rest: read raw block in rest_block and deserialize for json (Andrew Toth)
95ce0783a6 rpc: read raw block in getblock and deserialize for verbosity > 0 (Andrew Toth)
0865ab8712 test: check more details on zmq raw block response (Andrew Toth)
38265cc14e zmq: read raw block with ReadRawBlockFromDisk (Andrew Toth)
da338aada7 blockstorage: check nPos in ReadRawBlockFromDisk before seeking back (Andrew Toth)

Pull request description:

  For the `getblock` endpoint with `verbosity=0`, the  `rest_block` REST endpoint for `bin` and `hex`, and zmq `NotifyBlock` we don't have to deserialize the block since we're just sending the raw data. This PR uses `ReadRawBlockFromDisk` instead of `ReadBlockFromDisk` to serve these requests, and only deserializes for `verbosity > 0` and `json` REST requests. See benchmarks in https://github.com/bitcoin/bitcoin/pull/26684.

  Benchmarked using ApacheBench. Requesting block 750,000 in binary 10k times on a single core (set `-rest=1` in config):
  `ab -n 10000 -c 1 "http://127.0.0.1:8332/rest/block/0000000000000000000592a974b1b9f087cb77628bb4a097d5c2c11b3476a58e.bin"`

  On master, mean time 15ms.
  On this branch, mean time 1ms.

  For RPC
  ```
  echo '{"jsonrpc": "1.0", "id": "curltest", "method": "getblock", "params": ["0000000000000000000592a974b1b9f087cb77628bb4a097d5c2c11b3476a58e", 0]}' > /tmp/data.json
  ab -p /tmp/data.json -n 1000 -c 1 -A user:password "http://127.0.0.1:8332/"
  ```
  On master, mean time 32ms
  On this branch, mean time 13ms

ACKs for top commit:
  achow101:
    re-ACK e710cefd57

Tree-SHA512: 4cea13c7b563b2139d041b1fdcfdb793c8cc688654ae08db07e7ee6b875c5e582b8185db3ae603abbfb06d2164724f29205774620b48c493726b991999af289e
2024-03-12 13:17:57 -04:00
Ava Chow
bef99176e6
Merge bitcoin/bitcoin#27114: p2p: Allow whitelisting manual connections
0a533613fb docs: add release notes for #27114 (brunoerg)
e6b8f19de9 test: add coverage for whitelisting manual connections (brunoerg)
c985eb854c test: add option to speed up tx relay/mempool sync (brunoerg)
66bc6e2d17 Accept "in" and "out" flags to -whitelist to allow whitelisting manual connections (Luke Dashjr)
8e06be347c net_processing: Move extra service flag into InitializeNode (Luke Dashjr)
9133fd69a5 net: Move `NetPermissionFlags::Implicit` verification to `AddWhitelistPermissionFlags` (Luke Dashjr)
2863d7dddb net: store `-whitelist{force}relay` values in `CConnman` (brunoerg)

Pull request description:

  Revives #17167. It allows whitelisting manual connections. Fixes #9923

  Since there are some PRs/issues around this topic, I'll list some motivations/comments for whitelisting outbound connections from them:
  - Speed-up tx relay/mempool sync for testing purposes (my personal motivation for this) - In #26970, theStack pointed out that we whitelist peers to speed up tx relay for fast mempool synchronization, however, since it applies only for inbound connections and considering the topology `node0 <--- node1 <---- node2 <--- ... <-- nodeN`,  if a tx is submitted from any node other than node0, the mempool synchronization can take quite long.
  - https://github.com/bitcoin/bitcoin/pull/29058#issuecomment-1865155764 - "Before enabling -v2transport by default (which I'd image may happen after https://github.com/bitcoin/bitcoin/pull/24748) we could consider a way to force manual connections to be only-v1 or even only-v2 (disabling reconnect-with-v1). A possibility could be through a net permission flag, if https://github.com/bitcoin/bitcoin/pull/27114 makes it in."
  - https://github.com/bitcoin/bitcoin/pull/17167#issuecomment-1168606032 - "This would allow us to use https://github.com/bitcoin/bitcoin/pull/25355 when making outgoing connections to all nodes, except to whitelisted ones for which we would use our persistent I2P address."
  - Force-relay/mempool permissions for a node you intentionally connected to.

ACKs for top commit:
  achow101:
    ACK 0a533613fb
  sr-gi:
    re-ACK [0a53361](0a533613fb)
  pinheadmz:
    ACK 0a533613fb

Tree-SHA512: 97a79bb854110da04540897d2619eda409d829016aafdf1825ab5515334b0b42ef82f33cd41587af235b3af6ddcec3f2905ca038b5ab22e4c8a03d34f27aebe1
2024-03-12 12:59:02 -04:00
Andrew Toth
e710cefd57
rest: read raw block in rest_block and deserialize for json
Note that for speed this commit also removes the proof of work and
signet signature checks before returning the block in getblock.
It is assumed if a block is stored it will be valid.
2024-03-12 12:48:04 -04:00
Andrew Toth
95ce0783a6
rpc: read raw block in getblock and deserialize for verbosity > 0
Note that for speed this commit also removes the proof of work and
signet signature checks before returning the block in getblock.
It is assumed if a block is stored it will be valid.
2024-03-12 12:47:17 -04:00
Andrew Toth
38265cc14e
zmq: read raw block with ReadRawBlockFromDisk 2024-03-12 12:46:46 -04:00
Andrew Toth
da338aada7
blockstorage: check nPos in ReadRawBlockFromDisk before seeking back
ReadRawBlockFromDisk assumes a non-null pos that has an nPos >= 8.
This simple check makes the function safer to call in the future,
so callers don't need to worry about causing UB if the pos is null.
2024-03-12 12:46:07 -04:00
Ava Chow
12dae637a4
Merge bitcoin/bitcoin#29306: policy: enable sibling eviction for v3 transactions
1342a31f3a [functional test] sibling eviction (glozow)
5fbab37859 [unit test] sibling not returned from SingleV3Checks if 1p2c or 3gen (glozow)
170306728a [policy] sibling eviction for v3 transactions (glozow)
b5d15f764f [refactor] return pair from SingleV3Checks (glozow)

Pull request description:

  When we receive a v3 transaction that would bust a mempool transaction's descendant limit, instead of rejecting the new tx, consider replacing the other descendant if it is much higher feerate (using existing RBF criteria to assess that it's more incentive compatible and to avoid DoS).

  Delving post with more background and motivation: https://delvingbitcoin.org/t/sibling-eviction-for-v3-transactions/472

ACKs for top commit:
  sdaftuar:
    ACK 1342a31f3a
  achow101:
    ACK 1342a31f3a
  instagibbs:
    ACK 1342a31f3a

Tree-SHA512: dd957d49e51db78758f566c49bddc579b72478e371275c592d3d5ba097d20de47a6c81952045021b99d82a787f5b799baf16dd0ee0e6de90ba12e21e275352be
2024-03-12 12:19:48 -04:00
Fabian Jahr
d0e6564240
log: Remove error() reference 2024-03-12 16:26:15 +01:00
furszy
99afb9d15a
refactor: init, simplify index shutdown code 2024-03-12 11:55:04 -03:00
furszy
0faafb57f8
index: decrease ThreadSync cs_main contention
Only NextSyncBlock requires cs_main lock. The
other function calls like Commit or Rewind will
lock or not cs_main internally when they need it.

Avoiding keeping cs_main locked when Commit() or
Rewind() write data to disk.
2024-03-12 11:55:04 -03:00
furszy
f1469eb454
index: cache last block filter header
Avoid disk read operations on every new processed block.
2024-03-12 11:55:04 -03:00
Matthew Zipkin
dfcef536d0
blockstorage: do not flush block to disk if it is already there
test: ensure we can reindex from read-only block files now
2024-03-12 10:09:53 -04:00
furszy
a6756ecdb2
index: blockfilter, decouple header lookup into its own function 2024-03-12 09:31:39 -03:00
furszy
331f044e3b
index: blockfilter, decouple Write into its own function 2024-03-12 09:30:42 -03:00
furszy
bcbd7eb8d4
bench: basic block filter index initial sync
Introduce benchmark for the block filter index sync.
And makes synchronous 'Sync()' mechanism accessible.
2024-03-12 09:30:42 -03:00
fanquake
31be1a4767
Merge bitcoin/bitcoin#29236: log: Nuke error(...)
fa39151394 refactor: Remove unused error() (MarcoFalke)
fad0335517 scripted-diff: Replace error() with LogError() (MarcoFalke)
fa808fb749 refactor: Make error() return type void (MarcoFalke)
fa1d624348 scripted-diff:  return error(...);  ==>  error(...); return false; (MarcoFalke)
fa9a5e80ab refactor: Add missing {} around error() calls (MarcoFalke)

Pull request description:

  `error(...)` has many issues:

  * It is often used in the context of `return error(...)`, implying that it has a "fancy" type, creating confusion with `util::Result/Error`
  * `-logsourcelocations` does not work with it, because it will pretend the error happened inside of `logging.h`
  * The log line contains `ERROR: `, as opposed to `[error]`, like for other errors logged with `LogError`.

  Fix all issues by removing it.

ACKs for top commit:
  fjahr:
    re-utACK fa39151394
  stickies-v:
    re-ACK fa39151394, no changes since 4a903741b0
  ryanofsky:
    Code review ACK fa39151394. Just rebase since last review

Tree-SHA512: ec5bb502ab0d3733fdb14a8a00762638fce0417afd8dd6294ae0d485ce2b7ca5b1efeb50fc2cd7467f6c652e4ed3e99b0f283b08aeca04bbfb7ea4f2c95d283a
2024-03-12 10:05:06 +00:00
Ava Chow
a945f09fa6
Merge bitcoin/bitcoin#29007: test: create deterministic addrman in the functional tests
2cc8ca19f4 [test] Use deterministic addrman in addrman info tests (stratospher)
a897866109 [test] Restart a node with empty addrman (stratospher)
71c19915c0 [test] Use deterministic addrman in addpeeraddress test (stratospher)
7b868e6b67 Revert "test: avoid non-determinism in asmap-addrman test" (stratospher)
69e091f3e1 [init] Create deterministic addrman in tests using -test=addrman (stratospher)
be25ac3092 [init] Remove -addrmantest command line arg (stratospher)
802e6e128b [init] Add new command line arg for use only in functional tests (stratospher)

Pull request description:

  An address is placed in a `[bucket,position]` in the addrman table (new table or tried table) using the `addpeeraddress` RPC. This `[bucket,position]` is calculated using `nKey`(and other metrics) for the addrman which is chosen randomly during every run.

  Supposing there are 2 addresses to be placed in an addrman table. During every test run, a different `[bucket,position]` would be calculated for each address.These calculated `[bucket,position]` could even be the same for the 2 addresses in some test runs and result in collisions in the addrman. We wouldn't be able to predict when the collisions are going to happen because we can't predict the `nKey` value which is chosen at random. This can cause flaky tests.

  Because of these non deterministic collisions, we are limited in what we can do to test addrman functionality. Currently in our tests don't add a second address to prevent these collisions from happening - we only keep 1 address in the new table and 1 address in the tried table. See https://github.com/bitcoin/bitcoin/pull/26988#discussion_r1091145647, https://github.com/bitcoin/bitcoin/pull/23084, [#22831(comment)](https://github.com/bitcoin/bitcoin/pull/22831/files#r708302639).

  This PR lets us create a deterministic addrman with fixed `nKey` so that we can know the `[bucket,position]` collisions beforehand, safely add more addresses in an addrman table and write more extensive tests.

ACKs for top commit:
  amitiuttarwar:
    ACK 2cc8ca19f4
  achow101:
    ACK 2cc8ca19f4
  0xB10C:
    ACK 2cc8ca19f4
  mzumsande:
    Code Review ACK 2cc8ca19f4

Tree-SHA512: 8acd9bdfe7de1eb44d22373bf13533d8ecf602df966fdd5b8b78afcd8cc35a286c95d2712f67a89473a0d68dded7d38f5599f6e4bf95a6589475444545bfb189
2024-03-11 10:29:31 -04:00
Ava Chow
6dda050865
Merge bitcoin/bitcoin#29458: refactor: Preallocate result in TryParseHex to avoid resizing
a19235c14b Preallocate result in `TryParseHex` to avoid resizing (Lőrinc)
b7489ecb52 Add benchmark for TryParseHex (Lőrinc)

Pull request description:

  This pull request introduces optimizations to the `TryParseHex` function, focusing primarily on the ideal case (valid hexadecimal input without spaces).
  A new benchmark, `HexParse` was introduced in a separate commit.

  The main optimization preallocates the result vector based on the input string's length. This aims to completely avoid costly dynamic reallocations when no spaces are present.

  ------------

  Before:
  ```
  |           ns/base16 |            base16/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |                1.60 |      623,238,893.11 |    0.3% |      0.01 | `HexParse`
  |                1.65 |      606,747,566.34 |    0.6% |      0.01 | `HexParse`
  |                1.60 |      626,149,544.07 |    0.3% |      0.01 | `HexParse`
  ```

  After:
  ```
  |           ns/base16 |            base16/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |                0.68 |    1,465,555,976.27 |    0.8% |      0.01 | `HexParse`
  |                0.68 |    1,472,962,920.18 |    0.3% |      0.01 | `HexParse`
  |                0.68 |    1,476,159,423.00 |    0.3% |      0.01 | `HexParse`
  ```

ACKs for top commit:
  achow101:
    ACK a19235c14b
  hebasto:
    ACK a19235c14b.
  andrewtoth:
    Re-ACK a19235c14b
  Empact:
    Re-ACK a19235c14b

Tree-SHA512: e09a59791104be3fd1026862ce98de9efafa1f949626fa01e3b7d58e6a2ef02a11f0de55ddba5c43230a53effd24e6d368c1e12848b17e8ce91d7908a59333f0
2024-03-11 09:59:35 -04:00
Ava Chow
b4a05751b6
Merge bitcoin/bitcoin#29586: wallet: default wallet migration, modify inconvenient backup filename
a951dba3a9 wallet: default wallet migration, modify inconvenient backup filename (furszy)

Pull request description:

  Fixes #29584

  On default legacy wallets, the backup filename starts with an "-" due to the wallet name being empty. This is inconvenient for systems who treat what follows the initial "-" character as flags.

  Note:
  As the user can freely set the wallet name to anything, we could also guard the backup filename against other inconvenient characters in the future (we need to be careful here, because the wallet name could also be a path).

ACKs for top commit:
  achow101:
    ACK a951dba3a9
  brunoerg:
    utACK a951dba3a9
  vasild:
    ACK  a951dba3a9

Tree-SHA512: 6347bb12cfb50526a4baad96e4f1df9d82b493f79f0a0f7e0a1c8335a86a1e8e147c7b7f95cec6ede6f4507506a7eaf7972bd35131a2d5ed4cbbf38d94f0a9ca
2024-03-11 08:59:06 -04:00
MarcoFalke
fa39151394
refactor: Remove unused error() 2024-03-11 13:49:51 +01:00
MarcoFalke
fad0335517
scripted-diff: Replace error() with LogError()
This fixes the log output when -logsourcelocations is used.

Also, instead of 'ERROR:', the log will now say '[error]', like other
errors logged with LogError.

-BEGIN VERIFY SCRIPT-
 sed -i --regexp-extended 's!  error\("([^"]+)"!  LogError("\1\\n"!g' $( git grep -l '  error(' ./src/ )
-END VERIFY SCRIPT-
2024-03-11 13:49:37 +01:00
MarcoFalke
fa808fb749
refactor: Make error() return type void
This is needed for the next commit to compile.
2024-03-11 13:49:35 +01:00
MarcoFalke
fa1d624348
scripted-diff: return error(...); ==> error(...); return false;
This is needed for the next commit.

-BEGIN VERIFY SCRIPT-
 # Separate sed invocations to replace one-line, and two-line error(...) calls
 sed -i             --regexp-extended 's!( +)return (error\(.*\);)!\1\2\n\1return false;!g'             $( git grep -l 'return error(' )
 sed -i --null-data --regexp-extended 's!( +)return (error\([^\n]*\n[^\n]*\);)!\1\2\n\1return false;!g' $( git grep -l 'return error(' )
-END VERIFY SCRIPT-
2024-03-11 13:49:25 +01:00
MarcoFalke
fa9a5e80ab
refactor: Add missing {} around error() calls
This is required for the next commit to be correct.
2024-03-11 13:49:25 +01:00
Ava Chow
4a903741b0
Merge bitcoin/bitcoin#28120: p2p: make block download logic aware of limited peers threshold
c5b5843d8f test: avoid requesting blocks beyond limited peer threshold (furszy)
2f6a05512f p2p: sync from limited peer, only request blocks below threshold (furszy)
73127722a2 refactor: Make FindNextBlocks friendlier (furszy)

Pull request description:

  Even when the node believes it has IBD completed, need to avoid
  requesting historical blocks from network-limited peers.
  Otherwise, the limited peer will disconnect right away.

  The simplest scenario could be a node that gets synced, drops
  connections, and stays inactive for a while. Then, once it re-connects
  (IBD stays completed), the node tries to fetch all the missing blocks
  from any peer, getting disconnected by the limited ones.

  Note:
  Can verify the behavior by cherry-picking the test commit alone on
  master. It will fail there.

ACKs for top commit:
  achow101:
    ACK c5b5843d8f
  vasild:
    ACK c5b5843d8f
  mzumsande:
    Code Review ACK c5b5843d8f
  pinheadmz:
    ACK c5b5843d8f

Tree-SHA512: 9e550698bc6e63cc587b2b988a87d0ab555a8fa188c91c3f33287f8201d77c28b373331845356ad86f17bb21c15950b6466bc1cafd0ce8139d70364cb71c2ad2
2024-03-11 08:15:42 -04:00
glozow
07cd510ffe [refactor] consolidate invalid MempoolAcceptResult processing
Deduplicate code that exists in both tx processing and ProcessOrphanTx.
Additionally, this can be reused in a function that handles multiple
MempoolAcceptResults from package submission.
2024-03-11 11:41:23 +00:00
glozow
9353aa4066 [refactor] consolidate valid MempoolAcceptResult processing
Deduplicate code that exists in both tx processing and ProcessOrphanTx.
Additionally, this can be reused in a function that handles multiple
MempoolAcceptResults from package submission.
2024-03-11 11:07:34 +00:00
Ava Chow
5ebb406357
Merge bitcoin/bitcoin#26564: test: test_bitcoin: allow -testdatadir=<datadir>
d27e2d87b9 test: test_bitcoin: allow -testdatadir=<datadir> (Larry Ruane)

Pull request description:

  This backward-compatible change would help with code review, testing, and debugging. When `test_bitcoin` runs, it creates a working or data directory within `/tmp/test_common_Bitcoin\ Core/`, named as a long random (hex) string.

  This small patch does three things:

  - If the (new) argument `-testdatadir=<datadir>` is given, use `<datadir>/test_temp/<test-name>/datadir` as the working directory
  - When the test starts, remove `<datadir>/test_temp/<test-name>/datadir` if it exists from an earlier run (currently, it's presumed not to exist due to the long random string)
  - Don't delete the working directory at the end of the test if a custom data directory is being used

  Example usage, which will remove, create, use `/somewhere/test_temp/getarg_tests/boolarg`, and leave it afterward:
  ```
  $ test_bitcoin --run_test=getarg_tests/boolarg -- -testdatadir=/somewhere
  Running 1 test case...
  Test directory (will not be deleted): "/somewhere/test_temp/getarg_tests/boolarg/datadir"

  *** No errors detected
  $ ls -l /somewhere/test_temp/getarg_tests/boolarg/datadir
  total 8
  drwxrwxr-x 2 larry larry 4096 Feb 22 10:28 blocks
  -rw-rw-r-- 1 larry larry 1273 Feb 22 10:28 debug.log
  ```
  (A relative pathname also works.)

  This change affects only `test_bitcoin`; it could also be applied to `test_bitcoin-qt` but that's slightly more involved so I'm skipping that for now.

  The rationale for this change is that, when running the test using the debugger, it's often useful to watch `debug.log` as the test runs and inspect some of the other files (I've looked at the generated `blknnnn.dat` files for example). Currently, that requires figuring out where the test's working directory is since it changes on every test run. Tests can be run with `-printtoconsole=1` to show debug logging to the terminal, but it's nice to keep `debug.log` continuously open in an editor, for example.

  Even if not using a debugger, it's sometimes helpful to see `debug.log` and other artifacts after the test completes.

  Similar functionality is already possible with the functional tests using the `--tmpdir=` and `--nocleanup` arguments.

ACKs for top commit:
  davidgumberg:
    ACK d27e2d87b9
  tdb3:
    re-ACK for d27e2d87b9
  achow101:
    ACK d27e2d87b9
  cbergqvist:
    ACK d27e2d87b95b7982c05b4c88e463cc9626ab9f0a! (Already did some testing with `fs::remove()` to make sure it was compatible with the `util::Lock/UnlockDirectory` implementation).
  marcofleon:
    ACK d27e2d87b9. I ran all the tests with my previous open file limit and no errors were detected. Also ran some individual tests with no, relative, and absolute paths and everything looks good.
  furszy:
    ACK d27e2d8

Tree-SHA512: a8f535f34a48b6699cb440f97f5562ec643f3bfba4ea685768980b871fc8b6e1135f70fc05dbe19aa2c8bacb1ddeaff212d63473605a7422ff76332b3a6b1f68
2024-03-11 07:03:02 -04:00
Ava Chow
4cc99df44a
Merge bitcoin/bitcoin#29569: Rename CalculateHeadersWork to CalculateClaimedHeadersWork
eb7cc9fd21 Rename CalculateHeadersWork to CalculateClaimedHeadersWork (Greg Sanders)

Pull request description:

  And clean up some comments. Confusion about what this is doing seems to be a running theme:

  https://github.com/bitcoin/bitcoin/pull/29549#discussion_r1511113344

  https://github.com/bitcoin/bitcoin/pull/27278#discussion_r1141510303

ACKs for top commit:
  achow101:
    ACK eb7cc9fd21
  pablomartin4btc:
    ACK eb7cc9fd21
  0xB10C:
    ACK eb7cc9fd21
  dergoegge:
    ACK eb7cc9fd21
  BrandonOdiwuor:
    ACK eb7cc9fd21

Tree-SHA512: 6ccbc5e417155516487bb220753d189b5341dec05366db88a3fa5b1932eace21fbfaf23408c639bb54b36169a8d0a7536a1ee5e63b4ce5a3b70f2ff8407b6e07
2024-03-08 21:39:07 -05:00
Ava Chow
a78ca706f6
Merge bitcoin/bitcoin#29393: i2p: log connection was refused due to arbitrary port
5b358cdd1a i2p: log connection was refused due to arbitrary port (brunoerg)

Pull request description:

  For I2P, we do not try to connect if port is != 0. However, we do not have anything that indicates it or any error when trying to connect with port != 0. This PR adds a log for it. Also, it improves the functional test. With this log we can ensure the reason we won't connect is the port, in the current test, we cannot ensure it.

ACKs for top commit:
  jonatack:
    ACK 5b358cdd1a
  epiccurious:
    re-ACK 5b358cdd1a.
  achow101:
    ACK 5b358cdd1a
  kristapsk:
    re-ACK 5b358cdd1a
  vasild:
    ACK 5b358cdd1a

Tree-SHA512: 027245afa771c9295fff0bfd17c251dca4a9f4c739e5773922de3c030a65ef05d96291edcbdeeaa50ba3add61f75f28d8c00be503e03fc33d3491d1956fc549f
2024-03-08 21:15:24 -05:00
Ava Chow
c07935bcf5
Merge bitcoin/bitcoin#28960: kernel: Remove dependency on CScheduler
d5228efb53 kernel: Remove dependency on CScheduler (TheCharlatan)
06069b3913 scripted-diff: Rename MainSignals to ValidationSignals (TheCharlatan)
0d6d2b650d scripted-diff: Rename SingleThreadedSchedulerClient to SerialTaskRunner (TheCharlatan)
4abde2c4e3 [refactor] Make MainSignals RAII styled (TheCharlatan)
84f5c135b8 refactor: De-globalize g_signals (TheCharlatan)
473dd4b97a [refactor] Prepare for g_signals de-globalization (TheCharlatan)
3fba3d5dee [refactor] Make signals optional in mempool and chainman (TheCharlatan)

Pull request description:

  By defining a virtual interface class for the scheduler client, users of the kernel can now define their own event consuming infrastructure, without having to spawn threads or rely on the scheduler design.

  Removing `CScheduler` also allows removing the thread and exception modules from the kernel library.

  To make the `CMainSignals` class easier to use from a kernel library perspective, remove its global instantiation and adopt RAII practices.

  Renames `CMainSignals` to `ValidationSignals`, which more accurately describes its purpose and scope.

  Also make the `ValidationSignals` in the `ChainstateManager` and CTxMemPool` optional. This could be useful in the future for using or testing these classes without having to instantiate any form of signal handling.

  ---

  This PR is part of the [libbitcoinkernel project](https://github.com/bitcoin/bitcoin/issues/27587). It improves the kernel API and removes two modules from the kernel library.

ACKs for top commit:
  maflcko:
    re-ACK d5228efb53 🌄
  ryanofsky:
    Code review ACK d5228efb53. Just comment change since last review.
  vasild:
    ACK d5228efb53
  furszy:
    diff ACK d5228ef

Tree-SHA512: e93a5f10eb6182effb84bb981859a7ce750e466efd8171045d8d9e7fe46e4065631d9f6f533c5967c4d34c9bb7d7a67e9f4593bd4c5b30cd7b3bbad7be7b331b
2024-03-08 20:58:04 -05:00
furszy
a951dba3a9
wallet: default wallet migration, modify inconvenient backup filename
On default legacy wallets, the backup filename starts with an "-" due
to the wallet name being empty. This is inconvenient for systems who
treat what follows the initial "-" character as flags.
2024-03-08 19:40:11 -03:00
Lőrinc
6f2f4a4d09 Reserve memory for ToLower/ToUpper conversions 2024-03-08 23:06:22 +01:00
Matthew Zipkin
a64a2b77e0 rpc: refactor single/batch requests
Simplify the request handling flow so that errors and results only
come from JSONRPCExec()
2024-03-07 19:13:27 -05:00
Matthew Zipkin
df6e3756d6 rpc: Avoid copies in JSONRPCReplyObj()
Change parameters from const references to values, so they can be moved into
the reply instead of copied. Also update callers to move instead of copy.
2024-03-07 19:13:15 -05:00
Larry Ruane
d27e2d87b9 test: test_bitcoin: allow -testdatadir=<datadir>
Specifying this argument overrides the path location for test_bitcoin;
it becomes <datadir>/test_common_Bitcoin Core/<testname>/datadir. Also,
this directory isn't removed after the test completes. This can make it
easier for developers to study the results of a test (see the state of
the data directory after the test runs), and also (for example) have an
editor open on debug.log to monitor it across multiple test runs instead
of having to re-open a different pathname each time.

Example usage (note the "--" is needed):

test_bitcoin --run_test=getarg_tests/boolarg -- \
-testdatadir=/somewhere/mydatadir

This will create (if necessary) and use the data directory:

/somewhere/mydatadir/test_common_Bitcoin Core/getarg_tests/boolarg/datadir

Co-authored-by: furszy <mfurszy@protonmail.com>
2024-03-07 10:11:45 -07:00
Hennadii Stepanov
bd8f0354ba
build: Add missed definition for AM_OBJCXXFLAGS 2024-03-07 13:06:47 +00:00
Hennadii Stepanov
c2c6a7d1dc
Merge bitcoin-core/gui#803: test: Set organization name
0dcbad341b qt, test: Clean settings after tests (Hennadii Stepanov)
49cf63522e qt, test: Set organization name (Hennadii Stepanov)

Pull request description:

  From Qt [docs](https://doc.qt.io/qt-5/qsettings.html#QSettings-4):

  > If [`QCoreApplication::setOrganizationName()`](https://doc.qt.io/qt-5/qcoreapplication.html#organizationName-prop) and [`QCoreApplication::setApplicationName()`](https://doc.qt.io/qt-5/qcoreapplication.html#applicationName-prop) has not been previously called, the `QSettings` object will not be able to read or write any settings, and [`status()`](https://doc.qt.io/qt-5/qsettings.html#status) will return [`AccessError`](https://doc.qt.io/qt-5/qsettings.html#Status-enum).

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

ACKs for top commit:
  pablomartin4btc:
    utACK 0dcbad341b

Tree-SHA512: d5ac160f17cc358f0c1b89097193cd5adfd25f5531955c211f3e0994fc084e0a2b8d3aeddebe38f3a8ab5333edef5aa92b18915885c9e58b33f2e5786f31c600
2024-03-07 12:50:18 +00:00
fanquake
55bd5d8015
Merge bitcoin/bitcoin#29561: Fixed seeds update for 27.0
7ab54397f8 seeds: Update testnet seeds (Ava Chow)
34a233b6d8 seeds: Update mainnet seeds (Ava Chow)
9701bc435f makeseeds: Check i2p seeds too (Ava Chow)
a8ec9eede4 makeseeds: Update PATTERN_AGENT (Ava Chow)

Pull request description:

  The ipv4 and ipv6 seeds are updated from sipa's crawler, as outlined in contrib/seeds/README.md. The onion and i2p seeds are pulled from my node's addrman using `getrawaddrman` and then a connection was made to each node to retrieve the current service flags, block height, and user agent string before filtering through makeseeds.py. The CJDNS nodes were not updated as my node is not connected to that network.

  makeseeds.py is also updated for more recent user agent strings as well as being able to handle i2p addresses.

  Also updated the testnet seeds.

ACKs for top commit:
  fanquake:
    ACK 7ab54397f8

Tree-SHA512: 5edba63d51116e5d9a8ae23561ba5a311f4df88c555c60b2d7a6066e63f8cdfd256be7dac9acea4b370879d0d3c3a4b55328c15de4284b5f0d86e6cac2e5ba9b
2024-03-06 14:43:58 +00:00
fanquake
312f3381a2
fuzz: restrict fopencookie usage to Linux & FreeBSD
Should fix the GCC compilation portion of #29517:
https://github.com/bitcoin/bitcoin/issues/29517#issuecomment-1973573314.

See also:
https://www.gnu.org/software/gnulib/manual/html_node/fopencookie.html
but note that FreeBSD has supported this function since 11.x.
2024-03-05 21:18:44 +00:00
fanquake
11a1db8780
Merge bitcoin/bitcoin#29547: kernel: chainparams updates for 27.x
d9f30b021a kernel: chainparams updates for 27.x (fanquake)
1611aa1789 kernel: update chainTxData for 27.x (fanquake)
af78d31e71 kernel: update nMinimumChainWork & defaultAssumeValid for 27.x (fanquake)

Pull request description:

  Update chainparams pre `27.x` branch off.

  Note: Remember that some variance is expected in the m_assumed_* sizes.

ACKs for top commit:
  Sjors:
    ACK d9f30b021a
  glozow:
    ACK d9f30b021a (checked mainnet locally, checked testnet/signet on block explorers and sanity checked the numbers)
  instagibbs:
    ACK d9f30b021a

Tree-SHA512: 6ce65b964334b9d15fff4aa1af6d26fb3ef4eab50b8237fc2cda180230ae724a99d13c9f6b3c58105548d3520c0ca0810f354736132d11793d6c91ad3eeac4c7
2024-03-05 16:15:24 +00:00
Greg Sanders
eb7cc9fd21 Rename CalculateHeadersWork to CalculateClaimedHeadersWork 2024-03-05 10:01:24 -05:00
Hennadii Stepanov
0dcbad341b
qt, test: Clean settings after tests
A test suite should not leave any artifacts except for those explicitly
expected.

This change is easy to review with `git diff --ignore-all-space`
command.
2024-03-05 07:39:48 +00:00
Hennadii Stepanov
49cf63522e
qt, test: Set organization name
If `setOrganizationName()` and `setApplicationName()` has not been
previously called, the `QSettings` object will not be able to read or
write any settings.
2024-03-05 07:02:54 +00:00
Ava Chow
7ab54397f8 seeds: Update testnet seeds 2024-03-04 19:53:30 -05:00
Ava Chow
34a233b6d8 seeds: Update mainnet seeds 2024-03-04 19:53:24 -05:00
fanquake
3329b35e09
Merge bitcoin/bitcoin#29546: qt: 27.0 translations update
632b69f79b qt: 27.0 translations update (Hennadii Stepanov)

Pull request description:

  This PR pulls the recent translations from the [Transifex.com](https://www.transifex.com/bitcoin/bitcoin) using the [`bitcoin-maintainer-tools/update-translations.py`](https://github.com/bitcoin-core/bitcoin-maintainer-tools/blob/main/update-translations.py) tool.

ACKs for top commit:
  stickies-v:
    ACK 632b69f79b , getting a zero-diff when running `update-translations.py` on fce53f132e

Tree-SHA512: 1e2823451e9192e60dec9d50e801fca4cdc621e6acabdc15dbd88cab1624e05bd56de9ac818a1ff91002d62e24c0bab0ef1eaad3fd3cc6ef6cd044989d39734f
2024-03-04 11:58:55 +00:00
fanquake
d9f30b021a
kernel: chainparams updates for 27.x 2024-03-04 10:56:27 +00:00
fanquake
1611aa1789
kernel: update chainTxData for 27.x 2024-03-04 10:56:27 +00:00
fanquake
af78d31e71
kernel: update nMinimumChainWork & defaultAssumeValid for 27.x 2024-03-04 10:56:27 +00:00
Hennadii Stepanov
776d48dd56
Merge bitcoin-core/gui#801: Fix nullptr clientModel access during shutdown
b7aa717cdd refactor: gui, simplify boost signals disconnection (furszy)
f3a612f901 gui: guard accessing a nullptr 'clientModel' (furszy)

Pull request description:

  Fixing #800.

  During shutdown, already queue events dispatched from the backend such
  'numConnectionsChanged' and 0networkActiveChanged' could try to access
  the clientModel object, which might not exist because we manually delete
  it inside 'BitcoinApplication::requestShutdown()'.

  This happen because boost does not clears the queued events when they arise
  concurrently with the signal disconnection (see https://www.boost.org/doc/libs/1_55_0/doc/html/signals2/thread-safety.html).
  From the docs:
  1) "Note that since we unlock the connection's mutex before executing its associated slot, it is possible a slot will still be executing after it has been disconnected by a [connection::disconnect](https://www.boost.org/doc/libs/1_55_0/doc/html/boost/signals2/connection.html#idp89761576-bb)(), if the disconnect was called concurrently with signal invocation."
  2)  "The fact that concurrent signal invocations use the same combiner object means you need to insure any custom combiner you write is thread-safe"

  So, we need to guard `clientModel` before accessing it at the handler side.

ACKs for top commit:
  hebasto:
    re-ACK b7aa717cdd

Tree-SHA512: f1a21d69248628f6a13556a9438c9e4ea9f0a3678aab09ddfe836e78e4eee405a6730d37d39f1445068ada3a110b655b619cf0e090fc2d0cdf99bed061364aeb
2024-03-04 10:15:43 +00:00
fanquake
e60804f121
Merge bitcoin/bitcoin#29524: p2p: Don't consider blocks mutated if they don't connect to known prev block
a1fbde0ef7 p2p: Don't consider blocks mutated if they don't connect to known prev block (Greg Sanders)

Pull request description:

  Followup to https://github.com/bitcoin/bitcoin/pull/29412 to revert some of the behavior change that was likely unintentional.

  Based on comments from https://github.com/bitcoin/bitcoin/pull/29412#discussion_r1507499192

ACKs for top commit:
  0xB10C:
    utACK a1fbde0ef7
  dergoegge:
    Code review ACK a1fbde0ef7
  Sjors:
    ACK a1fbde0ef7
  sr-gi:
    tACK a1fbde0ef7

Tree-SHA512: be6204c8cc57b271d55c1d02a5c77d03a37738d91cb5ac164f483b0bab3991c24679c5ff02fbaa52bf37ee625874b63f4c9f7b39ad6fd5f3a25386567a0942e4
2024-03-04 10:09:47 +00:00
Hennadii Stepanov
632b69f79b
qt: 27.0 translations update 2024-03-04 10:02:26 +00:00
Matthew Zipkin
567cec9a05
doc: add release notes and help text for unix sockets 2024-03-01 14:47:29 -05:00
Matthew Zipkin
c65c0d0163
init: allow UNIX socket path for -proxy and -onion 2024-03-01 14:47:29 -05:00
Matthew Zipkin
c3bd43142e
gui: accomodate unix socket Proxy in updateDefaultProxyNets()
This will require a follow-up to add unix socket options to the GUI
2024-03-01 14:47:29 -05:00
Matthew Zipkin
a88bf9dedd
i2p: construct Session with Proxy instead of CService 2024-03-01 14:47:29 -05:00
Matthew Zipkin
d9318a37ec
net: split ConnectToSocket() from ConnectDirectly() for unix sockets 2024-03-01 14:47:28 -05:00
Matthew Zipkin
ac2ecf3182
proxy: rename randomize_credentials to m_randomize_credentials 2024-03-01 14:47:28 -05:00
Matthew Zipkin
a89c3f59dc
netbase: extend Proxy class to wrap UNIX socket as well as TCP 2024-03-01 14:47:28 -05:00
Matthew Zipkin
3a7d6548ef
net: move CreateSock() calls from ConnectNode() to netbase methods 2024-03-01 14:47:28 -05:00
Matthew Zipkin
74f568cb6f
netbase: allow CreateSock() to create UNIX sockets if supported 2024-03-01 14:47:24 -05:00
Matthew Zipkin
bae86c8d31
netbase: refactor CreateSock() to accept sa_family_t
Also implement CService::GetSAFamily() to provide sa_family_t
2024-03-01 13:13:07 -05:00
fanquake
521693378b
build: move sha256_sse4 into libbitcoin_crypto_base
Followup to discussion in #29407.
Drops LIBBITCOIN_CRYPTO_SSE4.
2024-03-01 11:57:24 -05:00
fanquake
8da62a1041
Merge bitcoin/bitcoin#29263: serialization: c++20 endian/byteswap/clz modernization
86b7f28d6c serialization: use internal endian conversion functions (Cory Fields)
432b18ca8d serialization: detect byteswap builtins without autoconf tests (Cory Fields)
297367b3bb crypto: replace CountBits with std::bit_width (Cory Fields)
52f9bba889 crypto: replace non-standard CLZ builtins with c++20's bit_width (Cory Fields)

Pull request description:

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

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

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

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

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

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

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

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

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

Tree-SHA512: 715a32ec190c70505ffbce70bfe81fc7b6aa33e376b60292e801f60cf17025aabfcab4e8c53ebb2e28ffc5cf4c20b74fe3dd8548371ad772085c13aec8b7970e
2024-03-01 11:19:58 -05:00
glozow
5fbab37859 [unit test] sibling not returned from SingleV3Checks if 1p2c or 3gen 2024-03-01 15:23:04 +00:00
glozow
170306728a [policy] sibling eviction for v3 transactions 2024-03-01 15:23:03 +00:00
fanquake
ae4165f7bc
Merge bitcoin/bitcoin#29495: fuzz: add target for local address stuff
25eab52389 fuzz: add target for local addresses (brunoerg)

Pull request description:

  This PR adds fuzz target for local address functions - (`AddLocal`, `RemoveLocal`, `SeenLocal`, `IsLocal`)

ACKs for top commit:
  dergoegge:
    ACK 25eab52389
  vasild:
    ACK 25eab52389

Tree-SHA512: 24faaab86dcd8835ba0e2d81fb6322a39a9266c7edf66415dbc4421754054f47efb6e0de4efdc7ea026b0686792658e86a526f7cf27cbc6cf9ed0c4aed376f97
2024-03-01 10:07:48 -05:00
stickies-v
30a6c99935
rpc: access some args by name
Use the new key-based Arg helper in a few locations to show how
it is used.
2024-03-01 13:51:21 +00:00
stickies-v
bbb31269bf
rpc: add named arg helper
Overload the Arg and MaybeArg helpers to allow accessing arguments
by name as well.

Also update the docs to document Arg and MaybeArg separately
2024-03-01 13:51:21 +00:00
stickies-v
13525e0c24
rpc: add arg helper unit test
Compare the results of self.Arg with the request.params accessors
to ensure they behave the same way.
2024-03-01 13:51:21 +00:00
Greg Sanders
a1fbde0ef7 p2p: Don't consider blocks mutated if they don't connect to known prev block 2024-02-29 16:38:58 -05:00
fanquake
dfc35c9934
Merge bitcoin/bitcoin#29407: build: remove confusing and inconsistent disable-asm option
f8a06f7a02 doc: remove references to disable-asm option now that it's gone (Cory Fields)
376f0f6d07 build: remove confusing and inconsistent disable-asm option (Cory Fields)

Pull request description:

  1. It didn't actually disable asm usage in our code. Regardless of the setting, asm is used in random.cpp and support/cleanse.cpp.
  2. The value wasn't forwarded to libsecp as a user might have reasonably expected.
  3. We now have the DISABLE_OPTIMIZED_SHA256 define which is what disable-asm actually did in practice.

  If there is any desire, we can hook DISABLE_OPTIMIZED_SHA256 up to a new configure option that actually does what it says.

  Additionally, this is one of the last (THE last?) remaining uses of autoconf defines in our crypto code. As such it seems like low-hanging fruit.

ACKs for top commit:
  fanquake:
    ACK f8a06f7a02

Tree-SHA512: 4a99c2130225acbe9dc7399ed572a04ca155cbfa3eef8178a632ba533017d264691e6482cceb1d8f9c5d768619d99a2466dea4b82b27b18b872bceae91b92fbb
2024-02-29 16:14:41 -05:00
fanquake
9057598605
Merge bitcoin/bitcoin#29516: test: removes unnecessary check from validation_tests
6ee3997d03 test: removes unnecessary check from validation_tests (Sergi Delgado Segura)

Pull request description:

  An unnecessary check was added to the block mutation tests in #29412 where IsBlockMutated is returning true for the invalid reasons: we try to check mutation via transaction duplication, but the merkle root is not updated before the check, therefore the check fails because the provided root and the computed root differ, but not because the block contains the same transaction twice.

  Notice that a proper check to test the duplication case is added a few lines later, so this check is just meaningless and can be removed. Check https://github.com/bitcoin/bitcoin/pull/29412#discussion_r1506490281 for context.

ACKs for top commit:
  maflcko:
    ACK 6ee3997d03
  dergoegge:
    utACK 6ee3997d03
  BrandonOdiwuor:
    utACK 6ee3997d03

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

If there is any desire, we can hook DISABLE_OPTIMIZED_SHA256 up to a new
configure option that actually does what it says.
2024-02-29 19:05:45 +00:00
Ava Chow
22a5ccfb06
Merge bitcoin/bitcoin#29510: wallet: getrawchangeaddress and getnewaddress failures should not affect keypools for descriptor wallets
e073f1dfda test: make sure keypool sizes do not change on `getrawchangeaddress`/`getnewaddress` failures (UdjinM6)
367bb7a80c wallet: Avoid updating `ReserveDestination::nIndex` when `GetReservedDestination` fails (UdjinM6)

Pull request description:

  I think the expected behaviour of `getrawchangeaddress` and `getnewaddress` RPCs is that their failure should not affect keypool in any way. At least that's how legacy wallets work, you can confirm this behaviour by running `wallet_keypool.py --legacy-wallet` on master with e073f1dfda applied on top. However running `wallet_keypool.py --descriptors` on the same commit results in the following failure:
  ```
    File "/path/to/bitcoin/test/functional/test_framework/test_framework.py", line 131, in main
      self.run_test()
    File "/path/to/bitcoin/test/functional/wallet_keypool.py", line 114, in run_test
      assert_equal(kp_size_before, kp_size_after)
    File "/path/to/bitcoin/test/functional/test_framework/util.py", line 57, in assert_equal
      raise AssertionError("not(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args))
  AssertionError: not([18, 24] == [19, 24])
  ```

  This happens because we pass `nIndex` (which is a class member) into `GetReservedDestination` and since it's passed by reference we get an updated value back, so `nIndex` won't be equal `-1` anymore, no matter if the function failed or succeeded. This means that `ReturnDestination` (called by dtor of `ReserveDestination`) will try to return something we did not actually reserve.

  The fix is to simply use a temporary variable instead of a class member and only update `nIndex` when `op_address` actually has value, basically do it the same way we do for other class members (`address` and `fInternal`) already.

ACKs for top commit:
  achow101:
    ACK e073f1dfda
  josibake:
    ACK e073f1dfda

Tree-SHA512: 1128288a60dd4d8f306ef6f7ac66cdfeae3c9cc35c66ecada2d78fa61ac759f2a757b70fc3976ba8b5081200942b58dfabc184c01ccf911af40ba8c145344651
2024-02-29 13:25:38 -05:00
furszy
b7aa717cdd
refactor: gui, simplify boost signals disconnection
Preventing dangling signals.
2024-02-29 14:40:01 -03:00
brunoerg
25eab52389 fuzz: add target for local addresses 2024-02-29 14:13:58 -03:00
Sergi Delgado Segura
6ee3997d03 test: removes unnecessary check from validation_tests
An unnecessary check was added to the block mutation tests
in #29412 where IsBlockMutated is returning true for the invalid
reasons: we try to check mutation via transaction duplication,
but the merkle root is not updated before the check, therefore
the check fails because the provided root and the computed root
differ, but not because the block contains the same transaction twice.

The check is meaningless so it can be removed.
2024-02-29 09:54:47 -05:00
Ava Chow
2649e655b9
Merge bitcoin/bitcoin#29412: p2p: Don't process mutated blocks
d8087adc7e [test] IsBlockMutated unit tests (dergoegge)
1ed2c98297 Add transaction_identifier::size to allow Span conversion (dergoegge)
1ec6bbeb8d [validation] Cache merkle root and witness commitment checks (dergoegge)
5bf4f5ba32 [test] Add regression test for #27608 (dergoegge)
49257c0304 [net processing] Don't process mutated blocks (dergoegge)
2d8495e080 [validation] Merkle root malleation should be caught by IsBlockMutated (dergoegge)
66abce1d98 [validation] Introduce IsBlockMutated (dergoegge)
e7669e1343 [refactor] Cleanup merkle root checks (dergoegge)
95bddb930a [validation] Isolate merkle root checks (dergoegge)

Pull request description:

  This PR proposes to check for mutated blocks early as a defense-in-depth mitigation against attacks leveraging mutated blocks.

  We introduce `IsBlockMutated` which catches all known forms of block malleation and use it to do an early mutation check whenever we receive a `block` message.

  We have observed attacks that abused mutated blocks in the past, which could have been prevented by simply not processing mutated blocks (e.g. https://github.com/bitcoin/bitcoin/pull/27608 for which a regression test is included in this PR).

ACKs for top commit:
  achow101:
    ACK d8087adc7e
  maflcko:
    ACK d8087adc7e 🏄
  fjahr:
    Code review ACK d8087adc7e
  sr-gi:
    Code review ACK d8087adc7e

Tree-SHA512: 618ff4ea7f168e10f07504d3651290efbb1bb2ab3b838ffff3527c028caf6c52dedad18d04d3dbc627977479710930e200f2dfae18a08f627efe7e64a57e535f
2024-02-28 17:54:49 -05:00
fanquake
dfbad09c60
Merge bitcoin/bitcoin#29489: test: Remove Windows-specific code from system_tests/run_command
51bc1c7126 test: Remove Windows-specific code from `system_tests/run_command` (Hennadii Stepanov)

Pull request description:

  The removed code has been dead since https://github.com/bitcoin/bitcoin/pull/28967.

  Required as a precondition for replacing Boost.Process with [cpp-subprocess](https://github.com/bitcoin/bitcoin/pull/28981) to make diff for this code meaningful and reviewable.

  The plan is to reintroduce Windows-specific code in this test simultaneously with enabling Windows support in cpp-subprocess.

ACKs for top commit:
  Sjors:
    utACK 51bc1c7126
  theStack:
    Code-review ACK 51bc1c7126

Tree-SHA512: 0e3875c4dc20564332555633daf2227223b10dc3d052557635eced2734575d1e0252fb19e46ea6e6c47a15c51c345f70b6d437e33435abcd0e4fcf29edb50887
2024-02-28 17:30:08 -05:00
fanquake
d752831e64
Merge bitcoin/bitcoin#29493: subtree: update crc32c subtree
5d45552fd4 Squashed 'src/crc32c/' changes from 0bac72c455..b60d2b7334 (fanquake)

Pull request description:

  Update the crc32c subtree. Includes:
  * https://github.com/bitcoin-core/crc32c-subtree/pull/6

  Which fixes #29178.

ACKs for top commit:
  hebasto:
    ACK 359a8d9846.
  theuni:
    ACK 359a8d9846
  dergoegge:
    ACK 359a8d9846

Tree-SHA512: 2cec81a34ad26bbbc298aea5daffa41e56114d31cc2eb5fe486f46a77c3467bba22bdeca1c52ae97220e119d98818304272fc6337442af55282accabcd4c5833
2024-02-28 17:23:11 -05:00
furszy
f3a612f901
gui: guard accessing a nullptr 'clientModel'
During shutdown, already queue events dispatched from the backend such
'numConnectionsChanged' and 'networkActiveChanged' could try to access
the clientModel object, which might not exist because we manually delete
it inside 'BitcoinApplication::requestShutdown()'.
2024-02-28 17:58:47 -03:00
Lőrinc
a19235c14b Preallocate result in TryParseHex to avoid resizing
Running `make && ./src/bench/bench_bitcoin -filter=HexParse` a few times results in:
```
|           ns/base16 |            base16/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|                0.68 |    1,465,555,976.27 |    0.8% |      0.01 | `HexParse`
|                0.68 |    1,472,962,920.18 |    0.3% |      0.01 | `HexParse`
|                0.68 |    1,476,159,423.00 |    0.3% |      0.01 | `HexParse`
```
2024-02-28 17:23:54 +00:00
Lőrinc
b7489ecb52 Add benchmark for TryParseHex
Running `make && ./src/bench/bench_bitcoin -filter=HexParse` a few times results in:
```
|           ns/base16 |            base16/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|                1.60 |      623,238,893.11 |    0.3% |      0.01 | `HexParse`
|                1.65 |      606,747,566.34 |    0.6% |      0.01 | `HexParse`
|                1.60 |      626,149,544.07 |    0.3% |      0.01 | `HexParse`
```
2024-02-28 17:23:54 +00:00
Vasil Dimov
b3efb48673
protocol: make message types constexpr
As a side effect the names of the constants do not have to be
repeated in `src/protocol.cpp`.
2024-02-28 18:03:23 +01:00
Vasil Dimov
2fa9de06c2
net: make the list of known message types a compile time constant
Turn the `std::vector` to `std::array` because it is cheaper and
allows us to have the number of the messages as a compile time
constant: `ALL_NET_MESSAGE_TYPES.size()` which can be used in
future code to build other `std::array`s with that size.
2024-02-28 18:03:22 +01:00
Cory Fields
86b7f28d6c serialization: use internal endian conversion functions
These replace our platform-specific mess in favor of c++20 endian detection
via std::endian and internal byteswap functions when necessary.

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

These builtins and fallbacks can all be removed once we're using c++23, which
adds std::byteswap.
2024-02-28 13:42:38 +00:00
Luke Dashjr
66bc6e2d17 Accept "in" and "out" flags to -whitelist to allow whitelisting manual connections 2024-02-28 10:05:56 -03:00
Luke Dashjr
8e06be347c net_processing: Move extra service flag into InitializeNode 2024-02-28 10:05:56 -03:00
Luke Dashjr
9133fd69a5 net: Move NetPermissionFlags::Implicit verification to AddWhitelistPermissionFlags 2024-02-28 10:05:56 -03:00
brunoerg
2863d7dddb net: store -whitelist{force}relay values in CConnman 2024-02-28 10:04:18 -03:00
UdjinM6
367bb7a80c
wallet: Avoid updating ReserveDestination::nIndex when GetReservedDestination fails 2024-02-28 13:00:00 +03:00
Cory Fields
ad7584d8b6 serialization: replace char-is-int8_t autoconf detection with c++20 concept
This removes the only remaining autoconf macro in our serialization code,
so it can now be used trivially and safely out-of-tree.
2024-02-27 19:03:26 +00:00
fanquake
359a8d9846
Update crc32c subtree to latest upstream master 2024-02-27 18:28:19 +00:00
fanquake
5d45552fd4 Squashed 'src/crc32c/' changes from 0bac72c455..b60d2b7334
b60d2b7334 Merge bitcoin-core/crc32c-subtree#6: Fix UBSan "misaligned-pointer-use" warning on aarch64
1ac401e32b Fix UBSan "misaligned-pointer-use" warning on aarch64

git-subtree-dir: src/crc32c
git-subtree-split: b60d2b733406cc64025095c6c2cb3933e222b529
2024-02-27 18:28:19 +00:00
Hennadii Stepanov
51bc1c7126
test: Remove Windows-specific code from system_tests/run_command
This code has been dead since https://github.com/bitcoin/bitcoin/pull/28967.

Required as a precondition for replacing Boost.Process with
cpp-subprocess to make diff for this code meaningful and reviewable.

The plan is to reintroduce Windows-specific code in this test
simultaneously with enabling Windows support in cpp-subprocess.
2024-02-27 15:59:05 +00:00
dergoegge
d8087adc7e [test] IsBlockMutated unit tests 2024-02-27 14:19:15 +00:00
dergoegge
1ed2c98297 Add transaction_identifier::size to allow Span conversion 2024-02-27 14:19:15 +00:00
dergoegge
1ec6bbeb8d [validation] Cache merkle root and witness commitment checks
Slight performance improvement by avoiding duplicate work.
2024-02-27 14:19:15 +00:00
dergoegge
49257c0304 [net processing] Don't process mutated blocks
We preemptively perform a block mutation check before further processing
a block message (similar to early sanity checks on other messsage
types). The main reasons for this change are as follows:

- `CBlock::GetHash()` is a foot-gun without a prior mutation check, as
  the hash returned only commits to the header but not to the actual
  transactions (`CBlock::vtx`) contained in the block.
- We have observed attacks that abused mutated blocks in the past, which
  could have been prevented by simply not processing mutated blocks
  (e.g. https://github.com/bitcoin/bitcoin/pull/27608).
2024-02-27 14:19:15 +00:00
dergoegge
2d8495e080 [validation] Merkle root malleation should be caught by IsBlockMutated 2024-02-27 14:19:15 +00:00
dergoegge
66abce1d98 [validation] Introduce IsBlockMutated 2024-02-27 14:19:15 +00:00
dergoegge
e7669e1343 [refactor] Cleanup merkle root checks 2024-02-27 14:19:14 +00:00
dergoegge
95bddb930a [validation] Isolate merkle root checks 2024-02-27 14:17:32 +00:00
fanquake
4d7d7fd123
Merge bitcoin/bitcoin#29357: test: Drop x modifier in fsbridge::fopen call for MinGW builds
d2fe90571e test: Drop `x` modifier in `fsbridge::fopen` call for mingw builds (Hennadii Stepanov)

Pull request description:

  The MinGW-w64 toolchain links executables to the old msvcrt C Runtime Library that does not support the `x` modifier for the [`_wfopen()`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfopen?view=msvc-170) function.

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

ACKs for top commit:
  maflcko:
    ACK d2fe90571e
  fanquake:
    ACK d2fe90571e - the plan here should still be to migrate to the newer windows runtime.

Tree-SHA512: 0269b66531e58c093ecda3a3e355a20ee8274e165d7e010f8f125881b3c8d4cfe801abdca4605d81efd3b2dbe9a81896968971f6f53da7f6c6093b76b47c5bc9
2024-02-26 16:15:24 +00:00
Cory Fields
297367b3bb crypto: replace CountBits with std::bit_width
bit_width is a drop-in replacement with an exact meaning in c++, so there is
no need to continue testing/fuzzing/benchmarking.
2024-02-26 16:13:12 +00:00
Cory Fields
52f9bba889 crypto: replace non-standard CLZ builtins with c++20's bit_width
Also some header cleanups.
2024-02-26 16:13:12 +00:00
Hennadii Stepanov
d2fe90571e
test: Drop x modifier in fsbridge::fopen call for mingw builds
The MinGW-w64 toolchain links executables to the old msvcrt C Runtime
Library that does not support the `x` modifier for the _wfopen()
function.
2024-02-26 14:47:31 +00:00
fanquake
19b7f2b908
Merge bitcoin/bitcoin#29471: doc: Fix CI-detected codespell warnings
b03b20685a Fix CI-detected codespell warnings (Lőrinc)

Pull request description:

  Split out the typo fixes encountered in https://github.com/bitcoin/bitcoin/pull/29458 to a separate PR.

ACKs for top commit:
  maflcko:
    ACK b03b20685a

Tree-SHA512: 99b6fac01ba2ae6e6de9c50d2b481387899844a4b3a77d544c7b8afe7cfd25251a982329688d4739cde8b98ad35afcfd49be7c7cc3dad9bdff1d5915861a206d
2024-02-26 11:14:46 +00:00
fanquake
ba90b058bd
Merge bitcoin/bitcoin#29345: rpc: Do not wait for headers inside loadtxoutset
faa30a4c56 rpc: Do not wait for headers inside loadtxoutset (MarcoFalke)

Pull request description:

  While the `loadtxoutset` default 10 minute timeout is convenient when it is sufficient, it may cause hassle where it is not. For example:

  * When P2P connections are missing, it seems better to abort early than wait for the timeout.
  * When the 10 minute timeout is not sufficient, the RPC will have to be called again, so a check or loop is needed outside the RPC either way. So might as well remove the loop inside the RPC.

ACKs for top commit:
  fjahr:
    ACK faa30a4c56
  theStack:
    Code-review ACK faa30a4c56
  pablomartin4btc:
    tACK faa30a4c56
  TheCharlatan:
    ACK faa30a4c56

Tree-SHA512: 9167c7d8b2889bb3fd369de4acd2cc4d24a2fe225018d82bd9568ecd737093f6e19be7cc62815b574137b61076a6f773c29bff75398991b5cd702423aab2322b
2024-02-26 11:11:25 +00:00
fanquake
eaede27655
Merge bitcoin/bitcoin#29408: lint: Check for missing bitcoin-config.h includes
fa58ae74ea refactor: Add missing include for USE_BDB, USE_SQLITE to bench/wallet_ismine.cpp (MarcoFalke)
fa31908ea8 lint: Check for missing or redundant bitcoin-config.h includes (MarcoFalke)
fa63b0e351 lint: Make lint error easier to spot in output (MarcoFalke)
fa770fd368 doc: Add missing RUST_BACKTRACE=1 (MarcoFalke)
fa10051267 lint: Add get_subtrees() helper (MarcoFalke)

Pull request description:

  Missing `bitcoin-config.h` includes are problematic, because the build could silently pass, but produce an unintended result. For example, a slower fallback algorithm could be picked, even though `bitcoin-config.h` indicates that a faster feature is available and should be used.

  As the build succeeds silently, this problem is not possible to detect with iwyu.

  Thus, fix this by using a linter based on grepping the source code.

ACKs for top commit:
  theuni:
    Weak ACK fa58ae74ea.
  TheCharlatan:
    ACK fa58ae74ea
  hebasto:
    ACK fa58ae74ea, tested on Ubuntu 23.10 -- it catches bugs properly. I didn't review rust code changes.

Tree-SHA512: cf4346f81ea5b8c215da6004cb2403d1aaf569589613c305d8ba00329b82b3841da94fe1a69815ce15f2edecbef9b031758ec9b6433564976190e3cf91ec8181
2024-02-26 10:32:28 +00:00
Lőrinc
b03b20685a Fix CI-detected codespell warnings 2024-02-23 23:01:07 +01:00
Murch
9dae3b970a [fuzz] Avoid partial negative result 2024-02-21 15:49:05 -05:00
glozow
b5d15f764f [refactor] return pair from SingleV3Checks 2024-02-21 16:40:42 +00:00
Ryan Ofsky
8d491ae9ec serialization: Add ParamsStream GetStream() method
Add GetStream() method useful for accessing underlying stream. Use to improve
ParamsStream test coverage.
2024-02-21 07:35:38 -05:00
Ryan Ofsky
951203bcc4 net: Simplify ParamsStream usage
Simplify ParamsStream usage in ConvertSeeds now that ParamsStream supports
rvalue substream arguments.
2024-02-21 07:07:50 -05:00
Ryan Ofsky
e6794e475c serialization: Accept multiple parameters in ParamsStream constructor
Before this change it was possible but awkward to create ParamStream streams
with multiple parameter objects. After this change it is straightforward.

The change to support multiple parameters is implemented by letting
ParamsStream contain substream instances, instead of just references to
external substreams. So a side-effect of this change is that ParamStream can
now accept rvalue stream arguments and be easier to use in some other cases. A
test for rvalues is added in this commit, and some simplifications to non-test
code are made in the next commit.
2024-02-21 07:07:50 -05:00
Ryan Ofsky
cb28849a88 serialization: Reverse ParamsStream constructor order
Move parameter argument after stream argument so will be possible to accept
multiple variadic parameter arguments in the following commit.

Also reverse template parameter order for consistency.
2024-02-21 07:07:50 -05:00
Ryan Ofsky
83436d14f0 serialization: Drop unnecessary ParamsStream references
Drop unnecessary ParamsStream references from CTransaction and
CMutableTransaction constructors. This just couples these classes unnecessarily
to the ParamsStream class, making the ParamsStream class harder to modify, and
making the transaction classes in some cases (depending on parameter order)
unable to work with stream classes that have multiple parameters set.
2024-02-21 07:07:50 -05:00
Ryan Ofsky
84502b755b serialization: Drop references to GetVersion/GetType
Drop references to stream GetVersion()/GetType() methods which no longer exist
2024-02-21 07:07:50 -05:00
Ava Chow
fe67841464 descriptor: Be able to get the pubkeys involved in a descriptor 2024-02-20 11:20:58 -05:00
Ava Chow
ef6745879d key: Add constructor for CExtKey that takes CExtPubKey and CKey
We often need to construct a CExtKey given an CExtPubKey and CKey, so
implement a constructor that does that for us.
2024-02-20 11:20:58 -05:00
MarcoFalke
fa58ae74ea
refactor: Add missing include for USE_BDB, USE_SQLITE to bench/wallet_ismine.cpp
It was included indirectly via src/wallet/test/util.h, however it is
better to include what you use.
2024-02-20 15:11:58 +01:00
fanquake
45b2a91897
Merge bitcoin/bitcoin#29404: refactor: bitcoin-config.h includes cleanup
9d1dbbd4ce scripted-diff: Fix bitcoin_config_h includes (TheCharlatan)

Pull request description:

  As mentioned in https://github.com/bitcoin/bitcoin/pull/26924#issuecomment-1403449932 and https://github.com/bitcoin/bitcoin/pull/29263#issuecomment-1922334399, it is currently not safe to remove `bitcoin-config.h` includes from headers because some unrelated file might be depending on it.

  See also #26972 for discussion.

  Solve this by including the file directly everywhere it's required, regardless of whether or not it's already included by another header.

  There should be no functional change here, but it will allow us to safely remove includes from headers in the future.

  ~I'm afraid it's a bit tedious to reproduce these commits, but it's reasonably straightforward:~
  Edit: See note below

  ```bash
  # All commands executed from the src/ subdir.

  # Collect all tokens from bitcoin-config.h.in
  # Isolate the tokens and remove blank lines
  # Replace newlines with | and remove the last trailing one
  # Collect all files which use these tokens
  # Filter out subprojects (proper forwarding can be verified from Makefiles)
  # Filter out .rc files
  # Save to a text file
  git grep -E -l `grep undef config/bitcoin-config.h.in | cut -d" " -f2 | grep -v '^$' | tr '\n' '|' | sed 's/|$//'` | grep -v -e "^leveldb/" -e "^secp256k1/" -e "^crc32c/" -e "^minisketch/" -e "^Makefile" -e "\.rc$" > files-with-config-include.txt

  # Find all files from the above list which don't include bitcoin-config.h
  git grep -L -E "config/bitcoin-config.h" -- `cat files-with-config-include.txt`

  # Include them manually with the exception of some files in crypto:
  # crypto/sha256_arm_shani.cpp crypto/sha256_avx2.cpp crypto/sha256_sse41.cpp crypto/sha256_x86_shani.cpp
  # These are exceptions which don't use bitcoin-config.h, rather the Makefile.am adds these cppflags manually.

  # Commit changes. This should match the first commit of this PR.

  # Use the same search as above to find all files which DON'T use any config tokens
  git grep -E -L `grep undef config/bitcoin-config.h.in | cut -d" " -f2 | grep -v '^$' | tr '\n' '|' | sed 's/|$//'` | grep -v -e "^leveldb/" -e "^secp256k1/" -e "^crc32c/" -e "^minisketch/" -e "^Makefile" -e "\.rc$" > files-without-config-include.txt

  # Manually remove the includes and commit changes. This should match the second commit of this PR.
  ```

  Edit: I'll keep this old description for posterity, but the manual approach has been replaced with a scripted diff from TheCharlatan

ACKs for top commit:
  maflcko:
    ACK 9d1dbbd4ce 🚪
  TheCharlatan:
    ACK 9d1dbbd4ce
  hebasto:
    ACK 9d1dbbd4ce, I have reviewed the code and it looks OK.
  fanquake:
    ACK 9d1dbbd4ce

Tree-SHA512: f11ddc4ae6a887f96b954a6b77f310558ddb271088a3fda3edc833669c4251b7f392515224bbb8e5f67eb2c799b4ffed3b07d96454e82ec635c686d0df545872
2024-02-20 13:07:48 +00:00
Hennadii Stepanov
d301c99554
Merge bitcoin-core/gui#797: test: Recognize dialog object by name
4c9db9b587 qt, test: Recognize dialog object by name (Hennadii Stepanov)

Pull request description:

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

ACKs for top commit:
  furszy:
    Code ACK 4c9db9b587
  BrandonOdiwuor:
    ACK 4c9db9b587

Tree-SHA512: bd54a95d3ef77bce189c2ce279c6b3b4045bdc749e115045bfd7beda73be5a553e145eb331f454cb50374c5a9e98e73794d72d43aa1887dc42bcc585ca17d10c
2024-02-20 11:36:07 +00:00
Pieter Wuille
6e873df347 serfloat: improve/simplify tests 2024-02-20 11:33:32 +00:00
Pieter Wuille
b45f1f5658 serfloat: do not test encode(bits)=bits anymore 2024-02-20 10:25:41 +00:00
fanquake
b1a46b212f
Merge bitcoin/bitcoin#26008: wallet: cache IsMine scriptPubKeys to improve performance of descriptor wallets
e041ed9b75 wallet: Retrieve ID from loaded DescSPKM directly (Ava Chow)
39640dd34e wallet: Use scriptPubKeyCache in GetSolvingProvider (Ava Chow)
b410f68791 wallet: Use scriptPubKey cache in GetScriptPubKeyMans (Ava Chow)
edf4e73a16 wallet: Use scriptPubKey cache in IsMine (Ava Chow)
37232332bd wallet: Cache scriptPubKeys for all DescriptorSPKMs (Ava Chow)
99a0cddbc0 wallet: Introduce a callback called after TopUp completes (Ava Chow)
b276825932 bench: Add a benchmark for ismine (Ava Chow)

Pull request description:

  Wallets that have a ton of non-ranged descriptors (such as a migrated non-HD wallet) perform fairly poorly due to looping through all of the wallet's `ScriptPubKeyMan`s. This is done in various places, such as `IsMine`, and helper functions for fetching a `ScriptPubKeyMan` and a `SolvingProvider`. This also has a bit of a performance impact on standard descriptor wallets, although less noticeable due to the small number of SPKMs.

  As these functions are based on doing `IsMine` for each `ScriptPubKeyMan`, we can improve this performance by caching `IsMine` scriptPubKeys for all descriptors and use that to determine which `ScriptPubKeyMan` to actually use for those things. This cache is used exclusively and we no longer iterate the SPKMs.

  Also added a benchmark for `IsMine`.

ACKs for top commit:
  ryanofsky:
    Code review ACK e041ed9b75. Just suggested changes since last review
  josibake:
    ACK e041ed9b75
  furszy:
    Code review ACK e041ed9b

Tree-SHA512: 8e7081991a025e682e9dea838b4543b0d179832d1c47397fb9fe7a97fa01eb699c15a5d5a785634926844fc83a46e6ac07ef753119f39d84423220ef8a548894
2024-02-20 10:17:46 +00:00
Ava Chow
c265aad5b5
Merge bitcoin/bitcoin#29434: rpc: Fixed signed integer overflow for large feerates
dddd7be9bf doc: Clarify maxfeerate help (MarcoFalke)
fa2a4fdef7 rpc: Fixed signed integer overflow for large feerates (MarcoFalke)
fade94d11a rpc: Add ParseFeeRate helper (MarcoFalke)
fa0ff66109 rpc: Implement RPCHelpMan::ArgValue<> for UniValue (MarcoFalke)

Pull request description:

  Passing large BTC/kvB feerates to RPCs is problematic, because:

  * They are likely a typo. 1BTC/kvB (or larger) seems absurd.
  * They may cause signed integer overflow.
  * Anyone really wanting to pick such a large value can set `0` to disable the check.

  Fix all issues by rejecting anything more than 1BTC/kvB during parsing.

ACKs for top commit:
  brunoerg:
    crACK dddd7be9bf
  achow101:
    ACK dddd7be9bf
  vasild:
    ACK dddd7be9bf
  tdb3:
    Code review ACK and basic test ACK for dddd7be9bf.
  fjahr:
    utACK dddd7be9bf

Tree-SHA512: 5dcce1f0abe059dc6b2ff56787e11081d73a45b4ddd6dcc2c1ea13709ebc13af5e7265e84fffb97ef32027b56b81955672a67ed7702e8fa30c2e849d67727bac
2024-02-19 13:31:13 -05:00