Commit Graph

31264 Commits

Author SHA1 Message Date
W. J. van der Laan
a685da55b5
Merge bitcoin/bitcoin#23181: refactor: remove references to deprecated values under std::allocator
ea4b61a157 refactor: remove references to deprecated values under std::allocator (Pasta)

Pull request description:

  Removes usages of allocator::pointer, allocator::const_pointer, allocator::reference and allocator::const_reference which are deprecated in c++17 and **removed** in c++20. See https://en.cppreference.com/w/cpp/memory/allocator

  Also prefers `using` over `typedef` see: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rt-using I'll be happy to revert this if requested so

ACKs for top commit:
  laanwj:
    Re-ACK ea4b61a157

Tree-SHA512: 9353e47a7de27bcd91b341eb2d832318b51fce9f508fcc791f05c02c5a160f430f4e7214e76f4b3e29639750d311c679789d8b7409255b13637391e4575c9ebe
2021-10-22 15:50:13 +02:00
W. J. van der Laan
12eda278ac
Merge bitcoin/bitcoin#23288: tests: remove usage of LegacyScriptPubKeyMan from some wallet tests
2d2edc1248 tests: Use Descriptor wallets for generic wallet tests (Andrew Chow)
99516285b7 tests: Use legacy change type in subtract fee from outputs test (Andrew Chow)
dcd6eeb64a tests: Use descriptors in psbt_wallet_tests (Andrew Chow)
4b1588c6bd tests: Use DescriptorScriptPubKeyMan in coinselector_tests (Andrew Chow)
811319fea4 tests, gui: Use DescriptorScriptPubKeyMan in GUI tests (Andrew Chow)
9bf0243872 bench: Use DescriptorScriptPubKeyMan for wallet things (Andrew Chow)
5e54aa9b90 bench: remove global testWallet from CoinSelection benchmark (Andrew Chow)
a5595b1320 tests: Remove global vCoins and testWallet from coinselector_tests (Andrew Chow)

Pull request description:

  Currently, various tests use `LegacyScriptPubKeyMan` because it was convenient for the refactor that introduced the `ScriptPubKeyMan` interface. However, with the legacy wallet slated to be removed, these tests should not continue to use `LegacyScriptPubKeyMan` as they are not testing any specific legacy wallet behavior. These tests are changed to use `DescriptorScriptPubKeyMan`s.

  Some of the coin selection tests and benchmarks had a global `testWallet`, but this seemed to cause some issues with ensuring that descriptors were set up in that wallet for each test. Those have been restructured to not have any global variables that may be modified between tests.

  The tests which test specific legacy wallet behavior remain unchanged.

ACKs for top commit:
  laanwj:
    Code review ACK 2d2edc1248
  brunoerg:
    tACK 2d2edc1248

Tree-SHA512: 6d60e5978e822d48e46cfc0dae4635fcb1939f21ea9d84eb72e36112e925554b7ee8f932c7ed0c4881b6566c6c19260bec346abdff1956ca9f300b30fb4e2dd1
2021-10-22 15:14:07 +02:00
fanquake
5bb03fba04
Merge bitcoin/bitcoin#23333: wallet: fix segfault by avoiding invalid default-ctored external_spk_managers entry
6911ab95f1 wallet: fix segfault by avoiding invalid default-ctored `external_spk_managers` entry (Sebastian Falbesoner)

Pull request description:

  Fixes #23321 (bug reported by Josef Vondrlik (josef-v)).

  In the method `CWallet::LoadActiveScriptPubKeyMan`, the map `external_spk_managers` (or `internal_spk_managers`, if parameter `internal` is false) is accessed via std::map::operator[], which means that a default-ctored entry is created with a null-pointer as value, if the key doesn't exist.  As soon as this value is dereferenced, a segmentation fault occurs, e.g. in `CWallet::KeypoolCountExternalKeys`.

  The bevaviour can be reproduced by the following steps (starting with empty regtest datadir):

  ```
  $ ./src/bitcoind -regtest -daemon
  $ ./src/bitcoin-cli -regtest -named createwallet_name=wallet descriptors=true blank=true
  $ cat regtest-descriptors.txt
  [
    {
      "desc": "tr([e4445899/49'/1'/0']tprv8ZgxMBicQKsPd8jCeBWsYLEoWxbVgzJDatJ7XkwQ6G3uF4FsHuaziHQ5JZAW4K515nj6kVVwPaNWZSMEcR7aFCwL4tQqTcaoprMKTTtm6Zg/1/*)#mr3llm7f",
      "timestamp": 1634652324,
      "active": true,
      "internal": true,
      "range": [
        0,
        999
      ],
      "next": 0
    }
  ]
  $ ./src/bitcoin-cli -regtest importdescriptors "$(cat regtest-descriptors.txt)"
  [
    {
      "success": true
    }
  ]
  $ ./src/bitcoin-cli -regtest getwalletinfo
  error: timeout on transient error: Could not connect to the server 127.0.0.1:18443 (error code 1 - "EOF reached")
  ```

ACKs for top commit:
  achow101:
    Code Review ACK 6911ab95f1
  lsilva01:
    Tested ACK 6911ab9  on Ubuntu 20.04.
  instagibbs:
    ACK 6911ab95f1

