Commit graph

21344 commits

Author SHA1 Message Date
Carl Dong
7a68fe4831 bitcoin-chainstate: Lock cs_main to UnloadBlockIndex
This was introduced because of a silent merge conflict.
2022-03-08 16:12:03 -05:00
Andrew Chow
9d22dbe2e1
Merge bitcoin/bitcoin#24198: wallet, rpc: add wtxid in WalletTxToJSON
7abd8b21ba doc: include wtxid in TransactionDescriptionString (brunoerg)
2d596bce6f doc: add wtxid info in release-notes (brunoerg)
a5b66738f1 test: add wtxid in expected_fields for wallet_basic (brunoerg)
e8c659a297 wallet: add wtxid in WalletTxToJSON (brunoerg)
7482b6f895 wallet: add GetWitnessHash() (brunoerg)

Pull request description:

  This PR add `wtxid` in `WalletTxToJSON` which allows to return this field in `listsinceblock`, `listtransactions` and `gettransaction` (RPCs).

ACKs for top commit:
  achow101:
    re-ACK 7abd8b21ba
  w0xlt:
    crACK 7abd8b2
  luke-jr:
    re-utACK 7abd8b21ba

Tree-SHA512: f86f2dbb5e38e7b19932006121802f47b759d31bdbffe3263d1db464f6a3a30fddd68416f886a44f6d3a9fd570f7bd4f8d999737ad95c189e7ae5e8ec1ffbdaa
2022-03-08 14:32:10 -05:00
MarcoFalke
b07fdd7f9e
Merge bitcoin/bitcoin#24312: addrman: Log too low compat value
fa097d074b addrman: Log too low compat value (MarcoFalke)

Pull request description:

  Before this patch, when writing a negative `lowest_compatible` value, it would be read as a positive value. For example `-32` will be read as `224`. There is generally nothing wrong with that. Though, similarly there shouldn't be anything wrong with refusing to read a negative value. I find the code after this patch more logical than before. Also, this allows dropping a file-wide sanitizer suppression.

  In practice none of this should ever happen. Bitcoin Core would never write a negative `lowest_compatible` in normal operation, unless the file storage is later corrupted by external influence.

ACKs for top commit:
  mzumsande:
    re-ACK fa097d074b

Tree-SHA512: 9aae7b8fe666f52f667f149667025e0160cef1a793cc4d392e36608f65c2bee8096da429235118f40a3368f327aabe30f3732ae78c5874648ea6f423f2687b65
2022-03-08 16:48:22 +01:00
Ryan Ofsky
5b1aae12ca qt: Avoid crash on startup if int specified in settings.json
Fix GUI startup crash reported by Rspigler in
https://github.com/bitcoin/bitcoin/issues/24457 that happens if
settings.json contains an integer value for any of the configuration
options which GUI settings can currently clash with (-dbcache, -par,
-spendzeroconfchange, -signer, -upnp, -natpmp, -listen, -server, -proxy,
-proxy, -onion, -onion, -lang, and -prune).

Fix is a one-line change in ArgsManager::GetArg.
2022-03-07 13:29:46 -05:00
Ryan Ofsky
84b0973e35 test: Add tests for GetArg methods / settings.json type coercion
Just add tests. No changes to application behavior. Tests will be
updated in the next commit changing & improving current behavior.

Include a Qt test for GUI startup crash reported by Rspigler in
https://github.com/bitcoin/bitcoin/issues/24457 caused by GetArg
behavior that happens if settings.json contains an integer value for any
of the configuration options which GUI settings can currently clash with
(-dbcache, -par, -spendzeroconfchange, -signer, -upnp, -natpmp, -listen,
-server, -proxy, -proxy, -onion, -onion, -lang, and -prune).
2022-03-07 13:29:46 -05:00
fanquake
c9ed9927bb
Merge bitcoin/bitcoin#24132: build: Bump minimum Qt version to 5.11.3
956f7322f6 build: Bump minimum Qt version to 5.11.3 (Hennadii Stepanov)
e22d10b936 ci: Switch from bionic to buster (Hennadii Stepanov)

