forked from DecentralizedClimateFoundation/DCIPs
103 lines
4.9 KiB
Markdown
103 lines
4.9 KiB
Markdown
|
---
|
||
|
eip: 6465
|
||
|
title: SSZ Withdrawals Root
|
||
|
description: Migration of withdrawals MPT commitment to SSZ
|
||
|
author: Etan Kissling (@etan-status), Mikhail Kalinin (@mkalinin)
|
||
|
discussions-to: https://ethereum-magicians.org/t/eip-6465-ssz-withdrawals-root/12883
|
||
|
status: Draft
|
||
|
type: Standards Track
|
||
|
category: Core
|
||
|
created: 2023-02-08
|
||
|
requires: 4895
|
||
|
---
|
||
|
|
||
|
## Abstract
|
||
|
|
||
|
This EIP defines a migration process of the existing Merkle-Patricia Trie (MPT) commitment for withdrawals to [Simple Serialize (SSZ)](https://github.com/ethereum/consensus-specs/blob/67c2f9ee9eb562f7cc02b2ff90d92c56137944e1/ssz/simple-serialize.md).
|
||
|
|
||
|
## 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:** The proposed design reduces the number of use cases that require support for Merkle-Patricia Trie (MPT).
|
||
|
|
||
|
2. **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 an 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.
|
||
|
|
||
|
### Existing definitions
|
||
|
|
||
|
Definitions from existing specifications that are used throughout this document are replicated here for reference.
|
||
|
|
||
|
| Name | SSZ equivalent |
|
||
|
| - | - |
|
||
|
| [`ValidatorIndex`](https://github.com/ethereum/consensus-specs/blob/67c2f9ee9eb562f7cc02b2ff90d92c56137944e1/specs/phase0/beacon-chain.md#custom-types) | `uint64` |
|
||
|
| [`Gwei`](https://github.com/ethereum/consensus-specs/blob/67c2f9ee9eb562f7cc02b2ff90d92c56137944e1/specs/phase0/beacon-chain.md#custom-types) | `uint64` |
|
||
|
| [`ExecutionAddress`](https://github.com/ethereum/consensus-specs/blob/67c2f9ee9eb562f7cc02b2ff90d92c56137944e1/specs/bellatrix/beacon-chain.md#custom-types) | `Bytes20`
|
||
|
| [`WithdrawalIndex`](https://github.com/ethereum/consensus-specs/blob/67c2f9ee9eb562f7cc02b2ff90d92c56137944e1/specs/capella/beacon-chain.md#custom-types) | `uint64` |
|
||
|
|
||
|
| Name | Value |
|
||
|
| - | - |
|
||
|
| [`MAX_WITHDRAWALS_PER_PAYLOAD`](https://github.com/ethereum/consensus-specs/blob/67c2f9ee9eb562f7cc02b2ff90d92c56137944e1/specs/capella/beacon-chain.md#execution) | `uint64(2**4)` (= 16) |
|
||
|
|
||
|
### `Withdrawal` representation
|
||
|
|
||
|
The existing consensus [`Withdrawal`](https://github.com/ethereum/consensus-specs/blob/67c2f9ee9eb562f7cc02b2ff90d92c56137944e1/specs/capella/beacon-chain.md#withdrawal) SSZ container is used to represent withdrawals.
|
||
|
|
||
|
```python
|
||
|
class Withdrawal(Container):
|
||
|
index: WithdrawalIndex
|
||
|
validator_index: ValidatorIndex
|
||
|
address: ExecutionAddress
|
||
|
amount: Gwei
|
||
|
```
|
||
|
|
||
|
### Consensus `ExecutionPayload` building
|
||
|
|
||
|
When building a consensus `ExecutionPayload`, the `withdrawals_root` is now based on the `Withdrawal` SSZ container. Implementations that currently produce withdrawals in the [EIP-4895](./eip-4895.md) format can convert them using the [`normalize_withdrawal`](../assets/eip-6465/helpers/convert_withdrawals.py) helper function.
|
||
|
|
||
|
### Execution block header changes
|
||
|
|
||
|
The execution block header's `withdrawals-root` is updated to match the consensus [`ExecutionPayloadHeader.withdrawals_root`](https://github.com/ethereum/consensus-specs/blob/67c2f9ee9eb562f7cc02b2ff90d92c56137944e1/specs/capella/beacon-chain.md#executionpayloadheader).
|
||
|
|
||
|
```python
|
||
|
withdrawals = List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD](
|
||
|
withdrawal_0, withdrawal_1, withdrawal_2, ...)
|
||
|
|
||
|
block_header.withdrawals_root == withdrawals.hash_tree_root()
|
||
|
```
|
||
|
|
||
|
### Networking
|
||
|
|
||
|
The [`recover_encoded_withdrawal`](../assets/eip-6465/helpers/recover_withdrawals.py) helper function recovers a withdrawal's original representation for exchange through the devp2p `Withdrawals` message.
|
||
|
|
||
|
## 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. Analysis is required whether affected applications have a migration path available to use the SSZ `withdrawals_root` instead.
|
||
|
|
||
|
Withdrawals were only just recently introduced as part of [EIP-4895](./eip-4895.md) (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](../LICENSE.md).
|