Tree-SHA512: 76aa96847cf2739413fb68fb902afef0b3ab9381178dd62fb0abac69f853f1f6523d73c60e610375b9a7730f275eda9162503b89f5be6e6e349a8d047b59c8dc
2021-10-22 20:35:35 +08:00
W. J. van der Laan
58275db371
Merge bitcoin/bitcoin#23140: Make CAddrman::Select_ select buckets, not positions, first
632aad9e6d Make CAddrman::Select_ select buckets, not positions, first (Pieter Wuille)

Pull request description:

  The original CAddrMan behaviour (before #5941) was to pick a uniformly random non-empty bucket, and then pick a random element from that bucket. That commit, which introduced deterministic placement of entries in buckets, changed this to picking a uniformly random non-empty bucket position instead.

  I believe that was a mistake. Buckets are our best metric for spreading out requests across independently-controlled nodes. That
  does mean that if a bucket has fewer entries, its entries are supposed to be picked more frequently.

  This PR reverts to the original high-level behavior, but on top of the deterministic placement logic.

ACKs for top commit:
  jnewbery:
    utACK 632aad9e6d
  naumenkogs:
    ACK 632aad9e6d
  mzumsande:
    ACK 632aad9e6d

Tree-SHA512: 60768afba2b6f0abd0dddff04381cab5acf374df48fc0e883ee16dde7cf7fd33056a04b573cff24a1b4d8e2a645bf0f0b3689eec84da4ff330e7b59ef142eca1
2021-10-22 13:55:05 +02:00
Hennadii Stepanov
f778845d97
ci: Add vcpkg tools cache
This change avoids downloading of the cached vcpkg tools that could fail
accidentally, and it makes CI task more robust.
2021-10-22 14:33:04 +03:00
MarcoFalke
02feae54a5
Merge bitcoin/bitcoin#23002: Make descriptor wallets by default
9c1052a521 wallet: Default new wallets to descriptor wallets (Andrew Chow)
f19ad40463 rpc, wallet: Descriptor wallets are no longer experimental (Andrew Chow)

Pull request description:

  Changes the default wallet type from legacy to descriptors. Descriptor wallets will now by the default type. Additionally, descriptor wallets will no longer be marked as experimental.

  This follows the timeline proposed in #20160

ACKs for top commit:
  lsilva01:
    Tested ACK 9c1052a521 on Ubuntu 20.04
  prayank23:
    tACK 9c1052a521
  meshcollider:
    Code review ACK 9c1052a521

Tree-SHA512: 834e6fec88e0c18673af7ebe135bd5333694d1be502164eb93a90e3e76c27974165aa4e59426945100c88e4eca07356e16886ef5b05cf789683ecb23fc71a12a
2021-10-22 13:31:10 +02:00
fanquake
788909f3c7
Merge bitcoin/bitcoin#23042: net: Avoid logging AlreadyHaveTx when disconnecting misbehaving peer
fa2662c293 net: Avoid logging AlreadyHaveTx when disconnecting misbehaving peer (MarcoFalke)

Pull request description:

  There is no need to log `AlreadyHaveTx` for an inv when a peer is marked for disconnection due to sending that inv. In fact, I find it confusing that a `block-relay-only` connection calls `AlreadyHaveTx` at all. Also there is no need to call `AddKnownTx` when the peer is marked for disconnection.

ACKs for top commit:
  naumenkogs:
    ACK fa2662c293
  jnewbery:
    Code review ACK fa2662c293
  dunxen:
    Concept and code review ACK fa2662c293

Tree-SHA512: 9996b807a824021f992b5281d82ff0cbbe6a442c2fedf7dfd6adda64ccc5e0ef4fb0ff91ab75086f975837bbbb7a5934ac7e671a80dcababa7203c92fc0c7f84
2021-10-22 19:22:44 +08:00
MarcoFalke
fa7c6efca6
fuzz: Add wallet fuzz test 2021-10-22 12:43:18 +02:00
MarcoFalke
fa59d2ce5b
refactor: Use local args instead of global gArgs in CWallet::Create
Can be reviewed with --word-diff-regex=.
2021-10-22 12:42:12 +02:00
MarcoFalke
fa4ec1c0bd
Make GenTxid boolean constructor private 2021-10-22 12:32:16 +02:00
MarcoFalke
faeb9a5753
remove unused CTxMemPool::info(const uint256& txid) 2021-10-22 12:32:08 +02:00
MarcoFalke
c001da306b
Merge bitcoin/bitcoin#23325: mempool: delete exists(uint256) function
4307849256 [mempool] delete exists(uint256) function (glozow)
d50fbd4c5b create explicit GenTxid::{Txid, Wtxid} ctors (glozow)

Pull request description:

  We use the same type for txids and wtxids, `uint256`. In places where we want the ability to pass either one, we distinguish them using `GenTxid`.

  The (overloaded) `CTxMemPool::exists()` function is defined as follows:
  ```c
  bool exists(const uint256& txid) const { return exists(GenTxid{false, txid}); }
  ```
  It always assumes that a uint256 is a txid, which is a footgunny interface.
  Querying by wtxid returns a false negative if the transaction has a witness. 🐛

  Another approach would be to try both:
  ```c
  bool exists(const uint256& txid) const { return exists(GenTxid{false, txid}) || exists(GenTxid{false, txid}); }
  ```
  But that's slower and wrongfully placing the burden on the callee; the caller always knows whether the hash is a txid or a wtxid.

ACKs for top commit:
  laanwj:
    Code review ACK 4307849256
  jnewbery:
    Tested and code review ACK 4307849256
  MarcoFalke:
    review ACK 4307849256 👘

Tree-SHA512: 8ed167a96f3124b6c14e41073c8358658114ce121a15a4cca2db7a5ac565903a6236e34e88ac03382b8bb8b68e3999abbfc5718bc8c22476554d6b49a5298eec
2021-10-22 12:29:28 +02:00
MarcoFalke
4833d1fdf3
Merge bitcoin/bitcoin#23335: refactor: include a missing <limits> header in fs.cpp
077a875d94 refactor: include a missing <limits> header in fs.cpp (Joan Karadimov)

Pull request description:

  I get this compilation error on versions `0.21.1` and `22.0`:

  ```
  fs.cpp: In member function 'bool fsbridge::FileLock::TryLock()':
  fs.cpp:123:89: error: 'numeric_limits' is not a member of 'std'
    123 |     if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, std::numeric_limits<DWORD>::max(), std::numeric_limits<DWORD>::max(), &overlapped)) {
        |                                                                                         ^~~~~~~~~~~~~~
  fs.cpp:123:109: error: expected primary-expression before '>' token
    123 |     if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, std::numeric_limits<DWORD>::max(), std::numeric_limits<DWORD>::max(), &overlapped)) {
        |                                                                                                             ^
  fs.cpp:123:112: error: '::max' has not been declared; did you mean 'std::max'?
    123 |     if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, std::numeric_limits<DWORD>::max(), std::numeric_limits<DWORD>::max(), &overlapped)) {
        |                                                                                                                ^~~
        |                                                                                                                std::max
  In file included from C:/dev/msys64/mingw64/include/c++/11.2.0/bits/char_traits.h:39,
                   from C:/dev/msys64/mingw64/include/c++/11.2.0/string:40,
                   from ./fs.h:9,
                   from fs.cpp:5:
  C:/dev/msys64/mingw64/include/c++/11.2.0/bits/stl_algobase.h:300:5: note: 'std::max' declared here
    300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
        |     ^~~
  fs.cpp:123:124: error: 'numeric_limits' is not a member of 'std'
    123 |     if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, std::numeric_limits<DWORD>::max(), std::numeric_limits<DWORD>::max(), &overlapped)) {
        |                                                                                                                            ^~~~~~~~~~~~~~
  fs.cpp:123:144: error: expected primary-expression before '>' token
    123 |     if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, std::numeric_limits<DWORD>::max(), std::numeric_limits<DWORD>::max(), &overlapped)) {
        |                                                                                                                                                ^
  fs.cpp:123:147: error: '::max' has not been declared; did you mean 'std::max'?
    123 |     if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, std::numeric_limits<DWORD>::max(), std::numeric_limits<DWORD>::max(), &overlapped)) {
        |                                                                                                                                                   ^~~
        |                                                                                                                                                   std::max
  In file included from C:/dev/msys64/mingw64/include/c++/11.2.0/bits/char_traits.h:39,
                   from C:/dev/msys64/mingw64/include/c++/11.2.0/string:40,
                   from ./fs.h:9,
                   from fs.cpp:5:
  C:/dev/msys64/mingw64/include/c++/11.2.0/bits/stl_algobase.h:300:5: note: 'std::max' declared here
    300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
        |     ^~~
  ```

  It appears that `std::numeric_limits<T>::max` is used without the `limits` header being included. Probably on other STL implementations it's included transitively, but not in the one in MinGW. Including it fixes the compilation problem.

  Environment:
  OS: Windows 10
  Compiler: gcc 11.2.0
  Qt: 5.15.2 (included in msys2)
  Using the latest mingw w64 shipped with msys2.

ACKs for top commit:
  fanquake:
    ACK 077a875d94 - Thanks.
  hebasto:
    ACK 077a875d94

Tree-SHA512: 2289cb72fa3a28470f4250833be66079482d1392189b1e4679330dad109a8ae67b1d6d51cb635dbc1947c00c6c4cfbc4d7c9ae02269b932cfa1475583adaf73d
2021-10-22 12:28:06 +02:00
MarcoFalke
9469ffcb17
Merge bitcoin/bitcoin#23323: doc: Add note on deleting past-EOL release branches
fa38d98aa9 doc: Add note on deleting past-EOL release branches (MarcoFalke)

Pull request description:

  This is being done for years now, but wasn't documented.

  Some reasons to do it:
  * Backports to those branches are unlikely to be tested both on CI (since it is often fragile and broken for stale branches) and by users (since those users likely don't exist). If a user exists, they are better off backporting any fixes they need from the last still-supported branch and test them on their own infrastructure.
  * Community support of those branches is still possible, though this will need to be done in another project to relieve the burden on this project.
  * All release tags will remain, so no historic code is lost.

ACKs for top commit:
  hebasto:
    ACK fa38d98aa9
  fanquake:
    ACK fa38d98aa9 - I think this is fine as-is.

Tree-SHA512: caa714af541a6902925c89cc6a896b125f61bd77e901c5d384d84b34def2ee654bdae9f3e995001154c29672f60d2b689d0ff92d345666564fd5aa321a5b3fe7
2021-10-22 09:02:03 +02:00
fanquake
81cdbecd75
Merge bitcoin/bitcoin#23329: ci: Define cases when invalidate vcpkg binary cache
e8692cf2c1 ci: Improve vcpkg binary cache settings (Hennadii Stepanov)
b00646bc77 ci, refactor: Rename VCPKG_TAG variable and vcpkg_cache script (Hennadii Stepanov)

Pull request description:

  On master (c8bae2be34), the size of the vcpkg binary cache is potentially unbounded.

  The reason of such behavior is the internal caching logic, following which, any change in the [set of parameters](https://vcpkg.io/en/docs/users/binarycaching.html#implementation-notes-internal-details-subject-to-change-without-notice) defined by the vcpkg implementation will cause compiling of a new binaries following by adding them to the current cache.

  This PR defines two obvious cases when the vcpkg binary cache will be invalidated.

ACKs for top commit:
  sipsorcery:
    ACK e8692cf2c1.

Tree-SHA512: 125312b9b90a9f932702ae3a8c0ed9939fca73feb92b5cdd2ebff181ae7ac50a17f8956ff11dc115da05f79030a1b56decfa25b26e37faf3505a1f30ddd8a80f
2021-10-22 09:11:46 +08:00
Joan Karadimov
077a875d94 refactor: include a missing <limits> header in fs.cpp
... needed for std::numeric_limits<T>::max on WIN32
2021-10-22 04:03:45 +03:00
MarcoFalke
fa8fef6ef2
doc: Fix CWalletTx::Confirmation doc
Follow-up to:
* commit 700c42b85d, which replaced pIndex
  with block_hash in AddToWalletIfInvolvingMe.

* commit 9700fcb47f, which replaced
  posInBlock with confirm.nIndex.
2021-10-21 22:13:35 +02:00
MarcoFalke
12ff8993bc
Merge bitcoin/bitcoin#23331: test: Replace log with assert_equal in wallet_abandonconflict
fa6c62f34b test: Replace log with assert_equal in wallet_abandonconflict (MarcoFalke)

Pull request description:

  This will make the test fail as soon as the bug is fixed, forcing it to
  be updated. Otherwise, the bug might be fixed (or made worse)
  accidentally, leaving the test in an inconsistent state.

ACKs for top commit:
  theStack:
    Concept and code-review ACK fa6c62f34b
  brunoerg:
    tACK fa6c62f34b

Tree-SHA512: 416f72380164bf3f93332a5cfa81a8e61d8ada3714ef6815889ed3cf2d16c09411760dee4acf19629227e565b765b3dea491a0b23efd38eb370254cfadf7c441
2021-10-21 22:00:49 +02:00
W. J. van der Laan
179ce09833
Merge bitcoin/bitcoin#23293: doc: Add comment to COIN constant.
1946af2c45 Add comment to COIN constant. (Kennan Mell)

Pull request description:

  The COIN constant is critical in understanding Bitcoin's supply, but what it represents isn't clear from the name of the constant. Adding a comment clarifies the meaning of the constant for future readers.

ACKs for top commit:
  lsilva01:
    ACK 1946af2
  shaavan:
    ACK 1946af2c45

Tree-SHA512: ba27c6bd4a4c92664a71ef081104e9e50e47022d68eb955c247b7c49a0046a42bf64bf23a14563c646411b7be6027fea918cc62baa01bbf319b82d14d368f280
2021-10-21 19:58:44 +02:00
W. J. van der Laan
8a083bc5b5
Merge bitcoin/bitcoin#23218: p2p: Use mocktime for ping timeout
fadf1186c8 p2p: Use mocktime for ping timeout (MarcoFalke)

Pull request description:

  It is slightly confusing to use mocktime for some times, but not others.

  Start fixing that by making the ping timeout use mocktime.

  The only downside would be that tests that use mocktime disconnect peers after this patch. However, I don't think this is an issue, as the inactivity check is already disabled for all functional tests after commit 6d76b57ca0. Only one unit test needed the inactivity check disabled as part of this patch.

  A nice side effect of this patch is that the `p2p_ping` functional test now runs 4 seconds faster.

ACKs for top commit:
  laanwj:
    Code review ACK fadf1186c8

Tree-SHA512: e9e7b21040a89d9d574b3038f85a67e6336de6cd6e41aa286769cd03cada6e75a94ec01700e052e56d822ef85d7813cc06bf7e67b81543eff8917a16cdccf942
2021-10-21 19:44:38 +02:00
W. J. van der Laan
f41aa81c99
Merge bitcoin/bitcoin#23271: crypto: Fix K1/K2 use in the comments in ChaCha20-Poly1305 AEAD
be7f4130f9 Fix K1/K2 use in the comments in ChaCha20-Poly1305 AEAD (=)

Pull request description:

  As per [#22331](https://github.com/bitcoin/bitcoin/pull/22331) and the [Detailed Construction of the ChaCha20Forward4064-Poly1305@Bitcoin cipher suite](https://gist.github.com/jonasschnelli/c530ea8421b8d0e80c51486325587c52#detailed-construction) mentioned in BIP 324, K1 is used for encrypting the associated data(message length) and instantiating the Poly1305 MAC while K2 is used for encrypting the payload. This PR fixes the comments which need to be updated in:

  1. The test vector in `src/test/crypto_tests.cpp`
  2. In `src/crypto/chacha_poly_aead.h`,  `m_chacha_main` is a K2 ChaCha20 cipher instance and should be used for encrypting the payload. Also,  `m_chacha_header` is a K1 ChaCha20 cipher instance and is used for encrypting the length and instantiating the Poly1305 MAC.

ACKs for top commit:
  siv2r:
    ACK be7f413
  jonatack:
    ACK be7f4130f9
  Zero-1729:
    ACK be7f413
  shaavan:
    reACK be7f4130f9

Tree-SHA512: 9d3d0f45cf95d0a87b9f04c26f04b9ea78b2f2fa578d3722146a79dd0d377b9867532fc62e02b8e1487420df7702a1f033d15db562327535940c2049cbde401f
2021-10-21 19:30:09 +02:00
W. J. van der Laan
ee1294f155
Merge bitcoin/bitcoin#23324: Print peer counts for all reachable networks in -netinfo
96f469f91b netinfo: print peer counts for all reachable networks (Jon Atack)

Pull request description:

  instead of only for networks we have peer connections to.

  Users reported the previous behavior caused confusion, as no column was printed when a network was reachable but no peers were connected. Users expected a column to be printed with 0 peers. This commit aligns behavior with that expectation.

  In addition, the ipv4, ipv6, and onion columns were always printed whether or not they were reachable. With this change, only the reachable ones will be returned.

  Example with CJDNS reachable but no CJDNS peers (built on #23077 and #23175):

  before
  ```
          ipv4    ipv6   onion     i2p   total   block  manual
  in         0       0      12       5      17
  out        8       1       6       4      19       2       8
  total      8       1      18       9      36
  ```
  after
  ```
           ipv4    ipv6   onion     i2p   cjdns   total   block  manual
  in          0       0      12       5       0      17
  out         8       1       6       4       0      19       2       8
  total       8       1      18       9       0      36
  ```

  There is one additional space between the in/out/total row headers and the network counts.

ACKs for top commit:
  jsarenik:
    Tested ACK 96f469f91
  prayank23:
    utACK 96f469f91b
  laanwj:
    Code review and lightly tested ACK 96f469f91b
  naumenkogs:
    ACK 96f469f91b.
  hebasto:
    ACK 96f469f91b, tested by comparing the output of `watch src/bitcoin-cli -netinfo` with the Peer tab of the Node window in the GUI 🐅

Tree-SHA512: 3489f40148a2bd0afc9eef1e1577d44150c1fccec8dbf2a675bc23aa9343bfcae6c4039f5b96e54730668c83f40bc932fb6808f5540e86ff7249fde8dc0fff67
2021-10-21 17:42:03 +02:00
glozow
4307849256 [mempool] delete exists(uint256) function
Allowing callers to pass in a uint256 (which could be txid or wtxid)
but then always assuming that it's a txid is a footgunny interface.
2021-10-21 16:26:59 +01:00
glozow
d50fbd4c5b create explicit GenTxid::{Txid, Wtxid} ctors 2021-10-21 16:26:59 +01:00
Sebastian Falbesoner
6911ab95f1 wallet: fix segfault by avoiding invalid default-ctored external_spk_managers entry
In the method `CWallet::LoadActiveScriptPubKeyMan`, the map
`external_spk_managers` (or `internal_spk_managers`, if parameter
`internal` is false) is accessed via std::map::operator[], which means
that a default-ctored entry is created with a null-pointer as value, if
the key doesn't exist.  As soon as this value is dereferenced, a
segmentation fault occurs, e.g. in `CWallet::KeypoolCountExternalKeys`.

The bevaviour can be reproduced by the following steps (starting with empty regtest datadir):

$ ./src/bitcoind -regtest -daemon
$ ./src/bitcoin-cli -regtest -named createwallet_name=wallet descriptors=true blank=true
$ cat regtest-descriptors.txt
[
  {
    "desc": "tr([e4445899/49'/1'/0']tprv8ZgxMBicQKsPd8jCeBWsYLEoWxbVgzJDatJ7XkwQ6G3uF4FsHuaziHQ5JZAW4K515nj6kVVwPaNWZSMEcR7aFCwL4tQqTcaoprMKTTtm6Zg/1/*)#mr3llm7f",
    "timestamp": 1634652324,
    "active": true,
    "internal": true,
    "range": [
      0,
      999
    ],
    "next": 0
  }
]
$ ./src/bitcoin-cli -regtest importdescriptors "$(cat regtest-descriptors.txt)"
[
  {
    "success": true
  }
]
$ ./src/bitcoin-cli -regtest getwalletinfo
error: timeout on transient error: Could not connect to the server 127.0.0.1:18443 (error code 1 - "EOF reached")

Bug reported by Josef Vondrlik (josef-v).
2021-10-21 16:26:50 +02:00
MarcoFalke
fadb44606f
build: Inline FUZZ_SUITE_LDFLAGS_COMMON
This is a refactor
2021-10-21 13:57:09 +02:00
MarcoFalke
fa6c62f34b
test: Replace log with assert_equal in wallet_abandonconflict
This will make the test fail as soon as the bug is fixed, forcing it to
be updated. Otherwise, the bug might be fixed (or made worse)
accidentally, leaving the test in an inconsistent state.
2021-10-21 11:15:15 +02:00
MarcoFalke
88fc7950f8
Merge bitcoin/bitcoin#23267: test: bip125-replaceable in listsinceblock
b7884dd1b6 test: bip125-replaceable in listsinceblock (brunoerg)

Pull request description:

  This PR adds test coverage for bip125-replaceable in listsinceblock. I added this test into wallet_listtransactions.py instead of putting it into wallet_listsinceblock.py to utilize the scenario already created in wallet_listtransactions.py and avoid repetition.

ACKs for top commit:
  theStack:
    ACK b7884dd1b6
  promag:
    ACK b7884dd1b6.
  stratospher:
    tested ACK b7884dd. Verified the bip125-replaceable status of some transactions with listsinceblock.
  lsilva01:
    tACK b7884dd  on Ubuntu 20.04

Tree-SHA512: 510dfe5a6f9d68e5a656514d356dc8fe99324296ed8caa78f0eb4b6c6906cf70b1fb50bde80aa6f61d726b2fa1d4ce1fe48c635ce24285588e56ceff92291617
2021-10-21 10:21:30 +02:00
MarcoFalke
548ad5ef7f
Merge bitcoin/bitcoin#23281: test: check that bumpfee RPC fails for txs with descendants in mempool
4ac8c89ad9 test: check that bumpfee RPC fails for txs with descendants in mempool (Sebastian Falbesoner)

Pull request description:

  This PR adds missing test coverage for the bumpfee RPC error _"Transaction has descendants in the mempool"_,

  6419bdfeb1/src/wallet/feebumper.cpp (L29-L32)

  which is thrown if the bumped tx has descendants in the mempool and is _not_ connected to the bitcoin wallet (for those, the error "Transaction has descendants in the Wallet" is thrown a few lines above). To achieve that, the test framework's MiniWallet is used.

ACKs for top commit:
  brunoerg:
    tACK 4ac8c89ad9
  promag:
    Code review ACK 4ac8c89ad9. Nice stuff!
  lsilva01:
    Tested ACK 4ac8c89 cad756b10c9dee2d9e1405 on Ubuntu 20.04.
  stratospher:
    tested ACK 4ac8c89.

Tree-SHA512: 83e99f9dd2b140c0c0597c0c36c9c948fa334871be40e58a5e004440698d9685661c69bb83ab937d30f692545a3799705f991b31904f2ef31a2fbc3ae1179fa8
2021-10-21 10:14:47 +02:00
MarcoFalke
9aa4ddb410
Merge bitcoin/bitcoin#23287: test: get and decode tx with a single gettransaction RPC call
130ee48108 test: get and decode tx with a single `gettransaction` RPC call (Sebastian Falbesoner)

Pull request description:

  Rather than subsequently calling `gettransaction` and `decoderawtransaction` to get the decoded information  for a specific tx-id, we can simply use the verbose version of `gettransaction`, which returns this in a 'decoded' key. I.e.

  ```
  node.decoderawtransaction(node.gettransaction(txid)['hex'])
  ```

  can simply be replaced by:

  ```
  node.gettransaction(txid=txid, verbose=True)['decoded']
  ```

  Rationale: shorter code, shorter test logs, less RPC calls.

ACKs for top commit:
  stratospher:
    tested ACK 130ee48
  amadeuszpawlik:
    tACK 130ee48108
  lsilva01:
    Tested ACK 130ee48 on Ubuntu 20.04.
  shaavan:
    ACK 130ee48108

Tree-SHA512: cf0bd26e1e21b8022fb8062857906e0706f0ee32d3277f985c461e2519405afe445ab005f5f763fb268c7b4d6e48b2d47eda7af8621b3bce67cece8dfc9bc153
2021-10-21 10:07:06 +02:00
MarcoFalke
3e3f53c77e
Merge bitcoin/bitcoin#23328: ci: Disable syscall sandbox in valgrind functional tests
fa44406ffd ci: Disable syscall sandbox in valgrind functional tests (MarcoFalke)

Pull request description:

  Otherwise this will fail:

  ```
  $ valgrind ./src/bitcoind -regtest -datadir=/tmp -sandbox=log-and-abort
  ==204660== Memcheck, a memory error detector
  ==204660== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
  ==204660== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
  ==204660== Command: ./src/bitcoind -regtest -datadir=/tmp -sandbox=log-and-abort
  ==204660==
  Bad system call (core dumped)

ACKs for top commit:
  practicalswift:
    cr ACK fa44406ffd

Tree-SHA512: 41853e6d5697d99bd5775a9b9017859290b3119e83726036d7e58856fcbb3459ef794b129bfaba6eca54b9bc034e2baf74cc2c177767ad5d5af3f3be2a45507f
2021-10-21 09:59:24 +02:00
fanquake
c53e95f22c
Merge bitcoin/bitcoin#23137: Move-only: bloom to src/common
fa2d611bed style: Sort (MarcoFalke)
fa1e5de2db scripted-diff: Move bloom to src/common (MarcoFalke)
fac303c504 refactor: Remove unused MakeUCharSpan (MarcoFalke)

Pull request description:

  To avoid having all files at the top level `./src` directory, start moving them to their respective sub directory according to https://github.com/bitcoin/bitcoin/issues/15732.

  `bloom` currently depends on libconsensus (`CTransaction`, `CScript`, ...) and it is currently located in the libcommon. Thus, move it to `src/common/`. (libutil in `src/util/` is for stuff that doesn't depend on libconsensus).

ACKs for top commit:
  theStack:
    Code-review ACK fa2d611bed
  ryanofsky:
    Code review ACK fa2d611bed
  fanquake:
    ACK fa2d611bed - source shuffle starts now.

Tree-SHA512: d2fbc31b81741e9f0be539e1149542c9ca39958c240e12e8e757d882beccd0f0debdc10dcce146a05f03ef9f5c6247900a461a7a4799b515e8716dfb9af1fde2
2021-10-21 10:30:04 +08:00
fanquake
4229f71bf8
Merge bitcoin/bitcoin#23282: build: remove build stubs for external leveldb
17ae2601c7 build: remove build stubs for external leveldb (Cory Fields)

Pull request description:

  Presumably these stubs indicate to packagers that external leveldb is meant to be supported in some way. It is not. Remove the stubs to avoid sending any mixed messages.

  For context, this was reported on IRC:

  > \<Talkless> bitcoind fails to start with undefined symbol: _ZTIN7leveldb6LoggerE in Debian Sid after leveldb upgraded from 1.22 to 1.23: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=996486

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

Tree-SHA512: 2f1ac2cb30dac64791933a245a2b66ce237bde3955e6f4a6b7ec181248f77a9b1b10597d865d3e2c2b6def696af70de40e905ec274e4ae7cccd1daf461473957
2021-10-21 09:31:20 +08:00
fanquake
69986de383
Merge bitcoin/bitcoin#22839: log: improve addrman logging
b65a25a846 log: improve addrman logging (Martin Zumsande)

Pull request description:

  The addrman helper functions `GetNewBucket()` and `GetTriedBucket()`
  1) log into the wrong category (`BCLog::NET` instead of `BCLog::ADDRMAN`)
  2)  log too unspecifically - especially `GetTriedBucket()` gets called from many  different places (e.g. `Check_()`, `Serialize()`), it seems sufficient to me logging these when moving an address from new to tried. Running a node with `-checkaddrman=1`and net logging currently results in a lot of repetitive log entries.

  This PR moves these log entries to `Add_()` and `Good_()` and also adds logging for `Select_()` (allowing statistics about New/Tried success probabilities), `GetAddr_()`, `ClearNew()` and `MakeTried()`.

ACKs for top commit:
  jnewbery:
    ACK b65a25a846
  vasild:
    ACK b65a25a846

Tree-SHA512: 90ab0f64eb44b7388a198efccb613577b74989fea73194bda7de8bfbd50bdb19127cb12f5ec645c7859afdb89290614a79e255f3af0a63a58d4f21aa8fe7b696
2021-10-21 08:35:30 +08:00
Pasta
ea4b61a157 refactor: remove references to deprecated values under std::allocator
Includes allocator::pointer, allocator::const_pointer, allocator::reference and allocator::const_reference which are deprecated in c++17 and removed in c++20. See https://en.cppreference.com/w/cpp/memory/allocator

Also prefer `using` over `typedef` see: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rt-using
2021-10-20 18:36:40 -04:00
Hennadii Stepanov
e8692cf2c1
ci: Improve vcpkg binary cache settings
This change comes with two improvements:
1) using the VCPKG_DEFAULT_BINARY_CACHE variable drops dependency on
vcpkg default cached archives location, and improves readability
2) two obvious cases when binary cache is invalidated are defined, that
guaranties it won't grow boundlessly when, for example, vcpkg has being
updated.
2021-10-20 22:16:12 +03:00
Hennadii Stepanov
b00646bc77
ci, refactor: Rename VCPKG_TAG variable and vcpkg_cache script
The VCPKG_TAG variable renamed to CI_VCPKG_TAG to prevent any possible
name clash with vcpkg-specific variables.

The vcpkg_cache script renamed into more meaningful one.
2021-10-20 22:16:12 +03:00
MarcoFalke
fa44406ffd
ci: Disable syscall sandbox in valgrind functional tests 2021-10-20 21:06:10 +02:00
Hennadii Stepanov
da791c7f66
wallet: Use PACKAGE_NAME to mention our software 2021-10-20 21:09:14 +03:00
MarcoFalke
fa38d98aa9
doc: Add note on deleting past-EOL release branches 2021-10-20 18:45:03 +02:00
MarcoFalke
c8bae2be34
Merge bitcoin/bitcoin#23299: util: Add missing gettimeofday to syscall sandbox
faf13e272c Add missing gettimeofday to syscall sandbox (MarcoFalke)

Pull request description:

  Fixes:

  ```
  2021-10-18T09:12:31Z [init] [httpserver.cpp:181] [InitHTTPAllowList] Allowing HTTP connections from: 127.0.0.0/8 ::1/128
  2021-10-18T09:12:31Z [init] [util/syscall_sandbox.cpp:487] [SyscallSandboxDebugSignalHandler] ERROR: The syscall "gettimeofday" (syscall number 96) is not allowed by the syscall sandbox in thread "init". Please report.

ACKs for top commit:
  practicalswift:
    cr ACK faf13e272c

Tree-SHA512: fb7b56124e3c9b04fc03224e421f54e9b3a28992e03500a23c465819d5f7c0700b1c04eb0e4cf8e2378ef69694d9f068f4356a85245289b04cb02e08c58b7c9b
2021-10-20 18:40:47 +02:00
MarcoFalke
1435161f64
Merge bitcoin/bitcoin#23316: test: make the node param explicit in init_wallet()
7b3c9e4ee8 Make explicit the node param in init_wallet() (lsilva01)

Pull request description:

  This PR changes the definition of `def init_wallet(self, i)` to `def init_wallet(self, *, node)` to make the node parameter explicit, as suggested in https://github.com/bitcoin/bitcoin/pull/22794#discussion_r713287448 .

ACKs for top commit:
  stratospher:
    tested ACK 7b3c9e4.

Tree-SHA512: 2ef036f4c2110b2f7dc893dc6eea8faa0a18edd7f8f59b25460a6c544df7238175ddd6a0d766e2bb206326b1c9afc84238c75613a0f01eeda89a8ccb7d86a4f1
2021-10-20 17:44:01 +02:00
W. J. van der Laan
d807aceeab
Merge bitcoin/bitcoin#23314: build: explicitly disable libsecp256k1 openssl based tests
d7524546ab build: explicitly disable libsecp256k1 openssl based tests (fanquake)

Pull request description:

  These tests are failing when run against OpenSSL 3, and have been
  removed upstream, bitcoin-core/secp256k1#983, so
  disabled them for now to avoid `make check` failures.

  Note that this will also remove warning output from our build, due to
  the use of deprecated OpenSSL API functions. See bitcoin#23048.

ACKs for top commit:
  MarcoFalke:
    cr ACK d7524546ab
  elichai:
    Code review ACK d7524546ab

Tree-SHA512: a3805b4123ec49aaf21378066d86be382d11a022a7530682c2d8c0e756e785f32f18bea6fe73b1eca73f70bc3aee9166c391a9bf6adc0e450ebb0ce0bcf5a45e
2021-10-20 16:33:02 +02:00
Jon Atack
96f469f91b
netinfo: print peer counts for all reachable networks
instead of only for networks we have peer connections to.

Users reported the previous behavior caused confusion,
as no column was printed when a network was reachable
but no peers were connected. Users expected a column
to be printed with 0 peers. This commit aligns
behavior with that expectation.
2021-10-20 15:52:54 +02:00
W. J. van der Laan
c8e68b418f
Merge bitcoin/bitcoin#13875: [doc] nChainTx needs to become a 64-bit earlier due to SegWit
ef72e9bd41 doc: nChainTx needs to become a 64-bit earlier due to SegWit (Sjors Provoost)

Pull request description:

  As of block 597,379 txcount is 460,596,047 (see `chainparams.cpp`), while `uint32` can handle up to 4,294,967,296.

  Pre segwit the [minimum transaction size](https://en.bitcoin.it/wiki/Maximum_transaction_rate) was 166 bytes, so the worst case number of transactions per block was ~6000. As the original source comment for `unsigned int  nChainTx` says, that should last until the year 2030.

  With SegWit the smallest possible transaction is 60 bytes (potentially increased to 65 with a future soft fork, see #15482), without a witness:

  ```
  4 bytes version
      1 byte input count
          36 bytes outpoint
          1 byte scriptSigLen (0x00)
          0 bytes scriptSig
          4 bytes sequence
      1 byte output count
          8 bytes value
          1 byte scriptPubKeyLen
          1 byte scriptPubKey (OP_TRUE)
      4 bytes locktime
  ```

  That puts the maximum number of transactions per block at 16,666 so we might have to deal with this as early as a block 827,450 in early 2024.

  Given that it's a memory-only thing and we want to allow users many years to upgrade, I would suggest fixing this in v0.20 and back-porting it.

ACKs for top commit:
  practicalswift:
    re-ACK ef72e9bd41
  jarolrod:
    ACK ef72e9bd41
  theStack:
    ACK ef72e9bd41

Tree-SHA512: d8509ba7641796cd82af156354ff3a12ff7ec0f7b11215edff6696e95f8ca0e3596f719f3492ac3acb4b0884ac4e5bddc76f107b656bc2ed95a8ef1b2b5d4f71
2021-10-20 15:52:08 +02:00
fanquake
d7524546ab
build: explicitly disable libsecp256k1 openssl based tests
These tests are failing when run against OpenSSL 3, and have been
removed upstream, https://github.com/bitcoin-core/secp256k1/pull/983, so
disabled them for now to avoid `make check` failures.

Note that this will also remove warning output from our build, due to
the use of deprecated OpenSSL API functions. See #23048.
2021-10-20 16:16:34 +08:00
MarcoFalke
f9ad4d51e3
Merge bitcoin/bitcoin#23317: build: fix python detection post #23182
a78137ec33 build: fix python detection post #23182 (fanquake)

Pull request description:

  #23182 was broken. Fixup the changes, and add python3.11 as suggested. Was going to include this in other changes, but no point leaving this broken any longer.

ACKs for top commit:
  MarcoFalke:
    cr ACK a78137ec33
  hebasto:
    ACK a78137ec33, tested on Ubuntu Impish 21.10 running `./configure`:

Tree-SHA512: f77cbea76710617eaea85787351a707cc2dcfb7e5962fc6d63ea11e737ee96cb2a496a2a4bb5a147b37ba87b0428977d9295ea053e25417ea13f43137c959919
2021-10-20 09:37:47 +02:00
=
be7f4130f9 Fix K1/K2 use in the comments in ChaCha20-Poly1305 AEAD
This is done for the ChaCha20-Poly1305 AEAD test vector
and for the K1/K2 ChaCha20 cipher instances in chacha_poly_aead.h
2021-10-20 11:54:03 +05:30
fanquake
0ccf9b2e55
Merge bitcoin/bitcoin#23258: doc: Fix outdated comments referring to ::ChainActive()
a0efe529e4 Fix outdated comments referring to ::ChainActive() (Samuel Dobson)

Pull request description:

  After #21866 there are a few outdated comments referring to `::ChainActive()`, which should instead refer to `ChainstateManager::ActiveChain()`.

ACKs for top commit:
  jamesob:
    ACK a0efe529e4

Tree-SHA512: 80da19c105ed29ac247e6df4c8e916c3bf3f37230b63f07302114eef9c115add673e9649f0bbe237295be0c6da7b1030b5b93e14daf6768f17ce5de7cf2c9ff2
2021-10-20 13:28:28 +08:00
fanquake
a78137ec33
build: fix python detection post #23182
23182 was broken. Fix up the changes, and add python3.11 as suggested.
2021-10-20 12:28:04 +08:00