Skip to content

Commit 3c7ca39

Browse files
committed
feat: updates for payload attributes v4.
1 parent bca045e commit 3c7ca39

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed

src/ethereum_test_forks/base_fork.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,14 @@ def target_blobs_per_block(cls, block_number: int, timestamp: int) -> int:
270270
"""
271271
pass
272272

273+
@classmethod
274+
@abstractmethod
275+
def max_blobs_per_block(cls, block_number: int, timestamp: int) -> int:
276+
"""
277+
Returns the max blobs per block for a given fork.
278+
"""
279+
pass
280+
273281
@classmethod
274282
@abstractmethod
275283
def get_reward(cls, block_number: int = 0, timestamp: int = 0) -> int:
@@ -384,6 +392,26 @@ def engine_new_payload_target_blobs_per_block(
384392
"""
385393
pass
386394

395+
@classmethod
396+
@abstractmethod
397+
def engine_payload_attribute_target_blobs_per_block(
398+
cls, block_number: int = 0, timestamp: int = 0
399+
) -> bool:
400+
"""
401+
Returns true if the payload attributes include the target blobs per block.
402+
"""
403+
pass
404+
405+
@classmethod
406+
@abstractmethod
407+
def engine_payload_attribute_max_blobs_per_block(
408+
cls, block_number: int = 0, timestamp: int = 0
409+
) -> bool:
410+
"""
411+
Returns true if the payload attributes include the max blobs per block.
412+
"""
413+
pass
414+
387415
@classmethod
388416
@abstractmethod
389417
def engine_forkchoice_updated_version(

src/ethereum_test_forks/forks/forks.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,13 @@ def target_blobs_per_block(cls, block_number: int, timestamp: int) -> int:
239239
"""
240240
return 0
241241

242+
@classmethod
243+
def max_blobs_per_block(cls, block_number: int, timestamp: int) -> int:
244+
"""
245+
Returns the max number of blobs per block for a given fork.
246+
"""
247+
return 0
248+
242249
@classmethod
243250
def header_requests_required(cls, block_number: int, timestamp: int) -> bool:
244251
"""
@@ -305,6 +312,24 @@ def engine_new_payload_target_blobs_per_block(
305312
"""
306313
return False
307314

315+
@classmethod
316+
def engine_payload_attribute_target_blobs_per_block(
317+
cls, block_number: int = 0, timestamp: int = 0
318+
) -> bool:
319+
"""
320+
At genesis, payload attributes do not include the target blobs per block.
321+
"""
322+
return False
323+
324+
@classmethod
325+
def engine_payload_attribute_max_blobs_per_block(
326+
cls, block_number: int = 0, timestamp: int = 0
327+
) -> bool:
328+
"""
329+
At genesis, payload attributes do not include the max blobs per block.
330+
"""
331+
return False
332+
308333
@classmethod
309334
def engine_forkchoice_updated_version(
310335
cls, block_number: int = 0, timestamp: int = 0
@@ -978,6 +1003,13 @@ def target_blobs_per_block(cls, block_number: int, timestamp: int) -> int:
9781003
"""
9791004
return 3
9801005

1006+
@classmethod
1007+
def max_blobs_per_block(cls, block_number: int, timestamp: int) -> int:
1008+
"""
1009+
Blobs are enabled starting from Cancun, with a static max of 6 blobs.
1010+
"""
1011+
return 6
1012+
9811013
@classmethod
9821014
def tx_types(cls, block_number: int = 0, timestamp: int = 0) -> List[int]:
9831015
"""
@@ -1212,6 +1244,20 @@ def header_requests_required(cls, block_number: int, timestamp: int) -> bool:
12121244
"""
12131245
return True
12141246

1247+
@classmethod
1248+
def target_blobs_per_block(cls, block_number: int, timestamp: int) -> int:
1249+
"""
1250+
Blobs are decoupled from EL at Prague, and gets a static target of 6 blobs from the CL.
1251+
"""
1252+
return 6
1253+
1254+
@classmethod
1255+
def max_blobs_per_block(cls, block_number: int, timestamp: int) -> int:
1256+
"""
1257+
Blobs are decoupled from EL at Prague, and gets static max of 9 blobs from the CL.
1258+
"""
1259+
return 9
1260+
12151261
@classmethod
12161262
def header_target_blobs_per_block_required(
12171263
cls,
@@ -1249,6 +1295,24 @@ def engine_new_payload_version(
12491295
"""
12501296
return 4
12511297

1298+
@classmethod
1299+
def engine_payload_attribute_target_blobs_per_block(
1300+
cls, block_number: int = 0, timestamp: int = 0
1301+
) -> bool:
1302+
"""
1303+
Starting at Prague, payload attributes include the target blobs per block.
1304+
"""
1305+
return True
1306+
1307+
@classmethod
1308+
def engine_payload_attribute_max_blobs_per_block(
1309+
cls, block_number: int = 0, timestamp: int = 0
1310+
) -> bool:
1311+
"""
1312+
Starting at Prague, payload attributes include the max blobs per block.
1313+
"""
1314+
return True
1315+
12521316

12531317
class CancunEIP7692( # noqa: SC200
12541318
Cancun,

src/ethereum_test_rpc/types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ class PayloadAttributes(CamelModel):
111111
suggested_fee_recipient: Address
112112
withdrawals: List[Withdrawal] | None = None
113113
parent_beacon_block_root: Hash | None = None
114+
target_blobs_per_block: HexNumber | None = None
115+
max_blobs_per_block: HexNumber | None = None
114116

115117

116118
class BlobsBundle(CamelModel):

src/pytest_plugins/execute/rpc/hive.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,16 @@ def generate_block(self: "EthRPC"):
656656
suggested_fee_recipient=Address(0),
657657
withdrawals=[] if self.fork.header_withdrawals_required() else None,
658658
parent_beacon_block_root=parent_beacon_block_root,
659+
target_blobs_per_block=(
660+
self.fork.target_blobs_per_block(0, 0)
661+
if self.fork.engine_payload_attribute_target_blobs_per_block(0, 0)
662+
else None
663+
),
664+
max_blobs_per_block=(
665+
self.fork.max_blobs_per_block(0, 0)
666+
if self.fork.engine_payload_attribute_max_blobs_per_block(0, 0)
667+
else None
668+
),
659669
)
660670
forkchoice_updated_version = self.fork.engine_forkchoice_updated_version()
661671
assert (

0 commit comments

Comments
 (0)