Commit graph

26201 commits

Author SHA1 Message Date
stickies-v
78e52f663f
doc: rpc: fix submitpackage examples 2024-05-07 00:22:30 +01:00
stickies-v
1a875d4049
rpc: update min package size error message in submitpackage
Currently, the only allowed package topology has a min size of 2.
Update the error message to reflect that.
2024-05-07 00:22:28 +01:00
stickies-v
f9ece258aa
doc: rpc: submitpackage takes sorted array 2024-05-07 00:21:44 +01:00
Luke Dashjr
cc67d33fda refactor: Simply include CTxMemPool::Options in CTxMemPool directly rather than duplicating definition 2024-05-06 20:34:10 +00:00
Ava Chow
63d0b930f8
Merge bitcoin/bitcoin#29845: rpc: return warnings as an array instead of just a single one
42fb5311b1 rpc: return warnings as an array instead of just a single one (stickies-v)

Pull request description:

  The RPC documentation for `getblockchaininfo`, `getmininginfo` and `getnetworkinfo` states that "warnings" returns "any network and blockchain warnings". In practice, only a single warning (i.e. the latest one that is set) is returned, the other ones are ignored.

  Fix that by returning all warnings as an array.

  As a side benefit, clean up the GetWarnings() logic.

  Since this PR changes the RPC result schema, I've added release notes. Users can temporarily revert to the old results by using `-deprecatedrpc=warnings`, until it's removed in a future version.

  ---

  Some historical context from git log:

  - when `GetWarnings` was introduced in 401926283a, it was used in the `getinfo` RPC, where only a [single error/warning was returned](401926283a (diff-7442c48d42cd5455a79915a0f00cce5e13359db46437a32b812876edb0a5ccddR250)) (similar to how it is now).
  - later on, "warnings" RPC response fields were introduced, e.g. in ef2a3de25c, with the description [stating](ef2a3de25c (diff-1021bd3c74415ad9719bd764ad6ca35af5dfb33b1cd863c0be49bdf52518af54R411)) that it returned "any network warnings" but in practice still only a single warning was returned

ACKs for top commit:
  achow101:
    re-ACK 42fb5311b1
  tdb3:
    Re ACK for 42fb5311b1
  TheCharlatan:
    ACK 42fb5311b1
  maflcko:
    ACK 42fb5311b1 🔺

Tree-SHA512: 4225ed8979cd5f030dec785a80e7452a041ad5703445da79d2906ada983ed0bbe7b15889d663d75aae4a77d92e302c93e93eca185c7bd47c9cce29e12f752bd3
2024-05-06 12:24:09 -04:00
merge-script
fdb41e08c4
Merge bitcoin/bitcoin#29773: build, bench, msvc: Add missing benchmarks
31a15f0aff bench: Disable WalletCreate* benchmarks when building with MSVC (Hennadii Stepanov)
23dc0c19ac msvc, bench: Add missing source files to bench_bitcoin project (Hennadii Stepanov)

Pull request description:

  On the master branch, the `bench_bitcoin.vcxproj` MSVC project misses wallet-specific source files.

  This PR fixes this issue.

  Benchmark run on Windows:
  ```
  > src\bench_bitcoin.exe -filter="CoinSelection|BnBExhaustion|Wallet.*"

  |               ns/op |                op/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |          398,800.00 |            2,507.52 |    1.5% |      0.01 | `BnBExhaustion`
  |          584,450.00 |            1,711.01 |    1.5% |      0.01 | `CoinSelection`
  |       86,603,650.00 |               11.55 |    0.4% |      1.91 | `WalletAvailableCoins`
  |            7,604.00 |          131,509.73 |    0.9% |      0.01 | `WalletBalanceClean`
  |          124,028.57 |            8,062.66 |    2.6% |      0.01 | `WalletBalanceDirty`
  |            7,587.12 |          131,802.30 |    1.9% |      0.01 | `WalletBalanceMine`
  |               48.58 |       20,583,872.99 |    0.9% |      0.01 | `WalletBalanceWatch`
  |        2,371,060.00 |              421.75 |    1.3% |      0.13 | `WalletCreateTxUseOnlyPresetInputs`
  |       96,861,760.00 |               10.32 |    0.9% |      5.31 | `WalletCreateTxUsePresetInputsAndCoinSelection`
  |              280.71 |        3,562,424.13 |    1.5% |      0.01 | `WalletIsMineDescriptors`
  |            1,033.47 |          967,618.32 |    0.3% |      0.01 | `WalletIsMineLegacy`
  |              282.36 |        3,541,599.91 |    0.5% |      0.01 | `WalletIsMineMigratedDescriptors`
  |      484,547,300.00 |                2.06 |    1.0% |      2.43 | `WalletLoadingDescriptors`
  |       29,924,300.00 |               33.42 |    0.4% |      0.15 | `WalletLoadingLegacy`
  ```

