AlertSourceDiscuss
Skip to content
On this page

EIP-6465: SSZ Withdrawals Root

Migration of withdrawals MPT commitment to SSZ

⚠️ DraftCore

Draft Notice

This EIP is in the process of being drafted. The content of this EIP is not final and can change at any time; this EIP is not yet suitable for use in production. Thank you!

AuthorsEtan Kissling (@etan-status), Mikhail Kalinin (@mkalinin)
Created2023-02-08

Abstract

This EIP defines a migration process of the existing Merkle-Patricia Trie (MPT) commitment for withdrawals to Simple Serialize (SSZ).

Motivation

While the consensus ExecutionPayloadHeader and the execution block header map to each other conceptually, they are encoded differently. This EIP aims to align the encoding of the withdrawals_root, taking advantage of the more modern SSZ format. This brings several advantages:

  1. Reducing complexity: Merkle-Patricia Tries (MPT) are hard to work with. Replacing them with SSZ leaves only the state trie in the legacy MPT format.

  2. Better for smart contracts: The SSZ format is optimized for production and verification of merkle proofs. It allows proving specific fields of containers and allows chunked processing.

  3. Better for light clients: Light clients with access to the consensus ExecutionPayloadHeader no longer need to obtain the matching execution block header to verify proofs rooted in withdrawals_root.

  4. Reducing ambiguity: The name withdrawals_root is currently used to refer to different roots. The execution block header refers to a MPT root, the consensus ExecutionPayloadHeader refers to a SSZ root.

Specification

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174.

Execution block header changes

The existing consensus Withdrawal SSZ container is used to represent withdrawals.

python
class Withdrawal(Container):
    index: WithdrawalIndex
    validator_index: ValidatorIndex
    address: ExecutionAddress
    amount: Gwei

The execution block header's withdrawals-root is updated to match the consensus ExecutionPayloadHeader.withdrawals_root.

NameValueDescription
MAX_WITHDRAWALS_PER_PAYLOADuint64(2**4) (= 16)Maximum amount of withdrawals allowed in each block
python
block_header.withdrawals_root == hash_tree_root(List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD](
    withdrawal_0,
    withdrawal_1,
    withdrawal_2,
    ...
))

Helpers

python
def encode_withdrawal(withdrawal: Withdrawal) -> bytes:
    schema = (
        (big_endian_int, withdrawal.index),
        (big_endian_int, withdrawal.validator_index),
        (Binary[20, 20], withdrawal.address),
        (big_endian_int, withdrawal.amount),
    )
    sedes = List([schema for schema, _ in schema])
    values = [value for _, value in schema]
    return rlp.encode(values, sedes)
python
def decode_withdrawal(encoded_withdrawal: bytes) -> Withdrawal:
    class RLPWithdrawal(rlp.Serializable):
        fields = (
            ('index', bid_endian_int),
            ('validator_index', big_endian_int),
            ('address', Binary[20, 20]),
            ('amount', big_endian_int),
        )
    pre = RLPWithdrawal.deserialize(encoded_withdrawal)

    return Withdrawal(
        index=pre.index,
        validator_index=pre.validator_index,
        address=pre.address,
        amount=pre.amount,
    )

Rationale

This change was originally a candidate for inclusion in Shanghai, but was postponed to accelerate the rollout of withdrawals.

Backwards Compatibility

Applications that solely rely on the Withdrawal RLP encoding but do not rely on the withdrawals_root in the block header can still be used through a re-encoding proxy.

Applications that rely on the replaced MPT withdrawals_root in the block header can no longer find that information.

Withdrawals were only just recently introduced as part of EIP-4895 (Shanghai). It is not expected that major applications already rely on the Merkle-Patricia Trie commitment for withdrawals.

Test Cases

TBD

Reference Implementation

TBD

Security Considerations

None

Copyright and related rights waived via CC0.

Citation

Please cite this document as:

Etan Kissling, Mikhail Kalinin, "EIP-6465: SSZ Withdrawals Root[DRAFT]," Ethereum Improvement Proposals, no. 6465, 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6465.