-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Pow: Remove fCheckPOW from CheckBlockHeader #9717
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
|
Rather rename it to |
|
I'm all for unifying CheckBlockHeader with CheckProofOfWork in pow.o, but one step at a time. Currently the only difference between CheckProofOfWork and CheckBlockHeader and thus prevent from unifying the two functions are:
We can rename CheckBlockHeader to CheckProofOfWork, CheckBlockPoW or whatever, no problem. |
|
utACK. I'm not strongly in favor of this change though, given that if more functionality gets added to checkblockheader ever you would want to add fCheckPOW again. I am opposed to the other changes mentioned, ie, making checkproofofwork add the dos scores, seems better to keep checkproofofwork a pure function. |
|
If there are plans to add more functionality back to this functions (which I wouldn't oppose too), and I can only think that you are referring to this check https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L2967 then we definitely don't want either this PR or @luke-jr 's suggestion of going further and fully remove CheckBlockHeader in one step. But if we don't plan to put that code back there, then the fCheckPOW parameter doesn't make any sense in CheckBlockHeader. Better is better. This was supposed to be the simplest fix for something that honestly looks embarrassing when I think of reviewers reading this function without looking at the history or thinking about https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L2967 . Let's please first decide whether we want to remove fCheckPOW from this function or we want to bring the check After this, as @luke-jr points out CheckBlockHeader is just a wrapper for CheckProofOfWork but passing CValidationState. An option would be to remove it, another option would be to use CValidationState or maybe put it in https://github.com/bitcoin/bitcoin/blob/master/src/script/script_error.h (and maybe rename script_error.h to consensus/errors.o too, who knows). But if we can't decide whether fCheckPOW here is pointless or not (and I don't want to bet, but maybe the compiler has already decided for us at a lower level), I don't want to put more decisions in the same PR. @luke-jr @JeremyRubin Does that sound reasonable to you? For more context: At the same time, I understand neither this nor #9177 are a priority for bitcoin core itself, since I believe it is unlikely #9177 will ever be merged on mainnet unless I find a way that doesn't affect performance at all on mainchain and at the same time is not very disruptive (which as said I believe it's unlikely). It would be very useful for rebasing elements to have #9177 completed and merged in bitcoin core, but bitcoin core shouldn't care about that since not all it's users care about elements. PS: Sorry for the text wall, this shouldn't happen in a +4-4 PR. |
|
utACK 7b3b201 If needed later, can add again. |
|
Agree with @NicolasDorier - if This seems to be strictly an improvement, so utACK 7b3b201. |
|
@NicolasDorier @jnewbery By "CheckBlockHeader() can be added back if needed" I understand that you're not only ok with this but also with inlining CheckBlockHeader as suggested by @luke-jr in a future PR and therefore not bringing the MAX_FUTURE_BLOCK_TIME check back from ContextualCheckBlockHeader to CheckBlockHeader in the foreseeable future. |
|
@jtimon yes, I am fine with both. Indeed no much point to have CheckBlockHeader anymore after this PR. |
|
We can also pass the blockHash to CheckBlockHeader, that would make it closer to CheckProofOfWork, which I imagine would be more interesting to @luke-jr ? |
|
utACK 7b3b201 |
|
utACK 7b3b201, good simplification. |
7b3b201 to
9855eca
Compare
|
Sorry, forgot to make the function static while at it. |
|
utACK 9855ecaf880840a42f2a9678dc6d9e753c11c531. Only change since last review is making the function static. |
|
This seems like it is ready to be merged. It's very minor, 4 people acked it, and #10339 depends on it. |
|
NACK, there is no value in doing this, and it only makes the code less readable because it conflates the block header with the PoW. |
|
@luke-jr so lets just remove CheckBlockHeader instead and call CheckProofOfWork where we need to? |
|
@TheBlueMatt I don't see how that's an improvement, but at least it sounds non-confusing, and as such I wouldn't object. |
9855eca to
eb1e328
Compare
|
Needed rebase. Rebased on top of #10339 instead of the other way around.
I'm confused, I thought removing CheckBlockHeader was your preference #9717 (comment)
Right now they are the same thing (except for CValidationState and the fDontDoAnything param that this PR tries to remove). |
I'd rather that than making the code more confusing, but I don't see how either change is useful.
They are conceptually different things. If we add an additional check to CheckBlockHeader, we would not expect it to also be skipped when PoW checks are skipped. |
ryanofsky
left a comment
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.
utACK eb1e328e86d46d74121e8254114363115b6c854c. I don't know if this an improvement or not, but change seems fine if others want it.
eb1e328 to
b93cf78
Compare
|
Sorry, removed the commit from #10339 again.
It is useful because it simplifies an interface that is more complex than it needs to be. Currently, if you're calling the function with fCheckPOW=false (could as well be named fActuallyDoSomethingWhenCallingThisFunction), you can just not call it.
This argument actually makes sense to me. If you had specific examples it would be much simpler for me to close this PR. If you don't, I think your opposition to this PR is unreasonable. |
|
A specific example we could put there right now, would be to check the nVersion is >0. But either way, they are still conceptually different things, and so long as it says |
Thank you. I guess that would currently be an optimization. mhmm, didn't we used to check that block.version > 0 in ContextualCheckBlockHeader ? where are we checking it now? If in the future we want to use the "hardfork bit" to signal hardforks, I think ContextualCheckBlockHeader is the right place (assuming the hf is coordinated with bip9/bip8). Do you have more examples? An example of something that we currently don't validate would serve. |
|
ping this, is it really controversial or only for @luke-jr ? |
|
Closing for now, but don't discard to reopen if I ever touch or review the header of main::CheckBlockHeader again, my fault or not. |
After the time checks were removed from CheckBlockHeader,
, bool fCheckPOWmakes no sense.Nobody is calling it with fCheckPOW=false and if they were, they could simply not call CheckBlockHeader.