ACKs for top commit:
  maflcko:
    lgtm ACK 31a15f0aff

Tree-SHA512: 0241af06126edf612489322cdce66ba43792066b5400b1719a8b9d1ec62030e8a9d497e2f01e38290e94c387db59ccf2a458f4b35d3dc8030a1a1413d89eb792
2024-05-06 21:02:30 +08:00
Hennadii Stepanov
5deb0b024e
build, test, doc: Temporarily remove Android-related stuff
Previously, our Android builds were geared towards generating APKs,
which relied on Qt. However, after migrating to C++20, compiling for
Android became unfeasible due to Qt 5.15's compatibility limitations
with NDK only up to r25, which includes an outdated embedded libc++.

All removed stuff will be reinstated after migrating the build system to
CMake and upgrading Qt to version 6.x."
2024-05-06 11:29:14 +01:00
Andrew Toth
75d27fefc7
net: reduce LOCK(cs_main) scope in ProcessGetBlockData
This also changes behavior if ReadBlockFromDisk or
ReadRawBlockFromDisk fails. Previously, the node would crash
due to an assert. This has been replaced with logging the error,
disconnecting the peer, and returning early.
2024-05-04 15:38:39 -04:00
Andrew Toth
613a45cd4b
net: reduce LOCK(cs_main) scope in GETBLOCKTXN
Also adds a static assertion that MAX_BLOCKTXN_DEPTH <= MIN_BLOCKS_TO_KEEP
2024-05-04 15:33:36 -04:00
merge-script
eb0bdbdd75
Merge bitcoin/bitcoin#28657: miniscript: make operator""_mst consteval
63317103c9 miniscript: make operator_mst consteval (Pieter Wuille)

Pull request description:

  It seems modern compilers don't realize that all invocations of operator""_mst can be evaluated at compile time, despite the `constexpr` keyword.

  Since C++20, we can force them to evaluate at compile time using `consteval`, turning all the miniscript type constants into actual compile-time constants.

  This should give a nice but not very important speedup for miniscript logic, but it's also a way to start testing C++20 features.

ACKs for top commit:
  hebasto:
    re-ACK 63317103c9.
  theuni:
    utACK 63317103c9

Tree-SHA512: bdc9f1a6499b8bb3ca04f1a158c31e6876ba97206f95ee5718f50efd58b5b4e6b8867c07f791848430bfaa130b9676d8a68320b763cda9a340c75527acbfcc9e
2024-05-04 09:13:11 +08:00
merge-script
61d3280c3a
Merge bitcoin/bitcoin#29907: test: Fix test/streams_tests.cpp compilation on SunOS / illumos
976e5d8f7b test: Fix `test/streams_tests.cpp` compilation on SunOS / illumos (Hennadii Stepanov)

Pull request description:

  On systems where `int8_t` is defined as `char`, the `{S,Uns}erialize(Stream&, signed char)` functions become undefined.

  This PR 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.

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

  An alternative approach is mentioned in https://github.com/bitcoin/bitcoin/issues/29884#issuecomment-2058434577 as well.

ACKs for top commit:
  maflcko:
    lgtm ACK 976e5d8f7b
  theuni:
    ACK 976e5d8f7b. Nice to have the serialization concept actually tested :)

Tree-SHA512: 1033863e584fa8e99a281b236fa01fc919f610a024bcec792116762e28c1c16ee481bd01325c3a0ca9dd9d753176aa63bd9ac7e08a9bbce772db2949d06f6e61
2024-05-04 09:07:44 +08:00
furszy
53302a0981
bugfix: addmultisigaddress, add unsupported operation for redeem scripts over 520 bytes
Due to a bug in the legacy wallet, the p2sh maximum script size limit is also imposed
on 'p2sh-segwit' and 'bech32' redeem scripts.
Although redeem scripts over MAX_SCRIPT_ELEMENT_SIZE bytes are technically valid for
segwit output types, we don't want to enable this feature in legacy wallets for the
following reasons:

1) It introduces a compatibility-breaking change requiring downgrade protection; older
   wallets would be unable to interact with these "new" legacy wallets.

2) Considering the ongoing deprecation of the legacy spkm, this issue adds another
   good reason to transition towards descriptors.
