Commit graph

40940 commits

Author SHA1 Message Date
Ava Chow
ceb1e078f8
Merge bitcoin/bitcoin#28793: contrib: Add asmap-tool
6abe772a17 contrib: Add asmap-tool (Fabian Jahr)

Pull request description:

  This adds `asmap.py` and `asmap-tool.py` from sipa's `nextgen` branch: https://github.com/sipa/asmap/tree/nextgen

  The motivation is that we should maintain the tooling for de- and encoding asmap files within the bitcoin core repository because it is not possible to use an asmap file that is not encoded.

  We already had an earlier version of `asmap.py` within the seeds contrib tools. The newer version only had a small amount of changes and is still compatible, so the old version is removed from contrib/seeds and the new version is made available to `makeseeds.py`.

ACKs for top commit:
  virtu:
    ACK [6abe772](6abe772a17)
  0xB10C:
    ACK 6abe772a17
  achow101:
    ACK 6abe772a17
  brunoerg:
    ACK 6abe772a17

Tree-SHA512: cc2a82ffa4eb46fa0ce4ca769dd82f8d0d2f37fc3652aa748eeb060e1142f9da4035008fe89433e2fd524a4dc153b7b9c085748944b49137b37009b0c0be8afb
2024-05-09 11:57:30 -04:00
Ava Chow
921c61e9a5
Merge bitcoin/bitcoin#29973: test: Assumeutxo: ensure failure when importing a snapshot twice
b259b0e8d3 [Test] Assumeutxo: ensure failure when importing a snapshot twice (Alfonso Roman Zubeldia)

Pull request description:

  I am getting familiar with the `assume_utxo` tests and I found that the scenario of trying to activate a snapshot twice is not covered. This test is to ensure failure when loading a snapshot if there is already a snapshot-based chainstate.

ACKs for top commit:
  fjahr:
    Code review ACK b259b0e8d3
  kevkevinpal:
    tACK [b259b0e](b259b0e8d3)
  achow101:
    ACK b259b0e8d3
  rkrux:
    tACK [b259b0e](b259b0e8d3)

Tree-SHA512: 3510861390d0e40cdad6861b728df04827a1b63e642f3d956aee66ed2770b1cb7e3aa3eb00c62eb9da0544703c943cc5296936c9ebfcac18c719741c354421bb
2024-05-09 11:55:15 -04:00
merge-script
6f1d906438
Merge bitcoin/bitcoin#30063: build, test: Remove unused TIMEOUT environment variable
189d0da3f6 build, test: Remove unused `TIMEOUT` environment variable (Hennadii Stepanov)

Pull request description:

  Setting the `TIMEOUT` environment variable has been a noop in both cases since its introduction.

  It seems to have been inadvertently copy-pasted from existed code. For example, in commit d80e3cbece, it was needlessly copied from a valid case a few lines above for the `qa/pull-tester/run-bitcoind-for-test.sh` script.

ACKs for top commit:
  maflcko:
    utACK 189d0da3f6
  edilmedeiros:
    ACK 189d0da3f6

Tree-SHA512: 61111eba30e0c82a0220bea48eba451cd9caa68785b48ec8a91059ca5aadfaff2f6d2ccdc5aa737c5cefa33579cb735431bb9e94bda8fa047825d7bd28d542fb
2024-05-09 11:11:57 +08:00
Ava Chow
43003255c0
Merge bitcoin/bitcoin#29292: rpc: improve submitpackage documentation and other improvements
78e52f663f doc: rpc: fix submitpackage examples (stickies-v)
1a875d4049 rpc: update min package size error message in submitpackage (stickies-v)
f9ece258aa doc: rpc: submitpackage takes sorted array (stickies-v)
17f74512f0 test: add bounds checking for submitpackage RPC (stickies-v)

