Commit graph

25659 commits

Author SHA1 Message Date
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
ismaelsadeeq
5615e16b70 tx fees: update m_from_disconnected_block to m_mempool_limit_bypassed
The boolean indicates whether the transaction was added without enforcing mempool
fee limits. m_mempool_limit_bypassed is the correct variable name.

Also changes NewMempoolTransactionInfo booleans descriptions to the format that
is consistent with the codebase.
2024-01-02 12:41:01 +01:00
ismaelsadeeq
fcd4296648 doc: fix typo and update incorrect comment 2024-01-02 12:40:11 +01:00
Antoine Poinsot
a44808fb43
fuzz: rule-out too deep derivation paths in descriptor parsing targets
This fixes the reported timeouts and direct the target cycles toward what it's intended to fuzz: the descriptor syntax.
2023-12-31 16:19:56 +01:00
Martin Zumsande
fb5bfed26a cli: add transport protcol column to -netinfo 2023-12-27 16:41:17 -05:00
Martin Zumsande
9eed22e870 net: attempt v2 transport for addrfetch connections if we support it 2023-12-27 16:41:17 -05:00
Martin Zumsande
770c0311ef net: attempt v2 transport for manual connections if we support it
This affects manual connections made either with -connect, or with
-addnode provided as a bitcoind config arg (the addnode RPC has an
extra option for v2).

We don't necessarily know if our peer supports v2, but will reconnect
with v1 if they don't. In order to do that, improve the reconnection
behavior such that we will reconnect after a sleep of 500ms
(which usually should be enough for our peer to send us their
version message).
2023-12-27 16:39:32 -05:00
Luke Dashjr
d298ff8b62 During IBD, prune as much as possible until we get close to where we will eventually keep blocks 2023-12-27 02:57:30 +00:00
Sebastian Falbesoner
fa1d49542e refactor: share and use GenerateRandomKey helper
Making the `GenerateRandomKey` helper available to other modules via
key.{h.cpp} allows us to create random private keys directly at
instantiation of CKey, in contrast to the two-step process of creating
the instance and then having to call `MakeNewKey(...)`.
2023-12-23 13:26:00 +01:00
MarcoFalke
fab41697a5
Allow int8_t optimized vector serialization
int8_t serialization is allowed, but not the optimized vector
serialization. Fix that.
2023-12-22 09:58:19 +01:00
MarcoFalke
facaa14785
Faster std::byte (pre)vector (un)serialize 2023-12-22 09:58:18 +01:00
Ava Chow
dca0f231fa
Merge bitcoin/bitcoin#29056: refactor: Print verbose serialize compiler error messages
fae526345d Allow std::byte C-style array serialization (MarcoFalke)
fa898e6836 refactor: Print verbose serialize compiler error messages (MarcoFalke)

Pull request description:

  Currently, trying to serialize an object that can't be serialized will fail with a short error message. For example, the diff and the error message:

  ```diff
  diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp
  index d75eb499b4..773f49845b 100644
  --- a/src/test/serialize_tests.cpp
  +++ b/src/test/serialize_tests.cpp
  @@ -62,6 +62,8 @@ public:

   BOOST_AUTO_TEST_CASE(sizes)
   {
  +    int b[4];
  +    DataStream{} << b << Span{b};
       BOOST_CHECK_EQUAL(sizeof(unsigned char), GetSerializeSize((unsigned char)0));
       BOOST_CHECK_EQUAL(sizeof(int8_t), GetSerializeSize(int8_t(0)));
       BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(uint8_t(0)));
  ```

  ```
  ./serialize.h:765:6: error: member reference base type 'const int[4]' is not a structure or union
    765 |     a.Serialize(os);
        |     ~^~~~~~~~~~
  ```
  ```
  ./serialize.h:277:109: error: no matching function for call to 'UCharCast'
    277 | template <typename Stream, typename B> void Serialize(Stream& s, Span<B> span) { (void)/* force byte-type */UCharCast(span.data()); s.write(AsBytes(span)); }
        |                                                                                                             ^~~~~~~~~
  ```

  This is fine. However, it would be more helpful for developers and more accurate by the compiler to explain why each function is not selected.

  Fix this by using C++20 concepts where appropriate.

ACKs for top commit:
  ajtowns:
    reACK fae526345d
  achow101:
    ACK fae526345d
  TheCharlatan:
    Re-ACK fae526345d

Tree-SHA512: e03a684ccfcc5fbcad7f8a4899945a05989b555175fdcaebdb113aff46b52b4ee7b467192748edf99c5c348a620f8e52ab98bed3f3fca88280a64dbca458fe8a
2023-12-21 12:27:21 -05:00
Ava Chow
eefe4bacdd
Merge bitcoin/bitcoin#29027: wallet: fix key parsing check for miniscript expressions
e1281f1bbd wallet: fix key parsing check for miniscript expressions in `ParseScript` (brunoerg)

Pull request description:

  In `ParseScript`, when processing miniscript expressions, the way we check for key parsing error is wrong, the actual code is unreachable because we're checking it into `if (node)` (successful parsing) statement.

ACKs for top commit:
  sipa:
    utACK e1281f1bbd
  RandyMcMillan:
    utACK e1281f1bbd
  achow101:
    ACK e1281f1bbd

Tree-SHA512: c4b3765d32673928a1f6d84ecbaa311870da9a9625753ed15ea57c802a9f16ddafa48c1dc66c0e4be284c5862e7821ed94135498ed9b9f3d7342a080035da289
2023-12-21 12:06:35 -05:00
Ava Chow
7524fcff86
Merge bitcoin/bitcoin#28372: fuzz: coinselection, improve min_viable_change/change_output_size
cd810075ed fuzz: coinselection, improve `min_viable_change`/`change_output_size` (brunoerg)

Pull request description:

  Instead of "randomly" fuzzing `min_viable_change` and `change_output_size`, and since they're correlated, this PR changes the approach to fuzz them according to the logic in `CreateTransactionInternal`.

ACKs for top commit:
  murchandamus:
    ACK cd810075ed
  achow101:
    ACK cd810075ed
  furszy:
    Code ACK cd810075ed

Tree-SHA512: 4539b469f00cdf666078d80c07ed062726f804e390400348148cd3092db9cdc178c6d00ead39aef19acf97badfb6576ce23546d8967387e81c5398d52d7f4404
2023-12-20 19:45:41 -05:00
glozow
3a0f54dd24
Merge bitcoin/bitcoin#29115: [doc]: add doxygen comment describing what CheckPackageLimits returns
19bb65bf25 [doc]: add doxygen return comment for CheckPackageLimits (ismaelsadeeq)

Pull request description:

  This PR adds a  doxygen comment on `CheckPackageLimits` describing what the method returns.

  Fixes https://github.com/bitcoin/bitcoin/pull/28863#discussion_r1429805433

ACKs for top commit:
  Sjors:
    utACK 19bb65bf25
  Zero-1729:
    utACK 19bb65bf25

Tree-SHA512: ccf1cc00a44d3fff60f28ad6766019a9f61b349729eab3cb02bc76b13c2e55441348a1602d806e60e4b2eabeb1f5d1ddacddf86c0bcdb78b078bb3a863b650c2
2023-12-20 10:48:41 +00:00
Anthony Towns
e60fc7d5d3 logging: Replace uses of LogPrintfCategory
Replace LogPrintfCategory with alternative unconditional log statements.
2023-12-20 15:59:48 +10:00
Anthony Towns
f7ce5ac08c logging: add LogError, LogWarning, LogInfo, LogDebug, LogTrace
These provide simple and clear ways to write the most common logging
operations:

    LogInfo("msg");
    LogDebug(BCLog::LogFlags::NET, "msg");

    LogError("msg");
    LogWarning("msg");
    LogTrace(BCLog::LogFlags::NET, "msg");

For cases where the level cannot be hardcoded, LogPrintLevel(category,
level, ...) remains available.
2023-12-20 15:59:48 +10:00
Ava Chow
e3847f7ac4
Merge bitcoin/bitcoin#29037: Add multiplication operator to CFeeRate
1757452cc5 test: Add tests for CFeeRate multiplication operator (Kashif Smith)
1553c80786 Add multiplication operator to CFeeRate (Murch)

Pull request description:

  Allows us to use
  `coin_selection_params.m_long_term_feerate * 3`
  or
  `3 * coin_selection_params.m_long_term_feerate`
  instead of
  `CFeeRate{coin_selection_params.m_long_term_feerate.GetFee(3000)}`

  inspired by https://github.com/bitcoin/bitcoin/pull/27877#discussion_r1414455724

ACKs for top commit:
  kevkevinpal:
    reACK [1757452](1757452cc5)
  achow101:
    ACK 1757452cc5
  ajtowns:
    ACK 1757452cc5 ; lgtm
  ismaelsadeeq:
    ACK 1757452cc5

Tree-SHA512: a86faac1efd1b7688630cd811246533d184d56b62064a7fd9007de95dbf81fa668aa2252253d102fba67517b6a4ca2dc367c5388b8ab936215734d7d370740cf
2023-12-19 19:36:06 -05:00
Andrew Chow
d83bea42d1 wallettool: Don't create CWallet when dumping DB
It's not necessary to set up an entire CWallet just so we can get access
to the WalletDatabase and read the records. Instead we can go one level
lower and make just a WalletDatabase.
2023-12-19 16:54:06 -05:00
Ava Chow
40c80e36b1 wallettool: Don't unilaterally reset wallet_instance if loading error
When there is a wallet loading error, it could be a noncritical one so
it is not necessary to make wallet_instance a nullptr. The wallet can
still go on with normal operation in that case, as we do for loading in
bitcoind and bitcoin-qt.
2023-12-19 16:54:06 -05:00
ismaelsadeeq
19bb65bf25 [doc]: add doxygen return comment for CheckPackageLimits 2023-12-19 17:12:45 +01:00
glozow
dd391944dc
Merge bitcoin/bitcoin#28863: wallet, mempool: propagete checkChainLimits error message to wallet
8dec9c560b wallet, mempool: propagete `checkChainLimits` error message to wallet (ismaelsadeeq)

