Commit graph

25659 commits

Author SHA1 Message Date
Ava Chow
03d95cc630
Merge bitcoin/bitcoin#29375: wallet: remove unused 'accept_no_keys' arg from decryption process
2bb25ce502 wallet: remove unused 'accept_no_keys' arg from decryption process (furszy)

Pull request description:

  Found it while reviewing other PR. Couldn't contain myself from cleaning it up.

  The wallet decryption process (`CheckDecryptionKey()` and `Unlock()`)
  contains an arg 'accept_no_keys,' introduced in #13926, that has
  never been used.
  Additionally, this also removes the unimplemented `SplitWalletPath`
  function.

ACKs for top commit:
  delta1:
    ACK 2bb25ce502
  epiccurious:
    utACK 2bb25ce502.
  achow101:
    ACK 2bb25ce502
  theStack:
    Code-review ACK 2bb25ce502

Tree-SHA512: e0537c994be19ca0032551d8a64cf1755c8997e04d21ee0522b31de26ad90b9eb02a8b415448257b60bced484b9d2a23b37586e12dc5ff6e35bdd8ff2165c6bf
2024-02-06 13:02:47 -05:00
furszy
cfcb9b1ecf test: wallet, coverage for concurrent db transactions
Verifying that a database handler can't commit/abort changes
occurring in a different database handler.
2024-02-06 12:24:36 -05:00
Ava Chow
395bcd2454 sqlite: Ensure that only one SQLiteBatch is writing to db at a time
A SQLiteBatch need to wait for any other batch to finish writing before
it can begin writing, otherwise db txn state may be incorrectly
modified. To enforce this, each SQLiteDatabase has a semaphore which
acts as a lock and is acquired by a batch when it begins a write, erase,
or a transaction, and is released by it when it is done.

To avoid deadlocking on itself for writing during a transaction,
SQLiteBatch also keeps track of whether it has begun a transaction.
2024-02-06 12:24:36 -05:00
glozow
4de84557d6
Merge bitcoin/bitcoin#29356: test: make v2transport arg in addconnection mandatory and few cleanups
e7fd70f4b6 [test] make v2transport arg in addconnection mandatory and few cleanups (stratospher)

Pull request description:

  - make `v2transport` argument in `addconnection` regression-testing only RPC mandatory. https://github.com/bitcoin/bitcoin/pull/24748#discussion_r1470738750
  - previously it was an optional arg with default `false` value.
  - only place this RPC is used is in the [functional tests](11b436a66a/test/functional/test_framework/test_node.py (L742)) where we always pass the appropriate `v2transport` option to the RPC anyways. (and that too just for python dummy peer(`P2PInterface`) and bitcoind(`TestNode`) interactions)
  - rename `v2_handshake()` to `_on_data_v2_handshake()` https://github.com/bitcoin/bitcoin/pull/24748#discussion_r1466958424
  - more compact return statement in `wait_for_reconnect()` https://github.com/bitcoin/bitcoin/pull/24748#discussion_r1466979708
  - assertion to check that empty version packets are received from `TestNode`.

ACKs for top commit:
  glozow:
    ACK e7fd70f4b6
  theStack:
    Code-review ACK e7fd70f4b6
  mzumsande:
    Code Review ACK e7fd70f4b6

Tree-SHA512: e66e29baccd91e1e4398b91f7d45c5fc7c2841d77d8a6178734586017bf2be63496721649da91848dec71da605ee31664352407d5bb896e624cc693767c61a1f
2024-02-06 11:02:36 +00:00
brunoerg
b14298c5bc fuzz: remove unused args and context from FuzzedWallet 2024-02-05 17:06:10 -03:00
glozow
9eeee7caa3
Merge bitcoin/bitcoin#29254: log: Don't use scientific notation in log messages
c819a83b4d Don't use scientific notation in log messages (Kristaps Kaupe)

Pull request description:

  Don't see any benefits here, only harder to read for most of the users.

  Before:
  ```
  2024-01-16T13:11:36Z Dumped mempool: 8.165e-06s to copy, 0.00224268s to dump
  ```

  After:
  ```
  2024-01-16T13:11:36Z Dumped mempool: 0.000s to copy, 0.002s to dump
  ```

ACKs for top commit:
  kristapsk:
    > > > > lgtm ACK [c819a83](c819a83b4d). can you update the PR description?
  glozow:
    lgtm ACK c819a83b4d. can you update the PR description?

Tree-SHA512: 0972e0a05934e1b014fdeca0c235065aa017ba9abf74b3018f514e4d8022ef02b7f042a07d3675144b51449492468aea6b5b0183233ad7f1bab887d18e3d06af
2024-02-05 14:21:10 +00:00
glozow
cd3683c21a
Merge bitcoin/bitcoin#29354: test: Assumeutxo with more than just coinbase transactions
fa5cd66f0a test: Assumeutxo with more than just coinbase transactions (MarcoFalke)

Pull request description:

  Currently the AU tests only check that loading a txout set with only coinbase outputs works.

  Fix that by adding other transactions.

ACKs for top commit:
  jamesob:
    ACK fa5cd66f0a
  glozow:
    concept ACK fa5cd66f0a

Tree-SHA512: e090c41f73490ad72e36c478405bfd0716d46fbf5a131415095999da6503094a86689a179a84addae3562b760df64cdb67488f81692178c8ca8bf771b1e931ff
2024-02-05 14:16:44 +00:00
TheCharlatan
5ca9b24da1
test: Add makefile target for running unit tests
make check runs a bunch of other subtree tests that exercise code that
is hardly ever changed and have a comparatively long runtime. There
seems to be no target for running just the unit tests, so add one.
2024-02-03 17:59:43 +01:00
furszy
2bb25ce502
wallet: remove unused 'accept_no_keys' arg from decryption process
The wallet decryption process (CheckDecryptionKey() and Unlock())
contains an arg 'accept_no_keys,' introduced in #13926, that has
never been used.
Additionally, this also removes the unimplemented SplitWalletPath
function.
2024-02-03 12:56:43 -03:00
Ryan Ofsky
a11585692e
Merge bitcoin/bitcoin#28868: wallet: Fix migration of wallets with txs that have both spendable and watchonly outputs
4da76ca247 test: Test migration of tx with both spendable and watchonly (Ava Chow)
c62a8d03a8 wallet: Keep txs that belong to both watchonly and migrated wallets (Ava Chow)
71cb28ea8c test: Make sure that migration test does not rescan on reloading (Ava Chow)
78ba0e6748 wallet: Reload the wallet if migration exited early (Ava Chow)
9332c7edda wallet: Write bestblock to watchonly and solvable wallets (Ava Chow)

Pull request description:

  A transaction does not necessarily have to belong to either the migrated wallet (with the private keys) and the watchonly wallet (with watchonly things), it could have multiple outputs with each isminetype. So we should be putting such transactions in one or the other wallet, but rather putting it in both.

  I've added a test for this behavior, however the test also revealed a few other issues. Notably, it revealed that `migratewallet` would have the watchonly wallet rescan from genesis when it is reloaded at the end of migration. This could be a cause for migration appearing to be very slow. This is resolved by first writing best block records to the watchonly and solvable wallets, as well as updating the test to make sure that rescans don't happen.

  The change to avoid rescans also found an issue where some of our early exits would result in unloading the wallet even though nothing happened. So there is also a commit to reload the wallet for such early exits.

ACKs for top commit:
  ryanofsky:
    Code review ACK 4da76ca247. This looks great. The code is actually cleaner than before, two bugs are fixed, and the test checking for rescanning is pretty clever and broadens test coverage.
  furszy:
    Code review ACK 4da76ca2

Tree-SHA512: 5fc210cff16ca6720d7b2d0616d7e3f295c974147854abc704cf99a3bfaad17572ada084859e7a1b1ca94da647ad130303219678f429b7995f85e040236db35c
2024-02-02 21:50:22 -05:00
Ryan Ofsky
93e10cab5d
Merge bitcoin/bitcoin#29367: wallet: Set descriptors flag after migrating blank wallets
3904123da9 tests: Test that descriptors flag is set for migrated blank wallets (Ava Chow)
072d506240 wallet: Make sure that the descriptors flag is set for blank wallets (Ava Chow)

Pull request description:

  While rebasing #28710 after #28976 was merged, I realized that although blank wallets were being moved to sqlite, `WALLET_FLAG_DESCRIPTORS` was not being set so those blank wallets would still continue to be treated as legacy wallets.

  To fix that, just set the descriptor flags for blank wallets. Also added a test to catch this.

ACKs for top commit:
  epiccurious:
    Tested ACK 3904123da9.
  delta1:
    tested ACK 3904123da9
  ryanofsky:
    Code review ACK 3904123da9
  murchandamus:
    code review ACK 3904123da9

Tree-SHA512: 9f6fe9c1899ca387ab909b1bb6956cd6bc5acbf941686ddc6c061f9b1ceec2cc9d009ff472486fc86e963f6068f0e2f1ae96282e7c630193797a9734c4f424ab
2024-02-02 14:33:53 -05:00
Ava Chow
38941045c5
Merge bitcoin/bitcoin#29361: refactor: Fix timedata includes
fad0fafd5a refactor: Fix timedata includes (MarcoFalke)

Pull request description:

  Remove unused includes. Also, fixup comments, see https://github.com/bitcoin/bitcoin/pull/28956/files#r1464827885. Also, add missing includes to `chain.h` while touching it.

ACKs for top commit:
  achow101:
    ACK fad0fafd5a
  dergoegge:
    utACK fad0fafd5a
  stickies-v:
    ACK fad0fafd5a

Tree-SHA512: 45e86f2eb90f0e37012bd83bf30259719e0e58ede18b31f51ca8a6f6d23e6ca4d060fc0f56f821a711cbdb45792b82cf780f5ae3226680d7a966471990f352bc
2024-02-02 12:11:46 -05:00
Ava Chow
072d506240 wallet: Make sure that the descriptors flag is set for blank wallets 2024-02-01 18:00:58 -05:00
Ava Chow
c62a8d03a8 wallet: Keep txs that belong to both watchonly and migrated wallets
It is possible for a transaction that has an output that belongs to the
mgirated wallet, and another output that belongs to the watchonly
wallet. Such transaction should appear in both wallets during migration.
2024-02-01 14:09:05 -05:00
Ava Chow
78ba0e6748 wallet: Reload the wallet if migration exited early
Migration will unload loaded wallets prior to beginning. It will then
perform some checks which may exit early. Such unloaded wallets should
be reloaded prior to exiting.
2024-02-01 14:09:05 -05:00
Ava Chow
9332c7edda wallet: Write bestblock to watchonly and solvable wallets
When migrating, we should also be writing the bestblock record to the
watchonly and solvable wallets to avoid rescanning on the reload as that
can be slow.
2024-02-01 13:43:41 -05:00
fanquake
f879c1b24a
Merge bitcoin/bitcoin#29275: refactor: Fix prevector iterator concept issues
fad74bbbd0 refactor: Mark prevector iterator with std::contiguous_iterator_tag (MarcoFalke)
fab8a01048 refactor: Fix binary operator+ for prevector iterators (MarcoFalke)
fa44a60b2b refactor: Fix constness for prevector iterators (MarcoFalke)
facaa66b49 refactor: Add missing default constructor to prevector iterators (MarcoFalke)