Pull request description:

  `submitpackage` requires the package to be topologically sorted with the child being the last element in the array, but this is not documented in the RPC method or the error messages.

  Also sneaking in some other minor improvements that I found while going through the code:
  - Informing the user that `package` needs to be an array of length between `1` and `MAX_PACKAGE_COUNT` is confusing when `IsChildWithPackage()` requires that the package size >= 2. Remove this check to avoid code duplication and sending a confusing error message.
  - fixups to the `submitpackage` examples

ACKs for top commit:
  fjahr:
    re-ACK 78e52f663f
  instagibbs:
    ACK 78e52f663f
  achow101:
    ACK 78e52f663f
  glozow:
    utACK 78e52f663f

Tree-SHA512: a8845621bb1cbf784167fc7c82cb8ceb105868b65b26d3465f072d1c04ef3699e85a21a524ade805d423bcecbc34f7d5bff12f2c21cbd902ae1fb154193ebdc9
2024-05-08 18:39:56 -04:00
Ava Chow
8a45f572b9
Merge bitcoin/bitcoin#29335: test: Handle functional test disk-full error
357ad11054 test: Handle functional test disk-full error (Brandon Odiwuor)

Pull request description:

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

  Handle disk-full more gracefully in functional tests

ACKs for top commit:
  itornaza:
    re-ACK 357ad11054
  achow101:
    reACK 357ad11054
  cbergqvist:
    reACK 357ad11054. Looks good!
  tdb3:
    re ACK for 357ad11054

Tree-SHA512: 9bb0d3fbe84600c88873b9f55d4b5d1443f79ec303467680c301be2b4879201387f203d9d1984169461f321037189b5e10a6a4b9d61750de638f072d2f95d77e
2024-05-08 18:11:35 -04:00
Ava Chow
573f631165
Merge bitcoin/bitcoin#26326: net: don't lock cs_main while reading blocks in net processing
75d27fefc7 net: reduce LOCK(cs_main) scope in ProcessGetBlockData (Andrew Toth)
613a45cd4b net: reduce LOCK(cs_main) scope in GETBLOCKTXN (Andrew Toth)

Pull request description:

  Inspired by https://github.com/bitcoin/bitcoin/pull/11913 and https://github.com/bitcoin/bitcoin/pull/26308.

  `cs_main` doesn't need to be locked while reading blocks. This removes the locks in `net_processing`.

ACKs for top commit:
  sr-gi:
    ACK [75d27fe](75d27fefc7)
  achow101:
    ACK 75d27fefc7
  furszy:
    ACK 75d27fefc with a non-blocking nit.
  mzumsande:
    Code Review ACK 75d27fefc7
  TheCharlatan:
    ACK 75d27fefc7

Tree-SHA512: 79b85f748f68ecfb2f2afd3267857dd41b8e76dd482c9c922037399dcbce7b1e5d4c708a4f5fd17c3fb6699b0d88f26a17cc1d92db115dd43c8d4392ae27cec4
2024-05-08 18:04:19 -04:00
Ava Chow
4ff42762fd
Merge bitcoin/bitcoin#28336: rpc: parse legacy pubkeys consistently with specific error messages
98570fe29b test: add coverage for parsing cryptographically invalid pubkeys (Sebastian Falbesoner)
c740b154d1 rpc: use `HexToPubKey` helper for all legacy pubkey-parsing RPCs (Sebastian Falbesoner)
100e8a75bf rpc: check and throw specific pubkey parsing errors in `HexToPubKey` (Sebastian Falbesoner)

