Commit graph

34016 commits

Author SHA1 Message Date
laanwj
90e49c1ece
Merge bitcoin/bitcoin#24464: logging: Add severity level to logs
e11cdc9303  logging: Add log severity level to net.cpp (klementtan)
a8290649a6 logging: Add severity level to logs. (klementtan)

Pull request description:

  **Overview**: This PR introduces a new macro, `LogPrintLevel`, that allows developers to add logs with the severity level. Additionally, it will also print the log category if it is specified.

  Sample log:
  ```
  2022-03-04T16:41:15Z [opencon] [net:debug] trying connection XX.XX.XXX.XXX:YYYYY lastseen=2.7hrs
  ```

  **Motivation**: This feature was suggested in #20576 and I believe that it will bring the following benefits:
  * Allow for easier filtering of logs in `debug.log`
  * Can be extended to allow users to select the minimum level of logs they would like to view (not in the scope of this PR)

  **Details**:
  * New log format. `... [category:level]...`. ie:
    * Do not print category if `category == NONE`
    * Do not print level if `level == NONE`
    * If `category == NONE` and `level == NONE`, do not print any fields (current behaviour)
  * Previous logging functions:
    * `LogPrintf`:  no changes in log as it calls `LogPrintf_` with `category = NONE` and `level = NONE`
    * `LogPrint`: prints additional `[category]` field as it calls `LogPrintf_` with `category = category` and `level = NONE`
  * `net.cpp`: As a proof of concept, updated logs with obvious severity (ie prefixed with `Warning/Error:..`) to use the new logging with severity.

  **Testing**:
  * Compiling and running `bitcoind` with this PR should instantly display logs with the category name (ie `net/tor/...`)
  * Grepping for `net:debug` in `debug.log` should display the updated logs with severity level:
    <details>
    <summary>Code</summary>

    ```
    $ grep "net:debug" debug.log

    2022-03-04T16:41:15Z [opencon] [net:debug] trying connection XXX:YYY lastseen=2.7hrs
    2022-03-04T16:41:16Z [opencon] [net:debug] trying connection XXX:YYY lastseen=16.9hrs
    2022-03-04T16:41:17Z [opencon] [net:debug] trying connection XXX:YYY lastseen=93.2hrs
    2022-03-04T16:41:18Z [opencon] [net:debug] trying connection XXX:YYY lastseen=2.7hrs
    ```
    </details>

ACKs for top commit:
  laanwj:
    Code review and lightly tested ACK e11cdc9303

Tree-SHA512: 89a8c86667ccc0688e5acfdbd399aac1f5bec9f978a160e40b0210b0d9b8fdc338479583fc5bd2e2bc785821363f174f578d52136d228e8f638a20abbf0a568f
2022-05-24 19:32:45 +02:00
laanwj
7008087548
Merge bitcoin/bitcoin#24410: [kernel 2a/n] Split hashing/index GetUTXOStats codepaths, decouple from coinstatsindex
664a14ba7c coinstats: Move GetUTXOStats to rpc/blockchain (Carl Dong)
f100687566 kernel: Use ComputeUTXOStats in validation (Carl Dong)
faa52387e8 style-only: Rearrange using decls after scripted-diff (Carl Dong)
f329a9298c scripted-diff: Move src/kernel/coinstats to kernel:: (Carl Dong)
0e54456f04 Use only kernel/coinstats.h in index/coinstatsindex.h (Carl Dong)
80970985c9 coinstats: Split node/coinstats.h to kernel/coinstats.h (Carl Dong)
35f73ce4b2 coinstats: Move hasher codepath to kernel/coinstats (Carl Dong)
b7634fe02b Move logic from LookupUTXOStatsWithIndex to CoinStatsIndex::LookUpStats (Carl Dong)
1352e410a5 coinstats: Separate hasher/index lookup codepaths (Carl Dong)
524463daf6 coinstats: Return purely out-param CCoinsStats (Carl Dong)
46eb9fc56a coinstats: Extract index_requested in-member to in-param (Carl Dong)
a789f3f2b8 coinstats: Extract hash_type in-member to in-param (Carl Dong)
102294898d includes: Remove rpc/util.h -> node/coinstats.h (Carl Dong)
0848db9c35 fuzz: Remove useless GetUTXOStats fuzz case (Carl Dong)
52b1939993 kernel: Remove unnecessary blockfilter{index,}.cpp (Carl Dong)

