From a44071a9a522915a8640013943d5f5e05cd5b5dd Mon Sep 17 00:00:00 2001 From: Justin Traglia Date: Tue, 8 Oct 2024 12:19:13 -0500 Subject: [PATCH 1/2] Pass execution requests to Engine API as a list of bytes --- pysetup/spec_builders/electra.py | 3 ++- specs/electra/beacon-chain.md | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pysetup/spec_builders/electra.py b/pysetup/spec_builders/electra.py index 2ab1f5ecfb..a374b7384c 100644 --- a/pysetup/spec_builders/electra.py +++ b/pysetup/spec_builders/electra.py @@ -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 @@ -28,7 +29,7 @@ class NoopExecutionEngine(ExecutionEngine): def notify_new_payload(self: ExecutionEngine, execution_payload: ExecutionPayload, - execution_requests: ExecutionRequests, + execution_requests_list: list[bytes], parent_beacon_block_root: Root) -> bool: return True diff --git a/specs/electra/beacon-chain.md b/specs/electra/beacon-chain.md index c231e718e7..6c679afcc8 100644 --- a/specs/electra/beacon-chain.md +++ b/specs/electra/beacon-chain.md @@ -990,7 +990,7 @@ class NewPayloadRequest(object): ```python def notify_new_payload(self: ExecutionEngine, execution_payload: ExecutionPayload, - execution_requests: ExecutionRequests, + execution_requests_list: list[bytes], parent_beacon_block_root: Root) -> bool: """ Return ``True`` if and only if ``execution_payload`` and ``execution_requests`` @@ -1011,7 +1011,7 @@ def verify_and_notify_new_payload(self: ExecutionEngine, Return ``True`` if and only if ``new_payload_request`` is valid with respect to ``self.execution_state``. """ execution_payload = new_payload_request.execution_payload - 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] parent_beacon_block_root = new_payload_request.parent_beacon_block_root if not self.is_valid_block_hash(execution_payload, parent_beacon_block_root): @@ -1023,7 +1023,7 @@ def verify_and_notify_new_payload(self: ExecutionEngine, # [Modified in Electra] if not self.notify_new_payload( execution_payload, - execution_requests, + execution_requests_list, parent_beacon_block_root): return False @@ -1139,6 +1139,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`). From c9ea712389f04c26f0a7b3b0a46bd66b4d3f6497 Mon Sep 17 00:00:00 2001 From: Justin Traglia Date: Tue, 8 Oct 2024 12:27:50 -0500 Subject: [PATCH 2/2] Fix table of contents --- specs/electra/beacon-chain.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/electra/beacon-chain.md b/specs/electra/beacon-chain.md index 6c679afcc8..23a602da29 100644 --- a/specs/electra/beacon-chain.md +++ b/specs/electra/beacon-chain.md @@ -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)