43347 Commits

Author SHA1 Message Date
glozow
e810842acd [txorphanage] support multiple announcers
Add ability to add and track multiple announcers per orphan transaction,
erasing announcers but not the entire orphan.

The tx creation code in orphanage_tests needs to be updated so that each
tx is unique, because the CountOrphans() check assumes that calling
EraseForPeer necessarily means its orphans are deleted.

Unused for now.
2025-01-06 09:02:05 -05:00
glozow
62a9ff1870 [refactor] change type of unique_parents to Txid 2025-01-06 09:02:05 -05:00
glozow
6951ddcefd [txrequest] GetCandidatePeers
Needed for a later commit adding logic to ask the TxRequestTracker for a
list of announcers.  These announcers should know the parents of the
transaction they announced.
2025-01-06 09:02:05 -05:00
glozow
b1f0f3c288
Merge : test: fix test_invalid_tx_in_compactblock in p2p_compactblocks
7239ddb7cec38ab5a8aca93c18fb9efa6376421d test: make sure node has all transactions (brunoerg)
ee1b9bef000b7fb42a452faf06c6748a59ac02c7 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 7239ddb7cec38ab5a8aca93c18fb9efa6376421d
  glozow:
    ACK 7239ddb7cec38ab5a8aca93c18fb9efa6376421d
  lucasbalieiro:
    Tested ACK for commit [7239ddb](7239ddb7ce)

Tree-SHA512: 6d04fb7c50b5e635c83ede75c12130cbd8e1b229887a86a2e1bfe747e4208731faecc7265cae063c1ace187b20c5f37080d5116760766fa2948f38971e5f6fbf
2024-12-06 06:29:52 -05:00
merge-script
1a35447595
Merge : test: Avoid F541 (f-string without any placeholders)
fae76393bdbf867176e65447799d6ee3d3567b18 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 fae76393bdbf867176e65447799d6ee3d3567b18
  tdb3:
    Code review ACK fae76393bdbf867176e65447799d6ee3d3567b18

Tree-SHA512: 4992a74fcf0c19b32e4d95f7333e087b4269b5c5259c556789fb86721617db81c7a4fe210ae136c92824976f07f71ad0f374655e7008b1967c02c73324862d9a
2024-12-06 10:26:58 +00:00
merge-script
eb2ebe6f30
Merge : cmake: Fix IF_CHECK_PASSED option handling
97a18c85458b898fe5e3abda9528a2de442766ad cmake: Fix `IF_CHECK_PASSED` option handling (Hennadii Stepanov)

Pull request description:

  `IF_CHECK_PASSED` is a multi-value keyword, resulting in a list value. Convert it to a string before applying any `string()` command.

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

  No current CMake code is affected by this bug.

ACKs for top commit:
  theuni:
    utACK 97a18c85458b898fe5e3abda9528a2de442766ad

Tree-SHA512: d2556ca38c35a8992175e9f948c2028a789e71c2b2d5fdf365b31710c8ed3d5edf5d0363853c5d750d29abb58cfda3c78cdc2971a627e5b4c61aca4ec2a33356
2024-12-06 10:15:56 +00:00
merge-script
5b283fa147
Merge : util: use explicit cast in MultiIntBitSet::Fill()
edb41e4814ccc2c06a5694b2d2632dbbd22bc0cf util: use explicit cast in MultiIntBitSet::Fill() (Vasil Dimov)

Pull request description:

  The current code does not have a bug, but is implicitly casting -1 to 65535 and the sanitizer has no way to know whether we intend that or not.

  ```
  FUZZ=bitset src/test/fuzz/fuzz /tmp/fuz

  error: implicit conversion from type 'int' of value -1 (32-bit, signed)
  to type 'value_type' (aka 'unsigned short') changed the value to 65535
  (16-bit, unsigned)

  Base64: Qv7bX/8=
  ```

  https://api.cirrus-ci.com/v1/task/5685829642747904/logs/ci.log

ACKs for top commit:
  sipa:
    ACK edb41e4814ccc2c06a5694b2d2632dbbd22bc0cf
  maflcko:
    lgtm ACK edb41e4814ccc2c06a5694b2d2632dbbd22bc0cf
  Empact:
    ACK edb41e4814ccc2c06a5694b2d2632dbbd22bc0cf
  tdb3:
    code review ACK edb41e4814ccc2c06a5694b2d2632dbbd22bc0cf

