Skip to content

Commit c044cb3

Browse files
committed
feat(benchmark): add gas exhaustion validation using expected_receipt
Implement solution to address reviewer's concern about test validation by using EEST's expected_receipt feature to validate that benchmarks consume all gas. Changes: - Add TransactionReceipt import - Add expected_receipt to both test transactions validating gas_used equals gas_limit - Remove skip_gas_used_validation flag as validation is now explicit This ensures tests can distinguish between: - Early failure from invalid jump (~50K gas) indicating setup issues - Full gas exhaustion (all gas consumed) indicating successful benchmark run The invalid jump remains as a fail-fast mechanism for STATICCALL failures, while expected_receipt validates the benchmark actually executed.
1 parent 8590357 commit c044cb3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/benchmark/bloatnet/test_multi_opcode.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Block,
1616
BlockchainTestFiller,
1717
Transaction,
18+
TransactionReceipt,
1819
While,
1920
)
2021
from ethereum_test_vm import Bytecode
@@ -180,6 +181,11 @@ def test_bloatnet_balance_extcodesize(
180181
to=attack_address,
181182
gas_limit=gas_benchmark_value,
182183
sender=pre.fund_eoa(),
184+
# Validate that all gas is consumed (benchmark runs to exhaustion)
185+
# If STATICCALL fails and hits invalid jump, only ~50K gas used -> test fails
186+
expected_receipt=TransactionReceipt(
187+
gas_used=gas_benchmark_value, # Must consume all gas
188+
),
183189
)
184190

185191
# Post-state: just verify attack contract exists
@@ -191,7 +197,7 @@ def test_bloatnet_balance_extcodesize(
191197
pre=pre,
192198
blocks=[Block(txs=[attack_tx])],
193199
post=post,
194-
skip_gas_used_validation=True,
200+
# Gas validation is now handled by expected_receipt
195201
)
196202

197203

@@ -338,6 +344,11 @@ def test_bloatnet_balance_extcodecopy(
338344
to=attack_address,
339345
gas_limit=gas_benchmark_value,
340346
sender=pre.fund_eoa(),
347+
# Validate that all gas is consumed (benchmark runs to exhaustion)
348+
# If STATICCALL fails and hits invalid jump, only ~50K gas used -> test fails
349+
expected_receipt=TransactionReceipt(
350+
gas_used=gas_benchmark_value, # Must consume all gas
351+
),
341352
)
342353

343354
# Post-state
@@ -349,5 +360,5 @@ def test_bloatnet_balance_extcodecopy(
349360
pre=pre,
350361
blocks=[Block(txs=[attack_tx])],
351362
post=post,
352-
skip_gas_used_validation=True,
363+
# Gas validation is now handled by expected_receipt
353364
)

0 commit comments

Comments
 (0)