Pull request description:

  The current minimum Qt version is 5.9.5 which has been set in bitcoin/bitcoin#21286.

  Distro support:
  - centos 7 -- unsupported since bitcoin/bitcoin#23511
  - centos 8 -- [5.15.2](http://mirror.centos.org/centos/8/AppStream/x86_64/os/Packages/qt5-qtbase-5.15.2-3.el8.x86_64.rpm)
  - buster -- [5.11.3](https://packages.debian.org/buster/libqt5core5a)
  - bullseye  -- [5.15.2](https://packages.debian.org/bullseye/libqt5core5a)
  - _bionic_ -- [5.9.5](https://packages.ubuntu.com/bionic/libqt5core5a)
  - focal -- [5.12.8](https://packages.ubuntu.com/focal/libqt5core5a)

  As another Ubuntu LTS is coming soon, it seems unreasonable to stick to Qt 5.9 which support [ended](https://www.qt.io/blog/2017/06/07/renewed-qt-support-services) on 2020-05-31. Anyway, it's still possible to build Bitcoin Core GUI with depends on bionic system.

  Bumping the minimum Qt version allows to make code safer and more reliable, e.g.:
  - functor-parameter overload of [`QMetaObject::invokeMethod`](https://doc.qt.io/qt-5/qmetaobject.html#invokeMethod-4)
  - fixed https://bugreports.qt.io/browse/QTBUG-10907

  An example of the patch using the functor-overload of `QMetaObject::invokeMethod`:
  ```diff
  --- a/src/qt/walletmodel.cpp
  +++ b/src/qt/walletmodel.cpp
  @@ -349,7 +349,7 @@ bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureStri
   static void NotifyUnload(WalletModel* walletModel)
   {
       qDebug() << "NotifyUnload";
  -    bool invoked = QMetaObject::invokeMethod(walletModel, "unload");
  +    bool invoked = QMetaObject::invokeMethod(walletModel, &WalletModel::unload);
       assert(invoked);
   }

  ```
  It uses the same new syntax as signal-slot connection with compile-time check. Also see bitcoin/bitcoin#16348.

  This PR is intended to be merged early [after](https://github.com/bitcoin/bitcoin/issues/22969) branching `23.x` off.

ACKs for top commit:
  MarcoFalke:
    cr ACK 956f7322f6
  fanquake:
    ACK 956f7322f6

Tree-SHA512: 3d652bcdcd990ce785ad412ed70234d4f27743895e535a53ed44b35d4afc3052e066c4c84f417e30bc53d0a3dd9ebed62444c57b7c765cb1e9aa687fbf866877
2022-03-07 14:53:23 +00:00
MarcoFalke
5e49b2a252
Merge bitcoin/bitcoin#24050: validation: Give m_block_index ownership of CBlockIndexs
6c23c41561 refactor: Rewrite AddToBlockIndex with try_emplace (Carl Dong)
c05cf7aa1e style: Modernize range-based loops over m_block_index (Carl Dong)
c2a1655799 style-only: Use using instead of typedef for BlockMap (Carl Dong)
dd79dad175 refactor: Rewrite InsertBlockIndex with try_emplace (Carl Dong)
531dce0347 tests: Remove now-unnecessary manual Unload's (Carl Dong)
bec86ae326 blockstorage: Make m_block_index own CBlockIndex's (Carl Dong)

Pull request description:

  Part of: #24303
  Split off from: #22564

  ```
  Instead of having CBlockIndex's live on the heap, which requires manual
  memory management, have them be owned by m_block_index. This means that
  they will live and die with BlockManager.
  ```

  The second commit demonstrates how this makes calls to `Unload()` to satisfy the address sanitizer unnecessary.

ACKs for top commit:
  ajtowns:
    ACK 6c23c41561
  MarcoFalke:
    re-ACK 6c23c41561 🎨

Tree-SHA512: 81b2b5119be27cc0f8a9457b11da60cc60930315d2a5be36be89fe253d32073ffe622348ff153114b9b3212197bddbc791810913a43811b33cc58e7162bd105b
2022-03-07 13:15:27 +01:00
fanquake
b9894a1308
Merge bitcoin/bitcoin#24461: build: Minor leveldb subtree update
1b20109b04 Squashed 'src/leveldb/' changes from f8ae182c1e..330dd6235f (MarcoFalke)

Pull request description:

  A minor change to:

  * Consistently use the same symbol names in the whole project.
  * Fix compiling with C++20.

ACKs for top commit:
  fanquake:
    ACK fa0c32eb74

Tree-SHA512: b5d4540dd621cf4aa8caac811bae03bb74e502a31dbdda9354182e4caa39905550e62ad3cf8ea7d7f9bfc3e5120d119d34ab0f1e633716ec8089876037cbf192
2022-03-07 11:39:41 +00:00
laanwj
cba41db327
Merge bitcoin/bitcoin#24299: validation, refactor: UnloadBlockIndex and ChainstateManager::Reset thread safety cleanups
ae9ceed3e2 validation, refactoring: remove ChainstateManager::Reset() (Jon Atack)
daad0093e3 validation: replace lock with annotation in UnloadBlockIndex() (Jon Atack)

Pull request description:

  Thread safety refactoring seen in #24177:
  - replace re-acquiring lock cs_main with a thread safety annotation in UnloadBlockIndex()
  - remove ChainstateManager::Reset(), as it is currently unused (can be reintroduced in the test utilities if needed for unit testing)

ACKs for top commit:
  laanwj:
    Code review ACK ae9ceed3e2
  vasild:
    ACK ae9ceed3e2
  klementtan:
    crACK ae9ceed3e2

Tree-SHA512: cebb782572997cc2dda01590d6bb6c5e479e8202324d8b6ff459b814ce09e818b996c881736bfebd1b8bf4b6d7a0f79faf3ffea176a4699dd7d7429de2db2d13
2022-03-07 12:13:32 +01:00
laanwj
f6d335e828
Merge bitcoin/bitcoin#24468: init, doc: improve -onlynet help and related tor/i2p documentation
a1db99adea init, doc: improve -onlynet help and tor/i2p documentation (Jon Atack)

Pull request description:

  including review feedback from https://github.com/bitcoin/bitcoin/pull/22834#discussion_r795253056 and https://github.com/bitcoin/bitcoin/pull/24205#discussion_r818629106 concerning `src/init.cpp`, `doc/tor.md` and `doc/i2p.md`

  - s/outgoing/automatic outbound/
  - s/Incoming/Inbound and manual/ (are not affected by this option.)
  - s/only through network/only to network/
  - s/this option. This option/this option. It/
  - s/network types/networks/

  and pick up a few nits in `doc/p2p-bad-ports.md` from https://github.com/bitcoin/bitcoin/pull/23542#pullrequestreview-881415043.

ACKs for top commit:
  laanwj:
    ACK a1db99adea
  w0xlt:
    ACK a1db99a
  theStack:
    ACK a1db99adea

Tree-SHA512: dd727904b9b3dadb16053e2b0350e6c0814ef68fb0cca7d34880b883123cfe3aa03b15813b40a863f6367d596d17ee4517eab55281cfe35cd00767b8a39593ca
2022-03-07 11:42:36 +01:00
MarcoFalke
6687bb24ae
Merge bitcoin/bitcoin#24306: util: Make ArgsManager::GetPathArg more widely usable
60aa179d8f Use GetPathArg where possible (Pavol Rusnak)
5b946edd73 util, refactor: Use GetPathArg to read "-settings" value (Ryan Ofsky)
687e655ae2 util: Add GetPathArg default path argument (Ryan Ofsky)

Pull request description:

  Improve `ArgsManager::GetPathArg` method added in recent PR #24265, so it is usable more places. This PR starts to use it for the `-settings` option. This can also be helpful for #24274 which is parsing more path options.

  - Add `GetPathArg` default argument so it is less awkward to use to parse options that have default values.
  - Fix `GetPathArg` negated argument handling. Return path{} not path{"0"} when path argument is negated.
  - Add unit tests for default and negated cases
  - Move `GetPathArg` method declaration next to `GetArg` declaration. The two methods are close substitutes for each, so this should help keep them consistent and make them more discoverable.

ACKs for top commit:
  w0xlt:
    Tested ACK 60aa179 on Ubuntu 21.10
  hebasto:
    re-ACK 60aa179d8f

Tree-SHA512: 3d24b885d8bbeef39ea5d0556e2f09b9e5f4a21179cef11cbbbc1b84da29c8fb66ba698889054ce28d80bc25926687654c8532ed46054bf5b2dd1837866bd1cd
2022-03-07 10:00:53 +01:00
MarcoFalke
384866e870
Merge bitcoin/bitcoin#24427: refactor: Release cs_main before MaybeSendFeefilter
faa329fd46 refactor: Release cs_main before MaybeSendFeefilter (MarcoFalke)

Pull request description:

  There is no need for any lock to be held, because net processing is single threaded. So holding the validation lock cs_main for sending a feefilter is confusing and might even degrade blockchain-related RPC performance minimally.

ACKs for top commit:
  ajtowns:
    ACK faa329fd46 ; code review only
  vasild:
    ACK faa329fd46

Tree-SHA512: 3e7f9faff1631cc64c86fc1a354ada67617ad1e7a046625cc741f4711854eb41ca8aad5a51ef0d94ff65947b68dba8345c9f786b20ee0a8b7a2e8741cfced21f
2022-03-07 08:47:05 +01:00
Sebastian Falbesoner
8ea6167099 wallet: refactor: dedup sqlite blob binding 2022-03-06 20:43:16 +01:00
Jon Atack
4d2b503d6c
gui: improve "Addresses Rate-Limited" translator comments and tooltip in peers tab 2022-03-06 17:49:20 +01:00
Jon Atack
81ef1f7ef1
gui: improve "Addresses Processed" translator comments and tooltip in peers tab 2022-03-06 17:49:01 +01:00
Jon Atack
77f24aac52
gui: improve "Address Relay" translator comments and tooltip in peers tab 2022-03-06 17:48:26 +01:00
Hennadii Stepanov
c8f2817bd6
Merge bitcoin-core/gui#549: refactor: use std::chrono for formatDurationStr() helper
6f2593dc23 gui, refactor: use std::chrono for formatDurationStr() helper (Jon Atack)

Pull request description:

  Updates `formatDurationStr()` to use the `chrono` standard lib. No change in behavior.

ACKs for top commit:
  RandyMcMillan:
    tACK 6f2593dc23
  shaavan:
    ACK 6f2593dc23
  w0xlt:
    tACK 6f2593d on Ubuntu 21.10 Qt 5.15.2
  promag:
    Code review ACK 6f2593dc23.

Tree-SHA512: 61e9afdb1db779150df338e6af08727c34f69639add465c2f7003ff775d97dce3e78e78d325bc6dea5bc13f0fce9ef1c3506d13f1661a5e083e52bba8a32ba44
2022-03-05 17:20:55 +01:00
MarcoFalke
fae20e6b50
Revert "Avoid the use of P0083R3 std::set::merge"
This reverts commit 6cf4ea7187.
2022-03-04 14:13:55 +00:00
Andrew Chow
bada9636d7
Merge bitcoin/bitcoin#24043: Add (sorted)multi_a descriptor for k-of-n multisig inside tr
4828d53ecc Add (sorted)multi_a descriptors to doc/descriptors.md (Pieter Wuille)
b5f33ac1f8 Simplify wallet_taproot.py functional test (Pieter Wuille)
eb0667ea96 Add tests for (sorted)multi_a derivation/signing (Pieter Wuille)
c17c6aa08d Add signing support for (sorted)multi_a scripts (Pieter Wuille)
3eed6fca57 Add multi_a descriptor inference (Pieter Wuille)
79728c4a3d Add (sorted)multi_a descriptor and script derivation (Pieter Wuille)
25e95f9ff8 Merge/generalize IsValidMultisigKeyCount/GetMultisigKeyCount (Pieter Wuille)

Pull request description:

  This adds a new `multi_a(k,key_1,key_2,...,key_n)` (and corresponding `sortedmulti_a`) descriptor for k-of-n policies inside `tr()`. Semantically it is very similar to the existing `multi()` descriptor, but with the following changes:
  * The corresponding script is `<key1> OP_CHECKSIG <key2> OP_CHECKSIGADD <key3> OP_CHECKSIGADD ... <key_n> OP_CHECKSIGADD <k> OP_NUMEQUAL`, rather than the traditional `OP_CHECKMULTISIG`-based script, making it usable inside the `tr()` descriptor.
  * The keys can optionally be specified in x-only notation.
  * Both the number of keys and the threshold can be as high as 999; this is the limit due to the consensus stacksize=1000 limit

  I expect that this functionality will later be replaced with a miniscript-based implementation, but I don't think it's necessary to wait for that.

  Limitations:
  * The wallet code will for not estimate witness size incorrectly for script path spends, which may result in a (dramatic) fee underpayment with large multi_a scripts.
  * The multi_a script construction is (slightly) suboptimal for n-of-n (where a `<key1> OP_CHECKSIGVERIFY ... <key_n-1> OP_CHECKSIGVERIFY <key_n> OP_CHECKSIG` would be better). Such a construction is not included here.

ACKs for top commit:
  achow101:
    ACK 4828d53ecc
  gruve-p:
    ACK 4828d53ecc
  sanket1729:
    code review ACK 4828d53ecc
  darosior:
    Code review ACK 4828d53ecc

Tree-SHA512: 5dcd434b79585f0ff830f7d501d27df5e346f5749f47a3109ec309ebf2cbbad0e1da541eec654026d911ab67fd7cf7793fab0f765628d68d81b96ef2a4d234ce
2022-03-04 07:28:23 -05:00
fanquake
4fae737f4b
Merge bitcoin/bitcoin#24441: fuzz: Limit script_format to 100kB
bbbbeaf9c8 fuzz: Limit script_format to 100kB (MarcoFalke)

Pull request description:

  The target is still one of the slowest ones, but doesn't seem incredibly important. Especially for sizes larger than the standard tx size.

  Fix that by limiting the script size.

ACKs for top commit:
  fanquake:
    ACK bbbbeaf9c8

Tree-SHA512: b6cf7248753909ef2f21d8824f187e7c05732dd3b99619c0067f862f3c2b0f9a87779d4ddbbd3a7a4bae5c794280e2f0a223bf835d6bc6ccaba01817d69479a2
2022-03-04 09:33:24 +00:00
MarcoFalke
619f8a27ad
Merge bitcoin/bitcoin#24304: [kernel 0/n] Introduce bitcoin-chainstate
2c03cec2ff ci: Build bitcoin-chainstate (Carl Dong)
095aa6ca37 build: Add example bitcoin-chainstate executable (Carl Dong)

Pull request description:

  Part of: #24303

  This PR introduces an example/demo `bitcoin-chainstate` executable using said library which can print out information about a datadir and take in new blocks on stdin.

  Please read the commit messages for more details.

  -----

  #### You may ask: WTF?! Why is `index/*.cpp`, etc. being linked in?

  This PR is meant only to capture the state of dependencies in our consensus engine as of right now. There are many things to decouple from consensus, which will be done in subsequent PRs. Listing the files out right now in `bitcoin_chainstate_SOURCES` is purely to give us a clear picture of the task at hand, it is **not** to say that these dependencies _belongs_ there in any way.

  ### TODO

  1. Clean up `bitcoin-chainstate.cpp`
     It is quite ugly, with a lot of comments I've left for myself, I should clean it up to the best of my abilities (the ugliness of our init/shutdown might be the upper bound on cleanliness here...)

ACKs for top commit:
  ajtowns:
    ACK 2c03cec2ff
  ryanofsky:
    Code review ACK 2c03cec2ff. Just rebase, comments, formatting change since last review
  MarcoFalke:
    re-ACK 2c03cec2ff 🏔

Tree-SHA512: 86e7fb5718caa577df8abc8288c754f4a590650d974df9d2f6476c87ed25c70f923c4db651c6963f33498fc7a3a31f6692b9a75cbc996bf4888c5dac2f34a13b
2022-03-03 19:31:36 +00:00
Ryan Ofsky
2f5fd3cf92 test: Correctly decode UTF-8 literal string paths
Call fs::u8path to convert some UTF-8 string literals to paths, instead
of relying on implicit conversions. The implicit conversions incorrectly
decode const char* paths using the current windows codepage, instead of
treating them as UTF-8. This could cause test failures depending what
environment windows tests are run in.

Issue was reported by MarcoFalke <falke.marco@gmail.com> in
https://github.com/bitcoin/bitcoin/pull/24306#discussion_r818566106
2022-03-03 14:12:07 -05:00
Ben Woosley
9b52672700
For descriptor pubkey parse errors, include context information
Note 'Multi:' is used rather than 'multi():' as it also encompasses 'sortedmulti():'
2022-03-03 17:09:56 +00:00
Jon Atack
a1db99adea
init, doc: improve -onlynet help and tor/i2p documentation
and harmonize them as follows

- s/outgoing/automatic outbound/
- s/Incoming/Inbound and manual/ (are not affected by this option.)
- s/only through network/only to network/
- s/this option. This option/this option. It/
- s/network types/networks/

and also pick up a few nits in doc/p2p-bad-ports.md
2022-03-03 16:14:01 +01:00
Vasil Dimov
7d64ea4a01
net: only assume all local addresses if listening on any
If `-bind=` is provided then we would bind only to a particular address
and should not add all the other addresses of the machine to the list of
local addresses.

Fixes https://github.com/bitcoin/bitcoin/issues/20184 (case 4.)
2022-03-02 15:42:40 +01:00
Vasil Dimov
0cfc0cd322
net: fix GetListenPort() to derive the proper port
`GetListenPort()` uses a simple logic: "if `-port=P` is given, then we
must be listening on `P`, otherwise we must be listening on `8333`".
This is however not true if `-bind=` has been provided with `:port` part
or if `-whitebind=` has been provided. Thus, extend `GetListenPort()` to
return the port from `-bind=` or `-whitebind=`, if any.

Fixes https://github.com/bitcoin/bitcoin/issues/20184 (cases 1. 2. 3. 5.)
2022-03-02 15:42:37 +01:00
Vasil Dimov
f98cdcb357
net: pass Span by value to CaptureMessage()
Span is lightweight and need not be passed by const reference.
2022-03-02 15:40:36 +01:00
Vasil Dimov
3cb9d9c861
net: make CaptureMessage() mockable
Rename `CaptureMessage()` to `CaptureMessageToFile()` and introduce a
`std::function` variable called `CaptureMessage` whose value can be
changed by unit tests, should they need to inspect message contents.
2022-03-02 15:40:36 +01:00
Vasil Dimov
43868ba416
timedata: rename variables to match the coding style
Rename the local variables in `src/timedata.cpp`:
`setKnown` -> `g_sources`
`vTimeOffsets` -> `g_time_offsets`
`fDone` -> `g_warning_emitted`
2022-03-02 15:40:35 +01:00
Vasil Dimov
60da1eaa11
timedata: make it possible to reset the state
Add a new function `TestOnlyResetTimeData()` which would reset the
internal state used by `GetTimeOffset()`, `GetAdjustedTime()` and
`AddTimeData()`.

This is needed so that unit tests that call `AddTimeData()` can restore
the state in order not to confuse other tests that rely on it.

Currently `timedata_tests/addtimedata` is the only test that modifies
the state (via `AddTimeData()`) and also the only test that relies on
that state.
2022-03-02 15:40:30 +01:00
MarcoFalke
fa0c32eb74
build: Minor leveldb subtree update 2022-03-02 15:25:48 +01:00
Pavol Rusnak
60aa179d8f Use GetPathArg where possible
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2022-03-02 12:09:27 +01:00
MarcoFalke
08bcfa2767
Merge bitcoin/bitcoin#24375: Do not use LocalTestingSetup in getarg_tests test file.
5d7f22595f Do not use `LocalTestingSetup` in getarg_tests test file. (Kiminuo)

Pull request description:

  Avoid using a test fixture in getarg_tests for better readability. Change was implemented by _kiminuo_ and posted https://github.com/bitcoin/bitcoin/pull/24306#issuecomment-1036643216

ACKs for top commit:
  kiminuo:
    ACK 5d7f22595f

Tree-SHA512: 0fd98622010e6923e91c66447a1d0861bf344a65d86a313dff7d428c089b1740a25f699327f6ed4c163255f270bcbd4f7be962bb551862214f9b9e395d40df04
2022-03-02 12:09:27 +01:00
Ryan Ofsky
5b946edd73 util, refactor: Use GetPathArg to read "-settings" value
Take advantage of GetPathArg to simplify code slightly.
2022-03-02 06:09:27 -05:00
Ryan Ofsky
687e655ae2 util: Add GetPathArg default path argument
Let GetPathArg method be used more places for path arguments that have
default values, like "-settings" and BITCOIN_SETTINGS_FILENAME in the
next commit.

Also:

- Fix negated argument handling. Return path{} not path{"0"} when path
  argument is negated.

- Add new tests for default and negated cases

- Move GetPathArg() method declaration next to GetArg() declarations.
  The two methods are close substitutes for each other, so this should
  help keep them consistent and make them more discoverable.
2022-03-02 06:09:27 -05:00
laanwj
8b6cd42c62
Merge bitcoin/bitcoin#24165: p2p: extend inbound eviction protection by network to CJDNS peers
b7be28cac5 test: add combined CJDNS/I2P/localhost/onion eviction protection tests (Jon Atack)
0a1bb84770 test: add tests for inbound eviction protection of CJDNS peers (Jon Atack)
0c00c0c981 test: fix off-by-one logic in an eviction protection test (Jon Atack)
f7b8094d61 p2p: extend inbound eviction protection by network to CJDNS peers (Jon Atack)

Pull request description:

  Extend inbound eviction protection for peers connected over CJDNS, as is the case for peers connected via onion, localhost, and I2P since #21261 and #20197.  CJDNS peers seem to have better min ping latency than onion and I2P peers but still higher than that of unencrypted IPv4/6 peers and can be disadvantaged under our eviction criteria. They are also very few in number, which is a further reason to protect them, as the goal of this logic is to favorise the diversity of our peer connections.  CJDNS support was added in #23077 for the upcoming v23 release.

ACKs for top commit:
  laanwj:
    Concept and code review ACK b7be28cac5
  w0xlt:
    tACK b7be28c

Tree-SHA512: 89ebdd217602e16ae14b9bd0d5a25fc09f9b2384c951f820bc0f5a6d8452bbc9042065db817d5d5296c0ad22988491a83fc5b9a611e660c40ebd4f03448c4061
2022-03-02 12:00:58 +01:00
laanwj
267917f563
Merge bitcoin/bitcoin#23304: wallet: Derive inactive HD chains in additional places
c4d76c6faa tests: Tests for inactive HD chains (Andrew Chow)
8077862c5e wallet: Refactor TopUp to be able to top up inactive chains too (Andrew Chow)
70134eb34f wallet: Properly set hd chain counters when loading (Andrew Chow)
961b9e4e40 wallet: Parse hdKeypath if key_origin is not available (Andrew Chow)
0652ee73ec Add size check on meta.key_origin.path (Rob Fielding)

Pull request description:

  Currently inactive HD chains are only derived from at the time a key in that chain is found to have been used. However, at that time, the wallet may not be able to derive keys (e.g. it is locked). Currently we would just move on and not derive any new keys, however this could result in missing funds.

  This PR resolves this problem by adding memory only variables to `CHDChain` which track the highest known index. `TopUp` is modified to always try to top up the inactive HD chains, and this process will use the new variables to determine how much to top up. In this way, after an encrypted wallet is unlocked, the inactive HD chains will be topped up and hopefully funds will not be missed.

  Note that because these variables are not persisted to disk (because `CHDChain`s for inactive HD chains are not written to disk), if an encrypted wallet is not unlocked in the same session as a key from an inactive chain is found to be used, then it will not be topped up later unless more keys are found.

  Additionally, wallets which do not have upgraded key metadata will not derive any keys from inactive HD chains. This is resolved by using the derivation path string in `CKeyMetadata.hdKeypath` to determine what indexes to derive.

ACKs for top commit:
  laanwj:
    Code review ACK c4d76c6faa

Tree-SHA512: b2b572ad7f1b1b2847edece09f7583543d63997e18ae32764e5a27ad608dd64b9bdb2d84ea27137894e986a8e82f047a3dba9c8015b74f5f179961911f0c4095
2022-03-02 09:35:07 +01:00
laanwj
ba11eb354b
Merge bitcoin/bitcoin#23542: net: open p2p connections to nodes that listen on non-default ports
36ee76d1af net: remove unused CNetAddr::GetHash() (Vasil Dimov)
d0abce9a50 net: include the port when deciding a relay destination (Vasil Dimov)
2e38a0e686 net: add CServiceHash constructor so the caller can provide the salts (Vasil Dimov)
97208634b9 net: open p2p connections to nodes that listen on non-default ports (Vasil Dimov)

Pull request description:

  By default, for mainnet, the p2p listening port is 8333. Bitcoin Core
  has a strong preference for only connecting to nodes that listen on that
  port.

  Remove that preference because connections over clearnet that involve
  port 8333 make it easy to detect, analyze, block or divert Bitcoin p2p
  traffic before the connection is even established (at TCP SYN time).

  For further justification see the OP of:
  https://github.com/bitcoin/bitcoin/pull/23306

ACKs for top commit:
  laanwj:
    Concept and light code review ACK 36ee76d1af
  prayank23:
    ACK 36ee76d1af
  stickies-v:
    tACK 36ee76d1a
  jonatack:
    ACK 36ee76d1af
  glozow:
    utACK 36ee76d1af

Tree-SHA512: 7f45ab7567c51c19fc50fabbaf84f0cc8883a8eef84272b76435c014c31d89144271d70dd387212cc1114213165d76b4d20a5ddb8dbc958fe7e74e6ddbd56d11
2022-03-02 09:33:03 +01:00
Jon Atack
afdf2de282
test: add CJDNS to LimitedAndReachable_Network unit tests 2022-03-01 21:03:21 +01:00
Jon Atack
2b7a8180a9
net, init: assert each network reachability is true by default
The default network reachability values are implicitly set
by this line in net.cpp:

static bool vfLimited[NET_MAX] GUARDED_BY(g_maplocalhost_mutex) = {};

This commit asserts that each network is reachable during
the first loop through them during bitcoind init.
2022-03-01 21:03:18 +01:00
laanwj
848b11615b
Merge bitcoin/bitcoin#22834: net: respect -onlynet= when making outbound connections
0eea83a85e scripted-diff: rename `proxyType` to `Proxy` (Vasil Dimov)
e53a8505db net: respect -onlynet= when making outbound connections (Vasil Dimov)

Pull request description:

  Do not make outbound connections to hosts which belong to a network
  which is restricted by `-onlynet`.

  This applies to hosts that are automatically chosen to connect to and to
  anchors.

  This does not apply to hosts given to `-connect`, `-addnode`,
  `addnode` RPC, dns seeds, `-seednode`.

  Fixes https://github.com/bitcoin/bitcoin/issues/13378
  Fixes https://github.com/bitcoin/bitcoin/issues/22647
  Supersedes https://github.com/bitcoin/bitcoin/pull/22651

ACKs for top commit:
  naumenkogs:
    utACK 0eea83a85e
  prayank23:
    reACK 0eea83a85e
  jonatack:
    ACK 0eea83a85e code review, rebased to master, debug built, and did some manual testing with various config options on signet

Tree-SHA512: 37d68b449dd6d2715843fc84d85f48fa2508be40ea105a7f4a28443b318d0b6bd39e3b2ca2a6186f2913836adf08d91038a8b142928e1282130f39ac81aa741b
2022-03-01 18:32:01 +01:00
Luke Dashjr
e8272024ab doc: Use human-friendly DefaultHint for change_address/changeAddress in wallet RPC help 2022-02-28 23:28:22 +00:00
Luke Dashjr
9d5e693c9d Bugfix: doc: Correct type of change_address/changeAddress in wallet RPC help (STR, not STR_HEX) 2022-02-28 23:27:38 +00:00
laanwj
b67ef6d59b qt: Pre-branch translation updates for 23.x
Pull the translations from transifex once before the 23.x branch-off, so
that master has at least somewhat-relevant translations.
2022-02-28 16:59:56 +01:00
laanwj
159f89c118
Merge bitcoin/bitcoin#24365: wallet: Don't generate keys for wallets with private keys disabled during upgradewallet
c7376cc8d7 tests: Test upgrading wallet with privkeys disabled (Andrew Chow)
3d985d4f43 wallet: Don't generate keys when privkeys disabled when upgrading (Andrew Chow)

Pull request description:

  When we're upgrading a wallet, we shouldn't be trying to generate new keys for wallets where private keys are disabled.

  Fixes #23610

ACKs for top commit:
  laanwj:
    Code review ACK c7376cc8d7
  benthecarman:
    tACK c7376cc8d7 this fixed the issue for me

Tree-SHA512: fa07cf37df9196ff98671bb1ce5c9aa0bab46495066b4dab796d7e8e5d5c7adb414ff56adae4fd3e15658a610995bd19a9e1edb00c46144b0df635c5b343f3a6
2022-02-28 13:15:11 +01:00
MarcoFalke
c7da61dcc3
Merge bitcoin/bitcoin#24403: Avoid implicit-integer-sign-change in VerifyLoadedChainstate
fa7991601c Fixup style of VerifyDB (MarcoFalke)
fa462ea787 Avoid implicit-integer-sign-change in VerifyLoadedChainstate (MarcoFalke)

Pull request description:

  This happens when checking all blocks (`-1`).

  To test:

  ```
  ./configure CC=clang CXX=clang++ --with-sanitizers=undefined,integer
  make
  UBSAN_OPTIONS="suppressions=$(pwd)/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1" ./test/functional/rpc_blockchain.py

ACKs for top commit:
  theStack:
    Code-review ACK fa7991601c
  brunoerg:
    crACK fa7991601c

Tree-SHA512: bcbe6becf2fbedd21bbde83a544122e79465937346802039532143b2e4165784905a8852c0ccb088b964874df5e5550931fdde3629cbcee3ae237f2f63c43a8e
2022-02-28 12:33:32 +01:00
fanquake
b71a07778f
Merge bitcoin/bitcoin#24417: net: Update hardcoded seeds for 23.x
d80dc12097 net: Update hardcoded seeds for 23.x (laanwj)
9f27157894 contrib: make-seeds updates for 23.x (laanwj)

Pull request description:

  Update hardcoded P2P network seeds for 23.x, and update the generation script and documentation as necessary

  Tool output:
  ```
    IPv4   IPv6  Onion Pass
  469910  72944      0 Initial
  469910  72944      0 Skip entries with invalid address
  469910  72944      0 After removing duplicates
  469909  72944      0 Skip entries from suspicious hosts
  165760  65113      0 Enforce minimal number of blocks
  160668  63183      0 Require service bit 1
    4951   1376      0 Require minimum uptime
    4406   1051      0 Require a known and recent user agent
    4307   1031      0 Filter out hosts with multiple bitcoin ports
  ERR: Could not resolve ASN for "2001:678:7dc:8::2": The DNS query name does not exist: 8.0.0.0.c.d.7.0.8.7.6.0.1.0.0.2.origin6.asn.cymru.com.
     512    134      0 Look up ASNs and limit results per ASN and per net
  ```.

ACKs for top commit:
  achow101:
    ACK d80dc12097
  jonatack:
    ACK d80dc12097 reviewed the changes and ran the README steps

Tree-SHA512: c651b0501cc28d397cc0778eff6aed4273669082d6ef207ce58ce198b443be66532bf1e8d618ccae3ba671ae4cccfd9b4dd2dfebacc97f3c3bd4e9fa58a3d7a3
2022-02-28 11:20:51 +00:00
MarcoFalke
40ab879f11
Merge bitcoin/bitcoin#24418: Chainparams update for 23.x
dca693e08e Update nMinimumChainWork, defaultAssumeValid for 23.x (laanwj)
85e71a3baa Update chainTxData for 23.x (laanwj)
37282dcf78 Update m_assumed_* chain parameters for 23.x (laanwj)

Pull request description:

  Update chain parameters for upcoming major release. See [doc/release-process.md](https://github.com/bitcoin/bitcoin/blob/master/doc/release-process.md) for review instructions.

  - `m_assumed_blockchain_size`, `m_assumed_chain_state_size`:

  ```
  bitcoin$ du -h .
  105M    ./blocks/index
  415G    ./blocks
  4.5G    ./chainstate
  420G    .
  bitcoin$ python3
  Python 3.9.10 (main, Jan 16 2022, 17:12:18)
  [GCC 11.2.0] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> 420 * 1.1
  462.00000000000006
  >>> 5 * 1.1
  5.5
  ```

  - `chainTxData`:
  ```
  cli getchaintxstats 4096 000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091
  {
    "time": 1645542140,
    "txcount": 712531200,
    "window_final_block_hash": "000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091",
    "window_final_block_height": 724466,
    "window_block_count": 4096,
    "window_tx_count": 6950257,
    "window_interval": 2404071,
    "txrate": 2.891036496010309
  }
  ```

  - `nMinimumChainWork`, `defaultAssumeValid`:

  ```
  $ cli getblockhash 724466 # was two from the tip at the time
  000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091
  $ cli getblockheader 000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091
  {
    "hash": "000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091",
    "confirmations": 3,
    "height": 724466,
    "version": 939515908,
    "versionHex": "37ffe004",
    "merkleroot": "35a08d9647972e7c3ec39ee7f4ab434f03445de7c446a4d1acc1254b4546bbbe",
    "time": 1645542140,
    "mediantime": 1645539567,
    "nonce": 188699556,
    "bits": "170a1078",
    "difficulty": 27967152532434.23,
    "chainwork": "00000000000000000000000000000000000000002927cdceccbd5209e81e80db",
    "nTx": 1948,
    "previousblockhash": "000000000000000000075e26c23c2ecec4e34699411ccd712ff6f2d252f65a78",
    "nextblockhash": "0000000000000000000905369cd69f68323e3e8da2933a78bea0b2cdb8baa89f"
  }
  ```

ACKs for top commit:
  Sjors:
    ACK dca693e08e
  achow101:
    ACK dca693e08e
  prayank23:
    ACK dca693e08e
  darosior:
    ACK dca693e08e -- only checked mainnet (on muliple nodes). Didn't do a reindex.

Tree-SHA512: 6d5d59f00717fce5f7ce10ec8d59f806ef11b0af21440cec112f70c8e13ebb884ba6c70e744e691fcc31fe7aec7aae968268c9207ccc820d64fdf7e7f98f0cff
2022-02-28 12:09:41 +01:00
eugene
fc471814dc
fuzz: FuzzedFileProvider::write should not return negative value
Doing so can lead to a glibc crash. Also the manpage for fopencookie
warns against this: https://man7.org/linux/man-pages/man3/fopencookie.3.html
2022-02-27 17:03:35 -05:00
Ryan Ofsky
691d45fdc8 Add coinstatsindex_unclean_shutdown test 2022-02-25 16:06:27 -05:00
MarcoFalke
bbbbeaf9c8
fuzz: Limit script_format to 100kB 2022-02-25 17:09:37 +01:00
MarcoFalke
fa097d074b
addrman: Log too low compat value
Also remove uint8_t{} casts from values that are already of the same
type.
2022-02-25 14:16:32 +01:00
MarcoFalke
aaaa4dbab4
Avoid implicit-integer-sign-change in bech32.cpp 2022-02-25 09:43:54 +01:00
MarcoFalke
b00b60ed4f
Merge bitcoin/bitcoin#24201: p2p: Avoid InitError when downgrading peers.dat
d41ed32153 p2p: Avoid InitError when downgrading peers.dat (junderw)

Pull request description:

  fixes #24188 (also see https://github.com/bitcoin/bitcoin/pull/22762#issuecomment-951063826)
  When downgrading, a peers.dat with a future version that has a minimum
  required version larger than the downgraded Bitcoin Core version would cause an InitError.

  This commit changes this behavior to overwrite the existing peers.dat with
  a new empty one.

ACKs for top commit:
  prayank23:
    reACK d41ed32153
  kallewoof:
    reACK d41ed32153

Tree-SHA512: c8e625fe36ce0b1aab6c8ef7241c8954038bb856f2de27bdc4814dc9a60e51be28815c7d77d0f96eace49687a0cea02deb713978bbd3a5add742f50a675f2a40
2022-02-25 08:45:11 +01:00
junderw
d41ed32153
p2p: Avoid InitError when downgrading peers.dat
fixes #24188
When downgrading, a peers.dat with a future version that has a minimum
required version larger than the downgraded version would cause an InitError.

This commit changes this behavior to overwrite the existing peers.dat with
a new empty one, while creating a backup in peers.dat.bak.
2022-02-25 09:53:10 +09:00
laanwj
dca693e08e Update nMinimumChainWork, defaultAssumeValid for 23.x
Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>
2022-02-24 16:19:09 +01:00
laanwj
85e71a3baa Update chainTxData for 23.x
Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>
2022-02-24 16:19:09 +01:00
laanwj
37282dcf78 Update m_assumed_* chain parameters for 23.x
- `m_assumed_chain_state_size` doesn't seem to need to be changed for mainnet.
- No change needed for testnet/signet.

Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>
2022-02-24 14:06:53 +01:00
Sjors Provoost
026b5b4523
move-only: helper function to present PSBT
This commit does not change behavior.

Review hint:
git show --color-moved --color-moved-ws=allow-indentation-change
2022-02-24 12:41:47 +01:00
laanwj
38020c4f2e qt: English (source) translations update
Last-minute update for bitcoin/bitcoin#24434 and bitcoin/bitcoin#24401.
2022-02-24 12:40:00 +01:00
Hennadii Stepanov
ff33c5ae63
Add missed word to error message 2022-02-24 02:59:38 +02:00
Andrew Chow
8d6f9210d9
Merge bitcoin/bitcoin#24401: wallet: Add external-signer-support specific error message
7f3a6a9495 wallet: Add external-signer-support specific error message (Hennadii Stepanov)

Pull request description:

  On master (5f44c5c428) an attempt to load an external signer wallet using Bitcoin Core compiled without external signer support fails with the following log messages:
  ```
  2022-02-20T19:01:11Z [qt-walletctrl] Using SQLite Version 3.31.1
  2022-02-20T19:01:11Z [qt-walletctrl] Using wallet /home/hebasto/.bitcoin/testnet3/wallets/coldcard-0220
  2022-02-20T19:01:11Z [qt-walletctrl] init message: Loading wallet…
  2022-02-20T19:01:11Z [qt-walletctrl] [coldcard-0220] Error: External signer wallet being loaded without external signer support compiled
  2022-02-20T19:01:11Z [qt-walletctrl] [coldcard-0220] Releasing wallet
  ```

  While log messages are good, a message in the GUI window is completely misleading:

  ![Screenshot from 2022-02-20 20-43-46](https://user-images.githubusercontent.com/32963518/154859854-b87032e0-c428-4e11-8009-39e38200482c.png)

  This PR fixes this issue:

  ![Screenshot from 2022-02-20 21-01-18](https://user-images.githubusercontent.com/32963518/154859868-e3a2c89d-4f0f-424e-96cb-7accaa48acc0.png)

ACKs for top commit:
  achow101:
    ACK 7f3a6a9495
  kristapsk:
    ACK 7f3a6a9495
  brunoerg:
    crACK 7f3a6a9495

Tree-SHA512: a4842751c0ca8a37ccc3ea00503678f6b712a7f53d6cbdc07ce02dcb85ca8a94890d1c2da20307be043faa347747abeba29185c88ba12edd5253bfca56531585
2022-02-23 17:19:49 -05:00
laanwj
358fe779cb
Merge bitcoin/bitcoin#24381: test: Run symlink regression tests on Windows
fad7ddf9e3 test: Run symlink regression tests on Windows (MarcoFalke)

Pull request description:

  Seems odd to add tests, but not run them on the platform that needs them most.

ACKs for top commit:
  laanwj:
    Code review ACK fad7ddf9e3
  ryanofsky:
    Code review ACK fad7ddf9e3, just removing new test. Would be nice if the test could be added later, of course.

Tree-SHA512: 64b235967a38c2eb90657e8d7a0447bcc8ce81d1b75a275b6c48bd42efd9ea7e7939257e484f297ee84598def3738eaeb289561aeba1dd6a99b258d389995139
2022-02-23 15:48:55 +01:00
fanquake
9977e1658c
Merge bitcoin/bitcoin#24372: bench: Avoid deprecated use of volatile +=
9999f891d1 bench: Avoid deprecated use of volatile += (MarcoFalke)

Pull request description:

  Deprecated in C++20 according to https://eel.is/c++draft/expr.ass#6 .

  ```
  bench/examples.cpp:16:13: warning: compound assignment with ‘volatile’-qualified left operand is deprecated [-Wvolatile]
     16 |         sum += sin(d);
        |         ~~~~^~~~~~~~~
  ```

  While C++20 is currently unsupported, I don't see any downside to a minor fixup to an example benchmark. This will also make a hypothetical C++20 patch smaller.

ACKs for top commit:
  fanquake:
    ACK 9999f891d1

Tree-SHA512: ca7d660fa8eba347a4648408a8b97a0ecb8263a825da7abd59129d783058102581e05b273667989f95480436a66d5384bd1e92d9ae79408f5b30e2178935cc38
2022-02-23 11:29:39 +00:00
fanquake
16d05cf6b9
Merge bitcoin/bitcoin#24406: test: Fix Wambiguous-reversed-operator compiler warnings
fafc4eb363 test: Fix Wambiguous-reversed-operator compiler warnings (MarcoFalke)

Pull request description:

  Add a missing const to avoid the C++20 clang **compiler warning**:

  ```
  test/fuzz/addrman.cpp:325:22: error: ISO C++20 considers use of overloaded operator '==' (with operand types 'AddrManDeterministic' and 'AddrManDeterministic') to be ambiguous despite there being a unique best viable function [-Werror,-Wambiguous-reversed-operator]
      assert(addr_man1 == addr_man2);
             ~~~~~~~~~ ^  ~~~~~~~~~
  /usr/include/assert.h:93:27: note: expanded from macro 'assert'
       (static_cast <bool> (expr)                                         \
                            ^~~~
  test/fuzz/addrman.cpp:140:10: note: ambiguity is between a regular call to this operator and a call with the argument order reversed
      bool operator==(const AddrManDeterministic& other)
           ^
  1 error generated.
  ```

  This patch also fixes the **compile error** if the first operand is `const`:

  ```
  test/fuzz/addrman.cpp:326:23: error: invalid operands to binary expression ('const AddrManDeterministic' and 'AddrManDeterministic')
      assert(addr_man_1 == addr_man2);
             ~~~~~~~~~~ ^  ~~~~~~~~~
  /usr/include/assert.h:90:27: note: expanded from macro 'assert'
       (static_cast <bool> (expr)                                         \
                            ^~~~
  test/fuzz/addrman.cpp:140:10: note: candidate function not viable: 'this' argument has type 'const AddrManDeterministic', but method is not marked const
      bool operator==(const AddrManDeterministic& other)
           ^
  1 error generated.

ACKs for top commit:
  hebasto:
    ACK fafc4eb363, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 92cd62ae06ee1393a6dc2ea6f3f553595a8f8d66f51592d231b42122bfb71ed4801a016daafc85360040339c5ae59b76888265cec37449c4688d6c7768f4567e
2022-02-23 11:19:02 +00:00
glozow
40e871d9b4 [miner] always assume we can create witness blocks
Given the low possibility of a reorg reverting the segwit soft fork,
there is no need to check whether segwit is active here. Also,
TestBlockValidity is run on the block template after it has been
created.
2022-02-23 10:55:05 +00:00
MarcoFalke
faa329fd46
refactor: Release cs_main before MaybeSendFeefilter 2022-02-23 10:26:54 +01:00
MarcoFalke
faa1aec26b
Remove confusing P1008R1 violation in ATMPArgs 2022-02-23 10:15:26 +01:00
Carl Dong
6c23c41561 refactor: Rewrite AddToBlockIndex with try_emplace 2022-02-22 11:56:49 -05:00
Carl Dong
c05cf7aa1e style: Modernize range-based loops over m_block_index 2022-02-22 11:56:49 -05:00
Carl Dong
c2a1655799 style-only: Use using instead of typedef for BlockMap 2022-02-22 11:56:49 -05:00
Carl Dong
dd79dad175 refactor: Rewrite InsertBlockIndex with try_emplace
Credit to ajtowns for this suggestion, thanks!
2022-02-22 11:56:49 -05:00
Carl Dong
531dce0347 tests: Remove now-unnecessary manual Unload's
These manual calls to Unload() are no longer necessary because
CBlockIndex's no longer live in the heap as of the previous commit.
2022-02-22 11:56:49 -05:00
Carl Dong
bec86ae326 blockstorage: Make m_block_index own CBlockIndex's
Instead of having CBlockIndex's live on the heap, which requires manual
memory management, have them be owned by m_block_index. This means that
they will live and die with BlockManager.

A change to BlockManager::LookupBlockIndex:
- Previously, it was a const member function returning a non-const CBlockIndex*
- Now, there's are const and non-const versions of
  BlockManager::LookupBlockIndex returning a CBlockIndex with the same
  const-ness as the member function:
    (e.g. const CBlockIndex* LookupBlockIndex(...) const)

See next commit for some weirdness that this eliminates.

The range based for-loops are modernize (using auto + destructuring) in
a future commit.
2022-02-22 11:52:19 -05:00
fanquake
2618fb8d15
Output license info when binaries are passed -version
Consolidate to outputting the licensing info when we pass -version to a binary,
i.e bitcoind -version:
```bash
itcoin Core version v22.99.0-fc1f355913f6-dirty
Copyright (C) 2009-2022 The Bitcoin Core developers

Please contribute if you find Bitcoin Core useful. Visit
<https://bitcoincore.org/> for further information about the software.
The source code is available from <https://github.com/bitcoin/bitcoin>.

This is experimental software.
Distributed under the MIT software license, see the accompanying file COPYING
or <https://opensource.org/licenses/MIT>
```
2022-02-22 15:36:19 +00:00
fanquake
4c3e3c5746
refactor: shift CopyrightHolders() and LicenseInfo() to clientversion.cpp 2022-02-22 15:36:19 +00:00
laanwj
d80dc12097 net: Update hardcoded seeds for 23.x 2022-02-22 15:15:27 +01:00
Hennadii Stepanov
c5158290af
qt: Update translation source file 2022-02-22 14:12:20 +02:00
laanwj
8add59d77d
Merge bitcoin/bitcoin#24367: User-facing content and codebase doc fixups from transifex translator feedback
48742693ac Replace "can not" with "cannot" in docs, user messages, and tests (Jon Atack)
e670edd434 User-facing content fixups from transifex translator feedback (Jon Atack)

Pull request description:

  Closes #24366.

ACKs for top commit:
  laanwj:
    Code review re-ACK 48742693ac
  hebasto:
    re-ACK 48742693ac, only suggested change since my previous [review](https://github.com/bitcoin/bitcoin/pull/24367#pullrequestreview-885938219).

Tree-SHA512: 4dcdcb417251a413e65fab6070515e13a1267c8e0dbcf521386b842511391f24c84a0c2168fe13458c977682034466509bf2a3453719d4d94d3c568fd9f4adb4
2022-02-22 13:08:08 +01:00
MarcoFalke
e200919cbe
Merge bitcoin/bitcoin#24305: Docs: [policy] Remove outdated confusing comment
e50a9be154 Remove outdated comment on CFeeRate (Murch)

Pull request description:

  This comment described how the constructor of CFeeRate was previously indirectly used to parse fee rate arguments from RPCs. The command line input was actually in sat/vB but due to the use of AmountFromValue() it got converted to BTC/vB which then got rectified in the constructor by creating a CFeeRate from that given value and COIN as the transaction size. Since this usage pattern was removed from the codebase some months ago, the comment is now obsolete.

ACKs for top commit:
  michaelfolkson:
    ACK e50a9be154
  jonatack:
    ACK e50a9be154

Tree-SHA512: f17bf0baeeca85a5c7883edadd407da845f6e3af1c949e93116bd67c02e601682a5f7f1ab2497172472e3acf1c4e3c234b01161a77e7d7f028e3551da34777f0
2022-02-22 11:19:38 +01:00
fanquake
bc49650b7c
Merge bitcoin/bitcoin#24310: docs / fixups from RBF and packages
77202f0554 [doc] package deduplication (glozow)
d35a3cb396 [doc] clarify inaccurate comment about replacements paying higher feerate (glozow)
5ae187f876 [validation] look up transaction by txid (glozow)

Pull request description:

  - Use txid, not wtxid, for `mempool.GetIter()`: https://github.com/bitcoin/bitcoin/pull/22674#discussion_r772934994
  - Fix a historically inaccurate comment about RBF during the refactors: https://github.com/bitcoin/bitcoin/pull/22855#discussion_r777130441
  - Add a section about package deduplication to policy/packages.md: https://github.com/bitcoin/bitcoin/pull/24152#discussion_r802955759 and https://github.com/bitcoin/bitcoin/pull/24152#discussion_r802723149

  (I'm intending for this to be in v23 since it's fixups for things that are already merged, which is why I split it from #24152)

ACKs for top commit:
  t-bast:
    LGTM, ACK 77202f0554
  darosior:
    ACK 77202f0554
  LarryRuane:
    ACK 77202f0554

Tree-SHA512: a428e791dfa59c359d3ccc67e8d3a4c1239815d2f6b29898e129700079271c00b3a45f091f70b65a6e54aa00a3d5b678b6da29d2a76b6cd6f946eaa7082ea696
2022-02-22 09:17:02 +00:00
Hennadii Stepanov
00f8492eeb
Merge bitcoin-core/gui#547: Override BitcoinApplication::event() to handle QEvent::Quit
e7fc50681e qt: Override BitcoinApplication::event() to handle QEvent::Quit (Hennadii Stepanov)

Pull request description:

  bitcoin-core/gui#336 introduced a regression when termination requests from a platform are not handled properly.

  This PR fixes this regression. On macOS shutdown after clicking "Quit" in Dock icon menu, and during logout works again.

  Fixes bitcoin-core/gui#545.

ACKs for top commit:
  RandyMcMillan:
    tACK e7fc50681e
  Sjors:
    tACK e7fc50681e (rebased on master) indeed fixes the crash described in #545
  promag:
    Tested ACK e7fc50681e on macOS 10.15 with Qt 5.15.2.

Tree-SHA512: 236a483dc0828f22999469e133b8ac9f0b6267ec2a27004c3ebaa967689ddb972ea1fa90c1dd41f3bff3d17bf571a707babcef53bd79fd711fda98cfbf120131
2022-02-22 10:35:15 +02:00
Jon Atack
48742693ac
Replace "can not" with "cannot" in docs, user messages, and tests 2022-02-21 19:07:29 +01:00
Martin Zumsande
eb6cc05da3 index: Commit DB_MUHASH and DB_BEST_BLOCK to disk together
If these are written to disk at different times,
unclean shutdowns can lead to index corruption.
2022-02-21 11:37:19 -05:00
MarcoFalke
48a90c61e2
Merge bitcoin/bitcoin#24370: rpc, cli: describe quality/recency filtering in getnodeaddresses and -addrinfo
ce690847b6 cli: describe quality/recency filtering in -addrinfo (Jon Atack)
7c975614c0 rpc: describe quality/recency filtering in getnodeaddresses (Jon Atack)

Pull request description:

  Addresses #24278.

  ```
  $ bitcoin-cli help getnodeaddresses
  getnodeaddresses ( count "network" )

  Return known addresses, after filtering for quality and recency.
  These can potentially be used to find new peers in the network.
  The total number of addresses known to the node may be higher.
  ```
  ```
  $ bitcoin-cli -help | grep -A3 addrinfo
    -addrinfo
         Get the number of addresses known to the node, per network and total,
         after filtering for quality and recency. The total number of
         addresses known to the node may be higher.
  ```

ACKs for top commit:
  mzumsande:
    Thanks, Code Review ACK ce690847b6
  prayank23:
    reACK ce690847b6

Tree-SHA512: 82d23b15e64a99411eb8e70d7267a1b4f23182fabe072e824277569d9677e392b466be63f00e3d157d7db94bbe032d53f12ad4ab30b55b7b8a629c37d80d1d8c
2022-02-21 16:44:22 +01:00
MarcoFalke
fafc4eb363
test: Fix Wambiguous-reversed-operator compiler warnings 2022-02-21 16:36:59 +01:00
MarcoFalke
faa7d8a3f7
util: Add SaturatingAdd helper 2022-02-21 14:32:53 +01:00
Jon Atack
ce690847b6
cli: describe quality/recency filtering in -addrinfo
Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
2022-02-21 14:16:48 +01:00
Jon Atack
7c975614c0
rpc: describe quality/recency filtering in getnodeaddresses
Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
2022-02-21 14:16:34 +01:00
MarcoFalke
1337b93f50
Merge bitcoin/bitcoin#24339: rpc: Improve RPC help by explicitly mentioning output types
c821ab8be8 Use `GetAllOutputTypes` in `getblock` RPC function (Kiminuo)
d970a85d33 Move `GetAllOutputTypes` function from `rpc/rawtransaction.cpp` to `rpc/util.{h|cpp}` (Kiminuo)

Pull request description:

  This PR attempts to replicate 0ccf9b2e55/src/rpc/rawtransaction.cpp (L547) to one other place (at the moment) so that users have better idea what RPC methods can actually return.

  I created this PR as a follow-up to the idea mentioned here https://github.com/bitcoin/bitcoin/pull/23320#discussion_r732458112 (resolved).

ACKs for top commit:
  kristapsk:
    re-ACK c821ab8be8

Tree-SHA512: 5ff66a41ad7c43ec769f4a99933d2d070feea7c617286d94b6f9bfa1a2547a42211915778210a89074ad4b14d99f34852cc6871efed5e6f1e2ffedd40d669386
2022-02-21 13:58:09 +01:00
fanquake
85ae549a46
Merge bitcoin/bitcoin#24137: doc: Rework generate* doc
fa30e62cc6 doc: Rework generate* doc (MarcoFalke)

Pull request description:

  Hide the test-only calls and clarify the short description

ACKs for top commit:
  0xB10C:
    reACK fa30e62cc6. changes since fa3bb584dcc742a767b2141cd7324877e3cf5302 are: dropping the `immediately` + formatting the touched line and a rebase

Tree-SHA512: 07439f39660bbf144c2cc406b6010b64dcdd27150d78654fe04a36a982a519f837a0cf0f030c9f30af69c451ccf7a3b7287a275637aa81904c202029b9efc661
2022-02-21 12:19:11 +00:00
Kiminuo
c821ab8be8 Use GetAllOutputTypes in getblock RPC function 2022-02-21 12:56:43 +01:00
fanquake
72f97289c4
Merge bitcoin/bitcoin#24343: Add descriptor_tests covering tr(), and fix minor bugs
0683f377e1 Add tr() descriptor unit tests (Pieter Wuille)
4b2e31a7ae Bugfix: make ToPrivateString work with x-only keys (Pieter Wuille)
18ad54c3b2 Bugfix: set x-only flag when inferring pk() inside tr() (Pieter Wuille)

Pull request description:

  This fixes two bugs in the current logic for `tr()` descriptors:
  * ToPrivateString does not always work, because the provided private key may mismatch the parity of the x-only public key.
  * The descriptors inferred for `pk()` inside `tr()` have the wrong x-only flag, leading to such descriptors generating the wrong scriptPubKey (roundtripping through ToString does fix it however, so this seems unobservable in the current code).

  These were discovered while adding unit tests to descriptor_tests that cover various aspects of `tr()` descriptors, which are now also added here.

ACKs for top commit:
  achow101:
    ACK 0683f377e1
  instagibbs:
    ACK 0683f377e1
  jonatack:
    Code review ACK 0683f377e1

Tree-SHA512: fc0e11b45da53054a108effff2029d67b64e508b160a6e22e00c98b506c39ec12ccc95afd21ea68a6c691eb62930afc7af18908f2fa3a954d102afdc67bc355a
2022-02-21 10:16:42 +00:00
MarcoFalke
fa30e62cc6
doc: Rework generate* doc
Can be reviewed with --word-diff-regex=. --ignore-all-space
2022-02-21 11:02:20 +01:00
MarcoFalke
fa7991601c
Fixup style of VerifyDB 2022-02-21 10:39:41 +01:00
MarcoFalke
fa462ea787
Avoid implicit-integer-sign-change in VerifyLoadedChainstate 2022-02-21 10:29:37 +01:00
MarcoFalke
cf22191fd8
Merge bitcoin/bitcoin#24072: doc: fix wording of alertnotify to match behaviour
6981de4435 doc: fix wording of alertnotify (willcl-ark)

Pull request description:

  The documentation of the `alertnotify` startup option no longer matches the implementation.

  Currently the alert is only triggered by `DoWarning` (as part of `CChainstate::UpdateTip` when blocks containing unknown versionbits are detected on the network, indicating that there may be an upcoming softfork which you don't know about), but not when we see a "really long fork":

  2825c41a61/src/validation.cpp (L2418-L2433)

  I think it would be desirable in a follow-up PR to implement the logic to alert on a (really) long fork, but not to alert for "partition detection" (abnormally slow/fast blocks). `PartitionChecker` code was removed in ab8be98fdb

ACKs for top commit:
  josibake:
    ACK 6981de4435
  achow101:
    ACK 6981de4435

Tree-SHA512: ea124f53ca1db803ba93d649f4bc983484c47fb5fe7fa61a8eb32fcbc7425f67d8578e66a6ba70202e13868fe8add0103306dede3b1edd1d3261ffb9c1042b87
2022-02-21 08:16:31 +01:00
MarcoFalke
4acf2332d4
Merge bitcoin/bitcoin#24376: doc: bitcoin-wallet fixes (help output and code comment)
62cc138ecb Rename wallet-tool to bitcoin-wallet in code comment (Kristaps Kaupe)
0db3ad3ba4 Mention -signet in bitcoin-wallet help output (Kristaps Kaupe)

Pull request description:

  * Mention `-signet` in sentence where there is already `-testnet/-signet` in help output.
  * Rename `wallet-tool` to `bitcoin-wallet` in single remaining place in code comments (was already done in #17648 at other places).

ACKs for top commit:
  RandyMcMillan:
    tACK 62cc138ecb

Tree-SHA512: c5df7811b8200f61943908dcf3b2b788fe991bf00bef28f069ab8784924556ffd5d86fc0ba2ad0b3c3f9be2ba73a34bc67059d7c057bba646c1801ffa3cb2070
2022-02-21 08:14:44 +01:00
MarcoFalke
abaf943477
Merge bitcoin/bitcoin#24231: streams: Fix read-past-the-end and integer overflows
fa1b89a6bd scripted-diff: Rename nReadPos to m_read_pos in streams.h (MarcoFalke)
fa56c79df9 Make CDataStream work properly on 64-bit systems (MarcoFalke)
fab02f7991 streams: Fix read-past-the-end and integer overflows (MarcoFalke)

Pull request description:

  This is a follow-up to commit e26b62093a with the following fixes:

  * Fix unsigned integer overflow in `ignore()`, when `nReadPos` wraps.
  * Fix unsigned integer overflow in `read()`, when `nReadPos` wraps.
  * Fix read-past-the-end in `read()`, when `nReadPos` wraps.

  This shouldn't be remote-exploitable, because it requires a stream of more than 1GB of size. However, it might be exploitable if the attacker controls the datadir (I haven't checked).

  A unit test for the overflow in `ignore()` looks like following. It is left as an excercise to the reader to replace `foo.ignore(7)` with the appropriate call to `read()` to reproduce the overflow and read-error in `read()`.

  ```diff
  diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp
  index 922fd8e513..ec6ea93919 100644
  --- a/src/test/coins_tests.cpp
  +++ b/src/test/coins_tests.cpp
  @@ -534,6 +534,20 @@ BOOST_AUTO_TEST_CASE(ccoins_serialization)
       } catch (const std::ios_base::failure&) {
       }

  +    CDataStream foo{0, 0};
  +    auto size{std::numeric_limits<uint32_t>::max()};
  +    foo.resize(size);
  +    BOOST_CHECK_EQUAL(foo.size(), size);
  +    foo.ignore(std::numeric_limits<int32_t>::max());
  +    size -= std::numeric_limits<int32_t>::max();
  +    BOOST_CHECK_EQUAL(foo.size(), size);
  +    foo.ignore(std::numeric_limits<int32_t>::max());
  +    size -= std::numeric_limits<int32_t>::max();
  +    BOOST_CHECK_EQUAL(foo.size(), size);
  +    BOOST_CHECK_EQUAL(foo.size(), 1);
  +    foo.ignore(7); // Should overflow, as the size is only 1
  +    BOOST_CHECK_EQUAL(foo.size(), uint32_t(1 - 7));
  +
       // Very large scriptPubKey (3*10^9 bytes) past the end of the stream
       CDataStream tmp(SER_DISK, CLIENT_VERSION);
       uint64_t x = 3000000000ULL;
  ```

ACKs for top commit:
  klementtan:
    Code Review ACK fa1b89a6bd:

Tree-SHA512: 67f0a1baafe88eaf1dc844ac55b638d5cf168a18c945e3bf7a2cb03c9a5976674a8e3af2487d8a2c3eae21e5c0e7a519c8b16ee7f104934442e2769d100660e9
2022-02-21 08:09:18 +01:00
MarcoFalke
7cc39b1838
Merge bitcoin/bitcoin#24347: rpc: Fix implicit-integer-sign-change in verifychain
fa8dad0e07 rpc: Fix implicit-integer-sign-change in verifychain (MarcoFalke)

Pull request description:

  It doesn't really make sense to treat `DEFAULT_CHECKLEVEL` as unsigned as long as `VerifyDB` accepts a signed integer.

  Making it signed also avoids a cast round trip from signed->unsigned->signed in the RPC.

ACKs for top commit:
  luke-jr:
    utACK fa8dad0e07
  theStack:
    Code-review ACK fa8dad0e07

Tree-SHA512: 75499dbe4ace2962792e5fbec7defb10c25fdbbfde951d5e542a91daa880cc50395da0287173e2c84a28e18267c74af7b44b9f38ce364bcb0216c402f65b7641
2022-02-21 07:52:57 +01:00
Hennadii Stepanov
7f3a6a9495
wallet: Add external-signer-support specific error message 2022-02-20 21:04:23 +02:00
fanquake
5f44c5c428
Merge bitcoin/bitcoin#24133: index: Improve robustness of coinstatsindex at restart
820c03aff5 index: check muhash is in sync on coinstatsindex launch (Fabian Jahr)
38ed58b850 index: remove txindex references from base index (Fabian Jahr)

Pull request description:

  This change lets the `coinstatsindex` fail loudly in case the internal `muhash` state differs from the last finalized output saved on disk, which would indicate that the `muhash` state somehow got out of sync. This should generally not happen since both are written to disk in a batch but #24076 seems to indicate that the might still be an issue.

  Since #24076 so far can not be reproduced reliably, the issue should not be closed yet. Further investigation and testing needs to be done.

ACKs for top commit:
  Sjors:
    re-ACK 820c03aff5
  mzumsande:
    re-ACK 820c03aff5
  ryanofsky:
    Code review ACK 820c03aff5. Good to catch the error earlier

Tree-SHA512: 3c985d7152698d25bad95d4ad512ff87dff13fabef790589c5a6cf93ca4251ad599e12feb7251a084503e2a213b022eaacfbaaa601464114ad372b029f64f204
2022-02-20 11:30:42 +00:00
fanquake
ffcbaf569e
Merge bitcoin/bitcoin#24369: util: Add missing rseq to syscall sandbox
6c4fd36089 util: Add missing rseq to syscall sandbox (laanwj)

Pull request description:

  Fixes #24368.

ACKs for top commit:
  prusnak:
    Approach ACK 6c4fd36

Tree-SHA512: fc01b99483581280fc5dcbd3367975677849eadf2aabb66850dd0fa40bba9c3979c67d96427c1f4feff948b68744797c4a3ec0a12fc983d91642da794fcea824
2022-02-20 11:29:29 +00:00
fanquake
2b0735d183
Merge bitcoin/bitcoin#23907: tracing: utxocache tracepoints follow up for #22902
799968e8b3 tracing: misc follow-ups to 22902 (0xb10c)
36a6584703 tracing: correctly scope utxocache:flush tracepoint (Arnab Sen)

Pull request description:

  This PR is a follow-up to the [#22902](https://github.com/bitcoin/bitcoin/pull/22902).

  Previously, the tracepoint `utxocache:flush` was called, even when it was not flushing. So, the tracepoint is now scoped to write only when coins cache to disk.

ACKs for top commit:
  0xB10C:
    ACK 799968e8b3

Tree-SHA512: ebb096cbf991c551c81e4339821f10d9768c14cf3d8cb14d0ad851acff5980962228a1c746914c6aba3bdb27e8be53b33349c41efe8bab5542f639916e437b5f
2022-02-20 11:27:54 +00:00
klementtan
a84650ebd5
util: Fix ReadBinaryFile reading beyond maxsize 2022-02-19 18:39:43 +08:00
MarcoFalke
a6c3da131c
Merge bitcoin/bitcoin#24350: Primitives: Correct CTransaction deserialization docstring
d4b3483cec Primitives: Correct CTransaction deserialization docstring (TheCharlatan)

Pull request description:

  Since https://github.com/bitcoin/bitcoin/pull/8589 CTxWitness was removed and instead replaced with CScriptWitness inside each CTxIn.

ACKs for top commit:
  w0xlt:
    ACK d4b3483

Tree-SHA512: 02bb73e8a7d1fc449e4776a162009261baecc573837fade74ad7d76b3cd63200424e02fd0abd000c63706072f2ab3c95d3053139495b81347463f43e56192ca9
2022-02-19 09:35:10 +01:00
MarcoFalke
fad7ddf9e3
test: Run symlink regression tests on Windows 2022-02-18 15:27:08 +01:00
Kiminuo
5d7f22595f Do not use LocalTestingSetup in getarg_tests test file. 2022-02-18 07:12:57 -05:00
MarcoFalke
66636ca438
Merge bitcoin/bitcoin#24360: doc: improve -netinfo help based on feedback from users and devs
a4da16fbd4 Improve -netinfo help based on feedback from users and devs (Jon Atack)

Pull request description:

  Clarify which networks are displayed by the peer counts table (*reachable* networks; follow-up to #23324) in response to questions received over the past months, and a few other improvements.

ACKs for top commit:
  laanwj:
    Code review ACK a4da16fbd4
  w0xlt:
    ACK a4da16f
  kristapsk:
    utACK a4da16fbd4

Tree-SHA512: e6522c08421aa7f10d50723156d0a8fc5ec82cad2f0bd931bbec603077fcd4921c6505ef743d57386fba81c95dcfc77df75abf3378319886368e4ae33f9a6d73
2022-02-18 07:32:06 +01:00
Kristaps Kaupe
62cc138ecb
Rename wallet-tool to bitcoin-wallet in code comment 2022-02-18 07:30:05 +02:00
Kristaps Kaupe
0db3ad3ba4
Mention -signet in bitcoin-wallet help output 2022-02-18 07:29:06 +02:00
fanquake
edc0d327f1
Merge bitcoin/bitcoin#24349: fuzz: Split script formatting from script fuzz target
fae3f17823 fuzz: Split script formatting from script fuzz target (MarcoFalke)

Pull request description:

  This is a follow-up to commit 9237bdaac1.

  The target was improved a bit, but is still taking enormously long. See for example 4096 seconds in https://cirrus-ci.com/task/5153886888525824?logs=ci#L4451.

  Most of the time is spent formatting the script. See the flamegraph: ![flame](https://user-images.githubusercontent.com/6399679/154052491-ad868078-42e6-4d85-9c77-c2e7e8291a9f.png)

  Thus, I suggest to split up the formatting into a new target. This will:

  * Allow more fuzz cycles in the `script` target when exploring the search space with the fuzz engine
  * Hopefully allow to reduce the fuzz inputs in `qa-assets` without losing coverage

ACKs for top commit:
  fanquake:
    ACK fae3f17823

Tree-SHA512: f86154b23019b7721e5dd10f54d11f4f7603d280471a396cb5256f4c460f48333318a60efe8b77fa8749a4abc67ad2631211b766fde5da70ded9fab8f904747b
2022-02-17 16:48:44 +00:00
fanquake
003523d239
Merge bitcoin/bitcoin#24338: util: Work around libstdc++ create_directories issue
b223c3c21e test: Add functional test for symlinked blocks directory (laanwj)
ddb75c2e87 test: Add fs_tests/create_directories unit test (Hennadii Stepanov)
1f46b6e46e util: Work around libstdc++ create_directories issue (laanwj)

Pull request description:

  Work around libstdc++ issue [PR101510] with create_directories where the leaf already exists as a symlink. Fixes #24257, introduced by the switch to `std::filesystem`. It is meant to be more thorough than #24266, which worked around one instance of the problem.

  The issue was [fixed upstream](https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=124eaa50e0a34f5f89572c1aa812c50979da58fc), but unfortunately we'll have to carry a fix for it for a while.

  This introduces a function `fs::create_directories` which wraps
  `std::filesystem::create_directories`. This allows easiliy reverting the
  workaround when it is no longer necessary.

ACKs for top commit:
  jonatack:
    re-ACK b223c3c21e per `git range-diff df08250 67019cd b223c3c`
  hebasto:
    re-ACK b223c3c21e
  w0xlt:
    re-ACK b223c3c
  vasild:
    ACK b223c3c21e

Tree-SHA512: 028321717c8b10d16185c3711b35da6b05fb7aa31cee1c8c7e754e92bf5a0b02719a3785cd0f6f8bf052b3bd759f644af212320672baabc9e44e0b93ba464abc
2022-02-17 16:29:10 +00:00
MarcoFalke
9999f891d1
bench: Avoid deprecated use of volatile += 2022-02-17 17:25:57 +01:00
laanwj
6c4fd36089 util: Add missing rseq to syscall sandbox
Fixes #24368.
2022-02-17 15:01:43 +01:00
laanwj
922c49a138
Merge bitcoin/bitcoin#23819: ConnectBlock: don't serialize block hash twice
eb8b22d517 block_connected: re-use previous GetTimeMicros (William Casarin)
80e1c55687 block_connected: don't serialize block hash twice (William Casarin)

Pull request description:

  In the validation:block_connected tracepoint, we call block->GetHash(), which
  ends up calling CBlockHeader::GetHash(), executing around 8000 serialization
  instructions. We don't need to do this extra work, because block->GetHash() is
  already called further up in the function. Let's save that value as a local
  variable and re-use it in our tracepoint so there is no unnecessary tracepoint
  overhead.

  Shave off an extra 100 or so instructions from the validation:block_connected
  tracepoint by reusing a nearby GetTimeMicros(). This brings the tracepoint down
  to 54 instructions.  Still high, but much better than the previous ~154 and
  8000 instructions which it was originally.

  Signed-off-by: William Casarin <jb55@jb55.com>

ACKs for top commit:
  0xB10C:
    ACK eb8b22d517
  laanwj:
    Code review ACK eb8b22d517
  theStack:
    re-ACK eb8b22d517

Tree-SHA512: 92ae585e487554e0f73042a8abaa239f630502c1d198e010bd7c1de252d882bccb627bbf0e4faec09c1253e782b145bcf153f9fee78cdb8456188044a96f8267
2022-02-17 14:10:13 +01:00
Jon Atack
e670edd434
User-facing content fixups from transifex translator feedback 2022-02-17 12:59:30 +01:00
Hennadii Stepanov
ddb75c2e87 test: Add fs_tests/create_directories unit test 2022-02-17 12:30:59 +01:00
laanwj
1f46b6e46e util: Work around libstdc++ create_directories issue
Work around libstdc++ issue [PR101510] with create_directories where the
leaf already exists as a symlink. Fixes #24257, introduced by the switch
to `std::filesystem`. It is meant to be more thorough than #24266, which
only worked around one instance of the problem.

The issue was fixed upstream in
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=124eaa50e0a34f5f89572c1aa812c50979da58fc,
but unfortunately we'll have to carry a fix for it for a while.

This introduces a function `fs::create_directories` which wraps
`std::filesystem::create_directories`. This allows easiliy reverting the
workaround when it is no longer necessary.
2022-02-17 12:30:11 +01:00
laanwj
df0825046a
Merge bitcoin/bitcoin#24331: util: Revert back MoveFileExW call for MinGW-w64
dc01cbc538 test: Add fs_tests/rename unit test (Hennadii Stepanov)
d4999d40b9 util: Revert back MoveFileExW call for MinGW-w64 (Hennadii Stepanov)

Pull request description:

  Unfortunately, bitcoin/bitcoin#24308 introduced a [regression](https://github.com/bitcoin/bitcoin/pull/24308#issuecomment-1037259386) for mingw builds.

  The root of the problem is a broken implementation of [`std::filesystem::rename`](https://en.cppreference.com/w/cpp/filesystem/rename). In particular, the expected behavior
  > If `old_p` is a non-directory file, then `new_p` must be ... existing non-directory file: `new_p` _is first deleted_...

  fails with the "File exists" error.

  This PR reverts back the `MoveFileExW` call, and adds the [suggested](https://github.com/bitcoin/bitcoin/pull/24308#pullrequestreview-878832906) unit test.

ACKs for top commit:
  vasild:
    ACK dc01cbc538

Tree-SHA512: c8e5a98844cfa32bec0ad67a1aaa58fe2efd0c5474d3e83490211985b110f83245758a742dcaa0a933a192ab66a7f11807e0c53ae69260b7dd02fc99f6d03849
2022-02-17 12:29:41 +01:00
MarcoFalke
03c8c6937e
Merge bitcoin/bitcoin#24177: validation, refactor: add missing thread safety lock assertions
f485a07454 Add missing thread safety lock assertions in validation.h (Jon Atack)
37af8a20cf Add missing thread safety lock assertions in validation.cpp (Jon Atack)

Pull request description:

  A number of functions in validation.{h,cpp} have a thread safety lock annotation in the declaration but are missing the corresponding run-time lock assertion in the definition.

ACKs for top commit:
  hebasto:
    re-ACK f485a07454, only suggested change since my [previous](https://github.com/bitcoin/bitcoin/pull/24177#pullrequestreview-877810465) review.
  vasild:
    ACK f485a07454

Tree-SHA512: c86c0c0e8fe6ec7ae9ed9890f1dd7d042aa482ecf99feb6679a670aa004f6e9a99f7bc047205a34968fab7f1f841898c59b48c3ed6245c166e3b5abbf0867445
2022-02-17 08:01:52 +01:00
Andrew Chow
3d985d4f43 wallet: Don't generate keys when privkeys disabled when upgrading
When private keys are disabled, we should not be trying to generate new
keys during upgradewallet.
2022-02-16 22:53:27 -05:00
Fabian Jahr
820c03aff5
index: check muhash is in sync on coinstatsindex launch 2022-02-17 00:36:47 +01:00
Fabian Jahr
38ed58b850
index: remove txindex references from base index 2022-02-17 00:34:37 +01:00
Taeik Lim
ba4906f951 doc: Fix typos 2022-02-17 03:42:08 +09:00
Jon Atack
a4da16fbd4
Improve -netinfo help based on feedback from users and devs
- clarify that the peer counts table is of reachable networks

- a few other clarifications
2022-02-16 18:38:37 +01:00
Pieter Wuille
0683f377e1 Add tr() descriptor unit tests 2022-02-15 18:34:02 -05:00
MarcoFalke
1e8aa02ec5
Merge bitcoin/bitcoin#24117: index: make indices robust against init aborts
bfcd60f5d5 test: activate all index types in feature_init.py (Martin Zumsande)
0243907fae index: Don't commit without valid m_best_block_index (Martin Zumsande)

Pull request description:

  When an index thread receives an interrupt during init before it got to index anything (so `m_best_block_index == nullptr` still), it will still try to commit previous "work" before stopping the thread. That means that `BaseIndex::CommitInternal()` calls `GetLocator(nullptr)`, which returns an locator to the tip ([code](06b6369766/src/chain.cpp (L31-L32))), and saves it to the index DB.
  On the next startup, this locator will be read and it will be assumed that we have successfully synced the index to the tip, when in reality we have indexed nothing.
  In the case of coinstatsindex, this would lead to a shutdown of bitcoind without any indication what went wrong. For the other indexes, there would be no immediate shutdown, but the index would be corrupt.

  This PR fixes this by not committing when `m_best_block_index==nullptr`, and it also adds an error log message to the silent coinstatsindex shutdown path.

  This is another small bug found by `feature_init.py` - the second commit enables blockfilterindex and coinstatsindex for this test, enabling coinstatsindex without the first commit would have led to frequent failures.

ACKs for top commit:
  fjahr:
    reACK bfcd60f5d5
  shaavan:
    reACK bfcd60f5d5

Tree-SHA512: 8e2bac0fc40cde209518a9e59b597ae0a5a875a2a90898673987c91733718d40e528dada942bf552b58bc021bf46e59da2d0cc5a61045f48f9bae2b1baf6033b
2022-02-15 19:57:25 +01:00
Pieter Wuille
4b2e31a7ae Bugfix: make ToPrivateString work with x-only keys 2022-02-15 11:57:25 -05:00
TheCharlatan
d4b3483cec
Primitives: Correct CTransaction deserialization docstring
Since https://github.com/bitcoin/bitcoin/pull/8589 CTxWitness was
removed and instead replaced with CScriptWitness inside each CTxIn.
2022-02-15 12:27:08 +01:00
MarcoFalke
fae3f17823
fuzz: Split script formatting from script fuzz target 2022-02-15 12:19:34 +01:00
MarcoFalke
fa8dad0e07
rpc: Fix implicit-integer-sign-change in verifychain 2022-02-15 11:12:05 +01:00
MarcoFalke
444b6b342d
Merge bitcoin/bitcoin#24340: util: Add missing unlinkat to syscall sandbox
fa455975e5 util: Add missing unlinkat to syscall sandbox (MarcoFalke)

Pull request description:

  This will be needed for g++-12 (after libstdc++6 12-20220206).

  Steps to reproduce:

  ```
  gdb --args ./src/bitcoind -sandbox=log-and-abort -regtest
  ./src/bitcoin-cli -regtest -named createwallet wallet_name=a descriptors=false
  ./src/bitcoin-cli -regtest stop
  ```

  BT:

  ```
  Thread 1 "b-shutoff" received signal SIGSYS, Bad system call.
  0x00007ffff79564f7 in unlinkat () from /lib/x86_64-linux-gnu/libc.so.6
  (gdb) bt
  #0  0x00007ffff79564f7 in unlinkat () from /lib/x86_64-linux-gnu/libc.so.6
  #1  0x00007ffff7cc7335 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
  #2  0x00007ffff7cc94e3 in std::filesystem::remove_all(std::filesystem::__cxx11::path const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
  #3  0x00005555559d4918 in wallet::BerkeleyEnvironment::Flush (this=0x7fffc4005160, fShutdown=<optimized out>) at /usr/include/c++/12/bits/fs_path.h:595
  #4  0x000055555592c058 in wallet::StopWallets (context=...) at /usr/include/c++/12/bits/shared_ptr_base.h:1665
  #5  0x00005555556617ca in Shutdown (node=...) at ./src/init.cpp:293
  #6  0x000055555563ada6 in AppInit (argv=<optimized out>, argc=<optimized out>, node=...) at ./src/bitcoind.cpp:249
  #7  main (argc=<optimized out>, argv=<optimized out>) at ./src/bitcoind.cpp:273

ACKs for top commit:
  laanwj:
    Code review ACK fa455975e5

Tree-SHA512: e80a38828f8656040954c9befa2d1c9d5170e204dc09c61031633349897f51ccd85cc5c99a089c4726d7f5237875cd9ed3fa8ef864cd6c1c8a2b8250b392d57f
2022-02-15 09:26:44 +01:00
Hennadii Stepanov
1695d6661b
Merge bitcoin-core/gui#509: Respect dialog modality and fix a regression in wallet unlock
f730bd7d58 scripted-diff: Rename ShowModalDialogAndDeleteOnClose (Hennadii Stepanov)
5d7666b151 qt: Revert 7fa91e8312 partially (Hennadii Stepanov)
89c277a6fc qt: Delay shutdown while a modal dialog is active (Hennadii Stepanov)
8c0eb80f41 qt: Disable tray icon menu when a modal dialog is active (Hennadii Stepanov)
92427354dd qt, refactor: Use local QAction instances for the tray icon menu (Hennadii Stepanov)
58e16035c1 qt, refactor: Drop BitcoinGUI::{send,receive}CoinsMenuAction members (Hennadii Stepanov)
fd667e73cd qt: Make show_hide_action dependent on the main window actual state (Hennadii Stepanov)
ee151d0327 qt: Drop BitcoinGUI::toggleHideAction member (Hennadii Stepanov)
78189daac8 qt, refactor: Fill up trayIconMenu before connections (Hennadii Stepanov)
66afa286e5 qt, refactor: Replace BitcoinGUI::trayIconActivated with a lambda (Hennadii Stepanov)
c3ca8364b2 qt, refactor: Replace BitcoinGUI::macosDockIconActivated with a lambda (Hennadii Stepanov)

Pull request description:

  As pointed in bitcoin/bitcoin#23790 a regression in wallet unlock was introduced in bitcoin-core/gui#336 when a synchronous `AskPassphraseDialog` has been replaced with an asynchronous one.

  This PR reverts a call back to a synchronous mode.

  To make synchronous dialogs behave nice during shutdown some additional changes were made.

  Please note that disabling the tray icon menu when a modal dialog is active is useful itself as on master (4ad59042b3) it is possible to switch to the "Receive" tab while the GUI is waiting for a password for the "Send" tab:

  ![Screenshot from 2021-12-17 18-59-51](https://user-images.githubusercontent.com/32963518/146580710-0a755f24-a166-414b-be60-7863232ac778.png)

  This is confusing and must be avoided.

  Fixes bitcoin/bitcoin#23790.

ACKs for top commit:
  prayank23:
    tACK f730bd7d58

Tree-SHA512: 2b68275754190e4a9831b96e882d3c5b005e03909aeb6f2c5846da07199bb3efbb74ce87a9d25bb139f643c43d377a2051b221d553281fa5aefdd3181a58077f
2022-02-15 08:38:57 +02:00
Jon Atack
6f2593dc23
gui, refactor: use std::chrono for formatDurationStr() helper 2022-02-15 00:48:02 +01:00
Pieter Wuille
18ad54c3b2 Bugfix: set x-only flag when inferring pk() inside tr() 2022-02-14 18:14:10 -05:00
Murch
e50a9be154
Remove outdated comment on CFeeRate
This comment described how the constructor of CFeeRate was previously
indirectly used to parse fee rate arguments from RPCs. The command line
input was actually in sat/vB but due to the use of AmountFromValue() it
got converted to BTC/vB. In the constructor this could be rectified by
creating a CFeeRate from that given value (in BTC/vB) and COIN as the
transaction size, turning the input effectively to sat/vB. Since this
usage pattern was removed from the codebase some months ago, the comment
is now obsolete.

Also:
• Use vsize and vbyte instead of size and byte
2022-02-14 16:01:26 -05:00
laanwj
c23bf06492
Merge bitcoin/bitcoin#24115: ARMv8 SHA2 Intrinsics
aaa1d03d3a Add optimized sha256d64_arm_shani::Transform_2way (Pieter Wuille)
fe0629852a Implement sha256_arm_shani::Transform (Pavol Rusnak)
48a72fa81f Add sha256_arm_shani to build system (Pavol Rusnak)
c2b7934250 Rename SHANI to X86_SHANI to allow future implementation of ARM_SHANI (Pavol Rusnak)

Pull request description:

  This PR adds support for ARMv8 SHA2 Intrinsics.

  Fixes https://github.com/bitcoin/bitcoin/issues/13401 and https://github.com/bitcoin/bitcoin/issues/17414

  * Integration part was done by me.
  * The original SHA2 NI code comes from https://github.com/noloader/SHA-Intrinsics/blob/master/sha256-arm.c
  * Minor optimizations from https://github.com/rollmeister/bitcoin-armv8/blob/master/src/crypto/sha256.cpp are applied too.
  * The 2-way transform added by @sipa

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

Tree-SHA512: 9689d6390c004269cb1ee79ed05430d7d35a6efef2554a2b6732f7258a11e7e959b3306c04b4e8637a9623fb4c12d1c1b3592da0ff0dc6d737932db302509669
2022-02-14 21:12:39 +01:00
Carl Dong
2c03cec2ff ci: Build bitcoin-chainstate
...to make sure that the linker errors that arise from coupling
regressions are caught by CI.

Adding to the "no wallet" ci job as suggested by MarcoFalke.
2022-02-14 14:54:01 -05:00
Carl Dong
095aa6ca37 build: Add example bitcoin-chainstate executable
The bitcoin-chainstate executable serves to surface the dependencies
required by a program wishing to use Bitcoin Core's consensus engine as
it is right now.

More broadly, the _SOURCES list serves as a guiding "North Star" for the
libbitcoinkernel project: as we decouple more and more modules of the
codebase from our consensus engine, this _SOURCES list will grow shorter
and shorter. One day, only what is critical to our consensus engine will
remain. Right now, it's "the minimal list of files to link in to even
use our consensus engine".

[META] In a future commit the libbitcoinkernel library will be extracted
       from bitcoin-chainstate, and the libbitcoinkernel library's
       _SOURCES list will be the list that we aim to shrink.
2022-02-14 14:53:46 -05:00
MarcoFalke
fa455975e5
util: Add missing unlinkat to syscall sandbox 2022-02-14 17:12:34 +01:00
Hennadii Stepanov
dc01cbc538
test: Add fs_tests/rename unit test
Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
2022-02-14 16:56:40 +02:00
Hennadii Stepanov
d4999d40b9
util: Revert back MoveFileExW call for MinGW-w64 2022-02-14 16:56:35 +02:00
Kiminuo
d970a85d33 Move GetAllOutputTypes function from rpc/rawtransaction.cpp to rpc/util.{h|cpp} 2022-02-14 14:34:04 +01:00
fanquake
3ce40e64d4
Merge bitcoin/bitcoin#24309: test: test that OP_1-OP_16 (but not lower/higher) start witness programs
34d0e07e92 Test that OP_1-OP_16 (but not lower/higher) start witness programs (Pieter Wuille)

Pull request description:

  Cherry-picks one of the commits adding test coverage from #13062. As [pointed out by aj](https://github.com/bitcoin/bitcoin/pull/13062/files#r492723037):
  > could move the test additions to the first commit, since they're testing things that are already true

  Pull the additional test code into master earlier.

ACKs for top commit:
  laanwj:
    Code review ACK 34d0e07e92

Tree-SHA512: ff0ab2a54613ea6e8246b443363b362dd41b5e464faba4d11be6003aa6588a626cf56e142a3b94465cd37dd3ac4debea08455db96bade336171b6c30ea894950
2022-02-14 10:40:11 +00:00
MarcoFalke
af0b578041
Merge bitcoin/bitcoin#24187: Followups for getdeploymentinfo
e5f0356e3f rpc/blockchain: rename getdeploymentinfo tip/active_chain_tip to blockindex (Anthony Towns)
fbab43f169 rpc/blockchain: a constant craving (Anthony Towns)
5179656ef8 trivial: comment tweaks (Anthony Towns)
32f04e6da9 rpc documentation improvements (Anthony Towns)
555eafa793 doc: getdeploymentinfo release notes tweaks (Anthony Towns)

Pull request description:

  Documentation, comments and trivial code changes to followup #23508.

ACKs for top commit:
  Sjors:
    utACK e5f0356e3f

Tree-SHA512: 4e854a8453588901edb887504f7bfa100cc32df2e99654a5e5970032a0bd63259ba0582479e15bc09ef4792c6672715007f89eb1a7b2d7e229433a678cde9f44
2022-02-14 11:17:59 +01:00
glozow
d35a3cb396 [doc] clarify inaccurate comment about replacements paying higher feerate
Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>
2022-02-14 10:04:51 +00:00
glozow
5ae187f876 [validation] look up transaction by txid
GetIter takes a txid, not wtxid.
2022-02-14 10:04:51 +00:00
fanquake
e0367e84b3
Merge bitcoin/bitcoin#24301: build: header-only Boost
5d399f9f3d build: remove native B2 package (fanquake)
2037a3b6c1 build: header-only Boost (fanquake)
39e66e938f build: use header-only Boost unit test (fanquake)

Pull request description:

  This PR converts our Boost usage to header only. We switch from using our last remaining Boost lib (unit test), to using it's header-only implementation (see https://www.boost.org/doc/libs/1_78_0/libs/test/doc/html/boost_test/adv_scenarios/single_header_customizations/multiple_translation_units.html).

  Also related to #24291.

  Guix build:
  ```bash
  ```

ACKs for top commit:
  hebasto:
    re-ACK 5d399f9f3d
  MarcoFalke:
    approach ACK 5d399f9f3d 📞

Tree-SHA512: e60835ee9c11aa941a64679616da2002d6cd86e464895372fafdd42ad6499d7eb1dde6f0013c60adaeb97bd191198430cb158a7a7417b38080dd7106b28e3ba5
2022-02-14 10:04:17 +00:00
MarcoFalke
fd25d3493d
Merge bitcoin/bitcoin#24319: refactor: Avoid unsigned integer overflow in core_write
fa6065661a refactor: Avoid unsigned integer overflow in core_write (MarcoFalke)

Pull request description:

  Also, I find the new code a bit easier to understand.

ACKs for top commit:
  shaavan:
    Code Review ACK fa6065661a

Tree-SHA512: cd751e3b4dc97ef525eb8be8d0a49e9629389cb114df18d59a06e05388822af2939078e937f01494e6b317d601743b1a433ba47aa40c4dc602372d1f0fd0dc11
2022-02-14 10:08:38 +01:00