7035 Commits

Author SHA1 Message Date
pythcoiner
32d4861387
Merge 28a4fcb03c0fb1cd5112eca1eb36dcb13e0b4ff2 into 5f4422d68dc3530c353af1f87499de1c864b60ad 2025-03-17 03:54:18 +01:00
merge-script
5f4422d68d
Merge bitcoin/bitcoin#32010: qa: Fix TxIndex race conditions
3301d2cbe8c3b76c97285d75fa59637cb6952d0b qa: Wait for txindex to avoid race condition (Hodlinator)
9bfb0d75ba10591cc6c9620f9fd1ecc0e55e7a48 qa: Remove unnecessary -txindex args (Hodlinator)
7ac281c19cd3d11f316dbbb3308eabf1ad4f26d6 qa: Add missing coverage of corrupt indexes (Hodlinator)

Pull request description:

  - Add synchronization in 3 places where if the Transaction Index happens to be slow, we get rare test failures when querying it for transactions (one such case experienced on Windows, prompting investigation).
  - Remove unnecessary TxIndex initialization in some tests.
  - Add some test coverage where TxIndex aspect could be tested in feature_init.py.

ACKs for top commit:
  fjahr:
    re-ACK 3301d2cbe8c3b76c97285d75fa59637cb6952d0b
  mzumsande:
    Code Review ACK 3301d2cbe8c3b76c97285d75fa59637cb6952d0b
  furszy:
    Code review ACK 3301d2cbe8c3b76c97285d75fa59637cb6952d0b
  Prabhat1308:
    Concept ACK [`3301d2c`](3301d2cbe8)

Tree-SHA512: 7c2019e38455f344856aaf6b381faafbd88d53dc88d13309deb718c1dcfbee4ccca7c7f1b66917395503a6f94c3b216a007ad432cc8b93d0309db9805f38d602
2025-03-17 10:28:14 +08:00
merge-script
cd8089c20b
Merge bitcoin/bitcoin#32069: test: fix intermittent failure in wallet_reorgsrestore.py
36b0713edc4655f6e0c291975d6d280fbc89cf2e test: fix intermittent failure in wallet_reorgsrestore.py (furszy)

Pull request description:

  In response to #32066 intermittent failure.

  Wait until the node's process has fully stopped before starting a new instance of it.
  Same behavior as in the [tool_wallet.py](698f86964c/test/functional/tool_wallet.py (L540)) test.

ACKs for top commit:
  maflcko:
    lgtm ACK 36b0713edc4655f6e0c291975d6d280fbc89cf2e
  Chand-ra:
    tACK [36b0713](36b0713edc)

Tree-SHA512: 8e01493ef1fb58589479f3e12d7429d02ca75a2183d5f79d3b6a2fbf13334878926274a20857f1b4729afc1d30b65789daed229ce06ba236b91d949b73f45d5a
2025-03-16 22:29:14 +08:00
merge-script
70a0ee89c6
Merge bitcoin/bitcoin#32063: test: fix intermittent failure in p2p_orphan_handling.py
02942056fd861581503a8a35a06dcf22d4ba1473 test: fix intermittent failure in p2p_orphan_handling.py (Martin Zumsande)

Pull request description:

  If the mocktime is bumped before the node has successfully disconnected the peer, the requests for both parents could be spread over two GETDATAS: The first time `GetRequestsToSend` is invoked it would only request one tx from peer2, because the other one would only be available after peer1  was disconnected and its outstanding txrequest cleared.
  So two GETDATAs would be sent, which would make the test fail.

  Fixes #31700

ACKs for top commit:
  maflcko:
    lgtm ACK 02942056fd861581503a8a35a06dcf22d4ba1473
  instagibbs:
    ACK 02942056fd

Tree-SHA512: 769200898345da197d86d673d9506f08f0a64b72a456e7e7c988ac37450d9c54ec65da1c8447c566c8578f7cfccdc5723ea680e636bfbe0b3d38265e5ef57774
2025-03-16 22:27:40 +08:00
merge-script
ca05b28710
Merge bitcoin/bitcoin#31859: test: Rename send_message to send_without_ping
fa9cf38ab666b50b0d8e82cb17f9e5a8a613547d scripted-diff: test: Rename send_message to send_without_ping (MarcoFalke)
fa4356717d6efcc41709f62a5116c62519d1a853 test: Prefer send_and_ping over send_message+sync_with_ping (MarcoFalke)

