-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(cheats): RLP #11232
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
base: master
Are you sure you want to change the base?
feat(cheats): RLP #11232
Conversation
/// RLP encodes a list of bytes into an RLP payload. | ||
#[cheatcode(group = Utilities)] | ||
function toRlp(bytes[] calldata data) external pure returns (bytes memory); | ||
/// RLP decodes an RLP payload into a list of bytes. | ||
#[cheatcode(group = Utilities)] | ||
function fromRlp(bytes calldata rlp) external pure returns (bytes[] memory data); |
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.
unsure how useful this really is because this can only bytes
but imo these dont really hurt
any opinions here @grandizzy
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 is good for a start and then we could improve, @qiweiii wonder though why it is marked as breaking change?
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.
you mean in pr checklist? It should not, I just removed it
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.
@mattsse @grandizzy This is perfect for now, can just abi encode/decode each element which can be abstracted away by helper methods.
import "ds-test/test.sol"; | ||
import "cheats/Vm.sol"; | ||
|
||
contract Rlp is DSTest { |
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.
Would like to see the following test:
- Use
cast block <some_block> --raw
to get the raw rlp encoded block header for some given block. - Set the value above as a test constant (e.g.
bytes header = hex"...";
) - Use
cast block <some_block> --json
to get the blocks decoded fields. - Compare decoded RLP encoded block header to known hardcoded field values from previous step.
NOTES:
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.
@qiweiii bump
@qiweiii would oyu have time to drive this to the finish line? if not we can take it over, thank you |
sry pls take it, since I won't have time until next week |
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.
LGTM! 🚀
Motivation
closes #11144
Add rlp related cheats as requested in the issue
PR Checklist