Tree-SHA512: a53835d654d9a7246ec0dab30fa5fbc08155dadb40d9bee3297060aa90816e0ce3d3e92dbdcd7af9474446d842d03f2781b7645a68ffef7fb5fc32ee02545112
2024-12-06 10:00:39 +00:00
Ryan Ofsky
2eccb8bc5e
Merge : test: Rework wallet_migration.py to use previous releases
55347a5018b2c252c56548f0a6dc1e88e42f66b6 test: Rework migratewallet to use previous release (v28.0) (Ava Chow)
f42ec0f3bfbea8c2cd0c02f4b4d64b71ded6d081 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 

ACKs for top commit:
  maflcko:
    re-ACK 55347a5018b2c252c56548f0a6dc1e88e42f66b6 🥊
  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 : test: Avoid logging error when logging error
cccca8a77f3c1b22fb0ea825ca92aebd63b16d77 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 cccca8a77f3c1b22fb0ea825ca92aebd63b16d77

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

Pull request description:

  Fixes: 

  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
Vasil Dimov
edb41e4814
util: use explicit cast in MultiIntBitSet::Fill()
The current code does not have a bug, but is implicitly casting -1 to
65535 and the sanitizer has no way to know whether we intend that or
not.

```
FUZZ=bitset src/test/fuzz/fuzz /tmp/fuz

error: implicit conversion from type 'int' of value -1 (32-bit, signed)
to type 'value_type' (aka 'unsigned short') changed the value to 65535
(16-bit, unsigned)

Base64: Qv7bX/8=
```
2024-12-05 16:55:36 +01:00
glozow
083770adbe
Merge : test: orphan parent is re-requested from 2nd peer
0f84cdd26614a229d9aee6cd74a1aa01b204a1f5 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 0f84cdd26614a229d9aee6cd74a1aa01b204a1f5
  tdb3:
    code review ACK 0f84cdd26614a229d9aee6cd74a1aa01b204a1f5
  theStack:
    ACK 0f84cdd26614a229d9aee6cd74a1aa01b204a1f5
  marcofleon:
    tACK 0f84cdd26614a229d9aee6cd74a1aa01b204a1f5. 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: 

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
e8cc790fe2
Merge : test: addrman: tried 3 times and never a success so isTerrible=true
1807df3d9fb0135057a33e01173080ea14b0403d test: addrman: tried 3 times and never a success so `isTerrible=true` (brunoerg)

Pull request description:

  This PR adds test coverage for the following verification:
  ```cpp
  if (TicksSinceEpoch<std::chrono::seconds>(m_last_success) == 0 && nAttempts >= ADDRMAN_RETRIES) { // tried N times and never a success
      return true;
  }
  ```

  If we've tried an address for 3 or more times and were unsuccessful, this address should be pointed out as "terrible".

  -------

  You can test this by applying:
  ```diff
  diff --git a/src/addrman.cpp b/src/addrman.cpp
  index 054a9bee32..93a9521b59 100644
  --- a/src/addrman.cpp
  +++ b/src/addrman.cpp
  @@ -81,7 +81,7 @@ bool AddrInfo::IsTerrible(NodeSeconds now) const
       }

       if (TicksSinceEpoch<std::chrono::seconds>(m_last_success) == 0 && nAttempts >= ADDRMAN_RETRIES) { // tried N times and never a success
  -        return true;
  +        return false;
       }
  ```

ACKs for top commit:
  jonatack:
    re-ACK 1807df3d9fb0135057a33e01173080ea14b0403d
  naumenkogs:
    ACK 1807df3d9fb0135057a33e01173080ea14b0403d
  achow101:
    ACK 1807df3d9fb0135057a33e01173080ea14b0403d

