Commit graph

35662 commits

Author SHA1 Message Date
Anthony Towns
d575a675cc net_processing: add thread safety annotation for m_highest_fast_announce 2022-09-15 20:28:55 +10:00
Anthony Towns
0ae7987f68 net_processing: add thread safety annotations for PeerManagerImpl members accessed only via the msgproc thread 2022-09-15 20:28:55 +10:00
Anthony Towns
a66a7ccb82 net_processing: add thread safety annotations for Peer members accessed only via the msgproc thread 2022-09-15 20:28:55 +10:00
kouloumos
cc434cbf58 wallet: fix sendall creates tx that fails tx-size check
The `sendall` RPC doesn't use `CreateTransactionInternal`as the rest of
the wallet RPCs and it never checks against the tx-size mempool limit.
Add a check for tx-size as well as test coverage for that case.
2022-09-15 13:22:19 +03:00
fanquake
ff7c81f63a
build: remove duplicate / unneeded libs from bench_bitcoin
EVENT_*_LIBS are already in LDADD.
Move wallet libs into the wallet conditional, similar to zmq.
2022-09-15 10:29:12 +01:00
fanquake
4b656b9ed3
build: remove unused libevent cppflags 2022-09-15 09:30:26 +01:00
fanquake
afce044bb6
build: remove unused natpmp / upnp cppflags
Their inclusion is likely just the result of copy-paste.

The only place upnp/natpmpflags  should be used is `libbitcoin_node`
(mapport.cpp).
2022-09-15 09:30:26 +01:00
MacroFake
fa1ce96184
test: Add missing syncwithvalidationinterfacequeue 2022-09-15 09:06:13 +02:00
MacroFake
718304d222
Merge bitcoin/bitcoin#26084: sendall: check if the maxtxfee has been exceeded
6f8e3818af sendall: check if the maxtxfee has been exceeded (ishaanam)

Pull request description:

  Previously the `sendall` RPC didn't check whether the fees of the transaction it creates exceed the set `maxtxfee`. This PR adds this check to `sendall` and a test case for it.

ACKs for top commit:
  achow101:
    ACK 6f8e3818af
  Xekyo:
    ACK 6f8e3818af
  glozow:
    Concept ACK 6f8e3818af. The high feerate is unlikely but sendall should respect the existing wallet options.

Tree-SHA512: 6ef0961937091293d49be16f17e4451cff3159d901c0c7c6e508883999dfe0c20ed4d7126bf74bfea8150d4c1eef961a45f0c28ef64562e6cb817fede2319f1a
2022-09-15 08:45:08 +02:00
Anthony Towns
bf12abe454 net: drop cs_sendProcessing
SendMessages() is now protected g_msgproc_mutex; so this additional
per-node mutex is redundant.
2022-09-15 14:44:42 +10:00
Anthony Towns
1e78f566d5 net: add NetEventsInterface::g_msgproc_mutex
There are many cases where we assume message processing is
single-threaded in order for how we access node-related memory to be
safe. Add an explicit mutex that we can use to document this, which allows
the compiler to catch any cases where we try to access that memory from
other threads and break that assumption.
2022-09-15 14:44:38 +10:00
Andrew Chow
2e3cd26a1a
Merge bitcoin/bitcoin#26053: rpc: bugfix, 'add_inputs' default value is true unless 'inputs' are provided
b00fc44ca5 test: add coverage for 'add_inputs' dynamic default value (furszy)
ddbcfdf3d0 RPC: bugfix, 'add_inputs' default value is true unless 'inputs' are provided (furszy)

Pull request description:

  This bugfix was meant to be in #25685, but decoupled it to try to make it part of 24.0 release.
  It's a truly misleading functionality.

  This PR doesn't change behavior in any way. Just fixes two invalid RPC help messages and adds test
  coverage for the current behavior.

  #### Description
  In both RPC commands `send()` and `walletcreatefundedpsbt` the help message says
  that `add_inputs` default value is false when it's actually dynamically set by the following statement:

  ```c++
  coin_control.m_allow_other_inputs = rawTx.vin.size() == 0;
  ```

  Which means that, by default, `add_inputs` is true unless there is any pre-set input, in which
  case, the default is false.