2024-05-03 14:20:45 -03:00
furszy
9d9a91c4ea
rpc: bugfix, incorrect segwit redeem script size used in signrawtransactionwithkey
The process currently fails to sign redeem scripts that are longer than
520 bytes. Even when it shouldn't. The 520 bytes redeem scripts limit
is a legacy p2sh rule, and not a segwit limitation.

Segwit redeem scripts are not restricted by the script item size limit.

The reason why this occurs, is the usage of the same keystore used by
the legacy spkm. Which contains blockage for any redeem scripts longer
than the script item size limit.
2024-05-03 14:20:45 -03:00
furszy
0c9fedfc45
fix incorrect multisig redeem script size limit for segwit
The multisig script generation process currently fails when
the user exceeds 15 keys, even when it shouldn't. The maximum
number of keys allowed for segwit redeem scripts (p2sh-segwit
and bech32) is 20 keys.
This is because the redeem script placed in the witness is not
restricted by the item size limit.

The reason behind this issue is the utilization of the legacy
p2sh redeem script restrictions on segwit ones. Redeem scripts
longer than 520 bytes are blocked from being inserted into the
keystore, which causes the signing process and the descriptor
inference process to fail.

This occurs because the multisig generation flow uses the same
keystore as the legacy spkm (FillableSigningProvider), which
contains the 520-byte limit.
2024-05-03 14:20:44 -03:00
Ava Chow
f5b6f621ff
Merge bitcoin/bitcoin#30024: doc: replace remaining "520" magic nums with MAX_SCRIPT_ELEMENT_SIZE
ffc674595c Replace remaining "520" magic numbers with MAX_SCRIPT_ELEMENT_SIZE (Jon Atack)

Pull request description:

  Noticed these while reviewing BIPs yesterday.

  It would be clearer and more future-proof to refer to their constant name.

ACKs for top commit:
  instagibbs:
    ACK ffc674595c
  sipa:
    ACK ffc674595c
  achow101:
    ACK ffc674595c
  glozow:
    ACK ffc674595c, agree it's clearer for these comments to refer to the greppable name of the limit rather than the number

Tree-SHA512: 462afc1c64543877ac58cb3acdb01d42c6d08abfb362802f29f3482d75401a2a8adadbc2facd222a9a9fefcaab6854865ea400f50ad60bec17831d29f7798afe
2024-05-03 12:36:56 -04:00
Pieter Wuille
63317103c9 miniscript: make operator_mst consteval
It seems modern compilers don't realize that all invocations of operator""_mst
can be evaluated at compile time, despite the constexpr keyword.

Since C++20, we can force them to evaluate at compile time, turning all the
miniscript type constants into actual compile-time constants.

It appears that MSVC does not support consteval operator"" when used inside
certain expressions. For the few places where this happens, define a
constant outside the operator call.

Co-Authored-By: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2024-05-03 11:38:14 -04:00
Ryan Ofsky
70e4d6ff1d
Merge bitcoin/bitcoin#30026: refactor, test: Always initialize pointer
bd2de7ac59 refactor, test: Always initialize pointer (Hennadii Stepanov)

Pull request description:

  This change fixes MSVC warning [C4703](https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4703).

  All `DisableSpecificWarnings` dropped from `test_bitcoin.vcxproj` as all remained are inherited from `common.init.vcxproj`.

  Required to simplify warning suppression porting to the CMake-based build system.

ACKs for top commit:
  maflcko:
    utACK bd2de7ac59
  sipsorcery:
    utACK bd2de7ac59.
  ryanofsky:
    Code review ACK bd2de7ac59

Tree-SHA512: 006db041d3c3697a77d9df14de86cf7c8a10804b45789df01268b2236cf6452e77dc57e89f5d5a6bc26d4b5cd483f0722d6035649c8a523b57954bb1fc810d0c
2024-05-03 09:54:52 -04:00
willcl-ark
fb9f150759
gui: fix misleading signmessage error with segwit
As described in #10542 (and numerous other places), message signing in
Bitcoin Core only supports message signing using P2PKH addresses, at
least until a new message-signing standard is agreed upon.

Therefore update the possibly-misleading error message presented to the
user in the GUI to detail more specifically the reason their message
cannot be signed, in the case that a non P2PKH address is entered.
2024-05-03 08:36:57 +01:00
merge-script
99d7538cdb
Merge bitcoin/bitcoin#30012: opportunistic 1p1c followups
7f6fb73c82 [refactor] use reference in for loop through iters (glozow)
6119f76ef7 Process every MempoolAcceptResult regardless of PackageValidationResult (glozow)
2b482dc1f3 [refactor] have ProcessPackageResult take a PackageToValidate (glozow)
c2ada05307 [doc] remove redundant PackageToValidate comment (glozow)
9a762efc7a [txpackages] use std::lexicographical_compare instead of sorting hex strings (glozow)
8496f69e1c [refactor] make MempoolAcceptResult::m_replaced_transactions non-optional (glozow)