Tree-SHA512: e3cc43c98bddfe90f585d5b4bd00543be443b77ecaf038615261aa8cc4d14fc2f1006d0b00c04188040eaace455c5c6dbb3bb200a2c0f29c3b4ef5128bf0973a
2024-12-04 15:34:59 -05:00
Ryan Ofsky
17372d788e
Merge : refactor: prohibit direct flags access in CCoinsCacheEntry and remove invalid tests
50cce20013c97e1257cb9f4c9319701a09b0a196 test, refactor: Compact ccoins_access and ccoins_spend (Lőrinc)
0a159f0914775756dcac2d9fa7fe4e4d4e70ba0c test, refactor: Remove remaining unbounded flags from coins_tests (Lőrinc)
c0b4b2c1eef95c0b626573a9a2e217f4a541a880 test: Validate error messages on fail (Lőrinc)
d5f8d607ab1f8fd9fc17aba4105867b450117be2 test: Group values and states in tests into CoinEntry wrappers (Lőrinc)
ca74aa7490a5005d227da75dc8f2d1ab73c6e9d2 test, refactor: Migrate GetCoinsMapEntry to return MaybeCoin (Lőrinc)
15aaa81c3818b4138602c127d6a16018aae75687 coins, refactor: Remove direct GetFlags access (Lőrinc)
6b733699cfc79253ffae1527106baa428dd62f39 coins, refactor: Assume state after SetClean in AddFlags to prevent dangling pointers (Lőrinc)
fc8c282022e6ce4eb3ce526800a6ada3b4a2996d coins, refactor: Make AddFlags, SetDirty, SetFresh static (Lőrinc)
cd0498eabc910efa3ed7a6d32e687107248bb5be coins, refactor: Split up AddFlags to remove invalid states (Lőrinc)

Pull request description:

  Similarly to https://github.com/bitcoin/bitcoin/pull/30849, this cleanup is intended to de-risk https://github.com/bitcoin/bitcoin/pull/30673#discussion_r1739909068 by simplifying the coin cache public interface.

  `CCoinsCacheEntry` provided general access to its internal flags state, even though, in reality, it could only be `clean`, `fresh`, `dirty`, or `fresh|dirty` (in the follow-up, we will remove `fresh` without `dirty`).

  Once it was marked as `dirty`, we couldn’t set the state back to clean with `AddFlags(0)`—tests explicitly checked against that.

  This PR refines the public interface to make this distinction clearer and to make invalid behavior impossible, rather than just checked by tests. We don't need extensive access to the internals of `CCoinsCacheEntry`, as many tests were simply validating invalid combinations in this way.

  The last few commits contain significant test refactorings to make `coins_tests` easier to change in follow-ups.

ACKs for top commit:
  andrewtoth:
    Code Review ACK 50cce20013c97e1257cb9f4c9319701a09b0a196
  laanwj:
    Code review ACK 50cce20013c97e1257cb9f4c9319701a09b0a196
  ryanofsky:
    Code review ACK 50cce20013c97e1257cb9f4c9319701a09b0a196. Looks good! Thanks for the followups.

Tree-SHA512: c0d65f1c7680b4bb9cd368422b218f2473c2ec75a32c7350a6e11e8a1601c81d3c0ae651b9f1dae08400fb4e5d43431d9e4ccca305a718183f9a936fe47c1a6c
2024-12-04 14:09:05 -05:00
Ava Chow
11f68cc810
Merge : util: Improve documentation and negation of args
95a0104f2e9869799db84add108ae8c57b56d360 test: Add tests for directories in place of config files (Hodlinator)
e85abe92c7cc5380489c028479f0d42f91827efd args: Catch directories in place of config files (Hodlinator)
e4b6b1822ce004365be11c54c8f5f02f95303fb0 test: Add tests for -noconf (Hodlinator)
483f0dacc413f4b1ba1b74c2429c4367b87e7f11 args: Properly support -noconf (Hodlinator)
312ec64cc0619f58c6e8abc5855fd2fa0e920c3f test refactor: feature_config_args.py - Stop nodes at the end of tests, not at the beginning (Hodlinator)
7402658bc2b9d835b240edb9c1dac308859687c3 test: -norpccookiefile (Hodlinator)
39cbd4f37c3d3a32cd993cbc78052d53f700989b args: Support -norpccookiefile for bitcoind and bitcoin-cli (Hodlinator)
e82ad88452bce4132e4583727e610d52dcf9ad9e logs: Use correct path and more appropriate macros in cookie-related code (Hodlinator)
6e28c76907ca0012b1a4556d9a982dfffb5abaf6 test: Harden testing of cookie file existence (Hodlinator)
75bacabb55f3d54ad9b2c660cafc82c167e4f644 test: combine_logs.py - Output debug.log paths on error (Hodlinator)
bffd92f00f5bfbb5a622d0bd20bfeed9f8b10928 args: Support -nopid (Hodlinator)
12f8d848fd91b11d5cffe21dfc3ba124102ee236 args: Disallow -nodatadir (Hodlinator)
6ff9662760099c405cf13153dd1de22900045f5e scripted-diff: Avoid printing version information for -noversion (Hodlinator)
e8a2054edc814b2c4661b96a3dce91da9be68fa4 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 95a0104f2e9869799db84add108ae8c57b56d360
  achow101:
    ACK 95a0104f2e9869799db84add108ae8c57b56d360
  ryanofsky:
    Code review ACK 95a0104f2e9869799db84add108ae8c57b56d360. 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 : test: fix MIN macro redefinition
