Skip to content

Conversation

qiweiii
Copy link
Contributor

@qiweiii qiweiii commented Aug 7, 2025

Motivation

closes #11144

Add rlp related cheats as requested in the issue

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Comment on lines +2950 to +2955
/// 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);
Copy link
Member

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

Copy link
Collaborator

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?

Copy link
Contributor Author

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

Copy link
Contributor

@0xClandestine 0xClandestine Sep 25, 2025

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.

@DaniPopes DaniPopes marked this pull request as draft August 12, 2025 09:30
import "ds-test/test.sol";
import "cheats/Vm.sol";

contract Rlp is DSTest {
Copy link
Contributor

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:

  1. Use cast block <some_block> --raw to get the raw rlp encoded block header for some given block.
  2. Set the value above as a test constant (e.g. bytes header = hex"...";)
  3. Use cast block <some_block> --json to get the blocks decoded fields.
  4. Compare decoded RLP encoded block header to known hardcoded field values from previous step.

NOTES:

  • Block headers contain all fields within this struct in the order they're defined.
  • Here's an example example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiweiii bump

@grandizzy
Copy link
Collaborator

@qiweiii would oyu have time to drive this to the finish line? if not we can take it over, thank you

@qiweiii
Copy link
Contributor Author

qiweiii commented Oct 2, 2025

sry pls take it, since I won't have time until next week

@0xrusowsky 0xrusowsky marked this pull request as ready for review October 2, 2025 14:55
@0xrusowsky 0xrusowsky moved this to Ready For Review in Foundry Oct 2, 2025
@0xrusowsky 0xrusowsky changed the title add RLP cheats feat(cheats): RLP Oct 2, 2025
@0xrusowsky 0xrusowsky requested a review from mattsse October 2, 2025 15:01
Copy link
Contributor

@0xClandestine 0xClandestine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

feat(cheats): add RLP related cheats
5 participants