Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EIP-7002: convert to use 7685 requests #8469

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 8 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 @@ -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 | |
Expand All @@ -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
Expand Down Expand Up @@ -225,7 +224,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 +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:

Expand All @@ -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)
Expand Down
Loading