Pull request description:

  Parsing legacy public keys can fail for three reasons (in this order):
  - pubkey is not in hex
  - pubkey has an invalid length (not 33 or 65 bytes for compressed/uncompressed, respectively)
  - pubkey is crytographically invalid, i.e. is not on curve (`CPubKey.IsFullyValid()` check)

  Many RPCs currently perform these checks manually with different error messages, even though we already have a `HexToPubKey` helper. This PR puts all three checks in this helper (the length check was done on the call-sites before), adds specific error messages for each case, and consequently uses it for all RPCs that parse legacy pubkeys. This leads to deduplicated code and also to more consistent and detailed error messages for the user.

  Affected RPC calls are `createmultisig`, `addmultisigaddress`, `importpubkey`, `importmulti`, `fundrawtransaction`, `walletcreatefundedpsbt`, `send` and `sendall`.

  Note that the error code (-5 a.k.a. `RPC_INVALID_ADDRESS_OR_KEY`) doesn't change in any of the causes, so the changes are not breaking RPC API compatibility. Only the messages are more specific.

  The last commits adds test coverage for the cryptographically invalid (not-on-curve) pubkey case which wasn't exercised before.

ACKs for top commit:
  stratospher:
    tested ACK 98570fe.
  davidgumberg:
    ACK 98570fe29b
  Eunovo:
    Tested ACK 98570fe29b
  achow101:
    ACK 98570fe29b

Tree-SHA512: cfa474176e95b5b18f3a9da28fdd9e87195cd58994c1331198f2840925fff322fd323a6371feab74a1b32e4b9ea58a6dc732fa751b4cdd45402c1029af609ece
2024-05-08 17:52:58 -04:00
Hennadii Stepanov
189d0da3f6
build, test: Remove unused TIMEOUT environment variable
Setting the `TIMEOUT` environment variable has been a noop in both cases
since its introduction.

It seems to have been inadvertently copy-pasted from existing code. For
example, in commit d80e3cbece, it was
needlessly copied from a valid case a few line above for the
`qa/pull-tester/run-bitcoind-for-test.sh` script.
2024-05-08 14:31:16 +01:00
merge-script
43a66c55ec
Merge bitcoin/bitcoin#30053: test: added test coverage to loadtxoutset could not open file
ee67bba76c test: added test coverage to loadtxoutset (kevkevin)

Pull request description:

  The functional test coverage did not cover the rpc error of "Couldn't open file..." for loadtxoutset and this test adds coverage for it

  This adds coverage to this line
  https://github.com/bitcoin/bitcoin/blob/master/src/rpc/blockchain.cpp#L2777

ACKs for top commit:
  maflcko:
    ACK ee67bba76c
  davidgumberg:
    LGTM ACK ee67bba76c
  rkrux:
    ACK [ee67bba](ee67bba76c)
  alfonsoromanz:
    ACK ee67bba76c. Code looks good to me. I also ran `test/functional/feature_assumeutxo.py` to make sure all tests passes, including this one.
  tdb3:
    ACK for ee67bba76c

Tree-SHA512: 210a7eb928f625d2a8d9acb63ee83cb4aaec9c267e5a0c52ad219c2935466e2cdc68667e30ad29566e6060981587e5bec42805d296f6e60f9b3b13f3330575f2
2024-05-08 16:15:00 +08:00
merge-script
74f517b441
Merge bitcoin/bitcoin#30054: ci: Exclude feature_init for now in valgrind task
fab179d102 ci: Exclude feature_init for now in valgrind task (MarcoFalke)

Pull request description:

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

ACKs for top commit:
  fanquake:
    ACK fab179d102

Tree-SHA512: 5943a2abcec59253af8775e8ac7a120011a92cb66711b01a7e377a9302175d56c7de39ce028edc875b1584bf65458f92face2b0ee2028e84f4d3978d2cbafd0a
2024-05-08 11:56:32 +08:00
merge-script
09d3ad2861
Merge bitcoin/bitcoin#30025: doc: fix broken relative md links
4b9f49da2b doc: fix broken relative md links (willcl-ark)

Pull request description:

  These relative links in our documentation are broken, fix them.

ACKs for top commit:
  maflcko:
    ACK 4b9f49da2b
  ryanofsky:
    Code review ACK 4b9f49da2b. Thanks for the updates!
  ismaelsadeeq:
    Re ACK 4b9f49da2b

