Skip to content

Commit

Permalink
7002: convert withdrawal request into 7685 request
Browse files Browse the repository at this point in the history
  • Loading branch information
lightclient committed Apr 18, 2024
1 parent f133377 commit 61cb5b5
Showing 1 changed file with 7 additions and 34 deletions.
41 changes: 7 additions & 34 deletions EIPS/eip-7002.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ status: Draft
type: Standards Track
category: Core
created: 2023-05-09
requires: 7685
---

## Abstract
Expand Down Expand Up @@ -58,20 +59,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 = 0x01 ++ rlp([source_address, validator_pubkey, amount])
```

#### Withdrawal Request Contract
Expand Down Expand Up @@ -225,7 +223,7 @@ def reset_withdrawal_requests_count():
sstore(WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS, WITHDRAWAL_REQUEST_COUNT_STORAGE_SLOT, 0)
```

#### Bytecode
##### Bytecode

```asm
caller
Expand Down Expand Up @@ -469,7 +467,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:

Expand All @@ -496,31 +494,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/5d80b1954a4b7a121aa36143d50b366727b66cbc/specs/_features/eip7002/beacon-chain.md)
Expand Down

0 comments on commit 61cb5b5

Please sign in to comment.