ACKs for top commit:
  achow101:
    ACK b00fc44ca5
  S3RK:
    ACK b00fc44ca5

Tree-SHA512: 5c68a40d81c994e0ab6de0817db69c4d3dea3a9a64a60362531bf583b7a4c37d524b740905a3f3a89cdbf221913ff5b504746625adb8622788aea93a35bbcd40
2022-09-14 16:15:03 -04:00
Hennadii Stepanov
d190003700
Merge bitcoin-core/gui#669: Update translation source file for string freeze (round 2)
6725030e41 qt: Update translation source file for string freeze (round 2) (Hennadii Stepanov)

Pull request description:

  On the day of [translation string freeze](https://github.com/bitcoin/bitcoin/issues/24987#issuecomment-1234026641), it happened that bitcoin-core/gui#660 did not include new strings from bitcoin/bitcoin#19602.

  This PR includes all recent updates.

  As a Transifex translator, I believe it is enough time for all translators to handle a few new strings by a release date. Also a Transifex check failure has been [fixed](bitcoin-core/gui/pull/664).

ACKs for top commit:
  jarolrod:
    ACK 6725030e41

Tree-SHA512: d57b841e87e389d31ec4ae9067b83f7f209e168399bc088c3234c2c66b34772739cb801f04b5038d55de115083d022d603bc976374bfd537b8ea10c10a545183
2022-09-14 20:00:29 +01:00
furszy
b00fc44ca5
test: add coverage for 'add_inputs' dynamic default value
Covered cases for send() and walletcreatefundedpsbt() RPC commands:

1. Default add_inputs value with no preset inputs (add_inputs=true):
       Expect: automatically add coins from the wallet to the tx.

2. Default add_inputs value with preset inputs (add_inputs=false):
       Expect: disallow automatic coin selection.

3. Explicit add_inputs=true and preset inputs (with preset inputs not-covering the target amount).
       Expect: include inputs from the wallet.

4. Explicit add_inputs=true and preset inputs (with preset inputs covering the target amount).
       Expect: only preset inputs are used.

5. Explicit add_inputs=true, no preset inputs (same as (1) but with an explicit set):
       Expect: include inputs from the wallet.
2022-09-14 11:13:45 -03:00
Hennadii Stepanov
6725030e41
qt: Update translation source file for string freeze (round 2) 2022-09-14 15:03:07 +01:00
Hennadii Stepanov
f523df1ee8
Merge bitcoin-core/gui#664: Prevent wrong handling of %2 token by Transifex
8ed2b72767 qt: Prevent wrong handling of `%2` token by Transifex (Hennadii Stepanov)

Pull request description:

  On master (124e75a41e), Transifex translation check fails for 124e75a41e/src/qt/forms/intro.ui (L206) with a message:
  > The expression '%2G' is not present in the translation.

  In "Organization Settings" --> ["Translation checks"](https://www.transifex.com/bitcoin/settings/validations/) I have changed the status of the "**Variable substitution specifiers (like "%s") are preserved in the translations.**" check from "error" to "warning" temporarily. This setting should be reverted after applying this PR change.

  [Noted](https://www.transifex.com/bitcoin/bitcoin/translate/#ru/qt-translation-024x/436102928/) by Transifex user [AHOHNMYC](https://www.transifex.com/user/profile/AHOHNMYC/).

  I faced the same issue while working on Ukrainian translation.

ACKs for top commit:
  katesalazar:
    ACK 8ed2b72767
  jarolrod:
    ACK 8ed2b72767

Tree-SHA512: 304f795ac9241ac8453c614ed18d967226d9d515f9ea079b51af5bcbe2f0760ca7dcaea5efb38207720cb7a18159c2bcd337b961bc522a128715c70e0db81061
2022-09-14 14:58:59 +01:00
Hennadii Stepanov
bc29c4d4a5
Merge bitcoin-core/gui#663: Cleanup translation comment
5f28fc8160 qt: Cleanup translation comment (Hennadii Stepanov)

Pull request description:

  An unneeded character slipped in bitcoin-core/gui#629.

ACKs for top commit:
  jarolrod:
    ACK 5f28fc8160
  jonatack:
    utACK 5f28fc8160

Tree-SHA512: 210fb626e8035786cf6859160c60b2815c813e02908c75efc71a2c64d511edd6f81b2f67f1c98b29122b990260ebf663da445ea2d01b6268e3e046ada1ca5b6e
2022-09-14 14:56:26 +01:00
fanquake
c67d6f5b5f
Merge bitcoin/bitcoin#26079: Revert "doc: note that brew installed qt is not supported"
34a2f91055 Revert "doc: note that brew installed qt is not supported" (Hennadii Stepanov)

Pull request description:

  As bitcoin/bitcoin#26056 fixes bitcoin/bitcoin#25947 it looks reasonable to revert bitcoin/bitcoin#21988.

ACKs for top commit:
  fanquake:
    ACK 34a2f91055 - haven't tested at all.
  jarolrod:
    ACK 34a2f91055

Tree-SHA512: 4470f21fb6ea32970d7572c83ba064bcbe6e3282cea79122312f8ac203a5b1617b21952db1d6e47ba5b6f605abc23f72c04c07cef7251272e22fb593ff317beb
2022-09-14 14:51:00 +01:00
Hennadii Stepanov
34a2f91055
Revert "doc: note that brew installed qt is not supported"
This reverts commit 33b0b26a03.
2022-09-14 13:51:17 +01:00
MacroFake
faa4916529
test/doc: Remove unused syncwithvalidationinterfacequeue
See https://github.com/bitcoin/bitcoin/pull/25768#discussion_r958562071

Also fix doc typo from https://github.com/bitcoin/bitcoin/pull/25768#discussion_r958571943
2022-09-14 14:34:53 +02:00
Vasil Dimov
9d7ae4b66c
sync: remove unused template parameter from ::UniqueLock
The template parameter `typename Base = typename Mutex::UniqueLock` is
not used, so remove it. Use internally defined type `Base` to avoid
repetitions of `Mutex::UniqueLock`.
2022-09-14 14:17:09 +02:00
Vasil Dimov
11c190e3f1
sync: simplify MaybeCheckNotHeld() definitions by using a template
Reduce 4 of the `MaybeCheckNotHeld()` definitions to 2 by using a
template. This also makes the function usable for other
[BasicLockable](https://en.cppreference.com/w/cpp/named_req/BasicLockable)
types.
2022-09-14 14:17:01 +02:00
MacroFake
a8c3590890
Merge bitcoin/bitcoin#25831: refactor: Remove trailing semicolon from LOCK2 macro
0f0cc05e4c refactor: Remove trailing semicolon from LOCK2 (Aurèle Oulès)

Pull request description:

  Macros should not have a trailing semi-colon to avoid empty statements when using them with another semi-colon.
  Noticed this while reviewing a PR.

ACKs for top commit:
  vasild:
    ACK 0f0cc05e4c

Tree-SHA512: 97fa4d89f5131ac30e05b293f750b757d5526feed56885c6feeb403b3ac3d3d3205874bc507c3b56a8296a6e3bdc8d879b2c339784f1e6ab1963d1b8a8d7b02f
2022-09-14 13:06:25 +02:00
Cory Fields
02c9e56468
fs: fully initialize _OVERLAPPED for win32 2022-09-14 11:55:10 +01:00
stickies-v
26cf9ea8e4
scripted-diff: rename pszThread to thread_name
Since it is now a string_view instead of a const char*, update the
name to reflect that the variable is no longer a "Pointer to
String, Zero-terminated" (psz).

-BEGIN VERIFY SCRIPT-
sed -i s/pszThread/thread_name/ $(git grep -l pszThread src)
-END VERIFY SCRIPT-
2022-09-14 11:00:14 +01:00
fanquake
a10df7cf35
build: prune BOOST_CPPFLAGS from libbitcoin_zmq
Rather than including validation.h, which ultimately means needing boost
via txmempool.h, include primitives/block.h for CBlock, and remove
validation.h, as we can get cs_main from node/blockstorage.h.
2022-09-14 09:33:34 +01:00
fanquake
f839697d9b
build: remove BOOST_CPPFLAGS usage from bitcoin-tx
The only reason BOOST_CPPFLAGS is needed here, is because of the
policy/rbf.h include, which ultimately includes boost multi_index
via txmempool.h. However this include is actually unused.
2022-09-14 09:10:04 +01:00
fanquake
13fd9ee5c2
Merge bitcoin/bitcoin#26056: build: extract $(BOOST_CPPFLAGS) from $(BITCOIN_INCLUDES)
12de8f6262 build: extract $(BOOST_CPPFLAGS) from $(BITCOIN_INCLUDES) (fanquake)

Pull request description:

  This leaves `$(BITCOIN_INCLUDES)` as internal dependencies, and gives finer control over Boost includes.

  Fixes #25947.

ACKs for top commit:
  theuni:
    ACK 12de8f6262
  hebasto:
    ACK 12de8f6262, tested on macOS Monterey 12.6 (21G115, Intel).
  jarolrod:
    ACK 12de8f6262

Tree-SHA512: 550897c8168c82d6b79f51d5b9bbfa46ecc5e6deb514732762d0cf894de58787fda0ddf259675b4d224d7bd1a2bdcf2102d3c84f8b6ed73fc4b2357ab5687131
2022-09-14 08:59:56 +01:00
ishaanam
6f8e3818af sendall: check if the maxtxfee has been exceeded 2022-09-13 18:12:42 -04:00
furszy
ddbcfdf3d0
RPC: bugfix, 'add_inputs' default value is true unless 'inputs' are provided
In both RPC commands `send()` and `walletcreatefundedpsbt` the RPC help was saying
that `add_inputs` default value was false when it's actually dynamically set
by the following statement:

`coin_control.m_allow_other_inputs = rawTx.vin.size() == 0;`

Which means that, by default, `add_inputs` is true unless there
was any pre-set input, in which case, the default is false.
2022-09-13 16:13:05 -03:00
stickies-v
200d84d568
refactor: use std::string for index names 2022-09-13 19:10:41 +01:00
stickies-v
97f5b20c12
refactor: use std::string for thread names 2022-09-13 19:07:39 +01:00
James O'Beirne
bf95976061 doc: add note about snapshot chainstate init 2022-09-13 13:31:37 -04:00
James O'Beirne
e4d7995286 test: add testcases for snapshot initialization 2022-09-13 13:31:23 -04:00
James O'Beirne
cced4e7336 test: move-only-ish: factor out LoadVerifyActivateChainstate()
in TestingSetup(). This is used in the following commit to test
reinitializing chainstates after snapshot validation and cleanup.

Best reviewed with `git diff --color-moved=dimmed-zebra`.
2022-09-13 13:31:23 -04:00
James O'Beirne
51fc9241c0 test: allow on-disk coins and block tree dbs in tests
Used when testing cleanup of on-disk chainstate data for snapshot
testcases. Also necessary for simulating node restart in .cpp tests.
2022-09-13 13:31:23 -04:00
James O'Beirne
3c361391b8 test: add reset_chainstate parameter for snapshot unittests
This CreateAndActivateUTXOSnapshot parameter is necessary once we
perform snapshot completion within ABC, since the existing UpdateTip
test will fail because the IBD chain that has generated the snapshot
will exceed the base of the snapshot.

Being able to test snapshots being loaded into a mostly-uninitialized
datadir allows for more realistic unittest scenarios.
2022-09-13 13:31:21 -04:00
James O'Beirne
00b357c215 validation: add ResetChainstates()
Necessary for the following test commit.
2022-09-13 13:30:28 -04:00
James O'Beirne
3a29dfbfb2 move-only: test: make snapshot chainstate setup reusable
For use in next commit.

Most easily reviewed with
`--color-moved=dimmed_zebra --color-moved-ws=allow-indentation-change`.
2022-09-13 13:30:25 -04:00
James O'Beirne
8153bd9247 blockmanager: avoid undefined behavior during FlushBlockFile
If we call FlushBlockFile() without having intitialized the block index
with LoadBlockIndexDB(), we may be indexing into an empty vector.

Specifically this is an issue when we call MaybeRebalanceCaches() during
chainstate init before the block index has been loaded, which calls
FlushBlockFile().

Also add an assert to avoid undefined behavior.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
2022-09-13 13:30:25 -04:00
James O'Beirne
ad67ff377c validation: remove snapshot datadirs upon validation failure
If a UTXO snapshot fails to validate, don't leave the resulting datadir
on disk as this will confuse initialization on next startup and we'll
get an assertion error.
2022-09-13 13:30:25 -04:00
James O'Beirne
34d1590331 add utilities for deleting on-disk leveldb data
Used in later commits to remove leveldb directories for
- invalid snapshot chainstates, and
- background-vaildation chainstates that have finished serving their
  purpose.
2022-09-13 13:30:25 -04:00
James O'Beirne
252abd1e8b init: add utxo snapshot detection
Add functionality for activating a snapshot-based chainstate if one is
detected on-disk.

Also cautiously initialize chainstate cache usages so that we don't
somehow blow past our cache allowances during initialization, then
rebalance at the end of init.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
2022-09-13 13:30:14 -04:00
James O'Beirne
f9f1735f13 validation: rename snapshot chainstate dir
This changes the snapshot's leveldb chainstate dir name from
`chainstate_[blockhash]` to `chainstate_snapshot`. This simplifies
later logic that loads snapshot data, and enforces the limitation
of a single snapshot at any given time.

Since we still need to persis the blockhash of the base block, we
write that out to a file (`chainstate_snapshot/base_blockhash`) for
later use during initialization, so that we can reinitialize the
snapshot chainstate.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
2022-09-13 13:30:12 -04:00
James O'Beirne
d14bebf100 db: add StoragePath to CDBWrapper/CCoinsViewDB
This is used in subsequent commits. It allows us to clean up UTXO
snapshot chainstate after background validation completes.
2022-09-13 12:38:06 -04:00
MacroFake
fa2c72dda0
rpc: Set RPCArg options with designated initializers 2022-09-13 18:37:15 +02:00
fanquake
12de8f6262
build: extract $(BOOST_CPPFLAGS) from $(BITCOIN_INCLUDES)
This leaves $(BITCOIN_INCLUDES) as internal dependencies, and gives
finer control over Boost includes.
2022-09-13 17:15:17 +01:00
fanquake
29d540b7ad
Merge bitcoin/bitcoin#26070: build: Quiet warnings in symlinked headers installed from homebrew
b50a4b7647 build: quiet warnings in system headers installed from homebrew (Cory Fields)

Pull request description:

  From the included comment:

  Homebrew may create symlinks in `/usr/local/include` for some packages. Because MacOS's clang internally adds `-I /usr/local/include` to its search paths, this will negate efforts to use `-isystem` for those packages, as they will be found first in `/usr/local`. Use the internal `-internal-isystem` option to system-ify all `/usr/local/include` paths without adding it to the list of search paths in case it's not already there.

  This fixes the issue explained here: https://github.com/bitcoin/bitcoin/pull/26056#issuecomment-1243362059

  ~Also temporarily includes #26056 as a test. I will remove that commit if/when c-i is happy, and fanquake can rebase it post-merge.~
  I've removed this commit now that c-i succeeded with it.

ACKs for top commit:
  hebasto:
    ACK b50a4b7647, tested as a part of bitcoin/bitcoin#26056 on macOS Monterey 12.6 (21G115, both Intel and Apple M1) + Apple clang 14.0.0:

Tree-SHA512: 163aa359d27c31d52b444252762e32dd8a11acc043cf1a2aa953f902d1dab77ece52e2dfedcce637e6a1dda47e4c566bfeb8d3b092f82bfc73923843b7bc619c
2022-09-13 17:14:53 +01:00
Andrew Chow
c85688347e
Merge bitcoin/bitcoin#26021: wallet: bugfix, load a wallet with an unknown/corrupt descriptor causes a fatal error
e06676377d wallet: coverage for loading an unknown descriptor (furszy)
d26c3cc444 wallet: bugfix, load wallet with an unknown descriptor cause fatal error (furszy)

Pull request description:

  Fixes #26015

  If the descriptor entry is unrecognized (due a soft downgrade) or corrupt, the
  unserialization fails and `LoadWallet`, instead of stop there and return the error,
  continues reading all the db records. As other records tied to the unrecognized
  or corrupt descriptor are scanned, a fatal error is being thrown.

  This fixes it by catching the descriptor parse failure and return which wallet failed.
  Logging its name/path, so the user can remove it from the settings file, to prevent
  its load at startup.

  Note: added the test in a separate file intentionally.
  Will continue adding coverage for the wallet load process in follow-up PRs.

ACKs for top commit:
  achow101:
    ACK e06676377d
  Sjors:
    re-utACK e06676377d

Tree-SHA512: d1f1a5d7e944c89c97a33b25b4411a36a11edae172c22f8524f69c84a035f84c570b284679f901fe60f1300f781b76a6c17b015a8e7ad44ebd25a0c295ef260f
2022-09-13 11:51:51 -04:00
glozow
3a7e0a210c
Merge bitcoin/bitcoin#24513: CChainState -> Chainstate
00eeb31c76 scripted-diff: rename CChainState -> Chainstate (James O'Beirne)

Pull request description:

  Alright alright alright, I know: we hate refactors. We especially hate cosmetic refactors.

  Nobody knows better than I that changing broad swaths of code out from under our already-abused collaborators, only to send a cascade of rebase bankruptcies, is annoying at best and sadistic at worst. And for a rename! The indignation!

  But just for a second, imagine yourself. Programming `bitcoin/bitcoin`, on a sandy beach beneath a lapis lazuli sky. You go to type the name of what is probably the most commonly used data structure in the codebase, and you *only hit shift once*.

  What could you do in such a world? You could do anything. [The only limit is yourself.](https://zombo.com/)

  ---

  So maybe you like the idea of this patch but really don't want to deal with rebasing. You're in luck!

  Here're the commands that will bail you out of rebase bankruptcy:

  ```sh
  git rebase -i $(git merge-base HEAD master) \
    -x 'sed -i "s/CChainState/Chainstate/g" $(git ls-files | grep -E ".*\.(py|cpp|h)$") && git commit --amend --no-edit'
  # <commit changed?>
  git add -u && git rebase --continue
  ```

  ---

  ~~Anyway I'm not sure how serious I am about this, but I figured it was worth proposing.~~ I have decided I am very serious about this.

  Maybe we can have nice things every once in a while?

ACKs for top commit:
  MarcoFalke:
    cr ACK 00eeb31c76
  hebasto:
    ACK 00eeb31c76
  glozow:
    ACK 00eeb31c76, thanks for being the one to propose this
  w0xlt:
    ACK 00eeb31c76

Tree-SHA512: b828a99780614a9b74f7a9c347ce0687de6f8d75232840f5ffc26e02bbb25a3b1f5f9deabbe44f82ada01459586ee8452a3ee2da05d1b3c48558c8df6f49e1b1
2022-09-13 15:42:18 +01:00