Component
Forge
Describe the feature you would like
It would be useful imo to add RLP encoding/decoding related cheats, mirroring the functionality already available in cast via cast to-rlp and cast from-rlp. This would allow contracts to easily manage RLP data in tests without relying on external libraries or tooling.
/// @dev RLP encodes a list of `data` into an rlp payload.
function toRlp(bytes[] calldata data) public pure returns (bytes memory);
/// @dev RLP decodes an `rlp` payload into a list of `data`.
function fromRlp(bytes calldata rlp) public pure returns (bytes[] memory data);
Rather than bytes[] calldata data it may be cleaner to simply take in bytes calldata abiEncoded so usage becomes:
bytes memory rlpPayload = vm.toRlp(abi.encode(item0, item1, item2...));
(bytes item0, uint256 item1, address item2, ...) = abi.decode(vm.fromRlp(rlpPayload), (bytes, uint256, address);
Worth noting the abi.encode pattern might be annoying if you don't want to parse all elements.
Additional context
No response
Component
Forge
Describe the feature you would like
It would be useful imo to add RLP encoding/decoding related cheats, mirroring the functionality already available in
castviacast to-rlpandcast from-rlp. This would allow contracts to easily manage RLP data in tests without relying on external libraries or tooling.Rather than
bytes[] calldata datait may be cleaner to simply take inbytes calldata abiEncodedso usage becomes:Worth noting the
abi.encodepattern might be annoying if you don't want to parse all elements.Additional context
No response