Skip to content

Commit d492229

Browse files
marioevzdanceratopz
authored andcommitted
feat(types,forks,fixtures,specs): EIP-7691: Add blob schedule
Co-authored-by: danceratopz <[email protected]>
1 parent 3185c6f commit d492229

File tree

20 files changed

+274
-27
lines changed

20 files changed

+274
-27
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ Chain configuration object to be applied to the client running the blockchain te
9898

9999
Fork configuration for the test. It is guaranteed that this field contains the same value as the root field `network`.
100100

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+
101105
### `FixtureHeader`
102106

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

docs/consuming_tests/blockchain_test_engine.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ Chain configuration object to be applied to the client running the blockchain en
8585

8686
Fork configuration for the test. It is guaranteed that this field contains the same value as the root field `network`.
8787

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+
8892
### `FixtureEngineNewPayload`
8993

9094
#### - `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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ Chain configuration object.
6666

6767
### `FixtureConfig`
6868

69-
At the moment, this object is an empty dictionary and contains no fields.
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).
7074

7175
### `FixtureEnvironment`
7276

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",

src/ethereum_test_base_types/composite_types.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,3 +462,29 @@ class AccessList(CamelModel):
462462
def to_list(self) -> List[Address | List[Hash]]:
463463
"""Return access list as a list of serializable elements."""
464464
return [self.address, self.storage_keys]
465+
466+
467+
class ForkBlobSchedule(CamelModel):
468+
"""Representation of the blob schedule of a given fork."""
469+
470+
target_blobs_per_block: HexNumber = Field(..., alias="target")
471+
max_blobs_per_block: HexNumber = Field(..., alias="max")
472+
base_fee_update_fraction: HexNumber = Field(...)
473+
474+
475+
class BlobSchedule(EthereumTestRootModel[Dict[str, ForkBlobSchedule]]):
476+
"""Blob schedule configuration dictionary."""
477+
478+
root: Dict[str, ForkBlobSchedule] = Field(default_factory=dict, validate_default=True)
479+
480+
def append(self, *, fork: str, schedule: Any):
481+
"""Append a new fork schedule."""
482+
if not isinstance(schedule, ForkBlobSchedule):
483+
schedule = ForkBlobSchedule(**schedule)
484+
self.root[fork] = schedule
485+
486+
def last(self) -> ForkBlobSchedule | None:
487+
"""Return the last schedule."""
488+
if len(self.root) == 0:
489+
return None
490+
return list(self.root.values())[-1]

src/ethereum_test_fixtures/blockchain.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
)
4444

4545
from .base import BaseFixture
46+
from .common import FixtureBlobSchedule
4647

4748

4849
class HeaderForkRequirement(str):
@@ -400,6 +401,7 @@ class FixtureConfig(CamelModel):
400401
"""Chain configuration for a fixture."""
401402

402403
fork: str = Field(..., alias="network")
404+
blob_schedule: FixtureBlobSchedule | None = None
403405

404406

405407
class InvalidFixtureBlock(CamelModel):
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""Common types used to define multiple fixture types."""
2+
3+
from typing import Dict
4+
5+
from pydantic import Field
6+
7+
from ethereum_test_base_types import (
8+
BlobSchedule,
9+
CamelModel,
10+
EthereumTestRootModel,
11+
ZeroPaddedHexNumber,
12+
)
13+
14+
15+
class FixtureForkBlobSchedule(CamelModel):
16+
"""Representation of the blob schedule of a given fork."""
17+
18+
target_blobs_per_block: ZeroPaddedHexNumber = Field(..., alias="target")
19+
max_blobs_per_block: ZeroPaddedHexNumber = Field(..., alias="max")
20+
base_fee_update_fraction: ZeroPaddedHexNumber = Field(...)
21+
22+
23+
class FixtureBlobSchedule(EthereumTestRootModel[Dict[str, FixtureForkBlobSchedule]]):
24+
"""Blob schedule configuration dictionary."""
25+
26+
root: Dict[str, FixtureForkBlobSchedule] = Field(default_factory=dict, validate_default=True)
27+
28+
@classmethod
29+
def from_blob_schedule(
30+
cls, blob_schedule: BlobSchedule | None
31+
) -> "FixtureBlobSchedule | None":
32+
"""Return a FixtureBlobSchedule from a BlobSchedule."""
33+
if blob_schedule is None:
34+
return None
35+
return cls(
36+
root=blob_schedule.model_dump(),
37+
)

src/ethereum_test_fixtures/state.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44

55
from pydantic import BaseModel, Field
66

7-
from ethereum_test_base_types import AccessList, Address, Alloc, Bytes, Hash, ZeroPaddedHexNumber
7+
from ethereum_test_base_types import (
8+
AccessList,
9+
Address,
10+
Alloc,
11+
Bytes,
12+
Hash,
13+
ZeroPaddedHexNumber,
14+
)
815
from ethereum_test_exceptions import TransactionExceptionInstanceOrList
916
from ethereum_test_types.types import (
1017
AuthorizationTupleGeneric,
@@ -15,6 +22,7 @@
1522
)
1623

1724
from .base import BaseFixture
25+
from .common import FixtureBlobSchedule
1826

1927

2028
class FixtureEnvironment(EnvironmentGeneric[ZeroPaddedHexNumber]):
@@ -89,7 +97,7 @@ class FixtureForkPost(CamelModel):
8997
class FixtureConfig(CamelModel):
9098
"""Chain configuration for a fixture."""
9199

92-
pass
100+
blob_schedule: FixtureBlobSchedule | None = None
93101

94102

95103
class StateFixture(BaseFixture):

0 commit comments

Comments
 (0)