Ethereum, byte by byte
RLP is the serialization format used for Ethereum transactions, block headers, receipts, and trie nodes. I built a small Rust library to work through those encoding rules directly, from a single byte to recursively nested lists.
The implementation separates encoding, decoding, and typed conversion into small modules. The core library has no runtime dependencies.
What it does
- Encodes byte strings and nested lists, including short and long payloads.
- Decodes bytes into a recursive
RlpItemrepresentation. - Provides an
Encodabletrait for integers, booleans, strings, and collections. - Rejects non-canonical single bytes, non-minimal length prefixes, truncated payloads, and trailing data.
Ethereum integer encoding uses big-endian bytes with leading zeroes removed. Integer zero becomes an empty byte string; getting these boundary cases right matters as much as handling the happy path.
Checking the boundaries
The repository includes module tests, specification vectors, and a runnable encode/decode demo. The decoder follows the Ethereum RLP reference's canonical-form rules.
Explore the source and specification notes for the implementation, test vectors, and examples.