Skip to content

Commit

Permalink
Pass execution_requests_hash only to is_valid_block_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalinin committed Oct 1, 2024
1 parent 69b7be5 commit 21fdd85
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions pysetup/spec_builders/electra.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class NoopExecutionEngine(ExecutionEngine):
def notify_new_payload(self: ExecutionEngine,
execution_payload: ExecutionPayload,
execution_requests: ExecutionRequests,
parent_beacon_block_root: Root) -> bool:
return True
Expand All @@ -46,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_hash: Hash32) -> bool:
return True
def is_valid_versioned_hashes(self: ExecutionEngine, new_payload_request: NewPayloadRequest) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion specs/_features/eip7732/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ def process_execution_payload(state: BeaconState,
execution_payload=payload,
versioned_hashes=versioned_hashes,
parent_beacon_block_root=state.latest_block_header.parent_root,
execution_requests=requests,
execution_requests_hash=compute_execution_requests_hash(requests),
)
)

Expand Down
29 changes: 15 additions & 14 deletions specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
- [Request data](#request-data)
- [Modified `NewPayloadRequest`](#modified-newpayloadrequest)
- [Engine APIs](#engine-apis)
- [Modified `notify_new_payload`](#modified-notify_new_payload)
- [Modified `is_valid_block_hash`](#modified-is_valid_block_hash)
- [Modified `verify_and_notify_new_payload`](#modified-verify_and_notify_new_payload)
- [Block processing](#block-processing)
- [Withdrawals](#withdrawals)
Expand Down Expand Up @@ -940,23 +940,22 @@ class NewPayloadRequest(object):
execution_payload: ExecutionPayload
versioned_hashes: Sequence[VersionedHash]
parent_beacon_block_root: Root
execution_requests_hash: Hash32 # [New in Electra]
execution_requests_hash: Hash32 # [New in Electra:EIP7685]
```

#### Engine APIs

##### Modified `notify_new_payload`
##### Modified `is_valid_block_hash`

*Note*: The function `notify_new_payload` is modified to include the additional `execution_requests_hash` parameter in Electra.
*Note*: The function `is_valid_block_hash` is modified to include the additional `execution_requests_hash` parameter for EIP-7685.

```python
def notify_new_payload(self: ExecutionEngine,
execution_payload: ExecutionPayload,
parent_beacon_block_root: Root,
execution_requests_hash: execution_requests_hash) -> bool:
def is_valid_block_hash(self: ExecutionEngine,
execution_payload: ExecutionPayload,
parent_beacon_block_root: Root,
execution_requests_hash: Hash32) -> bool:
"""
Return ``True`` if and only if ``execution_payload`` and ``execution_requests``
are valid with respect to ``self.execution_state``.
Return ``True`` if and only if ``execution_payload.block_hash`` is computed correctly.
"""
...
```
Expand All @@ -976,17 +975,19 @@ def verify_and_notify_new_payload(self: ExecutionEngine,
parent_beacon_block_root = new_payload_request.parent_beacon_block_root
execution_requests_hash = new_payload_request.execution_requests_hash # [New in Electra]

if not self.is_valid_block_hash(execution_payload, parent_beacon_block_root):
# [Modified in Electra:EIP7685]
if not self.is_valid_block_hash(
execution_payload,
parent_beacon_block_root,
execution_requests_hash):
return False

if not self.is_valid_versioned_hashes(new_payload_request):
return False

# [Modified in Electra]
if not self.notify_new_payload(
execution_payload,
parent_beacon_block_root,
execution_requests_hash):
parent_beacon_block_root):
return False

return True
Expand Down

0 comments on commit 21fdd85

Please sign in to comment.