00c1dbd26ddb816e5541c5724397015a92a3d06b test: fix MIN macro-redefinition (0xb10c)

Pull request description:

  Renames the `MIN` macro to `_TRACEPOINT_TEST_MIN`.

  From :

  ```
  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 00c1dbd26ddb816e5541c5724397015a92a3d06b

Tree-SHA512: 1d91ed8b3c0b0410d42a11004286359546c17613c3ff03dd51c26896ee050e9280fff69fa2eaa6e6085f9b611663bcacedec80997a6c5e37874a79ba86bfa507
2024-12-04 17:13:00 +00:00
Ryan Ofsky
39950e148d
Merge : refactor: Prepare compile-time check of bilingual format strings
fa3e074304780549b1e7972217930e34fa55f59a refactor: Tidy fixups (MarcoFalke)
fa72646f2b197810a324cb0544d9a1fac37d3f9c move-only: Detail_CheckNumFormatSpecifiers and G_TRANSLATION_FUN (MarcoFalke)
faff8403f0aac3b5ec26d3c7fc98240f879f9906 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 fa3e074304780549b1e7972217930e34fa55f59a. Nice changes! These should allow related PRs to be simpler.
  l0rinc:
    ACK fa3e074304780549b1e7972217930e34fa55f59a
  hodlinator:
    cr-ACK fa3e074304780549b1e7972217930e34fa55f59a

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 :

```
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 : util: Drop boost posix_time in ParseISO8601DateTime
faf70cc9941ce2b0ce4fd48ecfdbe28194adb8ba Remove wallet::ParseISO8601DateTime, use ParseISO8601DateTime instead (MarcoFalke)
2222aecd5f8059785e655da7b7e3fcc59204245c 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 faf70cc9941ce2b0ce4fd48ecfdbe28194adb8ba, I have reviewed the code and it looks OK.
  dergoegge:
    utACK faf70cc9941ce2b0ce4fd48ecfdbe28194adb8ba

Tree-SHA512: 9dd745a356d04acf6200e13a6af52c51a9e2a0eeccea110093ce5da147b3c669c0eda918e46db0164c081a78c8feae3fe557a4759bea18449a8ff2d090095931
2024-12-04 11:21:43 +00:00
Ava Chow
ff873a20a7
Merge : refactor: Clamp worker threads in ChainstateManager constructor
8f85d36d68ab33ba237407a2ed16667eb149d61f refactor: Clamp worker threads in ChainstateManager constructor (TheCharlatan)

Pull request description:

  This ensures the options are applied consistently from contexts where they might not pass through the args manager, such as in some tests, or when used through the kernel library.

  This is similar to the patch applied in 09ef322acc0a88a9e119f74923399598984c68f6, used to make applying the mempool options consistent.

  ---

  This is part of the libbitcoinkernel project https://github.com/bitcoin/bitcoin/issues/27587

ACKs for top commit:
  maflcko:
    ACK 8f85d36d68ab33ba237407a2ed16667eb149d61f 🛳
  achow101:
    ACK 8f85d36d68ab33ba237407a2ed16667eb149d61f
  furszy:
    Code ACK 8f85d36d68ab33ba237407a2ed16667eb149d61f
  stickies-v:
    ACK 8f85d36d68ab33ba237407a2ed16667eb149d61f

Tree-SHA512: 32d7cc177d6726ee9df62ac9eb43e49ba676f35bfcff47834bd97a1e33f2a9ea7be65d0a8a37be149de04e58c9c500ecef730e498f4e3909042324d3136160e9
2024-12-03 18:02:37 -05:00
Ava Chow
c9a7418a8d
Merge : Package validation: accept packages of size 1
32fc59796f74a2941772b5ec2755b1319132cd9c 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 

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

