0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-04 10:07:27 -05:00
Commit graph

24154 commits

Author SHA1 Message Date
Luke Dashjr
1b0407f5f1
Bugfix: GUI: transactiondesc: Translate outlier "own address" and "watch-only" 2023-03-31 12:22:11 +01:00
Luke Dashjr
170f3126f2
GUI: Use translated external signer errors for messagebox text 2023-03-31 12:22:05 +01:00
Luke Dashjr
96989599d6
GUI: Make messages for copying unsigned PSBTs translatable 2023-03-31 12:22:00 +01:00
Luke Dashjr
08b8b287d3
Bugfix: GUI: Debug info: Use correct "kB" case for small mempool sizes, and make translation-friendly 2023-03-31 12:21:51 +01:00
Luke Dashjr
dacc322be1
GUI: PSBTOperationsDialog: Support translating window title 2023-03-31 12:21:42 +01:00
Luke Dashjr
5a4fe55270
GUI: Intro: Support translating caption of data directory chooser 2023-03-31 12:21:35 +01:00
Luke Dashjr
3868ba3a27
GUI: Support translating peer network names 2023-03-31 12:21:23 +01:00
Luke Dashjr
f1f9811198
GUI: Support translating address type dropdown entries 2023-03-31 12:21:11 +01:00
dergoegge
3fa4c54ac5 [net processing] Pass TxRelay to FindTxForGetData instead of Peer 2023-03-31 13:19:20 +02:00
dergoegge
c85ee76a36 [net processin] Don't take cs_main in FindTxForGetData
Taking cs_main is no longer necessary since we moved
`m_recently_announced_invs` to `Peer` and `mapRelay` is actually only
accessed from the message processing thread.
2023-03-31 13:18:39 +02:00
glozow
59afcc8354
Implement Mini version of BlockAssembler to calculate mining scores
Rewrite the same algo instead of reusing BlockAssembler because we have
a few extra requirements that would make the changes invasive and
difficult to review:

- Only operate on the relevant transactions rather than full mempool
- Remove transactions that will be replaced so they can't bump their ancestors
- Don't hold mempool lock outside of the constructor
- Skip things like max block weight and IsFinalTx
- Additionally calculate fees to bump remaining ancestor packages to target feerate

Co-authored-by: Murch <murch@murch.one>
2023-03-30 17:03:04 -04:00
dergoegge
3a060ae7b6 scripted-diff: Rename nUnconnectingHeaders and fPreferHeaders
-BEGIN VERIFY SCRIPT-
ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); }

ren nUnconnectingHeaders     m_num_unconnecting_headers_msgs
ren fPreferHeaders           m_prefers_headers
ren MAX_UNCONNECTING_HEADERS MAX_NUM_UNCONNECTING_HEADERS_MSGS

-END VERIFY SCRIPT-
2023-03-30 14:56:34 +02:00
dergoegge
279c53d7e4 [net processing] Move m_recently_announced_invs from CNodeState to Peer 2023-03-30 14:56:19 +02:00
dergoegge
938a8e2566 [net processing] Annotate m_recently_announced_invs as guarded by g_msgproc_mutex 2023-03-30 14:56:19 +02:00
dergoegge
8a2cb1f749 [net processing] Move fPreferHeaders from CNodeState to Peer 2023-03-30 14:56:19 +02:00
dergoegge
3605011e79 [net processing] Annotate fPreferHeaders as guarded by g_msgproc_mutex 2023-03-30 14:56:19 +02:00
dergoegge
4b84e502f5 [net processing] Move m_headers_sync_timeout from CNodeState to Peer 2023-03-30 14:56:19 +02:00
dergoegge
689b747fc3 [net processing] Annotate m_headers_sync_timeout as guarded by g_msgproc_mutex 2023-03-30 14:56:19 +02:00
dergoegge
d8c0d1c345 [net processing] Move nUnconnectingHeaders from CNodeState to Peer 2023-03-30 14:56:17 +02:00
dergoegge
5f80d8d1ee [net processing] Annotate nUnconnectingHeaders as guarded by g_msgproc_mutex 2023-03-30 14:55:28 +02:00
dergoegge
1d87137227 [validation] Annotate ChainstateManager::m_best_header as guarded by cs_main 2023-03-30 14:55:28 +02:00
Hennadii Stepanov
ea7ec78087
refactor: Drop no longer used CNetMsgMaker instances 2023-03-30 11:00:44 +01:00
fanquake
8d31d769b7
Merge bitcoin/bitcoin#27344: fuzz: Remove legacy int parse fuzz tests
faf8dc496e fuzz: Remove legacy int parse fuzz tests (MarcoFalke)

