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:
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.
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.
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 inwithdrawals_root
.Reducing ambiguity: The name
withdrawals_root
is currently used to refer to different roots. The execution block header refers to a MPT root, the consensusExecutionPayloadHeader
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.
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
.
Name | Value | Description |
---|---|---|
MAX_WITHDRAWALS_PER_PAYLOAD | uint64(2**4) (= 16) | Maximum amount of withdrawals allowed in each block |
block_header.withdrawals_root == hash_tree_root(List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD](
withdrawal_0,
withdrawal_1,
withdrawal_2,
...
))
Helpers
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)
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
Copyright and related rights waived via CC0.