-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Globals: TODO: Experiment: Kill "Params()" #7829
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
Well I just did :) I'll take a crack at these in a few weeks (if no one else beats me to it) once I get more time. |
subscribing, concept ACK |
d486a45
to
3bbfb65
Compare
Thank you @achow101 and @kirkalx for showing interest! As predicted, #7828 has been rapidly merged. Please subscribe to that It was also the first dependency in the list, so now I can cross it from the list, great! this PR/issue gets closer to get closed without being merged. I expect you pick one of them (I suggest ConnectBlock() as the next easiest one), create your PR for it and say it here so that I link to your PR in the dependency list for that one. If somebody wants to do more than one, that's fine, I'm not worried about running out of ideas to tell other people to do yet. But I suggest waiting for the first you open to be merged before opening another one. These changes are generally good and likely to be merged, but they're not a priority. So if you try to do too much of this at once you may end up suffering what is known as a "rebase mouse-wheel" (forgive me, I can't remember who I heard this term from). If you don't mind needing to rebase more times, fine. |
Updated the dependency list: replaced 2 TODO items with #7916. |
concept ACK |
3bbfb65
to
d3711c9
Compare
d3711c9
to
e908d34
Compare
Rebased and updated to TODO list. Added AcceptToMemoryPoolWorker() and ReceivedBlockTransactions(). Also replaced CheckBlockHeader, CheckBlock and ContextualCheckBlockHeader with a single line for #8077 (merged). |
e908d34
to
ee29a60
Compare
Rebased on top of #8413 which is very easy to review (hint to new contributors: reviewing is important too both for the project and for learning yourself). |
Concept ACK, but I think that for functions which are not part of consensus, there is not a lot to earn by removing Params() call. |
This is not to be merged, but for new devs to get ideas from (and I promise review. Outside of consensus...Params () is still equivalent to using the global it's hiding directly. Globals are bad. |
ee29a60
to
eb8b082
Compare
Needed rebase. Also added a couple of new commits. |
eb8b082
to
f03df4a
Compare
Rebased, added #8975 |
Hey there! I just made a pull request #9013 for LoadBlockIndexDB() on your TODO list. I'm new to contributing so please let me know if there's anything I've done incorrectly! |
Thank you! |
f03df4a
to
b06cc58
Compare
b06cc58
to
7cb4880
Compare
Added #9176 to the list and rebased |
7cb4880
to
7827573
Compare
Needs to rebase on top of #9176 but the TODO comments are still there. |
7827573
to
9776919
Compare
9776919
to
93d038d
Compare
Rebased and added more ideas. Not sure if maybe adding some of them to #9176 which doesn't seem to be interesting enough on its own. As the only reviewer, thoughts @mrbandrews ? |
- ReceivedBlockTransactions - AcceptToMemoryPoolWorker - AcceptToMemoryPoolWithTime also pass Consensus::Params to them directly
- CWallet::ScanForWalletTransactions - CWallet::CreateWalletFromFile and InitLoadWallet also make CWallet::CreateWalletFromFile private
Both validation::AcceptToMemoryPool() and CMerkleTx::AcceptToMemoryPool
93d038d
to
9b00b07
Compare
Thanks for all participants in this experiment, I hope you learned from it. Anyone feel free to ping me for review for more things in here or similar simple things for people to start contributing, but the interest has been decaying and there's no point on keep rebasing this or keeping it open. Closing. |
I think this is a good way to go, but better done in smaller, fast to review PR. |
Dependencies (and list of things TODO):
- [ ] Globals: Explicitly pass const CChainParams& to UpdateTip() #7876- [ ] Globals: DisconnectTip() requires the full CChainParams, not just Consensus::Params (depends on #7876)- [ ] Make functions in validation.cpp static: #10227Trivial: Globals: Explicitly pass const CChainParams& to ProcessMessage() Trivial: Globals: Explicitly pass const CChainParams& to ProcessMessage() #7828
Explicitly pass CChainParams& to DisconnectTip() Explicitly pass CChainParams& to DisconnectTip() #7916 (does UpdateTip() DisconnectTip() and InvalidateBlock() at once)
Consensus: Decouple from chainparams.o and timedata.o Consensus: Decouple from chainparams.o and timedata.o #8077 [CheckBlockHeader, CheckBlock, ContextualCheckBlockHeader]
Trivial: pass Consensus::Params& instead of CChainParams& in ContextualCheckBlock Trivial: pass Consensus::Params& instead of CChainParams& in ContextualCheckBlock #8413
Chainparams: Trivial: In AppInit2(), s/Params()/chainparams/ Chainparams: Trivial: In AppInit2(), s/Params()/chainparams/ #8975
Trivial: Explicitly pass const CChainParams& to LoadBlockIndexDB() Trivial: Explicitly pass const CChainParams& to LoadBlockIndexDB() #9013
pass Consensus::Params& to functions in validation.cpp and make them static pass Consensus::Params& to functions in validation.cpp and make them static #10201
Globals: Pass Consensus::Params through CBlockTreeDB::LoadBlockIndexGuts() Globals: Pass Consensus::Params through CBlockTreeDB::LoadBlockIndexGuts() #9176 [0.13-chainparams-loadblockindexguts]
ConnectBlock()
FlushStateToDisk()
LoadMempool()
ProcessMessages() [not trivial]
SendMessages() [not trivial]
IsInitialBlockDownload() (disruptive)
Explicitly pass const CChainParams and Consensus::Params() in net.cpp (several functions)
"I opened this PR so that newcomers to the Bitcoin Core project could make simple changes to get familiar with contributing to Bitcoin Core. I have marked a number of TODO comments in the source code of this pull request. The changes listed here are not critical to the project but they are good introductory material. Each TODO is relatively simple, and more experienced developers are busy doing other tasks, making this an excellent chance for you to get feedback from me on basic contributions to Bitcoin Core. Hopefully this will help you streamline submissions to Core, please let me know how I can help."
We can slowly turn the global pCurrentParams (hidden behind the function "Params()" for no good reason) into a CChainParams& parameter wherever is needed. This will take very long and I won't be done by one single person. I'm pretty convinced that everybody agrees with this in general, so it should be relatively easy to get your based-on-this-PR merged. But I'm here, just ask.
You may be interested in this PR because:
What would you have to do:
Simple: force me to remove TODO lines from this PR, one function at a time if possible.
PROMISES:
If you force me to replace any TODO line in this PR, and you're open for nits in your own PR, I promise:
Once a month (at least):
@laanwj please, take this as an open issue that is going to last for long. Just with code [but, still, never to merge no matter how much I change it].
Continues #6173 #6163 #6024 (closed) #5054 and friends.