Pull request description:

  * Requested in [#28391 comment](https://github.com/bitcoin/bitcoin/pull/28391#discussion_r1382997719)

  * The error message is static when a new transaction is created and package limit is reached.
  `Transaction has too long of a mempool chain`
  While the [`CTxMempool::CheckPackageLimits`](5800c558eb/src/txmempool.cpp (L199)) provide explicit information about the error message.
  * This PR updates [`CTxMempool::CheckPackageLimits`](5800c558eb/src/txmempool.cpp (L199)) return type to `util::Result<void>`, `CheckPackageLimits` now returns void when package limit is not hit, and returns the error string whenever package limit is hit instead of using out parameter `errString`.
  * The PR updates [`checkChainLimits`](5800c558eb/src/node/interfaces.cpp (L703)) return type to `util::Result<void>`.

  * Now the wallet `CreateTransactionInternal` will have access to the package limit error string whenever its hit.
  * Also Updated functional test to reflect the error message from `CTxMempool::CheckPackageLimits` output.

ACKs for top commit:
  glozow:
    utACK 8dec9c560b
  Sjors:
    utACK 8dec9c560b
  TheCharlatan:
    Re-ACK 8dec9c560b

Tree-SHA512: ddeac18aeba6f8e3be0e3fe76bf3db655352e3b415169f1f83ea1e8976a2f3e3de021c8da6880eb8382ab52d545e418e3f4d57adcc68ecb4f390339710ee6f30
2023-12-18 15:35:11 +00:00
fanquake
eef19c4ce2
Merge bitcoin/bitcoin#29064: fuzz: Improve fuzzing stability for minisketch harness
b2fc7a2eda [fuzz] Improve fuzzing stability for minisketch harness (dergoegge)

Pull request description:

  The `minisketch` harness has low stability due to:
  * Rng internal to minisketch
  * Benchmarkning for the best minisketch impl

  Fix this by seeding the rng and letting the fuzzer choose the impl.

  Also see #29018.

ACKs for top commit:
  maflcko:
    review ACK b2fc7a2eda

Tree-SHA512: 3d81414299c6803c34e928a53bcf843722fa8c38e1d3676cde7fa80923f9058b1ad4b9a2941f718303a6641b17eeb28b4a22eda09678102e9fb7c4e31d06f8f2
2023-12-18 13:54:00 +00:00
fanquake
4b94578fd8
Merge bitcoin/bitcoin#29079: fuzz: Limit p2p fuzz targets to MAX_PROTOCOL_MESSAGE_LENGTH
fa769d3e41 fuzz: Limit p2p fuzz targets to MAX_PROTOCOL_MESSAGE_LENGTH (MarcoFalke)

Pull request description:

  Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65039

ACKs for top commit:
  dergoegge:
    utACK fa769d3e41
  brunoerg:
    crACK fa769d3e41

Tree-SHA512: 46f70d1acf4e2f95055c70162909010c6322f8504a810906e1ab4db470dc2525f9a494b8427b254279bc68b1c8b87338c943787fd5249df7113556740701a51a
2023-12-18 12:52:59 +00:00
ismaelsadeeq
8dec9c560b wallet, mempool: propagete checkChainLimits error message to wallet
Update CheckPackageLimits to use util::Result to pass the error message
instead of out parameter.

Also update test to reflect the error message from `CTxMempool`
`CheckPackageLimits` output.
2023-12-17 21:13:44 +01:00
Ava Chow
3695ecbf68
Merge bitcoin/bitcoin#29088: tests: Don't depend on value of DEFAULT_PERMIT_BAREMULTISIG
7b45744df3 tests: ensure functional tests set permitbaremultisig=1 when needed (Anthony Towns)
7dfabdcf86 tests: test both settings for permitbaremultisig in p2sh tests (Anthony Towns)

Pull request description:

  Update unit and functional tests so that they continue to work if the default for `-permitbaremultisig` is changed.

ACKs for top commit:
  maflcko:
    lgtm ACK 7b45744df3
  instagibbs:
    crACK 7b45744df3
  ajtowns:
    > crACK [7b45744](7b45744df3)
  achow101:
    ACK 7b45744df3
  glozow:
    ACK 7b45744df3, changed default locally and all tests passed

Tree-SHA512: f89f9e2bb11f07662cfd57390196df9e531064e1bd662e1db7dcfc97694394ae5e8014e9d209b9405aa09195bf46fc331b7fba10378065cdb270cbd0669ae904
2023-12-15 16:22:54 -05:00
MarcoFalke
fae526345d
Allow std::byte C-style array serialization 2023-12-15 15:21:22 +01:00
MarcoFalke
fa898e6836
refactor: Print verbose serialize compiler error messages 2023-12-15 15:20:54 +01:00
brunoerg
cd810075ed fuzz: coinselection, improve min_viable_change/change_output_size
Change it to use same approach from
`CreateTransactionInternal`.
2023-12-15 06:28:42 -03:00
Anthony Towns
7dfabdcf86 tests: test both settings for permitbaremultisig in p2sh tests 2023-12-15 18:37:24 +10:00
Anthony Towns
fbd7642c8e logging: add -loglevelalways=1 option
This option tells the logging system to always include a "[cat:level]"
prefix, so [net] becomes [net:debug], LogInfo/LogPrint statements will have
an [all:info] prefix, and LogWarning and LogError logs will become
[all:warning] and [all:error]. This may be easier for automated parsing
of logs, particularly if additional prefixes such as thread or source
location are enabled.
2023-12-15 11:03:25 +10:00
Anthony Towns
782bb6a056 logging: treat BCLog::ALL like BCLog::NONE 2023-12-15 11:03:25 +10:00
Anthony Towns
667ce3e329 logging: Drop BCLog::Level::None
Now that Info-level logging is always logged, there is no further
need for the "None" level, so remove it.
2023-12-15 11:03:25 +10:00
Anthony Towns
ab34dc6012 logging: Log Info messages unconditionally
Previously Info-level logging when a category was specified (via
LogPrintLevel) would only print the corresponding log message if
`-debug=category` were specified, while Info-level logging without a
category would always be printed. Make this more consistent by having
Info messages always be logged, whether they include a category or not.
2023-12-15 11:03:25 +10:00
Anthony Towns
dfe98b6874 logging: make [cat:debug] and [info] implicit 2023-12-15 11:03:25 +10:00
Anthony Towns
c5c76dc615 logging: refactor: pull prefix code out 2023-12-15 11:03:22 +10:00
Ava Chow
1b2dedbf5c
Merge bitcoin/bitcoin#29040: refactor: Remove pre-C++20 code, fs::path cleanup
6666713041 refactor: Rename fs::path::u8string() to fs::path::utf8string() (MarcoFalke)
856c88776f ArgsManager: return path by value from GetBlocksDirPath() (Vasil Dimov)
fa3d9304e8 refactor: Remove pre-C++20 fs code (MarcoFalke)
fa00098e1a Add tests for C++20 std::u8string (MarcoFalke)
fa2bac08c2 refactor: Avoid copy/move in fs.h (MarcoFalke)
faea30227b refactor: Use C++20 std::chrono::days (MarcoFalke)

Pull request description:

  This:

  * Removes dead code.
  * Avoids unused copies in some places.
  * Adds copies in other places for safety.

ACKs for top commit:
  achow101:
    ACK 6666713041
  ryanofsky:
    Code review ACK 6666713041. Just documentation change since last review.
  stickies-v:
    re-ACK 6666713041

Tree-SHA512: 6176e44f30b310d51632ec2d3827c3819905d0ddc6a4b57acfcb6cfa1f9735176da75ee8ed4a4abd1296cb0b83bee9374cc6f91ffac87c19b63c435eeadf3f46
2023-12-14 16:46:54 -05:00
Ava Chow
08e6aaabef
Merge bitcoin/bitcoin#28920: wallet: birth time update during tx scanning
1ce45baed7 rpc: getwalletinfo, return wallet 'birthtime' (furszy)
83c66444d0 test: coverage for wallet birth time interaction with -reindex (furszy)
6f497377aa wallet: fix legacy spkm default birth time (furszy)
75fbf444c1 wallet: birth time update during tx scanning (furszy)
b4306e3c8d refactor: rename FirstKeyTimeChanged to MaybeUpdateBirthTime (furszy)

Pull request description:

  Fixing #28897.

  As the user may have imported a descriptor with a timestamp newer
  than the actual birth time of the first key (by setting 'timestamp=now'),
  the wallet needs to update the birth time when it detects a transaction
  older than the oldest descriptor timestamp.

  Testing Notes:
  Can cherry-pick the test commit on top of master. It will fail there.

ACKs for top commit:
  Sjors:
    re-utACK 1ce45baed7
  achow101:
    ACK 1ce45baed7

Tree-SHA512: 10c2382f87356ae9ea3fcb637d7edc5ed0e51e13cc2729c314c9ffb57c684b9ac3c4b757b85810c0a674020b7287c43d3be8273bcf75e2aff0cc1c037f1159f9
2023-12-14 16:27:40 -05:00
Ava Chow
4ad5c71adb
Merge bitcoin/bitcoin#28051: Get rid of shutdown.cpp/shutdown.h, use SignalInterrupt directly
6db04be102 Get rid of shutdown.cpp/shutdown.h, use SignalInterrupt directly (Ryan Ofsky)
213542b625 refactor: Add InitContext function to initialize NodeContext with global pointers (Ryan Ofsky)
feeb7b816a refactor: Remove calls to StartShutdown from KernelNotifications (Ryan Ofsky)
6824eecaf1 refactor: Remove call to StartShutdown from stop RPC (Ryan Ofsky)
1d92d89edb util: Get rid of uncaught exceptions thrown by SignalInterrupt class (Ryan Ofsky)
ba93966368 refactor: Remove call to ShutdownRequested from IndexWaitSynced (Ryan Ofsky)
42e5829d97 refactor: Remove call to ShutdownRequested from HTTPRequest (Ryan Ofsky)
73133c36aa refactor: Add NodeContext::shutdown member (Ryan Ofsky)
f4a8bd6e2f refactor: Remove call to StartShutdown from qt (Ryan Ofsky)
f0c73c1336 refactor: Remove call to ShutdownRequested from rpc/mining (Ryan Ofsky)
263b23f008 refactor: Remove call to ShutdownRequested from chainstate init (Ryan Ofsky)

Pull request description:

  This change drops `shutdown.h` and `shutdown.cpp` files, replacing them with a `NodeContext::shutdown` member which is used to trigger shutdowns directly. This gets rid of an unnecessary layer of indirection, and allows getting rid of the `kernel::g_context` global.

  Additionally, this PR tries to improve error handling of `SignalInterrupt` code by marking relevant methods `[[nodiscard]]` to avoid the possibility of uncaught exceptions mentioned https://github.com/bitcoin/bitcoin/pull/27861#discussion_r1255496707.

  Behavior is changing In a few cases which are noted in individual commit messages. Particularly: GUI code more consistently interrupts RPCs when it is shutting down, shutdown state no longer persists between unit tests, the stop RPC now returns an RPC error if requesting shutdown fails instead of aborting, and other failed shutdown calls now log errors instead of aborting.

  This PR is a net reduction in lines of code, but in some cases the explicit error handling and lack of global shutdown functions do make it more verbose. The verbosity can be seen as good thing if it discourages more code from directly triggering shutdowns, and instead encourages code to return errors or send notifications that could be translated into shutdowns. Probably a number of existing shutdown calls could just be replaced by better error handling.

ACKs for top commit:
  achow101:
    ACK 6db04be102
  TheCharlatan:
    Re-ACK 6db04be102
  maflcko:
    ACK 6db04be102 👗
  stickies-v:
    re-ACK 6db04be102

Tree-SHA512: 7a34cb69085f37e813c43bdaded1a0cbf6c53bd95fdde96f0cb45346127fc934604c43bccd3328231ca2f1faf712a7418d047ceabd22ef2dca3c32ebb659e634
2023-12-14 15:14:00 -05:00
dergoegge
b2fc7a2eda [fuzz] Improve fuzzing stability for minisketch harness
* Seed minisketch rng
* Use fuzzer chosen minisketch impl instead of benchmarking for the best
  impl
2023-12-14 20:10:21 +00:00
Ava Chow
4d7b787ad6
Merge bitcoin/bitcoin#29022: Make bitcoin-tx replaceable value optional
98afe78661 doc: Update bitcoin-tx replaceable documentation (Kashif Smith)
94feaf2b66 tests: Add unit tests for bitcoin-tx replaceable command (Kashif Smith)
c2b836b119 bitcoin-tx: Make replaceable value optional (Kashif Smith)

Pull request description:

  This fixes #28638. The issue was originally raised by dooglus, who also suggested the patch found in this code. Additionally, test coverage has been added and documentation has been updated.

ACKs for top commit:
  achow101:
    ACK 98afe78661
  pinheadmz:
    ACK 98afe78661
  hernanmarino:
    Tested ACK 98afe78661
  instagibbs:
    untested ACK 98afe78661

Tree-SHA512: ea1384aba7b0014c8cbeb7280d66b1e617d406fb02471dff33873057132b80518c94c7caa4b0426c26d17ce8aa393107de319dde781ace8df72f0314c8c75159
2023-12-14 13:54:00 -05:00
MarcoFalke
6666713041
refactor: Rename fs::path::u8string() to fs::path::utf8string() 2023-12-14 16:22:40 +01:00
MarcoFalke
fa769d3e41
fuzz: Limit p2p fuzz targets to MAX_PROTOCOL_MESSAGE_LENGTH 2023-12-14 12:39:02 +01:00
brunoerg
e03d6f7ed5 fuzz: set m_fallback_fee/m_fee_mode in wallet_fees target 2023-12-13 18:20:10 -03:00
Ava Chow
9f0f83d650
Merge bitcoin/bitcoin#29065: bench: wallet, fix change position out of range error
37c75c5820 test: wallet, fix change position out of range error (furszy)

Pull request description:

  Fixes #29061. Only the benchmark is affected.

  Since #25273, the behavior of 'inserting change at a random position'
  is instructed by passing ´std::nullopt´ instead of -1.

  Also, added missing documentation about the meaning of
  'change_pos=std::nullopt' inside 'CWallet::CreateTransaction()'

ACKs for top commit:
  achow101:
    ACK 37c75c5820
  kevkevinpal:
    ACK [37c75c5](37c75c5820)
  BrandonOdiwuor:
    ACK 37c75c5820

Tree-SHA512: d9a8d8533540455716a5090fcf407573cad9f0d0018a05f903f89e51620302f9b256318db6f7338b85c047f7fab372d724e916b1721d7ed302dbf3d845b08734
2023-12-13 12:45:30 -05:00
fanquake
f48a789385
Merge bitcoin/bitcoin#28075: util: Remove DirIsWritable, GetUniquePath
fa3da629a1 Remove DirIsWritable, GetUniquePath (MarcoFalke)
fad3a9793b Return LockResult::ErrorWrite in LockDirectory (MarcoFalke)
fa0afe7408 refactor: Return enum in LockDirectory (MarcoFalke)

Pull request description:

  `GetUniquePath` is only used in tests and in `DirIsWritable`. The check by `DirIsWritable` is redundant with the check done in `LockDirectory`.

  Fix the redundancy by removing everything, except `LockDirectory`.

ACKs for top commit:
  TheCharlatan:
    Re-ACK fa3da629a1
  hebasto:
    ACK fa3da629a1, I have reviewed the code and it looks OK.

Tree-SHA512: e95f18cd586de7582e9c08ac7ddb860bfcfcbc8963804f45c5784c5e4c0598dc59ae7e45dd4daf30a5020dbf8433f5db2ad06e46a8676371982003790043c6c9
2023-12-13 10:06:16 +00:00
furszy
37c75c5820
test: wallet, fix change position out of range error
Since #25273, the behavior of 'inserting change at a random
position' is instructed by passing std::nullopt instead of -1.

Also, added missing documentation about the meaning of
'change_pos=std::nullopt' inside 'CWallet::CreateTransaction()'
2023-12-12 15:20:38 -03:00
Andrew Chow
d646ca35d9
Merge bitcoin/bitcoin#28994: wallet: skip BnB when SFFO is enabled
576bee88fd fuzz: disable BnB when SFFO is enabled (furszy)
05e5ff194c test: add coverage for BnB-SFFO restriction (furszy)
0c5755761c wallet: create tx, log resulting coin selection info (furszy)
5cea25ba79 wallet: skip BnB when SFFO is active (Murch)

Pull request description:

  Solves #28918. Coming from https://github.com/bitcoin/bitcoin/issues/28918#issuecomment-1838626406 discussion.

  The intention is to decouple only the bugfix relevant commits from #28985, allowing them to be included in the 26.x release. This way, we can avoid disabling the coin selection fuzzing test for an entire release.

  Note:
  Have introduced few changes to the bug fix commit so that the unit tests pass without the additional burden introduced in #28985.

ACKs for top commit:
  josibake:
    ACK 576bee88fd
  murchandamus:
    ACK 576bee88fd
  achow101:
    ACK 576bee88fd

Tree-SHA512: f5d90eb3f3f524265afe4719495c9bf30f98b9af26cf039f7df5a7db977abae72caa7a3478cdd0ab10cd143bc1662e8fc5286b5bc10fc10f0dd582a45b45c31a
2023-12-12 10:52:12 -05:00
fanquake
60f677375e
Merge bitcoin/bitcoin#29055: tests, bench: Fix issue with CWallet::LoadWallet() being called in the wrong places
bd7f5d33e3 wallet: Assert that the wallet is not initialized in LoadWallet (Andrew Chow)
fb0b6ca4e5 tests, bench: Remove incorrect LoadWallet() calls (Andrew Chow)

Pull request description:

  `CWallet::LoadWallet()` expects to be called after a `CWallet` is constructed, but before any of its member functions called. Doing so invalidates pointers which causes issues with some PRs and branches that I am working on. This was being used incorrectly in a few tests and benchmarks, resulting in segfaults.

  As a precaution for this kind of issue in the future, I've also added a few asserts to `LoadWallet()` so that developers will notice when it is used incorrectly.

  As similar issue was fixed in #27666

ACKs for top commit:
  S3RK:
    ACK bd7f5d33e3
  furszy:
    ACK bd7f5d33

Tree-SHA512: 7664f12b8452994e7fc4d7d4f77697fb5f75edb0dba95ba99a4a23ec03d5b8e0ecbdcb7635547a0e8b4f89f708f98dcb5d039df0559e24b1ae411ed630e16e14
2023-12-12 11:47:34 +00:00
fanquake
622e79e0fb
Merge bitcoin/bitcoin#29021: refactor: rpc: Pass CBlockIndex by reference instead of pointer
fa5989d514 refactor: rpc: Pass CBlockIndex by reference instead of pointer (MarcoFalke)
fa604eb6cf refactor: Use reference instead of pointer in IsBlockPruned (MarcoFalke)

Pull request description:

  Follow-up to https://github.com/bitcoin/bitcoin/pull/29003#issuecomment-1841435462

ACKs for top commit:
  TheCharlatan:
    ACK fa5989d514
  pablomartin4btc:
    tACK fa5989d514
  dergoegge:
    Code review ACK fa5989d514

Tree-SHA512: 7449de3e3bb435dcbf438df88df343bb70f6edc3228ee7c0078f912ffb415e951ba30f8ecad916765f8cf896f0d784fe30535c5cf997e303cf5af257ade69773
2023-12-12 10:47:04 +00:00
furszy
576bee88fd
fuzz: disable BnB when SFFO is enabled 2023-12-11 23:40:21 -03:00
furszy
05e5ff194c
test: add coverage for BnB-SFFO restriction
Verify the transaction creation process does not produce
a BnB solution when SFFO is enabled.
This is currently problematic because it could require a
change output. And BnB is specialized on changeless solutions.

Co-authored-by: Andrew Chow <achow101@gmail.com>
Co-authored-by: Murch <murch@murch.one>
2023-12-11 23:40:21 -03:00
Andrew Chow
bd7f5d33e3 wallet: Assert that the wallet is not initialized in LoadWallet
LoadWallet() cannot be run after the wallet has been initialized. So
assert that to avoid making this mistake in the future.
2023-12-11 17:03:25 -05:00
Andrew Chow
fb0b6ca4e5 tests, bench: Remove incorrect LoadWallet() calls
LoadWallet() must only be called immediately after a CWallet is
constructed, or not at all. Doing so after any other CWallet member
functions have been called may cause pointers and other objects
setup by other those functions to become invalidated.

Since these tests and benchmarks are using completely new wallets with
mock databases, it's not necessary to call LoadWallet() anyways, so
these can be dropped.
2023-12-11 17:03:25 -05:00
Kashif Smith
1757452cc5 test: Add tests for CFeeRate multiplication operator 2023-12-11 16:27:58 -05:00
Kashif Smith
98afe78661 doc: Update bitcoin-tx replaceable documentation 2023-12-11 13:08:46 -05:00
MarcoFalke
fa46cc22bc
Remove deprecated -rpcserialversion 2023-12-11 18:22:13 +01:00
Vasil Dimov
856c88776f ArgsManager: return path by value from GetBlocksDirPath()
`ArgsManager::m_cached_blocks_path` is protected by
`ArgsManager::cs_args` and returning a reference to it after releasing
the mutex is unsafe.

To resolve this, return a copy of the path. This has some performance
penalty which is presumably ok, given that paths are a few 100s bytes
at most and `GetBlocksDirPath()` is not called often.

This silences the following (clang 18):

```
common/args.cpp:288:31: error: returning variable 'm_cached_blocks_path' by reference requires holding mutex 'cs_args' [-Werror,-Wthread-safety-reference-return]
  288 |     if (!path.empty()) return path;
      |                               ^
```

Do the same with
`ArgsManager::GetDataDir()`,
`ArgsManager::GetDataDirBase()` and
`ArgsManager::GetDataDirNet()`.
2023-12-11 17:42:17 +01:00
MarcoFalke
fa3d9304e8
refactor: Remove pre-C++20 fs code
Treating std::string as UTF-8 is deprecated in std::filesystem::path
since C++20.

However, it makes this codebase easier to read and maintain to retain
the ability for std::string to hold UTF-8.
2023-12-11 17:42:17 +01:00
MarcoFalke
fa00098e1a
Add tests for C++20 std::u8string
Also, add missing includes:

 #include <system_error>  // for error_code
 #include <type_traits>   // for is_same

 #include <cerrno>        // for errno
2023-12-11 17:42:05 +01:00
MarcoFalke
fa2bac08c2
refactor: Avoid copy/move in fs.h
The operator accepts a const& reference, so no copy or move is needed.
See https://en.cppreference.com/w/cpp/filesystem/path/append
2023-12-11 17:41:54 +01:00
MarcoFalke
faea30227b
refactor: Use C++20 std::chrono::days 2023-12-11 17:41:39 +01:00
fanquake
d5e5810bd3
Merge bitcoin/bitcoin#28999: build: Enable -Wunreachable-code
fa8adbe7c1 build: Enable -Wunreachable-code (MarcoFalke)

Pull request description:

  It seems a bit confusing to write code after a `return`. This can even lead to bugs, or incorrect code, such as https://github.com/bitcoin/bitcoin/pull/28830/files#r1415372320 . (Edit: The linked instance is not found by clang's `-Wunreachable-code`).

  Fix all issues by enabling `-Wunreachable-code`.

  This flag also enables `-Wunreachable-code-loop-increment`, according to https://clang.llvm.org/docs/DiagnosticsReference.html#wunreachable-code, so remove that.

ACKs for top commit:
  ajtowns:
    > ACK [fa8adbe](fa8adbe7c1)
  stickies-v:
    ACK fa8adbe7c1
  jonatack:
    ACK fa8adbe7c1 tested with arm64 clang 17.0.6

Tree-SHA512: 12a2f74b69ae002e62ae08038f7458837090a12051a4c154d05ae4bb26fb19fc1fa76c63aedf2b3fbb36f048c593ca3b8c0efe03fe93cf07a0fd114fc84ce1e7
2023-12-11 15:44:16 +00:00
fanquake
dabd704642
Merge bitcoin/bitcoin#25273: wallet: Pass through transaction locktime and preset input sequences and scripts to CreateTransaction
0295b44c25 wallet: return CreatedTransactionResult from FundTransaction (Andrew Chow)
758501b713 wallet: use optional for change position as an optional in CreateTransaction (Andrew Chow)
2d39db7aa1 wallet: Explicitly preserve scriptSig and scriptWitness in CreateTransaction (Andrew Chow)
14e50746f6 wallet: Explicitly preserve transaction version in CreateTransaction (Andrew Chow)
0fefcbb776 wallet: Explicitly preserve transaction locktime in CreateTransaction (Andrew Chow)
4d335bb1e0 wallet: Set preset input sequence through coin control (Andrew Chow)
596642c5a9 wallet: Replace SelectExternal with SetTxOut (Andrew Chow)
5321786b9d coincontrol: Replace HasInputWeight with returning optional from Get (Andrew Chow)
e1abfb5b20 wallet: Introduce and use PreselectedInput class in CCoinControl (Andrew Chow)

Pull request description:

  Currently `FundTransaction` handles transaction locktime and preset input data by extracting the selected inputs and change output from `CreateTransaction`'s results. This means that `CreateTransaction` is actually unaware of any user desired locktime or sequence numbers. This can have an effect on whether and how anti-fee-sniping works.

  This PR makes `CreateTransaction` aware of the locktime and preset input data by providing them to `CCoinControl`. `CreateTransasction` will then set the sequences, scriptSigs, scriptWItnesses, and locktime as appropriate if they are specified. This allows `FundTransaction` to actually use `CreateTransaction`'s result directly instead of having to extract the parts of it that it wants.

  Additionally `FundTransaction` will return a `CreateTransactionResult` as `CreateTransaction` does instead of having several output parameters. Lastly, instead of using `-1` as a magic number for the change output position, the change position is changed to be an optional with no value set indicating no desired change output position (when provided as an input parameter) or no change output present (in the result).

ACKs for top commit:
  josibake:
    ACK 0295b44c25
  S3RK:
    Code review ACK 0295b44c25

Tree-SHA512: 016be4d41cbf97e1938506e70959bb5335b87006162a1c1c62fa0adb637cbe7aefb76d342b8efad5f37dc693f270c8d0a0839e239fd1ac32c6941a8172f1a710
2023-12-11 15:29:25 +00:00
fanquake
255004fc5e
Merge bitcoin/bitcoin#29009: fuzz: p2p: Detect peer deadlocks
9f265d8825 fuzz: Detect deadlocks in process_message (dergoegge)
fae1e7e012 fuzz: p2p: Detect peer deadlocks (MarcoFalke)

Pull request description:

  It may be possible that a peer connection will deadlock, due to software bugs such as https://github.com/bitcoin/bitcoin/pull/18808.

  Fix this by detecting them in the fuzz target.

  Can be tested by introducing a bug such as:

  ```diff
  diff --git a/src/net_processing.cpp b/src/net_processing.cpp
  index 1067341495..97495a13df 100644
  --- a/src/net_processing.cpp
  +++ b/src/net_processing.cpp
  @@ -2436,3 +2436,3 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic
       if (it != peer.m_getdata_requests.end() && !pfrom.fPauseSend) {
  -        const CInv &inv = *it++;
  +        const CInv& inv = *it;
           if (inv.IsGenBlkMsg()) {
  ```

  Using a fuzz input such as:

  ```
  $ base64 ./timeout-ada0fecaba2b8c46c6e970cf637d9625b01bf7e5
  kNptdNbW1tbWYghvXIpwb25vPQAA////////cwAjLv8AXAB2ZXJhY2sAQW5v/62tra3Pz///////
  //////////////////////9c8GZpbHRlcmxvYWQAAAEAAwAAAABVYwC2XABmaWx0ZXJhZGQAAAAX
  Fxdn/////2V0F861tcqvEmAAACEAAABjYXB0dXJldmUAAH4AgAA1PNfX11x0Z2V0ZGF0YQBDACOw
  AQMAAAAGIm5GERoLWcqvEmBD61u/KMNPOl4zKh/HKLK3PPGIkQ9eE/////////8AAAAAAAAAAFtb
  WyjDTzpeMSofx7K3PNfX11x0Z2V0ZGF0YQBDACMwAQMAAAAGIm5GERoLWcqvEmBD61u/KMNPOl4z
  Kh/Hsrc88YiRD2/Nzc3Nzc3Nzc3NTc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N
  zWWj1NTUudTU1NTU1P///0j+P/9cdHR4AAAAAAAAy/4AAHR4AAAAAAAAP8v+AAD/+P//////////
  AX55bJl8HWnz/////wAgXGF0YVPxY2RkAAAA
  ```

  And running the fuzz target:

  ```
  $ FUZZ=process_messages ./src/test/fuzz/fuzz -runs=1 -timeout=18 ./timeout-ada0fecaba2b8c46c6e970cf637d9625b01bf7e5
  INFO: Running with entropic power schedule (0xFF, 100).
  INFO: Seed: 3436516708
  INFO: Loaded 1 modules   (390807 inline 8-bit counters): 390807 [0x55d0d6221e80, 0x55d0d6281517),
  INFO: Loaded 1 PC tables (390807 PCs): 390807 [0x55d0d6281518,0x55d0d6877e88),
  ./src/test/fuzz/fuzz: Running 1 inputs 1 time(s) each.
  Running: ./timeout-ada0fecaba2b8c46c6e970cf637d9625b01bf7e5
  ALARM: working on the last Unit for 19 seconds
         and the timeout value is 18 (use -timeout=N to change)
  ==375014== ERROR: libFuzzer: timeout after 19 seconds
  ```

ACKs for top commit:
  naumenkogs:
    ACK 9f265d8825
  dergoegge:
    ACK 9f265d8825
  brunoerg:
    ACK 9f265d8825

Tree-SHA512: da83ff90962bb679aae00e8e9dba639c180b7aaba544e0c4d0978d36e28a9ff1cd7a2e13009d8ab407ef57767656aca1ebc767a7d2f1bc880284f8f57c197a50
2023-12-11 15:05:40 +00:00
fanquake
40bc501bf4
Merge bitcoin/bitcoin#29031: fuzz: Improve fuzzing stability for txorphan harness
15f5a0d0c8 fuzz: Improve fuzzing stability for txorphan harness (dergoegge)

Pull request description:

  The `txorphan` harness has low stability as eviction of orphan txs is entirely random at the moment.

  Fix this by passing the rng to `LimitOrphans`, which can be deterministic in tests.

  Also see #29018.

ACKs for top commit:
  maflcko:
    lgtm ACK 15f5a0d0c8
  brunoerg:
    utACK 15f5a0d0c8

Tree-SHA512: 854ec34b3a0f16f26db6dc419096c6e7a380e8400119534aa278d6b1d54c253b572aa2fad13c383c796c431d8ff4263956e6f60326e99f8bf6abd16d9a280e97
2023-12-11 12:34:41 +00:00
Murch
1553c80786
Add multiplication operator to CFeeRate 2023-12-09 09:33:45 -05:00
Andrew Chow
0295b44c25 wallet: return CreatedTransactionResult from FundTransaction
Instead of using the output parameters, return CreatedTransactionResult
from FundTransaction in the same way that CreateTransaction does.
Additionally, instead of modifying the original CMutableTransaction, the
result from CreateTransactionInternal is used.
2023-12-08 17:12:19 -05:00
Andrew Chow
758501b713 wallet: use optional for change position as an optional in CreateTransaction
Instead of making -1 a magic number meaning no change or random change
position, use an optional to have that meaning.
2023-12-08 17:12:19 -05:00
Andrew Chow
2d39db7aa1 wallet: Explicitly preserve scriptSig and scriptWitness in CreateTransaction
When creating a transaction with preset inputs, also preserve the
scriptSig and scriptWitness for those preset inputs if they are provided
(e.g. in fundrawtransaction).
2023-12-08 17:12:19 -05:00
Andrew Chow
14e50746f6 wallet: Explicitly preserve transaction version in CreateTransaction
We provide the preset nVersion to CCoinControl so that
CreateTransactionInternal can be aware of it and set it in the produced
transaction.
2023-12-08 14:55:14 -05:00
Andrew Chow
0fefcbb776 wallet: Explicitly preserve transaction locktime in CreateTransaction
We provide the preset nLockTime to CCoinControl so that
CreateTransactionInternal can be aware of it and set it in the produced
transaction.
2023-12-08 14:55:14 -05:00
Andrew Chow
4d335bb1e0 wallet: Set preset input sequence through coin control 2023-12-08 14:55:14 -05:00
Andrew Chow
596642c5a9 wallet: Replace SelectExternal with SetTxOut
Instead of having a separate CCoinControl::SelectExternal function, we
can use the normal CCoinControl::Select function and explicitly use
PreselectedInput::SetTxOut in the caller. The semantics of what an
external input is remains.
2023-12-08 14:55:14 -05:00
Andrew Chow
5321786b9d coincontrol: Replace HasInputWeight with returning optional from Get 2023-12-08 14:55:14 -05:00
Andrew Chow
e1abfb5b20 wallet: Introduce and use PreselectedInput class in CCoinControl
Instead of having different maps for selected inputs, external inputs,
and input weight in CCoinControl, have a class PreselectedInput which
tracks stores that information for each input.
2023-12-08 14:54:48 -05:00
dergoegge
15f5a0d0c8 fuzz: Improve fuzzing stability for txorphan harness 2023-12-08 13:14:46 +00:00
fanquake
3e691258d8
Merge bitcoin/bitcoin#28349: build: Require C++20 compiler
fa6e50d6c7 fuzz: Use C++20 starts_with in rpc.cpp (MarcoFalke)
faa48388bc Revert "tracepoints: Disables `-Wgnu-zero-variadic-macro-arguments` to compile without warnings" (MarcoFalke)
fae3b77a87 refactor: Drop unused _Pragma to ignore -Wgnu-zero-variadic-macro-arguments (MarcoFalke)
fa02fc0a86 refactor: modernize-use-default-member-init for bit-fields (C++20) (MarcoFalke)
fa67f096bd build: Require C++20 compiler (MarcoFalke)

Pull request description:

  C++20 allows to write safer code, because it allows to enforce more stuff at compile time (`constinit`, `conteval`, `constexpr`, `std::span`, ...).

  Also, it allows to write less verbose and easier to understand code (C++ 20 Concepts).

  See https://github.com/bitcoin/bitcoin/issues/23363 and https://en.cppreference.com/w/cpp/compiler_support#cpp20

  With g++-10 (https://github.com/bitcoin/bitcoin/pull/28348) and clang-13 (https://github.com/bitcoin/bitcoin/pull/28210), there is broad support for almost all features of C++20.

  It should be fine to require a C++20 compiler for Bitcoin Core 27.0 in 2024 (next year), not the soon upcoming 26.0 next month.

  This pull request includes three small cleanups to make use of C++20 features. If any issues are detected before or after merge, this should be easy to revert. If no issues arise, it should be fine to make use of more involved C++20 features later on.

ACKs for top commit:
  fanquake:
    ACK fa6e50d6c7

Tree-SHA512: 244d79bfb0b750a4bdd713f40573b9ca33816fb84b6c84a58f027b9d7d4bb0cc4f18642959e4cf3d094808a69e5b8a327ca8521d7c0c08af27dacb5da3e78e71
2023-12-08 12:10:16 +00:00
fanquake
a7f4f1a09c
Merge bitcoin/bitcoin#28894: wallet: batch all individual spkms setup db writes in a single db txn
f053024273 wallet: batch external signer descriptor import (Sjors Provoost)
1f65241b73 wallet: descriptors setup, batch db operations (furszy)
3eb769f150 wallet: batch legacy spkm TopUp (furszy)
075aa44ceb wallet: batch descriptor spkm TopUp (furszy)
bb4554c81e bench: add benchmark for wallet creation procedure (furszy)

Pull request description:

  Work decoupled from #28574.

  Instead of performing multiple single write operations per spkm
  setup call, this PR batches them all within a single atomic db txn.

  Speeding up the process and preventing the wallet from entering
  an inconsistent state if any of the intermediate transactions fail
  (which shouldn't happen but.. if it does, it is better to not store
  any spkm rather than storing them partially).

  To compare the changes, added benchmark in the first commit.

ACKs for top commit:
  Sjors:
    re-utACK f053024273
  achow101:
    ACK f053024273
  BrandonOdiwuor:
    ACK f053024273
  theStack:
    Code-review ACK f053024273

Tree-SHA512: aead8548473e17d4d53e8e7039bbaf5e8bf2fe83f33b33f81cdedefe8a31b7003ceb6d5379b1bad1ca2692e909492009a21284ec8338eede078df3d19046ab5a
2023-12-08 11:25:01 +00:00
brunoerg
e1281f1bbd wallet: fix key parsing check for miniscript expressions in ParseScript 2023-12-08 06:54:00 -03:00
furszy
0c5755761c
wallet: create tx, log resulting coin selection info
Useful for understanding what is going on internally
when the software is running. Debug issues, and provide
more accurate feedback to users.
2023-12-07 21:47:20 -03:00
Murch
5cea25ba79
wallet: skip BnB when SFFO is active
Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
2023-12-07 21:47:20 -03:00
fanquake
fcdb39d3ee
Merge bitcoin/bitcoin#28924: refactor: Remove unused and fragile string interface from arith_uint256
fa63f16018 test: Add uint256 string parse tests (MarcoFalke)
facf629ce8 refactor: Remove unused and fragile string interface from arith_uint256 (MarcoFalke)

Pull request description:

  The string interface (`base_uint(const std::string&)`, as well as `base_uint::SetHex`) is problematic for many reasons:

  * It is unused (except in test-only code).
  * It is redundant with the `uint256` string interface: `std::string -> uint256 -> UintToArith256`.
  * It is brittle, because it inherits the brittle `uint256` string interface, which is brittle due to the use of `c_str()` (embedded null will be treated as end-of string), etc ...

  Instead of fixing the interface, remove it since it is unused and redundant with `UintToArith256`.

ACKs for top commit:
  ajtowns:
    ACK fa63f16018
  TheCharlatan:
    ACK fa63f16018

Tree-SHA512: a95d5b938ffd0473361336bbf6be093d01265a626c50be1345ce2c5e582c0f3f73eb11af5fd1884019f59d7ba27e670ecffdb41d2c624ffb9aa63bd52b780e62
2023-12-07 16:02:05 +00:00
pablomartin4btc
b2e531e70a qt: update widgets availability on wallet selection
The Transaction View should be only enabled when a wallet is selected.
Therefore it has been added a condition for a selected wallet on
enableHistoryAction() since its availability also depends on the mask
value checkbox.
2023-12-07 12:49:23 -03:00
MarcoFalke
fa5989d514
refactor: rpc: Pass CBlockIndex by reference instead of pointer
All functions assume that the pointer is never null, so pass by
reference, to avoid accidental segfaults at runtime, or at least make
them more obvious.

Also, remove unused c-style casts in touched lines.

Also, add CHECK_NONFATAL checks, to turn segfault crashes into an
recoverable runtime error with debug information.
2023-12-07 12:05:21 +01:00
MarcoFalke
fa604eb6cf
refactor: Use reference instead of pointer in IsBlockPruned
This makes it harder to pass nullptr and cause issues such as
dde7ac5c70
2023-12-07 12:02:54 +01:00
MarcoFalke
fa6e50d6c7
fuzz: Use C++20 starts_with in rpc.cpp 2023-12-07 11:06:16 +01:00
MarcoFalke
faa48388bc
Revert "tracepoints: Disables -Wgnu-zero-variadic-macro-arguments to compile without warnings"
This reverts commit 5197660e94.
2023-12-07 11:06:13 +01:00
MarcoFalke
fae3b77a87
refactor: Drop unused _Pragma to ignore -Wgnu-zero-variadic-macro-arguments 2023-12-07 11:06:05 +01:00
MarcoFalke
fa02fc0a86
refactor: modernize-use-default-member-init for bit-fields (C++20) 2023-12-07 11:06:01 +01:00
MarcoFalke
fa67f096bd
build: Require C++20 compiler 2023-12-07 11:05:33 +01:00
fanquake
2e8ec6b338
Merge bitcoin/bitcoin#29012: fuzz: Avoid timeout in bitdeque
fad1903b8a fuzz: Avoid timeout in bitdeque (MarcoFalke)

Pull request description:

  Avoid timeouts such as https://github.com/bitcoin/bitcoin/issues/28812#issuecomment-1842914664

  This is done by:

  * Limiting the maximum number of iterations if the maximum size of the container is "large" (see the magic numbers in the code).
  * Check the equality only once. This should be fine, because if a crash were to happen in the equality check, but the crash doesn't happen if further iterations were run, the fuzz engine should eventually find the crash by truncating the fuzz input.

ACKs for top commit:
  sipa:
    utACK fad1903b8a
  dergoegge:
    utACK fad1903b8a
  brunoerg:
    crACK fad1903b8a

Tree-SHA512: d3d83acb3e736b8fcaf5d17ce225ac82a9f9a2efea048512d2fed594ba6c76c25bae72eb0fab3276d4db37baec0752e5367cecfb18161301b921fed09693045e
2023-12-06 17:16:17 +00:00
Andrew Chow
c46cc8d3c1
Merge bitcoin/bitcoin#27581: net: Continuous ASMap health check
3ea54e5db7 net: Add continuous ASMap health check logging (Fabian Jahr)
28d7e55dff test: Add tests for unfiltered GetAddr usage (Fabian Jahr)
b8843d37ae fuzz: Let fuzzers use filter options in GetAddr/GetAddresses (Fabian Jahr)
e16f420547 net: Optionally include terrible addresses in GetAddr results (Fabian Jahr)

Pull request description:

  There are certain statistics we can collect by running all our known clearnet addresses against the ASMap file. This could show issues with a maliciously manipulated file or with an old file that has decayed with time.

  This is just a proof of concept for now. My idea currently is to run the analysis once per day and print the results to logs if an ASMap file is used.

ACKs for top commit:
  achow101:
    ACK 3ea54e5db7
  mzumsande:
    ACK 3ea54e5db7
  brunoerg:
    crACK 3ea54e5db7

Tree-SHA512: 777acbfac43cc43ce4a0a3612434e4ddbc65f59ae8ffc9e24f21de09011bccb297f0599cbaa82bcf40ef68e5af582c4e98556379db7ceff7d9f97574a1cf8e09
2023-12-06 11:22:42 -05:00
dergoegge
9f265d8825 fuzz: Detect deadlocks in process_message 2023-12-06 16:04:21 +00:00
Andrew Chow
25d23e6b18
Merge bitcoin/bitcoin#28980: rpc: encryptwallet help, mention HD seed rotation and backup requirement
ca09415e63 rpc, doc: encryptwallet, mention HD seed rotation and new backup (furszy)

Pull request description:

  Small and simple PR, updating the `encryptwallet` help message.

  Better to notify users about the HD seed rotation and the new
  backup requirement before executing the encryption process.
  Ensuring they are prepared to update previous backups and
  securely safeguard the updated wallet file.

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

Tree-SHA512: f0ee65f5cea66450566e3a85e066d4c06b3293dd0e0b2ed5fafdb7fb11da0a2cd94407299a3c57a0706c2ed782f8eabb73443e85d8099a62a3fb10a02636ab46
2023-12-06 10:44:18 -05:00
Andrew Chow
9693cfa0a4
Merge bitcoin/bitcoin#28989: test: Fix test by checking the actual exception instance
55e3dc3e03 test: Fix test by checking the actual exception instance (Hennadii Stepanov)

Pull request description:

  The `system_tests/run_command` test is broken because it passes even with the diff as follows:
  ```diff
  --- a/src/test/system_tests.cpp
  +++ b/src/test/system_tests.cpp
  @@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(run_command)
           });
       }
       {
  -        BOOST_REQUIRE_THROW(RunCommandParseJSON("echo \"{\""), std::runtime_error); // Unable to parse JSON
  +        BOOST_REQUIRE_THROW(RunCommandParseJSON("invalid_command \"{\""), std::runtime_error); // Unable to parse JSON
       }
       // Test std::in, except for Windows
   #ifndef WIN32
  ```

  The reason of such fragility is that the [`BOOST_REQUIRE_THROW`](https://www.boost.org/doc/libs/1_83_0/libs/test/doc/html/boost_test/utf_reference/testing_tool_ref/assertion_boost_level_throw.html) macro passes even if the command raises an exception in the underlying subprocess implementation, which might have a type derived from `std::runtime_error`.

ACKs for top commit:
  maflcko:
    lgtm ACK 55e3dc3e03
  achow101:
    ACK 55e3dc3e03
  furszy:
    Non-Windows code ACK 55e3dc3e
  pablomartin4btc:
    ACK 55e3dc3e03

Tree-SHA512: 32f49421bdcc94744c81e82dc10cfa02e3f8ed111974edf1c2a47bdaeb56d7baec1bede67301cc89464fba613029ecb131dedc6bc5948777ab52f0f12df8bfe9
2023-12-06 10:33:29 -05:00
MarcoFalke
fad1903b8a
fuzz: Avoid timeout in bitdeque 2023-12-06 15:44:38 +01:00
ismaelsadeeq
562664d263 test: wait for fee estimator to catch up before estimating fees 2023-12-06 15:01:54 +01:00
MarcoFalke
fae1e7e012
fuzz: p2p: Detect peer deadlocks 2023-12-06 13:11:38 +01:00
furszy
1ce45baed7
rpc: getwalletinfo, return wallet 'birthtime'
And add coverage for it
2023-12-05 18:55:35 -03:00
furszy
6f497377aa
wallet: fix legacy spkm default birth time
To avoid scanning blocks, as assumed by a wallet with no
generated keys or imported scripts, the default value for
the birth time needs to be set to the maximum int64_t value.

Once the first key is generated or the first script is imported,
the legacy SPKM will update the birth time automatically.
2023-12-05 18:55:35 -03:00
furszy
ca09415e63
rpc, doc: encryptwallet, mention HD seed rotation and new backup
Better to notify users about the HD seed rotation and the new
backup requirement before executing the encryption process.
Ensuring they are prepared to update previous backups and
securely safeguard the updated wallet file.

Co-authored-by: jonatack <jon@atack.com>
2023-12-05 18:46:58 -03:00
Andrew Chow
406b71abcb wallet: Migrate entire address book entries 2023-12-05 13:35:55 -05:00
Martin Zumsande
494a926d05 rpc: fix getrawtransaction segfault
The crash would happen when querying a mempool transaction with verbosity=2, while pruning.
2023-12-05 13:11:02 -05:00
MarcoFalke
fa8adbe7c1
build: Enable -Wunreachable-code 2023-12-05 15:36:08 +01:00
fanquake
b3ab0c3819
Merge bitcoin/bitcoin#28997: fuzz: txorphan check wtxids using GenTxid::Wtxid not GenTxid::Txid
38816ff64e fuzz: txorphan check wtxids using GenTxid::Wtxid not GenTxid::Txid (Greg Sanders)

Pull request description:

  Fixes the bugs in the fuzz test with no more changes as an alternative to https://github.com/bitcoin/bitcoin/pull/28658

ACKs for top commit:
  naumenkogs:
    ACK 38816ff64e
  dergoegge:
    ACK 38816ff64e

Tree-SHA512: 5e46a83f2b2a2ac0672a63eb6200b019e01089ab1aa80c4ab869b6fcf27ccf2e84a064e96397f1a1869ccfa43b0c9638cbae681a27c4ca3c96ac71f41262601e
2023-12-05 10:56:07 +00:00
Kashif Smith
c2b836b119 bitcoin-tx: Make replaceable value optional 2023-12-04 16:14:00 -05:00
Greg Sanders
38816ff64e fuzz: txorphan check wtxids using GenTxid::Wtxid not GenTxid::Txid 2023-12-04 14:42:13 -05:00
Ryan Ofsky
6db04be102 Get rid of shutdown.cpp/shutdown.h, use SignalInterrupt directly
This change is mostly a refectoring that removes some code and gets rid of an
unnecessary layer of indirection after #27861

But it is not a pure refactoring since StartShutdown, AbortShutdown, and
WaitForShutdown functions used to abort on failure, and the replacement code
logs or returns errors instead.
2023-12-04 15:39:15 -04:00
Ryan Ofsky
213542b625 refactor: Add InitContext function to initialize NodeContext with global pointers
Having InitContext() avoids the need to add duplicate code to src/init/*.cpp
files in the next commit. It also lets these files avoid referencing global
variables like gArgs.

There is no change in behavior in this commit.
2023-12-04 15:39:15 -04:00
Ryan Ofsky
feeb7b816a refactor: Remove calls to StartShutdown from KernelNotifications
Use SignalInterrupt object instead. There is a slight change in behavior here
because the previous StartShutdown code used to abort on failure and the
new code logs errors instead.
2023-12-04 15:39:15 -04:00
Ryan Ofsky
6824eecaf1 refactor: Remove call to StartShutdown from stop RPC
Use SignalInterrupt object instead. There is a slight change in behavior here
because the previous StartShutdown code used to abort on failure and the
new code returns an RPC error instead.
2023-12-04 15:39:15 -04:00
Ryan Ofsky
1d92d89edb util: Get rid of uncaught exceptions thrown by SignalInterrupt class
Replace exceptions thrown by signal and wait methods with [[nodiscard]] return
values.

This is mostly a refactoring, but there is a slight change of behavior if
AbortShutdown function fails. The original behavior which was unintentionally
changed in #27861 is restored, so it now triggers an assert failure again
instead of throwing an exception. (The AbortShutdown function is only ever
called in the the GUI version of Bitcoin Core when corruption is detected on
loading and the user tries to reindex.)

Problems with using exceptions were pointed out by MarcoFalke in
https://github.com/bitcoin/bitcoin/pull/27861#discussion_r1255496707.
2023-12-04 15:39:15 -04:00
Ryan Ofsky
ba93966368 refactor: Remove call to ShutdownRequested from IndexWaitSynced
Use the node interrupt object instead.

There is no change in behavior in this commit.
2023-12-04 15:39:15 -04:00
Ryan Ofsky
42e5829d97 refactor: Remove call to ShutdownRequested from HTTPRequest
Pass HTTP server an interrupt object instead of having it depend on shutdown.h
and global shutdown state.

There is no change in behavior in this commit.
2023-12-04 15:39:15 -04:00
Ryan Ofsky
73133c36aa refactor: Add NodeContext::shutdown member
Add NodeContext::shutdown variable and start using it to replace the
kernel::Context::interrupt variable. The latter can't easily be removed right
away but will be removed later in this PR.

Moving the interrupt object from the kernel context to the node context
increases flexibility of the kernel API so it is possible to use multiple
interrupt objects, or avoid creating one if one is not needed. It will also
allow getting rid of the kernel::g_context global later in this PR, replacing
it with a private SignalInterrupt instance in init.cpp

There is no change in behavior in this commit outside of unit tests. In unit
tests there should be no visible change either, but internally now each test
has its own interrupt variable so the variable will be automatically reset
between tests.
2023-12-04 15:39:15 -04:00
Ryan Ofsky
f4a8bd6e2f refactor: Remove call to StartShutdown from qt
Use interfaces::Node object instead.

There is a minor change in behavior in this commit, because the new code calls
InterruptRPC() and StopRPC() when previous code did not do this.  But this
should be a good thing since it makes sense to interrupt RPC when the system is
shutting down, and it is better for the GUI shut down in a consistent way
regardless of how the shutdown is triggered.
2023-12-04 15:39:15 -04:00
Ryan Ofsky
f0c73c1336 refactor: Remove call to ShutdownRequested from rpc/mining
Use chainman.m_interrupt object instead

There is no change in behavior in this commit
2023-12-04 15:39:15 -04:00
Ryan Ofsky
263b23f008 refactor: Remove call to ShutdownRequested from chainstate init
Use chainman.m_interrupt object instead

There is no change in behavior in this commit
2023-12-04 15:39:15 -04:00
willcl-ark
8f6ab31863
init: don't delete PID file if it was not generated
Previously, starting a second bitcoind using the same datadir would
correctly fail to init and shutdown. However during shutdown the PID
file belonging to the first instance would be erroneously removed by
the second process shutting down.

Fix this to only delete the PID file if we created it.
2023-12-04 12:54:20 +00:00
Hennadii Stepanov
55e3dc3e03
test: Fix test by checking the actual exception instance
The BOOST_REQUIRE_THROW passes even if the command raises an exception
in the underlying subprocess implementation, which might have a type
derived from std::runtime_error.
2023-12-03 16:04:20 +00:00
Fabian Jahr
3ea54e5db7
net: Add continuous ASMap health check logging 2023-12-02 22:03:08 +01:00
Andrew Chow
a97a89244e
Merge bitcoin/bitcoin#28368: Fee Estimator updates from Validation Interface/CScheduler thread
91504cbe0d rpc: `SyncWithValidationInterfaceQueue` on fee estimation RPC's (ismaelsadeeq)
714523918b tx fees, policy: CBlockPolicyEstimator update from `CValidationInterface` notifications (ismaelsadeeq)
dff5ad3b99 CValidationInterface: modify the parameter of `TransactionAddedToMempool` (ismaelsadeeq)
91532bd382 tx fees, policy: update `CBlockPolicyEstimator::processBlock` parameter (ismaelsadeeq)
bfcd401368 CValidationInterface, mempool: add new callback to `CValidationInterface` (ismaelsadeeq)
0889e07987 tx fees, policy: cast with static_cast instead of C-Style cast (ismaelsadeeq)
a0e3eb7549 tx fees, policy: bugfix: move `removeTx` into reason != `BLOCK` condition (ismaelsadeeq)

Pull request description:

  This is an attempt to  #11775

  This Pr will enable fee estimator to listen to ValidationInterface notifications to process new transactions added and removed from the mempool.

  This PR includes the following changes:

  - Added a new callback to the Validation Interface `MempoolTransactionsRemovedForConnectedBlock`, which notifies listeners about the transactions that have been removed due to a new block being connected, along with the height at which the transactions were removed.
  - Modified the `TransactionAddedToMempool` callback parameter to include additional information about the transaction needed for fee estimation.
  - Updated `CBlockPolicyEstimator` to process transactions using` CTransactionRef` instead of `CTxMempoolEntry.`
  - Implemented the `CValidationInterface` interface in `CBlockPolicyEstimater` and overridden the `TransactionAddedToMempool`, `TransactionRemovedFromMempool`, and `MempoolTransactionsRemovedForConnectedBlock` methods to receive updates from their notifications.

  Prior to this PR, the fee estimator updates from the mempool, i.e whenever a new block is connected all transactions in the block that are in our mempool are going to be removed using the `removeForBlock` function in `txmempool.cpp`.

  This removal triggered updates to the fee estimator. As a result, the fee estimator would block mempool's `cs` until it finished updating every time a new block was connected.
  Instead of being blocked only on mempool tx removal, we were blocking on both tx removal and fee estimator updating.
  If we want to further improve fee estimation, or add heavy-calulation steps to it, it is currently not viable as we would be slowing down block relay in the process

  This PR is smaller in terms of the changes made compared to #11775, as it focuses solely on enabling fee estimator updates from the validationInterface/cscheduler thread notifications.

  I have not split the validation interface because, as I understand it, the rationale behind the split in #11775 was to have `MempoolInterface` signals come from the mempool and `CValidationInterface` events come from validation. I believe this separation can be achieved in a separate refactoring PR when the need arises.

  Also left out some commits from #11775
  - Some refactoring which are no longer needed.
  - Handle reorgs much better in fee estimator.
  - Track witness hash malleation in fee estimator

  I believe they are a separate change that can come in a follow-up after this.

ACKs for top commit:
  achow101:
    ACK 91504cbe0d
  TheCharlatan:
    Re-ACK 91504cbe0d
  willcl-ark:
    ACK 91504cbe0d

Tree-SHA512: 846dfb9da57a8a42458827b8975722d153907fe6302ad65748d74f311e1925557ad951c3d95fe71fb90ddcc8a3710c45abb343ab86b88780871cb9c38c72c7b1
2023-12-01 15:07:23 -05:00
Andrew Chow
18bed148af
Merge bitcoin/bitcoin#28784: rpc: keep .cookie file if it was not generated
7cb9367157 rpc: keep .cookie if it was not generated (Roman Zeyde)

Pull request description:

  Otherwise, starting bitcoind twice may cause the `.cookie` file generated by the first instance to be deleted by the second instance shutdown (after failing to obtain a lock).

ACKs for top commit:
  willcl-ark:
    re-ACK 7cb9367157
  achow101:
    ACK 7cb9367157
  kristapsk:
    re-ACK 7cb9367157
  stickies-v:
    ACK 7cb9367157

Tree-SHA512: 0960dbc457975b0e0535f3d814824a879d7f85c9f1191537415b3fc253429a316a8e4badde56c8bc139778f132392983cec5fbe03891fb15ff61d3bc3f6e681b
2023-12-01 12:24:29 -05:00
Andrew Chow
6b3927f79a
Merge bitcoin/bitcoin#28848: bugfix, Change up submitpackage results to return results for all transactions
f23ba24aa0 test_submitpackage: only make a chain of 3 txns (Greg Sanders)
e67a345162 doc: submitpackage vsize results are sigops-adjusted (Greg Sanders)
b67db52c39 RPC submitpackage: change return format to allow partial errors (Greg Sanders)

Pull request description:

  This was prompted by errors being returned that didn't "make any sense" to me, because it would for example return a "fee too low" error, when the "real" error was the child had something invalid, which disallowed CPFP evaluation. Rather than make judgment calls on what error is important(which is currently just return the "first"!), we simply return all errors and let the callers determine what's best.

  Added a top level `package_msg` for quick eye-balling of general success of the package.

  This PR also fixes a couple bugs:

  1) Currently we don't actually broadcast a transaction, even if it was entered into our mempool, if a subsequent transaction causes `PKG_TX` failure.
  2) "other-wtxid" is uncovered by tests, but IIUC was previously required to return "fees" and "vsize" results, but did not. I just make those results optional.

ACKs for top commit:
  Sjors:
    Light re-utACK f23ba24aa0
  achow101:
    ACK f23ba24aa0
  glozow:
    utACK f23ba24aa0, thanks for taking the suggestions

Tree-SHA512: ebfd716a4fed9e8c2dea3d2181ba6a6171b06718d29ac2324c67b7a30b374d199f7e1739f91ab5d036be172d0479de9bc89c32263ee62143c0338b9b622d0cca
2023-12-01 12:17:15 -05:00
Andrew Chow
498994b6f5
Merge bitcoin/bitcoin#26762: bugfix: Make CCheckQueue RAII-styled (attempt 2)
5b3ea5fa2e refactor: Move `{MAX,DEFAULT}_SCRIPTCHECK_THREADS` constants (Hennadii Stepanov)
6e17b31680 refactor: Make `CCheckQueue` non-copyable and non-movable explicitly (Hennadii Stepanov)
8111e74653 refactor: Drop unneeded declaration (Hennadii Stepanov)
9cf89f7a5b refactor: Make `CCheckQueue` constructor start worker threads (Hennadii Stepanov)
d03eaacbcf Make `CCheckQueue` destructor stop worker threads (Hennadii Stepanov)
be4ff3060b Move global `scriptcheckqueue` into `ChainstateManager` class (Hennadii Stepanov)

Pull request description:

  This PR:
  - makes `CCheckQueue` RAII-styled
  - gets rid of the global `scriptcheckqueue`
  - fixes https://github.com/bitcoin/bitcoin/issues/25448

  The previous attempt was in https://github.com/bitcoin/bitcoin/pull/18731.

ACKs for top commit:
  martinus:
    ACK 5b3ea5fa2e
  achow101:
    ACK 5b3ea5fa2e
  TheCharlatan:
    ACK 5b3ea5fa2e

Tree-SHA512: 45cca846e7ed107e3930149f0b616ddbaf2648d6cde381f815331b861b5d67ab39e154883ae174b8abb1dae485bc904318c50c51e5d6b46923d89de51c5eadb0
2023-11-30 14:28:46 -05:00
Ryan Ofsky
ffb021612b
Merge bitcoin/bitcoin#28451: refactor: Remove unused SER_DISK, SER_NETWORK, CDataStream
fa98a097a3 Rename version.h to node/protocol_version.h (MarcoFalke)
fa4fbd5816 Remove unused version.h include (MarcoFalke)
fa0ae22ff2 Remove unused SER_NETWORK, SER_DISK (MarcoFalke)
fae00fe9c2 Remove unused CDataStream (MarcoFalke)
fa7eb4f5c3 fuzz: Drop unused version from fuzz input format (MarcoFalke)

Pull request description:

  Seems odd to have code that is completely dead.

  Fix this by removing all of it.

ACKs for top commit:
  sipa:
    utACK fa98a097a3
  ajtowns:
    ACK fa98a097a3
  ryanofsky:
    Seems odd to not code review ACK fa98a097a3 (looks good)

Tree-SHA512: 9f1b9d9f92bda0512610bda6653e892756f637860362a9abfa439faab62de233cbad94b7df78ebacc160d9667aadfed4d9df08c0edefa618c040a049050fb913
2023-11-30 11:11:51 -05:00
fanquake
05d3f8e822
Merge bitcoin/bitcoin#28951: fuzz: BIP324: damage ciphertext/aad in full byte range
e67634ef19 fuzz: BIP324: damage ciphertext/aad in full byte range (Sebastian Falbesoner)

Pull request description:

  This PR is a tiny improvement for the `bip324_cipher_roundtrip` fuzz target: currently the damaging of input data for decryption (either ciphertext or aad) only ever happens in the lower nibble within the byte at the damage position, as the bit position for the `damage_val` byte was calculated with `damage_bit & 3` (corresponding to `% 4`) rather than `damage_bit & 7` (corresponding to the expected `% 8`).

  Noticed while reviewing #28263 which uses similar constructs.

ACKs for top commit:
  stratospher:
    ACK e67634ef.
  dergoegge:
    utACK e67634ef19

Tree-SHA512: 1bab4df28708e079874feee939beef45eff235215375c339decc696f4c9aef04e4b417322b045491c8aec6e88ec8ec2db564e27ef1b0be352b6ff4ed38bad49a
2023-11-30 15:03:53 +00:00
MarcoFalke
fa98a097a3
Rename version.h to node/protocol_version.h 2023-11-30 11:28:31 +01:00
MarcoFalke
fa4fbd5816
Remove unused version.h include 2023-11-30 11:28:19 +01:00
MarcoFalke
fa0ae22ff2
Remove unused SER_NETWORK, SER_DISK 2023-11-30 11:28:17 +01:00
MarcoFalke
fae00fe9c2
Remove unused CDataStream 2023-11-30 11:27:54 +01:00
MarcoFalke
fa7eb4f5c3
fuzz: Drop unused version from fuzz input format 2023-11-30 11:27:21 +01:00
Greg Sanders
e67a345162 doc: submitpackage vsize results are sigops-adjusted 2023-11-29 12:56:26 -05:00
Greg Sanders
b67db52c39 RPC submitpackage: change return format to allow partial errors
Behavior prior to this commit allows some transactions to
enter into the local mempool but not be reported to the user
when encountering a PackageValidationResult::PCKG_TX result.

This is further compounded with the fact that any transactions
submitted to the mempool during this call would also not be
relayed to peers, resulting in unexpected behavior.

Fix this by, if encountering a package error, reporting all
wtxids, along with a new error field, and broadcasting every
transaction that was found in the mempool after submission.

Note that this also changes fees and vsize to optional,
which should also remove an issue with other-wtxid cases.
2023-11-29 12:56:26 -05:00
fanquake
7bc8c5312b
Merge bitcoin/bitcoin#28969: fuzz: Avoid signed-integer-overflow in wallet_notifications fuzz target
fab164f342 fuzz: Avoid signed-integer-overflow in wallet_notifications fuzz target (MarcoFalke)

Pull request description:

  Should avoid

  ```
  policy/feerate.cpp:29:63: runtime error: signed integer overflow: 77600710321911316 * 149 cannot be represented in type 'int64_t' (aka 'long')
      #0 0x563a1775ed66 in CFeeRate::GetFee(unsigned int) const src/policy/feerate.cpp:29:63
      #1 0x563a15913a69 in wallet::COutput::COutput(COutPoint const&, CTxOut const&, int, int, bool, bool, bool, long, bool, std::optional<CFeeRate>) src/./wallet/coinselection.h:91:57
      #2 0x563a16fa6a6d in wallet::FetchSelectedInputs(wallet::CWallet const&, wallet::CCoinControl const&, wallet::CoinSelectionParams const&) src/wallet/spend.cpp:297:17
      #3 0x563a16fc4512 in wallet::CreateTransactionInternal(wallet::CWallet&, std::vector<wallet::CRecipient, std::allocator<wallet::CRecipient>> const&, int, wallet::CCoinControl const&, bool) src/wallet/spend.cpp:1105:33
      #4 0x563a16fbec74 in wallet::CreateTransaction(wallet::CWallet&, std::vector<wallet::CRecipient, std::allocator<wallet::CRecipient>> const&, int, wallet::CCoinControl const&, bool) src/wallet/spend.cpp:1291:16
      #5 0x563a16fcf6df in wallet::FundTransaction(wallet::CWallet&, CMutableTransaction&, long&, int&, bilingual_str&, bool, std::set<int, std::less<int>, std::allocator<int>> const&, wallet::CCoinControl) src/wallet/spend.cpp:1361:16
      #6 0x563a1597b7b9 in wallet::(anonymous namespace)::FuzzedWallet::FundTx(FuzzedDataProvider&, CMutableTransaction) src/wallet/test/fuzz/notifications.cpp:162:15
      #7 0x563a15958240 in wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_0::operator()() const src/wallet/test/fuzz/notifications.cpp:228:23
      #8 0x563a15958240 in unsigned long CallOneOf<wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_0, wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_1>(FuzzedDataProvider&, wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_0, wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_1) src/./test/fuzz/util.h:43:27
      #9 0x563a15958240 in wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>) src/wallet/test/fuzz/notifications.cpp:196:9
      #10 0x563a15fdef0c in std::function<void (Span<unsigned char const>)>::operator()(Span<unsigned char const>) const /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_function.h:591:9
      #11 0x563a15fdef0c in LLVMFuzzerTestOneInput src/test/fuzz/fuzz.cpp:178:5
      #12 0x563a158032a4 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x19822a4) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06)
      #13 0x563a15802999 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1981999) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06)
      #14 0x563a15804586 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1983586) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06)
      #15 0x563a15804aa7 in fuzzer::Fuzzer::Loop(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1983aa7) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06)
      #16 0x563a157f21fb in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x19711fb) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06)
      #17 0x563a1581c766 in main (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x199b766) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06)
      #18 0x7f499e17b0cf  (/lib/x86_64-linux-gnu/libc.so.6+0x280cf) (BuildId: 96ab1a8f3b2c9a2ed37c7388615e6a726d037e89)
      #19 0x7f499e17b188 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x28188) (BuildId: 96ab1a8f3b2c9a2ed37c7388615e6a726d037e89)
      #20 0x563a157e70c4 in _start (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x19660c4) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06)

  SUMMARY: UndefinedBehaviorSanitizer: signed-integer-overflow policy/feerate.cpp:29:63 in
  MS: 0 ; base unit: 0000000000000000000000000000000000000000
  0x3f,0x0,0x2f,0x5f,0x5f,0x5f,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0xff,0xff,0xff,0xff,0xff,0x53,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0x13,0x5e,0x5f,0x5f,0x8,0x25,0x0,0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x8,0x25,0xca,0x7f,0x5f,0x5f,0x5f,0x13,0x13,0x5f,0x5f,0x5f,0x2,0xdb,0xca,0x0,0x0,0xe7,0xe6,0x66,0x65,0x0,0x0,0x0,0x0,0x44,0x3f,0xa,0xa,0xff,0xff,0xff,0xff,0xff,0x61,0x76,0x6f,0x69,0x0,0xb5,0x15,
  ?\000/___}}}}}}}}}}}}}}}}}}}}\377\377\377\377\377S\377\377\377\377\377\000\000\000\000\000\000\023^__\010%\000______\010%\312\177___\023\023___\002\333\312\000\000\347\346fe\000\000\000\000D?\012\012\377\377\377\377\377avoi\000\265\025
  artifact_prefix='./'; Test unit written to ./crash-4d3bac8a64d4e58b2f0943e6d28e6e1f16328d7d
  Base64: PwAvX19ffX19fX19fX19fX19fX19fX19fX3//////1P//////wAAAAAAABNeX18IJQBfX19fX18IJcp/X19fExNfX18C28oAAOfmZmUAAAAARD8KCv//////YXZvaQC1FQ==

ACKs for top commit:
  dergoegge:
    ACK fab164f342
  brunoerg:
    ACK fab164f342

Tree-SHA512: f416828f4394aa7303ee437f141e9bbd23c0e0f1b830e4ef3932338858249ba68a811b9837c5b7ad8c6ab871b6354996434183597c1a910a8d8e8d829693e4b2
2023-11-29 17:18:01 +00:00
fanquake
dd73c22976
Merge bitcoin/bitcoin#28486: test, bench: Initialize and terminate use of Winsock properly
fd4c6a10f2 test: Setup networking globally (Hennadii Stepanov)

Pull request description:

  On the master branch, when compiling without external signer support, the `bench_bitcoin.exe` does not initialize Winsock DLL that is required, for example, here: 459272d639/src/bench/addrman.cpp (L124)

  Moreover, Windows docs explicitly [state](https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsacleanup) that `WSAStartup` and `WSACleanup` must be balanced:
  > There must be a call to `WSACleanup` for each successful call to `WSAStartup`. Only the final `WSACleanup` function call performs the actual cleanup. The preceding calls simply decrement an internal reference count in the WS2_32.DLL.

  That is not the case for our unit tests because the `SetupNetworking()` call is a part of the `BasicTestingSetup` fixture and is invoked multiple times, while `~CNetCleanup()` is invoked once only, at the end of the test binary execution.

  This PR fixes Winsock DLL initialization and termination.

  More docs:
  - https://learn.microsoft.com/en-us/windows/win32/winsock/initializing-winsock
  - https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsastartup
  - https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsacleanup

  Fix https://github.com/bitcoin/bitcoin/issues/28940.

ACKs for top commit:
  maflcko:
    lgtm ACK fd4c6a10f2

Tree-SHA512: d360eaf776943f7f7a35ed5a5f9f3228d9e3d18eb824e5997cdc8eadddf466abe9f2da4910ee3bb86bf5411061e758259f7e1ec344f234ef7996f1bf8781dcda
2023-11-29 17:14:34 +00:00
MarcoFalke
fab164f342
fuzz: Avoid signed-integer-overflow in wallet_notifications fuzz target 2023-11-29 17:12:50 +01:00
MarcoFalke
faecde9102
fuzz: Fix nullptr deref in scriptpubkeyman
Also, add missing includes to scriptpubkeyman.

Also, export dependecies of the BasicTestingSetup from setup_common.h,
to avoid having to include them when setup_common.h is already included.
2023-11-29 16:04:08 +01:00
fanquake
8cf2137dbe
Merge bitcoin/bitcoin#28958: refactor: Use Txid in CMerkleBlock
fa02c08c93 refactor: Use Txid in CMerkleBlock (MarcoFalke)

Pull request description:

  This should also fix a gcc-13 compiler warning, see https://github.com/bitcoin/bitcoin/pull/28922#discussion_r1407856376

  ```
  rpc/txoutproof.cpp: In lambda function:
  rpc/txoutproof.cpp:72:33: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
     72 |                     const Coin& coin = AccessByTxid(active_chainstate.CoinsTip(), Txid::FromUint256(tx));
        |                                 ^~~~
  rpc/txoutproof.cpp:72:52: note: the temporary was destroyed at the end of the full expression ‘AccessByTxid((*(const CCoinsViewCache*)(&(& active_chainstate)->Chainstate::CoinsTip())), transaction_identifier<false>::FromUint256((* & tx)))’
     72 |                     const Coin& coin = AccessByTxid(active_chainstate.CoinsTip(), Txid::FromUint256(tx));
        |                                        ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1plus: all warnings being treated as errors

ACKs for top commit:
  TheCharlatan:
    Re-ACK fa02c08c93
  dergoegge:
    reACK fa02c08c93

Tree-SHA512: 2e6837b9d0c90bd6e9d766330e7086d68c6ec80bb27fe2cfc4702b251b00d91a79f8bfbc76d998cbcd90bee5317402cf617f61099eee96d94e7ac8f37ba7a642
2023-11-29 10:55:18 +00:00
Andrew Chow
16b5b4b674
Merge bitcoin/bitcoin#28579: refactor: Remove redundant checks in compat/assumptions.h
fa1a384706 Move compat.h include from system.h to system.cpp (MarcoFalke)
88887531b7 Move compat/assumptions.h include to one place that actually needs it (MarcoFalke)
77774110f4 Remove __cplusplus from compat/assumptions.h (MarcoFalke)
faa3d4f1d8 Remove duplicate NDEBUG check from compat/assumptions.h (MarcoFalke)

Pull request description:

  Generally, compile-time checks should be close to the code that use them. Especially, since `compat/assumptions.h` is only included in one place, where iwyu suggests to remove it.

  Fix all issues:
  * The `NDEBUG` check is used in `util/check`, so it is redundant in `compat/assumptions.h`.
  * The `__cplusplus` check is redundant with `doc/dependencies.md` (see commit message).
  * Add missing `// IWYU pragma: keep` to avoid removing the include by accident.

ACKs for top commit:
  achow101:
    ACK fa1a384706
  TheCharlatan:
    re-ACK fa1a384706
  theuni:
    ACK fa1a384706

Tree-SHA512: f8b6db84be5d8844a2267345c0b1405fcbc39b8b5eeaa24db5b8412a74145fe44cf188b6b0c39cc2b062690ed37ca5b4662473484afe28dbec6469e79961389b
2023-11-28 16:51:28 -05:00
Andrew Chow
75462b39d2
Merge bitcoin/bitcoin#28554: bugfix: throw an error if an invalid parameter is passed to getnetworkhashps RPC
9ac114e5cd Throw error if invalid parameters passed to getnetworkhashps RPC endpoint (Jameson Lopp)

Pull request description:

  When writing some scripts that iterated over many blocks to generate hashrate estimates I realized that my script was going out of range of the current chain tip height but was not encountering any errors.

  I believe that passing an invalid block height to this function but receiving the hashrate estimate for the chain tip instead should be considered unexpected behavior.

ACKs for top commit:
  Sjors:
    re-utACK 9ac114e5cd
  kevkevinpal:
    reACK [9ac114e](9ac114e5cd)
  achow101:
    ACK 9ac114e5cd

Tree-SHA512: eefb465c2dd654fc48267f444e1809597ec5363cdd131ea9ec812458fed1e4bffbbbb0617d74687c9f7bb16274b598d8292f5eeb7953421e5d2a8dc2cc081f2b
2023-11-28 16:26:04 -05:00
Andrew Chow
535424a10b
Merge bitcoin/bitcoin#28903: refactor: Make CTxMemPoolEntry only explicitly copyable
705e3f1de0 refactor: Make CTxMemPoolEntry only explicitly copyable (TheCharlatan)

Pull request description:

  This has the goal of prohibiting users from accidentally creating runtime failures, e.g. by interacting with iterator_to with a copied entry. This was brought up here:  https://github.com/bitcoin/bitcoin/pull/28886#issuecomment-1814794954.

  CTxMemPoolEntry is already implicitly not move-constructable. So be explicit about this and use a std::list to collect the values in the policy_estimator fuzz test instead of a std::vector.

ACKs for top commit:
  maflcko:
    ACK 705e3f1de0 🌯
  achow101:
    ACK 705e3f1de0
  ajtowns:
    ACK 705e3f1de0
  ismaelsadeeq:
    ACK 705e3f1de0

Tree-SHA512: 62056905c679c919d00f9ae065ed66ac986e7e7062015aea542843d8deecda57104d7a68d002f7b20afa3164f8e9215d2d2d002c167224129540e3b1bd0712cc
2023-11-28 14:45:23 -05:00
Hennadii Stepanov
fd4c6a10f2
test: Setup networking globally 2023-11-28 19:11:52 +00:00
Ryan Ofsky
6acec6b9ff multiprocess: Add type conversion code for UniValue types
Extend IPC unit test to cover this and verify the serialization happens
correctly.
2023-11-28 12:35:50 -05:00
fanquake
fe4e83f50d
Merge bitcoin/bitcoin#28912: refactor: VectorWriter and SpanReader without nVersion
fae76a1f2a scripted-diff: Use DataStream in most places (MarcoFalke)
fac39b56b7 refactor: SpanReader without nVersion (MarcoFalke)

Pull request description:

  The serialize version is unused, so remove it. This also allows to remove `GCS_SER_VERSION` and allows a scripted-diff to remove most of `CDataStream`.

ACKs for top commit:
  ajtowns:
    ACK fae76a1f2a
  ryanofsky:
    Code review ACK fae76a1f2a

Tree-SHA512: 3b487dba8ea380f1eacff9fdfb9197f025dbc30906813d3f4c3e6f1e9e4d9f2a169c6f163f51d135e18af538be78e2d2b13d694073ad25c5762980ae971a4c83
2023-11-28 17:35:50 +00:00
Ryan Ofsky
0cc74fce72 multiprocess: Add type conversion code for serializable types
Allow any C++ object that has Serialize and Unserialize methods and can be
serialized to a bitcoin CDataStream to be converted to a capnproto Data field
and passed as arguments or return values to capnproto methods using the Data
type.

Extend IPC unit test to cover this and verify the serialization happens
correctly.
2023-11-28 12:35:50 -05:00
Ryan Ofsky
4aaee23921 test: add ipc test to test multiprocess type conversion code
Add unit test to test IPC method calls and type conversion between bitcoin c++
types and capnproto messages.

Right now there are custom type hooks in bitcoin IPC code, so the test is
simple, but in upcoming commits, code will be added to convert bitcoin types to
capnproto messages, and the test will be expanded.
2023-11-28 12:35:50 -05:00
MarcoFalke
fa02c08c93
refactor: Use Txid in CMerkleBlock 2023-11-28 17:49:41 +01:00
fanquake
31ce305d46
Merge bitcoin/bitcoin#28952: fuzz: Avoid timeout in process_messages
fa825975b5 fuzz: Avoid timeout in process_messages (MarcoFalke)

Pull request description:

  Reduce the number of messages per fuzz input. There should be no reason to have more messages than that.

  This should also avoid timeouts, such as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64548. CC https://github.com/bitcoin/bitcoin/issues/28812

ACKs for top commit:
  dergoegge:
    utACK fa825975b5

Tree-SHA512: eeff732f7b0bd9a71f23aeecbf813d31fe34d355b906fd0384a43075cbc3cebc46a26df741b0f337208d8b33b3e28210c9b9437e2eed77844f03131bb8f5f2a1
2023-11-28 16:24:06 +00:00
Andrew Chow
26b7bcf10e
Merge bitcoin/bitcoin#28766: Improve peformance of CTransaction::HasWitness (28107 follow-up)
af1d2ff883 [primitives] Precompute result of CTransaction::HasWitness (dergoegge)

Pull request description:

  This addresses https://github.com/bitcoin/bitcoin/pull/28107#discussion_r1364961590 from #28107.

ACKs for top commit:
  theStack:
    ACK af1d2ff883
  achow101:
    ACK af1d2ff883
  stickies-v:
    ACK af1d2ff883
  TheCharlatan:
    ACK af1d2ff883

Tree-SHA512: a77654ae429d0d7ce12daa309770e75beec4f8984734f80ed203156199425af43b50ad3d8aab85a89371a71356464ebd4503a0248fd0103579adfc74a55aaf51
2023-11-28 08:44:41 -05:00
MarcoFalke
fae76a1f2a
scripted-diff: Use DataStream in most places
The remaining places are handled easier outside a scripted-diff.

-BEGIN VERIFY SCRIPT-
 sed --regexp-extended -i 's/CDataStream ([0-9a-zA-Z_]+)\(SER_[A-Z]+, [A-Z_]+_VERSION\);/DataStream \1{};/g' $( git grep -l CDataStream)
 sed -i 's/, CDataStream/, DataStream/g' src/wallet/walletdb.cpp
-END VERIFY SCRIPT-
2023-11-28 12:42:37 +01:00
MarcoFalke
fac39b56b7
refactor: SpanReader without nVersion
The field is unused, so remove it.

This is also required for future commits.
2023-11-28 12:42:07 +01:00
fanquake
c252a0fc0f
Merge bitcoin/bitcoin#28892: refactor: P2P transport without serialize version and type
fa79a881ce refactor: P2P transport without serialize version and type (MarcoFalke)
fa9b5f4fe3 refactor: NetMsg::Make() without nVersion (MarcoFalke)
66669da4a5 Remove unused Make() overload in netmessagemaker.h (MarcoFalke)
fa0ed07941 refactor: VectorWriter without nVersion (MarcoFalke)

Pull request description:

  Now that the serialize framework ignores the serialize version and serialize type, everything related to it can be removed from the code.

  This is the first step, removing dead code from the P2P stack. A different pull will remove it from the wallet and other parts.

ACKs for top commit:
  ajtowns:
    reACK fa79a881ce

Tree-SHA512: 785b413580d980f51f0d4f70ea5e0a99ce14cd12cb065393de2f5254891be94a14f4266110c8b87bd2dbc37467676655bce13bdb295ab139749fcd8b61bd5110
2023-11-28 11:24:09 +00:00
fanquake
dc369af3f5
Merge bitcoin/bitcoin#28936: Change petertodd seeds to petertodd.net
ecb46837e7 Change petertodd seeds to petertodd.net (Peter Todd)

Pull request description:

  I changed my DNS seeds to .net from .org to avoid issues with DNS blacklisting, that falsely thinks my domain name is pointing to IP addresses with malware and similar things. Right now there are CNAME records, so the .org addresses still work. But eventually, if needed, I'll remove those CNAME's.

ACKs for top commit:
  pablomartin4btc:
    tACK ecb46837e7
  fanquake:
    ACK ecb46837e7 - tested that usable addresses are being returned.

Tree-SHA512: 285f7101198ea8e2e20900c17b38aa86db812308c6985d762e5fa8b6f1bc5b0d2d278da841fe2e10cf32e3fe18d4c984bc8cf195bd8d40c86b092b545c62acfa
2023-11-28 10:53:27 +00:00
MarcoFalke
fa825975b5
fuzz: Avoid timeout in process_messages 2023-11-28 09:58:10 +01:00
Sebastian Falbesoner
e67634ef19 fuzz: BIP324: damage ciphertext/aad in full byte range
Currently the damaging of input data for decryption (either ciphertext
or aad) only ever happens in the lower nibble within the byte at the
damage position, as the bit position for the `damage_val` byte was
calculated with `damage_bit & 3` (corresponding to `% 4`) rather than
`damage_bit & 7` (corresponding to the expected `% 8`).
2023-11-28 02:30:09 +01:00
fanquake
794f971607
Merge bitcoin/bitcoin#28933: fuzz: Faster wallet_notifications target
fa15861763 fuzz: Faster wallet_notifications target (MarcoFalke)
fa971c09f2 Export assert from util/check.h (MarcoFalke)

Pull request description:

  Avoid read/write from storage to speed the target up.

ACKs for top commit:
  dergoegge:
    reACK fa15861763
  brunoerg:
    reACK fa15861763

Tree-SHA512: 90aa856ae31db27a55ef0dfa2cb303d98e6c4d530d2937ad8d808c5f4048389b7ed3c78c27df92db8fe29531b5530aecbb06a0e8274dda424149f46cd6c19f98
2023-11-27 17:35:45 +00:00
MarcoFalke
fa15861763
fuzz: Faster wallet_notifications target 2023-11-27 12:06:06 +01:00
Andrew Toth
1c4b9cbe90
bench: add readblock benchmark 2023-11-26 13:24:05 -05:00
fanquake
5f9fd11680
Merge bitcoin/bitcoin#28931: fuzz: Limit fuzz buffer size in script_flags target
faf1fb207f Fix IWYU for the script_flags fuzz target (MarcoFalke)
fa71285b73 fuzz: Limit fuzz buffer size in script_flags target (MarcoFalke)
fa6b87b9ee fuzz: CDataStream -> DataStream in script_flags (MarcoFalke)

Pull request description:

  Most fuzz targets have an upper limit on the buffer size to avoid excessive runtime. Do the same for `script_flags` to avoid timeouts such as https://github.com/bitcoin/bitcoin/issues/28812#issuecomment-1824696971

  Also, fix iwyu. Also, remove legacy `CDataStream`.

ACKs for top commit:
  dergoegge:
    ACK faf1fb207f
  brunoerg:
    utACK faf1fb207f

Tree-SHA512: 9301917b353f7409e448b6fd3635de19330856e0742431db5ef04e62873501b5b4cd6cb78ad81ada2747fa2bdae033115b5951d10489dd5d0d320426c8b96bee
2023-11-26 12:22:50 +00:00
Peter Todd
ecb46837e7
Change petertodd seeds to petertodd.net
I changed my DNS seeds to .net from .org to avoid issues with DNS blacklisting,
that falsely thinks my domain name is pointing to IP addresses with malware and
similar things. Right now there are CNAME records, so the .org addresses still
work. But eventually, if needed, I'll remove those CNAME's.
2023-11-25 13:59:41 +00:00
fanquake
b5a271334c
Merge bitcoin/bitcoin#28922: Use Txid in COutpoint
9e58c5bcd9 Use Txid in COutpoint (dergoegge)

Pull request description:

  This PR changes the type of the hash of a transaction outpoint from `uint256` to `Txid`.

ACKs for top commit:
  Sjors:
    ACK 9e58c5bcd9
  stickies-v:
    ACK 9e58c5bcd9. A sizeable diff, but very straightforward changes. Didn't see anything controversial. Left a few nits, but nothing blocking, only if you have to retouch.
  TheCharlatan:
    ACK 9e58c5bcd9

Tree-SHA512: 58f61ce1c58668f689513e62072a7775419c4d5af8f607669cd8cdc2e7be9645ba14af7f9e2d65da2670da3ec1ce7fc2a744037520caf799aba212fd1ac44b34
2023-11-24 14:41:58 +00:00
MarcoFalke
fa971c09f2
Export assert from util/check.h
This avoids having to include both headers when assert and Assert are
used at the same time.
2023-11-24 13:11:36 +01:00
fanquake
f4073c5395
Merge bitcoin/bitcoin#28578: fuzz: add target for DescriptorScriptPubKeyMan
47e5c9994c fuzz: add target for `DescriptorScriptPubKeyMan` (brunoerg)
641dddf018 fuzz: create ConsumeCoins (brunoerg)
2e1833ca13 fuzz: move `MockedDescriptorConverter` to `fuzz/util` (brunoerg)

Pull request description:

  This PR adds fuzz target for `DescriptorScriptPubKeyMan`. Also, moves `MockedDescriptorConverter` to `fuzz/util/descriptor` to be used here and in `descriptor` target.

ACKs for top commit:
  maflcko:
    lgtm ACK 47e5c9994c 🏓
  dergoegge:
    ACK 47e5c9994c

Tree-SHA512: 519acca6d7b7a3a0bfc031441b02d5980b12bfb97198bd1958a83cd815ceb9eb1499a48a3f0a7fe20e5d06d83b89335d987376fc0a014e2106b0bc0e9838dd02
2023-11-23 17:34:03 +00:00
MarcoFalke
faf1fb207f
Fix IWYU for the script_flags fuzz target
Also, export script_error.h from interpreter.h, because there should
rarely be a case where script_error.h is included without interpreter.h
2023-11-23 17:57:53 +01:00
MarcoFalke
fa71285b73
fuzz: Limit fuzz buffer size in script_flags target 2023-11-23 17:56:52 +01:00
MarcoFalke
fa6b87b9ee
fuzz: CDataStream -> DataStream in script_flags 2023-11-23 17:50:33 +01:00
furszy
75fbf444c1
wallet: birth time update during tx scanning
As the user could have imported a descriptor with
a newer timestamp (by blindly setting 'timestamp=now'),
the wallet needs to update the birth time when it detects
a transaction older than the oldest descriptor timestamp.
2023-11-23 09:55:10 -03:00
furszy
b4306e3c8d
refactor: rename FirstKeyTimeChanged to MaybeUpdateBirthTime
In the following-up commit, the wallet birth time will also
be modified by the transactions scanning process. When a tx
older than all descriptor's timestamp is detected.
2023-11-23 09:55:09 -03:00
MarcoFalke
fa79a881ce
refactor: P2P transport without serialize version and type 2023-11-23 13:43:39 +01:00
fanquake
4374a87879
Merge bitcoin/bitcoin#28895: p2p: do not make automatic outbound connections to addnode peers
5e7cc4144b test: add unit test for CConnman::AddedNodesContain() (Jon Atack)
cc62716920 p2p: do not make automatic outbound connections to addnode peers (Jon Atack)

Pull request description:

  to allocate our limited outbound slots correctly, and to ensure addnode
  connections benefit from their intended protections.

  Our addnode logic usually connects the addnode peers before the automatic
  outbound logic does, but not always, as a connection race can occur.  If an
  addnode peer disconnects us and if it was the only one from its network, there
  can be a race between reconnecting to it with the addnode thread, and it being
  picked as automatic network-specific outbound peer.  Or our internet connection
  or router or the addnode peer could be temporarily offline, and then return
  online during the automatic outbound thread.  Or we could add a new manual peer
  using the addnode RPC at that time.

  The race can be more apparent when our node doesn't know many peers, or with
  networks like cjdns that currently have few bitcoin peers.

  When an addnode peer is connected as an automatic outbound peer and is the only
  connection we have to a network, it can be protected by our new outbound
  eviction logic and persist in the "wrong role".

  Finally, there does not seem to be a reason to make block-relay or short-lived
  feeler connections to addnode peers, as the addnode logic will ensure we connect
  to them if they are up, within the addnode connection limit.

  Fix these issues by checking if the address is an addnode peer in our automatic
  outbound connection logic.

ACKs for top commit:
  mzumsande:
    Tested ACK 5e7cc4144b
  brunoerg:
    utACK 5e7cc4144b
  vasild:
    ACK 5e7cc4144b
  guggero:
    utACK 5e7cc4144b

Tree-SHA512: 2438c3ec92e98aebca2a0da960534e4655a9c6e1192a24a085fc01326d95cdb1b67d8c44e4ee706bc1d8af8564126d446a21b5579dcbec61bdea5fce2f0115ee
2023-11-22 11:47:18 +00:00
fanquake
ca041fc4ab
Merge bitcoin/bitcoin#28904: Drop CAutoFile
4eb2a9ea4b streams: Drop unused CAutoFile (Anthony Towns)
cde9a4b137 refactor: switch from CAutoFile to AutoFile (Anthony Towns)
bbd4646a2e blockstorage: switch from CAutoFile to AutoFile (Anthony Towns)
c72ddf04db streams: Remove unused CAutoFile::GetVersion (Anthony Towns)
e63f643079 streams: Base BufferedFile on AutoFile instead of CAutoFile (Anthony Towns)

Pull request description:

  Continuing the move away from `GetVersion()`, replace uses of `CAutoFile` with `AutoFile`.

ACKs for top commit:
  maflcko:
    re-ACK 4eb2a9ea4b 🖼
  TheCharlatan:
    ACK 4eb2a9ea4b
  stickies-v:
    ACK 4eb2a9ea4b

Tree-SHA512: 1a68c42fdb725ca4bf573e22794fe7809fea764a5f97ecb33435add3c609d40f336038fb22ab1ea72567530efd39678278c9016f92ed04891afdb310631b4e82
2023-11-22 11:24:39 +00:00
fanquake
3dca308bd7
Merge bitcoin/bitcoin#28891: test: fix AddNode unit test failure on OpenBSD
007d6f0e85 test: fix `AddNode` unit test failure on OpenBSD (Sebastian Falbesoner)

Pull request description:

  On OpenBSD 7.4, the following check of the unit test `test_addnode_getaddednodeinfo_and_connection_detection` currently fails:
  ```
  BOOST_CHECK(!connman->AddNode({/*m_added_node=*/"127.1", /*m_use_v2transport=*/true}));
  ```
  The reason for that is that this OS seemingly doesn't support the IPv4 shorthand notation with omitted zero-bytes:

  ```
  $ ping 127.1
  ping: no address associated with name
  ```

  As a simple fix, this PR skips the check for this with a pre-processor #if. On NetBSD and FreeBSD, `127.1` is resolved correctly to localhost and hence the test passes (thanks to vasild for verifying on the latter!).

ACKs for top commit:
  vasild:
    ACK 007d6f0e85

Tree-SHA512: 8ab8393c490e1ecc140e8ff74f6fa4d26d0dd77e6a77a241cd198314b8c5afee7422f95351ca05f4c1742433dab77016a8ccb8d28062f8edd4b703a918a2bbda
2023-11-22 11:18:24 +00:00
ismaelsadeeq
91504cbe0d rpc: SyncWithValidationInterfaceQueue on fee estimation RPC's
This ensures that the most recent fee estimation data is used for the
fee estimation with `estimateSmartfee` and `estimaterawfee` RPC's.
2023-11-22 11:48:21 +01:00
ismaelsadeeq
714523918b tx fees, policy: CBlockPolicyEstimator update from CValidationInterface notifications
`CBlockPolicyEstimator` will implement `CValidationInterface` and
subscribe to its notification to process transactions added and removed
from the mempool.

Re-delegate calculation of `validForFeeEstimation` from validation to fee estimator.

Also clean up the validForFeeEstimation arg thats no longer needed in `CTxMempool`.

Co-authored-by: Matt Corallo <git@bluematt.me>
2023-11-22 11:48:21 +01:00
ismaelsadeeq
dff5ad3b99 CValidationInterface: modify the parameter of TransactionAddedToMempool
Create a new struct `NewMempoolTransactionInfo` that will be used as the new parameter of
`TransactionAddedToMempool` callback.
2023-11-22 11:48:21 +01:00
ismaelsadeeq
91532bd382 tx fees, policy: update CBlockPolicyEstimator::processBlock parameter
Update `processBlock` parameter to reference to a vector of `RemovedMempoolTransactionInfo`.
2023-11-22 11:48:21 +01:00
ismaelsadeeq
bfcd401368 CValidationInterface, mempool: add new callback to CValidationInterface
This commit adds a new callback `MempoolTransactionsRemovedForBlock` which notify
its listeners of the transactions that are removed from the mempool because a new
block is connected, along with the block height the transactions were removed.
The transactions are in `RemovedMempoolTransactionInfo` format.

`CTransactionRef`, base fee, virtual size, and height which the transaction was added
to the mempool are all members of the struct called `RemovedMempoolTransactionInfo`.

A struct `NewMempoolTransactionInfo`, which has fields similar to `RemovedMempoolTransactionInfo`,
will be added in a later commit, create a struct `TransactionInfo` with all similar fields.
They can both have a member with type `TransactionInfo`.
2023-11-22 11:48:21 +01:00
ismaelsadeeq
0889e07987 tx fees, policy: cast with static_cast instead of C-Style cast 2023-11-22 11:48:21 +01:00
ismaelsadeeq
a0e3eb7549 tx fees, policy: bugfix: move removeTx into reason != BLOCK condition
If the removal reason of a transaction is BLOCK, then the `removeTx`
boolean argument should be true.

Before this PR, `CBlockPolicyEstimator` have to complete updating the fee stats
before the mempool clears that's why having removeTx call outside reason!= `BLOCK`
in `addUnchecked` was not a bug.

But in a case where the `CBlockPolicyEstimator` update is asynchronous, the mempool might
clear before we update the `CBlockPolicyEstimator` fee stats.
Transactions that are removed for `BLOCK` reasons will also be incorrectly removed from
`CBlockPolicyEstimator` stats as failures.
2023-11-22 11:48:21 +01:00
Sjors Provoost
f053024273
wallet: batch external signer descriptor import
Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
2023-11-21 23:07:00 -03:00
furszy
1f65241b73
wallet: descriptors setup, batch db operations
Instead of doing one db transaction per descriptor setup,
batch all descriptors' setup writes in a single db txn.

Speeding up the process and preventing the wallet from entering
an inconsistent state if any of the intermediate transactions
fail.
2023-11-21 23:01:42 -03:00
furszy
3eb769f150
wallet: batch legacy spkm TopUp
Instead of performing multiple atomic write
operations per legacy spkm setup call, batch
them all within a single atomic db txn.
2023-11-21 23:01:30 -03:00
furszy
075aa44ceb
wallet: batch descriptor spkm TopUp
Instead of performing multiple atomic write
operations per descriptor setup call, batch
them all within a single atomic db txn.
2023-11-21 23:01:30 -03:00
MarcoFalke
fa63f16018
test: Add uint256 string parse tests 2023-11-21 17:37:57 +01:00
MarcoFalke
facf629ce8
refactor: Remove unused and fragile string interface from arith_uint256 2023-11-21 17:37:25 +01:00
dergoegge
9e58c5bcd9 Use Txid in COutpoint 2023-11-21 13:15:44 +00:00
brunoerg
47e5c9994c fuzz: add target for DescriptorScriptPubKeyMan 2023-11-20 15:57:56 -03:00
brunoerg
641dddf018 fuzz: create ConsumeCoins 2023-11-20 15:57:56 -03:00
brunoerg
2e1833ca13 fuzz: move MockedDescriptorConverter to fuzz/util 2023-11-20 15:57:50 -03:00
Martin Leitner-Ankerl
d5b4c0b69e pool: change memusage_test to use int64_t, add allocation check
If alignment of the PoolAllocator would be insufficient, then the test would fail. This also catches the issue with ARM 32bit,
where int64_t is aligned to 8 bytes but void* is aligned to 4 bytes. The test adds a check to ensure the pool has allocated
a minimum number of chunks
2023-11-20 17:10:34 +01:00
MarcoFalke
fa9b5f4fe3
refactor: NetMsg::Make() without nVersion
The nVersion field is unused, so remove it.

This is also required for future commits.

Also, add PushMessage aliases in PeerManagerImpl to make calling code
less verbose.

Co-Authored-By: Anthony Towns <aj@erisian.com.au>
2023-11-20 14:02:27 +01:00
Martin Leitner-Ankerl
ce881bf9fc pool: make sure PoolAllocator uses the correct alignment
This changes the PoolAllocator to default the alignment to the given type. This makes the code simpler, and most importantly
fixes a bug on ARM 32bit that caused OOM: The class CTxOut has a member CAmount which is an int64_t and on ARM 32bit int64_t
are 8 byte aligned which is larger than the pointer alignment of 4 bytes. So for CCoinsMap to be able to use the pool, we
need to use the alignment of the member instead of just alignof(void*).
2023-11-19 18:43:29 +01:00
TheCharlatan
705e3f1de0
refactor: Make CTxMemPoolEntry only explicitly copyable
This has the goal of prohibiting users from accidentally creating
runtime failures, e.g. by interacting with iterator_to with a copied
entry.

CTxMemPoolEntry is already implicitly not move-constructable. So be
explicit about this and use a std::list to collect the values in the
policy_estimator fuzz test instead of a std::vector.

Co-authored-by: Anthony Towns <aj@erisian.com.au>
2023-11-17 23:02:02 +01:00
Anthony Towns
4eb2a9ea4b streams: Drop unused CAutoFile 2023-11-18 03:01:41 +10:00
Anthony Towns
cde9a4b137 refactor: switch from CAutoFile to AutoFile 2023-11-18 03:01:41 +10:00
Anthony Towns
bbd4646a2e blockstorage: switch from CAutoFile to AutoFile
Also bump includes per suggestions from iwyu.
2023-11-18 03:01:03 +10:00
Anthony Towns
c72ddf04db streams: Remove unused CAutoFile::GetVersion 2023-11-18 00:15:25 +10:00
Anthony Towns
e63f643079 streams: Base BufferedFile on AutoFile instead of CAutoFile 2023-11-18 00:15:22 +10:00
MarcoFalke
66669da4a5
Remove unused Make() overload in netmessagemaker.h 2023-11-17 14:38:40 +01:00