Commit graph

37448 commits

Author SHA1 Message Date
glozow
381593c906
Merge bitcoin/bitcoin#24845: wallet: return error msg for "too-long-mempool-chain"
f3221d373a test: add wallet too-long-mempool-chain error coverage (furszy)
acf0119d24 wallet: return error msg for too-long-mempool-chain failure (furszy)

Pull request description:

  Fixes #23144.

  We currently return a general "Insufficient funds" from Coin
  Selection when we actually skipped unconfirmed UTXOs that
  surpassed the mempool ancestors limit.

  This PR make the error clearer by returning:
  "Unconfirmed UTXOs are available, but spending them creates
  a chain of transactions that will be rejected by the mempool"

  Also, added an early return from Coin Selection if the sum of
  the discarded coins decreases the available balance below the
  target amount.

ACKs for top commit:
  achow101:
    ACK f3221d373a
  S3RK:
    Code review ACK f3221d373a
  Xekyo:
    ACK f3221d373a

Tree-SHA512: 13e5824b75ac302280ff894560a4ebf32a74f32fe49ef8281f2bc99c0104b92cef33d3b143c6e131f3a07eafe64533af7fc60abff585142c134b9d6e531a6a66
2023-03-23 15:53:56 +00:00
fanquake
483fb8d216
Merge bitcoin/bitcoin#27287: test: Replace threading with concurrent.futures
fa0696e786 test: Replace threading with concurrent.futures (MarcoFalke)

Pull request description:

  `threading` has no easy way to get the return value or exception once the target function stops. Not checking the return value or exception can make tests more fragile and failures harder to debug.

  Fix this by checking the return value (or exception) by wrapping the function execution into a future and calling `result()` on it.

  Can be reviewed with `--ignore-all-space`.

  (There are still some uses of `threading` around, because some tests do expect an exception to be thrown and caught in the target function)

ACKs for top commit:
  ishaanam:
    ACK fa0696e786
  stickies-v:
    ACK fa0696e786

Tree-SHA512: d9ddf6b3c530cd8c485a030a3c84d4e03d3e9f9ea8240b050afcd566a884f5cabe816ac56910cec9ea9fa299239e5abb99e672dda05a74974f61bb68dc3c1d65
2023-03-23 15:09:50 +00:00
Hennadii Stepanov
25e8fe70c6
build, qt: Fix handling of CXX=clang++ when building qt package 2023-03-23 14:38:02 +00:00
fanquake
8acfb1f8e0
Merge bitcoin/bitcoin#18933: rpc: Add submit option to generateblock
fa18504d57 rpc: Add submit option to generateblock (MarcoFalke)
fab9a08e14 refactor: Replace block_hash with block_out (MarcoFalke)

Pull request description:

  When submit is turned off, a block can be generated and returned as hex, to be used for further tests. For example, it can be submitted on a different node, on a different interface (like p2p), or just never submitted and be used for other testing purposes.

ACKs for top commit:
  instagibbs:
    ACK fa18504d57
  TheCharlatan:
    tACK fa18504d57

Tree-SHA512: 1b2ab6b71bb7e155c6482d75f5373f4e77de6446cb16bc2dfd19e7a4075b3a6ad87d7ad7a049a9eed934cb71574acfd27202f54c8bb3b03fac869f2e95db7ee5
2023-03-23 13:40:30 +00:00
fanquake
f380bb93e8
Merge bitcoin/bitcoin#27311: ci: Use clang-15 in "tidy" task
8fe27fbed8 ci: Use clang-15 in "tidy" task (Hennadii Stepanov)

Pull request description:

  Newer tools usually are better in terms of features and bug fixes.

  Requested in https://github.com/bitcoin/bitcoin/pull/26642#issuecomment-1440230390.

  Split from https://github.com/bitcoin/bitcoin/pull/26766.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 8fe27fbed8

