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

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
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
41 changes: 39 additions & 2 deletions pysetup/spec_builders/electra.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,46 @@ class ElectraSpecBuilder(BaseSpecBuilder):

@classmethod
def imports(cls, preset_name: str):
return f'''
return f"""
from eth2spec.deneb import {preset_name} as deneb
'''
"""

@classmethod
def execution_engine_cls(cls) -> str:
return """
class NoopExecutionEngine(ExecutionEngine):

def notify_new_payload(self: ExecutionEngine,
execution_payload: ExecutionPayload,
parent_beacon_block_root: Root,
target_blobs_per_block: uint64) -> bool:
return True

def notify_forkchoice_updated(self: ExecutionEngine,
head_block_hash: Hash32,
safe_block_hash: Hash32,
finalized_block_hash: Hash32,
payload_attributes: Optional[PayloadAttributes]) -> Optional[PayloadId]:
pass

def get_payload(self: ExecutionEngine, payload_id: PayloadId) -> GetPayloadResponse:
# pylint: disable=unused-argument
raise NotImplementedError("no default block production")

def is_valid_block_hash(self: ExecutionEngine,
execution_payload: ExecutionPayload,
parent_beacon_block_root: Root) -> bool:
return True

def is_valid_versioned_hashes(self: ExecutionEngine, new_payload_request: NewPayloadRequest) -> bool:
return True

def verify_and_notify_new_payload(self: ExecutionEngine,
new_payload_request: NewPayloadRequest) -> bool:
return True


EXECUTION_ENGINE = NoopExecutionEngine()"""

@classmethod
def hardcoded_ssz_dep_constants(cls) -> Dict[str, str]:
Expand Down
53 changes: 53 additions & 0 deletions specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
- [New `compute_consolidation_epoch_and_update_churn`](#new-compute_consolidation_epoch_and_update_churn)
- [Modified `slash_validator`](#modified-slash_validator)
- [Beacon chain state transition function](#beacon-chain-state-transition-function)
- [Execution engine](#execution-engine)
- [Request data](#request-data)
- [Engine APIs](#engine-apis)
- [Modified `notify_new_payload`](#modified-notify_new_payload)
- [Modified `verify_and_notify_new_payload`](#modified-verify_and_notify_new_payload)
- [Epoch processing](#epoch-processing)
- [Modified `process_epoch`](#modified-process_epoch)
- [Modified `process_registry_updates`](#modified-process_registry_updates)
Expand Down Expand Up @@ -801,6 +806,54 @@ def slash_validator(state: BeaconState,

## Beacon chain state transition function

### Execution engine

#### Request data

#### Engine APIs

##### Modified `notify_new_payload`

*Note*: The function `notify_new_payload` is modified to include the target number of blobs
allowed per block.

```python
def notify_new_payload(self: ExecutionEngine,
execution_payload: ExecutionPayload,
parent_beacon_block_root: Root,
target_blobs_per_block: uint64) -> bool:
"""
Return ``True`` if and only if ``execution_payload`` is valid with respect to ``self.execution_state``.
"""
...
```

##### Modified `verify_and_notify_new_payload`

```python
def verify_and_notify_new_payload(self: ExecutionEngine,
new_payload_request: NewPayloadRequest) -> bool:
"""
Return ``True`` if and only if ``new_payload_request`` is valid with respect to ``self.execution_state``.
"""
execution_payload = new_payload_request.execution_payload
parent_beacon_block_root = new_payload_request.parent_beacon_block_root

if not self.is_valid_block_hash(execution_payload, parent_beacon_block_root):
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,
MAX_BLOBS_PER_BLOCK // 2):
return False

return True
```

### Epoch processing

#### Modified `process_epoch`
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`

`PayloadAttributes` is extended with the 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_blob_count: uint64 # [New in Electra]
maximum_blob_count: uint64 # [New in Electra]
```
2 changes: 2 additions & 0 deletions specs/electra/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,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_blob_count=MAX_BLOBS_PER_BLOCK // 2, # [New in Electra]
maximum_blob_count=MAX_BLOBS_PER_BLOCK, # [New in Electra]
)
return execution_engine.notify_forkchoice_updated(
head_block_hash=parent_hash,
Expand Down