{"id":1825,"library":"eth-rlp","title":"eth-rlp","description":"eth-rlp provides RLP (Recursive Length Prefix) serialization definitions for common Ethereum objects in Python. It's used to encode arbitrarily nested arrays of binary data into a space-efficient format, crucial for data transfer between Ethereum nodes and object serialization within the Ethereum execution layer. The library is currently at version 2.2.0 and receives updates to align with Ethereum protocol specifications.","status":"active","version":"2.2.0","language":"en","source_language":"en","source_url":"https://github.com/ethereum/eth-rlp","tags":["ethereum","rlp","serialization","blockchain","encoding","cryptocurrency"],"install":[{"cmd":"pip install eth-rlp","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Required for core Ethereum numeric types like Uint used in RLP schemas.","package":"ethereum-types","optional":false}],"imports":[{"symbol":"encode","correct":"from ethereum_rlp import encode"},{"symbol":"decode_to","correct":"from ethereum_rlp import decode_to"}],"quickstart":{"code":"from dataclasses import dataclass\nfrom ethereum_rlp import encode, decode_to\nfrom ethereum_types.numeric import Uint\nfrom typing import List\n\n@dataclass\nclass Stuff:\n    toggle: bool\n    number: Uint\n    sequence: List[\"Stuff\"]\n\n# Encode an object\noriginal_stuff = Stuff(toggle=True, number=Uint(3), sequence=[])\nencoded_data = encode(original_stuff)\nprint(f\"Encoded: {encoded_data.hex()}\")\n\n# Decode back to the object type\ndecoded_stuff = decode_to(Stuff, encoded_data)\nprint(f\"Decoded number: {decoded_stuff.number}\")\nassert decoded_stuff.number == Uint(3)","lang":"python","description":"This example demonstrates defining an RLP schema using a dataclass, then encoding a Python object into RLP bytes and decoding it back. It utilizes `ethereum_types.numeric.Uint` for integer types."},"warnings":[{"fix":"Review transaction and data payloads to ensure they do not exceed the `MAX_RLP_BLOCK_SIZE` (approximately 12 MiB total) imposed by EIP-7934. Split larger operations if necessary.","message":"Ethereum's EIP-7934 introduced a strict upper limit on the size of RLP-encoded execution blocks (10 MiB plus a safety margin). Applications using `eth-rlp` to create large transactions or data structures must ensure they adhere to these new size constraints, as oversized blocks are non-backward compatible and will be rejected by the network.","severity":"breaking","affected_versions":"Ethereum protocol versions after EIP-7934 activation."},{"fix":"Always convert Python data to RLP-compatible types (bytes, lists of bytes/lists, big-endian integers without leading zeros) before encoding. Utilize schema definitions (e.g., dataclasses with `eth-rlp`) to manage complex object serialization correctly.","message":"RLP is designed specifically for encoding arbitrarily nested arrays of binary data. It does not inherently handle all Python data types (e.g., floats, complex objects beyond basic lists/bytes/integers) directly. Higher-order protocols or libraries (like `eth-rlp` using dataclasses) are required to map complex Python objects to RLP-compatible structures. Positive integers must be represented in big-endian binary form with no leading zeros.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be mindful of which Ethereum layer data is being processed for and use the appropriate serialization library (RLP for execution, SSZ for consensus) to avoid compatibility issues.","message":"Ethereum's execution layer predominantly uses RLP for serialization, while the newer consensus layer (Beacon Chain) has transitioned to Simple Serialize (SSZ). Developers interacting with both layers must be aware of these distinct serialization standards, as they are not interchangeable and can introduce complexity when building unified clients or applications.","severity":"gotcha","affected_versions":"All versions (Ethereum 2.0 and later)"},{"fix":"Ensure `eth-rlp` is up-to-date and that custom parsing or construction of RLP-encoded EIP-1559 transactions aligns with the latest Ethereum protocol specifications for transaction envelopes.","message":"The RLP encoding structure for EIP-1559 transactions has been refined (e.g., to avoid an 'extra empty byte' for legacy gas price fields). Applications relying on a precise RLP byte-level representation of EIP-1559 transactions, especially older implementations, might encounter discrepancies with current specifications if not updated.","severity":"gotcha","affected_versions":"Potentially older versions prior to RLP encoding updates for EIP-1559."}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}