-
Notifications
You must be signed in to change notification settings - Fork 457
✨ verifyBlockHash + toShortHeader #1483
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
✨ verifyBlockHash + toShortHeader #1483
Conversation
|
|
||
| // cast block 23270177 --raw | ||
| // vm.getRawBlockHeader(23270177) | ||
| bytes private constant _ETH_BLOCK_23270177 = |
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.
Fork tests are preferred, not sure how you handle them though.
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.
Need to bump forge-std to support vm.getRawBlockHeader.
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.
i think we’ll just fake it for now.
when we are really free, we can add a CI that does fork testing.
| /// @solidity memory-safe-assembly | ||
| assembly { | ||
| calldatacopy(mload(0x40), header.offset, header.length) | ||
| if iszero(eq(result, keccak256(mload(0x40), header.length))) { |
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.
Is xor more efficient here than iszero + eq?
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.
not for here, i think.
|
anything else needed on this? |
* ✨ verifyBlockHash + toShortHeader (#1483) Co-authored-by: clandestine.eth <[email protected]>
Description
Adds minimal block header utilities for state proofs + light client implementations.
Added
BlockHashLib.verifyBlockHash(blockHeader, blockNumber)Validates RLP-encoded headers against
BlockHashLib.blockHash(blockNumber).Added
BlockHashLib.toShortHeader(blockHeader):Efficiently extracts relevant fields from RLP-encoded block headers for MPT proof verification, without full RLP-decoding.
Checklist
Ensure you completed all of the steps below before submitting your pull request:
forge fmt?forge test?Pull requests with an incomplete checklist will be thrown out.