-
Notifications
You must be signed in to change notification settings - Fork 37.7k
[Consensus] Add nAdjustedTime parameter to CheckBlock and CheckBlockHeader. #7985
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
Moves both functions closer to being pure.
Concept ACK. |
utACK b3a9f85 |
utACK |
utACK b3a9f85 |
utACK b3a9f85 |
utACK b3a9f85 (maybe this could be taken even further, I'm not sure what you're rationale is to stop at e.g. ConnectBlock but not TestBlockValidity, but it's a good start) |
@laanwj I was trying to fuzz these two functions and was unable to do so easily. In the near future I'm certain I'll have the same issue elsewhere. |
@@ -3212,20 +3212,20 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne | |||
return true; | |||
} | |||
|
|||
bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW) | |||
bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, int64_t nAdjustedTime, bool fCheckPOW) |
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.
If it's not too late for bikeshedding...all the times I've tried to do this, I've named the variable nTime instead of nAdjustedTime. Not important, but would make https://github.com/jtimon/bitcoin/commits/jt easier to rebase to 0.13...
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.
except... it's actually the adjusted time
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.
Whatever...no big deal
Can you also pass Consensus::Params like in #7947 ? The diff shouldn't grow much and it would save us from changing exactly the same lines twice. Should also be better for fuzzing. |
@jtimon I made a decision not to pass Params() to keep the commit clean and obviously correct. |
IMO the commit will remain clean and obviously correct. It's currently +11 -11, and I predict it to become +15 -13 or less. |
@jtimon Nope I think this is as much change as I want to be in this PR. |
If we do the thing in 2 steps, it will be about 2 commits +11 -11. |
Opened #8077 which also does ContextualCheckBlockHeader (+16 -17). I believe that's still clean and obviously correct (even if the scope is bigger). |
#8077 has been merged. |
Moves both functions closer to being pure.
I want this to improve my fuzzing results.