Tree-SHA512: df4ef5ddece6c21125ce719ed6a4f69aba4f884c353ff7a8445ecb6438ed6bf0ff8268a1ae19cdd910adaadc189c6861c445b4d469f92ee81874d810dcbd0846
2024-05-08 11:54:46 +08:00
merge-script
4e56df8f91
Merge bitcoin-core/gui#819: Fix misleading signmessage error with segwit
fb9f150759 gui: fix misleading signmessage error with segwit (willcl-ark)

Pull request description:

  As described in https://github.com/bitcoin/bitcoin/issues/10542 (and numerous other places), message signing in Bitcoin Core does not support "signing with a segwit address" and likely will not in the foreseeable future, or 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.

  This change takes the [suggested wording](https://github.com/bitcoin/bitcoin/issues/10542#issuecomment-1960313569) from @adiabat.

  Perhaps with this we can close https://github.com/bitcoin/bitcoin/issues/10542 ?

ACKs for top commit:
  hebasto:
    ACK fb9f150759.

Tree-SHA512: 5ba8d722ad3632dad2e0a2aa94b0f466b904e7885a247a5d26ebdfce54e3611090b103029d8dfce92adc49e50fe5f4830f687d867b4c56c3ea997e519b4e188d
2024-05-07 21:31:14 +01:00
Ava Chow
8efd03ad04
Merge bitcoin/bitcoin#29494: build: Assume HAVE_CONFIG_H, Add IWYU pragma keep to bitcoin-config.h includes
fa09451f8e Add lint check for bitcoin-config.h include IWYU pragma (MarcoFalke)
dddd40ba82 scripted-diff: Add IWYU pragma keep to bitcoin-config.h includes (MarcoFalke)

Pull request description:

  The `bitcoin-config.h` includes have issues:

  * The header is incompatible with iwyu, because symbols may be defined or not defined. So the `IWYU pragma: keep` is needed to keep the include when a symbol is not defined on a platform. Compare the previous discussion in https://github.com/bitcoin/bitcoin/pull/29408#issuecomment-1948959711
  * Guarding the includes by `HAVE_CONFIG_H` is verbose and brittle. Now that all build config dependencies have been removed from low level headers, the benefits are questionable, and the guard can be removed. The linter could also be tricked by guarding the include by `#if defined(HAVE_C0NFIG_H)` (`O` replaced by `0`). Compare the previous discussion in https://github.com/bitcoin/bitcoin/pull/29404#discussion_r1483189853 .

ACKs for top commit:
  achow101:
    ACK fa09451f8e
  TheCharlatan:
    ACK fa09451f8e
  hebasto:
    re-ACK fa09451f8e, only rebased since my recent [review](https://github.com/bitcoin/bitcoin/pull/29494#pullrequestreview-2028864535) (`timedata.cpp` removed in https://github.com/bitcoin/bitcoin/pull/29623).

Tree-SHA512: 47cb973f7f24bc625acc4e78683371863675d186780236d55d886cf4130e05a78bb04f1d731aae7088313b8e963a9677cc77cf518187dbd99d776f6421ca9b52
2024-05-07 14:14:03 -04:00
MarcoFalke
fab179d102
ci: Exclude feature_init for now in valgrind task 2024-05-07 08:53:18 +02:00
merge-script
ef09f535b7
Merge bitcoin/bitcoin#29984: net: Replace ifname check with IFF_LOOPBACK in Discover
a68fed111b net: Fix misleading comment for Discover (laanwj)
7766dd280d net: Replace ifname check with IFF_LOOPBACK in Discover (laanwj)

Pull request description:

  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.

  Also remove a misleading comment in Discover's doc comment.

ACKs for top commit:
  sipa:
    utACK a68fed111b
  willcl-ark:
    utACK a68fed111b
  theuni:
    utACK a68fed111b. Satoshi-era brittleness :)

Tree-SHA512: e2d7fc541f40f6a6af08286e7bcb0873ff55debdcd8b38b03f274897b673a6fb51d84d6c7241a02a9567ddf2645f50231d91bb1f55307ba7c6e68196c29b0edf
2024-05-07 10:28:58 +08:00
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
stickies-v
17f74512f0
test: add bounds checking for submitpackage RPC 2024-05-07 00:21:43 +01:00
kevkevin
ee67bba76c
test: added test coverage to loadtxoutset
The functional test coverage did not cover the rpc error of Couldn't
open file for loadtxoutset and this test adds coverage for it
2024-05-06 17:11:22 -05: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
merge-script
00ac1b963d
Merge bitcoin/bitcoin#29960: depends: pass verbose through to cmake based makefiles
7c69baf227 depends: pass verbose through to cmake based make (Max Edwards)

Pull request description:

  While testing https://github.com/bitcoin/bitcoin/pull/29708 I was not able to enable verbose output to check which flags were being given to the compiler.

  With this PR, running depends with V=1 will enable verbose output from makefiles generated by cmake.

  How to test:

  ```shell
  make -C depends libnatpmp V=1
  ```

ACKs for top commit:
  hebasto:
    ACK 7c69baf227. Tested using the folowing command:
  fanquake:
    ACK 7c69baf227

Tree-SHA512: 81cd1326e940c5f14cbde96735fd02b03c1150881ed88d1e8dfa9385dfa12284bfa2cdfe097ce5f43a726c1718afb76ae16f71552ab68c207d74fdc1f7bb46ae
2024-05-06 09:47:29 +08:00
merge-script
f7b81c7e1e
Merge bitcoin/bitcoin#30031: msvc: Compile test\fuzz\miniscript.cpp
9155b733e1 build, msvc: Compile test\fuzz\miniscript.cpp (Hennadii Stepanov)

Pull request description:

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

  From the CI [log](https://github.com/bitcoin/bitcoin/actions/runs/8941546183/job/24562123707?pr=30031#step:29:234):
  ```
  miniscript_script: succeeded against 721 files in 1s.
  Run miniscript_script with args ['D:\\a\\bitcoin\\bitcoin\\src\\fuzz.exe', WindowsPath('D:/a/_temp/qa-assets/fuzz_seed_corpus/miniscript_script')]
  miniscript_smart: succeeded against 1429 files in 2s.
  Run miniscript_smart with args ['D:\\a\\bitcoin\\bitcoin\\src\\fuzz.exe', WindowsPath('D:/a/_temp/qa-assets/fuzz_seed_corpus/miniscript_smart')]
  miniscript_stable: succeeded against 1871 files in 2s.
  Run miniscript_stable with args ['D:\\a\\bitcoin\\bitcoin\\src\\fuzz.exe', WindowsPath('D:/a/_temp/qa-assets/fuzz_seed_corpus/miniscript_stable')]
  miniscript_string: succeeded against 918 files in 3s.
  Run miniscript_string with args ['D:\\a\\bitcoin\\bitcoin\\src\\fuzz.exe', WindowsPath('D:/a/_temp/qa-assets/fuzz_seed_corpus/miniscript_string')]
  ```

ACKs for top commit:
  maflcko:
    ACK 9155b733e1
  TheCharlatan:
    ACK 9155b733e1

Tree-SHA512: 967f199aac41733265532518ff7b1d881ba5a7bbde9f827d6a0b6d984c94a65b20d5854ce0ea247158eaa17b21d4c9f7d25c79bac17960788bacd2586112630b
2024-05-06 09:33:56 +08: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
Hennadii Stepanov
9155b733e1
build, msvc: Compile test\fuzz\miniscript.cpp 2024-05-04 09:04:09 +01: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
merge-script
bd597c33e3
Merge bitcoin/bitcoin#25972: build: no-longer disable WARN_CXXFLAGS when CXXFLAGS is set
f0e22be69a build: no-longer disable WARN_CXXFLAGS when CXXFLAGS is set (fanquake)
b088062e68 ci: remove -Wdocumentation from -Werror in multiprocess CI (fanquake)
bec6a88fbc ci: remove -Warray-bounds from -Werror for win64 (fanquake)
7469ac7032 ci: disable -Werror=maybe-uninitialized for Windows builds (fanquake)

Pull request description:

  Now that `CXXFLAGS` are [back in user control](https://github.com/bitcoin/bitcoin/pull/24391), I don't think there's a
  reason to no-longer use our warning flags when `CXXFLAGS` has been
  overriden (this includes, by default, when building from depends).

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

  Closes: #18092.

ACKs for top commit:
  maflcko:
    utACK f0e22be69a 🍡
  hebasto:
    ACK f0e22be69a.
  theuni:
    ACK f0e22be69a. It'll be nice to have this fixed.
  TheCharlatan:
    ACK f0e22be69a

Tree-SHA512: dcef4bd4a57bab6f586ca015fad725e7a38bf24b7a08808a74d8c8ca47cf68c5fca7b04ed38649a047c6929fb708e2c97f2000fc46d5a8d25da49951c5bb0f66
2024-05-04 08:47:18 +08: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
Ava Chow
f9486de6a9
Merge bitcoin/bitcoin#30029: test: remove duplicate WITNESS_SCALE_FACTOR constant definition
af3c18169a [test]: remove duplicate WITNESS_SCALE_FACTOR (ismaelsadeeq)

Pull request description:

  Notice this while working on #29523

  - `blocktools.py` and `messages.py` both define `WITNESS_SCALE_FACTOR` constant

  99d7538cdb/test/functional/test_framework/blocktools.py (L48)

  99d7538cdb/test/functional/test_framework/messages.py (L68)
  - This PR deletes the one in `blocktools.py` and update the tests to only use `WITNESS_SCALE_FACTOR` from `messages.py`

ACKs for top commit:
  maflcko:
    ACK af3c18169a
  sipa:
    ACK af3c18169a
  achow101:
    ACK af3c18169a
  glozow:
    lgtm ACK af3c18169a
  brunoerg:
    ACK af3c18169a
  willcl-ark:
    ACK af3c18169a

Tree-SHA512: 6bd8060c9eea10e03940acee2aa4cd08e4e0afb6d26be3e6300ad405fd0af5b373a00e994eb39515a2dcafa1625562bcd57945049a84b9c9dcc7ea60c24f0911
2024-05-03 12:36:00 -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
willcl-ark
4b9f49da2b
doc: fix broken relative md links
These relative links in our documentation are broken, fix them.
2024-05-03 16:07:12 +01: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
ismaelsadeeq
af3c18169a [test]: remove duplicate WITNESS_SCALE_FACTOR 2024-05-03 10:30:50 +01: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
fanquake
f0e22be69a
build: no-longer disable WARN_CXXFLAGS when CXXFLAGS is set
Now that CXXFLAGS are back in user control, I don't think there's a
reason to no-longer use our warning flags when CXXFLAGS has been
overriden (this includes when building from depends).

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

Fixes: #18092.
2024-05-03 15:31:54 +08:00
fanquake
b088062e68
ci: remove -Wdocumentation from -Werror in multiprocess CI
The issues here are coming from Boost Test code.
2024-05-03 15:31:54 +08:00
fanquake
bec6a88fbc
ci: remove -Warray-bounds from -Werror for win64
These warnings are coming from leveldb, and appear to be fixed starting
with GCC 13.
2024-05-03 15:31:54 +08:00
fanquake
7469ac7032
ci: disable -Werror=maybe-uninitialized for Windows builds
This produces false positives, such as:
```bash
torcontrol.cpp: In static member function ‘static void TorControlConnection::readcb(bufferevent*, void*)’:
torcontrol.cpp:94:28: error: ‘result’ may be used uninitialized [-Werror=maybe-uninitialized]
   94 |         self->message.code = ToIntegral<int>(s.substr(0, 3)).value_or(0);
      |         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./netaddress.h:18,
                 from ./torcontrol.h:11,
                 from torcontrol.cpp:6:
./util/strencodings.h:184:7: note: ‘result’ was declared here
  184 |     T result;
      |       ^~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:11088: libbitcoin_node_a-torcontrol.o] Error 1
```
2024-05-03 15:31:54 +08: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
62ef33a718
Merge bitcoin/bitcoin#29617: test: Validate UTXO snapshot with coin height > base height & amount > MAX_MONEY supply
ec1f1abfef test:Validate UTXO snapshot with coin_height > base_height & amount > money_supply (jrakibi)

Pull request description:

  ### Ensure snapshot loading fails for coins exceeding base height

  **Objective**: This test verifies that snapshot loading is correctly rejected for coins with a height greater than the base height.

  **Update**:
  - Added `test_invalid_snapshot_wrong_coin_code` to `feature_assumeutxo.py`.
  - The test artificially sets a coin's height above 299 in a snapshot and checks for load failure.
  - Edit: Added a test case for outputs whose amounts surpass the MAX_MONEY supply limit.

  This implementation addresses the request for enhancing `assumeutxo` testing as outlined in issue #28648

  ---

  **Edit: This is an explanation on how I arrive at content values: b"\x84\x58" and b"\xCA\xD2\x8F\x5A"**

  You can use this tool to decode the utxo snapshot https://github.com/jrakibi/utxo-live
  Here’s an overview of how it’s done:
  The serialization format for a UTXO in the snapshot is as follows:
  1. Transaction ID (txid) - 32 bytes
  2. Output Index (outnum)- 4 bytes
  3. VARINT (code) - A varible-length integer encoding the height and whether the transaction is a coinbase. The format of this VARINT is (height << 1) | coinbase_flag.
  4. VARINT (amount_v) - A variable-length integer that represents a compressed format of the output amount (in satoshis).

  For the test cases mentioned:
  * **`b"\x84\x58"`** - This value corresponds to a VARINT representing the height and coinbase flag. Once we decode this code, we can extract the height and coinbase using `height = code_decoded >> 1` and `coinbase = code_decoded & 0x01`. In our case, with code_decoded = 728, it results in `height = 364` and `coinbase = 0`.
  * **`b"\xCA\xD2\x8F\x5A"`** - This byte sequence represents a compressed amount value. The decompression function takes this value and translates it into a full amount in satoshis. In our case, the decompression of this amount translates to a number larger than the maximum allowed value of coins (21 million BTC)

ACKs for top commit:
  fjahr:
    re-ACK ec1f1abfef
  maflcko:
    ACK ec1f1abfef 👑
  achow101:
    ACK ec1f1abfef

Tree-SHA512: 42b36fd1d76e9bc45861028acbb776bd2710c5c8bff2f75c751ed505995fbc1d4bc698df3be24a99f20bcf6a534615d2d9678fb3394162b88133eaec88ca2120
2024-05-02 16:45:42 -04: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
merge-script
3d28725134
Merge bitcoin/bitcoin#29968: refactor: Avoid unused-variable warning in init.cpp
fa9abf9688 refactor: Avoid unused-variable warning in init.cpp (MarcoFalke)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/pull/27679#discussion_r1580606777

ACKs for top commit:
  TheCharlatan:
    ACK fa9abf9688

Tree-SHA512: dcf56d7aa68578ba611a2dc591de036ab1d08f7f4dfb35d325ecf7241d8e17abc0af7005b96c44da9777adc36961b4da7fdde282a1ab0e0a6f229c8108923101
2024-05-02 21:09:14 +08: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