Commit graph

6830 commits

Author SHA1 Message Date
Sjors Provoost
bfc4e029d4
Remove testBlockValidity() from mining interface
It's very low level and not used by the proposed Template Provider.

This method was introduced in d8a3496b5a
and a74b0f93ef.
2024-12-18 09:18:21 +07:00
merge-script
785486a975
Merge bitcoin/bitcoin#31489: fuzz: Fix test_runner error reporting
fa0e30b93a fuzz: Fix test_runner error reporting (MarcoFalke)

Pull request description:

  The error reporting is confusing, because right now it prints:

  https://cirrus-ci.com/task/4846031060336640?logs=ci#L4931

  ```
  ...
  Traceback (most recent call last):
    File "/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu/test/fuzz/test_runner.py", line 411, in <module>
      main()
    File "/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu/test/fuzz/test_runner.py", line 199, in main
      run_once(
    File "/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu/test/fuzz/test_runner.py", line 376, in run_once
      assert len(done_stat) == 1
             ^^^^^^^^^^^^^^^^^^^
  AssertionError
  ```

  This is harmless, but confusing.

  Fix it by collecting statistics only when the program has not aborted. (Can be reviewed with `--color-moved=dimmed-zebra`)

  Also, reword the error message to align it with error messages in other test_runners in this repo.

ACKs for top commit:
  dergoegge:
    utACK fa0e30b93a
  brunoerg:
    code review ACK fa0e30b93a
  marcofleon:
    Tested ACK fa0e30b93a. Prints out the error for the target that crashed. Much clearer than the current error message.

Tree-SHA512: 5e8d3fc0e4837b3264ff0c3cb322fe7fe2ec7af48d35e2a14f82080d03ace793963c3314611b0a170a38e200497d7ba703d9c35c9a7ed3272d93e43f0f0e4c2b
2024-12-17 11:07:51 +00:00
Ava Chow
b042c4f053
Merge bitcoin/bitcoin#31223: net, init: derive default onion port if a user specified a -port
Some checks failed
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Has been cancelled
CI / test each commit (push) Has been cancelled
CI / macOS 14 native, arm64, fuzz (push) Has been cancelled
CI / Win64 native, VS 2022 (push) Has been cancelled
CI / Win64 native fuzz, VS 2022 (push) Has been cancelled
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Has been cancelled
1dd3af8fbc Add release note for #31223 (Martin Zumsande)
997757dd2b test: add functional test for -port behavior (Martin Zumsande)
0e2b12b92a net, init: derive default onion port if a user specified a -port (Martin Zumsande)

Pull request description:

  This resolves #31133 (setups with multiple local nodes each using a different `-port` no longer working with v28.0, see the issue description for more details) by deriving the default onion listening port to be the value specified by `-port` incremented by 1 (idea by vasild / laanwj).
  Note that with this fix, the chosen `-port` values of two local nodes cannot be adjacent, otherwise there will be port collisions again.

  From the discussion in the linked issue, this was the most popular option, followed by doing nothing and telling affected users to change their setups to use `-bind` instead of `-port`. But more opinions are certainly welcome!

  I think that if we decide to do something about the problem described in the issue, we should do so soon (in 28.1.), so I opened this PR.
  Fixes #31133

ACKs for top commit:
  achow101:
    ACK 1dd3af8fbc
  laanwj:
    Tested ACK 1dd3af8fbc
  tdb3:
    Code review ACK 1dd3af8fbc

Tree-SHA512: 37fda2b23bbedcab5df3a401cf5afce66ae5318fb78f9660f83e3fd075b528e8156d7a0903f9a12ffe97ab5d83860587116b74af28670a1f4c2f0d1be4999f40
2024-12-13 18:56:37 -05:00
MarcoFalke
fa0e30b93a
fuzz: Fix test_runner error reporting 2024-12-13 14:34:36 +01:00
merge-script
d5ab5a47f0
Merge bitcoin/bitcoin#31452: wallet: Migrate non-HD keys to combo() descriptor
62b2d23edb wallet: Migrate non-HD keys to combo() descriptor (Ava Chow)

Pull request description:

  Non-HD keys do not have an HD seed ID associated with them, so if this value is the null value (all 0s), then we should not perform any seed ID comparison that would result in excluding the keys from combo() migration.

  This changes the migration of non-HD wallets (or blank wallets with imported private keys) to make a single combo() descriptors for the non-HD/imported keys, rather than pk(), pkh(), sh(wpkh()), and wpkh() descriptors for the keys.

  Implements https://github.com/bitcoin/bitcoin/pull/31374#discussion_r1876650074

ACKs for top commit:
  laanwj:
    Concept and code review ACK 62b2d23edb
  brunoerg:
    code review ACK 62b2d23edb
  furszy:
    Nice catch. ACK 62b2d23edb
  theStack:
    ACK 62b2d23edb
  rkrux:
    tACK 62b2d23edb

