Skip to content

Commit

Permalink
chore(fw): rename blob count to blobs per block.
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-tb committed Nov 20, 2024
1 parent d91fb50 commit 132fa98
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
16 changes: 8 additions & 8 deletions src/ethereum_test_fixtures/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ class FixtureHeader(CamelModel):
None
)
requests_hash: Annotated[Hash, HeaderForkRequirement("requests")] | None = Field(None)
target_blob_count: Annotated[
ZeroPaddedHexNumber, HeaderForkRequirement("target_blob_count")
target_blobs_per_block: Annotated[
ZeroPaddedHexNumber, HeaderForkRequirement("target_blobs_per_block")
] | None = Field(None)

fork: Fork | None = Field(None, exclude=True)
Expand Down Expand Up @@ -202,7 +202,7 @@ class FixtureExecutionPayload(CamelModel):
blob_gas_used: HexNumber | None = Field(None)
excess_blob_gas: HexNumber | None = Field(None)

target_blob_count: HexNumber | None = Field(None)
target_blobs_per_block: HexNumber | None = Field(None)

block_hash: Hash

Expand Down Expand Up @@ -310,11 +310,11 @@ def from_fixture_header(
raise ValueError(f"Requests are required for ${fork}.")
params.append(requests)

if fork.engine_new_payload_target_blob_count(header.number, header.timestamp):
target_blob_count = header.target_blob_count
if target_blob_count is None:
raise ValueError(f"Target blob count is required for ${fork}.")
params.append(target_blob_count)
if fork.engine_new_payload_target_blobs_per_block(header.number, header.timestamp):
target_blobs_per_block = header.target_blobs_per_block
if target_blobs_per_block is None:
raise ValueError(f"Target blobs per block is required for ${fork}.")
params.append(target_blobs_per_block)

payload_params: EngineNewPayloadParameters = tuple(params)
new_payload = cls(
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum_test_fixtures/tests/test_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
excess_blob_gas=18,
parent_beacon_block_root=19,
requests_hash=20,
target_blob_count=10,
target_blobs_per_block=10,
),
transactions=[
Transaction(
Expand Down Expand Up @@ -1192,7 +1192,7 @@ def test_json_deserialization(
withdrawals_root=Hash(16),
blob_gas_used=17,
excess_blob_gas=18,
target_blob_count=10,
target_blobs_per_block=10,
),
transactions=[
Transaction(
Expand Down
10 changes: 5 additions & 5 deletions src/ethereum_test_forks/base_fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ def transaction_intrinsic_cost_calculator(

@classmethod
@abstractmethod
def header_target_blob_count_required(cls, block_number: int, timestamp: int) -> bool:
def header_target_blobs_per_block_required(cls, block_number: int, timestamp: int) -> bool:
"""
Returns true if the header must contain target blob count
Returns true if the header must contain target blobs per block.
"""
pass

Expand All @@ -264,7 +264,7 @@ def blob_gas_per_blob(cls, block_number: int, timestamp: int) -> int:

@classmethod
@abstractmethod
def target_blob_count(cls, block_number: int, timestamp: int) -> int:
def target_blobs_per_block(cls, block_number: int, timestamp: int) -> int:
"""
Returns the target blobs per block for a given fork.
"""
Expand Down Expand Up @@ -375,9 +375,9 @@ def engine_new_payload_requests(cls, block_number: int = 0, timestamp: int = 0)

@classmethod
@abstractmethod
def engine_new_payload_target_blob_count(cls, block_number: int = 0, timestamp: int = 0) -> bool:
def engine_new_payload_target_blobs_per_block(cls, block_number: int = 0, timestamp: int = 0) -> bool:
"""
returns true if the engine api version requires new payload calls to include target blob count.
returns true if the engine api version requires new payload calls to include target blobs per block.
"""
pass

Expand Down
10 changes: 5 additions & 5 deletions src/ethereum_test_forks/forks/forks.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ def blob_gas_per_blob(cls, block_number: int, timestamp: int) -> int:
return 2**17

@classmethod
def target_blob_count(cls, block_number: int, timestamp: int) -> int:
def target_blobs_per_block(cls, block_number: int, timestamp: int) -> int:
"""
Blobs are enabled starting from Cancun, with a static target of 3 blobs.
"""
Expand Down Expand Up @@ -1184,10 +1184,10 @@ def header_requests_required(cls, block_number: int, timestamp: int) -> bool:
return True

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

Expand All @@ -1199,9 +1199,9 @@ def engine_new_payload_requests(cls, block_number: int = 0, timestamp: int = 0)
return True

@classmethod
def engine_new_payload_target_blob_count(cls, block_number: int = 0, timestamp: int = 0) -> bool:
def engine_new_payload_target_blobs_per_block(cls, block_number: int = 0, timestamp: int = 0) -> bool:
"""
Starting at Prague, new payloads include the target blob count as a parameter.
Starting at Prague, new payloads include the target blobs per block as a parameter.
"""
return True

Expand Down
6 changes: 3 additions & 3 deletions src/ethereum_test_specs/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +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
target_blobs_per_block: Removable | HexNumber | None = None

REMOVE_FIELD: ClassVar[Removable] = Removable()
"""
Expand Down Expand Up @@ -362,8 +362,8 @@ def make_genesis(
requests_hash=Requests(max_request_type=fork.max_request_type(0, 0))
if fork.header_requests_required(0, 0)
else None,
target_blob_count=fork.target_blob_count(0, 0)
if fork.header_target_blob_count_required(0, 0)
target_blobs_per_block=fork.target_blobs_per_block(0, 0)
if fork.header_target_blobs_per_block_required(0, 0)
else None,
fork=fork,
)
Expand Down
6 changes: 3 additions & 3 deletions src/ethereum_test_types/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ class EnvironmentGeneric(CamelModel, Generic[NumberBoundTypeVar]):
difficulty: NumberBoundTypeVar | None = Field(None, alias="currentDifficulty")
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="currentTargetBlobCount")
target_blobs_per_block: NumberBoundTypeVar | None = Field(None, alias="currentTargetBlobsPerBlock")

parent_difficulty: NumberBoundTypeVar | None = Field(None)
parent_timestamp: NumberBoundTypeVar | None = Field(None)
Expand Down Expand Up @@ -475,8 +475,8 @@ def set_fork_requirements(self, fork: Fork) -> "Environment":
):
updated_values["parent_beacon_block_root"] = 0

if fork.header_target_blob_count_required(number, timestamp) and self.target_blob_count is None:
updated_values["target_blob_count"] = fork.target_blob_count(number, timestamp)
if fork.header_target_blobs_per_block_required(number, timestamp) and self.target_blobs_per_block is None:
updated_values["target_blobs_per_block"] = fork.target_blobs_per_block(number, timestamp)

return self.copy(**updated_values)

Expand Down
4 changes: 2 additions & 2 deletions src/pytest_plugins/execute/rpc/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ def base_pre_genesis(
block_number=block_number, timestamp=timestamp
)
else None,
target_blob_count=base_fork.target_blob_count(
target_blobs_per_block=base_fork.target_blobs_per_block(
block_number=block_number, timestamp=timestamp
)
if base_fork.header_target_blob_count_required(
if base_fork.header_target_blobs_per_block_required(
block_number=block_number, timestamp=timestamp
)
else None,
Expand Down

0 comments on commit 132fa98

Please sign in to comment.