Skip to content

refactor: Remove ::Params() global from CChainState#21789

Merged
fanquake merged 2 commits into
bitcoin:masterfrom
maflcko:2104-ChainstateParamsRefactor
Jun 29, 2021
Merged

refactor: Remove ::Params() global from CChainState#21789
fanquake merged 2 commits into
bitcoin:masterfrom
maflcko:2104-ChainstateParamsRefactor

Conversation

@maflcko

@maflcko maflcko commented Apr 27, 2021

Copy link
Copy Markdown
Member

The ::Params() global is verbose and confusing. Also it makes tests a bit harder to write because they'd have to mock a global.

Fix all issues by simply using a member variable that points to the right params.

(Can be reviewed with --word-diff-regex=.)

@maflcko
maflcko force-pushed the 2104-ChainstateParamsRefactor branch from fa5915e to fad0c2a Compare April 27, 2021 18:51
@jamesob

jamesob commented Apr 27, 2021

Copy link
Copy Markdown
Contributor

Concept ACK, will review soon

@practicalswift

Copy link
Copy Markdown
Contributor

Concept ACK

1 similar comment
@fanquake

Copy link
Copy Markdown
Member

Concept ACK

@maflcko
maflcko force-pushed the 2104-ChainstateParamsRefactor branch from fad0c2a to fa4b981 Compare April 28, 2021 05:08
@DrahtBot

DrahtBot commented Apr 28, 2021

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

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.

Comment thread src/validation.h Outdated
@kiminuo

kiminuo commented Apr 28, 2021

Copy link
Copy Markdown
Contributor

Concept ACK.

It looks like a very nice simplification which makes it harder to make a mistake.

@DrahtBot

DrahtBot commented May 3, 2021

Copy link
Copy Markdown
Contributor

🕵️ @sipa has been requested to review this pull request as specified in the REVIEWERS file.

Comment thread src/chain.h Outdated
@kiminuo

kiminuo commented Jun 3, 2021

Copy link
Copy Markdown
Contributor

The main change in the first commit (fa216cc7) seems to be: "refactor: Add CChainState member to CChainState class" rather than "refactor: Remove ::Params() global from CChainState".

Also, the changes like this fa216cc#diff-97c3a52bc5fad452d82670a7fd291800bae20c7bc35bb82686c2c0a4ea7b5b98R2284 in the first commit (fa216cc7) can probably be moved to the second commit (fa06aaacf3b9c35d9e30c883bcd7780dcf0bceda) so that the first commit would only introduce m_params.

Changes in fa216cc79267ba25fa3709982626def61f4abe2a & fa06aaacf3b9c35d9e30c883bcd7780dcf0bceda LGTM.

@jnewbery

jnewbery commented Jun 9, 2021

Copy link
Copy Markdown
Contributor

Concept ACK

@maflcko

maflcko commented Jun 10, 2021

Copy link
Copy Markdown
Member Author

I think the two commits are nicely split up. The first one removes it from inside the functions, the second removes the arg of the functions.

@maflcko
maflcko force-pushed the 2104-ChainstateParamsRefactor branch from faa72ee to 2222da8 Compare June 10, 2021 09:49
@jnewbery

Copy link
Copy Markdown
Contributor

ACK 2222da832066d06be3ff8752e49008fef71eb668

Comment thread src/test/util/setup_common.cpp Outdated
MarcoFalke added 2 commits June 13, 2021 09:39
…ctions

It is confusing and verbose to repeatedly access the global when a
member variable can simply refer to it.
Passing this is confusing and redundant with the m_params member.
@maflcko
maflcko force-pushed the 2104-ChainstateParamsRefactor branch from 2222da8 to fa0d921 Compare June 13, 2021 07:44
@maflcko

maflcko commented Jun 14, 2021

Copy link
Copy Markdown
Member Author

Rebased

@jnewbery

Copy link
Copy Markdown
Contributor

ACK fa0d921

@kiminuo

kiminuo commented Jun 14, 2021

Copy link
Copy Markdown
Contributor

utACK fa0d921

for (int i = 0; i < 10; ++i) {
BlockValidationState state;
m_node.chainman->ActiveChainstate().InvalidateBlock(state, Params(), active.Tip());
m_node.chainman->ActiveChainstate().InvalidateBlock(state, active.Tip());

@kiminuo kiminuo Jun 14, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is #include <chainparams.h> still needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, will try to remove if I have to force push

@theStack theStack left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK fa0d921 🍉
Nice refactoring idea, glad to see this simplification of the CChainState interface.

@fanquake
fanquake merged commit 8071ec1 into bitcoin:master Jun 29, 2021
@maflcko
maflcko deleted the 2104-ChainstateParamsRefactor branch June 29, 2021 06:39
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jun 29, 2021
gwillen pushed a commit to ElementsProject/elements that referenced this pull request Jun 1, 2022
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
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