Skip to content

Commit 554189d

Browse files
authored
Merge pull request ethereum#3800 from ralexstokes/cl-drives-blob-limit
EIP-7742: Uncouple blob limits per block across CL and EL
2 parents 72061bb + 9e085e4 commit 554189d

File tree

6 files changed

+84
-9
lines changed

6 files changed

+84
-9
lines changed

pysetup/spec_builders/electra.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class NoopExecutionEngine(ExecutionEngine):
3030
def notify_new_payload(self: ExecutionEngine,
3131
execution_payload: ExecutionPayload,
3232
parent_beacon_block_root: Root,
33-
execution_requests_list: Sequence[bytes]) -> bool:
33+
execution_requests_list: Sequence[bytes],
34+
target_blobs_per_block: uint64) -> bool:
3435
return True
3536
3637
def notify_forkchoice_updated(self: ExecutionEngine,
@@ -46,7 +47,9 @@ def get_payload(self: ExecutionEngine, payload_id: PayloadId) -> GetPayloadRespo
4647
4748
def is_valid_block_hash(self: ExecutionEngine,
4849
execution_payload: ExecutionPayload,
49-
parent_beacon_block_root: Root) -> bool:
50+
parent_beacon_block_root: Root,
51+
execution_requests_list: Sequence[bytes],
52+
target_blobs_per_block: uint64) -> bool:
5053
return True
5154
5255
def is_valid_versioned_hashes(self: ExecutionEngine, new_payload_request: NewPayloadRequest) -> bool:

specs/_features/eip7594/beacon-chain.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
5353
versioned_hashes=versioned_hashes,
5454
parent_beacon_block_root=state.latest_block_header.parent_root,
5555
execution_requests=body.execution_requests,
56+
target_blobs_per_block=MAX_BLOBS_PER_BLOCK // 2,
5657
)
5758
)
5859
# Cache execution payload header

specs/_features/eip7732/beacon-chain.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ def process_execution_payload(state: BeaconState,
705705
versioned_hashes=versioned_hashes,
706706
parent_beacon_block_root=state.latest_block_header.parent_root,
707707
execution_requests=requests,
708+
target_blobs_per_block=MAX_BLOBS_PER_BLOCK // 2,
708709
)
709710
)
710711

