Skip to content

Commit edbace1

Browse files
authored
feat(forks,specs,tests): EIP-7691, EIP-4844: Refactor to use dynamic parameters (#1023)
* fix(fixtures,forks): Disable EIP-7742 on Prague * fix(tests): EIP-4844: Rollback EIP-7742 changes * feat(forks): New methods for EIP-7691+EIP-7762 * fixup(forks): Return instead of error raise in `blob_gas_per_blob` * fix(specs): Replace EIP-4844 constants with `Fork` method calls * fixup(forks): Remove EIP-7762 change * fix(tests): EIP-4844, EIP-7691: Refactor EIP-4844 tests to use dynamic blob parameters * new(tests): EIP-4844: Add blob count combinations to some tests * docs: changelog * fix(docs): Spelling * fix(forks): tox * fix(tests): tox * refactor(tests): parametrize_by_fork rename
1 parent 76069fe commit edbace1

File tree

18 files changed

+966
-712
lines changed

18 files changed

+966
-712
lines changed

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Test fixtures for use by clients are available for each release on the [Github r
2424
- 🔀 Update EIP-7251 according to [spec updates](https://github.com/ethereum/EIPs/pull/9127) ([#1024](https://github.com/ethereum/execution-spec-tests/pull/1024)).
2525
- 🔀 Update EIP-7002 according to [spec updates](https://github.com/ethereum/EIPs/pull/9119) ([#1024](https://github.com/ethereum/execution-spec-tests/pull/1024)).
2626
- 🔀 Update EIP-2935 according to [spec updates](https://github.com/ethereum/EIPs/pull/9144) ([#1046](https://github.com/ethereum/execution-spec-tests/pull/1046))
27+
-[EIP-7691](https://eips.ethereum.org/EIPS/eip-7691) Blob throughput increase tests by parametrization of existing EIP-4844 tests ([#1023](https://github.com/ethereum/execution-spec-tests/pull/1023))
2728

2829
### 🛠️ Framework
2930

@@ -71,6 +72,7 @@ Test fixtures for use by clients are available for each release on the [Github r
7172
- ✨ Slow tests now have greater timeout when making a request to the T8N server ([#1037](https://github.com/ethereum/execution-spec-tests/pull/1037)).
7273
- ✨ Introduce [`pytest.mark.parametrize_by_fork`](https://ethereum.github.io/execution-spec-tests/main/writing_tests/test_markers/#pytestmarkfork_parametrize) helper marker ([#1019](https://github.com/ethereum/execution-spec-tests/pull/1019), [#1057](https://github.com/ethereum/execution-spec-tests/pull/1057)).
7374
- 🐞 fix(consume): allow absolute paths with `--evm-bin` ([#1052](https://github.com/ethereum/execution-spec-tests/pull/1052)).
75+
- ✨ Disable EIP-7742 framework changes for Prague ([#1023](https://github.com/ethereum/execution-spec-tests/pull/1023)).
7476

7577
### 🔧 EVM Tools
7678

src/ethereum_test_fixtures/blockchain.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ def from_fixture_header(
229229
List[Hash],
230230
Hash,
231231
List[Bytes],
232-
HexNumber,
233232
]
234233

235234
# Important: We check EngineNewPayloadV3Parameters first as it has more fields, and pydantic

src/ethereum_test_fixtures/tests/test_blockchain.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
Bytes,
1515
Hash,
1616
HeaderNonce,
17-
HexNumber,
1817
TestPrivateKey,
1918
ZeroPaddedHexNumber,
2019
to_json,
@@ -667,7 +666,6 @@
667666
excess_blob_gas=18,
668667
parent_beacon_block_root=19,
669668
requests_hash=20,
670-
target_blobs_per_block=21,
671669
),
672670
transactions=[
673671
Transaction(
@@ -729,7 +727,7 @@
729727
"blobGasUsed": hex(17),
730728
"excessBlobGas": hex(18),
731729
"blockHash": (
732-
"0x9f6459fb2eca2b75ee861e97d679ba91457bb446c8484a7ad76d1675a7f78fde"
730+
"0x93bd662d8a80a1f54bffc6d140b83d6cda233209998809f9540be51178b4d0b6"
733731
),
734732
"transactions": [
735733
Transaction(
@@ -787,9 +785,8 @@
787785
),
788786
).requests_list
789787
],
790-
HexNumber(21).hex(),
791788
],
792-
"forkchoiceUpdatedVersion": "4",
789+
"forkchoiceUpdatedVersion": "3",
793790
"newPayloadVersion": "4",
794791
"validationError": "BlockException.INCORRECT_BLOCK_FORMAT"
795792
"|TransactionException.INTRINSIC_GAS_TOO_LOW",
@@ -824,7 +821,6 @@
824821
excess_blob_gas=18,
825822
parent_beacon_block_root=19,
826823
requests_hash=20,
827-
target_blobs_per_block=21,
828824
),
829825
transactions=[
830826
Transaction(
@@ -885,7 +881,7 @@
885881
"blobGasUsed": hex(17),
886882
"excessBlobGas": hex(18),
887883
"blockHash": (
888-
"0x9f6459fb2eca2b75ee861e97d679ba91457bb446c8484a7ad76d1675a7f78fde"
884+
"0x93bd662d8a80a1f54bffc6d140b83d6cda233209998809f9540be51178b4d0b6"
889885
),
890886
"transactions": [
891887
Transaction(
@@ -943,10 +939,9 @@
943939
),
944940
).requests_list
945941
],
946-
HexNumber(21).hex(),
947942
],
948943
"newPayloadVersion": "4",
949-
"forkchoiceUpdatedVersion": "4",
944+
"forkchoiceUpdatedVersion": "3",
950945
"validationError": "BlockException.INCORRECT_BLOCK_FORMAT"
951946
"|TransactionException.INTRINSIC_GAS_TOO_LOW",
952947
},
@@ -1224,7 +1219,6 @@ def test_json_deserialization(
12241219
target_pubkey=BLSPublicKey(2),
12251220
),
12261221
).requests_list,
1227-
HexNumber(9),
12281222
),
12291223
[
12301224
{
@@ -1290,7 +1284,6 @@ def test_json_deserialization(
12901284
),
12911285
).requests_list
12921286
],
1293-
HexNumber(9).hex(),
12941287
],
12951288
id="fixture_engine_new_payload_parameters_v4",
12961289
),

src/ethereum_test_forks/base_fork.py

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ def __call__(self, block_number: int = 0, timestamp: int = 0) -> Any:
2222

2323

2424
class MemoryExpansionGasCalculator(Protocol):
25-
"""A protocol to calculate the gas cost of memory expansion for a given fork."""
25+
"""A protocol to calculate the gas cost of memory expansion at a given fork."""
2626

2727
def __call__(self, *, new_bytes: int, previous_bytes: int = 0) -> int:
2828
"""Return gas cost of expanding the memory by the given length."""
2929
pass
3030

3131

3232
class CalldataGasCalculator(Protocol):
33-
"""A protocol to calculate the transaction gas cost of calldata for a given fork."""
33+
"""A protocol to calculate the transaction gas cost of calldata at a given fork."""
3434

3535
def __call__(self, *, data: BytesConvertible, floor: bool = False) -> int:
3636
"""Return the transaction gas cost of calldata given its contents."""
@@ -46,7 +46,7 @@ def __call__(self, *, data: BytesConvertible) -> int:
4646

4747

4848
class TransactionIntrinsicCostCalculator(Protocol):
49-
"""A protocol to calculate the intrinsic gas cost of a transaction for a given fork."""
49+
"""A protocol to calculate the intrinsic gas cost of a transaction at a given fork."""
5050

5151
def __call__(
5252
self,
@@ -78,6 +78,29 @@ def __call__(
7878
pass
7979

8080

81+
class BlobGasPriceCalculator(Protocol):
82+
"""A protocol to calculate the blob gas price given the excess blob gas at a given fork."""
83+
84+
def __call__(self, *, excess_blob_gas: int) -> int:
85+
"""Return the blob gas price given the excess blob gas."""
86+
pass
87+
88+
89+
class ExcessBlobGasCalculator(Protocol):
90+
"""A protocol to calculate the excess blob gas for a block at a given fork."""
91+
92+
def __call__(
93+
self,
94+
*,
95+
parent_excess_blob_gas: int | None = None,
96+
parent_excess_blobs: int | None = None,
97+
parent_blob_gas_used: int | None = None,
98+
parent_blob_count: int | None = None,
99+
) -> int:
100+
"""Return the excess blob gas given the parent's excess blob gas and blob gas used."""
101+
pass
102+
103+
81104
class BaseForkMeta(ABCMeta):
82105
"""Metaclass for BaseFork."""
83106

@@ -171,16 +194,24 @@ def header_blob_gas_used_required(cls, block_number: int = 0, timestamp: int = 0
171194

172195
@classmethod
173196
@abstractmethod
174-
def header_beacon_root_required(cls, block_number: int, timestamp: int) -> bool:
197+
def header_beacon_root_required(cls, block_number: int = 0, timestamp: int = 0) -> bool:
175198
"""Return true if the header must contain parent beacon block root."""
176199
pass
177200

178201
@classmethod
179202
@abstractmethod
180-
def header_requests_required(cls, block_number: int, timestamp: int) -> bool:
203+
def header_requests_required(cls, block_number: int = 0, timestamp: int = 0) -> bool:
181204
"""Return true if the header must contain beacon chain requests."""
182205
pass
183206

207+
@classmethod
208+
@abstractmethod
209+
def header_target_blobs_per_block_required(
210+
cls, block_number: int = 0, timestamp: int = 0
211+
) -> bool:
212+
"""Return true if the header must contain target blobs per block."""
213+
pass
214+
184215
# Gas related abstract methods
185216

186217
@classmethod
@@ -226,26 +257,48 @@ def transaction_intrinsic_cost_calculator(
226257

227258
@classmethod
228259
@abstractmethod
229-
def header_target_blobs_per_block_required(cls, block_number: int, timestamp: int) -> bool:
230-
"""Return true if the header must contain target blobs per block."""
260+
def blob_gas_price_calculator(
261+
cls, block_number: int = 0, timestamp: int = 0
262+
) -> BlobGasPriceCalculator:
263+
"""Return a callable that calculates the blob gas price at a given fork."""
264+
pass
265+
266+
@classmethod
267+
@abstractmethod
268+
def excess_blob_gas_calculator(
269+
cls, block_number: int = 0, timestamp: int = 0
270+
) -> ExcessBlobGasCalculator:
271+
"""Return a callable that calculates the excess blob gas for a block at a given fork."""
272+
pass
273+
274+
@classmethod
275+
@abstractmethod
276+
def min_base_fee_per_blob_gas(cls, block_number: int = 0, timestamp: int = 0) -> int:
277+
"""Return the minimum base fee per blob gas at a given fork."""
278+
pass
279+
280+
@classmethod
281+
@abstractmethod
282+
def blob_gas_per_blob(cls, block_number: int = 0, timestamp: int = 0) -> int:
283+
"""Return the amount of blob gas used per blob at a given fork."""
231284
pass
232285

233286
@classmethod
234287
@abstractmethod
235-
def blob_gas_per_blob(cls, block_number: int, timestamp: int) -> int:
236-
"""Return amount of blob gas used per blob for a given fork."""
288+
def blob_base_fee_update_fraction(cls, block_number: int = 0, timestamp: int = 0) -> int:
289+
"""Return the blob base fee update fraction at a given fork."""
237290
pass
238291

239292
@classmethod
240293
@abstractmethod
241-
def target_blobs_per_block(cls, block_number: int, timestamp: int) -> int:
242-
"""Return target blobs per block for a given fork."""
294+
def target_blobs_per_block(cls, block_number: int = 0, timestamp: int = 0) -> int:
295+
"""Return the target blobs per block at a given fork."""
243296
pass
244297

245298
@classmethod
246299
@abstractmethod
247-
def max_blobs_per_block(cls, block_number: int, timestamp: int) -> int:
248-
"""Return max blobs per block for a given fork."""
300+
def max_blobs_per_block(cls, block_number: int = 0, timestamp: int = 0) -> int:
301+
"""Return the max blobs per block at a given fork."""
249302
pass
250303

251304
@classmethod

0 commit comments

Comments
 (0)