Tree-SHA512: 86a80b7dcc1598ab18068a2572ff4b4920b233178b760f7b76c5b21a9e6608005ac872f90e082a8f99b51daab0b049e73e4bee5b8e0b537d56ed0d34122a1f49
2024-12-13 10:43:43 +00:00
Hodlinator
e2d3372e55
lint: Disable signature output in git log
Necessary for users that have signature output enabled by default, since the script would stumble on them and error out.
2024-12-12 10:28:22 +01:00
Ryan Ofsky
676936845b
Merge bitcoin/bitcoin#30933: test: Prove+document ConstevalFormatString/tinyformat parity
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
c93bf0e6e2 test: Add missing %c character test (Hodlinator)
76cca4aa6f test: Document non-parity between tinyformat and ConstevalFormatstring (Hodlinator)
533013cba2 test: Prove+document ConstevalFormatString/tinyformat parity (Hodlinator)
b81a465995 refactor test: Profit from using namespace + using detail function (Hodlinator)

Pull request description:

  Clarifies and puts the extent of parity under test.

  Broken out from #30546 based on https://github.com/bitcoin/bitcoin/pull/30546#discussion_r1755013263 and https://github.com/bitcoin/bitcoin/pull/30546#discussion_r1756495304.

ACKs for top commit:
  maflcko:
    re-ACK c93bf0e6e2 🗜
  l0rinc:
    ACK c93bf0e6e2
  ryanofsky:
    Code review ACK c93bf0e6e2. Just a few cleanups tweaking function declarations and commit comments and consolidating some test cases since last review.

Tree-SHA512: 5ecc893b26cf2761c0009861be392ec4c4fceb0ef95052a2f6f9df76b2e459cfb3f9e257f61be07c3bb2ecc6e525e72c5ca853be1f63b70b52785323d3db6b42
2024-12-10 22:05:03 -05:00
Ava Chow
8ad2c90274
Merge bitcoin/bitcoin#31343: test: avoid internet traffic in rpc_net.py
988721d37a test: avoid internet traffic in rpc_net.py (Sebastian Falbesoner)