Pull request description:

  Currently prevector iterators have many issues:

  * Forward iterators (and stronger) must be default constructible (https://eel.is/c++draft/forward.iterators#1.2). Otherwise, some functions can not be instantiated, like `std::minmax_element`.
  * Various `const` issues with random access iterators. For example, a `const iterator` is different from a `const_iterator`, because the first one holds a mutable reference and must also return it without `const`. Also, `operator+` must be callable regardless of the iterator object's `const`-ness.
  * When adding an offset to random access iterators, both `x+n` and `n+x` must be specified, see https://eel.is/c++draft/random.access.iterators#tab:randomaccessiterator

  Fix all issues.

  Also, upgrade the `std::random_access_iterator_tag` (C++17) to `std::contiguous_iterator_tag` (C++20)

ACKs for top commit:
  TheCharlatan:
    ACK fad74bbbd0
  stickies-v:
    ACK fad74bbbd0
  willcl-ark:
    ACK fad74bbbd0

Tree-SHA512: b1ca778a31602af94b323b8feaf993833ec78be09f1d438a68335485a4ba97f52125fdd977ffb9541b89f8d45be0105076aa07b5726936133519aae832556e0b
2024-02-01 15:57:52 +00:00
MarcoFalke
fad0fafd5a
refactor: Fix timedata includes 2024-02-01 13:52:05 +01:00
Hernan Marino
ede5014c44 Modify command line help to show support for BIP21 URIs 2024-02-01 00:57:14 -03:00
Ava Chow
aa9231fafe
Merge bitcoin/bitcoin#26859: fuzz: extend ConsumeNetAddr() to return I2P and CJDNS addresses
b851c5385d fuzz: extend ConsumeNetAddr() to return I2P and CJDNS addresses (Vasil Dimov)

Pull request description:

  In the process of doing so, refactor `ConsumeNetAddr()` to generate the addresses from IPv4, IPv6, Tor, I2P and CJDNS networks in the same way - by preparing some random stream and deserializing from it. Similar code was already found in `RandAddr()`.

ACKs for top commit:
  achow101:
    ACK b851c5385d
  mzumsande:
    ACK b851c5385d
  brunoerg:
    utACK b851c5385d

Tree-SHA512: 9905acff0e996f30ddac0c14e5ee9e1db926c7751472c06d6441111304242b563f7c942b162b209d80e8fb65a97249792eef9ae0a96100419565bf7f59f59676
2024-01-31 16:45:00 -05:00
Ava Chow
6f7395b3ff
Merge bitcoin/bitcoin#29301: init: settings, do not load auto-generated warning msg
987a1b51ee init: settings, do not load auto-generated warning msg (furszy)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/pull/29144#issuecomment-1907071391.

  The settings warning message is meant to be used only to discourage users from
  modifying the file manually. Therefore, there is no need to keep it in memory.

ACKs for top commit:
  achow101:
    ACK 987a1b51ee
  ryanofsky:
    Code review ACK 987a1b51ee. Seems like a clean, simple fix

Tree-SHA512: 3f2bdcf4b4a9cadb396dcff9b43155211eeed018527a07356970a341d139ad18edbd1a4d369377c8907b8ec1f19ee2ab8aacf85a887379e6d57a8a6db2403d51
2024-01-31 16:23:02 -05:00
Ryan Ofsky
5a1473e2c0
Merge bitcoin/bitcoin#28976: wallet: Fix migration of blank wallets
c11c404281 tests: Test migration of blank wallets (Andrew Chow)
563b2a60d6 wallet: Better error message when missing LegacySPKM during migration (Andrew Chow)
b1d2c771d4 wallet: Check for descriptors flag before migration (Andrew Chow)
8c127ff1ed wallet: Skip key and script migration for blank wallets (Andrew Chow)

Pull request description:

  Blank wallets (wallets without any keys are scripts) are being detected as already being descriptor wallets even though they are not. This is because the check for whether a wallet is already a descriptor wallet uses the presence of a `LegacyScriptPubKeyMan` which is only setup when keys or scripts are found. This PR resolves this issue by checking for the descriptor wallet flag instead and subsequently skipping the keys and scripts part of migration for blank wallets.

  Fixes the issue mentioned in https://github.com/bitcoin/bitcoin/pull/28868#issuecomment-1809641110

ACKs for top commit:
  furszy:
    reACK c11c404281. CI failure is unrelated.
  ryanofsky:
    Code review ACK c11c404281

Tree-SHA512: 2466fdf1542eb8489c841253191f85dc88365493f0bb3395b67dee3e43709a9993c68b9d7623657b54b779adbe68fc81962d60efef4802c5d461f154167af7f4
2024-01-31 16:00:46 -05:00
Ava Chow
3c13f5d612
Merge bitcoin/bitcoin#28956: Nuke adjusted time from validation (attempt 2)
ff9039f6ea Remove GetAdjustedTime (dergoegge)

Pull request description:

  This picks up parts of #25908.

  The use of adjusted time is removed from validation code while the warning to users if their clock is out of sync with the rest of the network remains.

ACKs for top commit:
  naumenkogs:
    ACK ff9039f6ea
  achow101:
    ACK ff9039f6ea
  maflcko:
    lgtm ACK ff9039f6ea 🤽
  stickies-v:
    ACK ff9039f6ea

Tree-SHA512: d1f6b9445c236915503fd2ea828f0d3b92285a5dbc677b168453276115e349972edbad37194d8becd9136d8e7219b576af64ec51c72bdb1923e57e405c0483fc
2024-01-31 15:58:47 -05:00
Ava Chow
3c63c2f324
Merge bitcoin/bitcoin#29347: net: enable v2transport by default
0bef1042ce net: enable v2transport by default (Pieter Wuille)

Pull request description:

  This enables BIP324's v2 transport by default (see #27634):
  * Inbound connections will auto-sense whether v1 or v2 is in use.
  * Automatic outbound connections will use v2 if `NODE_P2P_V2` was set in addr gossip, but retry with v1 if met with immediate failure.
  * Manual outbound connections will default to v2, but retry with v1 if met with immediate failure.

  It remains possible to run with `-v2transport=0` to disable all of these, and make all outbound and inbound connections v1. It also remains possible to specify the `v2transport` argument to the `addnode` RPC as `false`, to disable attempting a v2 connection for that particular added node.

ACKs for top commit:
  stratospher:
    ACK 0bef104.
  josibake:
    reACK 0bef1042ce
  achow101:
    ACK 0bef1042ce
  naumenkogs:
    ACK 0bef1042ce
  theStack:
    ACK 0bef1042ce
  willcl-ark:
    crACK 0bef1042ce
  BrandonOdiwuor:
    utACK 0bef1042ce
  pablomartin4btc:
    re ACK 0bef1042ce
  kristapsk:
    utACK 0bef1042ce

Tree-SHA512: 3f17a91e318b9304c40c74a7a5b231149f664ae684d13e9739a05be6c05ba9720f3c3c62da6a73ace0ae8ce733f1c8410b211f9fa15694e6a8d28999ab9882d8
2024-01-31 15:33:57 -05:00
Ava Chow
a01da41112
Merge bitcoin/bitcoin#29253: wallet: guard against dangling to-be-reverted db transactions
b298242c8d test: sqlite, add coverage for dangling to-be-reverted db txns (furszy)
fc0e747192 sqlite: guard against dangling to-be-reverted db transactions (furszy)
472d2ca981 sqlite: introduce HasActiveTxn method (furszy)
dca874e838 sqlite: add ability to interrupt statements (furszy)
fdf9f66909 test: wallet db, exercise deadlock after write failure (furszy)

Pull request description:

  Discovered while was reviewing #29112, specifically https://github.com/bitcoin/bitcoin/pull/29112#pullrequestreview-1821862931.

  If the db handler that initiated the database transaction is destroyed,
  the ongoing transaction cannot be left dangling when the db txn fails
  to abort. It must be forcefully reverted; otherwise, any subsequent
  db handler executing a write operation will dump the dangling,
  to-be-reverted transaction data to disk.

  This not only breaks the isolation property but also results in the
  improper storage of incomplete information on disk, impacting
  the wallet consistency.

  This PR fixes the issue by resetting the db connection, automatically
  rolling back the transaction (per https://www.sqlite.org/c3ref/close.html)
  when the handler object is being destroyed and the txn abortion failed.

  Testing Notes
  Can verify the failure by reverting the fix e5217fea and running the test.
  It will fail without e5217fea and pass with it.

ACKs for top commit:
  achow101:
    ACK b298242c8d
  ryanofsky:
    Code review ACK b298242c8d. Just fix for exec result codes and comment update since last review.

Tree-SHA512: 44ba0323ab21440e79e9d7791bc1c56a8873c8bd3e8f6a85641b91576e1293011fa8032d8ae5b0580f3fb7a949356f7b9676693d7ceffa617aaad9f6569993eb
2024-01-31 15:22:44 -05:00
Kristaps Kaupe
c819a83b4d
Don't use scientific notation in log messages 2024-01-31 21:20:05 +02:00
stratospher
e7fd70f4b6 [test] make v2transport arg in addconnection mandatory and few cleanups
`TestNode::add_outbound_p2p_connection()` is the only place where
addconnection test-only RPC is used. here, we always pass the
appropriate v2transport option to addconnection RPC.

currently the v2transport option for addconnection RPC is optional.
so simply make the v2transport option mandatory instead.
2024-01-31 22:37:54 +05:30
Ava Chow
0b768746ef
Merge bitcoin/bitcoin#28170: p2p: adaptive connections services flags
27f260aa6e net: remove now unused global 'g_initial_block_download_completed' (furszy)
aff7d92b15 test: add coverage for peerman adaptive connections service flags (furszy)
6ed53602ac net: peer manager, dynamically adjust desirable services flag (furszy)
9f36e591c5 net: move state dependent peer services flags (furszy)
f9ac96b8d6 net: decouple state independent service flags from desirable ones (furszy)
97df4e3887 net: store best block tip time inside PeerManager (furszy)

Pull request description:

  Derived from #28120 discussion.

  By relocating the peer desirable services flags into the peer manager, we
  allow the connections acceptance process to handle post-IBD potential
  stalling scenarios.

  The peer manager will be able to dynamically adjust the services flags
  based on the node's proximity to the tip (back and forth). Allowing the node
  to recover from the following post-IBD scenario:
  Suppose the node has successfully synced the chain, but later experienced
  dropped connections and remained inactive for a duration longer than the limited
  peers threshold (the timeframe within which limited peers can provide blocks). In
  such cases, upon reconnecting to the network, the node might only establish
  connections with limited peers, filling up all available outbound slots. Resulting
  in an inability to synchronize the chain (because limited peers will not provide
  blocks older than the `NODE_NETWORK_LIMITED_MIN_BLOCKS` threshold).

ACKs for top commit:
  achow101:
    ACK 27f260aa6e
  vasild:
    ACK 27f260aa6e
  naumenkogs:
    ACK 27f260aa6e
  mzumsande:
    Light Code Review ACK 27f260aa6e
  andrewtoth:
    ACK 27f260aa6e

Tree-SHA512: 07befb9bcd0b60a4e7c45e4429c02e7b6c66244f0910f4b2ad97c9b98258b6f46c914660a717b5ed4ef4814d0dbfae6e18e6559fe9bec7d0fbc2034109200953
2024-01-31 11:44:41 -05:00
MarcoFalke
fa5cd66f0a
test: Assumeutxo with more than just coinbase transactions 2024-01-31 12:39:51 +01:00
furszy
b298242c8d
test: sqlite, add coverage for dangling to-be-reverted db txns 2024-01-30 17:27:36 -03:00
furszy
fc0e747192
sqlite: guard against dangling to-be-reverted db transactions
If the handler that initiated the database transaction is destroyed,
the ongoing transaction cannot be left dangling when the db txn fails
to abort. It must be forcefully reversed; otherwise, any subsequent
db handler executing a write operation will dump the dangling,
to-be-reverted transaction data to disk.

This not only breaks the database isolation property but also results
in the improper storage of incomplete information on disk, impacting
the wallet consistency.
2024-01-30 17:27:36 -03:00
furszy
472d2ca981
sqlite: introduce HasActiveTxn method
Util function to clean up code and let us
verify, in the following-up commit, that dangling,
to-be-reverted db transactions cannot occur anymore.
2024-01-30 17:27:20 -03:00
furszy
dca874e838
sqlite: add ability to interrupt statements
By encapsulating sqlite3_exec into its own standalone method
and introducing the 'SQliteExecHandler' class, we enable the
ability to test db statements execution failures within the
unit test framework.

This is used in the following-up commit to exercise a deadlock
and improve our wallet db error handling code.

Moreover, the future encapsulation of other sqlite functions
within this class will contribute to minimize the impact of
any future API changes.
2024-01-30 17:26:45 -03:00
MarcoFalke
faa30a4c56
rpc: Do not wait for headers inside loadtxoutset 2024-01-30 18:09:58 +01:00
glozow
cad2df24b3
Merge bitcoin/bitcoin#29308: doc: update BroadcastTransaction comment
31cce4a1bd doc: update `BroadcastTransaction` comment (ismaelsadeeq)

Pull request description:

  `BroadcastTransaction` is also called by `submitpackage` RPC.

  All transactions that are accepted into the mempool post package processing are broadcasted to peers individually here
  ea4ddd8652/src/rpc/mempool.cpp (L926)

  It's not maintainable to list all the callers of a function.

ACKs for top commit:
  stickies-v:
    ACK 31cce4a1bd
  kristapsk:
    ACK 31cce4a1bd
  naumenkogs:
    ACK 31cce4a1bd

Tree-SHA512: 8aea92c53c1911a0ac36fe9e3a24d37d83e7d9b40a16f0832bfa7a719328697621e3f94a5dc80d1840e7ae705e0c3aab7a3df7064986e1e53a4a4114adf078a8
2024-01-30 12:09:52 +00:00
glozow
7005766492
Merge bitcoin/bitcoin#29299: validation: fix misleading checkblockindex comments
9819db4cca validation: move nChainTx assert down in CheckBlockIndex (Martin Zumsande)
033477dba6 doc: fix checkblockindex comments (Martin Zumsande)

Pull request description:

  The two assumptions there were described as test-only, which has led to confusion whether they should exist.
  However, they are necessary in general, as the changed comment explains - without them, the check would fail everywhere where it is enabled.
  The second commit moves this assert down to the other checks.

  Closes #29261

ACKs for top commit:
  maflcko:
    ACK 9819db4cca 🌦
  naumenkogs:
    ACK 9819db4cca
  ryanofsky:
    Code review ACK 9819db4cca. Thanks for figuring this issue out and fixing it. Would suggest changing pr name from "improve comments" to "fix misleading comments" since previous comments were wrong about the reasons the conditions are needed.

Tree-SHA512: 3f77791253eb0c97f8153dd8ae1c567f43f6387ea7a53efea94817463c672a4e11d548aa7eff62235346ff0713ff4d6fe08f9ec50d0c30a1e6b6d27b9918b419
2024-01-30 12:06:18 +00:00
Pieter Wuille
0bef1042ce net: enable v2transport by default 2024-01-29 22:48:01 -05:00
Ava Chow
411ba32af2
Merge bitcoin/bitcoin#24748: test/BIP324: functional tests for v2 P2P encryption
bc9283c441 [test] Add functional test to test early key response behaviour in BIP 324 (stratospher)
ffe6a56d75 [test] Check whether v2 TestNode performs downgrading (stratospher)
ba737358a3 [test] Add functional tests to test v2 P2P behaviour (stratospher)
4115cf9956 [test] Ignore BIP324 decoy messages (stratospher)
8c054aa04d [test] Allow inbound and outbound connections supporting v2 P2P protocol (stratospher)
382894c3ac  [test] Reconnect using v1 P2P when v2 P2P terminates due to magic byte mismatch (stratospher)
a94e350ac0 [test] Build v2 P2P messages (stratospher)
bb7bffed79 [test] Use lock for sending P2P messages in test framework (stratospher)
5b91fb14ab [test] Read v2 P2P messages (stratospher)
05bddb20f5 [test] Perform initial v2 handshake (stratospher)
a049d1bd08 [test] Introduce EncryptedP2PState object in P2PConnection (stratospher)
b89fa59e71 [test] Construct class to handle v2 P2P protocol functions (stratospher)
8d6c848a48 [test] Move MAGIC_BYTES to messages.py (stratospher)
595ad4b168 [test/crypto] Add ECDH (stratospher)
4487b80517 [rpc/net] Allow v2 p2p support in addconnection (stratospher)

Pull request description:

  This PR introduces support for v2 P2P encryption(BIP 324) in the existing functional test framework and adds functional tests for the same.

  ### commits overview
  1. introduces a new class `EncryptedP2PState` to store the keys, functions for performing the initial v2 handshake and encryption/decryption.
  3. this class is used by `P2PConnection` in inbound/outbound connections to perform the initial v2 handshake before the v1 version handshake. Only after the initial v2 handshake is performed do application layer P2P messages(version, verack etc..) get exchanged. (in a v2 connection)
      - `v2_state` is the object of class `EncryptedP2PState` in `P2PConnection` used to store its keys, session-id etc.
      - a node [advertising](https://github.com/stratospher/blogosphere/blob/main/integration_test_bip324.md#advertising-to-support-v2-p2p) support for  v2 P2P is different from a node actually [supporting v2 P2P](https://github.com/stratospher/blogosphere/blob/main/integration_test_bip324.md#supporting-v2-p2p) (differ when false advertisement of services occur)
          - introduce a boolean variable `supports_v2_p2p` in `P2PConnection` to denote if it supports v2 P2P.
          - introduce a boolean variable `advertises_v2_p2p` to denote whether `P2PConnection` which mimics peer behaviour advertises V2 P2P support. Default option is `False`.
      - In the test framework, you can create Inbound and Outbound connections to `TestNode`
          1. During **Inbound Connections**, `P2PConnection` is the initiator [`TestNode` <--------- `P2PConnection`]
              - Case 1:
                  - if the `TestNode` advertises/signals v2 P2P support (means `self.nodes[i]` set up with `"-v2transport=1"`), different behaviour will be exhibited based on whether:
                      1. `P2PConnection` supports v2 P2P
                      2. `P2PConnection` does not support v2 P2P
                 - In a real world scenario, the initiator node would intrinsically know if they support v2 P2P based on whatever code they choose to run. However, in the test scenario where we mimic peer behaviour, we have no way of knowing if `P2PConnection` should support v2 P2P or not. So `supports_v2_p2p` boolean variable is used as an option to enable support for v2 P2P in `P2PConnection`.
                - Since the `TestNode` advertises v2 P2P support (using "-v2transport=1"), our initiator `P2PConnection` would send:
                  1. (if the `P2PConnection` supports v2 P2P) ellswift + garbage bytes to initiate the connection
                  2. (if the `P2PConnection` does not support v2 P2P) version message to initiate the connection
             - Case 2:
                  - if the `TestNode` doesn't signal v2 P2P support; `P2PConnection` being the initiator would send version message to initiate a connection.
         2. During **Outbound Connections** [TestNode --------> P2PConnection]
             - initiator `TestNode` would send:
                  - (if the `P2PConnection` advertises v2 P2P) ellswift + garbage bytes to initiate the connection
                  - (if the `P2PConnection` advertises v2 P2P) version message to initiate the connection
            - Suppose `P2PConnection` advertises v2 P2P support when it actually doesn't support v2 P2P (false advertisement scenario)
                 - `TestNode` sends ellswift + garbage bytes
                 - `P2PConnection` receives but can't process it and disconnects.
                 - `TestNode` then tries using v1 P2P and sends version message
                 - `P2PConnection` receives/processes this successfully and they communicate on v1 P2P

  4. the encrypted P2P messages follow a different format - 3 byte length + 1-13 byte message_type + payload + 16 byte MAC
  5. includes support for testing decoy messages and v2 connection downgrade(using false advertisement - when a v2 node makes an outbound connection to a node which doesn't support v2 but is advertised as v2 by some malicious
  intermediary)

  ### run the tests
  * functional test - `test/functional/p2p_v2_encrypted.py` `test/functional/p2p_v2_earlykeyresponse.py`

  I'm also super grateful to @ dhruv for his really valuable feedback on this branch.
  Also written a more elaborate explanation here - https://github.com/stratospher/blogosphere/blob/main/integration_test_bip324.md

ACKs for top commit:
  naumenkogs:
    ACK bc9283c441
  mzumsande:
    Code Review ACK bc9283c441
  theStack:
    Code-review ACK bc9283c441
  glozow:
    ACK bc9283c441

Tree-SHA512: 9b54ed27e925e1775e0e0d35e959cdbf2a9a1aab7bcf5d027e66f8b59780bdd0458a7a4311ddc7dd67657a4a2a2cd5034ead75524420d58a83f642a8304c9811
2024-01-29 12:31:31 -05:00
ismaelsadeeq
31cce4a1bd doc: update BroadcastTransaction comment
BroadcastTransaction is also called by submitpackage RPC.

It's not maintainable to list all the callers of a function.
2024-01-29 13:07:47 +01:00
Ava Chow
5fbcc8f056
Merge bitcoin/bitcoin#29180: crypto: remove use of BUILD_BITCOIN_INTERNAL macro in sha256
bbf218d061 crypto: remove sha256_sse4 from the base crypto helper lib (Cory Fields)
4dbd0475d8 crypto: remove use of BUILD_BITCOIN_INTERNAL macro in sha256 (Cory Fields)

Pull request description:

  Replace it with a more explicit `DISABLE_OPTIMIZED_SHA256` and clean up some.

  The macro was originally used by libbitcoinconsensus which opts out of optimized sha256 for the sake of simplicity.

  Also remove the `BUILD_BITCOIN_INTERNAL` define from libbitcoinkernel for now as it does not export an api. When it does we can pick a less confusing define to control its exports.

  Removing the define should have the effect of enabling sha256 optimizations for the kernel.

ACKs for top commit:
  TheCharlatan:
    Re-ACK bbf218d061
  hebasto:
    re-ACK bbf218d061

Tree-SHA512: 7c17592bb2d3e671779f96903cb36887c5785408213bffbda1ae37b66e6bcfaffaefd0c1bf2d1a407060cd377e3d4881cde3a73c429a1aacb677f370314a066a
2024-01-26 18:56:41 -05:00
Hennadii Stepanov
fa2bcf627b
Merge bitcoin-core/gui#789: Avoid non-self-contained Windows header
8023640a71 qt: Avoid non-self-contained Windows header (Hennadii Stepanov)

Pull request description:

  Using the `windows.h` header guarantees correctness regardless of the content of other headers.

  For more details, please refer to https://stackoverflow.com/questions/4845198/fatal-error-no-target-architecture-in-visual-studio

  Fixes the MSVC build when using the upcoming CMake-based build system and Qt packages installed via the vcpkg package manager.

  Related to https://github.com/hebasto/bitcoin/pull/77.

ACKs for top commit:
  theuni:
    ACK 8023640a71. It's not completely clear to me why this currently works, but I don't think it's worth wasting more time on. `windows.h` seems more correct regardless.

Tree-SHA512: 1c03f909943111fb2663f86d33ec9a947bc5903819e5bd94f436f6b0782d9f5c5d80d9cd3490674ecd8921b2981c509e97e41580bccc436f8b5c7db84b4e493c
2024-01-26 20:40:46 +00:00
glozow
9a29d470fb [rpc] return full string for package_msg and package-error 2024-01-26 15:58:35 +00:00
Ava Chow
717103bcce
Merge bitcoin/bitcoin#29315: refactor: Compile unreachable walletdb code
fa3373d3ad refactor: Compile unreachable code (MarcoFalke)

Pull request description:

  When unreachable code isn't compiled, compile failures are not detected.

  Fix this by leaving it unreachable, but compiling it.

  Fixes https://github.com/bitcoin/bitcoin/pull/28999#discussion_r1465010916

ACKs for top commit:
  achow101:
    ACK fa3373d3ad
  ryanofsky:
    Code review ACK fa3373d3ad. This looks good, and should prevent code in the else blocks from accidentally breaking.

Tree-SHA512: 3a3764915dfc935bf5d7a48f1ca151dcbac340c1cbdce8236b24ae9b4f04d6ee9771ed058ca60bcbca6e19d13671de3517f828a8f7ab6444c7cc4e3538d1ba4e
2024-01-25 17:16:09 -05:00
Ava Chow
36720994a4
Merge bitcoin/bitcoin#20827: During IBD, prune as much as possible until we get close to where we will eventually keep blocks
d298ff8b62 During IBD, prune as much as possible until we get close to where we will eventually keep blocks (Luke Dashjr)

Pull request description:

  This should reduce pruning flushes even more, speeding up IBD with pruning on systems that have a sufficient dbcache.

  Assumes 1 MB per block between tip and best header chain. Simply adds this to the buffer pruning is trying to leave available, which results in pruning almost everything up until we get close to where we need to be keeping blocks.

ACKs for top commit:
  andrewtoth:
    ACK d298ff8b62
  fjahr:
    utACK d298ff8b62
  achow101:
    ACK d298ff8b62

Tree-SHA512: 2a482376bfb177e2ba7c2f0bb0b58b02efdb38b34755a18d1fc3e869df5959c85b6f1009e1386fa8b89c4f90d520383e36bd3e21dec221042315134efb1a455b
2024-01-25 15:20:17 -05:00
MarcoFalke
fa3373d3ad
refactor: Compile unreachable code
When unreachable code isn't compiled, compile failures are not detected.

Fix this by leaving it unreachable, but compiling it.

Fixes https://github.com/bitcoin/bitcoin/pull/28999#discussion_r1465010916

Can be reviewed with --ignore-all-space
2024-01-25 16:25:55 +01:00
Hennadii Stepanov
8023640a71
qt: Avoid non-self-contained Windows header
Using the `windows.h` header guarantees correctness regardless of the
content of other headers.
For more details, please refer to https://stackoverflow.com/questions/4845198/fatal-error-no-target-architecture-in-visual-studio

Fixes the MSVC build when using the upcoming CMake-based build system
and Qt packages installed via the vcpkg package manager.
2024-01-25 10:26:26 +00:00
fanquake
4ad83ef09b
Merge bitcoin/bitcoin#29205: build: always set -g -O2 in CORE_CXXFLAGS
00c1e2aa44 build: fix optimisation flags used for --coverage (fanquake)
1dc2c9b385 ci: cleanup C*FLAG usage in Valgrind jobs (fanquake)
6cc2a38c13 build: add sanitizer flags to configure output (fanquake)
08cd5aca18 build: always set -g -O2 in CORE_CXXFLAGS (fanquake)

Pull request description:

  Rather than trying to sporadically rely on / override Autoconf default behaviour. Just always override (if unset), and always set the flags we want (which are the same as the Autoconf defaults).

  Removes the need for duplicate code to clear (if not overridden) `CXXFLAGS`.

  Fixes cases of "missing" `-O2`. i.e this PR when running a Valgrind CI job with changes here:
  ```bash
  CXXFLAGS        =  -g -O2  -fdebug-prefix-map=$(abs_top_srcdir)=.  -Wstack-protector -fstack-protector-all -mbranch-protection=bti   -Werror  -fsanitize=fuzzer  -gdwarf-4
  ```

  Fixes configure output to reflect actual compilation flag ordering, so it's useful.

  Note that if we do still end up with a duplicate "-g -O2" when compiling, that has no effect, and I don't really thinks it's something worth trying to optimize.

ACKs for top commit:
  TheCharlatan:
    lgtm ACK 00c1e2aa44
  hebasto:
    ACK 00c1e2aa44, I have reviewed the code and it looks OK. Also tested `ci/test/00_setup_env_native_valgrind.sh`.
  theuni:
    ACK 00c1e2aa44

Tree-SHA512: cf6c7acf813ba10b198561e83eb72e9b2532a39cb1767c452d031e82921dcd42a47b129735b24c4e36131fd0c8fe7457f7cae870c1e011cdfdd430bdc4d4912b
2024-01-25 10:12:56 +00:00
marco
ff54314d4a wallet: clarify replaced_by_txid and replaces_txid in help output 2024-01-23 17:34:16 -07:00
furszy
987a1b51ee
init: settings, do not load auto-generated warning msg
The settings warning message is meant to be used only to discourage
users from modifying the file manually. Therefore, there is no need
to keep it in memory.
2024-01-23 21:01:32 -03:00
Martin Zumsande
9819db4cca validation: move nChainTx assert down in CheckBlockIndex
There is a designated section meant for the actual consistency
checks, marked by a comment.
2024-01-23 18:27:32 -05:00
Martin Zumsande
033477dba6 doc: fix checkblockindex comments
These exceptions are not related to situations specific to tests,
but are required in general:
Without the first check CheckBlockindex could fail for blocks where we
only know the header.
Without the second, it could fail when blocks are received out of order.
2024-01-23 18:26:57 -05:00
Ava Chow
e69796c79c
Merge bitcoin/bitcoin#28560: wallet, rpc: FundTransaction refactor
18ad1b9142 refactor: pass CRecipient to FundTransaction (josibake)
5ad19668db refactor: simplify `CreateRecipients` (josibake)
47353a608d refactor: remove out param from `ParseRecipients` (josibake)
f7384b921c refactor: move parsing to new function (josibake)
6f569ac903 refactor: move normalization to new function (josibake)
435fe5cd96 test: add tests for fundrawtx and sendmany rpcs (josibake)

Pull request description:

  ## Motivation

  The primary motivation for this PR is to enable `FundTransaction` to take a vector of `CRecipient` objects to allow passing BIP352 silent payment addresses to RPCs that use `FundTransaction` (e.g. `send`, `walletcreatefundedpsbt`). To do that, SFFO logic needs to be moved out of `FundTransaction` so the `CRecipient` objects with the correct SFFO information can be created and then passed to `FundTransaction`.

  As a secondary motivation, this PR moves the SFFO stuff closer to the caller, making the code cleaner and easier to understand. This is done by having a single function which parses RPC inputs for SFFO and consistently using the `set<int>` method for communicating SFFO.

  I'm also not convinced we need to pass a full `CMutableTx` object to `FundTransaction`, but I'm leaving that for a follow-up PR/discussion, as its not a blocker for silent payments.

ACKs for top commit:
  S3RK:
    reACK 18ad1b9142
  josibake:
    > According to my `range-diff` nothing changed. reACK [18ad1b9](18ad1b9142)
  achow101:
    ACK 18ad1b9142

Tree-SHA512: d61f017cf7d98489ef216475b68693fd77e7b53a26a6477dcd73e7e5ceff5036b2d21476e377839e710bb73644759d42c4f9f4b14ed96b3e56ed87b07aa6d1a7
2024-01-23 16:40:58 -05:00
Ava Chow
2f218c664b
Merge bitcoin/bitcoin#28921: multiprocess: Add basic type conversion hooks
6acec6b9ff multiprocess: Add type conversion code for UniValue types (Ryan Ofsky)
0cc74fce72 multiprocess: Add type conversion code for serializable types (Ryan Ofsky)
4aaee23921 test: add ipc test to test multiprocess type conversion code (Ryan Ofsky)

Pull request description:

  Add type conversion hooks to allow `UniValue` objects, and objects that have `CDataStream` `Serialize` and `Unserialize` methods to be used as arguments and return values in Cap'nProto interface methods. Also add unit test to verify the hooks are working and data can be round-tripped correctly.

  The non-test code in this PR was previously part of #10102 and has been split off for easier review, but the test code is new.

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/issues/28722).

ACKs for top commit:
  achow101:
    ACK 6acec6b9ff
  dergoegge:
    reACK 6acec6b9ff

Tree-SHA512: 5d2cbc5215d488b876d34420adf91205dabf09b736183dcc85aa86255e3804c2bac5bab6792dacd585ef99a1d92cf29c8afb3eb65e4d953abc7ffe41994340c6
2024-01-23 16:22:29 -05:00
Ava Chow
874c8bdb9e
Merge bitcoin/bitcoin#29144: init: handle empty settings file gracefully
e9014042a6 settings: add auto-generated warning msg for editing the file manually (furszy)
966f5de99a init: improve corrupted/empty settings file error msg (furszy)

Pull request description:

  Small and simple issue reported [here](https://community.umbrel.com/t/bitcoin-docker-container-keeps-restarting/2144).

  Improving a confusing situation reported by users who did not understand why a
  settings parsing error occurred when the file was empty and did not know how to solve it.

  Empty setting file could be due (1) corruption or (2) an user manually cleaning up the file content.
  In both scenarios, the 'Unable to parse settings file' error does not help the user move forward.

ACKs for top commit:
  achow101:
    ACK e9014042a6
  hebasto:
    re-ACK e9014042a6.
  ryanofsky:
    Code review ACK e9014042a6. Just whitespace formatting changes and shortening a test string literal since last review
  shaavan:
    Code review ACK e9014042a6

Tree-SHA512: 2910654c6b9e9112de391eedb8e46980280f822fa3059724dd278db7436804dd27fae628d2003f2c6ac1599b07ac5c589af016be693486e949f558515e662bec
2024-01-23 15:14:03 -05:00
Ava Chow
6f732ffc3c
Merge bitcoin/bitcoin#28774: wallet: avoid returning a reference to vMasterKey after releasing the mutex that guards it
32a9f13cb8 wallet: avoid returning a reference to vMasterKey after releasing the mutex that guards it (Vasil Dimov)

Pull request description:

  `CWallet::GetEncryptionKey()` would return a reference to the internal
  `CWallet::vMasterKey`, guarded by `CWallet::cs_wallet`, which is unsafe.

  Returning a copy would be a shorter solution, but could have security
  implications of the master key remaining somewhere in the memory even
  after `CWallet::Lock()` (the current calls to
  `CWallet::GetEncryptionKey()` are safe, but that is not future proof).

  So, instead of `EncryptSecret(m_storage.GetEncryptionKey(), ...)`
  change the `GetEncryptionKey()` method to provide the encryption
  key to a given callback:
  `m_storage.WithEncryptionKey([](const CKeyingMaterial& k) { EncryptSecret(k, ...); })`

  This silences the following (clang 18):

  ```
  wallet/wallet.cpp:3520:12: error: returning variable 'vMasterKey' by reference requires holding mutex 'cs_wallet' [-Werror,-Wthread-safety-reference-return]
   3520 |     return vMasterKey;
        |            ^
  ```

  ---
  _Previously this PR modified both ArgsManager and wallet code. But the ArgsManager commit 856c88776f was merged in https://github.com/bitcoin/bitcoin/pull/29040 so now this only affects wallet code. The previous PR description was:_

  Avoid this unsafe pattern from `ArgsManager` and `CWallet`:

  ```cpp
  class A
  {
      Mutex mutex;
      Foo member GUARDED_BY(mutex);
      const Foo& Get()
      {
          LOCK(mutex);
          return member;
      } // callers of `Get()` will have access to `member` without owning the mutex.
  ```

ACKs for top commit:
  achow101:
    ACK 32a9f13cb8
  ryanofsky:
    Code review ACK 32a9f13cb8. This seems like a potentially real race condition, and the fix here is pretty simple.
  furszy:
    ACK 32a9f13c

Tree-SHA512: 133da84691642afc1a73cf14ad004a7266cb4be1a6a3ec634d131dca5dbcdef52522c1d5eb04f5b6c4e06e1fc3e6ac57315f8fe1e207b464ca025c2b4edefdc1
2024-01-23 15:05:23 -05:00
Ava Chow
7cb7759b25
Merge bitcoin/bitcoin#29272: wallet: fix coin selection tracing to return -1 when no change pos
d55fdb1a49 Move TRACEx parameters to seperate lines (Richard Myers)
2d58629ee6 wallet: fix coin selection tracing to return -1 when no change pos (Richard Myers)

Pull request description:

  This is a bugfix for from when [optional was introduced](758501b713)  for `change_pos` in the wallet. When optional `change_pos` is unset, we should return -1 and not 0.

  I added two new checks to the `test/functional/interface_usdt_coinselection.py` which adds coverage for the situations when `normal_create_tx_internal` and `aps_create_tx_internal` events occur with no change.

  You can reproduce this bug using the coin-selection-simulation scripts as described in [issue #16](https://github.com/achow101/coin-selection-simulation/issues/16). You can also run the `interface_usdt_coinselection.py` test  without the changes to `wallet/spend.cpp`.

ACKs for top commit:
  0xB10C:
    ACK d55fdb1a49
  achow101:
    ACK d55fdb1a49
  murchandamus:
    ACK d55fdb1a49

Tree-SHA512: 6efac3b756bdf51debbcb759dc3c4b7a4304626bc047b70025cec02f3a04937ace7712e9558ac71e560fd136005a98c518ac5bb4b90c3282d776beccd0de9749
2024-01-23 14:33:43 -05:00
fanquake
8c9dceb962
Merge bitcoin/bitcoin#29291: Add test for negative transaction version w/ CSV to tx_valid.json
97181decf5 Add test for negative transaction version w/ CSV to tx_valid.json (Chris Stewart)

Pull request description:

  This PR adds a static test vector corresponding to the bug found in various implementations of the bitcoin protocol discovered by dergoegge

  For more information see:

  https://delvingbitcoin.org/t/disclosure-btcd-consensus-bugs-due-to-usage-of-signed-transaction-version/455

ACKs for top commit:
  darosior:
    ACK 97181decf5
  dergoegge:
    ACK 97181decf5

Tree-SHA512: 92bbcd3cd10a569757b4de91e1b2bcfebc2b75ddb0160be36d8e512a6fa4623cced1aba93bd1cc044962cd2b10e1d184ef109ccdfe3cfcf85cf4b9585d80d115
2024-01-23 16:53:37 +00:00
stratospher
4487b80517 [rpc/net] Allow v2 p2p support in addconnection
This test-only RPC is required when a TestNode initiates
an outbound v2 p2p connection. Add a new arg `v2transport`
so that the node can attempt v2 connections.
2024-01-23 22:04:48 +05:30
furszy
27f260aa6e
net: remove now unused global 'g_initial_block_download_completed' 2024-01-23 10:25:16 -03:00
furszy
aff7d92b15
test: add coverage for peerman adaptive connections service flags 2024-01-23 10:25:15 -03:00
furszy
6ed53602ac
net: peer manager, dynamically adjust desirable services flag
Introduces functionality to detect when limited peers connections
are desirable or not. Ensuring that the new connections desirable
services flags stay relevant throughout the software's lifecycle.
(Unlike the previous approach, where once the validation IBD flag
was set, the desirable services flags remained constant forever).

This will let us recover from stalling scenarios where the node had
successfully synced, but subsequently dropped connections and remained
inactive for a duration longer than the limited peers threshold (the
timeframe within which limited peers can provide blocks). Then, upon
reconnection to the network, the node may end up only establishing
connections with limited peers, leading to an inability to synchronize
the chain.

This also fixes a possible limited peers threshold violation during IBD,
when the user configures `-maxtipage` further than the BIP159's limits.
This rule violation could lead to sync delays and, in the worst-case
scenario, trigger the same post-IBD stalling scenario (mentioned above)
but during IBD.
2024-01-23 10:25:05 -03:00
Vasil Dimov
b851c5385d
fuzz: extend ConsumeNetAddr() to return I2P and CJDNS addresses
In the process of doing so, refactor `ConsumeNetAddr()` to generate the
addresses from IPv4, IPv6, Tor, I2P and CJDNS networks in the same way -
by preparing some random stream and deserializing from it. Similar code
was already found in `RandAddr()`.
2024-01-23 11:49:32 +01:00
furszy
e9014042a6
settings: add auto-generated warning msg for editing the file manually
Hopefully, refraining users from modifying the file unless they are
certain about the potential consequences.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2024-01-22 10:50:03 -03:00
furszy
966f5de99a
init: improve corrupted/empty settings file error msg
The preceding "Unable to parse settings file" message lacked
the necessary detail and guidance for users on what steps to
take next in order to resolve the startup error.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2024-01-22 10:50:03 -03:00
Sebastian Falbesoner
e2ad343f69 wallet: remove unused SignatureData instances in spkm's FillPSBT methods
These are filled with signature data from a PSBT input, but not used anywhere
after, hence they can be removed.
2024-01-22 13:42:36 +01:00
glozow
651fb034d8
Merge bitcoin/bitcoin#29260: refactor: remove CTxMemPool::queryHashes()
282b12ddb0 refactor: remove CTxMemPool::queryHashes() (stickies-v)

Pull request description:

  `CTxMemPool::queryHashes()` is only used in `MempoolToJSON()`, where it can just as easily be replaced with the more general `CTxMemPool::entryAll()`. No behaviour change, just cleans up the code.

ACKs for top commit:
  dergoegge:
    Code review ACK 282b12ddb0
  TheCharlatan:
    ACK 282b12ddb0
  glozow:
    ACK 282b12ddb0. Looks like there's no conflicts.

Tree-SHA512: 16160dec8e1f2457fa0f62dc96d2d2efd92c4bab810ecdb0e08918b8e85a667702c8e41421eeb4ea6abe92a5956a2a39a7a6368514973b78be0d22de2ad299b2
2024-01-22 10:03:57 +00:00
Richard Myers
d55fdb1a49
Move TRACEx parameters to seperate lines 2024-01-20 14:58:17 +01:00
Richard Myers
2d58629ee6
wallet: fix coin selection tracing to return -1 when no change pos 2024-01-20 14:56:41 +01:00
josibake
18ad1b9142
refactor: pass CRecipient to FundTransaction
Instead turning tx.vout into a vector of `CRecipient`, make `FundTransaction`
take a `CRecipient` vector directly. This allows us to remove SFFO logic from
the wrapper RPC `FundTransaction` since the `CRecipient` objects have already
been created with the correct SFFO values. This also allows us to remove
SFFO from both `FundTransaction` function signatures.

This sets us up in a future PR to be able to use these RPCs with BIP352
static payment codes.
2024-01-19 15:04:56 +01:00
josibake
5ad19668db
refactor: simplify CreateRecipients
Move validation logic out of `CreateRecipients` and instead take the
already validated outputs from `ParseOutputs` as an input.

Move SFFO parsing out of `CreateRecipients` into a new function,
`InterpretSubtractFeeFromOutputsInstructions`. This takes the SFFO instructions
from `sendmany` and `sendtoaddress` and turns them into a set of integers.
In a later commit, we will also move the SFFO parsing logic from
`FundTransaction` into this function.

Worth noting: a user can pass duplicate addresses and addresses that dont exist
in the transaction outputs as SFFO args to `sendmany` and `sendtoaddress`
without triggering a warning. This behavior is preserved in to keep this commit
strictly a refactor.
2024-01-19 15:04:56 +01:00
josibake
47353a608d
refactor: remove out param from ParseRecipients
Have `ParseRecipients` return a vector of `CRecipients` and rename to `CreateRecipients`.
2024-01-19 15:04:56 +01:00
josibake
f7384b921c
refactor: move parsing to new function
Move the parsing and validation out of `AddOutputs` into its own function,
`ParseOutputs`. This allows us to re-use this logic in `ParseRecipients` in a
later commit, where the code is currently duplicated.

The new `ParseOutputs` function returns a CTxDestination,CAmount tuples.
This allows the caller to then translate the validated outputs into
either CRecipients or CTxOuts.
2024-01-19 15:04:56 +01:00
josibake
6f569ac903
refactor: move normalization to new function
Move the univalue formatting logic out of AddOutputs and into its own function,
`NormalizeOutputs`. This allows us to re-use this logic in later commits.
2024-01-19 15:04:56 +01:00
stickies-v
282b12ddb0
refactor: remove CTxMemPool::queryHashes()
Its only usage can easily be replaced with CTxMemPool::entryAll()
2024-01-18 21:54:56 +00:00
MarcoFalke
fad74bbbd0
refactor: Mark prevector iterator with std::contiguous_iterator_tag 2024-01-18 19:29:34 +01:00
Ava Chow
5f3a0574c4
Merge bitcoin/bitcoin#29262: rpc: Fix race in loadtxoutset
5555d8db33 test: Use blocks_path where possible (MarcoFalke)
fa9108941f rpc: Fix race in loadtxoutset (MarcoFalke)

Pull request description:

  The tip may have advanced, also if it did not, there is no reason to
  have two variables point to the same block.

  Fixes https://github.com/bitcoin/bitcoin/pull/27596#discussion_r1344694600

ACKs for top commit:
  achow101:
    ACK 5555d8db33
  pablomartin4btc:
    ACK 5555d8db33
  BrandonOdiwuor:
    Code Review ACK 5555d8db33

Tree-SHA512: 23a82924a915b61bb1adab8ad20ec8914139c8ee647817af34ca27ee310a2e45833d8b285503e0feebe63e4667193d6d98cfcbbc1509bf40712225e04dd19e8b
2024-01-18 13:17:35 -05:00
Vasil Dimov
32a9f13cb8
wallet: avoid returning a reference to vMasterKey after releasing the mutex that guards it
`CWallet::GetEncryptionKey()` would return a reference to the internal
`CWallet::vMasterKey`, guarded by `CWallet::cs_wallet`, which is unsafe.

Returning a copy would be a shorter solution, but could have security
implications of the master key remaining somewhere in the memory even
after `CWallet::Lock()` (the current calls to
`CWallet::GetEncryptionKey()` are safe, but that is not future proof).

So, instead of `EncryptSecret(m_storage.GetEncryptionKey(), ...)`
change the `GetEncryptionKey()` method to provide the encryption
key to a given callback:
`m_storage.WithEncryptionKey([](const CKeyingMaterial& k) { EncryptSecret(k, ...); })`

This silences the following (clang 18):

```
wallet/wallet.cpp:3520:12: error: returning variable 'vMasterKey' by reference requires holding mutex 'cs_wallet' [-Werror,-Wthread-safety-reference-return]
 3520 |     return vMasterKey;
      |            ^
```
2024-01-18 18:12:59 +01:00
MarcoFalke
fab8a01048
refactor: Fix binary operator+ for prevector iterators 2024-01-18 15:46:33 +01:00
MarcoFalke
fa44a60b2b
refactor: Fix constness for prevector iterators 2024-01-18 15:46:24 +01:00
MarcoFalke
facaa66b49
refactor: Add missing default constructor to prevector iterators 2024-01-18 15:46:11 +01:00
fanquake
03c5b0064d
Merge bitcoin/bitcoin#29085: refactor: C++20: Use std::rotl
6044628543 crypto, hash: replace custom rotl32 with std::rotl (Fabian Jahr)

Pull request description:

  While exploring some C++20 changes and checking against our code I found this potential improvement:

  1. We can replace our custom implementation of `rotl32` in crypto/chacha20 with `std::rotl` from the [new `bit` header](https://en.cppreference.com/w/cpp/header/bit).

ACKs for top commit:
  fanquake:
    ACK 6044628543

Tree-SHA512: db55b366f20fca2ef62e5f10a838f8a709d531678c35c1dba20898754029c788a2fd47995208ed6d187cf814109a7ca397bc2c301504500aee79da04c95d6895
2024-01-18 09:40:44 +00:00
fanquake
514268170b
Merge bitcoin/bitcoin#29133: refactor: Allow std::span construction from CKey
fa96d93711 refactor: Allow std::span construction from CKey (MarcoFalke)
999962d68d Add missing XOnlyPubKey::data() to get mutable data (MarcoFalke)

Pull request description:

  Is is possible to construct a `Span` from a reference to a `CKey`. However, the same is not possible with `std::span`.

  Fix that.

ACKs for top commit:
  shaavan:
    ReACK fa96d93711
  willcl-ark:
    ACK fa96d93711

Tree-SHA512: 44fccdce5f32bc16b44f3b1bd32e86d9eabfd09bca6abe79f2d6db0cb0b5e4aaeaff710f023cb21ccde9315d2007d55f1b43f29416e81bceeeabe3948f673d3a
2024-01-17 16:00:32 +00:00
MarcoFalke
fa9108941f
rpc: Fix race in loadtxoutset
The tip may have advanced, also if it did not, there is no reason to
have two variables point to the same block.
2024-01-17 16:48:42 +01:00
Ava Chow
8106b268cd
Merge bitcoin/bitcoin#29239: rpc: Make v2transport default for addnode RPC when enabled
3ba815b42d Make v2transport default for addnode RPC when enabled (Pieter Wuille)

Pull request description:

  Since #29058, several types of manually configured connections will attempt v2 connections when `-v2transport` is enabled, except for the `addnode` RPC, as that one has an explicit argument to enable or disable.

  Make the default for that RPC match the `-v2transport` setting so the behavior matches that of other manual connections from a user perspective.

ACKs for top commit:
  achow101:
    ACK 3ba815b42d
  kristapsk:
    ACK 3ba815b42d
  theStack:
    Code-review ACK 3ba815b42d

Tree-SHA512: 31ef48cf1e533abb17866020378c004df929e626074dc98b3229fb60a66de58435e95c8fda8d1b463e1208aa39d1f42d239818e7e58595a3738089920598befc
2024-01-16 16:50:03 -05:00
Ava Chow
a3fb1f80ac
Merge bitcoin/bitcoin#28791: snapshots: don't core dump when running -checkblockindex after loadtxoutset
cdc6ac4126 snapshots: don't core dump when running -checkblockindex after `loadtxoutset` (Mark Friedenbach)

Pull request description:

  Transaction counts aren't known for block history loaded from a snapshot. If you start with `-checkblockindex` after loading a snapshot, the bitcoin daemon will core dump. The test suite does not check for this because all the snapshots have no non-coinbase transactions (all blocks prior to the snapshot are assumed to have `nTx = 1`).

  Recommend for backport to 26.x

ACKs for top commit:
  fjahr:
    utACK cdc6ac4126
  achow101:
    ACK cdc6ac4126
  pablomartin4btc:
    tACK cdc6ac4126

Tree-SHA512: f7488a85cc29056e2ac443ce8f34aea4dfde6ba246efce82235d6a4dca2dca4344f07b93c93424b4addcb83e4cb2ae49a3ebb37d89840d42d2aeea35904cab04
2024-01-16 15:02:53 -05:00
Ava Chow
5711da6588
Merge bitcoin/bitcoin#29213: doc, test: test and explain service flag handling
74ebd4d135 doc, test: Test and explain service flag handling (Martin Zumsande)

Pull request description:

  Service flags received from the peer-to-peer network are handled differently, depending on how we receive them.
  If received directly from an outbound peer the flags belong to, they replace existing flags.
  If received via gossip relay (so that anyone could send them), new flags are added, but existing ones but cannot be overwritten.

  Document that and add test coverage for it.

ACKs for top commit:
  achow101:
    ACK 74ebd4d135
  furszy:
    ACK 74ebd4d135
  brunoerg:
    utACK 74ebd4d135

Tree-SHA512: 604adc3304b8e3cb1a10dfd017025c10b029bebd3ef533f96bcb5856fee5d4396a9aed4949908b8e7ef267ad21320d1814dd80f88426330c5c9c2c529c497591
2024-01-16 13:35:45 -05:00
MarcoFalke
fa96d93711
refactor: Allow std::span construction from CKey 2024-01-16 15:29:18 +01:00
glozow
158623b8e0 [refactor] change Workspace::m_conflicts and adjacent funcs/structs to use Txid
It's preferable to use type-safe transaction identifiers to avoid
confusing txid and wtxid. The next commit will add a reference to this
set; we use this opportunity to change it to Txid ahead of time instead
of adding new uses of uint256.
2024-01-16 14:20:33 +00:00
fanquake
9fa8eda8af
Merge bitcoin/bitcoin#29230: doc: update -loglevel help to add info to the always logged levels
ec779a2b8e doc: add unconditional info loglevel following merge of PR 28318 (Jon Atack)

Pull request description:

  Commit ab34dc6012 of #28318 was an incomplete version of [`118c756` (#25203)](118c7567f6) from the `Severity-based logging` parent PR.

  Add the missing text to update the `-loglevel` help doc.

  While here, make the help text a little easier to understand.

  Can be tested by running:

  ```
  ./src/bitcoind -regtest -help-debug | grep -A12 loglevel=
  ```

  before
  ```
    -loglevel=<level>|<category>:<level>
         Set the global or per-category severity level for logging categories
         enabled with the -debug configuration option or the logging RPC:
         info, debug, trace (default=debug); warning and error levels are
         always logged.
  ```

  after
  ```
    -loglevel=<level>|<category>:<level>
         Set the global or per-category severity level for logging categories
         enabled with the -debug configuration option or the logging RPC.
         Possible values are info, debug, trace (default=debug). The
         following levels are always logged: error, warning, info.
  ```

ACKs for top commit:
  stickies-v:
    ACK ec779a2b8e

Tree-SHA512: 0c375e30a5a4c168ca7d97720e8c287f598216767afedae329824e09a480830faf8537b792c5c4bb647c68681c287fe3005c62093708ce85624e9a71c8245e42
2024-01-16 10:52:54 +00:00
MarcoFalke
999962d68d
Add missing XOnlyPubKey::data() to get mutable data
This is needed for consistency, and also to allow std::span construction
from XOnlyPubKey.
2024-01-16 10:58:57 +01:00
fanquake
08cd5aca18
build: always set -g -O2 in CORE_CXXFLAGS
This avoids cases of missing -O2, when *FLAGS has been overriden.
Removes the need for duplicate code to clear autoconf defaults.

Also, move CORE_CXXFLAGS before DEBUG_CXXFLAGS, so that -O2 is always
overriden if debugging etc.
2024-01-16 09:46:17 +00:00
fanquake
2ac2821a74
Merge bitcoin/bitcoin#29185: build: remove --enable-lto
2d1b1c7dae build: remove --enable-lto (fanquake)

Pull request description:

  This has outlived its usefulness, doesn't gel well with newer compilers & `-flto` related options, i.e thin vs full, or `=auto`, and having `-flto` as the only option means that sometimes this just needs to be worked around, i.e in oss-fuzz:
  https://github.com/google/oss-fuzz/blob/master/projects/bitcoin-core/build.sh.

  While it was convenient when `-flto` was newer, support for `-flto` is now in all compilers we use, and there's also no-longer any real need for us to treat `-flto` different to any other optimization option.

  Remove it, to remove build complexity, and so there's no need to port a similar option to CMake.

  Note that the LTO option remains in depends, because we still a way to build packages that have LTO specific patches/options.

ACKs for top commit:
  TheCharlatan:
    ACK 2d1b1c7dae
  hebasto:
    ACK 2d1b1c7dae.

Tree-SHA512: 91812de7da35346f51850714a188fcffbac478bc8b348bf756c2555fcbde86ba622ac2fb77d294dea0378c741d3656f06121ef3a795aeed63fd170fc31bfa5af
2024-01-16 09:42:12 +00:00
furszy
fdf9f66909
test: wallet db, exercise deadlock after write failure 2024-01-15 20:09:22 -03:00
Martin Zumsande
74ebd4d135 doc, test: Test and explain service flag handling
Service flags are handled differently, depending on whether
validated (if received from the peer) or unvalidated (received
via gossip relay).
2024-01-15 16:19:53 -05:00
fanquake
05c4c5a434
Merge bitcoin/bitcoin#29227: log mempool loading progress
eb78ea4eeb [log] mempool loading (glozow)

Pull request description:

  Motivated by #29193. Currently, we only log something (non-debug) when we fail to load the file and at the end of importing all the transactions. That means it's hard to tell what's happening if it's taking a long time to load.

  This PR adds a maximum of 10 new unconditional log lines:
  - When we start to load transactions.
  - Our progress percentage when it advances by at least 10% from the last time we logged. Percentage is based on the number of transactions.

  If there are lots of transactions in the mempool, the logs will look like this:
  ```
  2024-01-11T11:36:30.410726Z Loading 401 mempool transactions from disk...
  2024-01-11T11:36:30.423374Z Progress loading mempool transactions from disk: 10% (tried 41, 360 remaining)
  2024-01-11T11:36:30.435539Z Progress loading mempool transactions from disk: 20% (tried 81, 320 remaining)
  2024-01-11T11:36:30.447874Z Progress loading mempool transactions from disk: 30% (tried 121, 280 remaining)
  2024-01-11T11:36:30.460474Z Progress loading mempool transactions from disk: 40% (tried 161, 240 remaining)
  2024-01-11T11:36:30.473731Z Progress loading mempool transactions from disk: 50% (tried 201, 200 remaining)
  2024-01-11T11:36:30.487806Z Progress loading mempool transactions from disk: 60% (tried 241, 160 remaining)
  2024-01-11T11:36:30.501739Z Progress loading mempool transactions from disk: 70% (tried 281, 120 remaining)
  2024-01-11T11:36:30.516334Z Progress loading mempool transactions from disk: 80% (tried 321, 80 remaining)
  2024-01-11T11:36:30.531309Z Progress loading mempool transactions from disk: 90% (tried 361, 40 remaining)
  2024-01-11T11:36:30.549019Z  Imported mempool transactions from disk: 401 succeeded, 0 failed, 0 expired, 0 already there, 400 waiting for initial broadcast
  ```
  If there are 0 or 1 transactions, progress logs aren't printed.

ACKs for top commit:
  kevkevinpal:
    Concept ACK [eb78ea4](eb78ea4eeb)
  ismaelsadeeq:
    ACK eb78ea4eeb
  dergoegge:
    Code review ACK eb78ea4eeb
  theStack:
    re-ACK eb78ea4eeb
  mzumsande:
    tested ACK eb78ea4eeb

Tree-SHA512: ae4420986dc7bd5cb675a7ebc76b24c8ee60007f0296ed37e272f1c3415764d44963bea84c51948da319a65661dca8a95eac2a59bf7e745519b6fcafa09812cf
2024-01-15 15:20:18 +00:00
Murch
89d0956643 opt: Tie-break UTXO sort by waste for BnB
Since we are searching for the minimal waste, we sort UTXOs with equal
effective value by ascending waste to be able to cut barren branches
earlier.
2024-01-15 09:08:01 -05:00
Murch
aaee65823c doc: Document max_weight on BnB 2024-01-15 09:08:01 -05:00
furszy
9f36e591c5
net: move state dependent peer services flags
No behavior change. Just an intermediate refactoring.

By relocating the peer desirable services flags into the peer
manager, we allow the connections acceptance process to handle
post-IBD potential stalling scenarios.

In the follow-up commit(s), the desirable service flags will be
dynamically adjusted to detect post-IBD stalling scenarios (such
as a +48-hour inactive node that must prefer full node connections
instead of limited peer connections because they cannot provide
historical blocks). Additionally, this encapsulation enable us
to customize the connections decision-making process based on
new user's configurations in the future.
2024-01-15 10:28:20 -03:00
furszy
f9ac96b8d6
net: decouple state independent service flags from desirable ones
This former one will be moved to the peer manager class in the
following-up commit.
2024-01-15 10:28:20 -03:00
furszy
97df4e3887
net: store best block tip time inside PeerManager
And implement 'ApproximateBestBlockDepth()' to estimate
the distance, in blocks, between the best-known block
and the network chain tip. Utilizing the best-block time
and the chainparams blocks spacing to approximate it.
2024-01-15 10:28:20 -03:00
Ava Chow
ea2551e55d wallet: Reset chain notifications handler if AttachChain fails
AttachChain will create the chain notifications handler which contains a
reference to the wallet's shared_ptr. If AttachChain fails, the wallet
needs to be unloaded, and this is expected to happen with its custom
deleter ReleaseWallet. However, if the chain notifications handler is
still set, then the shared_ptr is still referenced by something, so the
wallet is never actually released.
2024-01-12 20:09:08 -05:00
Pieter Wuille
3ba815b42d Make v2transport default for addnode RPC when enabled 2024-01-12 09:31:31 -05:00
glozow
eb78ea4eeb [log] mempool loading
Log at the top before incrementing so that this log isn't printed when
there's only 1 tx.
2024-01-12 13:48:02 +00:00
glozow
cd603361a4
Merge bitcoin/bitcoin#28885: mempool / rpc: followup to getprioritisedtransactions and delete a mapDeltas entry when delta==0
0eebd6fe7d test: Assert that a new tx with a delta of 0 is never added (kevkevin)
cfdbcd19b3 rpc: exposing modified_fee in getprioritisedtransactions (kevkevin)
252a86729a rpc: renaming txid -> transactionid (kevkevin)
2fca6c2dd0 rpc: changed prioritisation-map -> "" (kevkevin)
3a118e19e1 test: Directly constructing 2 entry map for getprioritisedtransactions (kevkevin)

Pull request description:

  In this PR I am addressing some comments in https://github.com/bitcoin/bitcoin/pull/27501 as a followup.
  - changed `prioritisation-map` in the `RPCResult` to `""`
  - Directly constructing 2 entry map for getprioritisedtransactions in functional tests
  - renamed `txid` to `transactionid` in `RPCResult` to be more consistent with naming elsewhere
  - exposed the `modified_fee` field instead of having it be a useless arg
  - Created a new test that asserts when `prioritisedtransaction` is called with a fee_delta of 0 it is not added to mempool

ACKs for top commit:
  glozow:
    reACK 0eebd6fe7d, only change is the doc suggestion

Tree-SHA512: e99056e37a8b1cfc511d87c83edba7c928b50d2cd6c2fd7c038976779850677ad37fddeb2b983e8bc007ca8567eb21ebb78d7eae9b773657c2b297299993ec05
2024-01-12 12:03:52 +00:00
fanquake
8c5e4f42d5
Merge bitcoin/bitcoin#29208: build: Bump clang minimum supported version to 14
aaaace2fd1 fuzz: Assume presence of __builtin_*_overflow, without checks (MarcoFalke)
fa223ba5eb Revert "build: Fix undefined reference to __mulodi4" (MarcoFalke)
fa7c751bd9 build: Bump clang minimum supported version to 14 (MarcoFalke)

Pull request description:

  Most supported operating systems ship with clang-14 (or later), so bump the minimum to that and allow new code to drop workarounds for previous clang bugs.

  For reference:
  * https://packages.debian.org/bookworm/clang (`clang-14`)
  * https://packages.ubuntu.com/jammy/clang (`clang-14`)
  * CentOS-like 8/9 Stream: All Clang versions from 15 to 17
  * FreeBSD 12/13: All Clang versions from 15 to 16
  * OpenSuse Tumbleweed ships with https://software.opensuse.org/package/clang (`clang17`); No idea about OpenSuse Leap

  On operating systems where the clang version is not shipped by default, the user would have to use GCC, or install clang in a different way. For example:

  * https://packages.debian.org/bullseye/g++ (g++-10)
  * https://packages.ubuntu.com/focal/g++-10
  * https://apt.llvm.org/, or nix, or guix, or compile clang from source, ...

ACKs for top commit:
  fanquake:
    ACK aaaace2fd1

Tree-SHA512: 81d066b14cc568d27312f1cc814b09540b038a10a0a8e9d71fc9745b024fb6c32a959af673e6819b817ea7cef98da4abfa63dff16cffb7821b40083016b0291f
2024-01-12 10:03:22 +00:00
Chris Stewart
97181decf5 Add test for negative transaction version w/ CSV to tx_valid.json 2024-01-11 15:05:01 -06:00
Andrew Chow
563b2a60d6 wallet: Better error message when missing LegacySPKM during migration 2024-01-11 15:49:51 -05:00
Andrew Chow
b1d2c771d4 wallet: Check for descriptors flag before migration
Previously we would check that there is no LegacySPKM in order to
determine whether a wallet is already a descriptor wallet and doesn't
need to be migrated. However blank legacy wallets will also not have a
LegacySPKM, so we need to be checking for the descriptors flag instead.
2024-01-11 15:49:51 -05:00
Andrew Chow
8c127ff1ed wallet: Skip key and script migration for blank wallets
Blank wallets don't have any keys or scripts to migrate
2024-01-11 15:49:51 -05:00
Ava Chow
4baa162dbb
Merge bitcoin/bitcoin#29212: Fix -netinfo backward compat with getpeerinfo pre-v26
5fa74609b8 Fix -netinfo backward compat with getpeerinfo pre-v26 (Jon Atack)

Pull request description:

  Commit fb5bfed26a in #29058 will cause `-netinfo` to break when calling it on a node that is running pre-v26 bitcoind, as `getpeerinfo` doesn't yet return a "transport_protocol_type" field.

  Fix this by adding an `IsNull()` check, as already done for other recent getpeerinfo fields, and also in the same commit:

  a) avoid checking for the full string "detecting", and instead do the cheaper check for the most frequent case of the string starting with "v"

  b) drop displaying the "v" prefix in all the rows, as it doesn't add useful information, and instead use "v" for the column header

  c) display nothing when a value isn't determined yet, like for the -netinfo mping and ping columns (as `*` already has a separate meaning in this dashboard, and `?` might look like there is a bug)

ACKs for top commit:
  mzumsande:
    Code Review ACK 5fa74609b8
  achow101:
    ACK 5fa74609b8
  kristapsk:
    ACK 5fa74609b8

Tree-SHA512: 4afc513dc669b95037180008eb4c57fc0a0d742c02f24b236562d6b8daad5c120eb1ce0d90e51696e0f9b8361a72fc930c0b64f04902cf96fb48c8e042e58624
2024-01-11 13:04:26 -05:00
Jon Atack
ec779a2b8e doc: add unconditional info loglevel following merge of PR 28318
The `info` loglevel is now logged unconditionally following that merge.

While here, make the help text easier to understand.
2024-01-11 11:01:28 -06:00
kevkevin
cfdbcd19b3
rpc: exposing modified_fee in getprioritisedtransactions
Instead of having modified_fee be hidden we are now exposing it to avoid
having useless code
2024-01-11 08:16:22 -06:00
fanquake
4ae5171d42
Merge bitcoin/bitcoin#29219: fuzz: Improve fuzzing stability for ellswift_roundtrip harness
154fcce55c [fuzz] Improve fuzzing stability for ellswift_roundtrip harness (dergoegge)

Pull request description:

  See #29018

ACKs for top commit:
  sipa:
    utACK 154fcce55c
  brunoerg:
    crACK 154fcce55c

Tree-SHA512: 1e1ee47467a4a0d3a4e79f672018b440d8b3ccafba7428d37b9d0b8d3afd07e3f64f53ee668ed8a6a9ad1919422b5970814eaf857890acae7546951d8cb141d6
2024-01-11 11:51:57 +00:00
Ava Chow
507dbe4ca2
Merge bitcoin/bitcoin#29211: fuzz: fix connman initialization
e84dc36733 fuzz: fix `connman` initialization (brunoerg)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/pull/29172#issuecomment-1883547121

ACKs for top commit:
  achow101:
    ACK e84dc36733

Tree-SHA512: e5f3c378cfe367cc4c387fa1b13663a74d8b667a5d130d62919e21455861cfb9383b63ef4ebe56daab7b2c09e3b5031acc463065455f71607c5fb9e3c370d3ad
2024-01-10 14:20:57 -05:00
Ava Chow
7ff8e6b240
Merge bitcoin/bitcoin#28318: logging: Simplify API for level based logging
e60fc7d5d3 logging: Replace uses of LogPrintfCategory (Anthony Towns)
f7ce5ac08c logging: add LogError, LogWarning, LogInfo, LogDebug, LogTrace (Anthony Towns)
fbd7642c8e logging: add -loglevelalways=1 option (Anthony Towns)
782bb6a056 logging: treat BCLog::ALL like BCLog::NONE (Anthony Towns)
667ce3e329 logging: Drop BCLog::Level::None (Anthony Towns)
ab34dc6012 logging: Log Info messages unconditionally (Anthony Towns)
dfe98b6874 logging: make [cat:debug] and [info] implicit (Anthony Towns)
c5c76dc615 logging: refactor: pull prefix code out (Anthony Towns)

Pull request description:

  Replace `LogPrint*` functions with severity based logging functions:

   * `LogInfo(...)`, `LogWarning(...)`, `LogError(...)` for unconditional (uncategorised) logging (replaces `LogPrintf`)
   * `LogDebug(CATEGORY, ...)` and `LogTrace(CATEGORY, ...)` for conditional logging (replaces `LogPrint`)
   * `LogPrintLevel(CATEGORY, LEVEL, ...)` for when the level isn't known in advance, or a category needs to be added for an info/warning/error log message (mostly unchanged, but rarely needed)

  Logs look roughly as they do now with `LogInfo` not having an `[info]` prefix, and `LogDebug` having a `[cat]` prefix, rather than a `[cat:debug]` prefix. This removes `BCLog::Level::None` entirely -- for `LogFlags::NONE` just use `Level::Info`, for any actual category, use `Level::Debug`.

  Adds docs to developer-notes about when to use which level.

  Adds `-loglevelalways=1` option so that you get `[net:debug]`, `[all:info]`, `[all:warning]` etc, which might be helpful for automated parsing, or just if you like everything to be consistent. Defaults to off to reduce noise in the default config, and to avoid unnecessary changes on upgrades.

  Changes the behaviour of `LogPrintLevel(CATEGORY, BCLog::Level::Info, ...)` to be logged unconditionally, rather than only being an additional optional logging level in addition to trace and debug. Does not change the behaviour of `LogPrintLevel(NONE, Debug, ...)` and `LogPrintLevel(NONE, Trace, ...)` being no-ops.

ACKs for top commit:
  maflcko:
    re-ACK e60fc7d5d3 🌚
  achow101:
    ACK e60fc7d5d3
  stickies-v:
    ACK e60fc7d5d3
  jamesob:
    ACK e60fc7d5d3 ([`jamesob/ackr/28318.1.ajtowns.logging_simplify_api_for`](https://github.com/jamesob/bitcoin/tree/ackr/28318.1.ajtowns.logging_simplify_api_for))

Tree-SHA512: e7a4588779b148242495b7b6f64198a00c314cd57100affab11c43e9d39c9bbf85118ee2002792087fdcffdea08c84576e20844b3079f27083e26ddd7ca15d7f
2024-01-10 14:11:32 -05:00
dergoegge
154fcce55c [fuzz] Improve fuzzing stability for ellswift_roundtrip harness
`CPubKey::VerifyPubKey` uses rng internally which leads to instability
in the fuzz test.

We fix this by avoiding `VerifyPubKey` in the test and verifying the
decoded public key with a fuzzer chosen message instead.
2024-01-10 16:21:16 +00:00
Jon Atack
5fa74609b8 Fix -netinfo backward compat with getpeerinfo pre-v26
CLI -netinfo will currently break when calling it on a node that is running
pre-v26 bitcoind, as `getpeerinfo` doesn't yet return a transport_protocol_type
field.

Fix this by adding an `IsNull()` check as already done for other fields, and also:

- avoid checking for the full string "detecting", and instead do the cheaper
  check for the most frequent case of the string starting with "v"

- drop displaying the "v" prefix in all the rows, as it doesn't add useful
  information, and instead use "v" for the column header

- display nothing during peer setup, like for the -netinfo mping and ping columns
2024-01-09 15:27:08 -06:00
brunoerg
e84dc36733 fuzz: fix connman initialization 2024-01-09 15:15:36 -03:00
Ava Chow
063a8b8387
Merge bitcoin/bitcoin#29058: net, cli: use v2transport for manual/addrfetch connections, add to -netinfo
fb5bfed26a cli: add transport protcol column to -netinfo (Martin Zumsande)
9eed22e870 net: attempt v2 transport for addrfetch connections if we support it (Martin Zumsande)
770c0311ef net: attempt v2 transport for manual connections if we support it (Martin Zumsande)

Pull request description:

  Some preparations before enabling `-v2transport` as the default:
  * Use v2 for `-connect`, `-addnode` config arg and `-seednode` if `-v2transport` is enabled.
  Our peer may or may not support v2, but I don't think an extra option is necessary for any of these (we  have that for the `addnode` rpc), because we have the reconnection mechanism that will try again with `v1` if our peer doesn't support `v2`.
  * Add a column for the transport protocol to `-netinfo`. I added it next to the `net` column because I thought it looked nice there, but if people prefer it somewhere else I'm happy to move it.

  ![Screenshot from 2023-12-11 17-51-22](https://github.com/bitcoin/bitcoin/assets/48763452/b4f5dfcb-16be-4d8f-9303-9d342123deec)

ACKs for top commit:
  sipa:
    utACK fb5bfed26a
  achow101:
    ACK fb5bfed26a
  stratospher:
    tested ACK fb5bfed. addrfetch + manual connections aren't frequent and it would be useful to have this for transition to v2 one day.
  theStack:
    ACK fb5bfed26a
  kristapsk:
    ACK fb5bfed26a

Tree-SHA512: c4575ad11b99613870b342acae369fa08f877ac79e6e04eb62e94ad7a92d528e289183c0963c78aa779ba11cb91e2a6fad7c8b0d813126c46c3e5b54bd962c26
2024-01-09 12:46:52 -05:00
fanquake
5a121bcdee
Merge bitcoin/bitcoin#29200: net: create I2P sessions using both ECIES-X25519 and ElGamal encryption
9d728916b2 net: create I2P sessions with both ECIES-X25519 and ElGamal encryption (Jon Atack)

Pull request description:

  A Bitcoin Core node may only connect to a peer destination via I2P if both sides have sessions with the same encryption type.  Encryption type is a property of the session, not the destination.  Sessions may support multiple encryption types.

  As Bitcoin Core is not currently setting the encryption type when creating I2P sessions, it uses the older default, ElGamal (type 0).

  This pull updates our I2P session creation to use both ECIES-X25519 and ElGamal (types 4 and 0, respectively). This allows to connect to I2P peers of either type, and the newer, faster ECIES-X25519 will be preferred.

  See also:

  - discussion around https://github.com/qbittorrent/qBittorrent/issues/19625#issuecomment-1879582395
  - recently updated "Signature and Encryption Types" in https://geti2p.net/en/docs/api/samv3

  Thank you and credit to zzzi2p for reporting and to vort for the patch.

  Closes https://github.com/bitcoin/bitcoin/issues/29197.

ACKs for top commit:
  zzzi2p:
    ACK 9d728916b2
  recursive-rat4:
    ACK 9d728916b2
  kristapsk:
    cr utACK 9d728916b2
  brunoerg:
    crACK 9d728916b2
  shaavan:
    crACK 9d728916b2

Tree-SHA512: 0912fc01af9706914a7854f7479b9d82fc86c9530466cad8674e30f7eb4894d90d514efbc1aee8b7ea690faa6ff4a23b62cf5de8737cffdbc463300082c9b917
2024-01-09 17:08:06 +00:00
MarcoFalke
aaaace2fd1
fuzz: Assume presence of __builtin_*_overflow, without checks 2024-01-09 16:46:58 +01:00
MarcoFalke
fa223ba5eb
Revert "build: Fix undefined reference to __mulodi4"
This reverts commit e4c8bb62e4.
2024-01-09 15:38:57 +01:00
fanquake
f921d949a0
Merge bitcoin/bitcoin#29172: fuzz: set nMaxOutboundLimit in connman target
e5b9ee0221 fuzz: set `nMaxOutboundLimit` in connman target (brunoerg)

Pull request description:

  Setting `nMaxOutboundLimit` (`-maxuploadtarget`) will make fuzz to reach more coverage in connman target. This value is used in `GetMaxOutboundTimeLeftInCycle`, `OutboundTargetReached` and `GetOutboundTargetBytesLeft`.

ACKs for top commit:
  dergoegge:
    utACK e5b9ee0221
  jonatack:
    ACK e5b9ee0221

Tree-SHA512: d19c83602b0a487e6da0e3be539aa2abc95b8bbf36cf9a3e391a4af53b959f68ca38548a96d27d56742e3b772f648da04e2bf8973dfc0ab1cdabf4f2e8d44de6
2024-01-09 09:43:13 +00:00
kevkevin
252a86729a
rpc: renaming txid -> transactionid
renamed to transactionid because it is named this way in getrawmempool
and getmempoolancestors
2024-01-08 19:01:45 -06:00
kevkevin
2fca6c2dd0
rpc: changed prioritisation-map -> ""
prioritisation-map gets eaten by the help generator to be "" so we are
setting to "" to begin with
2024-01-08 19:01:21 -06:00
fanquake
c2d04f1319
Merge bitcoin/bitcoin#28610: wallet: Migrate entire address book entries to watchonly and solvables too
406b71abcb wallet: Migrate entire address book entries (Andrew Chow)

Pull request description:

  Not all of the data in an address book entry was being copied to the watchonly and solvables wallets. This includes information such as whether the address was previously spent, and any receive requests that may exist. A test has been added to check that the previously spent information is copied, although it passes without the changes in this PR since this information is also regenerated when a transaction is loaded/added into a wallet.

ACKs for top commit:
  ryanofsky:
    Code review ACK 406b71abcb. Just suggested change since last review
  furszy:
    Code review ACK 406b71ab

Tree-SHA512: 13de42b16a1d8524fe0555764744139566b2e7d29741ceffc1158a905dd537136b762330568b3b5cac28cbee1bfd363a20de97d0a6c5296738cb3aa99133945b
2024-01-08 14:44:47 +00:00
glozow
04b9df0f9f
Merge bitcoin/bitcoin#29184: RPC/Blockchain: scanblocks: Accept named param for filter_false_positives
5779010ed7 RPC/Blockchain: scanblocks: Accept named param for filter_false_positives (Luke Dashjr)

Pull request description:

  Possibly due to a silent cross-merge, `scanblocks` was left out of 96233146dd

ACKs for top commit:
  stickies-v:
    ACK 5779010ed7
  theStack:
    ACK 5779010ed7

Tree-SHA512: bade107c7cb5fdd1265224c263a1e1edfc8bc0698b3abfac8d65c49a270181f0311713f7243813de17932a7a7ca65a36850e527ab0b433cf64c32191d3adde70
2024-01-08 10:37:04 +00:00
Jon Atack
9d728916b2 net: create I2P sessions with both ECIES-X25519 and ElGamal encryption
A Bitcoin Core node may only connect to a peer destination via I2P if both sides
have sessions with the same encryption type.  The encryption type is a property
of the session, not the destination.  Sessions may support multiple encryption
types.

As Bitcoin Core is not currently setting the I2P encryption type when creating
sessions, it is using the older default, ElGamal (type 0).

This pull updates Bitcoin Core to use both ECIES-X25519 and ElGamal (types 4 and
0, respectively).  This allows to connect to I2P peers with either type, and the
newer, faster ECIES-X25519 will be preferred.

See also the recently updated section "Signature and Encryption Types" in
https://geti2p.net/en/docs/api/samv3

Thanks and credit to zzzi2p (https://github.com/zzzi2p) for reporting.

Closes https://github.com/bitcoin/bitcoin/issues/29197.
2024-01-07 16:24:08 -06:00
furszy
595d50a103
wallet: migration, remove extra NotifyTransactionChanged call
The wallet is unloaded at the beginning of the migration process,
so no object is listening to the signals.
2024-01-06 12:40:20 -03:00
furszy
a2b071f992
wallet: ZapSelectTx, remove db rewrite code
The function does not return DBErrors::NEED_REWRITE.
2024-01-06 12:40:19 -03:00
fanquake
04978c2e18
Merge bitcoin/bitcoin#29117: wallettool: Always be able to dump a wallet's database
d83bea42d1 wallettool: Don't create CWallet when dumping DB (Andrew Chow)
40c80e36b1 wallettool: Don't unilaterally reset wallet_instance if loading error (Ava Chow)

Pull request description:

  https://github.com/bitcoin/bitcoin/issues/29109#issuecomment-1863449058 reports that a wallet with noncritical errors cannot be dumped with `bitcoin-wallet dump`. This was caused by an erroneous reset of the wallet pointer when the loading the wallet returns something other than `LOAD_OK`. Not all errors are errors that require aborting, so unilaterally resetting the pointer at that time is incorrect. The first commit resolves this issue.

  Furthermore, if a wallet has loading errors, that should not prevent the wallet tool from dumping the wallet. The wallet application logic should not get in the way of performing such a low level database operation, especially when it's primary usage is for debugging potentially corrupted wallets. The 2nd commit is taken from #28710 and changes the `dump` to stop at making a `WalletDatabase` rather than making a `CWallet` only to retrieve the underlying `WalletDatabase`.

ACKs for top commit:
  furszy:
    Code review ACK d83bea42d1
  BrandonOdiwuor:
    Code Review ACK d83bea42d1

Tree-SHA512: 425d712dfff1002bd81272aca0bae1016f9126a3c89506f8cb7cf0a0ec9f33d0c03b8d03896394f3a45c2998e59047e19218dfd08dc8a5f40e8625134e886b0f
2024-01-05 17:40:44 +00:00
dergoegge
ff9039f6ea Remove GetAdjustedTime 2024-01-05 17:16:38 +00:00
Cory Fields
bbf218d061 crypto: remove sha256_sse4 from the base crypto helper lib
It was unused there and a confusing outlier.
2024-01-05 17:09:14 +00:00
Fabian Jahr
6044628543
crypto, hash: replace custom rotl32 with std::rotl 2024-01-05 17:12:38 +01:00
brunoerg
e5b9ee0221 fuzz: set nMaxOutboundLimit in connman target 2024-01-05 12:38:35 -03:00
fanquake
7c248b972b
Merge bitcoin/bitcoin#29042: doc: Clarify C++20 comments
fa87f8feb7 doc: Clarify C++20 comments (MarcoFalke)

Pull request description:

  Turns out "class template argument deduction for aggregates" is one of the few things implemented only in recent compilers, see https://en.cppreference.com/w/cpp/compiler_support/20

  So clarify the comments.

ACKs for top commit:
  hebasto:
    ACK fa87f8feb7, I verified the code with clang-{16,17}.

Tree-SHA512: f6d20f946cb6f8e34db224e074ed8f9dfa598377c066d1b58a8feb9e64d007444f1e2c0399e91a3e282fd5d59f90e0d7df90aa3956824d96bc78070ee12f603c
2024-01-05 15:37:06 +00:00
fanquake
2d1b1c7dae
build: remove --enable-lto
This has outlived its usefulness, doesn't gel well with
newer compilers & `-flto` related options, i.e thin vs full, or `=auto`,
and having `-flto` as the only option means that sometimes this just
needs to be worked around, i.e in oss-fuzz:
https://github.com/google/oss-fuzz/blob/master/projects/bitcoin-core/build.sh.

While it was convenient when `-flto` was newer, support for `-flto` is now
in all compilers we use, and there's also no-longer any real need
for us to treat `-flto` different to any other optimization option.

Remove it, to remove build complexity, and so there's no need
to port a similar option to CMake.

Note that the LTO option remains in depends, because we still a way to
build packages that have LTO specific patches/options.

If we decide to merge this, I'll follow up downstream in oss-fuzz first,
to make sure we don't break the build.
2024-01-05 15:17:50 +00:00
Cory Fields
4dbd0475d8 crypto: remove use of BUILD_BITCOIN_INTERNAL macro in sha256
Replace it with a more explicit DISABLE_OPTIMIZED_SHA256 and clean up some.

The macro was originally used by libbitcoinconsensus which opts out of
optimized sha256 for the sake of simplicity.

Also remove the BUILD_BITCOIN_INTERNAL define from libbitcoinkernel for now
as it does not export an api. When it does we can pick a less confusing define
to control its exports.

Removing the define should have the effect of enabling sha256 optimizations
for the kernel.
2024-01-05 12:31:33 +00:00
fanquake
143ace65db
Merge bitcoin/bitcoin#28890: rpc: Remove deprecated -rpcserialversion
fa46cc22bc Remove deprecated -rpcserialversion (MarcoFalke)

Pull request description:

  The flag is problematic for many reasons:

  * It is deprecated
  * It is a global flag, requiring a restart to change, as opposed to a flag that can be set on each RPC invocation
  * It may be hidden in config files by accident, hard to debug, causing LND crashes and bugs, see https://github.com/bitcoin/bitcoin/issues/28730#issuecomment-1780940868
  * It makes performance improvements harder to implement: https://github.com/bitcoin/bitcoin/pull/17529#issuecomment-556082818

  Fix all issues by removing it.

  If there is a use-case, likely a per-RPC flag can be added, if needed.

ACKs for top commit:
  ajtowns:
    crACK fa46cc22bc
  TheCharlatan:
    lgtm ACK fa46cc22bc

Tree-SHA512: 96ba1c60356ce93954fe5c2a59045771c6d1516ad0d9dc436ef1800a1f1b0153f0d5fb78ca99d53ad54ba25fbce36962bdf1d4325aceedfc8154a61347a6a915
2024-01-05 10:42:10 +00:00
MarcoFalke
fa87f8feb7
doc: Clarify C++20 comments 2024-01-05 11:22:31 +01:00
Ava Chow
d44554567f
Merge bitcoin/bitcoin#28832: fuzz: rule-out too deep derivation paths in descriptor parsing targets
a44808fb43 fuzz: rule-out too deep derivation paths in descriptor parsing targets (Antoine Poinsot)

Pull request description:

  This fixes the `mocked_descriptor_parse` timeout reported in #28812 and direct the targets more toward what they are intended to fuzz: the descriptor syntax.

ACKs for top commit:
  sipa:
    utACK a44808fb43
  achow101:
    ACK a44808fb43
  dergoegge:
    ACK a44808fb43 - Not running into timeouts anymore
  TheCharlatan:
    ACK a44808fb43

Tree-SHA512: a5dd1dbe9adf8f088bdc435addab88b56f435e6d7d2065bd6d5c6d80a32e3f1f97d3d2323131ab233618cd6dcc477c458abe3c4c865ab569449b8bc176231e93
2024-01-04 18:10:22 -05:00
Luke Dashjr
5779010ed7 RPC/Blockchain: scanblocks: Accept named param for filter_false_positives 2024-01-04 21:22:15 +00:00
glozow
737e5884cc
Merge bitcoin/bitcoin#29169: Update libsecp256k1 subtree to current master
29fde0223a Squashed 'src/secp256k1/' changes from 199d27cea3..efe85c70a2 (fanquake)

Pull request description:

  This includes changes from the 0.4.1 release: https://github.com/bitcoin-core/secp256k1/releases/tag/v0.4.1.

  > The point multiplication algorithm used for ECDH operations (module ecdh) was replaced with a slightly faster one.

  > Optional handwritten x86_64 assembly for field operations was removed because modern C compilers are able to output more efficient assembly. This change results in a significant speedup of some library functions when handwritten x86_64 assembly is enabled (--with-asm=x86_64 in GNU Autotools, -DSECP256K1_ASM=x86_64 in CMake), which is the default on x86_64. Benchmarks with GCC 10.5.0 show a 10% speedup for secp256k1_ecdsa_verify and secp256k1_schnorrsig_verify.

ACKs for top commit:
  hebasto:
    re-ACK e2cdeb5925
  jonasnick:
    reACK e2cdeb5925

Tree-SHA512: eaa82721b63e84b9d8dae82956d5e75dbcee50c58c9049b7901055d79aef938bd268e18ce4ff85feb73aae7ee1cf58018b93067692f8f69f80216d336bd6f10a
2024-01-04 16:55:02 +00:00
fanquake
e2cdeb5925
Update secp256k1 subtree to latest master 2024-01-04 14:40:28 +00:00
fanquake
29fde0223a Squashed 'src/secp256k1/' changes from 199d27cea3..efe85c70a2
efe85c70a2 Merge bitcoin-core/secp256k1#1466: release cleanup: bump version after 0.4.1
4b2e06f460 release cleanup: bump version after 0.4.1
1ad5185cd4 Merge bitcoin-core/secp256k1#1465: release: prepare for 0.4.1
672053d801 release: prepare for 0.4.1
1a81df826e Merge bitcoin-core/secp256k1#1380: Add ABI checking tool for release process
74a4d974d5 doc: Add ABI checking with `check-abi.sh` to the Release Process
e7f830e32c Add `tools/check-abi.sh`
77af1da9f6 Merge bitcoin-core/secp256k1#1455: doc: improve secp256k1_fe_set_b32_mod doc
3928b7c383 doc: improve secp256k1_fe_set_b32_mod doc
5e9a4d7aec Merge bitcoin-core/secp256k1#990: Add comment on length checks when parsing ECDSA sigs
4197d667ec Merge bitcoin-core/secp256k1#1431: Add CONTRIBUTING.md
0e5ea62207 CONTRIBUTING: add some coding and style conventions
e2c9888eee Merge bitcoin-core/secp256k1#1451: changelog: add entry for "field: Remove x86_64 asm"
d2e36a2b81 changelog: add entry for "field: Remove x86_64 asm"
1a432cb982 README: update first sentence
0922a047fb docs: move coverage report instructions to CONTRIBUTING
76880e4015 Add CONTRIBUTING.md including scope and guidelines for new code
d3e29db8bb Merge bitcoin-core/secp256k1#1450: Add group.h ge/gej equality functions
04af0ba162 Replace ge_equals_ge[,j] calls with group.h equality calls
60525f6c14 Add unit tests for group.h equality functions
a47cd97d51 Add group.h ge/gej equality functions
10e6d29b60 Merge bitcoin-core/secp256k1#1446: field: Remove x86_64 asm
07687e811d Merge bitcoin-core/secp256k1#1393: Implement new policy for VERIFY_CHECK and #ifdef VERIFY (issue #1381)
bb4672342e remove VERIFY_SETUP define
a3a3e11acd remove unneeded VERIFY_SETUP uses in ECMULT_CONST_TABLE_GET_GE macro
a0fb68a2e7 introduce and use SECP256K1_SCALAR_VERIFY macro
cf25c86d05 introduce and use SECP256K1_{FE,GE,GEJ}_VERIFY macros
5d89bc031b remove superfluous `#ifdef VERIFY`/`#endif` preprocessor conditions
c2688f8de9 redefine VERIFY_CHECK to empty in production (non-VERIFY) mode
5814d8485c Merge bitcoin-core/secp256k1#1438: correct assertion for secp256k1_fe_mul_inner
c1b4966410 Merge bitcoin-core/secp256k1#1445: bench: add --help option to bench_internal
f07cead0ca build: Don't call assembly an optimization
2f0762fa8f field: Remove x86_64 asm
1ddd76af0a bench: add --help option to bench_internal
e72103932d Merge bitcoin-core/secp256k1#1441: asm: add .note.GNU-stack section for non-exec stack
ea47c82e01 Merge bitcoin-core/secp256k1#1442: Return temporaries to being unsigned in secp256k1_fe_sqr_inner
dcdda31f2c Tighten secp256k1_fe_mul_inner's VERIFY_BITS checks
10271356c8 Return temporaries to being unsigned in secp256k1_fe_sqr_inner
33dc7e4d3e asm: add .note.GNU-stack section for non-exec stack
c891c5c2f4 Merge bitcoin-core/secp256k1#1437: ci: Ignore internal errors of snapshot compilers
8185e72d29 ci: Ignore internal errors in snapshot compilers
40f50d0fbd Merge bitcoin-core/secp256k1#1184: Signed-digit based ecmult_const algorithm
8e2a5fe908 correct assertion for secp256k1_fe_mul_inner
355bbdf38a Add changelog entry for signed-digit ecmult_const algorithm
21f49d9bec Remove unused secp256k1_scalar_shr_int
115fdc7232 Remove unused secp256k1_wnaf_const
aa9f3a3c00 ecmult_const: add/improve tests
4d16e90111 Signed-digit based ecmult_const algorithm
ba523be067 make SECP256K1_SCALAR_CONST reduce modulo exhaustive group order
2140da9cd5 Add secp256k1_scalar_half for halving scalars (+ tests/benchmarks).
1f1bb78b7f Merge bitcoin-core/secp256k1#1430: README: remove CI badge
5dab0baa80 README: remove CI badge
b314cf2833 Merge bitcoin-core/secp256k1#1426: ci/cirrus: Add native ARM64 jobs
fa4d6c76b6 ci/cirrus: Add native ARM64 persistent workers
ee7aaf213e Merge bitcoin-core/secp256k1#1395: tests: simplify `random_fe_non_zero` (remove loop limit and unneeded normalize)
ba9cb6f378 Merge bitcoin-core/secp256k1#1424: ci: Bump major versions for docker actions
d9d80fd155 ci: Bump major versions for docker actions
4fd00f4bfe Merge bitcoin-core/secp256k1#1422: cmake: Install `libsecp256k1.pc` file
421d84855a ci: Align Autotools/CMake `CI_INSTALL` directory names
9f005c60d6 cmake: Install `libsecp256k1.pc` file
2262d0eaab ci/cirrus: Bring back skeleton .cirrus.yml without jobs
b10ddd2bd2 Merge bitcoin-core/secp256k1#1416: doc: Align documented scripts with CI ones
49be5be9e8 Merge bitcoin-core/secp256k1#1390: tests: Replace counting_illegal_callbacks with CHECK_ILLEGAL_VOID
cbf3053ff1 Merge bitcoin-core/secp256k1#1417: release cleanup: bump version after 0.4.0
9b118bc7fb release cleanup: bump version after 0.4.0
70303643cf tests: add CHECK_ERROR_VOID and use it in scratch tests
f8d7ea68df tests: Replace counting_illegal_callbacks with CHECK_ILLEGAL_VOID
b0f7bfedc9 doc: Do not mention soname in CHANGELOG.md "ABI Compatibility" section
bd9d98d353 doc: Align documented scripts with CI ones
a1d52e3e12 tests: remove unnecessary test in run_ec_pubkey_parse_test
875b0ada25 tests: remove unnecessary set_illegal_callback
c45b7c4fbb refactor: introduce testutil.h (deduplicate `random_fe_`, `ge_equals_` helpers)
dc5514144f tests: simplify `random_fe_non_zero` (remove loop limit and unneeded normalize)
e02f313b1f Add comment on length checks when parsing ECDSA sigs

git-subtree-dir: src/secp256k1
git-subtree-split: efe85c70a2e357e3605a8901a9662295bae1001f
2024-01-04 14:40:28 +00:00
MarcoFalke
faebf1df2a
wallet: Fix use-after-free in WalletBatch::EraseRecords 2024-01-04 12:16:36 +01:00
Gloria Zhao
65c05db660
Merge bitcoin/bitcoin#29013: test: doc: follow-up #28368
b1318dcc56 test: change `m_submitted_in_package` input to fuzz data provider boolean (ismaelsadeeq)
5615e16b70 tx fees: update `m_from_disconnected_block` to `m_mempool_limit_bypassed` (ismaelsadeeq)
fcd4296648 doc: fix typo and update incorrect comment (ismaelsadeeq)
562664d263 test: wait for fee estimator to catch up before estimating fees (ismaelsadeeq)

Pull request description:

  This is a simple PR that does two things
  1.   Fixes #29000 by waiting for the fee estimator to catch up after `removeForBlock` calls before calling `estimateFee` in the `BlockPolicyEstimates` unit test.

  2. Addressed some outstanding review comments from #28368
  - Updated `NewMempoolTransactionInfo::m_from_disconnected_block` to `NewMempoolTransactionInfo::m_mempool_limit_bypassed` which now correctly indicates what the boolean does.
  - Changed  input of `processTransaction`'s tx_info  `m_submitted_in_package` input from false to fuzz data provider boolean.
  - Fixed some typos, and update incorrect comment

ACKs for top commit:
  martinus:
    re-ACK b1318dcc56
  glozow:
    utACK b1318dcc56

Tree-SHA512: 45268729bc044da4748fe004524e0df696d2ec92c5bd053db9aad6e15675f3838429b2a7b9061a6b694be4dc319d1782a876b44df506ddd439d62ad07252d0e1
2024-01-03 11:23:27 +00:00
Ava Chow
c3038bf95a
Merge bitcoin/bitcoin#29076: fuzz: set m_fallback_fee and m_fee_mode in wallet_fees target
e03d6f7ed5 fuzz: set `m_fallback_fee`/`m_fee_mode` in `wallet_fees` target (brunoerg)

Pull request description:

  `m_fallback_fee` and `m_fee_mode` are used in `GetMinimumFeeRate` but we're not setting any value for them in `wallet_fees` target. That's the reason fuzzing is never reaching the following code:

  ![Screenshot 2023-12-13 at 15 04 30](https://github.com/bitcoin/bitcoin/assets/19480819/454ddcaa-75ca-452f-ad13-5f142de0bdce)

  This PR fixes it.

ACKs for top commit:
  maflcko:
    review ACK e03d6f7ed5
  achow101:
    ACK e03d6f7ed5
  murchandamus:
    ACK e03d6f7ed5

Tree-SHA512: 5d364f5351d65762a3ddf88e3abb7bda401b7e4955285e083031d216fb50082b1ea98e2c065aff75a5a8a3d1bc4c2e5e3ca9f9478d902ee8f8d4347b6cbe53af
2024-01-02 11:33:29 -05:00
Ava Chow
00bf4a1711
Merge bitcoin/bitcoin#26684: bench: add readblock benchmark
1c4b9cbe90 bench: add readblock benchmark (Andrew Toth)

Pull request description:

  Requested in https://github.com/bitcoin/bitcoin/pull/13151#issuecomment-385962450.
  See https://github.com/bitcoin/bitcoin/pull/26415 and https://github.com/bitcoin/bitcoin/pull/21319.

  Benchmarking shows a >50x increase in speed on both nvme and spinning disk.

  Benchmark results:
  |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |        5,377,375.00 |              185.96 |    0.2% |   60,125,513.00 |   11,633,676.00 |  5.168 |   3,588,800.00 |    0.4% |      0.09 | `ReadBlockFromDiskTest`

  |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |           89,945.58 |           11,117.83 |    0.7% |       12,743.90 |       64,530.33 |  0.197 |       2,595.20 |    0.2% |      0.01 | `ReadRawBlockFromDiskTest`

ACKs for top commit:
  maflcko:
    lgtm ACK 1c4b9cbe90
  achow101:
    ACK 1c4b9cbe90
  TheCharlatan:
    ACK 1c4b9cbe90

Tree-SHA512: 71dbcd6c7e2be97eb3001e35d0a95ef8e0c9b10dc9193025c7f8e11a09017fa2fbf89489b686353cd88fb409fb729fe2c4a25c567d2988f64c9c164ab09fba9f
2024-01-02 11:12:32 -05:00
ismaelsadeeq
b1318dcc56 test: change m_submitted_in_package input to fuzz data provider boolean
In reality some mempool transaction might be submitted in a package,
so change m_submitted_in_package to fuzz data provider boolean just like
m_has_no_mempool_parents.
2024-01-02 12:41:01 +01:00