Pull request description:

  Followups from #28970:
  - https://github.com/bitcoin/bitcoin/pull/28970#discussion_r1568781077
  - https://github.com/bitcoin/bitcoin/pull/28970#discussion_r1585554972
  - https://github.com/bitcoin/bitcoin/pull/28970#discussion_r1581019326
  - https://github.com/bitcoin/bitcoin/pull/28970#discussion_r1581036209
  - https://github.com/bitcoin/bitcoin/pull/28970#discussion_r1586258730

ACKs for top commit:
  instagibbs:
    reACK 7f6fb73c82

Tree-SHA512: 9d8393d5f2fedbc6ebce582ff2a8ed074a02dd8e7dbf562c14d48b439fdc1ee6c3203b3609366d3c883d44655cc1a5c83a75ca56e490d25c1a34d95a0622d458
2024-05-03 15:31:06 +08:00
merge-script
5127844cab
Merge bitcoin/bitcoin#30017: refactor, fuzz: Make 64-bit shift explicit
b50d127a77 refactor: Make 64-bit shift explicit (Hennadii Stepanov)

Pull request description:

  This PR fixes MSVC warning [C4334](https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4334) in the fuzzing code. Similar to https://github.com/bitcoin/bitcoin/pull/26252.

  All `DisableSpecificWarnings` dropped from `fuzz.vcxproj` as all remained are inherited from `common.init.vcxproj`.

  Required to simplify warning suppression porting to the CMake-based build system.

ACKs for top commit:
  maflcko:
    utACK b50d127a77
  sipsorcery:
    utACK b50d127a77

Tree-SHA512: 18f6082b4234506ad2f9df54e577031b97cdf9f7ef64cad4162f275660716ab73587a97d3af0f778dfd48d2751d8676b5d3381d0aa837fcc60a09704473a9209
2024-05-03 10:47:37 +08:00
Hennadii Stepanov
bd2de7ac59
refactor, test: Always initialize pointer
This change fixes MSVC warning C4703.
See: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4703

All `DisableSpecificWarnings` dropped from `test_bitcoin.vcxproj` as all
remained are inherited from `common.init.vcxproj`.
2024-05-02 23:10:05 +01:00
Ava Chow
81174d8a9b
Merge bitcoin/bitcoin#29961: refactor: remove remaining unused code from cpp-subprocess
8b52e7f628 update comments in cpp-subprocess (check_output references) (Sebastian Falbesoner)
97f159776e remove unused method `Popen::kill` from cpp-subprocess (Sebastian Falbesoner)
908c51fe4a remove commented out code in cpp-subprocess (Sebastian Falbesoner)
ff79adbe05 remove unused templates from cpp-subprocess (Sebastian Falbesoner)

Pull request description:

  This PR removes remaining code that is unused within the cpp-subprocess module (templates and commented out code). Happy to add more removals if anyone finds more unused parts. Note that there are some API functions of the `Popen` class that we don't use, e.g. `wait()`, `pid()`, `poll()`, `kill()`, but they sound IMHO common enough to be useful in the future, so not sure how deep we should go there.

ACKs for top commit:
  fjahr:
    Code review ACK 8b52e7f628
  achow101:
    ACK 8b52e7f628
  hebasto:
    ACK 8b52e7f628.

Tree-SHA512: 14c1cd2216185d941923f06fdc7acbeed66cd87e2691d9a352f7309b3e07fe4877b580f598a2e4106f9c48395ed6de00a0bfb5d3c3af9c4624d1956a0f543e99
2024-05-02 16:33:18 -04:00
Jon Atack
ffc674595c Replace remaining "520" magic numbers with MAX_SCRIPT_ELEMENT_SIZE 2024-05-02 13:16:40 -06:00
MarcoFalke
fa9abf9688
refactor: Avoid unused-variable warning in init.cpp 2024-05-02 12:37:24 +02:00
glozow
7f6fb73c82 [refactor] use reference in for loop through iters 2024-05-02 11:24:36 +01:00
Hennadii Stepanov
b50d127a77
refactor: Make 64-bit shift explicit
This change fixes MSVC level-3 warning C4334.
See: https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4334