Pull request description:

  In order to avoid connecting to the internet in the functional test `rpc_net.py`, specify a non-working proxy (parameter `-proxy=127.0.0.1:1`, same approach as in #31142) for the nodes.  There is at least one known instance where this is currently happening on master where a connection attempt to a public IP is made (see also the discussion in #31339):

  17834bd197/test/functional/rpc_net.py (L253)

  Can be tested by running
  ```
  $ sudo tcpdump -i eth0 host 11.22.33.44
  ```
  both on master and the PR branch and verifying that no packets appear in the tcpdump in the latter anymore.

ACKs for top commit:
  achow101:
    ACK 988721d37a
  tdb3:
    ACK 988721d37a
  vasild:
    ACK 988721d37a

Tree-SHA512: 0f51fedccbfac0f80a7e6f9c5ba9193d0c20b5a788553c7cd7e583225df7b1151b86cd848d6ccf61f7b2de848f0ac98d73d7b5db100aa54fe8cbeeb4c0549106
2024-12-10 21:00:07 -05:00
Ava Chow
a582ee681c
Merge bitcoin/bitcoin#29982: test: Fix intermittent issue in wallet_backwards_compatibility.py
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
ec777917d6 test: Fix intermittent issue in wallet_backwards_compatibility.py (Randall Naar)

Pull request description:

  When creating and replacing a transaction using `bumpfee`, an async update is sent in the form of the `TransactionAddedToMempool` and `TransactionRemovedFromMempool` signals. When `wallet_backwards_compatibility.py` creates `tx3_id` this way and replaces it with `tx4_id`, the `abandontransaction` rpc is called right after. In some cases the `TransactionAddedToMempool` and `TransactionRemovedFromMempool` is handled after the transaction is abandoned in the wallet, and overwrites the transaction's `abandoned` flag. This PR forces the signals to get handled before `abandontransaction` is called by invoking `self.sync_mempools` which calls `syncwithvalidationinterfacequeue` on every node's rpc connection.

  This will mitigate the immediate inconsistency observed with the abandontransaction call, but the potential race conditions between the signals and wallet operations may also be useful to note in a separate issue (if it's okay to not address it in this one).

  Fixes #29806

ACKs for top commit:
  achow101:
    ACK ec777917d6
  tdb3:
    ACK ec777917d6

Tree-SHA512: e75bc2c1f7fefc4f4910bb353654848fed5661c1436416798a5f4e0c5a76bde15617a5af04c2384464005953326317b8f273039e47508d5124677908cf36d31e
2024-12-10 16:29:06 -05:00
Ava Chow
62b2d23edb wallet: Migrate non-HD keys to combo() descriptor
Non-HD keys in legacy wallets without a HD seed ID were being migrated
to separate pk(), pkh(), sh(wpkh()), and wpkh() descriptors for each key.
These could be more compactly represented as combo() descriptors, so
migration should make combo() for them.

It is possible that existing non-HD wallets that were migrated, or
wallets that started blank and had private keys imported into them have
run into this issue. However, as the 4 descriptors produce the same output
scripts as the single combo(), so any previously migrated wallets are
not missing any output scripts. The only observable difference should be
performance related, and the wallet size on disk.
2024-12-09 15:25:57 -05:00
Ava Chow
9039d8f1a1
Merge bitcoin/bitcoin#31374: wallet: fix crash during watch-only wallet migration
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
cdd207c0e4 test: add coverage for migrating standalone imported keys (furszy)
297a876c98 test: add coverage for migrating watch-only script (furszy)
932cd1e92b wallet: fix crash during watch-only wallet migration (furszy)

Pull request description:

  The crash occurs because we assume the cached scripts structure will not be empty,
  but it can be empty for watch-only wallets that start blank.

  This also adds test coverage for standalone imported keys, which were also crashing
  because pubkey imports are treated the same way as hex script imports through
  `importaddress()`.

  Testing Notes:
  This can be verified by cherry-picking and running any of the test commits on master.
  It will crash there but pass on this branch.

ACKs for top commit:
  theStack:
    re-ACK cdd207c0e4
  brunoerg:
    reACK cdd207c0e4
  achow101:
    ACK cdd207c0e4

Tree-SHA512: e05c77cf3e9f35f10f122a73680b3f131f683c56685c1e26b5ffc857f95195b64c8c9d4535960ed3d6f931935aa79b0b1242537462006126bdb68251f0452954
2024-12-09 15:12:34 -05:00
merge-script
35000e34cf
Merge bitcoin/bitcoin#31433: test: #31212 follow up (spelling, refactor)
Some checks are pending
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
41d934c72d chore: Typo Overriden -> Overridden (Hodlinator)
c9fb38a590 refactor test: Cleaner combine_logs.py logic (Hodlinator)

Pull request description:

  - Fixes typo caught by spelling linter (https://github.com/bitcoin/bitcoin/runs/33979284676).
  - Minor but nice refactoring of *combine_logs.py* change that was suggested late: https://github.com/bitcoin/bitcoin/pull/31212#discussion_r1869307947

ACKs for top commit:
  l0rinc:
    ACK 41d934c72d
  maflcko:
    lgtm ACK 41d934c72d
  theStack:
    ACK 41d934c72d
  BrandonOdiwuor:
    Code Review ACK 41d934c72d
  tdb3:
    ACK 41d934c72d

Tree-SHA512: cf8ecc070d0b01df9c4e57a75820e17d4535591e85bf9d271c7b8f60875f7e04b9978c56e9b88c10e89e69ff755c35b23ed291949c32c875a91c3317105a3c79
2024-12-08 16:33:31 +00:00
Hodlinator
76cca4aa6f
test: Document non-parity between tinyformat and ConstevalFormatstring
- For "%n", which is supposed to write to the argument for printf.
- For string/integer mismatches of width/precision specifiers.

Co-Authored-By: Ryan Ofsky <ryan@ofsky.org>
2024-12-06 21:56:16 +01:00
furszy
cdd207c0e4
test: add coverage for migrating standalone imported keys 2024-12-06 14:13:09 -05:00
furszy
297a876c98
test: add coverage for migrating watch-only script 2024-12-06 14:13:09 -05:00
Hodlinator
41d934c72d
chore: Typo Overriden -> Overridden 2024-12-06 15:34:37 +01:00
Hodlinator
c9fb38a590
refactor test: Cleaner combine_logs.py logic 2024-12-06 15:34:37 +01:00
glozow
b1f0f3c288
Merge bitcoin/bitcoin#31406: test: fix test_invalid_tx_in_compactblock in p2p_compactblocks
7239ddb7ce test: make sure node has all transactions (brunoerg)
ee1b9bef00 test: replace `is not` to `!=` when comparing block hash (brunoerg)

Pull request description:

  `test_invalid_tx_in_compactblock` tests that we don't get disconnected if we relay a compact block with valid header, but invalid transactions.

  In this test, after sending the block with invalid transactions, this test checks two things: the tip in the receiver node did not advance and the sender did not get disconnected. However, even if the block contains only valid transactions, the tip would not advance because the receiver does not have all transactions to reconstruct the valid and would request them back. This PR fixes it by sending all the transactions.

  Also, comparing block hash (int) using `is not` can lead to subtle bugs, this PR fixes it by replacing it to `!=`.

  --------------

  Can be tested by applying:
  ```diff
  diff --git a/test/functional/p2p_compactblocks.py b/test/functional/p2p_compactblocks.py
  index 274ef9532c..419153a32f 100755
  --- a/test/functional/p2p_compactblocks.py
  +++ b/test/functional/p2p_compactblocks.py
  @@ -723,11 +723,8 @@ class CompactBlocksTest(BitcoinTestFramework):
           utxo = self.utxos[0]

           block = self.build_block_with_transactions(node, utxo, 5)
  -        del block.vtx[3]
           block.hashMerkleRoot = block.calc_merkle_root()
           # Drop the coinbase witness but include the witness commitment.
  -        add_witness_commitment(block)
  -        block.vtx[0].wit.vtxinwit = []
           block.solve()

           # Make sure node has the transactions to reconstruct the block
  ```

ACKs for top commit:
  instagibbs:
    ACK 7239ddb7ce
  glozow:
    ACK 7239ddb7ce
  lucasbalieiro:
    Tested ACK for commit [7239ddb](7239ddb7ce)

Tree-SHA512: 6d04fb7c50b5e635c83ede75c12130cbd8e1b229887a86a2e1bfe747e4208731faecc7265cae063c1ace187b20c5f37080d5116760766fa2948f38971e5f6fbf
2024-12-06 06:29:52 -05:00
merge-script
1a35447595
Merge bitcoin/bitcoin#31417: test: Avoid F541 (f-string without any placeholders)
fae76393bd test: Avoid F541 (f-string without any placeholders) (MarcoFalke)

Pull request description:

  An extra `f` string-prefix is mostly harmless, but could be confusing or hint to a mistake where a format argument was forgotten.

  Try to avoid the confusion and mistakes by applying the `F541` linter rule.

ACKs for top commit:
  lucasbalieiro:
    **Tested ACK** [fae7639](fae76393bd)
  danielabrozzoni:
    ACK fae76393bd
  tdb3:
    Code review ACK fae76393bd

Tree-SHA512: 4992a74fcf0c19b32e4d95f7333e087b4269b5c5259c556789fb86721617db81c7a4fe210ae136c92824976f07f71ad0f374655e7008b1967c02c73324862d9a
2024-12-06 10:26:58 +00:00
Ryan Ofsky
2eccb8bc5e
Merge bitcoin/bitcoin#31248: test: Rework wallet_migration.py to use previous releases
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
55347a5018 test: Rework migratewallet to use previous release (v28.0) (Ava Chow)
f42ec0f3bf wallet: Check specified wallet exists before migration (Ava Chow)

Pull request description:

  This PR reworks wallet_migration.py to use previous releases to produce legacy wallets for testing so that the test will continue to work once legacy wallets are removed.

  Split from #28710

ACKs for top commit:
  maflcko:
    re-ACK 55347a5018 🥊
  rkrux:
    re-ACK 55347a5

Tree-SHA512: f90a2f475febc73d29e8ad3cb20d134c368a40a3b5934c3e4aaa77ae704af6314d4dd2e85c261142bd60a201902ac4ba00b8e2443d3cef7c8cc45d23281fa831
2024-12-05 15:47:43 -05:00
brunoerg
7239ddb7ce test: make sure node has all transactions 2024-12-05 16:12:38 -03:00
merge-script
6d973f86f7
Merge bitcoin/bitcoin#31408: test: Avoid logging error when logging error
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
cccca8a77f test: Avoid logging error when logging error (MarcoFalke)

Pull request description:

  Currently a logging error in the form of `--- Logging error ---` happens when an error is logged in the `_on_data` helper.

  Fix it by properly logging the error.

  Also, treat pylint errors as errors, to avoid this problem in the future.

  Can be tested by running `p2p_addrv2_relay.py` with the following example diff:

  ```diff
  diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py
  index 523e1bd068..0f1eb29d13 100755
  --- a/test/functional/test_framework/p2p.py
  +++ b/test/functional/test_framework/p2p.py
  @@ -137,7 +137,7 @@ MESSAGEMAP = {
       b"notfound": msg_notfound,
       b"ping": msg_ping,
       b"pong": msg_pong,
  -    b"sendaddrv2": msg_sendaddrv2,
  +    #b"sendaddrv2": msg_sendaddrv2,
       b"sendcmpct": msg_sendcmpct,
       b"sendheaders": msg_sendheaders,
       b"sendtxrcncl": msg_sendtxrcncl,

ACKs for top commit:
  fanquake:
    ACK cccca8a77f

Tree-SHA512: dd19f3feed0093246cb205903529fb9ebd5ad9a6c9330cfc5987c0154253c9dcec8d0e25ff99e4ac806a464ff58c3787a205378b8dfb7a1a521da25eac429136
2024-12-05 17:17:39 +00:00
merge-script
6a1e613e85
Merge bitcoin/bitcoin#31427: lint: bump MLC to v0.19.0
f6afca46a1 lint: use clearer wording on error message (willcl-ark)
811a65d3c6 lint: bump MLC to v0.19.0 (willcl-ark)

Pull request description:

  Fixes: #31044

  This MLC update includes a change which will ignore files being ignored by git, and help avoid false-positives when linting in this repo.

Top commit has no ACKs.

Tree-SHA512: d3edd0125f719c7a4456f7089e298dc851352a082b8119bbd8d642de518bb193827af9994ba416dd18a6a6f1359ee96122d95a31232da1623c679db39b370370
2024-12-05 16:34:06 +00:00
glozow
083770adbe
Merge bitcoin/bitcoin#31414: test: orphan parent is re-requested from 2nd peer
0f84cdd266 func: test orphan parent is re-requested from 2nd peer (Greg Sanders)

Pull request description:

  Small test which I couldn't find coverage for.

ACKs for top commit:
  glozow:
    lgtm ACK 0f84cdd266
  tdb3:
    code review ACK 0f84cdd266
  theStack:
    ACK 0f84cdd266
  marcofleon:
    tACK 0f84cdd266. Removing `node.bumpmocktime(GETDATA_TX_INTERVAL)` results in failure.

Tree-SHA512: fe8cb9d56aabc8f2ef1f49b6cd4e87e28a51ada8070c698f60c5fd945a28d849f0c5793f2e3e29f013e610168b860e0bf1c0aa010eec5b339688269d2b9e69af
2024-12-05 07:48:58 -05:00
willcl-ark
f6afca46a1
lint: use clearer wording on error message 2024-12-05 11:26:27 +00:00
willcl-ark
811a65d3c6
lint: bump MLC to v0.19.0
Fixes: #31044

This MLC update includes a change which will ignore files being ignored
by git, and help avoid false-positives when linting in this repo.
2024-12-05 11:24:48 +00:00
MarcoFalke
fae76393bd
test: Avoid F541 (f-string without any placeholders) 2024-12-05 08:39:09 +01:00
Ava Chow
11f68cc810
Merge bitcoin/bitcoin#31212: util: Improve documentation and negation of args
95a0104f2e test: Add tests for directories in place of config files (Hodlinator)
e85abe92c7 args: Catch directories in place of config files (Hodlinator)
e4b6b1822c test: Add tests for -noconf (Hodlinator)
483f0dacc4 args: Properly support -noconf (Hodlinator)
312ec64cc0 test refactor: feature_config_args.py - Stop nodes at the end of tests, not at the beginning (Hodlinator)
7402658bc2 test: -norpccookiefile (Hodlinator)
39cbd4f37c args: Support -norpccookiefile for bitcoind and bitcoin-cli (Hodlinator)
e82ad88452 logs: Use correct path and more appropriate macros in cookie-related code (Hodlinator)
6e28c76907 test: Harden testing of cookie file existence (Hodlinator)
75bacabb55 test: combine_logs.py - Output debug.log paths on error (Hodlinator)
bffd92f00f args: Support -nopid (Hodlinator)
12f8d848fd args: Disallow -nodatadir (Hodlinator)
6ff9662760 scripted-diff: Avoid printing version information for -noversion (Hodlinator)
e8a2054edc doc args: Document narrow scope of -color (Hodlinator)

Pull request description:

  - Document `-color` as only applying to `-getinfo`, to be less confusing for bitcoin-cli users.
  - No longer print version information when getting passed `-noversion`.
  - Disallow `-nodatadir` as we cannot run without one. It was previously interpreted as a mix of unset and as a relative path of "0".
  - Support `-norpccookiefile`
  - Support `-nopid`
  - Properly support `-noconf` (instead of working by accident). Also detect when directories are specified instead of files.

  Prompted by investigation in https://github.com/bitcoin/bitcoin/pull/16545#pullrequestreview-2316714013.

ACKs for top commit:
  l0rinc:
    utACK 95a0104f2e
  achow101:
    ACK 95a0104f2e
  ryanofsky:
    Code review ACK 95a0104f2e. Looks good! Thanks for all your work on this breaking the changes down and making them simple.

Tree-SHA512: 5174251e6b9196a9c6d135eddcb94130295c551bcfccc78e633d9e118ff91523b1be0d72828fb49603ceae312e6e1f8ee2651c6a2b9e0f195603a73a9a622785
2024-12-04 13:20:46 -05:00
merge-script
893ccea7e4
Merge bitcoin/bitcoin#31419: test: fix MIN macro redefinition
00c1dbd26d test: fix MIN macro-redefinition (0xb10c)

Pull request description:

  Renames the `MIN` macro to `_TRACEPOINT_TEST_MIN`.

  From #31418:

  ```
  stderr:
  /virtual/main.c:70:9: warning: 'MIN' macro redefined [-Wmacro-redefined]
     70 | #define MIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
        |         ^
  include/linux/minmax.h:329:9: note: previous definition is here
    329 | #define MIN(a,b) __cmp(min,a,b)
        |         ^
  1 warning generated.
  ```

  fixes: https://github.com/bitcoin/bitcoin/issues/31418

ACKs for top commit:
  maflcko:
    review ACK 00c1dbd26d

Tree-SHA512: 1d91ed8b3c0b0410d42a11004286359546c17613c3ff03dd51c26896ee050e9280fff69fa2eaa6e6085f9b611663bcacedec80997a6c5e37874a79ba86bfa507
2024-12-04 17:13:00 +00:00
Ryan Ofsky
39950e148d
Merge bitcoin/bitcoin#31295: refactor: Prepare compile-time check of bilingual format strings
fa3e074304 refactor: Tidy fixups (MarcoFalke)
fa72646f2b move-only: Detail_CheckNumFormatSpecifiers and G_TRANSLATION_FUN (MarcoFalke)
faff8403f0 refactor: Pick translated string after format (MarcoFalke)

Pull request description:

  The changes are required for https://github.com/bitcoin/bitcoin/pull/31061, however they also make sense on their own. For example, they are fixing up an `inline namespace`, which lead to compile errors otherwise (can be tested by observing the compile error after reverting the changes to `src/util/strencodings.h`). Also, a unit test comment is fixed.

ACKs for top commit:
  ryanofsky:
    Code review ACK fa3e074304. Nice changes! These should allow related PRs to be simpler.
  l0rinc:
    ACK fa3e074304
  hodlinator:
    cr-ACK fa3e074304

Tree-SHA512: 37371181a348610442186b5fbb7a6032d0caf70aae566002ad60be329a3131a2b89f28f6c51e10872079f987986925dc8c0611bde639057bee4f572d2b9ba92a
2024-12-04 11:15:58 -05:00
0xb10c
00c1dbd26d
test: fix MIN macro-redefinition
Renames the `MIN` macro to `_TRACEPOINT_TEST_MIN`.

From #31418:

```
stderr:
/virtual/main.c:70:9: warning: 'MIN' macro redefined [-Wmacro-redefined]
   70 | #define MIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
      |         ^
include/linux/minmax.h:329:9: note: previous definition is here
  329 | #define MIN(a,b) __cmp(min,a,b)
      |         ^
1 warning generated.
```

fixes: https://github.com/bitcoin/bitcoin/issues/31418
2024-12-04 15:51:17 +01:00
merge-script
ae69fc37e4
Merge bitcoin/bitcoin#31391: util: Drop boost posix_time in ParseISO8601DateTime
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
faf70cc994 Remove wallet::ParseISO8601DateTime, use ParseISO8601DateTime instead (MarcoFalke)
2222aecd5f util: Implement ParseISO8601DateTime based on C++20 (MarcoFalke)

Pull request description:

  `boost::posix_time` in `ParseISO8601DateTime` has many issues:

  * It parses random strings that are clearly invalid and returns a time value for them, see [1] below.
  * None of the separators `-`, or `:`, or `T`, or `Z` are validated.
  * It may crash when running under a hardened C++ library, see https://github.com/bitcoin/bitcoin/issues/28917.
  * It has been unmaintained for years, so reporting or fixing any issues will most likely be useless.
  * It pulls in a third-party dependency, when the functionality is already included in vanilla C++20.

  Fix all issues by replacing it with a simple helper function written in C++20.

  Fixes https://github.com/bitcoin/bitcoin/issues/28917.

  [1] The following patch passes on current master:

  ```diff
  diff --git a/src/wallet/test/rpc_util_tests.cpp b/src/wallet/test/rpc_util_tests.cpp
  index 32f6f5ab46..c1c94c7116 100644
  --- a/src/wallet/test/rpc_util_tests.cpp
  +++ b/src/wallet/test/rpc_util_tests.cpp
  @@ -12,6 +12,14 @@ BOOST_AUTO_TEST_SUITE(wallet_util_tests)

   BOOST_AUTO_TEST_CASE(util_ParseISO8601DateTime)
   {
  +    BOOST_CHECK_EQUAL(ParseISO8601DateTime("964296"), 242118028800);
  +    BOOST_CHECK_EQUAL(ParseISO8601DateTime("244622"), 15023836800);
  +    BOOST_CHECK_EQUAL(ParseISO8601DateTime("+INfINITy"), 9223372036854);
  +    BOOST_CHECK_EQUAL(ParseISO8601DateTime("7000802 01"), 158734166400);
  +    BOOST_CHECK_EQUAL(ParseISO8601DateTime("7469-2 +INfINITy"), 9223372036854);
  +    BOOST_CHECK_EQUAL(ParseISO8601DateTime("maXimum-datE-time"), 253402300799);
  +    BOOST_CHECK_EQUAL(ParseISO8601DateTime("577737     114maXimum-datE-time"), 253402300799);
  +
       BOOST_CHECK_EQUAL(ParseISO8601DateTime("1970-01-01T00:00:00Z"), 0);
       BOOST_CHECK_EQUAL(ParseISO8601DateTime("1960-01-01T00:00:00Z"), 0);
       BOOST_CHECK_EQUAL(ParseISO8601DateTime("2000-01-01T00:00:01Z"), 946684801);
  ```

ACKs for top commit:
  hebasto:
    ACK faf70cc994, I have reviewed the code and it looks OK.
  dergoegge:
    utACK faf70cc994

Tree-SHA512: 9dd745a356d04acf6200e13a6af52c51a9e2a0eeccea110093ce5da147b3c669c0eda918e46db0164c081a78c8feae3fe557a4759bea18449a8ff2d090095931
2024-12-04 11:21:43 +00:00
Ava Chow
c9a7418a8d
Merge bitcoin/bitcoin#31096: Package validation: accept packages of size 1
32fc59796f rpc: Allow single transaction through submitpackage (glozow)

Pull request description:

  There's no particular reason to restrict single transaction submissions with submitpackage. This change relaxes the RPC checks as enables the `AcceptPackage` flow to accept packages of a single transaction.

  Resolves #31085

ACKs for top commit:
  naumenkogs:
    ACK 32fc59796f
  achow101:
    ACK 32fc59796f
  glozow:
    ACK 32fc59796f

Tree-SHA512: ffed353bfdca610ffcfd53b40b76da05ffc26df6bac4b0421492e067bede930380e03399d2e2d1d17f0e88fb91cd8eb376e3aabebbabcc724590bf068d09807c
2024-12-03 17:46:23 -05:00
Ava Chow
6f24662eb9
Merge bitcoin/bitcoin#31175: rpc: Remove submitblock pre-checks
73db95c65c kernel: Make bitcoin-chainstate's block validation mirror submitblock's (TheCharlatan)
bb53ce9bda tests: Add functional test for submitting a previously pruned block (Greg Sanders)
1f7fc73825 rpc: Remove submitblock duplicate pre-check (TheCharlatan)
e62a8abd7d rpc: Remove submitblock invalid-duplicate precheck (TheCharlatan)
36dbebafb9 rpc: Remove submitblock coinbase pre-check (TheCharlatan)

Pull request description:

  With the introduction of a mining ipc interface and the potential future introduction of a kernel library API it becomes increasingly important to offer common behaviour between them. An example of this is ProcessNewBlock, which is used by ipc, rpc, net_processing and (potentially) the kernel library. Having divergent behaviour on suggested pre-checks and checks for these functions is confusing to both developers and users and is a maintenance burden.

  The rpc interface for ProcessNewBlock (submitblock) currently pre-checks if the block has a coinbase transaction and whether it has been processed before. While the current example binary for how to use the kernel library, bitcoin-chainstate, imitates these checks, the other interfaces do not.

  The coinbase check is repeated again early during ProcessNewBlock. Pre-checking it may also shadow more fundamental problems with a block. In most cases the block header is checked first, before validating the transactions. Checking the coinbase first therefore masks potential issues with the header. Fix this by removing the pre-check.

  Similary the duplicate checks are repeated early in the contextual checks of ProcessNewBlock. If duplicate blocks are detected much of their validation is skipped. Depending on the constitution of the block, validating the merkle root of the block is part of the more intensive workload when validating a block. This could be an argument for moving the pre-checks into block processing. In net_processing this would have a smaller effect however, since the block mutation check, which also validates the merkle root, is done before.

  Testing spamming a node with valid, but duplicate unrequested blocks seems to exhaust a CPU thread, but does not seem to significantly impact keeping up with the tip. The benefits of adding these checks to net_processing are questionable, especially since there are other ways to trigger the more CPU-intensive checks without submitting a duplicate block. Since these DOS concerns apply even less to the RPC interface, which does not have banning mechanics built in, remove them too.

  Finally, also remove the pre-checks from `bitcoin-chainstate.cpp`.

  ---

  This PR is part of the [libbitcoinkernel project](https://github.com/bitcoin/bitcoin/issues/27587).

ACKs for top commit:
  Sjors:
    re-utACK 73db95c65c
  achow101:
    ACK 73db95c65c
  instagibbs:
    ACK 73db95c65c
  mzumsande:
    ACK 73db95c65c

Tree-SHA512: 2d02e851cf402ecf6a1968c058df3576aac407e200cbf922a1a6391b7f97b4f42c6d9f6b0a78b9d1af0a6d40bdd529a7b11a1e6d88885bd7b8b090f6d1411861
2024-12-03 17:38:41 -05:00
Greg Sanders
0f84cdd266 func: test orphan parent is re-requested from 2nd peer 2024-12-03 11:12:49 -05:00
Hodlinator
95a0104f2e
test: Add tests for directories in place of config files 2024-12-03 11:04:10 +01:00
Hodlinator
e4b6b1822c
test: Add tests for -noconf 2024-12-03 11:04:10 +01:00
Hodlinator
312ec64cc0
test refactor: feature_config_args.py - Stop nodes at the end of tests, not at the beginning
This ensures we don't needlessly start the node, and reduces implicit dependencies between test functions.

test_seed_peers() - Move assert calling RPC to verify correct chain after our own function actually started the node.
2024-12-03 10:42:41 +01:00
Hodlinator
7402658bc2
test: -norpccookiefile
Both bitcoind and bitcoin-cli.
2024-12-03 10:38:21 +01:00
Hodlinator
6e28c76907
test: Harden testing of cookie file existence 2024-12-03 10:38:21 +01:00
Hodlinator
75bacabb55
test: combine_logs.py - Output debug.log paths on error 2024-12-03 10:38:20 +01:00
MarcoFalke
cccca8a77f
test: Avoid logging error when logging error 2024-12-03 09:40:18 +01:00
brunoerg
ee1b9bef00 test: replace is not to != when comparing block hash 2024-12-02 18:38:30 -03:00
Pieter Wuille
492e1f0994 [validation] merge all ConnectBlock debug logging code paths 2024-12-02 16:25:17 -05:00
Pieter Wuille
146a3d5426 [validation] Make script error messages uniform for parallel/single validation
This makes the debug output mostly the same for -par=1 and parallel validation runs. Of course,
parallel validation is non-deterministic in what error it may encounter first if there are
multiple issues. Also, the way certain script-related and non-script-related checks are
performed differs between the two modes still, which may result in discrepancies.
2024-12-02 16:25:17 -05:00
Ryan Ofsky
ebe4cac38b
Merge bitcoin/bitcoin#30991: test: enable running independent functional test sub-tests
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
409d0d6293 test: enable running individual independent functional test methods (ismaelsadeeq)

Pull request description:

  - Some test methods in the functional test framework are independent and do not require any prior context or setup in `run_test`.
  - This commit adds a new option for running these specific methods within a test file, allowing them to be executed individually without running the entire test suite.
  - Using this option reduces the time you need to wait before the test you are interested in starts executing.
  - The functionality added by this PR can be achieved manually by commenting out code, but having a pragmatic option to do this is more convenient.

  Note: Running test methods that require arguments or context will fail.

  **Example Usage**:
  ```zsh
  build/test/functional/feature_reindex.py --test_methods continue_reindex_after_shutdown
  ```

  ```zsh
  build/test/functional/feature_config_args.py --test_methods test_log_buffer test_args_log test_connect_with_seednode
  ```

ACKs for top commit:
  maflcko:
    review ACK 409d0d6293
  rkrux:
    reACK 409d0d6293
  ryanofsky:
    Code review ACK 409d0d6293. This seems like a good step towards making it easy to run independent tests quickly. I think ideally there would be some naming convention or @ annotation added to test methods that can run independently, so the test framework could provide more functionality like being able to list test methods, being able to show command lines to quickly reproduce problems when tests fails, and calling test methods automatically instead of requiring individual tests to call them. But these ideas are all compatible with the new `--test_methods` option

Tree-SHA512: b0daac7c3b322e6fd9b946962335d8279e8cb004ff76f502c8d597b9c4b0073840945be198a79d44c5aaa64bda421429829d5c84ceeb8c6139eb6ed079a35878
2024-12-02 11:45:32 -05:00
MarcoFalke
faf70cc994
Remove wallet::ParseISO8601DateTime, use ParseISO8601DateTime instead 2024-12-02 15:09:31 +01:00
merge-script
e043618d44
Merge bitcoin/bitcoin#31396: test: simple reordering to reduce run time
62f6d9e1a4 test: simple ordering optimization to reduce runtime (tdb3)

Pull request description:

  Noticed in #31371 that the position of `mempool_ephemeral_dust` within `BASE_SCRIPTS` was lengthening total test runtime. Instead of moving only that test, looked for others to move to reduce runtime.

  This is a quick optimization that was found to reduce overall functional test runtime of up to around 20% (depending on jobs and machine characteristics). Since it seems like test ordering could be done in many different ways, with many variables, and bike shedding could creep in, a relatively straightforward approach was taken for now that minimized changes to test_runner.

ACKs for top commit:
  maflcko:
    lgtm ACK 62f6d9e1a4
  TheCharlatan:
    ACK 62f6d9e1a4

Tree-SHA512: 6f93fbe4de3fce202383d9f84aa0e96961af3de3c02b8cab73589339d701f32c5e1b57a191eeebf4b06b5cd7a82617f63f24110732940be1a5a4d9237813a570
2024-12-02 14:08:58 +00:00
merge-script
eb646111cd
Merge bitcoin/bitcoin#31383: test: Add missing node.setmocktime(self.mocktime) to p2p_ibd_stalling.py
faa16ed4b9 test: Add missing node.setmocktime(self.mocktime) to p2p_ibd_stalling.py (MarcoFalke)

Pull request description:

  This was forgotten by myself in commit fa5b58ea01.

  This time, there is a diff to test, which fails on current master and passes with this pull request.

  ```diff
  diff --git a/src/net_processing.cpp b/src/net_processing.cpp
  index e503a68382..16438ebd08 100644
  --- a/src/net_processing.cpp
  +++ b/src/net_processing.cpp
  @@ -112,9 +112,9 @@ static_assert(MAX_BLOCKTXN_DEPTH <= MIN_BLOCKS_TO_KEEP, "MAX_BLOCKTXN_DEPTH too
    *  want to make this a per-peer adaptive value at some point. */
   static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024;
   /** Block download timeout base, expressed in multiples of the block interval (i.e. 10 min) */
  -static constexpr double BLOCK_DOWNLOAD_TIMEOUT_BASE = 1;
  +static constexpr double BLOCK_DOWNLOAD_TIMEOUT_BASE = .05; // 30 sec
   /** Additional block download timeout per parallel downloading peer (i.e. 5 min) */
  -static constexpr double BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 0.5;
  +static constexpr double BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 0.;
   /** Maximum number of headers to announce when relaying blocks with headers message.*/
   static const unsigned int MAX_BLOCKS_TO_ANNOUNCE = 8;
   /** Minimum blocks required to signal NODE_NETWORK_LIMITED */
  diff --git a/test/functional/p2p_ibd_stalling.py b/test/functional/p2p_ibd_stalling.py
  index fa07873929..f8cdd8998c 100755
  --- a/test/functional/p2p_ibd_stalling.py
  +++ b/test/functional/p2p_ibd_stalling.py
  @@ -82,6 +82,7 @@ class P2PIBDStallingTest(BitcoinTestFramework):
           # Need to wait until 1023 blocks are received - the magic total bytes number is a workaround in lack of an rpc
           # returning the number of downloaded (but not connected) blocks.
           bytes_recv = 172761 if not self.options.v2transport else 169692
  +        time.sleep(31);
           self.wait_until(lambda: self.total_bytes_recv_for_blocks() == bytes_recv)

           self.all_sync_send_with_ping(peers)

ACKs for top commit:
  brunoerg:
    ACK faa16ed4b9

Tree-SHA512: 5a670e2dcf828ac83b721a3e20d897744cca50080b0583a8460a0d0c7bf2c2c988cf7e35f688dde6a3349f1c21cc83a16ea5242ed06a59d59a04130416690737
2024-12-02 13:34:18 +00:00
tdb3
62f6d9e1a4
test: simple ordering optimization to reduce runtime 2024-11-30 12:31:16 -05:00