Skip to content

Commit b4f9b16

Browse files
authored
Merge pull request #1040 from ethereum/eip-blob-schedule
feat(forks,specs,fixtures): add eip-7840 blob schedule config
2 parents 607d1b6 + f42e224 commit b4f9b16

39 files changed

+801
-144
lines changed

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Release tarball changes:
8080
- ✨ Allow verification of the transaction receipt on executed test transactions ([#1068](https://github.com/ethereum/execution-spec-tests/pull/1068)).
8181
- ✨ Modify `valid_at_transition_to` marker to add keyword arguments `subsequent_transitions` and `until` to fill a test using multiple transition forks ([#1081](https://github.com/ethereum/execution-spec-tests/pull/1081)).
8282
- 🐞 fix(consume): use `"HIVE_CHECK_LIVE_PORT"` to signal hive to wait for port 8551 (Engine API port) instead of the 8545 port when running `consume engine` ([#1095](https://github.com/ethereum/execution-spec-tests/pull/1095)).
83+
-`state_test`, `blockchain_test` and `blockchain_test_engine` fixtures now contain the `blobSchedule` from [EIP-7840](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7840.md), only for tests filled for Cancun and Prague forks ([#1040](https://github.com/ethereum/execution-spec-tests/pull/1040)).
8384

8485
### 🔧 EVM Tools
8586

@@ -107,6 +108,7 @@ Release tarball changes:
107108
- The EOF fixture format contained in `eof_tests` may now contain multiple exceptions in the `"exception"` field in the form of a pipe (`|`) separated string ([#759](https://github.com/ethereum/execution-spec-tests/pull/759)).
108109
- Remove redundant tests within stable and develop fixture releases, moving them to a separate legacy release ([#788](https://github.com/ethereum/execution-spec-tests/pull/788)).
109110
- Ruff now replaces Flake8, Isort and Black resulting in significant changes to the entire code base including its usage ([#922](https://github.com/ethereum/execution-spec-tests/pull/922)).
111+
- `state_test`, `blockchain_test` and `blockchain_test_engine` fixtures now contain a `config` field, which contains an object that contains a `blobSchedule` field. On the `blockchain_test` and `blockchain_test_engine` fixtures, the object also contains a duplicate of the `network` root field. The root's `network` field will be eventually deprecated ([#1040](https://github.com/ethereum/execution-spec-tests/pull/1040)).
110112

111113
## [v3.0.0](https://github.com/ethereum/execution-spec-tests/releases/tag/v3.0.0) - 2024-07-22
112114

docs/consuming_tests/blockchain_test.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,12 @@ For each [`Fixture`](#fixture) test object in the JSON fixture file, perform the
5454

5555
#### - `network`: [`Fork`](./common_types.md#fork)
5656

57+
##### TO BE DEPRECATED
58+
5759
Fork configuration for the test.
5860

61+
This field is going to be replaced by the value contained in `config.network`.
62+
5963
#### - `pre`: [`Alloc`](./common_types.md#alloc-mappingaddressaccount)
6064

6165
Starting account allocation for the test. State root calculated from this allocation must match the one in the genesis block.
@@ -84,6 +88,20 @@ Account allocation for verification after all the blocks have been processed.
8488

8589
Deprecated: Seal engine used to mine the blocks.
8690

91+
#### - `config`: [`FixtureConfig`](#fixtureconfig)
92+
93+
Chain configuration object to be applied to the client running the blockchain test.
94+
95+
### `FixtureConfig`
96+
97+
#### - `network`: [`Fork`](./common_types.md#fork)
98+
99+
Fork configuration for the test. It is guaranteed that this field contains the same value as the root field `network`.
100+
101+
#### - `blobSchedule`: [`BlobSchedule`](./common_types.md#blobschedule-mappingforkforkblobschedule)
102+
103+
Optional; present from Cancun on. Maps forks to their blob schedule configurations as defined by [EIP-7840](https://eips.ethereum.org/EIPS/eip-7840).
104+
87105
### `FixtureHeader`
88106

89107
#### - `parentHash`: [`Hash`](./common_types.md#hash)

docs/consuming_tests/blockchain_test_engine.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ For each [`HiveFixture`](#hivefixture) test object in the JSON fixture file, per
4545

4646
#### - `network`: [`Fork`](./common_types.md#fork)
4747

48+
##### TO BE DEPRECATED
49+
4850
Fork configuration for the test.
4951

52+
This field is going to be replaced by the value contained in `config.network`.
53+
5054
#### - `genesisBlockHeader`: [`FixtureHeader`](./blockchain_test.md#fixtureheader)
5155

5256
Genesis block header.
@@ -63,10 +67,28 @@ Version of the `engine_forkchoiceUpdatedVX` directive to use to set the head of
6367

6468
Starting account allocation for the test. State root calculated from this allocation must match the one in the genesis block.
6569

70+
#### - `lastblockhash`: [`Hash`](./common_types.md#hash)
71+
72+
Hash of the last valid block, or the genesis block hash if the list of blocks is empty, or contains a single invalid block.
73+
6674
#### - `post`: [`Alloc`](./common_types.md#alloc-mappingaddressaccount)
6775

6876
Account allocation for verification after all the blocks have been processed.
6977

78+
#### - `config`: [`FixtureConfig`](#fixtureconfig)
79+
80+
Chain configuration object to be applied to the client running the blockchain engine test.
81+
82+
### `FixtureConfig`
83+
84+
#### - `network`: [`Fork`](./common_types.md#fork)
85+
86+
Fork configuration for the test. It is guaranteed that this field contains the same value as the root field `network`.
87+
88+
#### - `blobSchedule`: [`BlobSchedule`](./common_types.md#blobschedule-mappingforkforkblobschedule)
89+
90+
Optional; present from Cancun on. Maps forks to their blob schedule configurations as defined by [EIP-7840](https://eips.ethereum.org/EIPS/eip-7840).
91+
7092
### `FixtureEngineNewPayload`
7193

7294
#### - `executionPayload`: [`FixtureExecutionPayload`](#fixtureexecutionpayload)

docs/consuming_tests/common_types.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,26 @@ Storage of the account.
8282

8383
State allocation represented as a JSON object, where the keys are the addresses of the accounts, and the values are the accounts.
8484

85+
### `BlobSchedule`: [`Mapping`](#mapping)`[`[`Fork`](#fork)`,`[`ForkBlobSchedule`](#forkblobschedule)`]`
86+
87+
Maps forks to blob schedule configurations as defined by [EIP-7840](https://eips.ethereum.org/EIPS/eip-7840).
88+
89+
### `ForkBlobSchedule`
90+
91+
A fork blob schedule as defined by [EIP-7840](https://eips.ethereum.org/EIPS/eip-7840) as a JSON dictionary with the following entries:
92+
93+
#### - `target`: [`ZeroPaddedHexNumber`](#zeropaddedhexnumber)
94+
95+
The target blob count for a block.
96+
97+
#### - `max`: [`ZeroPaddedHexNumber`](#zeropaddedhexnumber)
98+
99+
The maximum possible blob count for a block.
100+
101+
#### - `base_fee_update_fraction`: [`ZeroPaddedHexNumber`](#zeropaddedhexnumber)
102+
103+
The blob base fee update fraction (adjusts the responsiveness of blob gas pricing per fork).
104+
85105
## Fork
86106

87107
Fork type is represented as a JSON string that can be set to one of the following values:

docs/consuming_tests/state_test.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ Transaction to be executed.
6060

6161
Mapping of lists of post for verification per fork, where each element represents a single possible outcome of the transaction execution after being applied to the `pre`.
6262

63+
#### - `config`: [`FixtureConfig`](#fixtureconfig)
64+
65+
Chain configuration object.
66+
67+
### `FixtureConfig`
68+
69+
At the moment this object can contain only the `blobSchedule` that is necessary to apply the correct cap to the maximum amount of blobs that a transaction can have. Otherwise, in forks prior to Cancun for example, it will be an empty JSON object.
70+
71+
#### - `blobSchedule`: [`BlobSchedule`](./common_types.md#blobschedule-mappingforkforkblobschedule)
72+
73+
Optional; present from Cancun on. Maps forks to their blob schedule configurations as defined by [EIP-7840](https://eips.ethereum.org/EIPS/eip-7840).
74+
6375
### `FixtureEnvironment`
6476

6577
#### - `currentCoinbase`: [`Address`](./common_types.md#address)

src/ethereum_clis/clis/besu.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import requests
1313

14+
from ethereum_test_base_types import BlobSchedule
1415
from ethereum_test_exceptions import (
1516
EOFException,
1617
ExceptionMapper,
@@ -101,8 +102,9 @@ def evaluate(
101102
txs: List[Transaction],
102103
env: Environment,
103104
fork: Fork,
104-
chain_id: int = 1,
105-
reward: int = 0,
105+
chain_id: int,
106+
reward: int,
107+
blob_schedule: BlobSchedule | None = None,
106108
eips: Optional[List[int]] = None,
107109
debug_output_path: str = "",
108110
state_test: bool = False,

src/ethereum_clis/tests/test_execution_specs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ def test_evm_t8n(
176176
txs=txs,
177177
env=env,
178178
fork=Berlin,
179+
chain_id=1,
180+
reward=0,
181+
blob_schedule=Berlin.blob_schedule(),
179182
)
180183
assert to_json(t8n_output.alloc) == expected.get("alloc")
181184
if isinstance(t8n, ExecutionSpecsTransitionTool):

src/ethereum_clis/transition_tool.py

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import textwrap
99
import time
1010
from abc import abstractmethod
11-
from dataclasses import dataclass, field
11+
from dataclasses import dataclass
1212
from pathlib import Path
1313
from typing import Any, Dict, List, Mapping, Optional, Type
1414
from urllib.parse import urlencode
@@ -17,14 +17,21 @@
1717
from requests.exceptions import ConnectionError as RequestsConnectionError
1818
from requests_unixsocket import Session # type: ignore
1919

20+
from ethereum_test_base_types import BlobSchedule
2021
from ethereum_test_exceptions import ExceptionMapper
2122
from ethereum_test_fixtures import FixtureFormat, FixtureVerifier
2223
from ethereum_test_forks import Fork
2324
from ethereum_test_types import Alloc, Environment, Transaction
2425

2526
from .ethereum_cli import EthereumCLI
2627
from .file_utils import dump_files_to_directory, write_json_file
27-
from .types import TransactionReceipt, TransitionToolInput, TransitionToolOutput
28+
from .types import (
29+
TransactionReceipt,
30+
TransitionToolContext,
31+
TransitionToolInput,
32+
TransitionToolOutput,
33+
TransitionToolRequest,
34+
)
2835

2936
model_dump_config: Mapping = {"by_alias": True, "exclude_none": True}
3037

@@ -130,9 +137,10 @@ class TransitionToolData:
130137
txs: List[Transaction]
131138
env: Environment
132139
fork_name: str
133-
chain_id: int = field(default=1)
134-
reward: int = field(default=0)
135-
state_test: bool = field(default=False)
140+
chain_id: int
141+
reward: int
142+
blob_schedule: BlobSchedule | None
143+
state_test: bool
136144

137145
def to_input(self) -> TransitionToolInput:
138146
"""Convert the data to a TransactionToolInput object."""
@@ -142,6 +150,18 @@ def to_input(self) -> TransitionToolInput:
142150
env=self.env,
143151
)
144152

153+
def get_request_data(self) -> TransitionToolRequest:
154+
"""Convert the data to a TransitionToolRequest object."""
155+
return TransitionToolRequest(
156+
state=TransitionToolContext(
157+
fork=self.fork_name,
158+
chain_id=self.chain_id,
159+
reward=self.reward,
160+
blob_schedule=self.blob_schedule,
161+
),
162+
input=self.to_input(),
163+
)
164+
145165
def _evaluate_filesystem(
146166
self,
147167
*,
@@ -298,37 +318,29 @@ def _evaluate_server(
298318
timeout: int,
299319
) -> TransitionToolOutput:
300320
"""Execute the transition tool sending inputs and outputs via a server."""
301-
input_contents = t8n_data.to_input()
302-
input_json = input_contents.model_dump(mode="json", **model_dump_config)
303-
post_data = {
304-
"state": {
305-
"fork": t8n_data.fork_name,
306-
"chainid": t8n_data.chain_id,
307-
"reward": t8n_data.reward,
308-
},
309-
"input": input_json,
310-
}
321+
request_data = t8n_data.get_request_data()
322+
request_data_json = request_data.model_dump(mode="json", **model_dump_config)
311323

312324
if debug_output_path:
313325
request_info = (
314326
f"Server URL: {self.server_url}\n\n"
315-
f"Request Data:\n{json.dumps(post_data, indent=2)}\n"
327+
f"Request Data:\n{json.dumps(request_data_json, indent=2)}\n"
316328
)
317329
dump_files_to_directory(
318330
debug_output_path,
319331
{
320-
"input/alloc.json": input_contents.alloc,
321-
"input/env.json": input_contents.env,
332+
"input/alloc.json": request_data.input.alloc,
333+
"input/env.json": request_data.input.env,
322334
"input/txs.json": [
323335
tx.model_dump(mode="json", **model_dump_config)
324-
for tx in input_contents.txs
336+
for tx in request_data.input.txs
325337
],
326338
"request_info.txt": request_info,
327339
},
328340
)
329341

330342
response = self._server_post(
331-
data=post_data, url_args=self._generate_post_args(t8n_data), timeout=timeout
343+
data=request_data_json, url_args=self._generate_post_args(t8n_data), timeout=timeout
332344
)
333345
output: TransitionToolOutput = TransitionToolOutput.model_validate(response.json())
334346

@@ -465,8 +477,9 @@ def evaluate(
465477
txs: List[Transaction],
466478
env: Environment,
467479
fork: Fork,
468-
chain_id: int = 1,
469-
reward: int = 0,
480+
chain_id: int,
481+
reward: int,
482+
blob_schedule: BlobSchedule | None,
470483
eips: Optional[List[int]] = None,
471484
debug_output_path: str = "",
472485
state_test: bool = False,
@@ -493,6 +506,7 @@ def evaluate(
493506
fork_name=fork_name,
494507
chain_id=chain_id,
495508
reward=reward,
509+
blob_schedule=blob_schedule,
496510
state_test=state_test,
497511
)
498512

src/ethereum_clis/types.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from pydantic import Field
66

7-
from ethereum_test_base_types import Bloom, Bytes, CamelModel, Hash, HexNumber
7+
from ethereum_test_base_types import BlobSchedule, Bloom, Bytes, CamelModel, Hash, HexNumber
88
from ethereum_test_types import Alloc, Environment, Transaction, TransactionReceipt
99

1010

@@ -52,3 +52,19 @@ class TransitionToolOutput(CamelModel):
5252
alloc: Alloc
5353
result: Result
5454
body: Bytes | None = None
55+
56+
57+
class TransitionToolContext(CamelModel):
58+
"""Transition tool context."""
59+
60+
fork: str
61+
chain_id: int = Field(..., alias="chainid")
62+
reward: int
63+
blob_schedule: BlobSchedule | None
64+
65+
66+
class TransitionToolRequest(CamelModel):
67+
"""Transition tool server request data."""
68+
69+
state: TransitionToolContext
70+
input: TransitionToolInput

src/ethereum_test_base_types/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616
Wei,
1717
ZeroPaddedHexNumber,
1818
)
19-
from .composite_types import AccessList, Account, Alloc, Storage, StorageRootType
19+
from .composite_types import (
20+
AccessList,
21+
Account,
22+
Alloc,
23+
BlobSchedule,
24+
ForkBlobSchedule,
25+
Storage,
26+
StorageRootType,
27+
)
2028
from .constants import (
2129
AddrAA,
2230
AddrBB,
@@ -39,16 +47,18 @@
3947
"AddrBB",
4048
"Address",
4149
"Alloc",
50+
"BlobSchedule",
4251
"Bloom",
4352
"BLSPublicKey",
4453
"BLSSignature",
4554
"Bytes",
4655
"CamelModel",
4756
"EmptyOmmersRoot",
4857
"EmptyTrieRoot",
49-
"FixedSizeBytes",
5058
"EthereumTestBaseModel",
5159
"EthereumTestRootModel",
60+
"FixedSizeBytes",
61+
"ForkBlobSchedule",
5262
"Hash",
5363
"HashInt",
5464
"HeaderNonce",

0 commit comments

Comments
 (0)