Tree-SHA512: 62be3307d488fc4f75c40c0fa095aaa091aade2d5fe85296b56751e006c801f9d58c72c5cee8c0a0b1ba1a43804e315a3301c03e6e394bb3f3eb9b763fbb6271
2023-03-23 13:27:50 +00:00
TheCharlatan
00e9b97f37
refactor: Move fs.* to util/fs.*
The fs.* files are already part of the libbitcoin_util library. With the
introduction of the fs_helpers.* it makes sense to move fs.* into the
util/ directory as well.
2023-03-23 12:55:18 +01:00
TheCharlatan
106b46d9d2
Add missing fs.h includes
The inclusion of this header should not depend on the inclusion of other
headers that include fs.h themselves.
2023-03-23 12:54:27 +01:00
TheCharlatan
b202b3dd63
Add missing cstddef include in assumptions.h
The inclusion of this header should not depend on the inclusion of other
headers that include cstddef themselves.
2023-03-23 12:52:08 +01:00
Ben Woosley
18fb36367a
refactor: Extract util/fs_helpers from util/system
This is an extraction of filesystem related functions from util/system
into their own utility file.

The background of this commit is an ongoing effort to decouple the
libbitcoinkernel library from the ArgsManager defined in system.h.
Moving these functions out of system.h allows including them from a
separate source file without including the ArgsManager definitions from
system.h.
2023-03-23 12:52:00 +01:00
ismaelsadeeq
d178082996 test: add bech32 decoding support to address_to_scriptpubkey()
This permits functional tests to decode bech32 addresses to scriptpubkeys.
2023-03-23 12:00:54 +01:00
ismaelsadeeq
aac8793c7a test: test_bech32_decode in address.py
Adds bech32_to_bytes() which can decode a bech32 address and return the
version as an `int` and the payload in bytes.

bech32_to_bytes() is used by the test_bech32_decode unit test to test
decoding of segwit addresses.
2023-03-23 11:59:29 +01:00
fanquake
eb1c3adf38
depends: qrencode 4.1.1
Upgrade to the latest qrencode, and disable some warnings that cause
compile failures with newer compilers (clang-15+).

Fixes part of #27299.
2023-03-23 10:31:25 +00:00
fanquake
2fadb261b6
Merge bitcoin/bitcoin#27233: refactor: Replace GetTimeMicros by SystemClock
faf3f12424 refactor: Replace GetTimeMicros by SystemClock (MarcoFalke)

Pull request description:

  It is unclear from the name that `GetTimeMicros` returns the system time. Also, it is not using the type-safe `std::chrono` types.

  Fix both issues by replacing it with `SystemClock` in the only place it is used.

  This refactor should not change behavior.

ACKs for top commit:
  willcl-ark:
    tACK faf3f1242
  john-moffett:
    ACK faf3f12424 changes, but left a comment for the existing code.

Tree-SHA512: 069e6ef26467a469f128b98a4aeb334f141742befd7880cb3a7d280480e9f0684dc0686fa6a828cdcb3d11943ae5c7f8ad5d9d9dab4c668be85e5d28c78cd489
2023-03-23 10:17:23 +00:00
fanquake
4c6b7d330a
Merge bitcoin/bitcoin#27297: test: Remove unused Check* default constructors
fae349076d test: Remove unused Check* default constructors (MarcoFalke)

Pull request description:

  They are no longer needed after the removal of `swap`, see https://github.com/bitcoin/bitcoin/pull/26749#discussion_r1144532693

  Also, flatten a redundant `if` check.

ACKs for top commit:
  hebasto:
    ACK fae349076d

Tree-SHA512: c0bc0c16b5df0f16fc25e18d2414a2a3c4769da1aa30d53f8d267bc2e97dd79a0296db94c1e49cd1ca89bd42275d8c462f7bf47f03f105dfe867ebea6563454b
2023-03-22 17:58:35 +00:00
Andrew Chow
fc7c21f664
Merge bitcoin/bitcoin#27271: RPC: Fix fund transaction crash when at 0-value, 0-fee
d7cc503843 Fix fund transaction case at 0-value, 0-fee (Greg Sanders)