Pull request description:

  Part of: #24303
  Depends on: #24322

  The `GetUTXOStats` function has 2 codepaths:
    - One which queries the `CoinStatsIndex` for the UTXO hash
    - One which actually performs the hashing

  For `libbitcoinkernel`, the only place where we call `GetUTXOStats` is in `PopulateAndValidateSnapshots`, which uses the `SHA256D` hash, and is therefore unable to use the `CoinStatsIndex` since that only provides `MuHash` hashes. Not that I think indices necessarily belong in `libbitcoinkernel` anyway.

  This PR separates these 2 aforementioned codepaths of `GetUTXOStats`, uses the hashing codepath in `PopulateAndValidateSnapshots`, and removes the need to link in `index/coinstatsindex.cpp` and `node/coinstats.cpp`.

  -----

  Logistically, this PR:
  - Extracts out the `index_requested` and `hash_type` members of `CoinStats`, which served as "in-params" to `GetUTXOStats` embedded within the `CoinStats` struct. This allows `CoinStats` to only consist of "out-param" members, and be returned by `GetUTXOStats` without needing to be an "in-out" param
  - Introduce the purely virtual `UTXOHashers` class, with 3 implementations: `SHA256DHasher`, `MuHashHasher`, and `NullHasher`. These replace the existing template-based polymorphism.
  - Split `GetUTXOStats` into:
      - `CalculateUTXOStatsWithHasher(UTXOHasher&, ...)`, and
      - `LookupUTXOStatsWithIndex(CoinStatsIndex&, ...)`
  - Use `CalculateUTXOStatsWithHasher` directly where appropriate (`src/validation.cpp` and `src/fuzz`)
  - Move `GetUTXOStats` to `rpc/blockchain`, which is the only place that depends on `GetUTXOStats`'s weird fallback behaviour
  - Move `LookupUTXOStatsWithIndex` to `index/coinstatsindex`

  Code organization:
  - `src/`
    - `kernel/` → only contains the hashing codepath
      - `coinstats.cpp` → hashing codepath implementations
      - `coinstats.h` → header for `kernel/coinstats.cpp`
    - `index/` → only contains the index codepath
      - `coinstatsindex.cpp` → index codepath implementations
      - `coinstatsindex.h`
    - `validation.cpp` → only uses the hashing codepath
    - `rpc/blockchain.cpp` → uses both the hashing and index codepath, old `GetUTXOStats` fallback logic moved here as static
    - `test/fuzz/coins_view.cpp` → only uses the hashing codepath

  TODOs:
  - [x] Commit messages could be fleshed out more

  Would love any feedback!

ACKs for top commit:
  laanwj:
    Code review ACK 664a14ba7c

Tree-SHA512: 18722c7bd279174d2d1881fec33ea04a9b261aae1c12e998cf434ef297d8ded47de69c526c8033a2ba7abc93ba3d2ff5faf4ce05e8888c725c31cf885ce3ef73
2022-05-24 14:43:00 +02:00
Hennadii Stepanov
8898906370
Merge bitcoin-core/gui#593: Getting ready to Qt 6 (8/n). Use QRegularExpression in AddressBookSortFilterProxyModel class
e280087946 qt: Use `QRegularExpression` in `AddressBookSortFilterProxyModel` class (Hennadii Stepanov)
5c5d8f2465 qt, test: Add tests for searching in `AddressBookPage` dialog (Hennadii Stepanov)

