From 6c47a3959f89f6fee4046e5e07124b31d5e8a020 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Tue, 8 Oct 2024 15:34:56 -0600 Subject: [PATCH 1/3] pass `execution_requests` to block hash validation --- specs/electra/beacon-chain.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/specs/electra/beacon-chain.md b/specs/electra/beacon-chain.md index 1629f45776..62d8cf60ac 100644 --- a/specs/electra/beacon-chain.md +++ b/specs/electra/beacon-chain.md @@ -77,6 +77,7 @@ - [Request data](#request-data) - [Modified `NewPayloadRequest`](#modified-newpayloadrequest) - [Engine APIs](#engine-apis) + - [Modified `is_valid_block_hash`](#modified-is_valid_block_hash) - [Modified `notify_new_payload`](#modified-notify_new_payload) - [Modified `verify_and_notify_new_payload`](#modified-verify_and_notify_new_payload) - [Block processing](#block-processing) @@ -983,6 +984,21 @@ class NewPayloadRequest(object): #### Engine APIs +##### Modified `is_valid_block_hash` + +*Note*: The function `is_valid_block_hash` is modified to include the additional `execution_requests` parameter in Electra. + +```python +def is_valid_block_hash(self: ExecutionEngine, + execution_payload: ExecutionPayload, + parent_beacon_block_root: Root, + execution_requests: ExecutionRequests) -> bool: + """ + Return ``True`` if and only if ``execution_payload.block_hash`` is computed correctly. + """ + ... +``` + ##### Modified `notify_new_payload` *Note*: The function `notify_new_payload` is modified to include the additional `execution_requests` parameter in Electra. @@ -993,7 +1009,7 @@ def notify_new_payload(self: ExecutionEngine, parent_beacon_block_root: Root, execution_requests: ExecutionRequests) -> bool: """ - Return ``True`` if and only if ``execution_payload`` and ``execution_requests`` + Return ``True`` if and only if ``execution_payload`` and ``execution_requests`` are valid with respect to ``self.execution_state``. """ ... @@ -1014,7 +1030,10 @@ def verify_and_notify_new_payload(self: ExecutionEngine, parent_beacon_block_root = new_payload_request.parent_beacon_block_root execution_requests = new_payload_request.execution_requests # [New in Electra] - if not self.is_valid_block_hash(execution_payload, parent_beacon_block_root): + if not self.is_valid_block_hash( + execution_payload, + parent_beacon_block_root, + execution_requests): return False if not self.is_valid_versioned_hashes(new_payload_request): From 8fd8a154c8c9d4200be6ee1fb2744fc65da90ad4 Mon Sep 17 00:00:00 2001 From: Justin Traglia <95511699+jtraglia@users.noreply.github.com> Date: Tue, 8 Oct 2024 17:31:16 -0500 Subject: [PATCH 2/3] Add execution_requests to is_valid_block_hash in spec builder --- pysetup/spec_builders/electra.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pysetup/spec_builders/electra.py b/pysetup/spec_builders/electra.py index 4c7ef7e9ed..fc3df0368f 100644 --- a/pysetup/spec_builders/electra.py +++ b/pysetup/spec_builders/electra.py @@ -45,7 +45,8 @@ def get_payload(self: ExecutionEngine, payload_id: PayloadId) -> GetPayloadRespo def is_valid_block_hash(self: ExecutionEngine, execution_payload: ExecutionPayload, - parent_beacon_block_root: Root) -> bool: + parent_beacon_block_root: Root, + execution_requests: ExecutionRequests) -> bool: return True def is_valid_versioned_hashes(self: ExecutionEngine, new_payload_request: NewPayloadRequest) -> bool: @@ -56,4 +57,4 @@ def verify_and_notify_new_payload(self: ExecutionEngine, return True -EXECUTION_ENGINE = NoopExecutionEngine()""" \ No newline at end of file +EXECUTION_ENGINE = NoopExecutionEngine()""" From dab5d139a85d82b68a68512aa2069e507e467abd Mon Sep 17 00:00:00 2001 From: Justin Traglia <95511699+jtraglia@users.noreply.github.com> Date: Tue, 8 Oct 2024 17:36:53 -0500 Subject: [PATCH 3/3] Revert change to last line