-
Notifications
You must be signed in to change notification settings - Fork 37.7k
DEPENDENT: API: Expose bitcoinconsensus_verify_header() in libconsensus #5995
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
75b466c
to
3e23de9
Compare
e6adb85
to
f086046
Compare
Needed rebase |
|
||
#include <algorithm> | ||
|
||
static const unsigned int MEDIAN_TIME_SPAN = 11; |
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.
IMHO this could get 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.
Feel free to suggest something. Probably better to comment in the smaller PRs for now as this branch will likely require more rebases and force pushes. In this case, the relevant PR is #6009
8ce53eb
to
7e0cd14
Compare
from main.cpp: -CheckBlockHeader -ContextualCheckBlockHeader -IsSuperMajority from pow.cpp: -CalculateNextWorkRequired -CheckProofOfWork -GetNextWorkRequired
7e0cd14
to
00b9b22
Compare
I realized this is mostly unreadable until something similar to #6048 is merged. |
To extend libconsensus' functionality, I propose to add
bitcoinconsensus_verify_header()
the partial checksCheckBlockHeader()
andContextualCheckBlockHeader
could be exposed as well.Unlike VerifyScript, VerifyBlockHeader depends on the nodes storage, as it requires data from the blockchain previous to the header being verified. How to exactly interface that data with VerifyBlockHeader can be a delicate matter and it should be of course open to discussion. Here there's just one proposal.
The offending dependency is CBlockIndex in chain.o, specially CBlockIndex::pprev which is a pointer to another object. All the other dependencies unacceptable for libconsensus have been removed first, to make things easier for someone who wants to propose to solve that final problem in some other way.
Dependencies:
-MOVEONLY: Move most consensus function declarations to consensus/consensus.h #6048
-Consensus: Refactor: Consensus version of CheckBlockHeader() #6035
-Separate CValidationState from main #5669
-Chainparams: Refactor: Decouple IsSuperMajority from Params() #5968
-Consensus: Decouple ContextualCheckBlockHeader from checkpoints #5975
-Consensus: Turn CBlockIndex::GetMedianTimePast into independent function #6009
-Consensus: Consensus version of pow functions #6037