Pull request description:

  This is a step in [migration](https://github.com/bitcoin/bitcoin/pull/24798) to Qt 6.

  Related:
  - bitcoin-core/gui#578
  - bitcoin-core/gui#585

  No behavior change. To ensure this, tests have been added.

ACKs for top commit:
  hebasto:
    > tACK [e280087](e280087946) on Ubuntu 21.10 Qt 5.15.2
  promag:
    Tested ACK e280087946 with Qt6 on macOS 12 M1.
  w0xlt:
    tACK e280087946 on Ubuntu 21.10 Qt 5.15.2
  jarolrod:
    Tested ACK e280087946 on M1 mac, x86 mac, x86 Linux with Qt5 and separately with Qt6

Tree-SHA512: 664baacc1504deb2f7fa651ea4a44f3942f5c9058befe4d2ce292beed032d4b1697710cfd10c0909602d8a4a6eeb680414e4a1f56d2038478c1ae2f34965d74f
2022-05-24 10:52:18 +02:00
Hennadii Stepanov
1368634433
Merge bitcoin-core/gui#601: refactor: Pass interfaces::Node references to OptionsModel constructor
31122aa979 refactor: Pass interfaces::Node references to OptionsModel constructor (Ryan Ofsky)

Pull request description:

  Giving OptionsModel access to the node interface is needed as part of #602 to get bitcoind and bitcoin-qt to use the same settings instead of different settings.

  It has been split off from #602 to simplify that PR. Previously these commits were part of bitcoin/bitcoin#15936 and also had some review discussion there.

ACKs for top commit:
  promag:
    Code review ACK 31122aa979.
  furszy:
    Code ACK 31122aa9
  jarolrod:
    ACK 31122aa979

Tree-SHA512: b8529322fd7ba97e19864129e6cf5f9acc58c124f2e5a7c50aca15772c8549de3c24e8b0c27e8cf2c06fd26529e9cdb898b0788a1de3cbfdfbdd3f85c9f0fe69
2022-05-24 10:48:27 +02:00
MacroFake
aa5cd3cc6d
Merge bitcoin/bitcoin#25149: refactor: Add thread safety annotation to BanMan::SweepBanned()
ab75388320 refactor: Remove redundant scope in `BanMan::SweepBanned()` (Hennadii Stepanov)
52c0b3e859 refactor: Add thread safety annotation to `BanMan::SweepBanned()` (Hennadii Stepanov)
3919059deb refactor: Move code from ctor into private `BanMan::LoadBanlist()` (Hennadii Stepanov)

Pull request description:

  This PR adds a proper thread safety annotation to `BanMan::SweepBanned()`.

  Also a simple refactoring applied.

ACKs for top commit:
  ajtowns:
    ACK ab75388320
  w0xlt:
    ACK ab75388320
  theStack:
    Code-review ACK ab75388320

Tree-SHA512: 8699079c308454f3ffe72be2e77f0935214156bd509f9338b1104f8d128bfdd02ee06ee8c1c99b2eefdf317a00edd555d52990caaeb1ed4540eedc1e3c9d1faf
2022-05-24 09:14:58 +02:00
Carl Dong
664a14ba7c coinstats: Move GetUTXOStats to rpc/blockchain
rpc/blockchain.cpp is now the only user of the vestigial
GetUTXOStats(...). And since GetUTXOStats(...)'s special fallback logic
was only really relevant/meant for rpc/blockchain.cpp, we can just move
it there.
2022-05-23 15:19:29 -04:00
Carl Dong
f100687566 kernel: Use ComputeUTXOStats in validation
This is the "fruit of our labor" for this patchset.
ChainstateManager::PopulateAndValidateSnapshot can now directly call
ComputeUTXOStats(...).

Our consensus engine is now fully decoupled from all indices.

See the src/Makefile.am for some satisfying removals.
2022-05-23 14:53:35 -04:00
Carl Dong
faa52387e8 style-only: Rearrange using decls after scripted-diff 2022-05-23 14:53:35 -04:00
Carl Dong
f329a9298c scripted-diff: Move src/kernel/coinstats to kernel::
Introduces a new kernel:: namespace and move all of src/kernel/coinstats
under it.

In the verify script, lines like:

line="$(grep -n 'namespace node {' -- src/kernel/coinstats.h | tail -n1 | cut -d: -f1)"
sed -i -e "${line}s@namespace node {@namespace kernel {@" -- src/kernel/coinstats.h

Are intended to replace only the last instance of "namespace node" with
"namespace kernel", this is to avoid replacing forward declarations of
things inside the node:: namespace.

-BEGIN VERIFY SCRIPT-
sed -E -i 's@namespace node@namespace kernel@g' -- src/kernel/coinstats.cpp

line="$(grep -n 'namespace node {' -- src/kernel/coinstats.h | tail -n1 | cut -d: -f1)"
sed -i -e "${line}s@namespace node {@namespace kernel {@" -- src/kernel/coinstats.h

line="$(grep -n '// namespace node' -- src/kernel/coinstats.h | tail -n1 | cut -d: -f1)"
sed -i -e "${line}s@// namespace node@// namespace kernel@" -- src/kernel/coinstats.h

things='(CCoinsStats|CoinStatsHashType|GetBogoSize|TxOutSer|ComputeUTXOStats)'
git grep -lE 'node::'"$things" | xargs sed -E -i 's@node::'"$things"'@kernel::\1@g'
sed -E -i 's@'"$things"'@kernel::\1@g' -- src/node/coinstats.cpp src/node/coinstats.h
sed -E -i 's@BlockManager@node::\0@g' -- src/kernel/coinstats.cpp
-END VERIFY SCRIPT-
2022-05-23 14:53:35 -04:00
Carl Dong
0e54456f04 Use only kernel/coinstats.h in index/coinstatsindex.h
Removes a circular dependency, horray!
2022-05-23 14:53:35 -04:00
Carl Dong
80970985c9 coinstats: Split node/coinstats.h to kernel/coinstats.h
Most of this commit is pure-move.

After this change:

- kernel/coinstats.h
    -> Contains declarations for:
       - enum class CoinStatsHashType
       - struct CCoinsStats
       - GetBogoSize(...)
       - TxOutSer(...)
       - ComputeUTXOStats(...)
- node/coinstats.h
    -> Just GetUTXOStats, which will be removed as we change callers to
       directly use the hashing/indexing codepaths in future commits.
2022-05-23 14:53:35 -04:00
Carl Dong
35f73ce4b2 coinstats: Move hasher codepath to kernel/coinstats
As mentioned in a previous commit, the hashing codepath can now be moved
to a separate file. This decouples callers that only rely on the hashing
codepath from the indexing one.

This is key for libbitcoinkernel, which needs to have the CoinsStats
hashing codepath for AssumeUTXO, but does not wish to be coupled with
indexes.

Note that only the .cpp file is split in this commit, the header files
will be split in a subsequent commit and the #includes to
node/coinstats.h will be adjusted to only #include the necessary
headers.
2022-05-23 14:53:31 -04:00
Carl Dong
b7634fe02b Move logic from LookupUTXOStatsWithIndex to CoinStatsIndex::LookUpStats
The indexing codepath logic in node/coinstats.cpp is simple enough to be
moved into CoinStatsIndex::LookUpStats, avoiding an additional layer of
function calls. Callers are modified accordingly.

Also, add 2 missed BOOST_CHECKs to the coinstatsindex_initial_sync unit
test.
2022-05-23 14:52:25 -04:00
Carl Dong
1352e410a5 coinstats: Separate hasher/index lookup codepaths
Split out ComputeUTXOStats and LookupUTXOStatsWithIndex from
GetUTXOStats, since the hashing and indexing codepaths are quite
disparate in practice.

Also allow add a constructor to CCoinsStats for it to be constructed
from a a block height and hash. This is used in both codepaths.

Also add a note in GetUTXOStats documenting a behaviour quirk that
predates this patchset.

[META] This allows the hashing codepath to be moved to a separate file
       in a future commit, decoupling callers that only rely on the
       hashing codepath from the indexing one. This is key for
       libbitcoinkernel, which needs to have the hashing codepath for
       AssumeUTXO, but does not wish to be coupled with indexes.
2022-05-23 14:52:23 -04:00
Carl Dong
524463daf6 coinstats: Return purely out-param CCoinsStats
In previous commits in this patchset, we removed all in-param members of
CCoinsStats. Now that that's done, we can modify GetUTXOStats to return
an optional CCoinsStats instead of a status bool. Callers are modified
accordingly.

In rpc/blockchain.cpp, we discover that GetUTXOStats' status bool when
getting UTXO stats for pprev was not checked for error. We fix this as
well.
2022-05-23 14:50:35 -04:00
MacroFake
44037a2912
Merge bitcoin/bitcoin#25176: Fix frequent -netinfo JSON errors from missing getpeerinfo#relaytxes
a17c5e96b6 Rename NetinfoRequestHandler::is_block_relay data member to is_tx_relay (Jon Atack)
f0bb7db34c Fix frequent -netinfo JSON errors from null getpeerinfo#relaytxes (Jon Atack)

Pull request description:

  CLI -netinfo frequently returns "error: JSON value is not a boolean as expected" since the merge of #21160, which moved fRelayTxes (renamed to m_relay_txs in that pull) from CNodeStats to CNodeStateStats.

  This change made getpeerinfo "relaytxes" an optional field that can return UniValue IsNull(). It is the only optional field consumed by -netinfo where the latter didn't already handle that case. See also https://github.com/bitcoin/bitcoin/pull/24691.

  Also rename the NetinfoRequestHandler::is_block_relay data member to is_tx_relay and inverse its boolean logic. The naming is out of date and incorrect, as lack of request of tx relay does not imply block relay, and a preference for tx relay doesn't imply that block relay isn't happening. Thanks to Marco Falke and Martin Zumsande for their feedback on this.

  (I may look at reducing the number of optional node stats fields via refactoring at the net processing level, but ongoing refactoring there may make that slow or complicated and this is a one-line fix that works now.)

ACKs for top commit:
  mzumsande:
    Code review ACK a17c5e96b6

Tree-SHA512: dc54ce80b78122874a6794555f99e5b328a1574b52bb3e7f974c699c2b759a60ea0807a6483c5bc0414a950d853c0eeeb13dcc1b790d3917c6ee4c9c99fe159f
2022-05-23 19:03:10 +02:00
MacroFake
fbb90c44ac
Merge bitcoin/bitcoin#25015: test: Use permissions from git in lint-files.py
908fb7e2ec test: Use permissions from git in `lint-files.py` (laanwj)
48d2e80a74 test: Don't use shell=True in `lint-files.py` (laanwj)

Pull request description:

  Improvements to the `lint-files.py` script:

  - Avoid use of `shell=True`.
  - Check the permissions in git's metadata instead of in the filesystem. This stops the umask or filesystem from interfering. It's also more efficient as it only needs a single call to `git ls-files`.

  (what triggered this change was `File "..." contains a shebang line, but has the file permission 775 instead of the expected executable permission 755.` errors running the script locally).

ACKs for top commit:
  vincenzopalazzo:
    re-tACK 908fb7e2ec

Tree-SHA512: 2eaf868c55a9c3508b12658a5b3ac429963fd0551e645332d0ac54be56fefccee95115e4667386df24b46b545593cb0d0bf8c6cecab73f9cb19d37ddf704c614
2022-05-23 18:59:26 +02:00
Andrew Chow
3368f84c43
Merge bitcoin/bitcoin#25083: Set effective_value when initializing a COutput
6fbb0edac2 Set effective_value when initializing a COutput (ishaanam)

Pull request description:

  Previously in COutput, effective_value was initialized as the absolute value of the txout and the fee as 0. effective_value along with the fee was calculated outside of the COutput constructor and set after the object had been initialized.
  These changes will allow either the fee or the feerate to be passed in a COutput constructor and the fee and effective_value are calculated and set in the constructor. As a result, AvailableCoins also needs to be passed the feerate when utxos are being spent. When balance is calculated or the coins are being listed and feerate is neither available nor required, AvailableCoinsListUnspent is used instead, which runs AvailableCoins while providing the default value for `feerate`. Unit tests for the calculation of effective value have also been added.

ACKs for top commit:
  achow101:
    re-ACK 6fbb0edac2
  Xekyo:
    re-ACK 6fbb0edac2
  w0xlt:
    Code Review ACK 6fbb0edac2
  furszy:
    Looks good, have been touching this area lately, code review ACK 6fbb0eda.

Tree-SHA512: 5943ee4f4b0c1dcfe146f2fc22853e607259d6d53156b80a8a8f4baa70760a8b25ab822777b7f5d21ecb02dac08bdee704a9a918d5660276d6994b19a284b256
2022-05-23 12:55:24 -04:00
Andrew Chow
5ebff43025
Merge bitcoin/bitcoin#25122: rpc: getreceivedbylabel, return early if no addresses were found in the address book
baa3ddc49c doc: add release notes about `getreceivedbylabel` returning an error if the label is not in the address book. (furszy)
8897a21658 rpc: getreceivedbylabel, don't loop over the entire wallet txs map if no destinations were found for the input label. (furszy)

Pull request description:

  Built on top of #23662, coming from comment https://github.com/bitcoin/bitcoin/pull/23662#pullrequestreview-971407999.

  If `wallet.GetLabelAddresses()` returns an empty vector (the wallet does not have stored destinations with that label in the addressbook) or if none of the returned destinations are from the wallet, we can return the function right away.
  Otherwise, we are walking through all the wallet txs + outputs for no reason (`output_scripts` is empty).

ACKs for top commit:
  achow101:
    ACK baa3ddc49c
  theStack:
    re-ACK baa3ddc49c
  w0xlt:
    ACK baa3ddc49c

Tree-SHA512: 00e10365b179bf008da2f3ef8fbb3ee04a330426374020e3f2d0151b16991baba4ef2b944e4659452f3e4d6cb20f128d0918ddf0453933a25a4d9fd8414a1911
2022-05-23 12:15:14 -04:00
laanwj
908fb7e2ec test: Use permissions from git in lint-files.py
Instead of using permissions from the local file system, which might
depend on the umask, directly check the permissions from git's metadata.
2022-05-23 11:09:07 +02:00
MacroFake
66e3b16b8b
Merge bitcoin/bitcoin#25184: refactor: Remove defunct attributes.h includes
71a8dbe5da refactor: Remove defunct attributes.h includes (Ben Woosley)

Pull request description:

  Since the removal of NODISCARD in 81d5af42f4,
  the only attributes.h def is LIFETIMEBOUND, and it's included in many more
  places that it is used.

  This removes all includes which do not have an associated use of LIFETIMEBOUND,
  and adds it to the following files, due to their use of the same:
  * src/validationinterface.h
  * src/script/standard.h

  See also #20499.

Top commit has no ACKs.

Tree-SHA512: f3e10a5cda5ab78371b77b702f4a241ff69d490a16cc6059f1a4202b97c584accdbc951cc7b6120eae94bee3b9249e9117b45cf6ed1a5228ca23b5638fcf7b7b
2022-05-23 09:41:02 +02:00
Hennadii Stepanov
dfe11a1a7e
Merge bitcoin-core/gui#586: Getting ready to Qt 6 (6/n). Replace QCoreApplication::quit() with QCoreApplication::exit(0)
252f363f2f qt: Replace `QCoreApplication::quit()` with `QCoreApplication::exit(0)` (Hennadii Stepanov)

Pull request description:

  ### Qt 5:
   - no behavior change.

  See https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/kernel/qcoreapplication.cpp?h=5.15#n2012:
  ```cpp
  void QCoreApplication::quit()
  {
      exit(0);
  }
  ```

  ### Qt 6:
   - this change avoids sending a duplicated `QEvent::Quit`

  We use `QEvent::Quit` to [handle](https://github.com/bitcoin-core/gui/pull/547) macOS dock menu events. Qt 6 uses `QEvent::Quit` more [widely](89f7a2759c). We do not want a duplicated `QEvent::Quit` which fires `Assert(node.args);` in the [`Shutdown()`](d1b3dfb275/src/init.cpp (L200)) function.

ACKs for top commit:
  promag:
    Code review ACK 252f363f2f.

Tree-SHA512: 6a04cbcf523c0375158a59b29afadf18da99738c8db8b8728f99319a8cdc10806d2f06dc5a7d3b8b0e1a5f1711be778a75d4ecdefef7cf66e26ae2848f7f57db
2022-05-23 08:57:41 +02:00
fanquake
6d20f4b920
Merge bitcoin/bitcoin#25178: doc: remove passing --disable-external-signer in OpenBSD build guide
9ecb0a3550 doc: remove passing `--disable-external-signer` in OpenBSD build guide (Sebastian Falbesoner)

Pull request description:

  Since we have a Boost.Process usage check in the build system (#24254, commit abc057c603), passing the option `--disable-external-signer` explicitly is not needed anymore on OpenBSD; the configure script will automatically detect that including `<boost/process.hpp>` leads to a compile error and disable external signer support accordingly:

  ```
  $ ./configure MAKE=gmake
  ...
  checking whether Boost.Process can be used... no
  ...
  Options used to compile and link:
    external signer = no
  ...

  $ ./configure --enable-external-signer MAKE=gmake
  ...
  checking whether Boost.Process can be used... no
  configure: error: External signing is not supported for this Boost version
  ```
  The PR basically reverts #22335 but keeps the part mentioning that external signer support is not available on OpenBSD. Also bumps the guide to version 7.1 (released [about a month ago](https://www.openbsd.org/71.html)), where I could verify that the instructions are still accurate.

ACKs for top commit:
  fanquake:
    ACK 9ecb0a3550

Tree-SHA512: a5f7e89a5a78f062a06e0047802c42ad49d89e0f0afb963886caa684966ea2e9c8a660320eedd98a5aa5eee0a9c2bb8bf7f5772338c4b49738a69c00e9367a15
2022-05-23 08:38:23 +02:00
Hennadii Stepanov
b0e16eb3ac
Merge bitcoin-core/gui#600: refactor: Add OptionsModel getOption/setOption methods
a63b60f02b refactor: Add OptionsModel getOption/setOption methods (Ryan Ofsky)

Pull request description:

  This is a trivial change which is needed as part of #602 to get bitcoind and bitcoin-qt to use the same settings instead of different settings. It is split off from #602 because it causes a lot of rebase conflicts (any time there is a GUI options change).

  This PR is very small and easy to review ignoring whitespace: https://github.com/bitcoin-core/gui/pull/600/files?w=1

ACKs for top commit:
  vasild:
    ACK a63b60f02b
  furszy:
    Code review ACK a63b60f0
  promag:
    Code review ACK a63b60f02b.

Tree-SHA512: 1d99a1ce435b4055c1a38d2490702cf5b89bacc7d168c9968a60550bfd9f6dace649d5e98699de68d6305f02d5d1e3eb7e177ab578b98b996dd873b1df0ed236
2022-05-22 20:12:41 +02:00
Ben Woosley
71a8dbe5da
refactor: Remove defunct attributes.h includes
Since the removal of NODISCARD in 81d5af42f4,
the only attributes def is LIFETIMEBOUND, and it's included in many more
places that it is used.

This removes all includes which do not have an associated use of LIFETIMEBOUND,
and adds it to the following files, due to their use of the same:
* src/validationinterface.h
* src/script/standard.h
2022-05-21 13:54:33 -05:00
Hennadii Stepanov
e280087946
qt: Use QRegularExpression in AddressBookSortFilterProxyModel class
Co-authored-by: João Barbosa <joao.paulo.barbosa@gmail.com>
2022-05-21 17:44:57 +02:00
Hennadii Stepanov
5c5d8f2465
qt, test: Add tests for searching in AddressBookPage dialog 2022-05-21 17:42:36 +02:00
ishaanam
6fbb0edac2 Set effective_value when initializing a COutput
Previously in COutput, effective_value was initialized as the absolute
value of the txout, and fee as 0. effective_value along with fee were
calculated outside of the COutput constructor and set after the
object had been initialized. These changes will allow either the fee
or the feerate to be passed in a COutput constructor. If either are
provided, fee and effective_value are calculated and set in the
constructor. As a result, AvailableCoins also needs to be passed the
feerate when utxos are being spent. When balance is calculated or the
coins are being listed and feerate is neither available nor required,
AvailableCoinsListUnspent is used instead, which runs AvailableCoins
while providing the default value for feerate. Unit tests for the
calculation of effective value have also been added.
2022-05-21 11:25:54 -04:00
Hennadii Stepanov
252f363f2f
qt: Replace QCoreApplication::quit() with QCoreApplication::exit(0)
Qt 5:
 - no behavior change

Qt 6:
 - this change avoids sending a duplicated `QEvent::Quit`
2022-05-21 16:57:31 +02:00
furszy
baa3ddc49c
doc: add release notes about getreceivedbylabel returning an error if the label is not in the address book. 2022-05-20 23:22:11 -03:00
Carl Dong
46eb9fc56a coinstats: Extract index_requested in-member to in-param
This change removes CCoinsStats' index_requested in-param member and
adds it to the relevant functions instead.
2022-05-20 16:33:24 -04:00
Carl Dong
a789f3f2b8 coinstats: Extract hash_type in-member to in-param
Currently, CCoinsStats is a struct with both in-params and out-params
where the hash_type and index_requested members are the only in-params.

This change removes CCoinsStats' hash_type in-param member and adds it
to the relevant functions instead.

[META] In subsequent commits, all of CCoinsStats' members which serve as
       in-params will be moved out so as to make CCoinsStats a pure
       out-param struct.
2022-05-20 16:33:24 -04:00
Carl Dong
102294898d includes: Remove rpc/util.h -> node/coinstats.h
Confirmed with IWYU that this is unnecessary.
2022-05-20 16:33:24 -04:00
Carl Dong
0848db9c35 fuzz: Remove useless GetUTXOStats fuzz case
In the GetUTXOStats fuzz case, GetUTXOStats is always called with a
CCoinsViewCache. Which is guaranteed to throw a std::logic_error when
its ::Cursor() method is called on the first line of GetUTXOStats.

In the fuzz case, we basically catch this logic error and declare
victory if we caught it.

There is no point to fuzzing this deterministic logic.

Confirmed with IWYU that the node/coinstats.h #include is no longer
necessary.
2022-05-20 16:33:24 -04:00
Carl Dong
52b1939993 kernel: Remove unnecessary blockfilter{index,}.cpp
It is no longer necessary to link in blockfilter.cpp and
index/blockfilterindex.cpp after merge of PR#21726 since validation has
been decouple from the blockfilterindex.
2022-05-20 16:33:24 -04:00
furszy
8897a21658
rpc: getreceivedbylabel, don't loop over the entire wallet txs map if no destinations were found for the input label.
If wallet.GetLabelAddresses() returns an empty vector (the wallet does not have addresses with that label in the addressbook) or if none of the returned destinations are from the wallet, we can return the function right away.
2022-05-20 16:32:09 -03:00
MacroFake
640eb772e5
Merge bitcoin/bitcoin#25064: [kernel 2b/n] Add ChainstateManager::m_adjusted_time_callback
53494bc739 validation: Have ChainstateManager own m_chainparams (Carl Dong)
04c31c1295 Add ChainstateManager::m_adjusted_time_callback (Carl Dong)
dbe45c34f8 Add ChainstateManagerOpts, using as ::Options (Carl Dong)

Pull request description:

  ```
  This decouples validation.cpp from netaddress.cpp (transitively,
  timedata.cpp, and asmap.cpp).

  This is important for libbitcoinkernel as:

  - There is no reason for the consensus engine to be coupled with
    netaddress, timedata, and asmap
  - Users of libbitcoinkernel can now easily supply their own
    std::function that provides the adjusted time.

  See the src/Makefile.am changes for some satisfying removals.
  ```

Top commit has no ACKs.

Tree-SHA512: a093ec6ecacdc659d656574f05bd31ade6a6cdb64d5a97684f94ae7e55c0e360b78177553d4d1ef40280192674464d029a0d68e96caf8711d9274011172f1330
2022-05-20 19:40:01 +01:00
MacroFake
aac99faa66
Merge bitcoin/bitcoin#25175: refactor: Improve thread safety analysis by propagating some negative capabilities
2b3373c152 refactor: Propagate negative `!m_tx_relay_mutex` capability (Hennadii Stepanov)
5a6e3c1db3 refactor: Propagate negative `!m_most_recent_block_mutex` capability (Hennadii Stepanov)

Pull request description:

  This PR is a follow-up for bitcoin/bitcoin#22778 and bitcoin/bitcoin#24062, and it seems [required](https://github.com/bitcoin/bitcoin/pull/24931#issuecomment-1132800173) for bitcoin/bitcoin#24931.

  See details in the commit messages.

ACKs for top commit:
  ajtowns:
    ACK 2b3373c152
  w0xlt:
    ACK 2b3373c152

Tree-SHA512: 8a4bb9641af8d79824ec12e2d6bfce0e09524094b298a2edcdb2ab115fbaa21215b9c97a6b059f8aa023551071fd5798eca66ab8d262a3f97246a91d960850d0
2022-05-20 18:43:09 +01:00
Andrew Chow
3aa851ad2a
Merge bitcoin/bitcoin#24820: test: 3 new tests for SelectCoins function
3f8def51d5 add 3 new test cases for SelectCoins() (akankshakashyap)

Pull request description:

  Three new tests have been added.

  1. More coins should be selected when effective fee < long term fee.
  2. Less coin should be selected when effective fee > long term fee.
  3. If a coin is preselected, it should be selected even if disadvantageous.

ACKs for top commit:
  achow101:
    ACK 3f8def51d5
  brunoerg:
    ACK 3f8def51d5

Tree-SHA512: 8db6dd942b02a38c99953b801605f98c4c17729768fdfcf7605c5bbdb17509500a39d0a78a4b19aab37812d2994ec7630d2b4e78d1d348f1c27b67588d74e155
2022-05-20 12:06:30 -04:00
Carl Dong
53494bc739 validation: Have ChainstateManager own m_chainparams
We want m_chainparams to be alive for the duration of
ChainstateManager's lifetime since ChainstateManager's behaviour depends
on m_chainparams.

We could allow for a std::shared_ptr to be passed in as m_chainparams,
but that complicates things further. Given that CChainParams is not an
entity class or struct, we can just copy it and have ChainstateManager
own it.
2022-05-20 11:57:54 -04:00
Carl Dong
04c31c1295 Add ChainstateManager::m_adjusted_time_callback
This decouples validation.cpp from netaddress.cpp (transitively,
timedata.cpp, and asmap.cpp).

This is important for libbitcoinkernel as:

- There is no reason for the consensus engine to be coupled with
  netaddress, timedata, and asmap
- Users of libbitcoinkernel can now easily supply their own
  std::function that provides the adjusted time.

See the src/Makefile.am changes for some satisfying removals.
2022-05-20 11:57:51 -04:00
Carl Dong
dbe45c34f8 Add ChainstateManagerOpts, using as ::Options
[META] Although it seems like we don't need it for just one option,
       we're going to introduce another member to this struct *in the
       next commit*. In future patchsets for libbitcoinkernel decoupling
       it from ArgsManager, even more members will be added here.
2022-05-20 11:54:18 -04:00
Jon Atack
a17c5e96b6 Rename NetinfoRequestHandler::is_block_relay data member to is_tx_relay
and inverse its logic.

The naming is out of date and incorrect, as lack of request of tx relay does not
imply block relay, and a preference for tx relay doesn't imply that block relay
isn't happening.
2022-05-20 16:06:07 +02:00
Sebastian Falbesoner
9ecb0a3550 doc: remove passing --disable-external-signer in OpenBSD build guide
Since the Boost.Process usage check was added to the build system
(commit abc057c603), passing the option
`--disable-external-signer` explicitly is not needed anymore on OpenBSD;
The configure script will automatically detect that including
<boost/process.hpp> leads to a compile error and disable external signer
support accordingly.
2022-05-20 15:34:13 +02:00
Hennadii Stepanov
ab75388320
refactor: Remove redundant scope in BanMan::SweepBanned() 2022-05-20 15:20:42 +02:00
Hennadii Stepanov
52c0b3e859
refactor: Add thread safety annotation to BanMan::SweepBanned() 2022-05-20 15:17:00 +02:00
Hennadii Stepanov
3919059deb
refactor: Move code from ctor into private BanMan::LoadBanlist()
Co-authored-by: Anthony Towns <aj@erisian.com.au>
2022-05-20 15:15:45 +02:00
MacroFake
4d0c00dffd
Merge bitcoin/bitcoin#25168: refactor: Avoid passing params where not needed
fa1b76aeb0 Do not call global Params() when chainman is in scope (MacroFake)
fa30234be8 Do not pass CChainParams& to PeerManager::make (MacroFake)
fafe5c0ca2 Do not pass CChainParams& to BlockAssembler constructor (MacroFake)
faf012b438 Do not pass Consensus::Params& to Chainstate helpers (MacroFake)
fa4ee53dca Do not pass time getter to Chainstate helpers (MacroFake)

Pull request description:

  It seems confusing to pass chain params, consensus params, or a time function around when it is not needed.

  Fix this by:

  * Inlining the passed time getter function. I don't see a use case why this should be mockable.
  * Using `chainman.GetConsensus()` or `chainman.GetParams()`, where possible.

ACKs for top commit:
  promag:
    Code review ACK fa1b76aeb0.
  vincenzopalazzo:
    ACK fa1b76aeb0

Tree-SHA512: 1abff5cba4b4871d97f17dbcdf67bc9255ff21fa4150a79a74e39b28f0610eab3e7dee24d56872dd6e111f003b55e288958cdd467e6218368d896f191e4ec9cd
2022-05-20 13:35:15 +01:00
Jon Atack
f0bb7db34c Fix frequent -netinfo JSON errors from null getpeerinfo#relaytxes
"error: JSON value is not a boolean as expected"

due to fRelayTxes/m_relay_txs being moved in PR 21160 from CNodeStats to
CNodeStateStats, which made getpeerinfo#relaytxes an optional field that
can return UniValue IsNull().
2022-05-20 14:33:12 +02:00
Hennadii Stepanov
2b3373c152
refactor: Propagate negative !m_tx_relay_mutex capability
Could be verified with
$ ./configure CC=clang CXX=clang++ CXXFLAGS='-Wthread-safety -Wthread-safety-negative'
$ make clean
$ make 2>&1 | grep m_tx_relay_mutex
2022-05-20 13:31:08 +02:00