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

Pass execution requests to Engine API as a list of bytes #3969

Merged
merged 4 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion pysetup/spec_builders/electra.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ElectraSpecBuilder(BaseSpecBuilder):
def imports(cls, preset_name: str):
return f'''
from eth2spec.deneb import {preset_name} as deneb
from eth2spec.utils.ssz.ssz_impl import serialize
'''

@classmethod
Expand All @@ -29,7 +30,7 @@ class NoopExecutionEngine(ExecutionEngine):
def notify_new_payload(self: ExecutionEngine,
execution_payload: ExecutionPayload,
parent_beacon_block_root: Root,
execution_requests: ExecutionRequests) -> bool:
execution_requests_list: list[bytes]) -> bool:
return True

def notify_forkchoice_updated(self: ExecutionEngine,
Expand Down
20 changes: 17 additions & 3 deletions specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
- [Modified `get_expected_withdrawals`](#modified-get_expected_withdrawals)
- [Modified `process_withdrawals`](#modified-process_withdrawals)
- [Execution payload](#execution-payload)
- [New `get_execution_requests_list`](#new-get_execution_requests_list)
- [Modified `process_execution_payload`](#modified-process_execution_payload)
- [Operations](#operations)
- [Modified `process_operations`](#modified-process_operations)
Expand Down Expand Up @@ -991,7 +992,7 @@ class NewPayloadRequest(object):
def notify_new_payload(self: ExecutionEngine,
execution_payload: ExecutionPayload,
parent_beacon_block_root: Root,
execution_requests: ExecutionRequests) -> bool:
execution_requests_list: list[bytes]) -> bool:
"""
Return ``True`` if and only if ``execution_payload`` and ``execution_requests``
are valid with respect to ``self.execution_state``.
Expand All @@ -1012,7 +1013,7 @@ def verify_and_notify_new_payload(self: ExecutionEngine,
"""
execution_payload = new_payload_request.execution_payload
parent_beacon_block_root = new_payload_request.parent_beacon_block_root
execution_requests = new_payload_request.execution_requests # [New in Electra]
execution_requests_list = get_execution_requests_list(new_payload_request.execution_requests) # [New in Electra]

if not self.is_valid_block_hash(execution_payload, parent_beacon_block_root):
return False
Expand All @@ -1024,7 +1025,7 @@ def verify_and_notify_new_payload(self: ExecutionEngine,
if not self.notify_new_payload(
execution_payload,
parent_beacon_block_root,
execution_requests):
execution_requests_list):
return False

return True
Expand Down Expand Up @@ -1139,6 +1140,19 @@ def process_withdrawals(state: BeaconState, payload: ExecutionPayload) -> None:

#### Execution payload

##### New `get_execution_requests_list`

*Note*: Encodes execution requests as defined by [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685).

```python
def get_execution_requests_list(execution_requests: ExecutionRequests) -> list[bytes]:
deposit_bytes = serialize(execution_requests.deposits)
withdrawal_bytes = serialize(execution_requests.withdrawals)
consolidation_bytes = serialize(execution_requests.consolidations)

return [deposit_bytes, withdrawal_bytes, consolidation_bytes]
```

##### Modified `process_execution_payload`

*Note*: The function `process_execution_payload` is modified to pass `execution_requests` into `execution_engine.verify_and_notify_new_payload` (via the updated `NewPayloadRequest`).
Expand Down