All `DisableSpecificWarnings` dropped from `fuzz.vcxproj` as all
remained are inherited from `common.init.vcxproj`.
2024-05-02 00:16:33 +01:00
Ayush Singh
d7290d662f fuzz: wallet, add target for Crypter 2024-05-02 01:14:15 +05:30
merge-script
d73245abc7
Merge bitcoin/bitcoin#29120: test: Add test case for spending bare multisig
e504b1fa1f test: Add test case for spending bare multisig (Brandon Odiwuor)

Pull request description:

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

ACKs for top commit:
  ajtowns:
    ACK e504b1fa1f ; LGTM and just checking the 1-of-3 case seems fine
  maflcko:
    utACK e504b1fa1f
  achow101:
    ACK e504b1fa1f
  willcl-ark:
    reACK e504b1fa1f

Tree-SHA512: 641a12599efa34e1a3eb65b125318df326628fef3e6886410ea9e63a044664fad7bcad46d1d6f41ddc59630746b9963cedb569c2682b5940b32b9225883da8f2
2024-05-01 14:43:58 -04:00
Sergi Delgado Segura
58594c7040 fuzz: txorphan tests fixups
Adds the following fixups in txorphan fuzz tests:

- Don't bond the output count of the created orphans based on the number of available coins
- Allow duplicate inputs, when applicable, but don't store duplicate outpoints

Rationale
---------

The way the test is currently written, duplicate inputs are allowed based on a random flag (`duplicate_input`).
If the flag is unset, upon selecting an outpoint as input for a new transaction, the input is popped to prevent re-selection,
and later re-added to the collection (once all inputs have been picked). However, the re-addition to the collection is performed independently of whether the flag was set or not.
This means that, if the flag is set, the selected inputs are duplicated which in turn makes these inputs more likely to be re-picked in the following iteration of the loop.

Additionally, both the input and output count of the transaction and bonded to the number of available outpoints. This makes sense for the former, but the latter shouldn't be.
2024-05-01 11:06:48 -04:00
stickies-v
42fb5311b1
rpc: return warnings as an array instead of just a single one
The RPC documentation for `getblockchaininfo`, `getmininginfo` and
`getnetworkinfo` states that "warnings" returns "any network and
blockchain warnings". In practice, only a single warning is returned.

Fix that by returning all warnings as an array.

As a side benefit, cleans up the GetWarnings() logic.
2024-05-01 14:44:57 +01:00
glozow
6119f76ef7 Process every MempoolAcceptResult regardless of PackageValidationResult 2024-05-01 13:48:03 +01:00
glozow
2b482dc1f3 [refactor] have ProcessPackageResult take a PackageToValidate 2024-05-01 13:38:19 +01:00
glozow
c2ada05307 [doc] remove redundant PackageToValidate comment 2024-05-01 13:35:12 +01:00
glozow
9a762efc7a [txpackages] use std::lexicographical_compare instead of sorting hex strings
No behavior change, but getting the hex string is more expensive than
necessary.
2024-05-01 13:34:37 +01:00
glozow
8496f69e1c [refactor] make MempoolAcceptResult::m_replaced_transactions non-optional 2024-05-01 13:34:37 +01:00
MarcoFalke
dddd40ba82
scripted-diff: Add IWYU pragma keep to bitcoin-config.h includes
-BEGIN VERIFY SCRIPT-
 perl -0777 -pi -e 's/#if defined\(HAVE_CONFIG_H\)\n#include <config\/bitcoin-config.h>.*\n#endif.*\n/#include <config\/bitcoin-config.h> \/\/ IWYU pragma: keep\n/g' $( git grep -l '#include <config/bitcoin-config.h>' )
-END VERIFY SCRIPT-
2024-05-01 08:33:04 +02:00
Ava Chow
4df2d0c4ce
Merge bitcoin/bitcoin#29983: msvc: Compile test\fuzz\bitdeque.cpp
774359b4a9 build, msvc: Compile `test\fuzz\bitdeque.cpp` (Hennadii Stepanov)
85f50a46c5 refactor: Fix "error C2248: cannot access private member" on MSVC (Hennadii Stepanov)

Pull request description:

  This PR resolves one point from the https://github.com/bitcoin/bitcoin/pull/29774#issuecomment-2028808614:
  > What is the issue with the bitdeque... ?

ACKs for top commit:
  maflcko:
    lgtm ACK 774359b4a9
  sipa:
    utACK 774359b4a9
  achow101:
    ACK 774359b4a9
  dergoegge:
    utACK 774359b4a9