Tree-SHA512: ffed353bfdca610ffcfd53b40b76da05ffc26df6bac4b0421492e067bede930380e03399d2e2d1d17f0e88fb91cd8eb376e3aabebbabcc724590bf068d09807c
2024-12-03 17:46:23 -05:00
Ava Chow
6f24662eb9
Merge : rpc: Remove submitblock pre-checks
73db95c65c1d372822166045ca8b9f173d5fd883 kernel: Make bitcoin-chainstate's block validation mirror submitblock's (TheCharlatan)
bb53ce9bdae2f02d7bd95cf5d8ca4ccf5136466a tests: Add functional test for submitting a previously pruned block (Greg Sanders)
1f7fc738255205a64374686aca9a4c53089360f1 rpc: Remove submitblock duplicate pre-check (TheCharlatan)
e62a8abd7df21795dcd173773f689b6d4c8feab6 rpc: Remove submitblock invalid-duplicate precheck (TheCharlatan)
36dbebafb9b54764005e6fffa7ad28d4cadfe5e4 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 73db95c65c1d372822166045ca8b9f173d5fd883
  achow101:
    ACK 73db95c65c1d372822166045ca8b9f173d5fd883
  instagibbs:
    ACK 73db95c65c1d372822166045ca8b9f173d5fd883
  mzumsande:
    ACK 73db95c65c1d372822166045ca8b9f173d5fd883

Tree-SHA512: 2d02e851cf402ecf6a1968c058df3576aac407e200cbf922a1a6391b7f97b4f42c6d9f6b0a78b9d1af0a6d40bdd529a7b11a1e6d88885bd7b8b090f6d1411861
2024-12-03 17:38:41 -05:00
Ava Chow
3867d2421a
Merge : Improve parallel script validation error debug logging
492e1f09943fcb6145c21d470299305a19e17d8b [validation] merge all ConnectBlock debug logging code paths (Pieter Wuille)
b49df703f031894b41ec1a624137e5d3206940b5 [validation] include all logged information in BlockValidationState (Pieter Wuille)
7b267c034fdc2c8cb964a763f182ff98a75ba2ac [validation] Add detailed txin/txout information for script error messages (Pieter Wuille)
146a3d542683ddb89a31104f5211dfc757d1dafb [validation] Make script error messages uniform for parallel/single validation (Pieter Wuille)
1ac1c33f3f120bbe0bde4fa948299bc07cac47ee [checkqueue] support user-defined return type through std::optional (Pieter Wuille)

Pull request description:

  ~~Builds on top of #31097~~ (now merged). Fixes .

  So far, detailed information about script validation failures is only reported when running with `-par=1`, due to a lack of ability to transfer information from the script validation threads to the validation thread. Fix this by extending the `CCheckQueue` functionality to pass more results through than just success/failure, and use this to report the exact Script error, as well as the transaction input in which it occurred.

ACKs for top commit:
  achow101:
    ACK 492e1f09943fcb6145c21d470299305a19e17d8b
  furszy:
    Code review ACK 492e1f0
  maflcko:
    re-ACK 492e1f09943fcb6145c21d470299305a19e17d8b 🍈
  dergoegge:
    ACK 492e1f09943fcb6145c21d470299305a19e17d8b
  instagibbs:
    ACK 492e1f09943fcb6145c21d470299305a19e17d8b
  mzumsande:
    Code Review ACK 492e1f09943fcb6145c21d470299305a19e17d8b

Tree-SHA512: 234f2e7dfd03bdcd2a56200875fe370962f211ea7ed334038a6a9279a758030bf94bb6246f60d06dd0473dac4b9dbf050d9a32ecaa4176f7727eff63572bf4fd
2024-12-03 15:22:38 -05:00
Ryan Ofsky
8e02b48059
Merge : ci: Skip broken Wine64 tests by default
fa5e7064597fc51366f082e3d07a4591e576db38 ci: Skip broken Wine64 tests by default (MarcoFalke)

Pull request description:

  I don't think the unit tests run in Wine after the Windows cross-compilation have ever shown a true positive since the MSVC task was added. However, they are a source of frequent false-positives.

  Thus, disable them by default for now. Anyone can still enable them by setting `RUN_UNIT_TESTS=true`.

  A follow-up could run them on real Windows, see https://github.com/bitcoin/bitcoin/pull/31176.

  Conceptually there are many other nightly tasks, which rarely find issues and are not run by default, like the valgrind or s390x tasks. So putting the Wine unit tests in the same bucket should be fine.

