-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Chainparams: Explicit Consensus::Params arg for almost all remaining functions #6163
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
utACK |
9c92da0
to
273606b
Compare
273606b
to
16ccaef
Compare
Needed rebase (2) |
16ccaef
to
bf790b2
Compare
ping |
ut ACK |
Asking a dumb but sincere question: why? These parameters are global and constant to main, the module being modified. This change appears to add parameters for little apparent gain. Is this an intermediate step to the code being moved to libconsensus? |
Well, these are actually the methods that are not required for libconsensus but still use Consensus::Params. Passing it explicitly as a parameter is also good for testing. Eventually we should be able to remove this line: https://github.com/bitcoin/bitcoin/blob/master/src/test/test_bitcoin.cpp#L36 #5970 is closed but contains this and more of the same, to get a better view of what all this is about. |
bf790b2
to
48c8e9d
Compare
Needed rebase. (3) |
@@ -2264,6 +2267,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo | |||
* that is already loaded (to avoid loading it again from disk). | |||
*/ | |||
bool ActivateBestChain(CValidationState &state, const CBlock *pblock) { | |||
const CChainParams& chainparams = Params(); | |||
CBlockIndex *pindexNewTip = NULL; | |||
CBlockIndex *pindexMostWork = NULL; | |||
const CChainParams& chainParams = Params(); |
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.
Dup of +L2270?
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.
How did this even compile?
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.
chainparams != chainParams (mind the uppercase P).
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.
@jtimon s/chainparams/chainParams/g
might be in order 👍
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.
Oops, lost in rebase.
Thanks @jonasschnelli @dcousens for the extremely fast and helpful review. I will force push this and #5970 with the fix.
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.
I'm going to maintain chainparams instead of chainParams for uniformity across the codebase.
When @theuni asked me #XXXX not to use "params" for both CChainParams and Consensus::Params I used "consensusParams" and "chainparams", but he meant "chainParams" (btw pow.cpp still uses "params" #5812, no big deal).
Now I'm afraid is too late for chainParams, even if he used that in one of his improvements to the checkpoints code #YYYY.
I can dig all the PR numbers if anyone is interested, but I don't have them at hand.
Sorry for the misunderstanding between theuni and me, mostly my fault since I was the listener.
I don't think theuni is married to chainParams, I'm sure he's fine with chainparams, he seemed mostly concerned about using the same variable name for 2 different types, I was just removing "Params()." all around.
48c8e9d
to
99112df
Compare
@jonasschnelli 's nit solved, faster with the help of @dcousens . |
99112df
to
0aac17a
Compare
Tested ACK (ran unit tests, did fiddle around with it in regtest). |
@@ -2063,13 +2064,14 @@ static int64_t nTimePostConnect = 0; | |||
* corresponding to pindexNew, to bypass loading it again from disk. | |||
*/ | |||
bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, const CBlock *pblock) { | |||
const CChainParams& chainparams = Params(); |
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.
Nit, why did you opt for chainparams
over chainParams
? camelCase is used consistently for most other variables.
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.
Yep, but chainparams is used in more places than chainParams (my fault) so it seems too late. I explained this in more detail here: #6163 (comment)
utACK and concept ACK |
0aac17a
to
f3ace17
Compare
Needed rebase (4). |
f3ace17
to
4b8de76
Compare
Rebased (4). |
4b8de76
to
7d9057a
Compare
Needs to fix https://github.com/bitcoin/bitcoin/blob/master/src/zmq/zmqpublishnotifier.cpp#L149 et al as well. |
7d9057a
to
b8fb6c2
Compare
-CheckBlockIndex -DisconnectTip -GetTransaction -InvalidateBlock -ProcessGetData -ReadBlockFromDisk
ad15ff6
to
87cbdb8
Compare
@MarcoFalke Yep, that's all I could see in travis, but I wanted to build src/zmq/zmqpublishnotifier.o locally before squashing. Squashing now... |
87cbdb8 Globals: Explicit Consensus::Params arg for main: (Jorge Timón)
..and at the same time prevent AcceptBlockHeader() from calling global function Params()
Bitcoin Core refactoring and cleanups 1 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#5994 - bitcoin/bitcoin#6538 - bitcoin/bitcoin#6163 - bitcoin/bitcoin#6982 - bitcoin/bitcoin#6986 - bitcoin/bitcoin#7053 - bitcoin/bitcoin#7444 - bitcoin/bitcoin#7793 - Excluding some comments in `txmempool.h` on code we haven't yet pulled in. - bitcoin/bitcoin#7916 - bitcoin/bitcoin#7815 Additionally, the Equihash parameters are moved into the consensus parameters. Part of #2074.
Bitcoin Core refactoring and cleanups 1 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#5994 - bitcoin/bitcoin#6538 - bitcoin/bitcoin#6163 - bitcoin/bitcoin#6982 - bitcoin/bitcoin#6986 - bitcoin/bitcoin#7053 - bitcoin/bitcoin#7444 - bitcoin/bitcoin#7793 - Excluding some comments in `txmempool.h` on code we haven't yet pulled in. - bitcoin/bitcoin#7916 - bitcoin/bitcoin#7815 Additionally, the Equihash parameters are moved into the consensus parameters. Part of #2074.
Bitcoin Core refactoring and cleanups 1 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#5994 - bitcoin/bitcoin#6538 - bitcoin/bitcoin#6163 - bitcoin/bitcoin#6982 - bitcoin/bitcoin#6986 - bitcoin/bitcoin#7053 - bitcoin/bitcoin#7444 - bitcoin/bitcoin#7793 - Excluding some comments in `txmempool.h` on code we haven't yet pulled in. - bitcoin/bitcoin#7916 - bitcoin/bitcoin#7815 Additionally, the Equihash parameters are moved into the consensus parameters. Part of #2074.
Bitcoin Core refactoring and cleanups 1 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#5994 - bitcoin/bitcoin#6538 - bitcoin/bitcoin#6163 - bitcoin/bitcoin#6982 - bitcoin/bitcoin#6986 - bitcoin/bitcoin#7053 - bitcoin/bitcoin#7444 - bitcoin/bitcoin#7793 - Excluding some comments in `txmempool.h` on code we haven't yet pulled in. - bitcoin/bitcoin#7916 - bitcoin/bitcoin#7815 Additionally, the Equihash parameters are moved into the consensus parameters. Part of #2074.
Bitcoin Core refactoring and cleanups 1 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#5994 - bitcoin/bitcoin#6538 - bitcoin/bitcoin#6163 - bitcoin/bitcoin#6982 - bitcoin/bitcoin#6986 - bitcoin/bitcoin#7053 - bitcoin/bitcoin#7444 - bitcoin/bitcoin#7793 - Excluding some comments in `txmempool.h` on code we haven't yet pulled in. - bitcoin/bitcoin#7916 - bitcoin/bitcoin#7815 Additionally, the Equihash parameters are moved into the consensus parameters. Part of #2074.
Bitcoin Core refactoring and cleanups 1 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6538 - bitcoin/bitcoin#6163 - bitcoin/bitcoin#6982 - bitcoin/bitcoin#6986 - bitcoin/bitcoin#7053 - bitcoin/bitcoin#7444 - bitcoin/bitcoin#7793 - Excluding some comments in `txmempool.h` on code we haven't yet pulled in. - bitcoin/bitcoin#7916 - bitcoin/bitcoin#7815 Additionally, the Equihash parameters are moved into the consensus parameters, and various other functions in `main.cpp` have `const CChainParams&` arguments added. Part of #2074.
Bitcoin Core refactoring and cleanups 1 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6538 - bitcoin/bitcoin#6163 - bitcoin/bitcoin#6982 - bitcoin/bitcoin#6986 - bitcoin/bitcoin#7053 - bitcoin/bitcoin#7444 - bitcoin/bitcoin#7793 - Excluding some comments in `txmempool.h` on code we haven't yet pulled in. - bitcoin/bitcoin#7916 - bitcoin/bitcoin#7815 Additionally, the Equihash parameters are moved into the consensus parameters, and various other functions in `main.cpp` have `const CChainParams&` arguments added. Part of #2074.
Bitcoin Core refactoring and cleanups 1 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6538 - bitcoin/bitcoin#6163 - bitcoin/bitcoin#6982 - bitcoin/bitcoin#6986 - bitcoin/bitcoin#7053 - bitcoin/bitcoin#7444 - bitcoin/bitcoin#7793 - Excluding some comments in `txmempool.h` on code we haven't yet pulled in. - bitcoin/bitcoin#7916 - bitcoin/bitcoin#7815 Additionally, the Equihash parameters are moved into the consensus parameters, and various other functions in `main.cpp` have `const CChainParams&` arguments added. Part of #2074.
Bitcoin Core refactoring and cleanups 1 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6538 - bitcoin/bitcoin#6163 - bitcoin/bitcoin#6982 - bitcoin/bitcoin#6986 - bitcoin/bitcoin#7053 - bitcoin/bitcoin#7444 - bitcoin/bitcoin#7793 - Excluding some comments in `txmempool.h` on code we haven't yet pulled in. - bitcoin/bitcoin#7916 - bitcoin/bitcoin#7815 Additionally, the Equihash parameters are moved into the consensus parameters, and various other functions in `main.cpp` have `const CChainParams&` arguments added. Part of #2074.
Explicitly pass Consensus::Params to functions:
-CheckBlockIndex
-DisconnectTip
-GetTransaction
-InvalidateBlock
-ProcessGetData
-ReadBlockFromDisk
Without counting the following consensus functions (which is done in #6591):
-CheckBlockHeader
-CheckBlock
-ContextualCheckBlockHeader
-ContextualCheckBlock
These are all the functions that use Consensus::Params but not CChainParams.