Tree-SHA512: dba5c0217b915468af08475795437a10d8e8dedfadeb319f36d9b1bf54a91a8b2c61470a6047565855276c2bc8589c7776dc19237610b65b57cc841a303de8b3
2024-04-30 20:14:02 -04:00
Ava Chow
326e563360
Merge bitcoin/bitcoin#28016: p2p: gives seednode priority over dnsseed if both are provided
82f41d76f1 Added seednode prioritization message to help output (tdb3)
3120a4678a Gives seednode priority over dnsseed if both are provided (Sergi Delgado Segura)

Pull request description:

  This is a follow-up of #27577

  If both `seednode` and `dnsseed` are provided, the node will start a race between them in order to fetch data to feed the `addrman`.

  This PR gives priority to `seednode` over `dnsseed` so if some nodes are provided as seeds, they can be tried before defaulting to the `dnsseeds`

ACKs for top commit:
  davidgumberg:
    untested reACK 82f41d76f1
  itornaza:
    tested re-ACK 82f41d76f1
  achow101:
    ACK 82f41d76f1
  cbergqvist:
    ACK 82f41d76f1

Tree-SHA512: 4e39e10a7449af6cd9b8f9f6878f846b94bca11baf89ff2d4fbcd4f28293978a6ed71a3a86cea36d49eca891314c834e32af93f37a09c2cc698a878f84d31c62
2024-04-30 18:59:56 -04:00
Ava Chow
0c3a3c9394
Merge bitcoin/bitcoin#29623: Simplify network-adjusted time warning logic
c6be144c4b Remove timedata (stickies-v)
92e72b5d0d [net processing] Move IgnoresIncomingTxs to PeerManagerInfo (dergoegge)
7d9c3ec622 [net processing] Introduce PeerManagerInfo (dergoegge)
ee178dfcc1 Add TimeOffsets helper class (stickies-v)
55361a15d1 [net processing] Use std::chrono for type-safe time offsets (stickies-v)
038fd979ef [net processing] Move nTimeOffset to net_processing (dergoegge)

Pull request description:

  [An earlier approach](1d226ae1f9/) in #28956 involved simplifying and refactoring the network-adjusted time calculation logic, but this was eventually [left out](https://github.com/bitcoin/bitcoin/pull/28956#issuecomment-1904214370) of the PR to make it easier for reviewers to focus on consensus logic changes.

  Since network-adjusted time is now only used for warning/informational purposes, cleaning up the logic (building on @dergoegge's approach in #28956) should be quite straightforward and uncontroversial. The main changes are:

  - Previously, we would only calculate the time offset from the first 199 outbound peers that we connected to. This limitation is now removed, and we have a proper rolling calculation. I've reduced the set to 50 outbound peers, which seems plenty.
  - Previously, we would automatically use the network-adjusted time if the difference was < 70 mins, and warn the user if the difference was larger than that. Since there is no longer any automated time adjustment, I've changed the warning threshold to ~~20~~ 10 minutes (which is an arbitrary number).
  - Previously, a warning would only be raised once, and then never again until node restart. This behaviour is now updated to  1) warn to log for every new outbound peer for as long as we appear out of sync, 2) have the RPC warning toggled on/off whenever we go in/out of sync, and 3) have the GUI warn whenever we are out of sync (again), but limited to 1 messagebox per 60 minutes
  - no more globals
  - remove the `-maxtimeadjustment` startup arg

  Closes #4521

ACKs for top commit:
  sr-gi:
    Re-ACK [c6be144](c6be144c4b)
  achow101:
    reACK c6be144c4b
  dergoegge:
    utACK c6be144c4b

Tree-SHA512: 1063d639542e882186cdcea67d225ad1f97847f44253621a8c4b36c4d777e8f5cb0efe86bc279f01e819d33056ae4364c3300cc7400c087fb16c3f39b3e16b96
2024-04-30 18:49:34 -04:00
Ava Chow
d813ba1bc4
Merge bitcoin/bitcoin#28970: p2p: opportunistically accept 1-parent-1-child packages
e518a8bf8a [functional test] opportunistic 1p1c package submission (glozow)
87c5c524d6 [p2p] opportunistically accept 1-parent-1-child packages (glozow)
6c51e1d7d0 [p2p] add separate rejections cache for reconsiderable txns (glozow)
410ebd6efa [fuzz] break out parent functions and add GetChildrenFrom* coverage (glozow)
d095316c1c [unit test] TxOrphanage::GetChildrenFrom* (glozow)
2f51cd680f [txorphanage] add method to get all orphans spending a tx (glozow)
092c978a42 [txpackages] add canonical way to get hash of package (glozow)
c3c1e15831 [doc] restore comment about why we check if ptx HasWitness before caching rejected txid (glozow)
6f4da19cc3 guard against MempoolAcceptResult::m_replaced_transactions (glozow)

