Commit graph

41350 commits

Author SHA1 Message Date
Lőrinc
c3a8843189 Use SCRIPT_VERIFY_NONE instead of hard-coded 0 in transaction_tests 2024-06-18 19:43:33 +02:00
Ava Chow
41544b8f96
Merge bitcoin/bitcoin#28984: Cluster size 2 package rbf
94ed4fbf8e Add release note for size 2 package rbf (Greg Sanders)
afd52d8e63 doc: update package RBF comment (Greg Sanders)
6e3c4394cf mempool: Improve logging of replaced transactions (Greg Sanders)
d3466e4cc5 CheckPackageMempoolAcceptResult: Check package rbf invariants (Greg Sanders)
316d7b63c9 Fuzz: pass mempool to CheckPackageMempoolAcceptResult (Greg Sanders)
4d15bcf448 [test] package rbf (glozow)
dc21f61c72 [policy] package rbf (Suhas Daftuar)
5da3967815 PackageV3Checks: Relax assumptions (Greg Sanders)

Pull request description:

  Allows any 2 transaction package with no in-mempool ancestors to do package RBF when directly conflicting with other mempool clusters of size two or less.

  Proposed validation steps:
  1) If the transaction package is of size 1, legacy rbf rules apply.
  2) Otherwise the transaction package consists of a (parent, child) pair with no other in-mempool ancestors (or descendants, obviously), so it is also going to create a cluster of size 2. If larger, fail.
  3) The package rbf may not evict more than 100 transactions from the mempool(bip125 rule 5)
  4) The package is a single chunk
  5) Every directly conflicted mempool transaction is connected to at most 1 other in-mempool transaction (ie the cluster size of the conflict is at most 2).
  6) Diagram check: We ensure that the replacement is strictly superior, improving the mempool
  7) The total fee of the package, minus the total fee of what is being evicted, is at least the minrelayfee * size of the package (equivalent to bip125 rule 3 and 4)

  Post-cluster mempool this will likely be expanded to general package rbf, but this is what we can safely support today.

ACKs for top commit:
  achow101:
    ACK 94ed4fbf8e
  glozow:
    reACK 94ed4fbf8e via range-diff
  ismaelsadeeq:
    re-ACK 94ed4fbf8e
  theStack:
    Code-review ACK 94ed4fbf8e
  murchandamus:
    utACK 94ed4fbf8e

Tree-SHA512: 9bd383e695964f362f147482bbf73b1e77c4d792bda2e91d7f30d74b3540a09146a5528baf86854a113005581e8c75f04737302517b7d5124296bd7a151e3992
2024-06-17 17:22:43 -04:00
Ava Chow
ddf2ebd465
Merge bitcoin/bitcoin#30058: Encapsulate warnings in generalized node::Warnings and remove globals
260f8da71a refactor: remove warnings globals (stickies-v)
9c4b0b7ce4 node: update uiInterface whenever warnings updated (stickies-v)
b071ad9770 introduce and use the generalized `node::Warnings` interface (stickies-v)
20e616f864 move-only: move warnings from common to node (stickies-v)
bed29c481a refactor: remove unnecessary AppendWarning helper function (stickies-v)

