refactor: reduce usage of chainstate globals in Dash-specific logic#5531
Merged
Conversation
kwvg
force-pushed
the
chainstate_deglob
branch
4 times, most recently
from
August 6, 2023 17:53
e6c2c1e to
8a4d988
Compare
See bitcoin#12401 and surrounding discussion
kwvg
force-pushed
the
chainstate_deglob
branch
from
August 19, 2023 18:56
8a4d988 to
7a932c1
Compare
kwvg
marked this pull request as ready for review
August 20, 2023 06:20
knst
reviewed
Aug 20, 2023
5 tasks
`deterministicMNManager` requires a chain to be initialized for its database upgrade logic and `BasicTestingSetup` doesn't initialize one
kwvg
force-pushed
the
chainstate_deglob
branch
2 times, most recently
from
August 21, 2023 07:14
92b2216 to
1d6d97a
Compare
kwvg
force-pushed
the
chainstate_deglob
branch
from
August 21, 2023 14:57
1d6d97a to
48a8fdf
Compare
UdjinM6
pushed a commit
that referenced
this pull request
Aug 22, 2023
## Issue being fixed or feature implemented The order of members in a class/struct definition and the order of their initialization should match. This ensures that the code is more error-proof in cases where the order of member initializations is important, as they may depend on each other. Instead manual checking of member initialization better let CI handle it. Last PR where it's noticed: #5531 (comment) ## What was done? New flag "-Werror=reorder" for `configure.ac` and fixes existing code. ## How Has This Been Tested? Build code with `--enable-werror` ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone
PastaPastaPasta
approved these changes
Aug 23, 2023
PastaPastaPasta
left a comment
Member
There was a problem hiding this comment.
utACK for squash merge
5 tasks
PastaPastaPasta
added a commit
that referenced
this pull request
Dec 17, 2024
…ng sequence between {,non-}unittest codepaths)
1974651 refactor: move remaining `LogPrintf` usage outside (Kittywhiskers Van Gogh)
04dbaa8 style-only: Remove redundant scope in *Chainstate (Kittywhiskers Van Gogh)
872158d Remove all #include // for * comments (Kittywhiskers Van Gogh)
09ab629 test/setup: Use LoadChainstate (Kittywhiskers Van Gogh)
459f339 node/chainstate: extract Dash post-`InitializeChainstate` logic (Kittywhiskers Van Gogh)
c06e074 node/chainstate: Add options for in-memory DBs (Kittywhiskers Van Gogh)
52bb35d node/caches: Remove intermediate variables (Kittywhiskers Van Gogh)
4ab1827 node/caches: Extract cache calculation logic (Kittywhiskers Van Gogh)
d7f1e23 validation: VerifyDB only needs Consensus::Params (Kittywhiskers Van Gogh)
c405492 node/chainstate: Decouple from ShutdownRequested (Kittywhiskers Van Gogh)
fdf803d node/chainstate: Decouple from GetTime (Kittywhiskers Van Gogh)
f7aef8d init: Delay RPC block notif until warmup finished (Kittywhiskers Van Gogh)
94c0ceb Move -checkblocks LogPrintf to AppInitMain (Kittywhiskers Van Gogh)
d3345ee node/chainstate: Reduce coupling of LogPrintf (Kittywhiskers Van Gogh)
a141f5d node/chainstate: Decouple from concept of uiInterface (Kittywhiskers Van Gogh)
913411e Split off VerifyLoadedChainstate (Kittywhiskers Van Gogh)
53231ca node/chainstate: Remove do/while loop (Kittywhiskers Van Gogh)
2ea1bbc Move init logistics message for BAD_GENESIS_BLOCK to init.cpp (Kittywhiskers Van Gogh)
29c7362 Move mempool nullptr Assert out of LoadChainstate (Kittywhiskers Van Gogh)
7071282 node/chainstate: Decouple from concept of NodeContext (Kittywhiskers Van Gogh)
ee9d3dd node/chainstate: Decouple from ArgsManager (Kittywhiskers Van Gogh)
d7419e4 node/chainstate: Decouple from stringy errors (Kittywhiskers Van Gogh)
9ab08c4 node/chainstate: Decouple from GetTimeMillis (Kittywhiskers Van Gogh)
2455c06 node: Extract chainstate loading sequence (Kittywhiskers Van Gogh)
620146b chore: sync chainstate loading logic with upstream (Kittywhiskers Van Gogh)
Pull request description:
## Additional Information
* Dependent on #6296
* Dependent on #6443
* As one of the backport's intentions were to unify code between `init.cpp` and `setup_common.cpp`, Dash-specific initialization code (to the extent that it can be moved out non-disruptively) has been spun out into `DashChainstateSetup{,Close}()` so it can also be used in `setup_common.cpp` and `validation_chainstatemanager_tests.cpp`.
This is also why `DashTestSetup{,Close}()` (now `DashPostChainstateSetup{,Close}()`) was introduced in [dash#5531](#5531).
* `DashChainstateSetup{,Close}()` (as defined in `node/chainstate.cpp`) cannot take `NodeContext` in because `node/chainstate.cpp` is used in `bitcoin-chainstate`, which doesn't include `NodeContext` ([source](https://github.com/bitcoin/bitcoin/pull/24304/files#diff-4cb884d03ebb901069e4ee5de5d02538c40dd9b39919c615d8eaa9d364bbbd77R795-R798)), this is reflected by neither `LoadChainstate` nor `VerifyLoadedChainstate` taking in `NodeContext`.
* To make it less onerous to use in unit tests, `DashChainstateSetup{,Close}()` has been overloaded with a variant that accepts `NodeContext`.
* To remove `LogPrintf` usage in `node/chainstate.cpp`, index enablement reporting has been pulled out of chainstate loading and BLS scheme reporting has been abstracted out using `notify_bls_state`.
## 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 **(note: N/A)**
- [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 1974651
PastaPastaPasta:
utACK 1974651
Tree-SHA512: 8ebfce48dccc6a867339aff9374a4cb8dc7b02b0c17432db2b97c982523d0d9589a87e6527a103f314bf32be176486311ef6dcde1c4d5cdccc1eeb1f80bbb040
ab4cus
pushed a commit
to ab4cus/e4Coin-core
that referenced
this pull request
Jul 8, 2026
## Issue being fixed or feature implemented The order of members in a class/struct definition and the order of their initialization should match. This ensures that the code is more error-proof in cases where the order of member initializations is important, as they may depend on each other. Instead manual checking of member initialization better let CI handle it. Last PR where it's noticed: dashpay/dash#5531 (comment) ## What was done? New flag "-Werror=reorder" for `configure.ac` and fixes existing code. ## How Has This Been Tested? Build code with `--enable-werror` ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone
ab4cus
pushed a commit
to ab4cus/e4Coin-core
that referenced
this pull request
Jul 8, 2026
…ng sequence between {,non-}unittest codepaths)
7113b24 refactor: move remaining `LogPrintf` usage outside (Kittywhiskers Van Gogh)
6d0e109 style-only: Remove redundant scope in *Chainstate (Kittywhiskers Van Gogh)
c5f9689 Remove all #include // for * comments (Kittywhiskers Van Gogh)
cb27702 test/setup: Use LoadChainstate (Kittywhiskers Van Gogh)
7c6c420 node/chainstate: extract Dash post-`InitializeChainstate` logic (Kittywhiskers Van Gogh)
514f280 node/chainstate: Add options for in-memory DBs (Kittywhiskers Van Gogh)
80cf449 node/caches: Remove intermediate variables (Kittywhiskers Van Gogh)
4907eb6 node/caches: Extract cache calculation logic (Kittywhiskers Van Gogh)
be7d4f8 validation: VerifyDB only needs Consensus::Params (Kittywhiskers Van Gogh)
278a7e2 node/chainstate: Decouple from ShutdownRequested (Kittywhiskers Van Gogh)
d7fcfd7 node/chainstate: Decouple from GetTime (Kittywhiskers Van Gogh)
615e15a init: Delay RPC block notif until warmup finished (Kittywhiskers Van Gogh)
0f50205 Move -checkblocks LogPrintf to AppInitMain (Kittywhiskers Van Gogh)
6a3918d node/chainstate: Reduce coupling of LogPrintf (Kittywhiskers Van Gogh)
ef21541 node/chainstate: Decouple from concept of uiInterface (Kittywhiskers Van Gogh)
ba106d9 Split off VerifyLoadedChainstate (Kittywhiskers Van Gogh)
767b84d node/chainstate: Remove do/while loop (Kittywhiskers Van Gogh)
160ebf7 Move init logistics message for BAD_GENESIS_BLOCK to init.cpp (Kittywhiskers Van Gogh)
0e5f73e Move mempool nullptr Assert out of LoadChainstate (Kittywhiskers Van Gogh)
56784e7 node/chainstate: Decouple from concept of NodeContext (Kittywhiskers Van Gogh)
812fc1d node/chainstate: Decouple from ArgsManager (Kittywhiskers Van Gogh)
0cf7399 node/chainstate: Decouple from stringy errors (Kittywhiskers Van Gogh)
ade906a node/chainstate: Decouple from GetTimeMillis (Kittywhiskers Van Gogh)
440c886 node: Extract chainstate loading sequence (Kittywhiskers Van Gogh)
8e31314 chore: sync chainstate loading logic with upstream (Kittywhiskers Van Gogh)
Pull request description:
## Additional Information
* Dependent on dashpay/dash#6296
* Dependent on dashpay/dash#6443
* As one of the backport's intentions were to unify code between `init.cpp` and `setup_common.cpp`, Dash-specific initialization code (to the extent that it can be moved out non-disruptively) has been spun out into `DashChainstateSetup{,Close}()` so it can also be used in `setup_common.cpp` and `validation_chainstatemanager_tests.cpp`.
This is also why `DashTestSetup{,Close}()` (now `DashPostChainstateSetup{,Close}()`) was introduced in [dash#5531](dashpay/dash#5531).
* `DashChainstateSetup{,Close}()` (as defined in `node/chainstate.cpp`) cannot take `NodeContext` in because `node/chainstate.cpp` is used in `bitcoin-chainstate`, which doesn't include `NodeContext` ([source](https://github.com/bitcoin/bitcoin/pull/24304/files#diff-4cb884d03ebb901069e4ee5de5d02538c40dd9b39919c615d8eaa9d364bbbd77R795-R798)), this is reflected by neither `LoadChainstate` nor `VerifyLoadedChainstate` taking in `NodeContext`.
* To make it less onerous to use in unit tests, `DashChainstateSetup{,Close}()` has been overloaded with a variant that accepts `NodeContext`.
* To remove `LogPrintf` usage in `node/chainstate.cpp`, index enablement reporting has been pulled out of chainstate loading and BLS scheme reporting has been abstracted out using `notify_bls_state`.
## 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 **(note: N/A)**
- [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 7113b24
PastaPastaPasta:
utACK 7113b24
Tree-SHA512: 8ebfce48dccc6a867339aff9374a4cb8dc7b02b0c17432db2b97c982523d0d9589a87e6527a103f314bf32be176486311ef6dcde1c4d5cdccc1eeb1f80bbb040
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
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.
No description provided.