Commit Graph

26006 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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