Commit Graph

43004 Commits

Author SHA1 Message Date
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
Antoine Poinsot
b7b2435290
doc: add release note for #31130 2024-10-25 09:27:30 -04:00
Antoine Poinsot
1b6dec98da
depends: drop miniupnpc 2024-10-25 09:27:30 -04:00
Antoine Poinsot
953533d021
doc: remove mentions of UPnP 2024-10-25 09:27:29 -04:00
Antoine Poinsot
94ad614482
ci: remove UPnP options 2024-10-25 09:27:12 -04:00
Greg Sanders
f32c34d0c3 functional test: Additional package evaluation coverage
Current test coverage doesn't ensure that mempool trimming
doesn't appear prior to the entire package, and not just
the subpackage, is finished being submitted.

Add a scenario that covers this case, where package
ancestors can make it in individually, but would be
immadiately evicted if not for the package CPFP.
2024-10-25 09:22:57 -04: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
8f24e492e2
Merge bitcoin/bitcoin#29991: depends: sqlite 3.46.1
def6dd0c59 depends: sqlite 3.46.1 (fanquake)

Pull request description:

  Update sqlite in depends from [3.38.5](https://sqlite.org/releaselog/3_38_5.html) to [3.46.1](https://sqlite.org/releaselog/3_46_1.html).

ACKs for top commit:
  TheCharlatan:
    ACK def6dd0c59
  theuni:
    Not opposed utACK def6dd0c59

Tree-SHA512: 1f12c8ed8d05600b8240bcdbad5cf7d073ea5ab0bbd4a0f49a39ccfe1a93c043ee855b6eb0c67028edec57d8c21588dc33246e64d0b94feafad1a6ec38839893
2024-10-25 11:43:09 +01:00
merge-script
2ef5004f78
Merge bitcoin/bitcoin#31146: ci: Temporary workaround for old CCACHE_DIR cirrus env
fa9747a896 ci: Temporary workaround for old CCACHE_DIR cirrus env (MarcoFalke)

Pull request description:

  On a CI re-run, the historic env vars and CI config is used from Cirrus. However, the most recent CI config and CI scripts from this repo are used. This may lead to issues.

  For example, `CCACHE_DIR` in the old location may be missing on new CI workers and lead to errors.

  Fix it, by falling back to the old logic when the old `CCACHE_DIR` was detected.

ACKs for top commit:
  fanquake:
    ACK fa9747a896 - have seen this now.

Tree-SHA512: 04f0ca8d09ab0b8216a474fde1e05b79fbc6524884be173e8d728799739b026cda18d1797e0fe53d7e1b0ea69c0485acfe4f8a8f85408ea5bfdcffcf13a7ce55
2024-10-25 10:46:04 +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
kevkevinpal
5c299ecafe
test: Assert that when we add the max orphan amount that we cannot add anymore and that a random orphan gets dropped 2024-10-24 21:48:39 -04: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
Ava Chow
74fb19317a
Merge bitcoin/bitcoin#30849: refactor: migrate bool GetCoin to return optional<Coin>
4feaa28728 refactor: Rely on returned value of GetCoin instead of parameter (Lőrinc)
46dfbf169b refactor: Return optional of Coin in GetCoin (Lőrinc)
e31bfb26c2 refactor: Remove unrealistic simulation state (Lőrinc)

Pull request description:

  While reviewing [the removal of the unreachable combinations from the Coin cache logic](https://github.com/bitcoin/bitcoin/pull/30673#discussion_r1721727681), we've noticed that the related tests often [reflect impossible states](https://github.com/bitcoin/bitcoin/pull/30673/files#r1740154464).

  Browsing the Coin cache refactoring history revealed that migrating `bool GetCoin` to `optional<Coin> GetCoin` was [already proposed a few times before](https://github.com/bitcoin/bitcoin/pull/18746#issuecomment-842393167).

  This refactor makes certain invalid states impossible, reducing the possibility of errors and making the code easier to understand. This will let us remove test code that exercises the impossible states as well.
  The PR is done in multiple small steps, first swapping the new `optional` return value, slowly strangling out the usages of the return parameter, followed by the removal of the parameter.

  Most of the invalid test states were still kept, except for https://github.com/bitcoin/bitcoin/pull/30673/files#r1748087322, where the new design prohibits invalid usage and https://github.com/bitcoin/bitcoin/pull/30673/files#r1749350258 was just marked with a TODO, will be removed in a follow-up PR.

ACKs for top commit:
  andrewtoth:
    re-ACK 4feaa28728
  achow101:
    ACK 4feaa28728
  laanwj:
    Code review ACK 4feaa28728
  theStack:
    Code-review ACK 4feaa28728

Tree-SHA512: 818d60b2e97f58c489a61120fe761fb67a08dffbefe7a3fce712d362fc9eb8c2cced23074f1bec55fe71c616a3561b5a8737919ad6ffb2635467ec4711683df7
2024-10-24 13:52:47 -04:00
Ava Chow
c16e909b3e
Merge bitcoin/bitcoin#28574: wallet: optimize migration process, batch db transactions
c98fc36d09 wallet: migration, consolidate external wallets db writes (furszy)
7c9076a2d2 wallet: migration, consolidate main wallet db writes (furszy)
9ef20e86d7 wallet: provide WalletBatch to 'SetupDescriptorScriptPubKeyMans' (furszy)
34bf0795fc wallet: refactor ApplyMigrationData to return util::Result<void> (furszy)
aacaaaa0d3 wallet: provide WalletBatch to 'RemoveTxs' (furszy)
57249ff669 wallet: introduce active db txn listeners (furszy)
91e065ec17 wallet: remove post-migration signals connection (furszy)
055c0532fc wallet: provide WalletBatch to 'DeleteRecords' (furszy)
122d103ca2 wallet: introduce 'SetWalletFlagWithDB' (furszy)
6052c7891d wallet: decouple default descriptors creation from external signer setup (furszy)
f2541d09e1 wallet: batch MigrateToDescriptor() db transactions (furszy)
66c9936455 bench: add coverage for wallet migration process (furszy)

Pull request description:

  Last step in a chain of PRs (#26836, #28894, #28987, #29403).

  #### Detailed Description:
  The current wallet migration process performs only individual db writes. Accessing disk to
  delete all legacy records, clone and clean each address book entry for every created wallet,
  create each new descriptor (with their corresponding master key, caches and key pool), and
  also clone and delete each transaction that requires to be transferred to a different wallet.

  This work consolidates all individual disk writes into two batch operations. One for the descriptors
  creation from the legacy data and a second one for the execution of the migration process itself.
  Efficiently dumping all the information to disk at once atomically at the end of each process.

  This represent a speed up and also a consistency improvement. During migration, we either
  want to succeed or fail. No other outcomes should be accepted. We should never leave a
  partially migrated wallet on disk and request the user to manually restore the previous wallet from
  a backup (at least not if we can avoid it).

  Since the speedup depends on the storage device, benchmark results can vary significantly.
  Locally, I have seen a 15% speedup on a USB 3.2 pendrive.

  #### Note for Testers:
  The first commit introduces a benchmark for the migration process. This one can be
  cherry-picked on top of master to compare results pre and post changes.

  Please note that the benchmark setup may take some time (~70 seconds here) due to the absence
  of a batching mechanism for the address generation process (`GetNewDestination()` calls).

ACKs for top commit:
  achow101:
    ACK c98fc36d09
  theStack:
    re-ACK c98fc36d09
  pablomartin4btc:
    re-ACK c98fc36d09

Tree-SHA512: a52d5f2eef27811045d613637c0a9d0b7e180256ddc1c893749d98ba2882b570c45f28cc7263cadd4710f2c10db1bea33d88051f29c6b789bc6180c85b5fd8f6
2024-10-24 13:30:47 -04:00
Antoine Poinsot
a9598e5eaa
build: drop miniupnpc dependency 2024-10-24 18:23:31 +02:00
Antoine Poinsot
a5fcfb7385
interfaces: remove now unused 'use_upnp' arg from 'mapPort' 2024-10-24 18:23:30 +02:00
Antoine Poinsot
038bbe7b20
daemon: remove UPnP support
Keep the "-upnp" option as a hidden arg for one major version in order
to show a more user friendly error to people who had this option set in
their config file.
2024-10-24 18:23:30 +02:00
Antoine Poinsot
844770b05e
qt: remove UPnP settings 2024-10-24 18:23:29 +02:00
merge-script
dd92911732
Merge bitcoin/bitcoin#31148: ci: display logs of failed unit tests automatically
8523d8c0fc ci: display logs of failed tests automatically (furszy)

Pull request description:

  Saw it here https://github.com/bitcoin/bitcoin/actions/runs/11488618084/job/31975712362?pr=31000.

  The 'test-each-commit' and 'win64' CI jobs currently do not display test logs when an error occurs, making it almost impossible to debug issues that don't arise locally. Fix this by setting the CTest `--output-on-failure` flag (per [README](2f40e453cc/src/test/README.md (L130))).

ACKs for top commit:
  hebasto:
    ACK 8523d8c0fc, I have reviewed the code and it looks OK.

Tree-SHA512: 59c025099fb623e2ed430cfc1ba808e1d3ff72773d021e2280a44423ae53615c16e96a07014eb8581c95aae241b6d2777e388a8931ff0904feb84ca45cb22763
2024-10-24 16:53:53 +01:00