-
Notifications
You must be signed in to change notification settings - Fork 784
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
Block: make blockchain mandatory in validation methods #942
Conversation
de24a45
to
ce69603
Compare
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. |
block: update validate docs block: update tests, add mockchain
2a862b6
to
6a21940
Compare
Rebased this one! |
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.
this lgtm! nice idea for making the mock blockchain
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.
Thanks, great! 👍
This PR:
blockchain
parameter mandatory invalidate
methods ofBlock
andBlockHeader
validateData
method toBlock
Hoists theextraData
check to the constructor ofBlockHeader
Rationale:
If you called
validate
inBlockHeader
without ablockchain
, the only check which is being done is checking thatextraData.length
is within the current bounds of the maximumextraData
. This can give consumers the false idea that the header is correct, but the method does practically nothing.Validate is now explicitly used to
validate
against the parentBlockHeader
(orBlock
). There is an additional function inBlock
which has the logic which does not needblockchain
in case a consumer does have a block but no access to a blockchain. (We cannot do all this in the constructor of the Block, as we need access to Trie here which is async).Note: hoisting the
extraData
check to the constructor makes the Ethash test fail, will open an issue for this, looks like this data is invalid (?). See #943This mandatory
blockchain
parameter is necessary in #933, this PR simply ensures that we make this parameter mandatory so we can work on this uncle validation logic in the future.