Pull request description:

  and when no inputs are pre-selected.

  triggered via:

  walletcreatefundedpsbt '[]' '[{"data": "deadbeef"}]' 0 '{"fee_rate": "0"}'

ACKs for top commit:
  achow101:
    ACK d7cc503843
  josibake:
    ACK d7cc503843
  furszy:
    Crashes sucks code ACK d7cc5038

Tree-SHA512: 3f5e10875666aaf52c11d6a38b951aa75d0cbe684cc7f904e199f7a864923bf31d03a654687f8b746cae0eebb886a799bff2c6d200699438480d4c0ff8785f3a
2023-03-22 12:54:26 -04:00
Hennadii Stepanov
8fe27fbed8
ci: Use clang-15 in "tidy" task 2023-03-22 15:21:39 +00:00
dergoegge
3566aa7d49 [net] Remove CNode friends
Both `CConnman` and `ConnmanTestMsg` no longer access private members of
`CNode`, we can therefore remove the friend relationship.
2023-03-22 13:18:57 +01:00
dergoegge
3eac5e7cd1 [net] Add CNode helper for send byte accounting 2023-03-22 13:18:57 +01:00
dergoegge
60441a3432 scripted-diff: [net] Rename CNode process queue members
-BEGIN VERIFY SCRIPT-
ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); }

ren cs_vProcessMsg    m_msg_process_queue_mutex
ren vProcessMsg       m_msg_process_queue
ren nProcessQueueSize m_msg_process_queue_size

-END VERIFY SCRIPT-
2023-03-22 13:18:56 +01:00
dergoegge
6693c499f7 [net] Make cs_vProcessMsg a non-recursive mutex 2023-03-22 13:18:32 +01:00
dergoegge
23d9352654 [net] Make CNode msg process queue members private
Now that all access to the process queue members is handled by methods
of `CNode` we can make these members private.
2023-03-22 13:18:32 +01:00
dergoegge
897e342d6e [net] Encapsulate CNode message polling 2023-03-22 13:18:30 +01:00
MarcoFalke
fae349076d
test: Remove unused Check* default constructors 2023-03-22 12:37:07 +01:00
fanquake
a70911492f
Merge bitcoin/bitcoin#26749: refactor: Use move semantics instead of custom swap functions
95ad70ab65 test: Default initialize `should_freeze` to `true` (Hennadii Stepanov)
cea50521fe refactor: Drop no longer used `swap` member functions (Hennadii Stepanov)
a87fb6bee5 clang-tidy: Fix modernize-use-default-member-init in `CScriptCheck` (Hennadii Stepanov)
b4bed5c1f9 refactor: Drop no longer used `CScriptCheck()` default constructor (Hennadii Stepanov)
d8427cc28e refactor: Use move semantics in `CCheckQueue::Loop` (Hennadii Stepanov)
9a0b524139 clang-tidy, test: Fix bugprone-use-after-move in `Correct_Queue_range()` (Hennadii Stepanov)
04831fee6d refactor: Make move semantics explicit for callers (Hennadii Stepanov)
6c2d5972f3 refactor: Use move semantics in `CCheckQueue::Add` (Hennadii Stepanov)
0682003214 test, refactor: Avoid `CScriptCheck::swap` in `transaction_tests` (Hennadii Stepanov)
15209d97c6 consensus, refactor: Avoid `CScriptCheck::swap` in `CheckInputScripts` (Hennadii Stepanov)

Pull request description:

  This PR makes code more succinct and readable by using move semantics.

ACKs for top commit:
  martinus:
    re-ACK 95ad70ab65
  achow101:
    ACK 95ad70ab65
  TheCharlatan:
    re-ACK 95ad70ab65
  MarcoFalke:
    re-ACK 95ad70ab65 🚥

