Skip to content

Commit

Permalink
feat(fw): add initial target blob count to header.
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-tb committed Oct 29, 2024
1 parent a7f0eca commit a5548ee
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ethereum_clis/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class Result(CamelModel):
blob_gas_used: HexNumber | None = None
requests_hash: Hash | None = None
requests: List[Bytes] | None = None
target_blob_count: HexNumber | None = None


class TransitionToolInput(CamelModel):
Expand Down
5 changes: 5 additions & 0 deletions src/ethereum_test_fixtures/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ class FixtureHeader(CamelModel):
None
)
requests_hash: Annotated[Hash, HeaderForkRequirement("requests")] | None = Field(None)
target_blob_count: Annotated[
ZeroPaddedHexNumber, HeaderForkRequirement("blob_count")
] | None = Field(None)

fork: Fork | None = Field(None, exclude=True)

Expand Down Expand Up @@ -199,6 +202,8 @@ class FixtureExecutionPayload(CamelModel):
blob_gas_used: HexNumber | None = Field(None)
excess_blob_gas: HexNumber | None = Field(None)

target_blob_count: HexNumber | None = Field(None)

block_hash: Hash

transactions: List[Bytes]
Expand Down
3 changes: 3 additions & 0 deletions src/ethereum_test_fixtures/tests/test_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@
excess_blob_gas=18,
parent_beacon_block_root=19,
requests_hash=20,
target_blob_count=10,
),
transactions=[
Transaction(
Expand Down Expand Up @@ -1191,6 +1192,7 @@ def test_json_deserialization(
withdrawals_root=Hash(16),
blob_gas_used=17,
excess_blob_gas=18,
target_blob_count=10,
),
transactions=[
Transaction(
Expand Down Expand Up @@ -1249,6 +1251,7 @@ def test_json_deserialization(
"baseFeePerGas": hex(15),
"blobGasUsed": hex(17),
"excessBlobGas": hex(18),
"targetBlobCount": hex(10),
"blockHash": "0xd90115b7fde329f64335763a446af1"
"50ab67e639281dccdb07a007d18bb80211",
"transactions": [
Expand Down
8 changes: 8 additions & 0 deletions src/ethereum_test_forks/base_fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ def header_requests_required(cls, block_number: int, timestamp: int) -> bool:
"""
pass

@classmethod
@abstractmethod
def header_blob_count_required(cls, block_number: int, timestamp: int) -> bool:
"""
Returns true if the header must contain target blob count
"""
pass

@classmethod
@abstractmethod
def blob_gas_per_blob(cls, block_number: int, timestamp: int) -> int:
Expand Down
8 changes: 8 additions & 0 deletions src/ethereum_test_forks/forks/forks.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,14 @@ def header_requests_required(cls, block_number: int, timestamp: int) -> bool:
"""
return True

@classmethod
def header_blob_count_required(cls, block_number: int = 0, timestamp: int = 0) -> bool:
"""
Prague requires that the execution layer header contains the beacon
chain target blob count.
"""
return True

@classmethod
def engine_new_payload_requests(cls, block_number: int = 0, timestamp: int = 0) -> bool:
"""
Expand Down
1 change: 1 addition & 0 deletions src/ethereum_test_specs/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class Header(CamelModel):
excess_blob_gas: Removable | HexNumber | None = None
parent_beacon_block_root: Removable | Hash | None = None
requests_hash: Removable | Hash | None = None
target_blob_count: Removable | HexNumber | None = None

REMOVE_FIELD: ClassVar[Removable] = Removable()
"""
Expand Down
2 changes: 2 additions & 0 deletions src/ethereum_test_types/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ class EnvironmentGeneric(CamelModel, Generic[NumberBoundTypeVar]):
base_fee_per_gas: NumberBoundTypeVar | None = Field(None, alias="currentBaseFee")
excess_blob_gas: NumberBoundTypeVar | None = Field(None, alias="currentExcessBlobGas")

target_blob_count: NumberBoundTypeVar | None = Field(None, alias="currentTargetBlobGasUsed")

parent_difficulty: NumberBoundTypeVar | None = Field(None)
parent_timestamp: NumberBoundTypeVar | None = Field(None)
parent_base_fee_per_gas: NumberBoundTypeVar | None = Field(None, alias="parentBaseFee")
Expand Down
4 changes: 4 additions & 0 deletions src/pytest_plugins/execute/rpc/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ def base_pre_genesis(
)
if base_fork.header_requests_required(block_number=block_number, timestamp=timestamp)
else None,
target_blob_count=env.target_blob_count if base_fork.header_blob_count_required(
block_number=block_number,
timestamp=timestamp
) else None,
)

return (pre_alloc, genesis)
Expand Down

0 comments on commit a5548ee

Please sign in to comment.