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

EIP-7742: Uncouple blob limits per block across CL and EL #3800

Merged
merged 14 commits into from
Dec 5, 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
7 changes: 5 additions & 2 deletions pysetup/spec_builders/electra.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class NoopExecutionEngine(ExecutionEngine):
def notify_new_payload(self: ExecutionEngine,
execution_payload: ExecutionPayload,
parent_beacon_block_root: Root,
execution_requests_list: Sequence[bytes]) -> bool:
execution_requests_list: Sequence[bytes],
target_blobs_per_block: uint64) -> bool:
return True

def notify_forkchoice_updated(self: ExecutionEngine,
Expand All @@ -46,7 +47,9 @@ 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_list: Sequence[bytes],
target_blobs_per_block: uint64) -> bool:
return True

def is_valid_versioned_hashes(self: ExecutionEngine, new_payload_request: NewPayloadRequest) -> bool:
Expand Down
1 change: 1 addition & 0 deletions specs/_features/eip7594/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
versioned_hashes=versioned_hashes,
parent_beacon_block_root=state.latest_block_header.parent_root,
execution_requests=body.execution_requests,
target_blobs_per_block=MAX_BLOBS_PER_BLOCK // 2,
)
)
# Cache execution payload header
Expand Down
1 change: 1 addition & 0 deletions specs/_features/eip7732/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ def process_execution_payload(state: BeaconState,
versioned_hashes=versioned_hashes,
parent_beacon_block_root=state.latest_block_header.parent_root,
execution_requests=requests,
target_blobs_per_block=MAX_BLOBS_PER_BLOCK // 2,
)
)

Expand Down
44 changes: 37 additions & 7 deletions specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,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)
Expand Down Expand Up @@ -1003,30 +1004,51 @@ class NewPayloadRequest(object):
versioned_hashes: Sequence[VersionedHash]
parent_beacon_block_root: Root
execution_requests: ExecutionRequests # [New in Electra]
target_blobs_per_block: uint64 # [New in Electra:EIP7742]
```

#### Engine APIs

##### Modified `is_valid_block_hash`

*Note*: The function `is_valid_block_hash` is modified to include the additional
`execution_requests_list` and `target_blobs_per_block` parameters in Electra.

```python
def is_valid_block_hash(self: ExecutionEngine,
execution_payload: ExecutionPayload,
parent_beacon_block_root: Root,
execution_requests_list: Sequence[bytes],
target_blobs_per_block: uint64) -> 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.
*Note*: The function `notify_new_payload` is modified to include the additional
`execution_requests_list` and `target_blobs_per_block` parameters in Electra.

```python
def notify_new_payload(self: ExecutionEngine,
execution_payload: ExecutionPayload,
parent_beacon_block_root: Root,
execution_requests_list: Sequence[bytes]) -> bool:
execution_requests_list: Sequence[bytes],
target_blobs_per_block: uint64) -> bool:
"""
Return ``True`` if and only if ``execution_payload`` and ``execution_requests``
Return ``True`` if and only if ``execution_payload`` and ``execution_requests_list``
are valid with respect to ``self.execution_state``.
"""
...
```

##### Modified `verify_and_notify_new_payload`

*Note*: The function `verify_and_notify_new_payload` is modified to pass the additional parameter `execution_requests`
when calling `notify_new_payload` in Electra.
*Note*: The function `verify_and_notify_new_payload` is modified to pass the additional parameters
`execution_requests_list` and `target_blobs_per_block` when calling `is_valid_block_hash` and
`notify_new_payload` in Electra.

```python
def verify_and_notify_new_payload(self: ExecutionEngine,
Expand All @@ -1037,11 +1059,17 @@ 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_list = get_execution_requests_list(new_payload_request.execution_requests) # [New in Electra]
target_blobs_per_block = new_payload_request.target_blobs_per_block # [New in Electra:EIP7742]

if b'' in execution_payload.transactions:
return False

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

if not self.is_valid_versioned_hashes(new_payload_request):
Expand All @@ -1051,7 +1079,8 @@ def verify_and_notify_new_payload(self: ExecutionEngine,
if not self.notify_new_payload(
execution_payload,
parent_beacon_block_root,
execution_requests_list):
execution_requests_list,
target_blobs_per_block):
jtraglia marked this conversation as resolved.
Show resolved Hide resolved
return False

return True
Expand Down Expand Up @@ -1213,6 +1242,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
versioned_hashes=versioned_hashes,
parent_beacon_block_root=state.latest_block_header.parent_root,
execution_requests=body.execution_requests, # [New in Electra]
target_blobs_per_block=MAX_BLOBS_PER_BLOCK // 2, # [New in Electra:EIP7742]
)
)
# Cache execution payload header
Expand Down
38 changes: 38 additions & 0 deletions specs/electra/fork-choice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Electra -- Fork Choice

## Table of contents
<!-- TOC -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Introduction](#introduction)
- [Containers](#containers)
- [Helpers](#helpers)
- [Extended `PayloadAttributes`](#extended-payloadattributes)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
<!-- /TOC -->

## Introduction

This is the modification of the fork choice accompanying the Electra upgrade.

## Containers

## Helpers

### Extended `PayloadAttributes`

*Note*: `PayloadAttributes` is extended with the target/maximum number of blobs per block.

```python
@dataclass
class PayloadAttributes(object):
timestamp: uint64
prev_randao: Bytes32
suggested_fee_recipient: ExecutionAddress
withdrawals: Sequence[Withdrawal]
parent_beacon_block_root: Root
target_blobs_per_block: uint64 # [New in Electra:EIP7742]
max_blobs_per_block: uint64 # [New in Electra:EIP7742]
```
2 changes: 2 additions & 0 deletions specs/electra/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def prepare_execution_payload(state: BeaconState,
suggested_fee_recipient=suggested_fee_recipient,
withdrawals=withdrawals,
parent_beacon_block_root=hash_tree_root(state.latest_block_header),
target_blobs_per_block=MAX_BLOBS_PER_BLOCK // 2, # [New in Electra:EIP7742]
max_blobs_per_block=MAX_BLOBS_PER_BLOCK, # [New in Electra:EIP7742]
)
return execution_engine.notify_forkchoice_updated(
head_block_hash=parent_hash,
Expand Down