@@ -94,6 +94,7 @@ class FillResult(BaseModel):
9494 fixture : BaseFixture
9595 gas_optimization : int | None
9696 benchmark_gas_used : int | None = None
97+ benchmark_block_gas_used : int | None = None
9798 benchmark_opcode_count : OpcodeCount | None = None
9899 post_verifications : PostVerifications | None = None
99100 metadata : Dict [str , Any ] = Field (default_factory = dict )
@@ -259,12 +260,25 @@ def get_genesis_environment(self) -> Environment:
259260 )
260261
261262 def validate_benchmark_gas (
262- self , * , benchmark_gas_used : int | None , gas_benchmark_value : int
263+ self ,
264+ * ,
265+ benchmark_gas_used : int | None ,
266+ gas_benchmark_value : int ,
267+ benchmark_block_gas_used : int | None = None ,
263268 ) -> None :
264269 """
265270 Validates the total consumed gas of the last block in the test matches
266271 the expectation of the benchmark test.
267272
273+ ``benchmark_gas_used`` is the combined gas across all dimensions (the
274+ receipt ``cumulativeGasUsed``) and is checked against
275+ ``expected_benchmark_gas_used``. ``benchmark_block_gas_used`` is the
276+ block-header gas, i.e. the maximum across the independent gas
277+ dimensions (EIP-8037); it is what must stay within the block gas
278+ limit, because the combined value can legitimately exceed it. When it
279+ is not available (e.g. execute mode), the combined value is used for
280+ the ceiling check instead.
281+
268282 Requires the following fields to be set:
269283 - expected_benchmark_gas_used
270284 - operation_mode
@@ -287,9 +301,17 @@ def validate_benchmark_gas(
287301 f"({ expected_benchmark_gas_used } ), "
288302 f"difference: { diff } "
289303 )
290- # Gas used should never exceed the maximum benchmark gas allowed.
291- assert benchmark_gas_used <= gas_benchmark_value , (
292- f"benchmark_gas_used ({ benchmark_gas_used } ) exceeds maximum "
304+ # No single gas dimension may exceed the block gas limit. The
305+ # block-header gas is the max across dimensions; the combined
306+ # regular+state gas may exceed the target under EIP-8037, so the
307+ # ceiling is checked against the header value when available.
308+ block_gas_used = (
309+ benchmark_block_gas_used
310+ if benchmark_block_gas_used is not None
311+ else benchmark_gas_used
312+ )
313+ assert block_gas_used <= gas_benchmark_value , (
314+ f"benchmark block gas used ({ block_gas_used } ) exceeds maximum "
293315 "benchmark gas allowed for this configuration: "
294316 f"{ gas_benchmark_value } "
295317 )
0 commit comments