Commit Graph

27276 Commits

Author SHA1 Message Date
Ava Chow
6b73eb9a1a
Merge bitcoin/bitcoin#31064: init: Correct coins db cache size setting
3a4a788ee0 init: Correct coins db cache size setting (TheCharlatan)

Pull request description:

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

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

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

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

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

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

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

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

Pull request description:

  Implements follow-up suggestions from #30793.

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

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

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

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

Pull request description:

  Part of #27463.

  This PR does 3 things:

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

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

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

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

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

Pull request description:

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

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

ACKs for top commit:
  fanquake:
    ACK 915640e191

Tree-SHA512: 2f17bae21be5d3f280a13425d22f5d1b2e23837a8aaf5ec89c433767509de030a42d598b261e102bdb5b860d8ede98013c124c3d25e081e956d4ee3a81b2584f
2024-10-29 16:21:07 +00:00
Hennadii Stepanov
70713303b6
scripted-diff: Rename PACKAGE_* variables to CLIENT_*
This change ensures consistent use of the `CLIENT_` namespace everywhere
in the repository.

-BEGIN VERIFY SCRIPT-

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

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

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

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

Pull request description:

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

  If `g_fuzzing` is `true` then:

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

  Closes #30950 #31057

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

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

Pull request description:

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

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

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

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

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

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

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

Tree-SHA512: 9ea48662775510f5ec6de7af65790f7c8d211603398e9d8c634a86387be81b28081419a95b4d6680d3d7fe6a9f16cec99f16516548201dc7e49781909899a657
2024-10-28 10:47:34 +00:00
tdb3
698f302df8
rpc: disallow boolean verbosity in getorphantxs
Updates ParseVerbosity() to support disallowing
boolean verbosity.  Removes boolean verbosity
for getorphantxs to encourage integer verbosity
usage
2024-10-25 17:53:48 -04:00
tdb3
808a708107
rpc: add entry time to getorphantxs 2024-10-25 17:11:26 -04:00
tdb3
ac68fcca70
rpc: disallow undefined verbosity in getorphantxs 2024-10-25 17:06:12 -04:00
Antoine Poinsot
40e5f26a3f
mapport: remove dead code in DispatchMapPort
Since there is now only two options in the MapPortProtoFlag enum, the
four possible combinations of current and enabled are already covered in
the four `if` branches.
2024-10-25 15:02:07 -04:00
Antoine Poinsot
38fdf7c1fb
mapport: drop outdated comments 2024-10-25 14:39:03 -04:00
Hennadii Stepanov
6b8a74463b
cmake: Add FindZeroMQ module 2024-10-25 18:09:36 +01:00
merge-script
9a7206a34e
Merge bitcoin/bitcoin#29536: fuzz: fuzz connman with non-empty addrman + ASMap
552cae243a fuzz: cover `ASMapHealthCheck` in connman target (brunoerg)
33b0f3ae96 fuzz: use `ConsumeNetGroupManager` in connman target (brunoerg)
18c8a0945b fuzz: move `ConsumeNetGroupManager` to util (brunoerg)
fe624631ae fuzz: fuzz `connman` with a non-empty addrman (brunoerg)
0a12cff2a8 fuzz: move `AddrManDeterministic` to util (brunoerg)

Pull request description:

  ### Motivation

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

  ### Changes

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

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

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

Pull request description:

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

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

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

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

Tree-SHA512: 1175cff250d9c52ed042e8807ddc2afd64a806e6f2195b5c648752869ff3beec0be8a8cbd7ab6ba35cd7077d79b88a380da6c6e244f5549f98cdd472808b6d8f
2024-10-25 14:45:42 +01:00
dergoegge
9f243cd7fa Introduce g_fuzzing global for fuzzing checks 2024-10-25 13:12:55 +01:00
merge-script
b95adf057a
Merge bitcoin/bitcoin#31150: util: Treat Assume as Assert when evaluating at compile-time
fa69a5f4b7 util: Treat Assume as Assert when evaluating at compile-time (MarcoFalke)

Pull request description:

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

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

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

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

Pull request description:

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

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

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

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

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

Pull request description:

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

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

  Hopefully sufficient to fix #30390.

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

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

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

Pull request description:

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

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

  ----

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

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

  ----

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

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

Tree-SHA512: 8c6e27488462be9ba9186b34abe6249c1d93026b3963acc0f42c75496f39407563766ae518cf1839156039cc0047e29d91f70d191cfb97e0fbde85665e88c71e
2024-10-24 18:01:41 -04:00