Pull request description:

  This PR:
  - moves warnings from common to the node library and into the node namespace (as suggested in https://github.com/bitcoin/bitcoin/pull/29845#discussion_r1570069541)
  - generalizes the warnings interface to `Warnings::Set()` and `Warnings::Unset()` methods, instead of having a separate function and globals for each warning. As a result, this simplifies the `kernel::Notifications` interface.
  - removes warnings.cpp from the kernel library
  - removes warning globals
  - adds testing for the warning logic

  Behaviour change introduced:
  - the `-alertnotify` command is executed for all `KernelNotifications::warningSet` calls, which now also covers the `LARGE_WORK_INVALID_CHAIN` warning
  - the GUI is updated automatically whenever a warning is (un)set, covering some code paths where it previously wouldn't be, e.g. when `node::AbortNode()` is called, or for the `LARGE_WORK_INVALID_CHAIN` warning

  Some discussion points:
  - ~is `const std::string& id` the best way to refer to warnings? Enums are an obvious alternative, but since we need to define warnings across libraries, strings seem like a straightforward solution.~ _edit: updated approach to use `node::Warning` and `kernel::Warning` enums._

ACKs for top commit:
  achow101:
    ACK 260f8da71a
  ryanofsky:
    Code review ACK 260f8da71a. Only change since last review was rebasing
  TheCharlatan:
    Re-ACK 260f8da71a

Tree-SHA512: a3fcedaee0d3ad64e9c111aeb30665162f98e0e72acd6a70b76ff2ddf4f0a34da4f97ce353c322a1668ca6ee4d8a81cc6e6d170c5bbeb7a43cffdaf66646b588
2024-06-17 17:09:18 -04:00
Ava Chow
d97ddbe797
Merge bitcoin/bitcoin#30193: ci: move ASan job to GitHub Actions from Cirrus CI
9eea51d905 ci: move Asan / LSan / USDT job to Github Actions (Max Edwards)
4b527fa93b ci: add IPV6 network to ci container (Max Edwards)

Pull request description:

  PR for moving the ASAN + LSAN + USDT + friends job to github actions from Cirrus.

  The motivation for this PR is that this task needs a full VM (or bare metal) to function, because of the tracepoints. It can not run in a container on an arbitrary Linux, because the outside machine must exactly match the specification of the distro used in the CI task config. This requires more maintenance for the persistent worker, and I think moving to GHA will reduce the maintenance burden, or at least make it possible for anyone to work on.

  Also, it makes it easier to run the task on forks (bitcoin-inquisition, bitcoin-knots, devel forks, ...) without having to set-up a real machine.

ACKs for top commit:
  maflcko:
    review ACK 9eea51d905
  achow101:
    ACK 9eea51d905
  hebasto:
    ACK 9eea51d905.

Tree-SHA512: 1111c1c9e3a11e725dff1344643fff3c91fb9b4d7c1cc9a7d507a8f146f5223316a00272030b41ae37ecb59d044f2e90e1cd907450049b25f094f0b60643d4c7
2024-06-17 15:49:43 -04:00
Ava Chow
f011022d53
Merge bitcoin/bitcoin#30195: test: Added test coverage to listsinceblock rpc
881724d443 test: Added test coverage to listsinceblock rpc (kevkevinpal)

Pull request description:

  This change is meant to add test coverage to this rpc error https://github.com/bitcoin/bitcoin/blob/master/src/wallet/rpc/transactions.cpp#L666C53-L666C79

  This is done by renaming the first block in the blocks folder

  ---

  Doing a quick grep for the error code in our functional tests leads to zero results
  `grep -nri "Can't read block from disk" ./test/functional/`

ACKs for top commit:
  achow101:
    ACK 881724d443
  tdb3:
    re ACK for 881724d443
  rkrux:
    tACK [881724](881724d443)

Tree-SHA512: c5dff20cf014d0181f49d6b161f1364e1c6b79e8661047f77f07e21e59f4d1f2fd6f745538c8fc5bd6d4244650a840dd64d184634366f7c21fa67141a60af44a
2024-06-17 15:35:49 -04:00
Ava Chow
4bcef32a93
Merge bitcoin/bitcoin#28312: test: fix keys_to_multisig_script (P2MS) helper for n/k > 16
5cf0a1f230 test: add `createmultisig` P2MS encoding test for all n (1..20) (Sebastian Falbesoner)
0570d2c204 test: add unit test for `keys_to_multisig_script` (Sebastian Falbesoner)
0c41fc3fa5 test: fix `keys_to_multisig_script` (P2MS) helper for n/k > 16 (Sebastian Falbesoner)

Pull request description:

  While reviewing #28307, I noticed that the test framework's `key_to_multisig_script` helper (introduced in #23305) is broken for pubkey count (n) and threshold (k) values larger than 16. This is due to the implementation currently enforcing a direct single-byte data push (using `CScriptOp.encode_op_n`), which obviously fails for values 17+. Fix that by passing the numbers directly to the CScript list, where it's automatically converted to minimally-encoded pushes (see class method `CScript.__coerce_instance`, branch `isinstance(other, int)`).

  The second commit adds a unit test to ensure that the encoding  is correct.

ACKs for top commit:
  achow101:
    ACK 5cf0a1f230
  tdb3:
    ACK 5cf0a1f230
  rkrux:
    reACK [5cf0a1f](5cf0a1f230)

Tree-SHA512: 4168a165c3f483ec8e37a27dba1628a7ea0063545a2b7e74d9e20d753fddd7e33d37e1a190434fa6dca39adf9eef5d0211f7a0c1c7b44979f0a3bb350e267562
2024-06-17 15:18:08 -04:00
Ava Chow
808898fddf
Merge bitcoin/bitcoin#30291: test: write functional test results to csv
ad06e68399 test: write functional test results to csv (tdb3)

Pull request description:

  Adds argument `--resultsfile` to test_runner.py.
  Enables functional test results to be written to a (csv) file for processing by other applications (or for historical archiving).
  Test name, status, and duration are written to the file provided with the argument.

  Since `test_runner.py` is being touched, also fixes a misspelling (linter warning).   Can split into its own commit if desired.

  #### Notes
   - Total runtime of functional tests has seemed to have increased on my development machines over the past few months (more tests added, individual test runtime increase, etc.).  Was interested in recording test runtime data over time to detect trends.  Initially searched `doc/benchmarking.md`, existing PRs, and Issues, but didn't immediately see this type of capability or alternate solutions (please chime in if you know of one!).  Thought it would be beneficial to add this capability to `test_runner` to facilitate this type of data analysis (and potentially other use cases)
   - Saw https://github.com/bitcoin/bitcoin/blob/master/test/functional/README.md#benchmarking-with-perf, and this PR's higher level data seems complimentary.
   - Was on the fence as to whether to expand `print_results()` (i.e. take advantage of the same loop over `test_results`) or implement in a separate `write_results()` function.  Decided on the latter for now, but interested in reviewers' thoughts.

  #### Example 1: all tests pass
  ```
  $ test/functional/test_runner.py --resultsfile functional_test_results.csv --cachedir=/mnt/tmp/cache --tmpdir=/mnt/tmp feature_blocksdir wallet_startup feature_config_args mempool_accept
  Temporary test directory at /mnt/tmp/test_runner_₿_🏃_20240614_201625
  Test results will be written to functional_test_results.csv
  ...

  $ cat functional_test_results.csv
  test,status,duration(seconds)
  feature_blocksdir.py,Passed,1
  feature_config_args.py,Passed,29
  mempool_accept.py,Passed,9
  wallet_startup.py,Passed,2
  ALL,Passed,29
  ```

  #### Example 2: one test failure
  ```
  $ cat functional_test_results.csv
  test,status,duration(seconds)
  feature_blocksdir.py,Passed,1
  feature_config_args.py,Passed,28
  wallet_startup.py,Passed,2
  mempool_accept.py,Failed,1
  ALL,Failed,28
  ```

ACKs for top commit:
  maflcko:
    re-ACK ad06e68399
  kevkevinpal:
    tACK [ad06e68](ad06e68399)
  achow101:
    ACK ad06e68399
  rkrux:
    tACK [ad06e68](ad06e68399)
  brunoerg:
    ACK ad06e68399
  marcofleon:
    Good idea, tested ACK ad06e68399

Tree-SHA512: 561194406cc744905518aa5ac6850c07c4aaecdaf5d4d8b250671b6e90093d4fc458f050e8a85374e66359cc0e0eaceba5eb24092c55f0d8f349d744a32ef76c
2024-06-17 14:54:08 -04:00
tdb3
ad06e68399
test: write functional test results to csv
Adds argument --resultsfile to test_runner.py.
Writes comma-separated functional test name, status,
and duration to the file provided with the argument.
Also fixes minor typo in test_runner.py
2024-06-16 22:51:12 -04:00
kevkevinpal
881724d443
test: Added test coverage to listsinceblock rpc
This change adds a test to add coverage to the rpc error that emmits the message "Can't
read block from disk"
2024-06-16 13:30:56 -04:00
Ava Chow
2c79abc7ad
Merge bitcoin/bitcoin#27969: bumpfee: ignore WALLET_INCREMENTAL_RELAY_FEE when user specifies fee_rate
f58beabe75 test: bumpfee with user specified fee_rate ignores walletIncrementalRelayFee (ismaelsadeeq)
436e88f433 bumpfee: ignore WALLET_INCREMENTAL_RELAY_FEE when user specifies fee rate (ismaelsadeeq)

Pull request description:

  Fixes #26973

  When using the `bumpfee` RPC and manually specifying `fee_rate`, there should be no requirement that the new fee must be at least the sum of the original fee and `incrementalFee` (maximum of `relayIncrementalFee` and `WALLET_INCREMENTAL_RELAY_FEE`).

  This restriction should only apply when user did not specify `fee_rate`.
  > because the GUI doesn't let the user specify the new fee rate yet (https://github.com/bitcoin-core/gui/issues/647), it would be very annoying to have to bump 20 times to increment by 20 sat/vbyte.

  The restriction should instead be the new fee must be at least the sum of the original fee and `incrementalFee` (`relayIncrementalFee`)

ACKs for top commit:
  achow101:
    ACK f58beabe75
  murchandamus:
    ACK f58beabe75

Tree-SHA512: 193259f87173b7d5a8e68e0e29f2ca7e75c550e3cf0dee3d6d822b5b1e07c2e6dec0bfc8fb435855736ebced97a10dbdbfef72e8c5abde06fdefcba122f2e7f1
2024-06-14 14:46:04 -04:00
Ava Chow
538497ba27
Merge bitcoin/bitcoin#30255: log: use error level for critical log messages
fae3a1f006 log: use error level for critical log messages (MarcoFalke)

Pull request description:

  This picks up the first commit from https://github.com/bitcoin/bitcoin/pull/29231, but extends it to also cover cases that were missed in it.

  As per https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#logging, LogError should be used for severe problems that require the node to shut down.

ACKs for top commit:
  stickies-v:
    re-ACK fae3a1f006, I'm ~0 on the latest force push as `user_error` was already logged at the right level through `GetNotifications().fatalError(user_error);` so I'd be in favour of deduplicating/cleaning up this logging logic but can be done in follow-up.
  kevkevinpal:
    ACK [fae3a1f](fae3a1f006)
  achow101:
    ACK fae3a1f006

Tree-SHA512: 3f99fd25d5a204d570a42d8fb2b450439aad7685692f9594cc813d97253c4df172a6ff3cf818959bfcf25dfcf8ee9a9c9ccc6028fcfcecdb47591e18c77ef246
2024-06-14 14:34:48 -04:00
merge-script
0b94fb8720
Merge bitcoin/bitcoin#30281: Update leveldb subtree to latest upstream
a37778d4d3 Squashed 'src/leveldb/' changes from e2f10b4e47..688561cba8 (fanquake)

Pull request description:

  Includes https://github.com/bitcoin-core/leveldb-subtree/pull/41 which is used in #30234.

ACKs for top commit:
  theuni:
    utACK 95812d912b

Tree-SHA512: 3d943695a3d33816cf5558b183f5629aa92a500a1544eecedf84952e93c8592a8cf0d554b88281fc0bad3c9e920ebcff1ed8edc12f8e73f36ed5335482beb829
2024-06-14 11:26:02 +01:00
merge-script
54c5f67c38
Merge bitcoin/bitcoin#30276: doc: archive release notes for v27.1
e71a21b641 doc: archive release notes for v27.1 (fanquake)

Pull request description:

ACKs for top commit:
  benalleng:
    ACK for e71a21b

Tree-SHA512: a89231d09b442e5e1755135a475030648a81bb0c331eec8d9c7a27a633f64fd0449dcfe8939c0d43cc5133ad0ab85acda7de757594986f9c93fe6f90efc11a02
2024-06-14 11:17:12 +01:00
merge-script
8efc346e3b
Merge bitcoin/bitcoin#30278: test: cover more errors for signrawtransactionwithkey RPC
e2779ce98b test: cover more errors for `signrawtransactionwithkey` RPC (brunoerg)

Pull request description:

  This PR adds test coverage for the following errors for the `signrawtransactionwithkey` RPC:

  - Invalid private key
  - TX decode failed

  For reference: https://maflcko.github.io/b-c-cov/total.coverage/src/rpc/rawtransaction.cpp.gcov.html

ACKs for top commit:
  maflcko:
    ACK e2779ce98b
  kevkevinpal:
    ACK [e2779ce](e2779ce98b)
  tdb3:
    ACK e2779ce98b
  BrandonOdiwuor:
    Code Review ACK e2779ce98b

Tree-SHA512: 41c7e990684b60645cf4ccec8aad5ebbe61da221871eb3c1685b2bb1eebda58b29358502cb1525b7c7a2b612e2bebf449ed0bae14ab663b4641c528a9c013b5b
2024-06-14 09:42:20 +01:00
Ava Chow
fcc3b653dc
Merge bitcoin/bitcoin#29607: refactor: Reduce memory copying operations in bech32 encoding
07f64177a4 Reduce memory copying operations in bech32 encode (Lőrinc)
d5ece3c4b5 Reserve hrp memory in Decode and LocateErrors (Lőrinc)

Pull request description:

  Started optimizing the base conversions in [TryParseHex](https://github.com/bitcoin/bitcoin/pull/29458), [Base58](https://github.com/bitcoin/bitcoin/pull/29473) and [IsSpace](https://github.com/bitcoin/bitcoin/pull/29602) - this is the next step.

  Part of this change was already merged in https://github.com/bitcoin/bitcoin/pull/30047, which made decoding `~26%` faster.

  Here I've reduced the memory reallocations and copying operations in bech32 encode, making it `~15%` faster.

  >  make && ./src/bench/bench_bitcoin --filter='Bech32Encode' --min-time=1000

  Before:
  ```
  |             ns/byte |              byte/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |               19.97 |       50,074,562.72 |    0.1% |      1.06 | `Bech32Encode`
  ```

  After:
  ```
  |             ns/byte |              byte/s |    err% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------:|:----------
  |               17.33 |       57,687,668.20 |    0.1% |      1.10 | `Bech32Encode`
  ```

ACKs for top commit:
  josibake:
    ACK 07f64177a4
  sipa:
    utACK 07f64177a4
  achow101:
    ACK 07f64177a4

Tree-SHA512: 511885217d044ad7ef2bdf9203b8e0b94eec8b279bc193bb7e63e29ab868df6d21e9e4c7a24390358e1f9c131447ee42039df72edcf1e2b11e1856eb2b3e10dd
2024-06-13 12:18:49 -04:00
Greg Sanders
94ed4fbf8e Add release note for size 2 package rbf 2024-06-13 09:52:59 -04:00
Greg Sanders
afd52d8e63 doc: update package RBF comment 2024-06-13 09:52:59 -04:00
Greg Sanders
6e3c4394cf mempool: Improve logging of replaced transactions 2024-06-13 09:52:59 -04:00
Greg Sanders
d3466e4cc5 CheckPackageMempoolAcceptResult: Check package rbf invariants 2024-06-13 09:52:59 -04:00
Greg Sanders
316d7b63c9 Fuzz: pass mempool to CheckPackageMempoolAcceptResult 2024-06-13 09:52:59 -04:00
glozow
4d15bcf448 [test] package rbf 2024-06-13 09:52:59 -04:00
Suhas Daftuar
dc21f61c72 [policy] package rbf
Support package RBF where the conflicting package would result
in a mempool cluster of size two, and each of its direct
conflicts are also part of an up-to-size-2 mempool cluster.

This restricted topology allows for exact calculation
of miner scores for each side of the equation, reducing
the surface area for new pins, or incentive-incompatible
replacements.

This allows wallets to create simple CPFP packages
that can fee bump other simple CPFP packages. This,
leveraged with other restrictions such as V3 transactions,
can create pin-resistant applications.

Future package RBF relaxations can be considered when appropriate.

Co-authored-by: glozow <gloriajzhao@gmail.com>
Co-authored-by: Greg Sanders <gsanders87@gmail.com>
2024-06-13 09:52:59 -04:00
fanquake
95812d912b
Update leveldb-subtree subtree to latest upstream 2024-06-13 13:17:57 +01:00
fanquake
a37778d4d3 Squashed 'src/leveldb/' changes from e2f10b4e47..688561cba8
688561cba8 Merge bitcoin-core/leveldb-subtree#41: Ignore clang's self-assignment check
7045a90ed7 Ignore clang's self-assignment check

git-subtree-dir: src/leveldb
git-subtree-split: 688561cba8746482893f835c4829e4eb4a5b7615
2024-06-13 13:17:57 +01:00
merge-script
080a47cb8a
Merge bitcoin/bitcoin#30270: Update minisketch subtree to eb37a9b8e79f9e49d73b96a49bf97a96d9eb676c
cb59af38e7 Squashed 'src/minisketch/' changes from 3472e2f5ec..eb37a9b8e7 (fanquake)

Pull request description:

  Includes https://github.com/sipa/minisketch/pull/87 which is used in https://github.com/bitcoin/bitcoin/pull/30234.
  Includes https://github.com/sipa/minisketch/pull/88 which is used in https://github.com/bitcoin/bitcoin/pull/29876.

ACKs for top commit:
  sipa:
    utACK 89464ad59c
  theuni:
    utACK 89464ad59c

Tree-SHA512: 838a8c60856bfdf714da7d5d97e31d458290849ba5007d5c5bb7abb83d413ada6b4c16e45b0e060ff892b5785e6b664be9b6a666d04f0a414b0e359d64d3ad44
2024-06-13 12:30:38 +01:00
stickies-v
260f8da71a
refactor: remove warnings globals 2024-06-13 11:20:49 +01:00
stickies-v
9c4b0b7ce4
node: update uiInterface whenever warnings updated
This commit introduces slight behaviour change. Previously, the
GUI status bar would be updated for most warnings, namely
UNKNOWN_NEW_RULES_ACTIVATED, CLOCK_OUT_OF_SYNC and
PRE_RELEASE_TEST_BUILD, but not for LARGE_WORK_INVALID_CHAIN
(and not for FATAL_INTERNAL_ERROR, but that is not really
meaningful).

Fix this by always updating the status bar when the warnings are
changed.
2024-06-13 11:20:48 +01:00
stickies-v
b071ad9770
introduce and use the generalized node::Warnings interface
Instead of having separate warning functions (and globals) for each
different warning that can be raised, encapsulate this logic into
a single class and allow to (un)set any number of warnings.

Introduces behaviour change:
- the `-alertnotify` command is executed for all
  `KernelNotifications::warningSet` calls, which now also covers the
  `LARGE_WORK_INVALID_CHAIN` warning.
- previously, warnings were returned based on a predetermined order,
  e.g. with the "pre-release test build" warning always first. This
  is no longer the case, and Warnings::GetMessages() will return
  messages sorted by the id of the warning.

Removes warnings.cpp from kernel.
2024-06-13 11:20:48 +01:00
stickies-v
20e616f864
move-only: move warnings from common to node
Since rpc/util.cpp is in common, also move GetNodeWarnings() to
node::GetWarningsForRPC()
2024-06-13 11:20:47 +01:00
stickies-v
bed29c481a
refactor: remove unnecessary AppendWarning helper function 2024-06-13 11:20:44 +01:00
Ava Chow
ff21eb2def
Merge bitcoin/bitcoin#30219: Lint: Support running individual lint checks
0fcbfdb7ad Support running individual lint checks (David Gumberg)

Pull request description:

  This PR was split out from  #29965:

  Adds support for running individual tests in the rust lint suite by passing `--lint=LINT_TO_RUN` to the lint runner. This PR also adds a corresponding help message.

  When running with `cargo run`, arguments after a double dash (`--`) are passed to the binary instead of the cargo command. For example, in order to run the linter check that tabs are not used as whitespace:

  ```console
  cd test/lint/test_runner && cargo run -- --lint=tabs_whitespace
  ```

ACKs for top commit:
  maflcko:
    ACK 0fcbfdb7ad
  achow101:
    ACK 0fcbfdb7ad
  marcofleon:
    Tested ACK 0fcbfdb7ad. Ran `cargo run` with various of the individual tests and with bad input. Also ran it with no arguments. Everything works as expected and help message looks good.

Tree-SHA512: 48fe4aa9fbb2acef5f8e3c17382ae22e0e350ae6ad9aeeb1a3c0a9192de98809f98728e32b8db24a36906ace999e35626ebd6cb2ca05f74146d21e9b6fb14615
2024-06-12 17:19:48 -04:00
Ava Chow
011a895a82
Merge bitcoin/bitcoin#29015: kernel: Streamline util library
c7376babd1 doc: Clarify distinction between util and common libraries in libraries.md (Ryan Ofsky)
4f74c59334 util: Move util/string.h functions to util namespace (Ryan Ofsky)
4d05d3f3b4 util: add TransactionError includes and namespace declarations (Ryan Ofsky)
680eafdc74 util: move fees.h and error.h to common/messages.h (Ryan Ofsky)
02e62c6c9a common: Add PSBTError enum (Ryan Ofsky)
0d44c44ae3 util: move error.h TransactionError enum to node/types.h (Ryan Ofsky)
9bcce2608d util: move spanparsing.h to script/parsing.h (Ryan Ofsky)
6dd2ad4792 util: move spanparsing.h Split functions to string.h (Ryan Ofsky)
23cc8ddff4 util: move HexStr and HexDigit from util to crypto (TheCharlatan)
6861f954f8 util: move util/message to common/signmessage (Ryan Ofsky)
cc5f29fbea build: move memory_cleanse from util to crypto (Ryan Ofsky)
5b9309420c build: move chainparamsbase from util to common (Ryan Ofsky)
ffa27af24d test: Add check-deps.sh script to check for unexpected library dependencies (Ryan Ofsky)

Pull request description:

  Remove `fees.h`, `errors.h`, and `spanparsing.h` from the util library. Specifically:

  - Move `Split` functions from `util/spanparsing.h` to `util/string.h`, using `util` namespace for clarity.
  - Move remaining spanparsing functions to `script/parsing.h` since they are used for descriptor and miniscript parsing.
  - Combine `util/fees.h` and `util/errors.h` into `common/messages.h` so there is a place for simple functions that generate user messages to live, and these functions are not part of the util library.

  Motivation for this change is that the util library is a dependency of the kernel, and we should remove functionality from util that shouldn't be called by kernel code or kernel applications. These changes should also improve code organization and make functions easier to discover. Some of these same moves are (or were) part of #28690, but did not help with code organization, or made it worse, so it is better to move them and clean them up in the same PR so code only has to change one time.

ACKs for top commit:
  achow101:
    ACK c7376babd1
  TheCharlatan:
    Re-ACK c7376babd1
  hebasto:
    re-ACK c7376babd1.

Tree-SHA512: 5bcef16c1255463b1b69270548711e7ff78ca0dd34e300b95e3ca1ce52ceb34f83d9ddb2839e83800ba36b200de30396e504bbb04fa02c6d0c24a16d06ae523d
2024-06-12 17:12:54 -04:00
brunoerg
e2779ce98b test: cover more errors for signrawtransactionwithkey RPC
* Invalid private key
* TX decode failed
2024-06-12 17:07:16 -03:00
merge-script
a7bc9b76e7
Merge bitcoin/bitcoin#30229: fuzz: Use std::span in FuzzBufferType
faa41e29d5 fuzz: Use std::span in FuzzBufferType (MarcoFalke)

Pull request description:

  The use of `Span` is problematic, because it lacks methods such as `rbegin`, leading to compile failures when used:

  ```
  error: no member named 'rbegin' in 'Span<const unsigned char>'
  ```

  One could fix `Span`, but it seems better to use `std::span`, given that `Span` will be removed anyway in the long term.

ACKs for top commit:
  dergoegge:
    utACK faa41e29d5

Tree-SHA512: 54bcaf51c83a1b48739cd7f1e8445c6eba0eb04231bce5c35591a47dddb3890ffcaf562cf932930443c80ab0e66950c4619560e6692240de0c52aeef3214facd
2024-06-12 18:16:07 +01:00
merge-script
d0cb5167d6
Merge bitcoin/bitcoin#30230: fuzz: add I2P harness
193c748e44 fuzz: add I2P harness (marcofleon)

Pull request description:

  Addresses https://github.com/bitcoin/bitcoin/issues/28803. This updated harness sets mock time at the beginning of each iteration and deletes the private key file at the end of each iteration. Mock time is used to make the fuzz test more stable, as `GetTime` is called at points in `i2p`. Deleting the private key file ensures that each iteration is independent from the last. Now, a new key is generated in `i2p` every time, so the fuzzer can eventually make progress through the target code.

  Re-working this harness also led me and dergoegge to resolve a couple of issues in `FuzzedSock`, which allows for full coverage of the `i2p` code. Those changes can be seen in https://github.com/bitcoin/bitcoin/pull/30211.

  The SAM protocol for interacting with I2P requires some specifc inputs so it's best to use a dictionary when running this harness.

  <details>
  <summary>I2P dict</summary>

  ```
  "HELLO VERSION"
  "HELLO REPLY RESULT=OK VERSION="
  "HELLO REPLY RESULT=NOVERSION"
  "HELLO REPLY RESULT=I2P_ERROR"
  "SESSION CREATE"
  "SESSION STATUS RESULT=OK DESTINATION="
  "SESSION STATUS RESULT=DUPLICATED_ID"
  "SESSION STATUS RESULT=DUPLICATED_DEST"
  "SESSION STATUS RESULT=INVALID_ID"
  "SESSION STATUS RESULT=INVALID_KEY"
  "SESSION STATUS RESULT=I2P_ERROR MESSAGE="
  "SESSION ADD"
  "SESSION REMOVE"
  "STREAM CONNECT"
  "STREAM STATUS RESULT=OK"
  "STREAM STATUS RESULT=INVALID_ID"
  "STREAM STATUS RESULT=INVALID_KEY"
  "STREAM STATUS RESULT=CANT_REACH_PEER"
  "STREAM STATUS RESULT=I2P_ERROR MESSAGE="
  "STREAM ACCEPT"
  "STREAM FORWARD"
  "DATAGRAM SEND"
  "RAW SEND"
  "DEST GENERATE"
  "DEST REPLY PUB= PRIV="
  "DEST REPLY RESULT=I2P_ERROR"
  "NAMING LOOKUP"
  "NAMING REPLY RESULT=OK NAME= VALUE="
  "DATAGRAM RECEIVED DESTINATION= SIZE="
  "RAW RECEIVED SIZE="
  "NAMING REPLY RESULT=INVALID_KEY NAME="
  "NAMING REPLY RESULT=KEY_NOT_FOUND NAME="
  "MIN"
  "MAX"
  "STYLE"
  "ID"
  "SILENT"
  "DESTINATION"
  "NAME"
  "SIGNATURE_TYPE"
  "CRYPTO_TYPE"
  "SIZE"
  "HOST"
  "PORT"
  "FROM_PORT"
  "TRANSIENT"
  "STREAM"
  "DATAGRAM"
  "RAW"
  "MASTER"
  "true"
  "false"
  ```

  </details>

  I'll add this dict to qa-assets later on.

ACKs for top commit:
  dergoegge:
    tACK 193c748e44
  brunoerg:
    ACK 193c748e44
  vasild:
    ACK 193c748e44

Tree-SHA512: 09ae4b3fa0738aa6f159f4d920493bdbce786b489bc8148e7a135a881e9dba93d727b40f5400c9510e218dd2cfdccc7ce2d3ac9450654fb29c78aac59af92ec3
2024-06-12 17:59:59 +01:00
fanquake
e71a21b641
doc: archive release notes for v27.1 2024-06-12 16:58:24 +01:00
fanquake
89464ad59c
Update minisketch subtree to latest master 2024-06-12 14:38:39 +01:00
fanquake
cb59af38e7 Squashed 'src/minisketch/' changes from 3472e2f5ec..eb37a9b8e7
eb37a9b8e7 Merge sipa/minisketch#87: Avoid copy in self-assign
fe6557642e Merge sipa/minisketch#88: build: Add `-Wundef`
8ea298bfa7 Avoid copy in self-assign
978a3d8869 build: Add `-Wundef`
3387044179 Merge sipa/minisketch#86: doc: fix typo in sketch_impl.h
15c2d13b60 doc: fix typo in sketch_impl.h
7be08b8a46 Merge sipa/minisketch#85: Fixes for integer precision loss
00fb4a4d83 Avoid or make integer precision conversion explicit
9d62a4d27c Avoid the need to cast/convert to size_t for vector operations
19e06cc7af Prevent overflows from large capacity/max_elements

git-subtree-dir: src/minisketch
git-subtree-split: eb37a9b8e79f9e49d73b96a49bf97a96d9eb676c
2024-06-12 14:38:39 +01:00
MarcoFalke
faa41e29d5
fuzz: Use std::span in FuzzBufferType 2024-06-12 15:21:31 +02:00
Max Edwards
9eea51d905 ci: move Asan / LSan / USDT job to Github Actions
Moving it from Cirrus CI so it can be easier to maintain and used by forks
2024-06-12 14:20:25 +01:00
glozow
aa6b876e01
Merge bitcoin/bitcoin#30268: util: add missing VecDeque include
f51da34ec1 utils: add missing include (Cory Fields)

Pull request description:

  Noticed when testing `VecDeque` with no other includes.

  For libc++, need type_traits for `std::is_trivially_destructible_v`.

ACKs for top commit:
  maflcko:
    ACK f51da34ec1
  glozow:
    ACK f51da34ec1
  sipa:
    utACK f51da34ec1

Tree-SHA512: bf96910abe9aaddd8586e6cc8f68a9bbac4c26d976ebeebcfa86b86c0da5783c1cbdbc7fa09b62cdcfde19e6442eb65a66bf1e2e80408d68e9dd9689dc22b0fa
2024-06-12 12:54:28 +01:00
merge-script
5ee6b76c69
Merge bitcoin/bitcoin#29325: consensus: Store transaction nVersion as uint32_t
429ec1aaaa refactor: Rename CTransaction::nVersion to version (Ava Chow)
27e70f1f5b consensus: Store transaction nVersion as uint32_t (Ava Chow)

Pull request description:

  Given that the use of a transaction's nVersion is always as an unsigned int, it doesn't make sense to store it as signed and then cast it to unsigned everywhere it is used and displayed.

  Since a few alternative implementations have recently been revealed to have made an error with this signedness that would have resulted in consensus failure, I think it makes sense for us to just make this always unsigned to make it clear that the version is treated as unsigned. This would also help us avoid future potential issues with signedness of this value.

  I believe that this is safe and does not actually change what transactions would or would not be considered both standard and consensus valid. Within consensus, the only use of the version in consensus is in BIP68 validation which was already casting it to uint32_t. Within policy, although it is used as a signed int for the transaction version number check, I do not think that this change would change standardness. Standard transactions are limited to the range [1, 2]. Negative numbers would have fallen under the < 1 condition, but by making it unsigned, they are still non-standard under the > 2 condition.

  Unsigned and signed ints are serialized and unserialized the same way so there is no change in serialization.

ACKs for top commit:
  maflcko:
    ACK 429ec1aaaa 🐿
  glozow:
    ACK 429ec1aaaa
  shaavan:
    ACK 429ec1aaaa 💯

Tree-SHA512: 0bcd92a245d7d16c3665d2d4e815a4ef28207ad4a1fb46c6f0203cdafeab1b82c4e95e4bdce7805d80a4f4a46074f6542abad708e970550d38a00d759e3dcef1
2024-06-12 10:32:31 +01:00
merge-script
416e26c1db
Merge bitcoin/bitcoin#30261: doc: add release note for 29091 and 29165
3d4ca62d88 doc: add release note for 29091 and 29165 (fanquake)

Pull request description:

  GCC 11.x or Clang 15.x are now required to compile Bitcoin Core.

ACKs for top commit:
  hebasto:
    ACK 3d4ca62d88.

Tree-SHA512: 6469a920ff9512897eeeb85d9c5538fd24884aabb20754d0f699f9975d81a320547de9e41758c242c4271bd45b7a76c363efe2ef703e156497e2c8cb9f3c14da
2024-06-12 10:23:28 +01:00
Ava Chow
91e0beede2
Merge bitcoin/bitcoin#30160: util: add BitSet
47f705b33f tests: add fuzz tests for BitSet (Pieter Wuille)
59a6df6bd5 util: add BitSet (Pieter Wuille)

Pull request description:

  Extracted from #30126.

  This introduces the `BitSet` data structure, inspired by `std::bitset`, but with a few features that cannot be implemented on top without efficiency loss:
  * Finding the first set bit (`First`)
  * Finding the last set bit (`Last`)
  * Iterating over all set bits (`begin` and `end`).

  And a few other operators/member functions that help readability for #30126:
  * `operator-` for set subtraction
  * `Overlaps()` for testing whether intersection is non-empty
  * `IsSupersetOf()` for testing (non-strict) supersetness
  * `IsSubsetOf()` for testing (non-strict) subsetness
  * `Fill()` to construct a set with all numbers from 0 to n-1, inclusive
  * `Singleton()` to construct a set with one specific element.

  Everything is tested through a simulation-based fuzz test that compares the behavior with normal `std::bitset` equivalent operations.

ACKs for top commit:
  instagibbs:
    ACK 47f705b33f
  achow101:
    ACK 47f705b33f
  cbergqvist:
    re-ACK 47f705b33f
  theStack:
    Code-review ACK 47f705b33f

Tree-SHA512: e451bf4b801f193239ee434b6b614f5a2ac7bb49c70af5aba24c2ac0c54acbef4672556800e4ac799ae835632bdba716209c5ca8c37433a6883dab4eb7cd67c1
2024-06-11 17:28:51 -04:00
Ava Chow
891e4bf374
Merge bitcoin/bitcoin#28339: validation: improve performance of CheckBlockIndex
5bc2077e8f validation: allow to specify frequency for -checkblockindex (Martin Zumsande)
d5a631b959 validation: improve performance of CheckBlockIndex (Martin Zumsande)
32c80413fd bench: add benchmark for checkblockindex (Martin Zumsande)

Pull request description:

  `CheckBlockIndex() ` are consistency checks that are currently enabled by default on regtest.

  The function is rather slow, which is annoying if you
  * attempt to run it on other networks, especially if not fully synced
  * want to generate a long chain on regtest and see block generation slow down because you forgot to disable `-checkblockindex` or don't know it existed.

  One reason why it's slow is that in order to be able to traverse the block tree depth-first from genesis, it inserts pointers to all block indices into a `std::multimap` - for which inserts and lookups become slow once there are hundred thousands of entries.
  However, typically the block index is mostly chain-like with just a few forks so a multimap isn't really needed for the most part. This PR suggests to store the block indices of the chain ending in the best header in a vector instead, and store only the rest of the indices in a multimap. This does not change the actual consistency checks that are being performed for each index, just the way the block index tree is stored and traversed.

  This adds a bit of complication to make sure each block is visited (note that there are asserts that check it), making sure that the two containers are traversed correctly, but it speeds up the function considerably:

  On master, a single invocation of `CheckBlockIndex` takes ~1.4s on mainnet for me (4.9s on testnet which has >2.4 million blocks).
  With this branch, the runtime goes down to ~0.27s (0.85s on testnet).This is a speedup by a factor ~5.

ACKs for top commit:
  achow101:
    ACK 5bc2077e8f
  furszy:
    ACK 5bc2077e8f
  ryanofsky:
    Code review ACK 5bc2077e8f. Just added suggested assert and simplification since last review

Tree-SHA512: 6b9c3e3e5069d6152b45a09040f962380d114851ff0f9ff1771cf8cad7bb4fa0ba25cd787ceaa3dfa5241fb249748e2ee6987af0ccb24b786a5301b2836f8487
2024-06-11 16:41:44 -04:00
Ava Chow
1bcc91a52c
Merge bitcoin/bitcoin#29521: cli: Detect port errors in rpcconnect and rpcport
24bc46c83b cli: Add warning for duplicate port definition (tdb3)
e208fb5d3b cli: Sanitize ports in rpcconnect and rpcport (tdb3)

Pull request description:

  Adds invalid port detection to bitcoin-cli for -rpcconnect and -rpcport.

  In addition to detecting malformed/invalid ports (e.g. those outside of the 16-bit port range, not numbers, etc.), bitcoin-cli also now considers usage of port 0 to be invalid.  bitcoin-cli previously considered port 0 to be valid and attempted to use it to reach bitcoind.

  Functional tests were added for invalid port detection as well as port prioritization.
  Additionally, a warning is provided when a port is specified in both -rpcconnect and -rpcport.

  This PR is an alternate approach to PR #27820 (e.g. SplitHostPort is unmodified).

  Considered an alternative to 127.0.0.1 being specified in functional tests, but at first glance, this might need an update to test_framework/util.py (e.g.  rpc_url), which might be left to a future PR.

ACKs for top commit:
  S3RK:
    light code review ACK 24bc46c83b
  achow101:
    ACK 24bc46c83b
  cbergqvist:
    re ACK 24bc46c83b

Tree-SHA512: c83ab6a30a08dd1ac8b368a7dcc2b4f23170f0b61dd67ffcad7bcda05096d333bcb9821fba11018151f55b2929c0a333bfec15b8bb863d83f41fc1974c6efca5
2024-06-11 15:55:18 -04:00
Ava Chow
2251460f3e
Merge bitcoin/bitcoin#28830: [refactor] Check CTxMemPool options in ctor
09ef322acc [[refactor]] Check CTxMemPool options in constructor (TheCharlatan)

Pull request description:

  The tests should run the same checks on the mempool options that the init code also applies. The downside to this patch is that the log line may now be printed more than once in the for loop.

  This was originally noticed here https://github.com/bitcoin/bitcoin/pull/25290#discussion_r900272797.

ACKs for top commit:
  stickies-v:
    re-ACK 09ef322acc . Fixed unreachable assert and updated docstring, and also added an exception for "-maxmempool must be at least " in the `tx_pool` fuzz test, which makes sense when looking at how the mempool options are constructed in `SetMempoolConstraints`.
  achow101:
    ACK 09ef322acc
  ryanofsky:
    Code review ACK 09ef322acc. Just fuzz test error checking fix and updated comment since last review

Tree-SHA512: eb3361411c2db70be17f912e3b14d9cb9c60fb0697a1eded952c3b7e8675b7d783780d45c52e091931d1d80fe0f0280cee98dd57a3100def13af20259d9d1b9e
2024-06-11 15:24:49 -04:00
Cory Fields
f51da34ec1 utils: add missing include
Noticed when testing VecDeque with no other includes.

For libc++, need type_traits for std::is_trivially_destructible_v.
2024-06-11 16:28:11 +00:00
merge-script
337f9d44c2
Merge bitcoin/bitcoin#30201: depends: remove FORCE_USE_SYSTEM_CLANG
7cbfd7a7ce refactor: rename (macho) ld64 to lld (fanquake)
d851451705 ci: update deps for macOS cross build (fanquake)
9ebdd5e9e0 depends: update install docs for macOS cross compilation (fanquake)
fb74fd66cb depends: remove no-longer used llvm_* vars from macOS build (fanquake)
9043f12425 depends: no-longer pass -B to clang in macOS cross-compile (fanquake)
f9994b025e depends: remove native LLVM package (fanquake)
e9a44faf14 depends: remove FORCE_USE_SYSTEM_CLANG (fanquake)
9946618f61 guix: use clang-toolchain-18 for macOS build (fanquake)

Pull request description:

  Remove `FORCE_USE_SYSTEM_CLANG` in favour of always using the system Clang and lld for macOS cross-compilation; rather than downloading precompiled blobs.

  For example, anyone using Ubuntu 24.04 should be able to `apt install clang llvm lld .. etc`, and then cross-compile for macOS using:
  ```bash
  # clang --version
  Ubuntu clang version 18.1.3 (1)
  make -C depends HOST=arm64-apple-darwin FORCE_USE_SYSTEM_CLANG=1
  ./autogen.sh
  CONFIG_SITE=/path/to/depends/arm64-apple-darwin/share/config.site ./configure
  make
  # file src/qt/bitcoin-qt
  src/qt/bitcoin-qt: Mach-O 64-bit arm64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE|HAS_TLV_DESCRIPTORS>
  ```

  Note that the minimum supported version of Clang we will support for macOS cross-compilation will likely be more recent than our other minimum supported version of Clang, due to compiler/linker option usage.

ACKs for top commit:
  Sjors:
    tACK 7cbfd7a7ce
  theuni:
    ACK 7cbfd7a7ce
  TheCharlatan:
    Nice, ACK 7cbfd7a7ce

Tree-SHA512: 1499e29b3b238c5c85278c38e8fb6bb5e7883db3443f62b6bf397c5d761bedbc054962be645a9defce15266f0a969bb4b3ccd28b6e4dd874472857b928f185d1
2024-06-11 16:40:43 +01:00
merge-script
5bc9b644a4
Merge bitcoin/bitcoin#30264: test: add coverage for errors for combinerawtransaction
ab98e6fd03 test: add coverage for errors for `combinerawtransaction` RPC (brunoerg)

Pull request description:

  This PR adds test coverage for the following errors for the `combinerawtransaction` RPC:

  * Tx decode failed
  * Missing transactions
  * Input not found or already spent

  For reference: https://maflcko.github.io/b-c-cov/total.coverage/src/rpc/rawtransaction.cpp.gcov.html

ACKs for top commit:
  maflcko:
    lgtm ACK ab98e6fd03
  tdb3:
    ACK ab98e6fd03

Tree-SHA512: 8a133c25dad2e1b236e0278a88796f60f763e3fd6fbbc080f926bb23f9dcc55599aa242d6e0c4ec15a179d9ded10a1f17ee5b6063719107ea84e6099f10416b2
2024-06-11 15:29:18 +01:00