Tree-SHA512: adda760891b12d252dc9b823fe7c41eed660364b6fb1a69f17607d7a31eb0bbb82a80d154a7acfaa241b5de37d42a293c2b6e059f26a8e92d88d3a87c99768fb
2023-03-22 11:16:56 +00:00
fanquake
6e69fead2b
Merge bitcoin/bitcoin#27280: test: Fix TypeError (expected str instance, bytes found) in wait_for_debug_log
33337eb860 test: Fix TypeError in wait_for_debug_log (MarcoFalke)

Pull request description:

ACKs for top commit:
  davidgumberg:
    tACK 33337eb860

Tree-SHA512: e641f23f0adc074d12b0ee10cab5845c16f3ac2858e42f895c69857c375fcb15c31bc1c9476bf2b6e2b49d0d2db4944687733da16d4a464152ae3323cbc6ca68
2023-03-22 10:01:01 +00:00
fanquake
24f26e08cc
guix: use cmake-minimal for python-lief
This also fixes atleast one --no-substitues build failure I've seen,
where cmake dependencies wouldn't build:
```bash
The following derivations will be built:
  /gnu/store/7qqvqq2g7l5ylrjv0gn6zha565a12kar-python-lief-0.12.1.drv
  /gnu/store/f9zwh1ldy63ga0i5w6cbbqlj6sfq226j-cmake-3.21.4.drv
  /gnu/store/3wg6ya847id503m5izhzhn1qqs464lfk-python-sphinx-4.2.0.drv

building /gnu/store/3wg6ya847id503m5izhzhn1qqs464lfk-python-sphinx-4.2.0.drv...
/ 'check' phasenote: keeping build directory `/tmp/guix-build-python-sphinx-4.2.0.drv-5'
builder for `/gnu/store/3wg6ya847id503m5izhzhn1qqs464lfk-python-sphinx-4.2.0.drv' failed with exit code 1
build of /gnu/store/3wg6ya847id503m5izhzhn1qqs464lfk-python-sphinx-4.2.0.drv failed
View build log at '/var/log/guix/drvs/3w/g6ya847id503m5izhzhn1qqs464lfk-python-sphinx-4.2.0.drv.gz'.
cannot build derivation `/gnu/store/f9zwh1ldy63ga0i5w6cbbqlj6sfq226j-cmake-3.21.4.drv': 1 dependencies couldn't be built
cannot build derivation `/gnu/store/7qqvqq2g7l5ylrjv0gn6zha565a12kar-python-lief-0.12.1.drv': 1 dependencies couldn't be built
guix environment: error: build of `/gnu/store/7qqvqq2g7l5ylrjv0gn6zha565a12kar-python-lief-0.12.1.drv' failed
```
2023-03-22 09:53:13 +00:00
fanquake
43d8173f99
guix: import LIEF from upstream (0.12.3)
Updates to version 0.12.3.
Retain our PPC64 patch.
Mention when we can drop our local definition.
2023-03-22 09:52:03 +00:00
fanquake
34551cb97a
Merge bitcoin/bitcoin#27289: Refactor: Remove unused FlatFilePos::SetNull
fa67b8181c Refactor: Remove unused FlatFilePos::SetNull (MarcoFalke)

Pull request description:

  This is unused outside of tests and the default constructor. With C++11, it can be replaced by C++11 member initializers in the default constructor.

  Beside removing unused code, this also makes it less fragile in light of uninitialized memory. (See also https://github.com/bitcoin/bitcoin/pull/26296#issuecomment-1477801767)

  If new code needs to set this to null, it can use `std::optional`, or in the worst case re-introduce this method.

ACKs for top commit:
  dergoegge:
    Code review ACK fa67b8181c
  TheCharlatan:
    ACK fa67b8181c
  john-moffett:
    ACK fa67b8181c

Tree-SHA512: 465c5e3eb4625405c445695d33e09a1fc5185c7dd1e766ba06034fb093880bfc65441d5334f7d9b20e2e417c2075557d86059f59d9648ca0e62a54c699c029b9
2023-03-22 09:43:43 +00:00
Andrew Chow
664500fc71
Merge bitcoin/bitcoin#27278: Log new headers
2c3a90f663 log: on new valid header (James O'Beirne)
e5ce857634 log: net: new header over cmpctblock (James O'Beirne)

Pull request description:

  Alternate to #27276.

  Devs were [suprised to realize](https://twitter.com/jamesob/status/1637237917201383425) last night that we don't have definitive logging for when a given header was first received.

  This logs to the main stream when new headers are received outside of IBD, as well as when headers come in over cmpctblocks. The rationale of not hiding these under log categories is that they may be useful to have widely available when debugging strange network activity, and the marginal volume is modest.

ACKs for top commit:
  dergoegge:
    Code review ACK 2c3a90f663
  achow101:
    ACK 2c3a90f663
  Sjors:
    tACK 2c3a90f663
  josibake:
    ACK 2c3a90f663

Tree-SHA512: 49fdcbe07799c8adc24143d7e5054a0c93fef120d2e9d5fddbd3b119550d895e2985be6ac10dd1825ea23a6fa5479c1b76d5518c136fbd983fa76c0d39dc354f
2023-03-21 13:48:12 -04:00
Hennadii Stepanov
95ad70ab65
test: Default initialize should_freeze to true
It is safe now, when move semantics is used instead of a custom swap
function.
2023-03-21 13:05:00 +00:00
Hennadii Stepanov
cea50521fe
refactor: Drop no longer used swap member functions 2023-03-21 13:04:53 +00:00
Hennadii Stepanov
a87fb6bee5
clang-tidy: Fix modernize-use-default-member-init in CScriptCheck 2023-03-21 13:04:44 +00:00
Hennadii Stepanov
b4bed5c1f9
refactor: Drop no longer used CScriptCheck() default constructor 2023-03-21 13:04:35 +00:00
Hennadii Stepanov
d8427cc28e
refactor: Use move semantics in CCheckQueue::Loop
Co-authored-by: Martin Leitner-Ankerl <martin.ankerl@gmail.com>
2023-03-21 13:04:21 +00:00
Hennadii Stepanov
9a0b524139
clang-tidy, test: Fix bugprone-use-after-move in Correct_Queue_range() 2023-03-21 13:04:12 +00:00
Hennadii Stepanov
04831fee6d
refactor: Make move semantics explicit for callers 2023-03-21 13:04:01 +00:00
Hennadii Stepanov
6c2d5972f3
refactor: Use move semantics in CCheckQueue::Add
Co-authored-by: Martin Leitner-Ankerl <martin.ankerl@gmail.com>
2023-03-21 13:03:41 +00:00
Hennadii Stepanov
0682003214
test, refactor: Avoid CScriptCheck::swap in transaction_tests 2023-03-21 13:03:30 +00:00
Hennadii Stepanov
15209d97c6
consensus, refactor: Avoid CScriptCheck::swap in CheckInputScripts 2023-03-21 13:03:16 +00:00
MarcoFalke
fa67b8181c
Refactor: Remove unused FlatFilePos::SetNull 2023-03-21 13:54:11 +01:00
MarcoFalke
fa0696e786
test: Replace threading with concurrent.futures 2023-03-21 09:49:39 +01:00
James O'Beirne
2c3a90f663 log: on new valid header 2023-03-20 13:05:55 -04:00
Andrew Chow
f4e42a78c7
Merge bitcoin/bitcoin#27179: guix: use osslsigncode 2.5
285edfadca guix: use osslsigncode 2.5 (fanquake)

Pull request description:

  Switches to using a newer version of [osslsigncode](https://github.com/mtrojnar/osslsigncode) in our Guix environment.

  achow101 can you test this with some sort of WIndows code-signing dry-run (no-rush).

ACKs for top commit:
  achow101:
    ACK 285edfadca

Tree-SHA512: 2ab8f65e506bd97e74e76f24e791ae20694e567a751cc57d3a27f31f0733e3530d058ef19825a35dc21d1342e3fffc52d8d643258198c669cc68b6db41bda629
2023-03-20 12:50:11 -04:00
Andrew Chow
b7edd55c22
Merge bitcoin/bitcoin#26899: p2p: set -dnsseed and -listen false if maxconnections=0
fabb95e7bf doc: add release note for 26899 (brunoerg)
c84c5f6e89 p2p: set `-dnsseed` and `-listen` false if `maxconnections=0` (brunoerg)

Pull request description:

  If `maxconnections=0`, it means our possible connections are going to be manual (e.g via `addnode`). For this reason, we can skip DNS seeds and set `listen` false.

ACKs for top commit:
  achow101:
    ACK fabb95e7bf
  vasild:
    ACK fabb95e7bf
  1440000bytes:
    reACK fabb95e7bf

Tree-SHA512: 33919a784723a32450f39ee4f6de3e27cc7c7f4c6ab4b8ce673981d461df334197deaf43e3f882039fa1ac36b2fddc6c6ab4413512d6c393d4a6865302dd05e7
2023-03-20 12:49:10 -04:00
Andrew Chow
60f142e395
Merge bitcoin/bitcoin#26531: mempool: Add mempool tracepoints
4b7aec2951 Add mempool tracepoints (virtu)

Pull request description:

  This PR adds multiple mempool tracepoints.

  | tracepoint  | description |
  | ------------- | ------------- |
  | `mempool:added`  | Is called when a transaction enters the mempool  |
  | `mempool:removed`  | ... when a transaction is removed from the mempool |
  | `mempool:replaced`  | ... when a transaction is replaced in the mempool |
  | `mempool:rejected`  | ... when a transaction is rejected from entering the mempool |

  The tracepoints are further documented in `docs/tracing.md`. Usage is demonstrated in the example script `contrib/tracing/mempool_monitor.py`. Interface tests are provided in `test/functional/interface_usdt_mempool.py`.

  The rationale for passing the removal reason as a string instead of numerically is that the benefits of not having to maintain a redundant enum-string mapping seem to outweigh the small cost of string generation. The reject reason is passed as string as well, although in this instance the string does not have to be generated but is readily available.

ACKs for top commit:
  0xB10C:
    ACK 4b7aec2951
  achow101:
    ACK 4b7aec2951

Tree-SHA512: 6deb3ba2d1a061292fb9b0f885f7a5c4d11b109b838102d8a8f4828cd68f5cd03fa3fc64adc6fdf54a08a1eaccce261b0aa90c2b8c33cd5fd3828c8f74978958
2023-03-20 12:42:24 -04:00
virtu
4b7aec2951 Add mempool tracepoints
Tracepoints for added, removed, replaced, and rejected transactions.

The removal reason is passed as string instead of a numeric value, since
the benefits of not having to maintain a redundant enum-string mapping
seem to outweigh the small cost of string generation.  The reject reason
is passed as string as well, although here the string does not have to
be generated but is readily available.

So far, tracepoint PRs typically included two demo scripts: a naive
bpftrace script to show raw tracepoint data and a bcc script for a more
refined view. However, as some of the ongoing changes to bpftrace
introduce a certain degree of unreliability (running some of the
existing bpftrace scripts was not possible with standard kernels and
bpftrace packages on latest stable Ubuntu, Debian, and NixOS), this PR
includes only a single bcc script that fuses the functionality of former
bpftrace and bcc scripts.
2023-03-20 15:57:31 +01:00
James O'Beirne
e5ce857634 log: net: new header over cmpctblock 2023-03-20 08:32:40 -04:00
Bushstar
1869310f3c
refactor: remove unused param from legacy pubkey 2023-03-20 11:41:52 +00:00
MarcoFalke
33337eb860
test: Fix TypeError in wait_for_debug_log
Traceback:

print_log = " - " + "\n - ".join(log.splitlines())
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: sequence item 0: expected str instance, bytes found
2023-03-20 11:54:06 +01:00
dergoegge
cc5cdf8776 [net] Deduplicate marking received message for processing 2023-03-19 14:34:37 +01:00