Skip to content

Conversation

jtimon
Copy link
Contributor

@jtimon jtimon commented May 19, 2015

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.

@jtimon jtimon changed the title Chainparams: Explicit Consensus::Params arg for main: Chainparams: Explicit Consensus::Params arg for almost all remaining functions May 19, 2015
@laanwj
Copy link
Member

laanwj commented May 20, 2015

utACK

@jtimon
Copy link
Contributor Author

jtimon commented Jun 2, 2015

Needed rebase after merging #5669 and #6173 (1)

@jtimon jtimon force-pushed the chainparams-remaining-consensus branch from 273606b to 16ccaef Compare June 21, 2015 12:10
@jtimon
Copy link
Contributor Author

jtimon commented Jun 21, 2015

Needed rebase (2)

@jtimon
Copy link
Contributor Author

jtimon commented Jul 4, 2015

ping

@theuni
Copy link
Member

theuni commented Jul 22, 2015

ut ACK

@jgarzik
Copy link
Contributor

jgarzik commented Jul 23, 2015

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?

@jtimon
Copy link
Contributor Author

jtimon commented Jul 23, 2015

Well, these are actually the methods that are not required for libconsensus but still use Consensus::Params.
This is part of a bigger process of making CChainParams being explicitly passed as a const reference instead of using the Params() function all around. Basically that function is a way to hide a global that @theuni and I want to take out of chainparams.

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.
Some of the changes there are no longer necessary because other PRs have kindly incorporated it when they were changing the function's parameters already.

@jtimon
Copy link
Contributor Author

jtimon commented Aug 20, 2015

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dup of +L2270?

Copy link
Contributor

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?

Copy link
Contributor

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).

Copy link
Contributor

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 👍

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@jtimon jtimon force-pushed the chainparams-remaining-consensus branch from 48c8e9d to 99112df Compare August 27, 2015 09:01
@jtimon
Copy link
Contributor Author

jtimon commented Aug 27, 2015

@jonasschnelli 's nit solved, faster with the help of @dcousens .

@jtimon jtimon force-pushed the chainparams-remaining-consensus branch from 99112df to 0aac17a Compare August 27, 2015 09:13
@jonasschnelli
Copy link
Contributor

Tested ACK (ran unit tests, did fiddle around with it in regtest).
Gitian build: https://builds.jonasschnelli.ch/pulls/6163/

@@ -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();
Copy link
Contributor

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.

Copy link
Contributor Author

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)

@dcousens
Copy link
Contributor

utACK and concept ACK

@jtimon jtimon force-pushed the chainparams-remaining-consensus branch from 0aac17a to f3ace17 Compare October 20, 2015 17:40
@jtimon
Copy link
Contributor Author

jtimon commented Oct 20, 2015

Needed rebase (4).

@jtimon jtimon force-pushed the chainparams-remaining-consensus branch from f3ace17 to 4b8de76 Compare October 30, 2015 11:24
@jtimon
Copy link
Contributor Author

jtimon commented Oct 30, 2015

Rebased (4).

@jtimon jtimon force-pushed the chainparams-remaining-consensus branch from 4b8de76 to 7d9057a Compare October 30, 2015 11:31
@maflcko
Copy link
Member

maflcko commented Oct 30, 2015

@jtimon jtimon force-pushed the chainparams-remaining-consensus branch from 7d9057a to b8fb6c2 Compare October 30, 2015 12:24
-CheckBlockIndex
-DisconnectTip
-GetTransaction
-InvalidateBlock
-ProcessGetData
-ReadBlockFromDisk
@jtimon jtimon force-pushed the chainparams-remaining-consensus branch from ad15ff6 to 87cbdb8 Compare October 30, 2015 13:07
@jtimon
Copy link
Contributor Author

jtimon commented Oct 30, 2015

@MarcoFalke Yep, that's all I could see in travis, but I wanted to build src/zmq/zmqpublishnotifier.o locally before squashing. Squashing now...

@laanwj laanwj merged commit 87cbdb8 into bitcoin:master Nov 10, 2015
laanwj added a commit that referenced this pull request Nov 10, 2015
87cbdb8 Globals: Explicit Consensus::Params arg for main: (Jorge Timón)
jtimon added a commit to jtimon/bitcoin that referenced this pull request Nov 11, 2015
..and at the same time prevent AcceptBlockHeader() from calling global function Params()
laanwj added a commit that referenced this pull request Nov 11, 2015
7267843 Globals: Make AcceptBlockHeader static (Fix #6163) (Jorge Timón)
zkbot added a commit to zcash/zcash that referenced this pull request Mar 10, 2018
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.
zkbot added a commit to zcash/zcash that referenced this pull request Apr 6, 2018
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.
zkbot added a commit to zcash/zcash that referenced this pull request May 31, 2018
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.
zkbot added a commit to zcash/zcash that referenced this pull request Oct 24, 2018
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.
zkbot added a commit to zcash/zcash that referenced this pull request Oct 25, 2018
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.
zkbot added a commit to zcash/zcash that referenced this pull request Apr 5, 2019
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.
zkbot added a commit to zcash/zcash that referenced this pull request Apr 9, 2019
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.
zkbot added a commit to zcash/zcash that referenced this pull request May 24, 2019
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.
zkbot added a commit to zcash/zcash that referenced this pull request May 28, 2019
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 bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants