From 68192f0f12005e4897bc9044a32e97a658c42e81 Mon Sep 17 00:00:00 2001 From: lightclient Date: Thu, 18 Apr 2024 16:43:03 -0600 Subject: [PATCH] 7002: convert withdrawal request into 7685 request --- EIPS/eip-7002.md | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/EIPS/eip-7002.md b/EIPS/eip-7002.md index 9da8f9c60a2ce..7502eba020b79 100644 --- a/EIPS/eip-7002.md +++ b/EIPS/eip-7002.md @@ -8,6 +8,7 @@ status: Draft type: Standards Track category: Core created: 2023-05-09 +requires: 7685 --- ## Abstract @@ -39,6 +40,7 @@ Note, 0x00 withdrawal credentials can be changed into 0x01 withdrawal credential | Name | Value | Comment | | - | - | - | | `WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS` | `0xEd8EA01d70Cb49726175BCf2778B9C982912e017` | Where to call and store relevant details about exit / partial withdrawal mechanism | +| `WITHDRAWAL_REQUEST_TYPE` | `0x01` | The [EIP-7685](./eip-7685.md) type prefix for withdrawal request | | `SYSTEM_ADDRESS` | `0xfffffffffffffffffffffffffffffffffffffffe` | Address used to invoke system operation on contract | `EXCESS_WITHDRAWAL_REQUESTS_STORAGE_SLOT` | 0 | | | `WITHDRAWAL_REQUEST_COUNT_STORAGE_SLOT` | 1 | | @@ -58,20 +60,17 @@ Note, 0x00 withdrawal credentials can be changed into 0x01 withdrawal credential #### Withdrawal request operation -The new withdrawal request operation consists of the following fields: +The new withdrawal request operation is an [EIP-7685](./eip-7685.md) request +with type `0x01` and consists of the following fields: 1. `source_address`: `Bytes20` 2. `validator_pubkey`: `Bytes48` 3. `amount:` `uint64` -RLP encoding of a withdrawal request **MUST** be computed as the following: +The [EIP-7685](./eip-7685) encoding of a withdrawal request **MUST** be computed as the follows: ```python -rlp_encoded_withdrawal_request = RLP([ - source_address, - validator_pubkey, - amount -]) +encoded = WITHDRAWAL_REQUEST_TYPE ++ rlp([source_address, validator_pubkey, amount]) ``` #### Withdrawal Request Contract @@ -225,7 +224,7 @@ def reset_withdrawal_requests_count(): sstore(WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS, WITHDRAWAL_REQUEST_COUNT_STORAGE_SLOT, 0) ``` -#### Bytecode +##### Bytecode ```asm caller @@ -469,7 +468,7 @@ push0 revert ``` -#### Deployment +##### Deployment The withdrawal requests contract is deployed like any other smart contract. A special synthetic address is generated by working backwards from the desired deployment transaction: @@ -496,31 +495,6 @@ Sender: 0x3da359dC1d98B53f32848dFfDC421410a47bbBD5 Address: 0xEd8EA01d70Cb49726175BCf2778B9C982912e017 ``` -#### Block structure - -Beginning with the `FORK_BLOCK`, the block body **MUST** be appended with the list of withdrawal requests returned by `read_withdrawal_requests()`. RLP encoding of the extended block body structure **MUST** be computed as follows: - -```python -block_body_rlp = RLP([ - field_0, - ..., - # Latest block body field before `withdrawal_requests` - field_n, - - [req_0, ..., req_k], -]) -``` - -Beginning with the `FORK_BLOCK`, the block header **MUST** be appended with the new **`withdrawal_requests_root`** field. The value of this field is the trie root committing to the list of requests in the block body. **`withdrawal_requests_root`** field value **MUST** be computed as follows: - -```python -def compute_trie_root_from_indexed_data(data): - trie = Trie.from([(i, obj) for i, obj in enumerate(data)]) - return trie.root - -block.header.withdrawal_requests_root = compute_trie_root_from_indexed_data(block.body.withdrawa_requests) -``` - ### Consensus layer [Full specification](https://github.com/ethereum/consensus-specs/blob/7bf43d1bc4fdb91059f0e6f4f7f0f3349b144950/specs/electra/beacon-chain.md)