Pull request description:

  The fuzz tests checked that the result of the new function was equal to the legacy function. (Side note: The checks were incomplete, as evident by the follow-up fix in commit b5c9bb5cb9).

  Given that they haven't found any issues in years (beside missing the above issue, that they couldn't catch), it seems time to remove them.

  They may come in handy in the rare case that someone would want to modify `LocaleIndependentAtoi()` or `Parse*Int*()`, however that seems unlikely. Also, appropriate checks can be added then.

ACKs for top commit:
  fanquake:
    ACK faf8dc496e
  dergoegge:
    ACK faf8dc496e

Tree-SHA512: 4ec88b9fa8ba49a923b0604016f0f471b3c9b9e0ba6c5c3dc4e20503c6994789921e7221d9ec467a2a37a73f21a70ba51ba3370ed5ad311dee989e218290b29a
2023-03-28 12:03:39 +01:00
fanquake
d254f942a5
Merge bitcoin/bitcoin#27324: net: #27257 follow-ups
cd0c8eeb09 [net] Pass nRecvFloodSize to CNode (dergoegge)
860402ef2e [net] Remove trivial GetConnectionType() getter (dergoegge)
b5a85b365a [net] Delete CNetMessage copy constructor/assignment op (dergoegge)

Pull request description:

  Follow-up PR for #27257

  * Deletes the copy constructor/assignment operator of `CNetMessage`
  * Removes trivial getter for the connection type
  * Avoids passing `nRecvFloodSize` to CNode methods by passing it to `CNode` on creation

ACKs for top commit:
  jnewbery:
    utACK cd0c8eeb09
  theStack:
    ACK cd0c8eeb09

Tree-SHA512: 673a758668617f69fba77e61f0eaa1538da27a4849c82c98742436692baa2d7f001129af3e7a66b160e599d12109dac08137a146f10ff9b9ebdc5c2237311d41
2023-03-28 11:48:02 +01:00
glozow
56484f0fdc
[mempool] find connected mempool entries with GatherClusters(…)
We limit GatherClusters’s result to a maximum of 500 transactions as
clusters can be made arbitrarily large by third parties.

Co-authored-by: Murch <murch@murch.one>
2023-03-27 17:35:12 -04:00
Martin Zumsande
f8abcb3e3b test: Fix intermittent failure in ChainStateManager tests
Before wiping the ChainStateManager, the validationinterface
queue must be drained to avoid accessing deleted memory.
2023-03-27 15:47:32 -04:00
Hennadii Stepanov
ff26406b2b
Merge bitcoin-core/gui#693: Fix segfault when shutdown during wallet open
9a1d73fdff Fix segfault when shutdown during wallet open (John Moffett)