Pull request description:

  `send_message` is problematic, because it is easy to forget a `sync_with_ping` (or other `wait_until`), leading to intermittent test failures. (Example: https://github.com/bitcoin/bitcoin/pull/31837#discussion_r1950370246)

  There are more uses of `send_and_ping` in the codebase than `send_message`, so in most cases `send_and_ping` is needed anyway.

  For the remaining cases, clearly document that no sync happens by renaming `send_message` to `send_without_ping`.

ACKs for top commit:
  instagibbs:
    ACK fa9cf38ab6

Tree-SHA512: 31caa6568d292ae3d3dda931a94aaa30cc1205ec2ef537a484393eb55687f86c212f1e751ac4a7636610bdf591502a50995dc63bf02f97be9fdc482072160b07
2025-03-16 17:08:12 +08:00
merge-script
51a20e56c2
Merge bitcoin/bitcoin#31977: test: Use rpc_deprecated only for testing deprecation
2819c514825577dc8d73690882f25117d412ed9f test: Use rpc_deprecated only for testing deprecation (Fabian Jahr)

Pull request description:

  The comment in `functional/rpc_deprecated.py` says "This test should be used to verify correct behaviour of deprecated RPC methods with and without the -deprecatedrpc flags." I think we can get rid of the "with" part since we can assume that every deprecated RPC is already tested in at least one other functional test. (I didn't look but I could verify in our coverage if someone has doubts about that.) In order for this test to continue working, the flag will need to be used there. Otherwise this seems to prescribe copy+pasting a basic test from another file and I don't see a good reason for that.

ACKs for top commit:
  maflcko:
    lgtm ACK 2819c514825577dc8d73690882f25117d412ed9f
  janb84:
    re ACK [2819c51](2819c51482)
  polespinasa:
    reACK 2819c514825577dc8d73690882f25117d412ed9f

Tree-SHA512: 96edfd07be863ad19f99feb27afbc2c3ad53560c93c93eac8de8d766ad8c46e5aa02fd013fec99af794cbe9adca8e459d5b80b454caea7e67b2388003e010bb6
2025-03-16 16:59:39 +08:00
Fabian Jahr
2819c51482
test: Use rpc_deprecated only for testing deprecation 2025-03-14 22:48:24 +01:00
furszy
36b0713edc
test: fix intermittent failure in wallet_reorgsrestore.py
Wait until the node's process has fully stopped before starting a new instance.

Since the same code is used in tool_wallet.py, this consolidates the behavior
into a 'kill_process()' function.
2025-03-14 11:06:44 -04:00
MarcoFalke
fa9cf38ab6
scripted-diff: test: Rename send_message to send_without_ping
send_message only drops the bytes in a buffer and a sync is needed to
avoid intermittent test issues. Change the name of the method to make
this more apparent during review.

-BEGIN VERIFY SCRIPT-
 sed -i 's/send_message(/send_without_ping(/g' $( git grep -l 'send_message(' )
-END VERIFY SCRIPT-
2025-03-14 12:45:20 +01:00
MarcoFalke
fa4356717d
test: Prefer send_and_ping over send_message+sync_with_ping
Also, add an explanation for the preference in the docs.
2025-03-14 12:44:34 +01:00
merge-script
698f86964c
Merge bitcoin/bitcoin#31961: Require sqlite when building the wallet
36b6f36ac4724cb2c9ed0e25314c3bbf55e4ebb8 build: require sqlite when building the wallet (Sjors Provoost)

Pull request description:

  Require that sqlite is available in order to compile the wallet. Removes instances of `USE_SQLITE` since it is no longer possible to not have sqlite available.

  The `NO_SQLITE` option is dropped from depends.

  This is another step towards dropping the legacy wallet, extracted from #31250.

ACKs for top commit:
  m3dwards:
    ACK 36b6f36ac4724cb2c9ed0e25314c3bbf55e4ebb8
  davidgumberg:
    crACK 36b6f36ac4
  hebasto:
    re-ACK 36b6f36ac4724cb2c9ed0e25314c3bbf55e4ebb8.

Tree-SHA512: 870a0135671c80c4f28602119eb8637a1ed43b51b1673bfe88425782fb62ec6ef0f3d6baf0d5984d6a243779b0f63423fd4c4dc324ef87bffba13d63e05ad793
2025-03-14 11:23:35 +08:00
merge-script
1b251f6b67
Merge bitcoin/bitcoin#31649: consensus: Remove checkpoints (take 2)
3c5d1a468199722da620f1f3d8ae3319980a46d5 Remove checkpoints (marcofleon)
632ae47372de90064f61e3e622d8da766d1d12de update comment on MinimumChainWork check (marcofleon)

Pull request description:

  The headers presync logic (only downloading headers that lead to a chain with sufficient work, implemented in https://github.com/bitcoin/bitcoin/pull/25717) should be enough to prevent memory DoS using low-work headers. Therefore, we no longer have any use for checkpoints.

  All checkpoints and checkpoint logic are removed in a single commit, to make it easy to revert if necessary.

  Some previous discussion can be found in https://github.com/bitcoin/bitcoin/pull/25725. The conclusion at the time was that more testing of the presync logic was needed. Now that we have [unit](https://github.com/bitcoin/bitcoin/blob/master/src/test/headers_sync_chainwork_tests.cpp), [functional](https://github.com/bitcoin/bitcoin/blob/master/test/functional/p2p_headers_sync_with_minchainwork.py), and [fuzz](https://github.com/bitcoin/bitcoin/blob/master/src/test/fuzz/p2p_headers_presync.cpp) tests for this logic, it seems safe to move forward with checkpoint removal.

ACKs for top commit:
  Sjors:
    Code review ACK 3c5d1a468199722da620f1f3d8ae3319980a46d5
  instagibbs:
    reACK 3c5d1a468199722da620f1f3d8ae3319980a46d5
  dergoegge:
    ACK 3c5d1a468199722da620f1f3d8ae3319980a46d5

Tree-SHA512: 051a6f9b82cd0262f4d3be4403906812fc6d1be022731fac16bb1c02bca471f31dfc7fc4b834ab2469e8f087265a6d99e84a1d665823cda1b112363a8e8f337d
2025-03-14 08:09:15 +08:00
Martin Zumsande
02942056fd test: fix intermittent failure in p2p_orphan_handling.py
If we bump the mocktime before the node has successfully disconnected
the peer, the requests for both parents could be spread over
two GETDATAS, which would make the test fail.
2025-03-13 17:59:02 -04:00
Ryan Ofsky
5d96c2eab9
Merge bitcoin/bitcoin#31907: qa: clarify and document one assumeutxo test case with malleated snapshot
e5ff4e416ecc8a51367022eb8a7a291f8cbc0c65 qa: use a clearer and documented amount error in malleated snapshot (Antoine Poinsot)
b34fdb5ade0b48384636f8c7c9673554bf82cedf test: introduce output amount (de)compression routines (Sebastian Falbesoner)
a7911ed101ff5b6b624a207f1526b1c347bf635f test: introduce VARINT (de)serialization routines (Sebastian Falbesoner)

Pull request description:

  The `feature_assumeutxo.py` functional test checks various errors with malleated snapshots. Some of these cases are brittle or use confusing and undocumented values. Fix one of those by using a clear, documented and forward-compatible value.

  I ran across those when working on an unrelated changeset which affected the snapshot. It took me a while to understand where the seemingly magic byte string was coming from, so i figured it was worth proposing this patch on its own for the sake of making the test more maintainable.

  See commit messages for details.

ACKs for top commit:
  janb84:
    re ACK [e5ff4e4](e5ff4e416e)
  theStack:
    ACK e5ff4e416ecc8a51367022eb8a7a291f8cbc0c65
  fjahr:
    Code review ACK e5ff4e416ecc8a51367022eb8a7a291f8cbc0c65
  i-am-yuvi:
    tACK e5ff4e416ecc8a51367022eb8a7a291f8cbc0c65

Tree-SHA512: 60f022b7176836ce05e8f287b436329d7ca6460f3fcd95f78cd24e07a95a7d4d9cbbb68a117916a113fe451732b09a012d300fe860ff33d61823eca797ceddaf
2025-03-13 16:34:56 -04:00
Ryan Ofsky
57d611e53b
Merge bitcoin/bitcoin#31757: wallet: fix crash on double block disconnection
11f8ab140fe63857f6a93b81021efda8f90ceeda test: wallet, coverage for crash on dup block disconnection during unclean shutdown (Martin Zumsande)
9ef429b6ae65f6ad3e9ac11c2d9c0a6c52beb865 wallet: fix crash on double block disconnection (furszy)

Pull request description:

  The wallet crashes if it processes the same block disconnection event twice in a row due
  to an incompatible coinbase transaction state.
  This happens because `disconnectBlock` provides `TxStateInactive` without the "abandoned"
  flag for coinbase transactions to `SyncTransaction`, while `AddToWallet()` internally modifies
  it to retain the abandoned state.

  The crash flow is as follows:
  1) On the first disconnection, the transaction state transitions from "confirmed" to
  "inactive," bypassing the state equality check since the provided state differs. Then,
  `AddToWallet` internally updates the state to "inactive + abandoned"

  2) On the second disconnection, as we provide only the "inactive" state
  to `SyncTransaction()`, the state equality assertion fails and crashes the wallet.

  Reviewers Note:
  The crash can easily be replicated by cherry-picking the test commit in master.

ACKs for top commit:
  mzumsande:
    Code Review ACK 11f8ab140fe63857f6a93b81021efda8f90ceeda
  rkrux:
    ACK 11f8ab140fe63857f6a93b81021efda8f90ceeda
  pinheadmz:
    ACK 11f8ab140fe63857f6a93b81021efda8f90ceeda

Tree-SHA512: 971069bca562f0afb06c34a2516842d01b5cbc2b18ed851392aa3caa3bb7488f4a84a5d017ea334e6361261d3c44aa597cc67a1d4fa16781f85e081f3d1f8771
2025-03-13 15:06:49 -04:00
marcofleon
3c5d1a4681 Remove checkpoints
The headers presync logic should be enough to prevent memory DoS using
low-work headers. Therefore, we no longer have any use for checkpoints.
2025-03-13 11:13:13 +00:00
Hennadii Stepanov
eb9730ab65
Merge bitcoin/bitcoin#31987: wallet: Replace "non-0" with "non-zero" in translatable error message
18e83534ace7aa2d26bc7dfa521b1d591b66edfa wallet: Replace "non-0" with "non-zero" in translatable error message (Hennadii Stepanov)

Pull request description:

  Transifex interprets the "-0" substring as a number in translatable strings. Since not all translations preserve "-0," this triggers a corresponding warning. While this warning could be disabled globally, it is more reasonable to adjust the original string instead.

ACKs for top commit:
  davidgumberg:
    ACK 18e83534ac
  l0rinc:
    ACK 18e83534ace7aa2d26bc7dfa521b1d591b66edfa
  1440000bytes:
    ACK 18e83534ac
  BrandonOdiwuor:
    Code Review ACK 18e83534ace7aa2d26bc7dfa521b1d591b66edfa
  laanwj:
    Code review ACK 18e83534ace7aa2d26bc7dfa521b1d591b66edfa

Tree-SHA512: 5c38cfc4b352dbbcc8de5fb907cf988a77a7ecded7a90fe0517bfb9e4cd5097bdeb1aa6edf5d9ca37de54d1d7939d5e49533ec93c403db90d9169ad7732e5124
2025-03-12 19:32:05 +00:00
Sjors Provoost
36b6f36ac4
build: require sqlite when building the wallet
Require that sqlite is available in order to compile the wallet. Removes
instances of USE_SQLITE since it is no longer possible to not have
sqlite available.

The NO_SQLITE option is dropped from depends.

Co-authored-by: Ava Chow <github@achow101.com>
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2025-03-12 15:42:38 +01:00
merge-script
8cb6ab0b97
Merge bitcoin/bitcoin#32025: validation, fix: Use wtxid instead of txid in CheckEphemeralSpends
e637dc2c01c3b566e6c51c911c5881a8d206c924 refactor: Replace uint256 type with Wtxid in PackageMempoolAcceptResult struct (marcofleon)
a3baead7cb8376e3b09f1726b8c466648d187524 validation: use wtxid instead of txid in CheckEphemeralSpends (marcofleon)

Pull request description:

  This PR addresses a small bug in [`AcceptMultipleTransactions`](45719390a1/src/validation.cpp (L1598)) where a txid was being inserted into a map that should only hold wtxids.  `CheckEphemeralSpends` has an out parameter on failure that records that the child transaction did not spend the parent's dust. Instead of using the txid of this child, use its wtxid.

  The second commit in this PR is a refactor of the `PackageMempoolAcceptResult` struct to use the `Wtxid` type instead of `uint256`. This helps to prevent errors like this in the future.

ACKs for top commit:
  instagibbs:
    ACK e637dc2c01
  glozow:
    ACK e637dc2c01c, hooray for type safety
  dergoegge:
    Code review ACK e637dc2c01c3b566e6c51c911c5881a8d206c924

Tree-SHA512: 17039efbb241b7741e2610be5a6d6f88f4c1cbe22d476931ec99e43f993d259a1a5e9334e1042651aff49edbdf7b9e1c1cd070a28dcba5724be6db842e4ad1e0
2025-03-12 19:57:58 +08:00
Hennadii Stepanov
7bb4c82d8b
Merge bitcoin/bitcoin#32021: qa: Enable feature_init.py on Windows
59c4930394cafc939eb396224b3d60d01ba0ce37 qa: Enable feature_init.py on Windows (Hodlinator)

Pull request description:

  Windows has been skipped since feature_init.py was added in #23289. Possibly due to poorer support on older Python versions, or attempts to use `CTRL_C_EVENT` (which didn't work in my testing either) instead of `CTRL_BREAK_EVENT`.

ACKs for top commit:
  maflcko:
    lgtm ACK 59c4930394cafc939eb396224b3d60d01ba0ce37
  BrandonOdiwuor:
    Code Review ACK 59c4930394cafc939eb396224b3d60d01ba0ce37
  hebasto:
    ACK 59c4930394cafc939eb396224b3d60d01ba0ce37, I have reviewed the code and it looks OK.

Tree-SHA512: 4f3649b41bcba2e8d03b8dcb1a7a6882edafb2c456db4b0768fc86018e9e9ed7171cb3d3c99e74b4ef38a3fcf3ab5d2f1865bbd49d791f1ce0a246806634e1a7
2025-03-12 11:26:58 +00:00
merge-script
502d47203e
Merge bitcoin/bitcoin#31161: cmake: Set top-level target output locations
568fcdddaec2cc8decba5a098257f31729cc1caa scripted-diff: Adjust documentation per top-level target output location (Hennadii Stepanov)
026bb226e96919603af829d0b677779a234a0f6e cmake: Set top-level target output locations (Hennadii Stepanov)

Pull request description:

  This PR sets the target output locations to the `bin` and `lib` subdirectories within the build tree, creating a directory structure that mirrors that of the installed targets.

  This approach is widely adopted by the large projects, such as [LLVM](e146c1867e/lldb/cmake/modules/LLDBStandalone.cmake (L128-L130)):
  ```cmake
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
  ```

  The `libsecp256k1` project has also recently [adopted](https://github.com/bitcoin-core/secp256k1/pull/1553) this approach.

  With this PR, all binaries are conveniently located. For example, run:
  ```
  $ ./build/bin/fuzz
  ```
  instead of:
  ```
  $ ./build/src/test/fuzz/fuzz
  ```

  On Windows, all required DLLs are now located in the same directory as the executables, allowing to run `bitcoin-chainstate.exe` (which loads `bitcoinkernel.dll`) without the need to copy DLLs or modify the `PATH` variable.

  The idea was briefly discussed among the build team during the recent CoreDev meeting.

  ---

  **Warning**: This PR changes build locations of newly built executables like `bitcoind` and `test_bitcoin` from `src/` to `bin/` without deleting previously built executables. A clean build is recommended to avoid accidentally running old binaries.

ACKs for top commit:
  theStack:
    Light re-ACK 568fcdddaec2cc8decba5a098257f31729cc1caa
  ryanofsky:
    Code review ACK 568fcdddaec2cc8decba5a098257f31729cc1caa. Only change since last review was rebasing. I'm ok with this PR in its current form if other developers are happy with it. I just personally think it is inappropriate to \*silently\* break an everyday developer workflow like `git pull; make bitcoind`. I wouldn't have a problem with this PR if it triggered an explicit error, or if the problem was limited to less common workflows like changing cmake options in an existing build.
  TheCharlatan:
    Re-ACK 568fcdddaec2cc8decba5a098257f31729cc1caa
  theuni:
    ACK 568fcdddaec2cc8decba5a098257f31729cc1caa

Tree-SHA512: 1aa5ecd3cd49bd82f1dcc96c8e171d2d19c58aec8dade4bc329df89311f9e50cbf6cf021d004c58a0e1016c375b0fa348ccd52761bcdd179c2d1e61c105e3b9f
2025-03-12 11:19:00 +08:00
merge-script
e38f09b776
Merge bitcoin/bitcoin#31955: test: Fix authproxy named args debug logging
fac1dd9dffba1033245c283bc0468e801c14e910 test: Fix authproxy named args debug logging (MarcoFalke)

Pull request description:

  In Python the meaning of `args or argsn` is that `argsn` is fully ignored when `args` is a list with at least one element. However, the RPC server accepts mixed positional and named args in the same RPC.

  Fix the debug log by always printing both. Also, add a new `_json_dumps` helper to avoid bloated code.

  Can be tested via `--tracerpc` on a call that uses named args mixed with positional args.

ACKs for top commit:
  i-am-yuvi:
    Tested ACK fac1dd9dffba1033245c283bc0468e801c14e910
  rkrux:
    tACK fac1dd9dffba1033245c283bc0468e801c14e910
  musaHaruna:
    Tested ACK [fac1dd9](fac1dd9dff)
  ryanofsky:
    Code review ACK fac1dd9dffba1033245c283bc0468e801c14e910. Thanks for logging fix. This change should have been included in #19762

Tree-SHA512: ff63fbc2564b2c7589e9294baacf4c7a79f10d593776813392510702ca726e3893a29db3ba261f3aee1789a59bb215d7cb10fc85ca1a02632631d3722ddcdfc5
2025-03-12 09:43:36 +08:00
marcofleon
a3baead7cb validation: use wtxid instead of txid in CheckEphemeralSpends 2025-03-11 16:00:46 +00:00
Hodlinator
3301d2cbe8
qa: Wait for txindex to avoid race condition
Can be verified to be necessary through adding std::this_thread::sleep_for(0.5s) at the beginning of TxIndex::CustomAppend.
2025-03-10 15:24:16 +01:00
wgyt
5601bab4f8 Docs: fix typos in documentation files 2025-03-08 09:26:18 +08:00
Hodlinator
59c4930394
qa: Enable feature_init.py on Windows 2025-03-07 22:33:49 +01:00
Hodlinator
9bfb0d75ba
qa: Remove unnecessary -txindex args
(Parent commit ensured indexes in feature_init.py are actually used, otherwise they would be removed here as well).
2025-03-07 22:22:31 +01:00
Hodlinator
7ac281c19c
qa: Add missing coverage of corrupt indexes 2025-03-07 22:22:31 +01:00
Martin Zumsande
11f8ab140f
test: wallet, coverage for crash on dup block disconnection during unclean shutdown
Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
2025-03-05 10:40:04 -05:00
glozow
0391d7e4c2
Merge bitcoin/bitcoin#31848: test, tracing: don't use problematic bpf_usdt_readarg_p()
a0b66b4bffaa6bc354c293785b785c2da2cef4de Revert "test: Disable known broken USDT test for now" (0xb10c)
ec47ba349d0b3cb2d274593ca7b828ae70584e10 contrib: don't use bpf_usdt_readarg_p (0xb10c)
35ae6ff60f622813d5bc311bceb5f93dc6f0f59b test: don't use bpf_usdt_readarg_p (0xb10c)

Pull request description:

  Instead of using the undocumented bcc helper `bpf_usdt_readarg_p()`, use [`bpf_usdt_readarg()`][1] and [`bpf_probe_read_user()`][2]/[`bpf_probe_read_user_str()`][3] as documented in the [bcc USDT reference guide][1].

  Note that the `bpf_probe_read_user()` documentation says the following:
  > For safety, all user address space memory reads must pass through bpf_probe_read_user().

  It's [assumed](https://github.com/bitcoin/bitcoin/issues/27380#issuecomment-2286505348) that using `bpf_usdt_readarg_p()` caused a lifetime issue. With `bpf_usdt_readarg()` and `bpf_probe_read_user()`, this doesn't [seem](https://github.com/bitcoin/bitcoin/issues/27380#issuecomment-2528671656) to be a problem anymore.

  This allows to revert faed533743 and closes #27380.

    [1]: https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md#6-usdt-probes
    [2]: https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md#10-bpf_probe_read_user
    [3]: https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md#11-bpf_probe_read_user_str

ACKs for top commit:
  i-am-yuvi:
    Tested ACK a0b66b4bffaa6bc354c293785b785c2da2cef4de
  willcl-ark:
    tACK a0b66b4bffaa6bc354c293785b785c2da2cef4de

Tree-SHA512: 002a692ad81ef284d4a610bbc6da477d623bf4dae5134c3692431c56b71692fa597e280fddd411eadd08eae77f01f47e2dcd0f37c0081326abe11a75bb10d6a6
2025-03-05 10:21:10 -05:00
fanquake
972b604dc4
doc: update location of minisketch repository 2025-03-05 14:13:53 +00:00
Antoine Poinsot
e5ff4e416e qa: use a clearer and documented amount error in malleated snapshot
In the assumeutxo functional tests, the final test case with alternated UTxO data tests the error
raised when deserializing a snapshot that contains a coin with an amount not in range (<0 or
>MAX_MONEY).

The current malleation uses an undocumented byte string and offset which makes it hard to maintain.
In addition, the undocumented offset is set surprisingly high (39 bytes is well into the
serialization of the amount which starts at offset 36). Similarly the value is surprisingly small,
presumably one was adjusted for the other. But there is no comment explaining how they were chosen,
why not in a clearer manner and what they are supposed to represent.

Instead replace this seemingly magic value with a clear one, MAX_MONEY + 1, serialize the whole
value for the amount field at the correct offset, and document the whole thing for the next person
around.
2025-03-04 12:50:17 -05:00
Sebastian Falbesoner
b34fdb5ade test: introduce output amount (de)compression routines 2025-03-04 12:50:17 -05:00
Hennadii Stepanov
18e83534ac
wallet: Replace "non-0" with "non-zero" in translatable error message
Transifex interprets the "-0" substring as a number in translatable
strings. Since not all translations preserve "-0," this triggers a
corresponding warning. While this warning could be disabled globally, it
is more reasonable to adjust the original string instead.
2025-03-04 16:29:43 +00:00
Sebastian Falbesoner
a7911ed101 test: introduce VARINT (de)serialization routines 2025-03-04 10:08:12 -05:00
merge-script
6876e5076e
Merge bitcoin/bitcoin#31943: test: add coverage for abandoning unconfirmed transaction
073a017016e62c7d52562aa61d942024379c110d test: add coverage for abandoning unconfirmed transaction (rkrux)

Pull request description:

  Previous discussion: https://github.com/bitcoin/bitcoin/pull/31794#pullrequestreview-2605174936
  Current Coverage: https://maflcko.github.io/b-c-cov/total.coverage/src/wallet/wallet.cpp.gcov.html#L1326

ACKs for top commit:
  Eunovo:
    Tested ACK 073a017016
  janb84:
    Tested ACK [073a017](073a017016)
  maflcko:
    lgtm ACK 073a017016e62c7d52562aa61d942024379c110d
  Prabhat1308:
    Concept ACK [`073a017`](073a017016)
  brunoerg:
    utACK 073a017016e62c7d52562aa61d942024379c110d

Tree-SHA512: be9b3d2e1cf65b20369be44d333aa2244b3af588f4a90374ad9562c3ea336669ba8f98a5fb88d616ba1f1f1b7dc0ad9bb47e7167aa03a52f2e0601525e156345
2025-02-26 09:36:34 -05:00
MarcoFalke
fac1dd9dff
test: Fix authproxy named args debug logging 2025-02-25 22:41:17 +01:00
costcould
d9ba427f9d chore: remove redundant word
Signed-off-by: costcould <fliter@myyahoo.com>
2025-02-25 23:39:23 +08:00
merge-script
c12a2528ce
Merge bitcoin/bitcoin#31415: test: fix TestShell initialization and reset()
303f8cca0568d2ca77189c4eccdfc7a6913c958d test: fix TestShell initialization and reset() (Brandon Odiwuor)

Pull request description:

  Fixes TestShell initialization issues caused by resolving symlinks and looking for config.ini in the source path instead of the build path after migration to CMake (see https://github.com/bitcoin/bitcoin/issues/31131#issuecomment-2433056070)

  ebe4cac38b/test/functional/test_framework/test_shell.py (L77)
  also fixes https://github.com/bitcoin/bitcoin/issues/31131

  **How to test:**
  ```
  $ python3
  >>> import sys
  >>> sys.path.insert(0, "./path/to/bitcoin/build/test/functional")
  >>> from test_framework.test_shell import TestShell
  >>> TestShell().setup(num_nodes=2, setup_clean_chain=True)
  >>> TestShell().shutdown()
  >>> TestShell.reset()
  ```

ACKs for top commit:
  pinheadmz:
    ACK 303f8cca0568d2ca77189c4eccdfc7a6913c958d
  theStack:
    Tested ACK 303f8cca0568d2ca77189c4eccdfc7a6913c958d
  pablomartin4btc:
    re-ACK 303f8cca0568d2ca77189c4eccdfc7a6913c958d

Tree-SHA512: 25396eb2f7e4bf14426399b1eb3d2c988903ab1f3d38a58f1044b67dd7200c11c01686578fb49b0f2943864166c5c9ccbf122b45202a1e723bf3dbf0c90020fa
2025-02-25 09:54:21 -05:00
rkrux
073a017016
test: add coverage for abandoning unconfirmed transaction
Co-authored-by: Eunovo <eunovo9@gmail.com>
2025-02-24 15:44:39 +05:30
Hennadii Stepanov
026bb226e9
cmake: Set top-level target output locations
This change:
1. Collects build artifacts in dedicated locations.
2. Allows running bitcoin-chainstate.exe with bitcoinkernel.dll directly
from the build tree on Windows.
2025-02-20 22:18:51 +00:00
Brandon Odiwuor
303f8cca05 test: fix TestShell initialization and reset() 2025-02-20 15:25:43 +03:00
Ava Chow
dc3a714633
Merge bitcoin/bitcoin#31794: wallet: abandon orphan coinbase txs, and their descendants, during startup
e4dd5a351bde88a94326824945f4c8b1e4c15df2 test: wallet, abandon coinbase txs and their descendants during startup (furszy)
474139aa9bf7109df78e46936e5a649c70703386 wallet: abandon inactive coinbase tx and their descendants during startup (furszy)

Pull request description:

  Since #26499, we mark coinbase transactions and their descendants as abandoned when a reorg arises through the "block disconnection" signal handler. However, this does not cover all scenarios; external wallets could contain coinbase transactions from blocks the node has not seen yet, or the user could have replaced the chain with an earlier or different version (one without the coinbase chain).

  This affects balance calculation as well as mempool rebroadcast (descendants shouldn't be relayed).
  Fix this by marking orphaned coinbase transactions and their descendants as abandoned during wallet startup.

ACKs for top commit:
  achow101:
    ACK e4dd5a351bde88a94326824945f4c8b1e4c15df2
  rkrux:
    tACK e4dd5a351bde88a94326824945f4c8b1e4c15df2
  mzumsande:
    Code Review ACK e4dd5a351bde88a94326824945f4c8b1e4c15df2

Tree-SHA512: 461a43de7a6f5a580f2e6e3b56ec9bc92239cd45e850a2ff594ab5488dcd4a507f68fbbf550a33d7173b2add0de80de1e1b3841e1dfab0c95b284212d8ced08a
2025-02-18 18:39:00 -08:00
Ava Chow
06757af2da
Merge bitcoin/bitcoin#29156: tests: add functional test for miniscript decaying multisig
bb633c9407c46eeadf6fe85e859cea1fed24473f tests: add functional test for miniscript decaying multisig (Michael Dietz)

Pull request description:

  This is very closely based on [test/functional/wallet_multisig_descriptor_psbt.py](https://github.com/bitcoin/bitcoin/blob/master/test/functional/wallet_multisig_descriptor_psbt.py) both in code and concept. It should serve as some integration testing for Miniscript descriptors, and also documents a simple multisig that starts as 4-of-4 and decays to 3-of-4, 2-of-4, and finally 1-of-4 at block heights (I think in the real world aligning this to halvenings would be nice).

ACKs for top commit:
  achow101:
    ACK bb633c9407c46eeadf6fe85e859cea1fed24473f
  rkrux:
    reACK bb633c9407c46eeadf6fe85e859cea1fed24473f
  hodlinator:
    ACK bb633c9407c46eeadf6fe85e859cea1fed24473f

Tree-SHA512: 1f8e8e50258d45d8f2b882b5f86dcd390d86c543ff4801f397733017102e0854ac387960b6e296bb164603545615d224a4b400247cbbc07bf21b2f4b718ab2ff
2025-02-18 18:22:59 -08:00
brunoerg
405dd0e647 test: remove scanning check on wallet_importdescriptors 2025-02-17 18:44:01 -03:00
furszy
e4dd5a351b
test: wallet, abandon coinbase txs and their descendants during startup 2025-02-15 10:49:08 -05:00
Ava Chow
43e71f7498
Merge bitcoin/bitcoin#27432: contrib: add tool to convert compact-serialized UTXO set to SQLite database
4080b66cbec2b6fc2fcfd7356941236f65d508e3 test: add test for utxo-to-sqlite conversion script (Sebastian Falbesoner)
ec99ed738083fc1ad4c9d85095e26e7e58372217 contrib: add tool to convert compact-serialized UTXO set to SQLite database (Sebastian Falbesoner)

Pull request description:

  ## Problem description

  There is demand from users to get the UTXO set in form of a SQLite database (#24628). Bitcoin Core currently only supports dumping the UTXO set in a binary _compact-serialized_ format, which was crafted specifically for AssumeUTXO snapshots (see PR #16899), with the primary goal of being as compact as possible. Previous PRs tried to extend the `dumptxoutset` RPC with new formats, either in human-readable form (e.g. #18689, #24202), or most recently, directly as SQLite database (#24952). Both are not optimal: due to the huge size of the ever-growing UTXO set with already more than 80 million entries on mainnet, human-readable formats are practically useless, and very likely one of the first steps would be to put them in some form of database anyway. Directly adding SQLite3 dumping support on the other hand introduces an additional dependency to the non-wallet part of bitcoind and the risk of increased maintenance burden (see e.g. https://github.com/bitcoin/bitcoin/pull/24952#issuecomment-1163551060, https://github.com/bitcoin/bitcoin/issues/24628#issuecomment-1108469715).

  ## Proposed solution

  This PR follows the "external tooling" route by adding a simple Python script for achieving the same goal in a two-step process (first create compact-serialized UTXO set via `dumptxoutset`, then convert it to SQLite via the new script). Executive summary:
  - single file, no extra dependencies (sqlite3 is included in Python's standard library [1])
  - ~150 LOC, mostly deserialization/decompression routines ported from the Core codebase and (probably the most difficult part) a little elliptic curve / finite field math to decompress pubkeys (essentialy solving the secp256k1 curve equation y^2 = x^3 + 7 for y given x, respecting the proper polarity as indicated by the compression tag)
  - creates a database with only one table `utxos` with the following schema:
    ```(txid TEXT, vout INT, value INT, coinbase INT, height INT, scriptpubkey TEXT)```
  - the resulting file has roughly 2x the size of the compact-serialized UTXO set (this is mostly due to encoding txids and scriptpubkeys as hex-strings rather than bytes)

  [1] note that there are some rare cases of operating systems like FreeBSD though, where the sqlite3 module has to installed explicitly (see #26819)

  A functional test is also added that creates UTXO set entries with various output script types (standard and also non-standard, for e.g. large scripts) and verifies that the UTXO sets of both formats match by comparing corresponding MuHashes. One MuHash is supplied by the bitcoind instance via `gettxoutsetinfo muhash`, the other is calculated in the test by reading back the created SQLite database entries and hashing them with the test framework's `MuHash3072` module.

  ## Manual test instructions
  I'd suggest to do manual tests also by comparing MuHashes. For that, I've written a go tool some time ago which would calculate the MuHash of a sqlite database in the created format (I've tried to do a similar tool in Python, but it's painfully slow).
  ```
  $ [run bitcoind instance with -coinstatsindex]
  $ ./src/bitcoin-cli dumptxoutset ~/utxos.dat
  $ ./src/bitcoin-cli gettxoutsetinfo muhash <block height returned in previous call>
  (outputs MuHash calculated from node)

  $ ./contrib/utxo-tools/utxo_to_sqlite.py ~/utxos.dat ~/utxos.sqlite
  $ git clone https://github.com/theStack/utxo_dump_tools
  $ cd utxo_dump_tools/calc_utxo_hash
  $ go run calc_utxo_hash.go ~/utxos.sqlite
  (outputs MuHash calculated from the SQLite UTXO set)

  => verify that both MuHashes are equal
  ```
  For a demonstration what can be done with the resulting database, see https://github.com/bitcoin/bitcoin/pull/24952#pullrequestreview-956290477 for some example queries. Thanks go to LarryRuane who gave me to the idea of rewriting this script in Python and adding it to `contrib`.

ACKs for top commit:
  ajtowns:
    ACK 4080b66cbec2b6fc2fcfd7356941236f65d508e3 - light review
  achow101:
    ACK 4080b66cbec2b6fc2fcfd7356941236f65d508e3
  romanz:
    tACK 4080b66cbe on signet (using [calc_utxo_hash](8981aa3e85/calc_utxo_hash/calc_utxo_hash.go)):
  tdb3:
    ACK 4080b66cbec2b6fc2fcfd7356941236f65d508e3

Tree-SHA512: be8aa0369a28c8421a3ccdf1402e106563dd07c082269707311ca584d1c4c8c7b97d48c4fcd344696a36e7ab8cdb64a1d0ef9a192a15cff6d470baf21e46ee7b
2025-02-14 15:22:10 -08:00
Ava Chow
e53310c47a
Merge bitcoin/bitcoin#30529: Fix -norpcwhitelist, -norpcallowip, and similar corner case behavior
a85e8c0e6158fad2408bda5cb1e36da707eb081b doc: Add some general documentation about negated options (Ryan Ofsky)
490c8fa17829c3f8ae4da739f526531c91f3ed87 doc: Add release notes summarizing negated option behavior changes. (Ryan Ofsky)
458ef0a11b57cb5af0e8903b50927723fbb3fcd6 refactor: Avoid using IsArgSet() on -connect list option (Ryan Ofsky)
752ab9c3c65e47fc05545d9b9c919be945851d51 test: Add test to make sure -noconnect disables -dnsseed and -listen by default (Ryan Ofsky)
3c2920ec98fc7d9f77abfd08fea17211b9ca7099 refactor: Avoid using IsArgSet() on -signetseednode and -signetchallenge list options (Ryan Ofsky)
d05668922a28e4e2c78dab2d4737433cd52d6302 refactor: Avoid using IsArgSet() on -debug, -loglevel, and -vbparams list options (Ryan Ofsky)
3d1e8ca53a05e7d4735a2207d1b200e1dcddc534 Normalize inconsistent -noexternalip behavior (Ryan Ofsky)
ecd590d4c1e7f310c6ba3b58373bc30679b491df Normalize inconsistent -noonlynet behavior (Ryan Ofsky)
5544a19f863737518944950fc73f97d9c1399a46 Fix nonsensical bitcoin-cli -norpcwallet behavior (Ryan Ofsky)
6e8e7f433fc3f753a20833aebe54692cdfe5ed75 Fix nonsensical -noasmap behavior (Ryan Ofsky)
b6ab3508064cd3135e1a356c884ae1269cda5250 Fix nonsensical -notest behavior (Ryan Ofsky)
6768389917a8d744f1b1ada4556d3d4fe63c310e Fix nonsensical -norpcwhitelist behavior (Ryan Ofsky)
e03409c70f7472d39e45d189df6c0cf6b676b761 Fix nonsensical -norpcbind and -norpcallowip behavior (Ryan Ofsky)
40c4899bc209921fb4bde02840359c3253663766 Fix nonsensical -nobind and -nowhitebind behavior (Ryan Ofsky)
5453e66fd91c303d04004d861ecad183ff177823 Fix nonsensical -noseednode behavior (Ryan Ofsky)

Pull request description:

  The PR changes behavior of negated `-noseednode`, `-nobind`, `-nowhitebind`, `-norpcbind`, `-norpcallowip`, `-norpcwhitelist`, `-notest`, `-noasmap`, `-norpcwallet`, `-noonlynet`, and `-noexternalip` options, so negating these options just clears previously specified values doesn't have other side effects.

  Negating options on the command line can be a useful way of resetting options that may have been set earlier in the command line or config file. But before this change, negating these options wouldn't fully reset them, and would have confusing and undocumented side effects (see commit descriptions for details). Now, negating these options just resets them and behaves the same as not specifying them.

  Motivation for this PR is to fix confusing behaviors and also to remove incorrect usages of the `IsArgSet()` function. Using `IsArgSet()` tends to lead to negated option bugs in general, but it especially causes bugs when used with list settings returned by `GetArgs()`, because when these settings are negated, `IsArgSet()` will return true but `GetArgs()` will return an empty list. This PR eliminates all uses of `IsArgSet()` and `GetArgs()` together, and followup PR #17783 makes it an error to use `IsArgSet()` on list settings, since calling `IsArgSet()` is never actually necessary. Most of the changes here were originally made in #17783 and then moved here to be easier to review and avoid a dependency on #16545.

ACKs for top commit:
  achow101:
    ACK a85e8c0e6158fad2408bda5cb1e36da707eb081b
  danielabrozzoni:
    re-ACK a85e8c0e6158fad2408bda5cb1e36da707eb081b
  hodlinator:
    re-ACK a85e8c0e6158fad2408bda5cb1e36da707eb081b

Tree-SHA512: dd4b19faac923aeaa647b1c241d929609ce8242b43e3b7bc32523cc48ec92a83ac0dc5aee79f1eba8794535e0314b96cb151fd04ac973671a1ebb9b52dd16697
2025-02-14 15:10:09 -08:00
Ava Chow
0b48f77e10
Merge bitcoin/bitcoin#31413: rpc: Remove deprecated dummy alias for listtransactions::label
fa8e0956c23789fb819ad1b31377711df091ec1b rpc: Remove deprecated dummy alias for listtransactions::label (MarcoFalke)

Pull request description:

  The RPC arg is not a dummy, but a label, so offering an undocumented alias is inconsistent with all other label interfaces and confusing at best, if not entirely unused.

  Fix it by removing the deprecated alias.

  This pull is a breaking change, but it should be limited, because it only affects someone using the deprecated named arg on this RPC. I can't imagine anyone doing this, because in all other places where label args are accepted, they are called `label`. If someone really didn't use `label` here as named arg, it would be trivial and less confusing for them to fix it up.

ACKs for top commit:
  achow101:
    ACK fa8e0956c23789fb819ad1b31377711df091ec1b
  rkrux:
    tACK fa8e0956c23789fb819ad1b31377711df091ec1b
  ryanofsky:
    Code review ACK fa8e0956c23789fb819ad1b31377711df091ec1b

Tree-SHA512: 0d0f3f53237ff9fac8c065b7d0a4245f5ff86efa427dbeeca711765494b7315a9d72b44751d346c76422847daf3d7ff90dbccb5ba200b089fb96128bd95da9f0
2025-02-14 13:29:17 -08:00
Ava Chow
21a0efaf8c
Merge bitcoin/bitcoin#29858: test: Add test for rpcwhitelistdefault
f0e5e4cdbec4df190c952d5a61d7a882a7e3b59e test: Add test for rpcwhitelistdefault (naiyoma)

Pull request description:

  This PR adds tests for `rpcwhitelistdefault.` The implementation is a continuation of this [PR](https://github.com/bitcoin/bitcoin/pull/17805).

  Applied suggestions  to include the tests in` rpc_whitelist.py` and to use a single node.

  PR covers three test cases:
  - rpcwhitelistdefault = 0, no permissions
  - rpcwhitelistdefault = 1, no permissions
  - rpcwhitelistdefault = 1, with user permissions

  I didn't add tests for rpcwhitelistdefault = 0 with user permissions since that is already tested here: [rpc_whitelist.py#L77](https://github.com/bitcoin/bitcoin/blob/master/test/functional/rpc_whitelist.py#L77).

ACKs for top commit:
  achow101:
    ACK f0e5e4cdbec4df190c952d5a61d7a882a7e3b59e
  ryanofsky:
    Code review ACK f0e5e4cdbec4df190c952d5a61d7a882a7e3b59e. PR seems very clear and simple, moving 1 test and adding 3 new tests.
  ismaelsadeeq:
    Tested and Code review ACK f0e5e4cdbec4df190c952d5a61d7a882a7e3b59e

Tree-SHA512: c3652940d2f23746e769ebe834e43dee47b7af8f258cbb133e38663aa8a05a1a8d0194d3008c3a10b0c54d11b5b95420c9cad0aa761c0fc1b9559277443b0696
2025-02-14 11:27:01 -08:00