Pull request description:

  This enables 1p1c packages to propagate in the "happy case" (i.e. not reliable if there are adversaries) and contains a lot of package relay-related code. See https://github.com/bitcoin/bitcoin/issues/27463 for overall package relay tracking.

  Rationale: This is "non-robust 1-parent-1-child package relay" which is immediately useful.
  - Relaying 1-parent-1-child CPFP when mempool min feerate is high would be a subset of all package relay use cases, but a pretty significant improvement over what we have today, where such transactions don't propagate at all. [1]
  - Today, a miner can run this with a normal/small maxmempool to get revenue from 1p1c CPFP'd transactions without losing out on the ones with parents below mempool minimum feerate.
  - The majority of this code is useful for building more featureful/robust package relay e.g. see the code in #27742.

  The first 2 commits are followups from #29619:
  - https://github.com/bitcoin/bitcoin/pull/29619#discussion_r1523094034
  - https://github.com/bitcoin/bitcoin/pull/29619#discussion_r1519819257

  Q: What makes this short of a more full package relay feature?

  (1) it only supports packages in which 1 of the parents needs to be CPFP'd by the child. That includes 1-parent-1-child packages and situations in which the other parents already pay for themselves (and are thus in mempool already when the package is submitted). More general package relay is a future improvement that requires more engineering in mempool and validation - see #27463.

  (2) We rely on having kept the child in orphanage, and don't make any attempt to protect it while we wait to receive the parent. If we are experiencing a lot of orphanage churn (e.g. an adversary is purposefully sending us a lot of transactions with missing inputs), we will fail to submit packages. This limitation has been around for 12+ years, see #27742 which adds a token bucket scheme for protecting package-related orphans at a limited rate per peer.

  (3) Our orphan-handling logic is somewhat opportunistic; we don't make much effort to resolve an orphan beyond asking the child's sender for the parents. This means we may miss packages if the first sender fails to give us the parent (intentionally or unintentionally). To make this more robust, we need receiver-side logic to retry orphan resolution with multiple peers. This is also an existing problem which has a proposed solution in #28031.

  [1]: see this writeup and its links 02ec218c78/bip-0331.mediawiki (propagate-high-feerate-transactions)

ACKs for top commit:
  sr-gi:
    tACK e518a8bf8a
  instagibbs:
    reACK e518a8bf8a
  theStack:
    Code-review ACK e518a8bf8a 📦
  dergoegge:
    light Code review ACK e518a8bf8a
  achow101:
    ACK e518a8bf8a

Tree-SHA512: 632579fbe7160cb763bbec6d82ca0dab484d5dbbc7aea90c187c0b9833b8d7c1e5d13b8587379edd3a3b4a02a5a1809020369e9cd09a4ebaf729921f65c15943
2024-04-30 18:40:53 -04:00
Ava Chow
2d3056751b
Merge bitcoin/bitcoin#29906: Disable util::Result copying and assignment
6a8b2befea refactor: Avoid copying util::Result values (Ryan Ofsky)
834f65e824 refactor: Drop util::Result operator= (Ryan Ofsky)

Pull request description:

  This PR just contains the first two commits of #25665.

  It disables copying of `util::Result` objects because unnecessary copies are inefficient and not possible after #25665, which makes `util::Result` object move-only.

  It disables the assignment operator and replaces it with an `Update()` method, because #25665 adds more information to `util::Result` objects (warning and error messages and failure values) and having an assignment operator that overwrites data instead of merging it would make it easy to accidentally erase existing information while trying to assign new information.

ACKs for top commit:
  stickies-v:
    re-ACK 6a8b2befea
  achow101:
    ACK 6a8b2befea
  furszy:
    re-ACK 6a8b2befea

Tree-SHA512: 3f21af9031d50d6c68cca69133de03080f69b1ddcf8b140bdeb762069f14645209b2586037236d15b6ebd8973af0fbefd7e83144aeb7b84078a4cb4df812f984
2024-04-30 12:19:03 -04:00
Matthew Zipkin
855dd8d592
system: use %LOCALAPPDATA% as default datadir on windows 2024-04-30 11:03:04 -04:00
glozow
36e660fc23
Merge bitcoin/bitcoin#29990: fuzz: don't allow adding duplicate transactions to the mempool
cc15c5bfd1 fuzz: don't allow adding duplicate transactions to the mempool (Suhas Daftuar)