ACKs for top commit:
  hebasto:
    ACK fa5e7064597fc51366f082e3d07a4591e576db38, to avoid false-positives.
  willcl-ark:
    ACK fa5e7064597fc51366f082e3d07a4591e576db38

Tree-SHA512: 6bd54470e4d5ce18923c5d724aba0dbf475d053d7097d3f87e822a455cc537b6ce5f0dfcc8ccd0719c12c5d0c8fc7355a6c84185a6c9b5d484d98aee763d0c49
2024-12-03 12:21:31 -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
e85abe92c7
args: Catch directories in place of config files
Previously passing a directory path as -conf would lead to an ifstream being opened for it, and would not trigger any errors.
2024-12-03 11:04:10 +01:00
Hodlinator
e4b6b1822c
test: Add tests for -noconf 2024-12-03 11:04:10 +01:00
Hodlinator
483f0dacc4
args: Properly support -noconf
-noconf would previously lead to an ifstream "successfully" being opened to the ".bitcoin"-directory (not a file). (Guards against the general case of directories as configs are added in grandchild commit to this one).

Other users of AbsPathForConfigVal() in combination with negated args have been updated earlier in this PR ("args: Support -nopid" and "args: Support -norpccookiefile...").
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
39cbd4f37c
args: Support -norpccookiefile for bitcoind and bitcoin-cli
Replaces belt & suspenders check for initialization in RPCAuthorized() with not allowing empty passwords further down.
2024-12-03 10:38:21 +01:00
Hodlinator
e82ad88452
logs: Use correct path and more appropriate macros in cookie-related code
filepath_tmp -> filepath in last message.

More material changes to nearby code in next commit.
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
b49df703f0 [validation] include all logged information in BlockValidationState 2024-12-02 16:25:17 -05:00
Pieter Wuille
7b267c034f [validation] Add detailed txin/txout information for script error messages
Don't just report which script error occurred, but which in which input of which transaction,
and which UTXO was being spent.
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
Pieter Wuille
1ac1c33f3f [checkqueue] support user-defined return type through std::optional
The check type function now needs to return a std::optional<R> for some type R,
and the check queue overall will return std::nullopt if all individual checks
return that, or one of the non-nullopt values if there is at least one.

For most tests, we use R=int, but for the actual validation code, we make it return
the ScriptError.
2024-12-02 16:25:13 -05:00
Ryan Ofsky
ebe4cac38b
Merge : test: enable running independent functional test sub-tests
409d0d629378c3e23388ed31516376ad1ae536b5 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 409d0d629378c3e23388ed31516376ad1ae536b5
  rkrux:
    reACK 409d0d629378c3e23388ed31516376ad1ae536b5
  ryanofsky:
    Code review ACK 409d0d629378c3e23388ed31516376ad1ae536b5. 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
merge-script
1927674100
Merge : doc: Use more precise anchor link to codesigning docs
19f49c7489d226e1cebc754fbbae3e4bebc360af doc: Use more precise anchor link to codesigning docs (Jeremy Rand)

Pull request description:

  The "Codesigning" section is what users presumably are looking for when they follow this link.

ACKs for top commit:
  fanquake:
    ACK 19f49c7489d226e1cebc754fbbae3e4bebc360af

Tree-SHA512: 0e25cf0d7160db7d564d67d3e3ac614f9bd209b2399414f1278fa01cfc1ff827aa8311f7c1c2666924d5ac2dc23fe9bc258b80ed8025d5b8d5b11bcf1d12b28c
2024-12-02 14:09:54 +00:00
MarcoFalke
faf70cc994
Remove wallet::ParseISO8601DateTime, use ParseISO8601DateTime instead 2024-12-02 15:09:31 +01:00
merge-script
e043618d44
Merge : test: simple reordering to reduce run time
62f6d9e1a48e3b63c504996e914075cacfdcaedc test: simple ordering optimization to reduce runtime (tdb3)

Pull request description:

  Noticed in  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 62f6d9e1a48e3b63c504996e914075cacfdcaedc
  TheCharlatan:
    ACK 62f6d9e1a48e3b63c504996e914075cacfdcaedc

Tree-SHA512: 6f93fbe4de3fce202383d9f84aa0e96961af3de3c02b8cab73589339d701f32c5e1b57a191eeebf4b06b5cd7a82617f63f24110732940be1a5a4d9237813a570
2024-12-02 14:08:58 +00:00