Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/ethereum_test_specs/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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}")
Expand Down
14 changes: 4 additions & 10 deletions tests/benchmark/test_worst_stateful_opcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def test_worst_address_state_cold(
fork: Fork,
opcode: Op,
absent_accounts: bool,
env: Environment,
gas_benchmark_value: int,
) -> None:
"""
Expand Down Expand Up @@ -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]))
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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,
)
Expand All @@ -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
Expand Down Expand Up @@ -507,7 +503,6 @@ def test_worst_selfdestruct_existing(
fork: Fork,
pre: Alloc,
value_bearing: bool,
env: Environment,
gas_benchmark_value: int,
) -> None:
"""
Expand Down Expand Up @@ -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(),
)
Expand Down Expand Up @@ -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(),
)

Expand Down
Loading