Pull request description:

  Filter duplicate transaction ids from being added to the mempool in the `partially_downloaded_block` fuzz target.

  I think a prerequisite for calling `CTxMemPool::addUnchecked` should be that the underlying txid doesn't already exist in the mempool (otherwise `addUnchecked` would need a way to return failure, which we don't currently have).

ACKs for top commit:
  glozow:
    utACK cc15c5bfd1 makes sense to me
  maflcko:
    lgtm ACK cc15c5bfd1
  brunoerg:
    ACK cc15c5bfd1
  dergoegge:
    utACK cc15c5bfd1

Tree-SHA512: 85f84ce405aba584e6d00391515f0a86c5648ce8b2da69036e50a6c1f6833d050d09b1972cc5ffbe7c4edb3e5f7f965ef34bd839deeddac27a889cc8d2e53b8f
2024-04-30 09:52:00 +01:00
kevkevin
95897ff181
doc: removed help text saying that peers may not connect automatically
This help text was introduced about two years ago and now a significant
portion of users are using version 23.0 and higher
2024-04-29 11:15:15 -05:00
Ryan Ofsky
19865a8350
Merge bitcoin/bitcoin#29277: RPC: access RPC arguments by name
30a6c99935 rpc: access some args by name (stickies-v)
bbb31269bf rpc: add named arg helper (stickies-v)
13525e0c24 rpc: add arg helper unit test (stickies-v)

Pull request description:

  Adds string overloads for the `RPCHelpMan::Arg` and `RPCHelpMan::MaybeArg` helpers to be able to access RPC arguments by name instead of index number. Especially in RPCs with a large number of parameters, this can be quite helpful.

  Example usage:
  ```cpp
  const auto action{self.Arg<std::string>("action")};
  ```

  Most of the LoC is adding test coverage and documentation updates. No behaviour change.

  An alternative approach to #27788 with significantly less overhaul.

ACKs for top commit:
  fjahr:
    Code review ACK 30a6c99935
  maflcko:
    ACK 30a6c99935 🥑
  ryanofsky:
    Code review ACK 30a6c99935. Nice change! Implementation is surprisingly simple and additional unit test coverage is welcome, too.

Tree-SHA512: 4904f5f914fe1d421d32f60edb7c5a028c8ea0f140a2f207a106b4752d441164e073066a6bf2e17693f859fe847815a96609d3cf521e0ac4178d8cd09362ea3d
2024-04-29 10:38:50 -04:00
merge-script
0c45d73f18
Merge bitcoin/bitcoin#29872: test: Add missing Assert(mock_time_in >= 0s) to SetMockTime
fae0db555c refactor: Use chrono type for g_mock_time (MarcoFalke)
fa382d3dd0 test: Add missing Assert(mock_time_in >= 0s) to SetMockTime (MarcoFalke)

Pull request description:

  Seems odd to have the assert in the *deprecated* function, but not in the other.

  Fix this by adding it to the other, and by inlining the deprecated one.

  Also, use chrono type for the global mocktime variable.

ACKs for top commit:
  davidgumberg:
    crACK fae0db555c
  stickies-v:
    ACK fae0db555c

Tree-SHA512: 630c2917422ff2a7fa307114f95f22ad3c205429ffe36e67f0b2650733e40c876289c1aecebe882a9123d3106db7606bd6eff067ed6e2ecb95765984d3fe8612
2024-04-29 21:37:49 +08:00
Suhas Daftuar
cc15c5bfd1 fuzz: don't allow adding duplicate transactions to the mempool 2024-04-28 15:39:10 -04:00
Sebastian Falbesoner
8b52e7f628 update comments in cpp-subprocess (check_output references)
Remove obsolete `check_output` references in the comments and remove
the numbering of the Popen API methods, as they don't seem to provide a
value and just make diffs larger for future changes.
2024-04-28 14:18:06 +02:00
Sebastian Falbesoner
97f159776e remove unused method Popen::kill from cpp-subprocess 2024-04-28 14:17:14 +02:00
laanwj
a68fed111b net: Fix misleading comment for Discover
All network addresses are being iterated over and added, not just the first one per interface.
2024-04-28 11:40:19 +02:00
laanwj
7766dd280d net: Replace ifname check with IFF_LOOPBACK in Discover
Checking the interface name is kind of brittle. In the age of network
namespaces and containers, there is no reason a loopback interface can't
be called differently.

Check for the `IFF_LOOPBACK` flag to detect loopback interface instead.
2024-04-28 11:37:54 +02:00
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
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
e58e1323a8
Update minisketch subtree to latest master 2024-04-12 14:27:45 +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
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