diff --git a/src/ethereum/prague/blocks.py b/src/ethereum/prague/blocks.py index 95b46aea27..45f14facec 100644 --- a/src/ethereum/prague/blocks.py +++ b/src/ethereum/prague/blocks.py @@ -74,7 +74,6 @@ class Header: excess_blob_gas: U64 parent_beacon_block_root: Root requests_hash: Hash32 - target_blobs_per_block: U64 @slotted_freezable diff --git a/src/ethereum/prague/fork.py b/src/ethereum/prague/fork.py index 1626beb729..9d847db6ae 100644 --- a/src/ethereum/prague/fork.py +++ b/src/ethereum/prague/fork.py @@ -802,7 +802,8 @@ def apply_body( block_logs += logs blob_gas_used += calculate_total_blob_gas(tx) - + if blob_gas_used > MAX_BLOB_GAS_PER_BLOCK: + raise InvalidBlock block_gas_used = block_gas_limit - gas_available block_logs_bloom = logs_bloom(block_logs) diff --git a/src/ethereum/prague/vm/gas.py b/src/ethereum/prague/vm/gas.py index d754e8a827..09b01204e4 100644 --- a/src/ethereum/prague/vm/gas.py +++ b/src/ethereum/prague/vm/gas.py @@ -73,9 +73,10 @@ GAS_BLS_G2_MUL = Uint(22500) GAS_BLS_G2_MAP = Uint(23800) +TARGET_BLOB_GAS_PER_BLOCK = U64(786432) GAS_PER_BLOB = Uint(2**17) MIN_BLOB_GASPRICE = Uint(1) -BLOB_BASE_FEE_UPDATE_FRACTION = Uint(5007716) +BLOB_GASPRICE_UPDATE_FRACTION = Uint(5007716) @dataclass @@ -276,8 +277,7 @@ def init_code_cost(init_code_length: Uint) -> Uint: def calculate_excess_blob_gas(parent_header: Header) -> U64: """ Calculated the excess blob gas for the current block based - on the gas used in the parent block and the gas target set - in the current block. + on the gas used in the parent block. Parameters ---------- @@ -292,11 +292,10 @@ def calculate_excess_blob_gas(parent_header: Header) -> U64: parent_blob_gas = ( parent_header.excess_blob_gas + parent_header.blob_gas_used ) - target_blob_gas = GAS_PER_BLOB * parent_header.target_blobs_per_block - if parent_blob_gas < target_blob_gas: + if parent_blob_gas < TARGET_BLOB_GAS_PER_BLOCK: return U64(0) else: - return parent_blob_gas - target_blob_gas + return parent_blob_gas - TARGET_BLOB_GAS_PER_BLOCK def calculate_total_blob_gas(tx: Transaction) -> Uint: @@ -336,7 +335,7 @@ def calculate_blob_gas_price(excess_blob_gas: U64) -> Uint: return taylor_exponential( MIN_BLOB_GASPRICE, Uint(excess_blob_gas), - BLOB_BASE_FEE_UPDATE_FRACTION, + BLOB_GASPRICE_UPDATE_FRACTION, ) diff --git a/src/ethereum_spec_tools/evm_tools/loaders/fork_loader.py b/src/ethereum_spec_tools/evm_tools/loaders/fork_loader.py index 3367a20eb5..8d2a51ca1b 100644 --- a/src/ethereum_spec_tools/evm_tools/loaders/fork_loader.py +++ b/src/ethereum_spec_tools/evm_tools/loaders/fork_loader.py @@ -82,11 +82,6 @@ def HISTORY_SERVE_WINDOW(self) -> Any: """HISTORY_SERVE_WINDOW of the given fork.""" return self._module("fork").HISTORY_SERVE_WINDOW - @property - def GAS_PER_BLOB(self) -> Any: - """GAS_PER_BLOB of the given fork.""" - return self._module("vm.gas").GAS_PER_BLOB - @property def process_general_purpose_requests(self) -> Any: """process_general_purpose_requests function of the given fork.""" diff --git a/src/ethereum_spec_tools/evm_tools/t8n/__init__.py b/src/ethereum_spec_tools/evm_tools/t8n/__init__.py index 1bcbec70c1..1340f37ea5 100644 --- a/src/ethereum_spec_tools/evm_tools/t8n/__init__.py +++ b/src/ethereum_spec_tools/evm_tools/t8n/__init__.py @@ -359,9 +359,8 @@ def apply_body(self) -> None: if self.fork.is_after_fork("ethereum.cancun"): blob_gas_used += self.fork.calculate_total_blob_gas(tx) - if not self.fork.is_after_fork("ethereum.prague"): - if blob_gas_used > self.fork.MAX_BLOB_GAS_PER_BLOCK: - raise InvalidBlock + if blob_gas_used > self.fork.MAX_BLOB_GAS_PER_BLOCK: + raise InvalidBlock except EthereumException as e: # The tf tools expects some non-blank error message # even in case e is blank. diff --git a/src/ethereum_spec_tools/evm_tools/t8n/env.py b/src/ethereum_spec_tools/evm_tools/t8n/env.py index e5f7b7a2e5..e09e5b7ce3 100644 --- a/src/ethereum_spec_tools/evm_tools/t8n/env.py +++ b/src/ethereum_spec_tools/evm_tools/t8n/env.py @@ -51,8 +51,6 @@ class Env: parent_blob_gas_used: Optional[U64] excess_blob_gas: Optional[U64] requests: Any - target_blobs_per_block: Optional[U64] - parent_target_blobs_per_block: Optional[U64] def __init__(self, t8n: "T8N", stdin: Optional[Dict] = None): if t8n.options.input_env == "stdin": @@ -92,7 +90,6 @@ def read_excess_blob_gas(self, data: Any, t8n: "T8N") -> None: self.parent_blob_gas_used = U64(0) self.parent_excess_blob_gas = U64(0) self.excess_blob_gas = None - self.parent_target_blobs_per_block = None if not t8n.fork.is_after_fork("ethereum.cancun"): return @@ -117,28 +114,11 @@ def read_excess_blob_gas(self, data: Any, t8n: "T8N") -> None: self.parent_excess_blob_gas + self.parent_blob_gas_used ) - if "parentTargetBlobsPerBlock" in data: - self.parent_target_blobs_per_block = parse_hex_or_int( - data["parentTargetBlobsPerBlock"], U64 - ) - parent_target_blob_gas_per_block = ( - self.parent_target_blobs_per_block * t8n.fork.GAS_PER_BLOB - ) - else: - parent_target_blob_gas_per_block = ( - t8n.fork.TARGET_BLOB_GAS_PER_BLOCK - ) + target_blob_gas_per_block = t8n.fork.TARGET_BLOB_GAS_PER_BLOCK self.excess_blob_gas = U64(0) - if excess_blob_gas >= parent_target_blob_gas_per_block: - self.excess_blob_gas = ( - excess_blob_gas - parent_target_blob_gas_per_block - ) - - if "currentTargetBlobsPerBlock" in data: - self.target_blobs_per_block = parse_hex_or_int( - data["currentTargetBlobsPerBlock"], U64 - ) + if excess_blob_gas >= target_blob_gas_per_block: + self.excess_blob_gas = excess_blob_gas - target_blob_gas_per_block def read_base_fee_per_gas(self, data: Any, t8n: "T8N") -> None: """ diff --git a/src/ethereum_spec_tools/evm_tools/t8n/t8n_types.py b/src/ethereum_spec_tools/evm_tools/t8n/t8n_types.py index a50a366c1b..4b1231c07d 100644 --- a/src/ethereum_spec_tools/evm_tools/t8n/t8n_types.py +++ b/src/ethereum_spec_tools/evm_tools/t8n/t8n_types.py @@ -308,7 +308,6 @@ class Result: blob_gas_used: Optional[Uint] = None requests_hash: Optional[Hash32] = None requests: Optional[List[Bytes]] = None - target_blobs_per_block: Optional[U64] = None def to_json(self) -> Any: """Encode the result to JSON""" @@ -359,7 +358,4 @@ def to_json(self) -> Any: # request data["requests"] = [encode_to_hex(req) for req in self.requests] - if self.target_blobs_per_block is not None: - data["currentBlobsPerBlock"] = hex(self.target_blobs_per_block) - return data diff --git a/tests/prague/test_rlp.py b/tests/prague/test_rlp.py index e183da5f3e..d9035f1a3a 100644 --- a/tests/prague/test_rlp.py +++ b/tests/prague/test_rlp.py @@ -105,7 +105,6 @@ blob_gas_used=U64(7), excess_blob_gas=U64(8), requests_hash=hash7, - target_blobs_per_block=U64(9), ) block = Block(