-
Notifications
You must be signed in to change notification settings - Fork 37.7k
[refactor] Fix the chainparamsbase -> util circular dependency #13639
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
Conversation
bbc6d2d
to
6640590
Compare
Note to reviewers: This pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
+1 for going after another dependency cycle :) Extracting Does it make sense to refactor the dependency of Line 8 in 9b638c7
This relationship seems the crux to the circular dependency to me. Imo util should have as little dependencies as possible.
|
Agree on minimizing |
6640590
to
3461ebd
Compare
Dropped the third commit and extracted #13690 for easier review. |
33539cb Extract MakeUnique into utilmemory.h (Ben Woosley) Pull request description: And use it to reduce chainparamsbase.cpp's and remove interfaces/handler.cpp's reliance on util.h This is a step toward fixing the chainparamsbase -> util circular dependency. Confirmed no need for the util.h include via iwyu and visual inspection. Extracted from #13639 for easier review. Tree-SHA512: 61cbf9eafb68c3e3706d21c70aeb0586a85364dad32cc49c2d40e963ac3b2c44424ad1522788a0a6b2a689fd9294ebce4482a392ceb88a94eabe09a84f070ce4
0504a02
to
6ebcfab
Compare
Rebased for #13690 |
6ebcfab
to
a216630
Compare
Ran clang-format |
a216630
to
73219c8
Compare
Rebased for #13695 |
I don't think moving the arguments for chain selection to util is the right solution here. Why does util depend on knowing something about chain parameters anyway? It's supposed to be a bunch of utility functions. |
What about moving argsmanager to a separate module? |
I'll look into that, thanks! |
These two were being set together in all cases. Using just one removes the internal reliance of chainparamsbase on gArgs in this case. Instead expose GetRPCPort and GetDataDir methods, which can be called with the m_network name stored by gArgs.
253e66b
to
af5754e
Compare
Ok I looked deeper into this and moved to a more comprehensive approach. The story is, there exist an This is functionally equivalent and simpler in implementation than the prior alternative. While |
What remains of CBaseChainParams is just a namespace for the network name strings.
af5754e
to
5194e16
Compare
5194e16
to
0579015
Compare
A possible follow-up - replacing the string-based handling with an enum class: https://github.com/Empact/bitcoin/compare/chainparamsbase-circ...Empact:chain-enum-class?expand=1 |
These options are intimately tied to ArgsManager::GetChainName, so their presence here makes sense, and moving them removes the final cause for a circular dependency between util and chainparamsbase.
0579015
to
9847689
Compare
33539cb Extract MakeUnique into utilmemory.h (Ben Woosley) Pull request description: And use it to reduce chainparamsbase.cpp's and remove interfaces/handler.cpp's reliance on util.h This is a step toward fixing the chainparamsbase -> util circular dependency. Confirmed no need for the util.h include via iwyu and visual inspection. Extracted from bitcoin#13639 for easier review. Tree-SHA512: 61cbf9eafb68c3e3706d21c70aeb0586a85364dad32cc49c2d40e963ac3b2c44424ad1522788a0a6b2a689fd9294ebce4482a392ceb88a94eabe09a84f070ce4
33539cb Extract MakeUnique into utilmemory.h (Ben Woosley) Pull request description: And use it to reduce chainparamsbase.cpp's and remove interfaces/handler.cpp's reliance on util.h This is a step toward fixing the chainparamsbase -> util circular dependency. Confirmed no need for the util.h include via iwyu and visual inspection. Extracted from bitcoin#13639 for easier review. Tree-SHA512: 61cbf9eafb68c3e3706d21c70aeb0586a85364dad32cc49c2d40e963ac3b2c44424ad1522788a0a6b2a689fd9294ebce4482a392ceb88a94eabe09a84f070ce4
33539cb Extract MakeUnique into utilmemory.h (Ben Woosley) Pull request description: And use it to reduce chainparamsbase.cpp's and remove interfaces/handler.cpp's reliance on util.h This is a step toward fixing the chainparamsbase -> util circular dependency. Confirmed no need for the util.h include via iwyu and visual inspection. Extracted from bitcoin#13639 for easier review. Tree-SHA512: 61cbf9eafb68c3e3706d21c70aeb0586a85364dad32cc49c2d40e963ac3b2c44424ad1522788a0a6b2a689fd9294ebce4482a392ceb88a94eabe09a84f070ce4
33539cb Extract MakeUnique into utilmemory.h (Ben Woosley) Pull request description: And use it to reduce chainparamsbase.cpp's and remove interfaces/handler.cpp's reliance on util.h This is a step toward fixing the chainparamsbase -> util circular dependency. Confirmed no need for the util.h include via iwyu and visual inspection. Extracted from bitcoin#13639 for easier review. Tree-SHA512: 61cbf9eafb68c3e3706d21c70aeb0586a85364dad32cc49c2d40e963ac3b2c44424ad1522788a0a6b2a689fd9294ebce4482a392ceb88a94eabe09a84f070ce4
33539cb Extract MakeUnique into utilmemory.h (Ben Woosley) Pull request description: And use it to reduce chainparamsbase.cpp's and remove interfaces/handler.cpp's reliance on util.h This is a step toward fixing the chainparamsbase -> util circular dependency. Confirmed no need for the util.h include via iwyu and visual inspection. Extracted from bitcoin#13639 for easier review. Tree-SHA512: 61cbf9eafb68c3e3706d21c70aeb0586a85364dad32cc49c2d40e963ac3b2c44424ad1522788a0a6b2a689fd9294ebce4482a392ceb88a94eabe09a84f070ce4
By moving gArgs references out of chainparamsbase.cpp.
Note both chainparams.cpp, bitcoin-cli.cpp, and all callers of
SetupChainParamsBaseOptions include util.h