specs/electra/beacon-chain.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
- [Request data](#request-data)
8080
- [Modified `NewPayloadRequest`](#modified-newpayloadrequest)
8181
- [Engine APIs](#engine-apis)
82+
- [Modified `is_valid_block_hash`](#modified-is_valid_block_hash)
8283
- [Modified `notify_new_payload`](#modified-notify_new_payload)
8384
- [Modified `verify_and_notify_new_payload`](#modified-verify_and_notify_new_payload)
8485
- [Block processing](#block-processing)
@@ -1003,30 +1004,51 @@ class NewPayloadRequest(object):
10031004
versioned_hashes: Sequence[VersionedHash]
10041005
parent_beacon_block_root: Root
10051006
execution_requests: ExecutionRequests # [New in Electra]
1007+
target_blobs_per_block: uint64 # [New in Electra:EIP7742]
10061008
```
10071009

10081010
#### Engine APIs
10091011

1012+
##### Modified `is_valid_block_hash`
1013+
1014+
*Note*: The function `is_valid_block_hash` is modified to include the additional
1015+
`execution_requests_list` and `target_blobs_per_block` parameters in Electra.
1016+
1017+
```python
1018+
def is_valid_block_hash(self: ExecutionEngine,
1019+
execution_payload: ExecutionPayload,
1020+
parent_beacon_block_root: Root,
1021+
execution_requests_list: Sequence[bytes],
1022+
target_blobs_per_block: uint64) -> bool:
1023+
"""
1024+
Return ``True`` if and only if ``execution_payload.block_hash`` is computed correctly.
1025+
"""
1026+
...
1027+
```
1028+
10101029
##### Modified `notify_new_payload`
10111030

1012-
*Note*: The function `notify_new_payload` is modified to include the additional `execution_requests` parameter in Electra.
1031+
*Note*: The function `notify_new_payload` is modified to include the additional
1032+
`execution_requests_list` and `target_blobs_per_block` parameters in Electra.
10131033

10141034
```python
10151035
def notify_new_payload(self: ExecutionEngine,
10161036
execution_payload: ExecutionPayload,
10171037
parent_beacon_block_root: Root,
1018-
execution_requests_list: Sequence[bytes]) -> bool:
1038+
execution_requests_list: Sequence[bytes],
1039+
target_blobs_per_block: uint64) -> bool:
10191040
"""
1020-
Return ``True`` if and only if ``execution_payload`` and ``execution_requests``
1041+
Return ``True`` if and only if ``execution_payload`` and ``execution_requests_list``
10211042
are valid with respect to ``self.execution_state``.
10221043
"""
10231044
...
10241045
```
10251046

10261047
##### Modified `verify_and_notify_new_payload`
10271048

1028-
*Note*: The function `verify_and_notify_new_payload` is modified to pass the additional parameter `execution_requests`
1029-
when calling `notify_new_payload` in Electra.
1049+
*Note*: The function `verify_and_notify_new_payload` is modified to pass the additional parameters
1050+
`execution_requests_list` and `target_blobs_per_block` when calling `is_valid_block_hash` and
1051+
`notify_new_payload` in Electra.
10301052

10311053
```python
10321054
def verify_and_notify_new_payload(self: ExecutionEngine,
@@ -1037,11 +1059,17 @@ def verify_and_notify_new_payload(self: ExecutionEngine,
10371059
execution_payload = new_payload_request.execution_payload
10381060
parent_beacon_block_root = new_payload_request.parent_beacon_block_root
10391061
execution_requests_list = get_execution_requests_list(new_payload_request.execution_requests) # [New in Electra]
1062+
target_blobs_per_block = new_payload_request.target_blobs_per_block # [New in Electra:EIP7742]
10401063

10411064
if b'' in execution_payload.transactions:
10421065
return False
10431066

1044-
if not self.is_valid_block_hash(execution_payload, parent_beacon_block_root):
1067+
# [Modified in Electra]
1068+
if not self.is_valid_block_hash(
1069+
execution_payload,
1070+
parent_beacon_block_root,
1071+
execution_requests_list,
1072+
target_blobs_per_block):
10451073
return False
10461074

10471075
if not self.is_valid_versioned_hashes(new_payload_request):
@@ -1051,7 +1079,8 @@ def verify_and_notify_new_payload(self: ExecutionEngine,
10511079
if not self.notify_new_payload(
10521080
execution_payload,
10531081
parent_beacon_block_root,
1054-
execution_requests_list):
1082+
execution_requests_list,
1083+
target_blobs_per_block):
10551084
return False
10561085

10571086
return True
@@ -1213,6 +1242,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
12131242
versioned_hashes=versioned_hashes,
12141243
parent_beacon_block_root=state.latest_block_header.parent_root,
12151244
execution_requests=body.execution_requests, # [New in Electra]
1245+
target_blobs_per_block=MAX_BLOBS_PER_BLOCK // 2, # [New in Electra:EIP7742]
12161246
)
12171247
)
12181248
# Cache execution payload header

specs/electra/fork-choice.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Electra -- Fork Choice
2+
3+
## Table of contents
4+
<!-- TOC -->
5+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
6+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
7+
8+
- [Introduction](#introduction)
9+
- [Containers](#containers)
10+
- [Helpers](#helpers)
11+
- [Extended `PayloadAttributes`](#extended-payloadattributes)
12+
13+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
14+
<!-- /TOC -->
15+
16+
## Introduction
17+
18+
This is the modification of the fork choice accompanying the Electra upgrade.
19+
20+
## Containers
21+
22+
## Helpers
23+
24+
### Extended `PayloadAttributes`
25+
26+
*Note*: `PayloadAttributes` is extended with the target/maximum number of blobs per block.
27+
28+
```python
29+
@dataclass
30+
class PayloadAttributes(object):
31+
timestamp: uint64
32+
prev_randao: Bytes32
33+
suggested_fee_recipient: ExecutionAddress
34+
withdrawals: Sequence[Withdrawal]
35+
parent_beacon_block_root: Root
36+
target_blobs_per_block: uint64 # [New in Electra:EIP7742]
37+
max_blobs_per_block: uint64 # [New in Electra:EIP7742]
38+
```

specs/electra/validator.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ def prepare_execution_payload(state: BeaconState,
176176
suggested_fee_recipient=suggested_fee_recipient,
177177
withdrawals=withdrawals,
178178
parent_beacon_block_root=hash_tree_root(state.latest_block_header),
179+
target_blobs_per_block=MAX_BLOBS_PER_BLOCK // 2, # [New in Electra:EIP7742]
180+
max_blobs_per_block=MAX_BLOBS_PER_BLOCK, # [New in Electra:EIP7742]
179181
)
180182
return execution_engine.notify_forkchoice_updated(
181183
head_block_hash=parent_hash,

0 commit comments

Comments
 (0)