diff --git a/src/ethereum_test_specs/benchmark.py b/src/ethereum_test_specs/benchmark.py index ff9f94a2c59..1d9ab0ba5af 100644 --- a/src/ethereum_test_specs/benchmark.py +++ b/src/ethereum_test_specs/benchmark.py @@ -218,8 +218,8 @@ def generate_blocks_from_code_generator(self, fork: Fork) -> List[Block]: return [execution_block] - def generate_blockchain_test(self, fork: Fork) -> BlockchainTest: - """Create a BlockchainTest from this BenchmarkTest.""" + def generate_blocks(self, fork: Fork) -> List[Block]: + """Generate blocks from the test properties.""" set_props = [ name for name, val in [ @@ -251,11 +251,11 @@ def generate_blockchain_test(self, fork: Fork) -> BlockchainTest: blocks.append(Block(txs=transactions)) - else: - raise ValueError( - "Cannot create BlockchainTest without a code generator, transactions, or blocks" - ) + return blocks + def generate_blockchain_test(self, fork: Fork) -> BlockchainTest: + """Create a BlockchainTest from this BenchmarkTest.""" + blocks = self.generate_blocks(fork) return BlockchainTest.from_test( base_test=self, genesis_environment=self.env, @@ -286,11 +286,12 @@ def execute( execute_format: ExecuteFormat, ) -> BaseExecute: """Execute the benchmark test by sending it to the live network.""" - del fork - if execute_format == TransactionPost: + blocks: List[List[Transaction]] = [ + list(block.txs) for block in self.generate_blocks(fork) + ] return TransactionPost( - blocks=[[self.tx]], + blocks=blocks, post=self.post, ) raise Exception(f"Unsupported execute format: {execute_format}") diff --git a/tests/benchmark/test_worst_stateful_opcodes.py b/tests/benchmark/test_worst_stateful_opcodes.py index 512a239def3..6889313bd16 100755 --- a/tests/benchmark/test_worst_stateful_opcodes.py +++ b/tests/benchmark/test_worst_stateful_opcodes.py @@ -50,7 +50,6 @@ def test_worst_address_state_cold( fork: Fork, opcode: Op, absent_accounts: bool, - env: Environment, gas_benchmark_value: int, ) -> None: """ @@ -86,7 +85,7 @@ def test_worst_address_state_cold( setup_tx = Transaction( to=factory_address, - gas_limit=env.gas_limit, + gas_limit=20 * gas_benchmark_value, sender=pre.fund_eoa(), ) blocks.append(Block(txs=[setup_tx])) @@ -334,7 +333,7 @@ def test_worst_storage_access_cold( sender_addr = pre.fund_eoa() setup_tx = Transaction( to=None, - gas_limit=env.gas_limit, + gas_limit=20 * gas_benchmark_value, data=creation_code, sender=sender_addr, ) @@ -411,7 +410,7 @@ def test_worst_storage_access_warm( sender_addr = pre.fund_eoa() setup_tx = Transaction( to=None, - gas_limit=env.gas_limit, + gas_limit=20 * gas_benchmark_value, data=creation_code, sender=sender_addr, ) @@ -432,10 +431,7 @@ def test_worst_storage_access_warm( def test_worst_blockhash( benchmark_test: BenchmarkTestFiller, - pre: Alloc, - fork: Fork, gas_benchmark_value: int, - tx_gas_limit_cap: int, ) -> None: """ Test running a block with as many blockhash accessing oldest allowed block @@ -507,7 +503,6 @@ def test_worst_selfdestruct_existing( fork: Fork, pre: Alloc, value_bearing: bool, - env: Environment, gas_benchmark_value: int, ) -> None: """ @@ -588,7 +583,7 @@ def test_worst_selfdestruct_existing( contracts_deployment_tx = Transaction( to=factory_caller_address, - gas_limit=env.gas_limit, + gas_limit=20 * gas_benchmark_value, data=Hash(num_contracts), sender=pre.fund_eoa(), ) @@ -814,7 +809,6 @@ def test_worst_selfdestruct_initcode( code_tx = Transaction( to=code_addr, gas_limit=gas_benchmark_value, - gas_price=10, sender=pre.fund_eoa(), )