Skip to content

Commit

Permalink
Update EIP-6110: change request to flat encoding
Browse files Browse the repository at this point in the history
Merged by EIP-Bot.
  • Loading branch information
fjl authored Oct 1, 2024
1 parent 1d4ce54 commit b48903e
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions EIPS/eip-6110.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,15 @@ The structure denoting the new deposit operation consists of the following field
4. `signature: Bytes96`
5. `index: uint64`

Deposits are a type of [EIP-7685](./eip-7685.md) request, therefore the encoding of the structure must be computed using the `DEPOSIT_REQUEST_TYPE` byte:
Deposits are a type of [EIP-7685](./eip-7685.md) request, with the following encoding:

```python
deposit_request_rlp = DEPOSIT_REQUEST_TYPE + rlp([
pubkey,
withdrawal_credentials,
amount,
signature,
index
])
request_type = DEPOSIT_REQUEST_TYPE
request_data = pubkey ++ withdrawal_credentials ++ amount ++ signature ++ index
```

The encoded deposits will be included in the header and body as generic requests following the format defined by EIP-7685.
Note that the request payload is just the concatenation of the elements returned by the contract.
The encoded deposits will be included in the header and body following the format defined by EIP-7685.

#### Block validity

Expand All @@ -94,17 +90,15 @@ def parse_deposit_data(deposit_event_data) -> bytes[]:
def little_endian_to_uint64(data: bytes) -> uint64:
return uint64(int.from_bytes(data, 'little'))

def event_data_to_deposit_request_rlp(deposit_event_data) -> bytes:
def event_data_to_deposit_request(deposit_event_data) -> bytes:
deposit_data = parse_deposit_data(deposit_event_data)
pubkey = Bytes48(deposit_data[0])
withdrawal_credentials = Bytes32(deposit_data[1])
amount = little_endian_to_uint64(deposit_data[2])
amount = deposit_data[2] # 8 bytes uint64 LE
signature = Bytes96(deposit_data[3])
index = little_endian_to_uint64(deposit_data[4])
index = deposit_data[4] # 8 bytes uint64 LE

return DEPOSIT_REQUEST_TYPE + rlp([
pubkey, withdrawal_credentials, amount, signature, index
])
return DEPOSIT_REQUEST_TYPE + pubkey + withdrawal_credentials + amount + signature + index

# Obtain receipts from block execution result
receipts = block.execution_result.receipts
Expand All @@ -114,8 +108,8 @@ expected_deposit_requests = []
for receipt in receipts:
for log in receipt.logs:
if log.address == DEPOSIT_CONTRACT_ADDRESS:
deposit_request_rlp = event_data_to_deposit_request_rlp(log.data)
expected_deposit_requests.append(deposit_request_rlp)
deposit_request = event_data_to_deposit_request(log.data)
expected_deposit_requests.append(deposit_request)

deposit_requests = [req for req in block.body.requests if req[:1] == DEPOSIT_REQUEST_TYPE]

Expand Down

0 comments on commit b48903e

Please sign in to comment.