Skip to content

Commit 42a4095

Browse files
fix: update benchmark wrapper for execute mode
1 parent de8973e commit 42a4095

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

packages/testing/src/execution_testing/specs/benchmark.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ def generate_blocks_from_code_generator(self, fork: Fork) -> List[Block]:
251251

252252
return [execution_block]
253253

254-
def generate_blockchain_test(self, fork: Fork) -> BlockchainTest:
255-
"""Create a BlockchainTest from this BenchmarkTest."""
254+
def generate_blocks(self, fork: Fork) -> List[Block]:
255+
"""Generate blocks for the benchmark test."""
256256
set_props = [
257257
name
258258
for name, val in [
@@ -268,7 +268,7 @@ def generate_blockchain_test(self, fork: Fork) -> BlockchainTest:
268268
f"Exactly one must be set, but got {len(set_props)}: {', '.join(set_props)}"
269269
)
270270

271-
blocks: List[Block] = self.setup_blocks
271+
blocks: List[Block] = []
272272

273273
if self.code_generator is not None:
274274
generated_blocks = self.generate_blocks_from_code_generator(fork)
@@ -291,6 +291,12 @@ def generate_blockchain_test(self, fork: Fork) -> BlockchainTest:
291291
"Cannot create BlockchainTest without a code generator, transactions, or blocks"
292292
)
293293

294+
return blocks
295+
296+
def generate_blockchain_test(self, fork: Fork) -> BlockchainTest:
297+
"""Create a BlockchainTest from this BenchmarkTest."""
298+
blocks: List[Block] = self.setup_blocks + self.generate_blocks(fork)
299+
294300
return BlockchainTest.from_test(
295301
base_test=self,
296302
genesis_environment=self.env,
@@ -323,11 +329,10 @@ def execute(
323329
execute_format: ExecuteFormat,
324330
) -> BaseExecute:
325331
"""Execute the benchmark test by sending it to the live network."""
326-
del fork
327-
328332
if execute_format == TransactionPost:
333+
blocks = self.generate_blocks(fork)
329334
return TransactionPost(
330-
blocks=[[self.tx]],
335+
blocks=[block.txs for block in blocks],
331336
post=self.post,
332337
)
333338
raise Exception(f"Unsupported execute format: {execute_format}")

tests/benchmark/test_worst_stateful_opcodes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_worst_address_state_cold(
9595

9696
setup_tx = Transaction(
9797
to=factory_address,
98-
gas_limit=env.gas_limit,
98+
gas_limit=20 * gas_benchmark_value,
9999
sender=pre.fund_eoa(),
100100
)
101101
blocks.append(Block(txs=[setup_tx]))
@@ -362,7 +362,7 @@ def test_worst_storage_access_cold(
362362
sender_addr = pre.fund_eoa()
363363
setup_tx = Transaction(
364364
to=None,
365-
gas_limit=env.gas_limit,
365+
gas_limit=20 * gas_benchmark_value,
366366
data=creation_code,
367367
sender=sender_addr,
368368
)
@@ -441,7 +441,7 @@ def test_worst_storage_access_warm(
441441
sender_addr = pre.fund_eoa()
442442
setup_tx = Transaction(
443443
to=None,
444-
gas_limit=env.gas_limit,
444+
gas_limit=20 * gas_benchmark_value,
445445
data=creation_code,
446446
sender=sender_addr,
447447
)
@@ -631,7 +631,7 @@ def test_worst_selfdestruct_existing(
631631

632632
contracts_deployment_tx = Transaction(
633633
to=factory_caller_address,
634-
gas_limit=env.gas_limit,
634+
gas_limit=20 * gas_benchmark_value,
635635
data=Hash(num_contracts),
636636
sender=pre.fund_eoa(),
637637
)

0 commit comments

Comments
 (0)