Pull request description:

  Fixes #689

  ## Summary

  If you open a wallet and send a shutdown signal during that process, you'll get a segfault when the wallet finishes opening. That's because the `WalletController` object gets deleted manually in bitcoin.cpp during shutdown, but copies of the pointer (and pointers to child objects) are dangling in various places and are accessed in queued events after the deletion.

  ## Details

  The issue in #689 is caused by the following sequence of events:

  1. Wallet open modal dialog is shown and worker thread does the actual work.
  2. Every 200ms, the main event loop checks to see if a shutdown has been requested, but only if a modal is not being shown.
  3. Request a shutdown while the modal window is shown.
  4. The wallet open process completes, the modal window is dismissed, and various `finish` signals are sent.
  5. During handling of one of the `finish` signals, `qApp->processEvents()` is [called](e9262ea32a/src/qt/sendcoinsdialog.cpp (L603)), which causes the main event loop to detect the shutdown (now that the modal window has been dismissed). The `WalletController` and all the `WalletModel`s are [deleted](65de8eeeca/src/qt/bitcoin.cpp (L394-L401)).
  6. Control returns to the `finish` method, which eventually tries to send a [signal](e9262ea32a/src/qt/sendcoinsdialog.cpp (L167)) from a wallet model, but it's been deleted already (and the signal is sent from a now-[dangling](d8bdee0fc8/src/qt/walletview.cpp (L65)) pointer).

  The simplest fix for that is to change the `qApp->processEvents()` into a `QueuedConnection` call. (The `qApp->processEvents() was a [workaround](https://github.com/bitcoin/bitcoin/pull/593#issuecomment-3050699) to get the GUI to scroll to the last item in a list that just got added, and this is just a safer way of doing that).

  However, once that segfault is fixed, another segfault occurs due to some queued wallet events happening after the wallet controller object is deleted here:

  65de8eeeca/src/qt/bitcoin.cpp (L394-L401)

  Since `m_wallet_controller` is a copy of that pointer in `bitcoingui.cpp`, it's now dangling and `if(null)` checks won't work correctly. For instance, this line:

  65de8eeeca/src/qt/bitcoingui.cpp (L413)

  sets up a `QueuedConnection` to `setCurrentWallet`, but by the time control reaches that method (one event cycle after shutdown deleted `m_wallet_controller` in `bitcoin.cpp`), the underlying objects have been destroyed (but the pointers are still dangling).

  Ideally, we'd use a `QPointer` or `std::shared_ptr / std::weak_ptr`s for these, but the changes would be more involved.

  This is a minimal fix for the issues. Just set `m_wallet_controller` to `nullptr` in `bitcoingui.cpp`, check its value in a couple places, and avoid a use of `qApp->processEvents`.

ACKs for top commit:
  hebasto:
    ACK 9a1d73fdff, I have reviewed the code and it looks OK.
  furszy:
    ACK 9a1d73fdff

Tree-SHA512: a1b94676eb2fcb7606e68fab443b1565b4122aab93c35382b561842a049f4b43fecc459535370d67a64d6ebc4bcec0ebcda981fff633ebd41bdba6f7093ea540
2023-03-27 15:53:42 +01:00
MarcoFalke
faf8dc496e
fuzz: Remove legacy int parse fuzz tests 2023-03-27 16:37:31 +02:00
dergoegge
cd0c8eeb09 [net] Pass nRecvFloodSize to CNode 2023-03-27 16:00:02 +02:00
dergoegge
860402ef2e [net] Remove trivial GetConnectionType() getter 2023-03-27 16:00:02 +02:00
dergoegge
b5a85b365a [net] Delete CNetMessage copy constructor/assignment op 2023-03-27 16:00:01 +02:00
fanquake
3963067555
Merge bitcoin/bitcoin#26642: clang-tidy: Add more performance-* checks and related fixes
03ec5b6f9c clang-tidy: Exclude `performance-*` checks rather including them (Hennadii Stepanov)
2400437230 clang-tidy: Add `performance-type-promotion-in-math-fn` check (Hennadii Stepanov)
7e975e6cf8 clang-tidy: Add `performance-inefficient-vector-operation` check (Hennadii Stepanov)
516b75f66e clang-tidy: Add `performance-faster-string-find` check (Hennadii Stepanov)

Pull request description:

ACKs for top commit:
  martinus:
    ACK 03ec5b6f9c
  TheCharlatan:
    re-ACK [03ec5b6](03ec5b6f9c)

Tree-SHA512: 2dfa52f9131da88826f32583bfd534a56a998477db9804b7333c0e7ac0b6b36141009755c7163b9f95d0ecbf5c2cb63f8a69ce4b114bb83423faed21b50cec67
2023-03-27 14:34:52 +01:00
Hennadii Stepanov
03ec5b6f9c
clang-tidy: Exclude performance-* checks rather including them 2023-03-26 20:18:13 +01:00
Hennadii Stepanov
2400437230
clang-tidy: Add performance-type-promotion-in-math-fn check
https://clang.llvm.org/extra/clang-tidy/checks/performance/type-promotion-in-math-fn.html
2023-03-26 20:18:03 +01:00
Hennadii Stepanov
7e975e6cf8
clang-tidy: Add performance-inefficient-vector-operation check
https://clang.llvm.org/extra/clang-tidy/checks/performance/inefficient-vector-operation.html
2023-03-26 20:17:55 +01:00
Hennadii Stepanov
516b75f66e
clang-tidy: Add performance-faster-string-find check
https://clang.llvm.org/extra/clang-tidy/checks/performance/faster-string-find.html
2023-03-26 20:17:46 +01:00
Andrew Chow
630756cac0
Merge bitcoin/bitcoin#26957: bench: update logging benchmarks
8c47d599b8 doc: improve -debuglogfile help to be a bit clearer (jonatack)
20d89d6802 bench: document expected results in logging benchmarks (jonatack)
d8deba8c36 bench: add LogPrintfCategory and LogPrintLevel benchmarks (Jon Atack)
102b203349 bench: order the logging benchmark code by output (Jon Atack)
4b3fdbf6fe bench: update logging benchmark naming for clarity (Jon Atack)
4684aa8733 bench: allow logging benchmarks to be order-independent (Larry Ruane)

Pull request description:

  Update our logging benchmarks for evaluating ongoing work like #25203 and refactoring proposals like #26619 and #26697.

  - make the logging benchmarks order-independent (Larry Ruane)
  - add missing benchmarks for the `LogPrintLevel` and `LogPrintfCategory` macros that our logging is migrating to; at some later point it should be feasible to drop some of the previous logging benchmarks
  - update the logging benchmark naming to be clear which benchmark corresponds to which log macro, and update the ordering to be the same as the output
  - add clarifying documentation to the logging benchmarks
  - improve the `-debuglogfile` config option help to be clearer; can be tested by running `./src/bitcoind -help | grep -A4 '\-debuglogfile'`

  Reviewers can run the logging benchmarks with:
  ```bash
  ./src/bench/bench_bitcoin -filter='LogP*.*'
  ```

ACKs for top commit:
  LarryRuane:
    ACK 8c47d599b8
  martinus:
    code review & tested ACK 8c47d599b8, here are my benchmark results:
  achow101:
    ACK 8c47d599b8

Tree-SHA512: 705f8720c9ceaf14a1945039c7578a0c17a12215cbc44908099af4ac444561c3f95d833c5a91b325cdd4470737d8a01e2da64db2d542dd7c9a3747fbfdbf213e
2023-03-23 17:03:39 -04:00
John Moffett
73f4eb511c Check that the Timestamp String is valid
The current `FormatISO8601DateTime` function will
return an empty string if it encounters an error
when converting the `int64_t` seconds since epoch
to a formatted date time. In the unlikely case that happens,
`strStamped.pop_back()` would be undefined behavior.
2023-03-23 16:00:34 -04:00
Martin Leitner-Ankerl
9f947fc3d4 Use PoolAllocator for CCoinsMap
In my benchmarks, using this pool allocator for CCoinsMap gives about
20% faster `-reindex-chainstate` with -dbcache=5000 with practically the
same memory usage. The change in max RSS changed was 0.3%.

The `validation_flush_tests` tests need to be updated because
memory allocation is now done in large pools instead of one node at a
time, so the limits need to be updated accordingly.
2023-03-23 19:38:38 +01:00
Martin Leitner-Ankerl
5e4ac5abf5 Call ReallocateCache() on each Flush()
This frees up all associated memory with the map, not only the nodes.
This is necessary in preparation for using the PoolAllocator for
CCoinsMap, which does not actually free any memory on clear().
2023-03-23 19:38:38 +01:00
Martin Leitner-Ankerl
1afca6b663 Add PoolResource fuzzer
Fuzzes PoolResource with random allocations/deallocations, and multiple
asserts.

Co-Authored-By: Pieter Wuille <pieter@wuille.net>
2023-03-23 19:38:38 +01:00
Martin Leitner-Ankerl
e19943f049 Calculate memory usage correctly for unordered_maps that use PoolAllocator
Extracts the resource from a PoolAllocator and uses it for
calculation of the node's memory usage.
2023-03-23 19:38:38 +01:00
Martin Leitner-Ankerl
b8401c3281 Add pool based memory resource & allocator
A memory resource similar to std::pmr::unsynchronized_pool_resource, but
optimized for node-based containers.

Co-Authored-By: Pieter Wuille <pieter@wuille.net>
2023-03-23 19:38:38 +01:00
stickies-v
cfbc8a623b
refactor: rpc: hide and rename ParseNonRFCJSONValue()
As per https://github.com/bitcoin/bitcoin/pull/26506#pullrequestreview-1211984059,
this function is no longer necessary and we can use UniValue::read() directly.

To avoid code duplication, we keep the function to throw on invalid input data
but rename it to Parse() and remove it from the header.
2023-03-23 18:18:46 +00:00
stickies-v
6c8bde6d54
test: move coverage on ParseNonRFCJSONValue() to UniValue::read()
Preparation to deprecate ParseNonRFCJSONValue() but keep test coverage
on the underlying UniValue::read() unaffected. The test coverage on
AmountFromValue is no longer included, since that is already tested
in the rpc_parse_monetary_values test case.

Fuzzing coverage on ParseNonRFCJSONValue() was duplicated between string.cpp
and parse_univalue.cpp, only the one in parse_univalue.cpp is kept.
2023-03-23 18:18:46 +00:00
fanquake
2305643646
Merge bitcoin/bitcoin#27257: refactor, net: End friendship of CNode, CConnman and ConnmanTestMsg
3566aa7d49 [net] Remove CNode friends (dergoegge)
3eac5e7cd1 [net] Add CNode helper for send byte accounting (dergoegge)
60441a3432 scripted-diff: [net] Rename CNode process queue members (dergoegge)
6693c499f7 [net] Make cs_vProcessMsg a non-recursive mutex (dergoegge)
23d9352654 [net] Make CNode msg process queue members private (dergoegge)
897e342d6e [net] Encapsulate CNode message polling (dergoegge)
cc5cdf8776 [net] Deduplicate marking received message for processing (dergoegge)
ad44aa5c64 [net] Add connection type getter to CNode (dergoegge)

Pull request description:

  We should define clear interfaces between CNode, CConnman and PeerManager. This PR makes a small step in that direction by ending the friendship of CNode, CConnman and ConnmanTestMsg. CNode's message processing queue is made private in the process and its mutex is turned into a non-recursive mutex.

ACKs for top commit:
  jnewbery:
    utACK 3566aa7d49
  vasild:
    ACK 3566aa7d49
  theStack:
    re-ACK 3566aa7d49
  brunoerg:
    re-ACK 3566aa7d49

Tree-SHA512: 26b87da5054e32401b693b2904e9c5f40e35a53937c0b6cf44b8597034ad07bacf27d87cdffc54d3e7ccfebde4231ef30a38d326f88cc18133bbb34688ead567
2023-03-23 17:31:52 +00:00
glozow
381593c906
Merge bitcoin/bitcoin#24845: wallet: return error msg for "too-long-mempool-chain"
f3221d373a test: add wallet too-long-mempool-chain error coverage (furszy)
acf0119d24 wallet: return error msg for too-long-mempool-chain failure (furszy)

Pull request description:

  Fixes #23144.

  We currently return a general "Insufficient funds" from Coin
  Selection when we actually skipped unconfirmed UTXOs that
  surpassed the mempool ancestors limit.

  This PR make the error clearer by returning:
  "Unconfirmed UTXOs are available, but spending them creates
  a chain of transactions that will be rejected by the mempool"

  Also, added an early return from Coin Selection if the sum of
  the discarded coins decreases the available balance below the
  target amount.

ACKs for top commit:
  achow101:
    ACK f3221d373a
  S3RK:
    Code review ACK f3221d373a
  Xekyo:
    ACK f3221d373a

Tree-SHA512: 13e5824b75ac302280ff894560a4ebf32a74f32fe49ef8281f2bc99c0104b92cef33d3b143c6e131f3a07eafe64533af7fc60abff585142c134b9d6e531a6a66
2023-03-23 15:53:56 +00:00
fanquake
8acfb1f8e0
Merge bitcoin/bitcoin#18933: rpc: Add submit option to generateblock
fa18504d57 rpc: Add submit option to generateblock (MarcoFalke)
fab9a08e14 refactor: Replace block_hash with block_out (MarcoFalke)

Pull request description:

  When submit is turned off, a block can be generated and returned as hex, to be used for further tests. For example, it can be submitted on a different node, on a different interface (like p2p), or just never submitted and be used for other testing purposes.

ACKs for top commit:
  instagibbs:
    ACK fa18504d57
  TheCharlatan:
    tACK fa18504d57

Tree-SHA512: 1b2ab6b71bb7e155c6482d75f5373f4e77de6446cb16bc2dfd19e7a4075b3a6ad87d7ad7a049a9eed934cb71574acfd27202f54c8bb3b03fac869f2e95db7ee5
2023-03-23 13:40:30 +00:00
TheCharlatan
00e9b97f37
refactor: Move fs.* to util/fs.*
The fs.* files are already part of the libbitcoin_util library. With the
introduction of the fs_helpers.* it makes sense to move fs.* into the
util/ directory as well.
2023-03-23 12:55:18 +01:00
TheCharlatan
106b46d9d2
Add missing fs.h includes
The inclusion of this header should not depend on the inclusion of other
headers that include fs.h themselves.
2023-03-23 12:54:27 +01:00