-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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-6110: change request to flat encoding #8856
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -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] # 4 bytes uint64 LE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that not making the endianness conversion here defers this responsibility to the Engine API handlers There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea is that this is already valid SSZ and that will be passed directly to CL. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, AFAIK the number is already converted to LE by the contract. |
||
signature = Bytes96(deposit_data[3]) | ||
index = little_endian_to_uint64(deposit_data[4]) | ||
index = deposit_data[4] # 4 bytes uint64 LE | ||
|
||
return DEPOSIT_REQUEST_TYPE + rlp([ | ||
pubkey, withdrawal_credentials, amount, signature, index | ||
]) | ||
return DEPOSIT_REQUEST_TYPE + pubkey + withdrawal_credentials + amount + signature + index | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to prepend the type? My understanding is that each element does not have the type, and the type is only used when calculating the commitment hash. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah just realised this has changed in other PRs :) |
||
|
||
# Obtain receipts from block execution result | ||
receipts = block.execution_result.receipts | ||
|
@@ -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] | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this helper now as it is no longer used