forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
backport: merge bitcoin#23497 (Add src/node/ and src/wallet/ code to node:: and wallet:: namespaces)
#6732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We will do this primarily for Dash-specific code
Split out as a separate commit as NodeContext is more pervasively used in Dash-specific code
This commit will not compile on its own, the commit after adjusts the rest of the codebase around this commit and should be compilable. Some files have been excluded as they're not in the `node::` namespace upstream.
Continuation of prior commit, should compile successfully.
This commit will not compile on its own, the commit after adjusts the rest of the codebase around this commit and should be compilable. Some files have been excluded as they're not a good fit for the namespace (particularly BIP39-specific code).
Continuation of prior commit, should compile successfully.
PastaPastaPasta
approved these changes
Jun 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK ab9ba84
UdjinM6
approved these changes
Jun 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK ab9ba84
PastaPastaPasta
added a commit
that referenced
this pull request
Jul 14, 2025
, bitcoin#25005, bitcoin#25410, bitcoin#24236, bitcoin#25438, bitcoin#25036, bitcoin#25489, bitcoin#25544, bitcoin#25594, bitcoin#13226, partial bitcoin#25218, bitcoin#26005 (wallet backports: part 6) 175970e merge bitcoin#13226: Optimize SelectCoinsBnB by tracking the selection by index rather than by position (Kittywhiskers Van Gogh) 27933a7 merge bitcoin#25594: Return BResult from restoreWallet (Kittywhiskers Van Gogh) b75f1ad partial bitcoin#26005: Fix error handling (copy_file failure in RestoreWallet, and in general via interfaces) (Kittywhiskers Van Gogh) 9f5845c partial bitcoin#25218: introduce generic 'Result' class and connect it to CreateTransaction and GetNewDestination (Kittywhiskers Van Gogh) db7e174 merge bitcoin#25544: don't iter twice when getting the cached debit/credit amount (Kittywhiskers Van Gogh) 48f5c10 merge bitcoin#25489: change `ScanForWalletTransactions` to use `Ticks(Dur2 d)` (Kittywhiskers Van Gogh) 4aafd98 merge bitcoin#25036: Save wallet scan progress (Kittywhiskers Van Gogh) e2f053a merge bitcoin#25438: remove unused methods in classes `CDBIterator,CDBWrapper,CCoinsViewDBCursor` (Kittywhiskers Van Gogh) 79fcd30 merge bitcoin#24236: Remove utxo db upgrade code (Kittywhiskers Van Gogh) d13ff52 fix: use URL quoting for password fields due to Base64 in pre-v0.12.2.x (Kittywhiskers Van Gogh) 7b6af94 fix: allow argument-free RPC calls with nodes running v0.12.2.x and lower (Kittywhiskers Van Gogh) 1026f11 fix: make `get_previous_release.py` translate triples for pre-v0.12.2.x (Kittywhiskers Van Gogh) a0b2c7d fix: make `get_previous_releases.py` understand windows target triples (Kittywhiskers Van Gogh) 51237c9 merge bitcoin#25410: fix warning: "argument name 'feerate' in comment does not match parameter name" (Kittywhiskers Van Gogh) 2438b9f merge bitcoin#25005: remove extra wtx lookup in 'AvailableCoins' + several code cleanups (Kittywhiskers Van Gogh) a498336 refactor: use initializer to set `nCoinType` instead of manual assignment (Kittywhiskers Van Gogh) ae24276 merge bitcoin#25083: Set effective_value when initializing a COutput (Kittywhiskers Van Gogh) a883a8e merge bitcoin#24666: Fix coinselection.h include, Make COutput a struct (Kittywhiskers Van Gogh) f447b5d merge bitcoin#24711: Postpone wallet loading notification for encrypted wallets (Kittywhiskers Van Gogh) 39557f9 fix: include `BOOST_AUTO_TEST_SUITE_END` within namespace `wallet` (Kittywhiskers Van Gogh) Pull request description: ## Additional Information * When backporting [bitcoin#23497](bitcoin#23497) (see [dash#6732](#6732)), some `BOOST_AUTO_TEST_SUITE_END()`s were placed _outside_ the `wallet` namespace scope, which resulted in incorrect behavior when rebasing this pull request over [dash#6732](#6732). This has been resolved. * Backports of [bitcoin#25083](bitcoin#25083) and [bitcoin#25005](bitcoin#25005) do not include changes to `wallet/rpc/spend.cpp` as the `sendall()` RPC has not been implemented in `develop` (f453998) as of this writing. * Backporting [bitcoin#24236](bitcoin#24236) required a fair number of additional considerations, firstly because the pull request introduces a test, `feature_unsupported_utxo_db.py`, that requires the last-capable of version Dash Core to generate a legacy UTXO database (the current database format debuted in [dash#1701](#1701), included in v0.12.2.2) and secondly, because v0.15 is the earliest expected version of Dash Core to work smoothly with our test framework ([source](https://github.com/dashpay/dash/blob/f453998bb76dee8fe016138da664dc281fc7f1d3/test/functional/mempool_compatibility.py#L29)). As we require the last release cycle that generates the legacy UTXO database by default, we used the last version of the v0.12.1.x family, v0.12.1.5 as the old node used in `feature_unsupported_utxo_db.py`. This brings unique challenges which are elaborated on below. * The test framework relies on `generatetoaddress`, a wallet-independent RPC call that was introduced in [bitcoin#7671](bitcoin#7671) to replace the old wallet-dependent `generate` RPC. It was backported as 760d58e in [dash#1790](#1790) and debuted in v0.12.3. We cannot use the `self.generate()` helper as simply dispatches a `generatetoaddress` ([source](https://github.com/dashpay/dash/blob/f453998bb76dee8fe016138da664dc281fc7f1d3/test/functional/test_framework/test_node.py#L343-L345)), which does not exist in v0.12.1.5. We work around this by using the more archaic `self.nodes[0].rpc.generate()`, in line with usage in `rpc_generate.py` ([source](https://github.com/dashpay/dash/blob/f453998bb76dee8fe016138da664dc281fc7f1d3/test/functional/rpc_generate.py#L25-L26)). * Releases before v0.12.3.x did not include the target triples in their naming convention (see tag [`v0.12.3.1`](https://github.com/dashpay/dash/releases/tag/v0.12.3.1) vs [`v0.12.1.5`](https://github.com/dashpay/dash/releases/tag/v0.12.1.5)), which causes problems when fetching packages based on the target `HOST` of the build environment. This has been remedied by introducing awareness for `RPi2`, `osx` and `linux{32,64}` labels. * Note, `RPi2` corresponds to `arm-linux-gnueabihf` based on the Gitian descriptor that was removed in [dash#2183](#2183) ([source](https://github.com/dashpay/dash/blob/dac090964fbdd96d896f725932aada71db736abf/contrib/gitian-descriptors/gitian-rpi2.yml#L26)) * This was also taken as an opportunity to introduce awareness for the `win32` and `win64` labels which persist even now (see tag [`v22.1.2`](https://github.com/dashpay/dash/releases/tag/v22.1.2)) * Currently, when we want to make RPC calls without arguments, a blank object is sent to by the RPC dispatcher. This is acceptable as objects are supported since [bitcoin#8811](bitcoin#8811) (backported as eb7a6b0 in [dash#1851](#1858)), included in v0.12.3. Unfortunately, since we are dealing with a version of Dash that is ancient even by previous release standards, this prevents the dispatcher from even acknowledging the RPC server is active (see below). <details> <summary>Test failure:</summary> ``` $ ./test/functional/feature_unsupported_utxo_db.py 2025-06-24T15:06:53.642000Z TestFramework (INFO): PRNG seed is: 1995903613070947610 2025-06-24T15:06:53.642000Z TestFramework (INFO): Initializing test directory /tmp/dash_func_test_1tqzf43o 2025-06-24T15:06:53.642000Z TestFramework (INFO): Create previous version (v0.12.1.5) utxo db 2025-06-24T15:06:53.895000Z TestFramework (ERROR): JSONRPC error Traceback (most recent call last): File "/home/eclair/Repositories/dashpay/dash/test/functional/test_framework/test_framework.py", line 161, in main self.run_test() File "/home/eclair/Repositories/dashpay/dash/./test/functional/feature_unsupported_utxo_db.py", line 35, in run_test self.start_node(0) File "/home/eclair/Repositories/dashpay/dash/test/functional/test_framework/test_framework.py", line 647, in start_node node.wait_for_rpc_connection() File "/home/eclair/Repositories/dashpay/dash/test/functional/test_framework/test_node.py", line 276, in wait_for_rpc_connection rpc.getblockcount() File "/home/eclair/Repositories/dashpay/dash/test/functional/test_framework/coverage.py", line 49, in __call__ return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/eclair/Repositories/dashpay/dash/test/functional/test_framework/authproxy.py", line 144, in __call__ raise JSONRPCException(response['error'], status) test_framework.authproxy.JSONRPCException: Params must be an array (-32600) 2025-06-24T15:06:53.947000Z TestFramework (INFO): Stopping nodes [...] ``` </details> * This is worked around by dispatching an empty array instead of an empty object, it has the same practical effect (conveying the lack of arguments) and is forwards-compatible. * Currently, the password used for RPC authentication in Base16 encoded. This is a result of [dash#1454](#1454), which switched away from Base64. Unfortunately, this benefit only extends to v0.12.2.0 onwards, which is too new for the old node needed in our functional test. Worse still, it was not the URL-safe variant of Base64, so attempting to establish a connection with the old node resulted in sporadic failures (see below). <details> <summary>Test failure:</summary> ``` $ ./test/functional/feature_unsupported_utxo_db.py 2025-06-24T15:13:27.517000Z TestFramework (INFO): PRNG seed is: 3228606794541395700 2025-06-24T15:13:27.518000Z TestFramework (INFO): Initializing test directory /tmp/dash_func_test_97d987gf 2025-06-24T15:13:27.518000Z TestFramework (INFO): Create previous version (v0.12.1.5) utxo db 2025-06-24T15:13:27.769000Z TestFramework (ERROR): Unexpected exception caught during testing Traceback (most recent call last): File "/home/eclair/Repositories/dashpay/dash/test/functional/test_framework/test_framework.py", line 161, in main self.run_test() File "/home/eclair/Repositories/dashpay/dash/./test/functional/feature_unsupported_utxo_db.py", line 35, in run_test self.start_node(0) File "/home/eclair/Repositories/dashpay/dash/test/functional/test_framework/test_framework.py", line 647, in start_node node.wait_for_rpc_connection() File "/home/eclair/Repositories/dashpay/dash/test/functional/test_framework/test_node.py", line 270, in wait_for_rpc_connection rpc = get_rpc_proxy( ^^^^^^^^^^^^^^ File "/home/eclair/Repositories/dashpay/dash/test/functional/test_framework/util.py", line 341, in get_rpc_proxy proxy = AuthServiceProxy(url, **proxy_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/eclair/Repositories/dashpay/dash/test/functional/test_framework/authproxy.py", line 78, in __init__ authpair = user + b':' + passwd ~~~~~^~~~~~ TypeError: unsupported operand type(s) for +: 'NoneType' and 'bytes' 2025-06-24T15:13:27.822000Z TestFramework (INFO): Stopping nodes [...] ``` </details> * This is worked around by escaping URL special characters for the password field. It is practically a no-op for the Base16 passwords generated from v0.12.2.0 onwards but allows connection and authentication with older versions of Dash Core. ## How Has This Been Tested? A full CoinJoin session run on 89cd497  ## Breaking Changes None expected. ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation **(note: N/A)** - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK 175970e PastaPastaPasta: utACK 175970e Tree-SHA512: 6a6fe593e25cc5c99da41333a334655010cc387f8c3e390d472de29782aaa6aa67276e2e00a90609facabe4f1817fa0152e6b6765f97e07541fd378ef0f4d566
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Additional Information
bitcoin#23497 was merged upstream in v0.23. As of this writing, the backport backlog for v0.23 is at ~91% completion. This change, while conflict-prone, is long-overdue as we have been backporting pull requests from v0.24 onwards that assume these namespaces and so far we've simply "cut out" those portions to allow those backports to be completed.
bitcoin-chainstate(see bitcoin#24304 and onwards), that are invested in these separation of concerns.Due to the increased usage of namespacing, to avoid potential
-Werror=thread-safety-analysisissues (see below), the usage ofcs_mainneeds to be disambiguated as being a part of the global namespace, to that effect, changes have been made to ensure that in Dash-specific code and anywhere else needed to quell compiler errors.Build error:
Some commits have been split out to ease in the review process, due to the nature of changes, except for
NodeContext(node/context.{cpp,h}), they could not be done on a file-to-file basis as it would create substantial diffs that would then be reverted in the next commit, which would make review harder.25.xbranch upstream for changes affecting upstream code not present during the backport (source) and compiler output for Dash-specific code.Checklist