Skip to content
Open
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
53 changes: 30 additions & 23 deletions tests/benchmark/compute/instruction/test_account_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Hash,
JumpLoopGenerator,
Op,
TestPhaseManager,
Transaction,
While,
compute_create2_address,
Expand Down Expand Up @@ -254,13 +255,14 @@ def test_extcode_ops(
)
factory_caller_address = pre.deploy_contract(code=factory_caller_code)

contracts_deployment_tx = Transaction(
to=factory_caller_address,
gas_limit=env.gas_limit,
gas_price=10**6,
data=Hash(num_contracts),
sender=pre.fund_eoa(),
)
with TestPhaseManager.setup():
contracts_deployment_tx = Transaction(
to=factory_caller_address,
gas_limit=env.gas_limit,
gas_price=10**6,
data=Hash(num_contracts),
sender=pre.fund_eoa(),
)

post = {}
deployed_contract_addresses = []
Expand Down Expand Up @@ -303,12 +305,14 @@ def test_extcode_ops(
f"code size {max_contract_size}"
)
opcode_address = pre.deploy_contract(code=attack_code)
opcode_tx = Transaction(
to=opcode_address,
gas_limit=attack_gas_limit,
gas_price=10**9,
sender=pre.fund_eoa(),
)

with TestPhaseManager.execution():
opcode_tx = Transaction(
to=opcode_address,
gas_limit=attack_gas_limit,
gas_price=10**9,
sender=pre.fund_eoa(),
)

blockchain_test(
pre=pre,
Expand Down Expand Up @@ -467,11 +471,12 @@ def test_ext_account_query_cold(
code=factory_code, balance=10**18
)

setup_tx = Transaction(
to=factory_address,
gas_limit=env.gas_limit,
sender=pre.fund_eoa(),
)
with TestPhaseManager.setup():
setup_tx = Transaction(
to=factory_address,
gas_limit=env.gas_limit,
sender=pre.fund_eoa(),
)
blocks.append(Block(txs=[setup_tx]))

for i in range(num_target_accounts):
Expand All @@ -489,11 +494,13 @@ def test_ext_account_query_cold(
+ Op.ISZERO,
)
op_address = pre.deploy_contract(code=op_code)
op_tx = Transaction(
to=op_address,
gas_limit=attack_gas_limit,
sender=pre.fund_eoa(),
)

with TestPhaseManager.execution():
op_tx = Transaction(
to=op_address,
gas_limit=attack_gas_limit,
sender=pre.fund_eoa(),
)
blocks.append(Block(txs=[op_tx]))

benchmark_test(
Expand Down
4 changes: 3 additions & 1 deletion tests/benchmark/compute/instruction/test_block_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Block,
ExtCallGenerator,
Op,
TestPhaseManager,
)


Expand Down Expand Up @@ -50,7 +51,8 @@ def test_blockhash(
) -> None:
"""Benchmark BLOCKHASH instruction accessing oldest allowed block."""
# Create 256 dummy blocks to fill the blockhash window.
blocks = [Block()] * 256
with TestPhaseManager.setup():
blocks = [Block()] * 256

benchmark_test(
setup_blocks=blocks,
Expand Down
24 changes: 13 additions & 11 deletions tests/benchmark/compute/instruction/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,22 +267,24 @@ def test_storage_access_cold(
+ Op.RETURN(0, Op.MSIZE)
)
sender_addr = pre.fund_eoa()
setup_tx = Transaction(
to=None,
gas_limit=env.gas_limit,
data=creation_code,
sender=sender_addr,
)
with TestPhaseManager.setup():
setup_tx = Transaction(
to=None,
gas_limit=env.gas_limit,
data=creation_code,
sender=sender_addr,
)

blocks = [Block(txs=[setup_tx])]

contract_address = compute_create_address(address=sender_addr, nonce=0)

op_tx = Transaction(
to=contract_address,
gas_limit=gas_benchmark_value,
sender=pre.fund_eoa(),
)
with TestPhaseManager.execution():
op_tx = Transaction(
to=contract_address,
gas_limit=gas_benchmark_value,
sender=pre.fund_eoa(),
)
blocks.append(Block(txs=[op_tx]))

benchmark_test(
Expand Down
54 changes: 30 additions & 24 deletions tests/benchmark/compute/instruction/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
JumpLoopGenerator,
Op,
StateTestFiller,
TestPhaseManager,
Transaction,
While,
compute_create2_address,
Expand Down Expand Up @@ -175,13 +176,14 @@ def test_xcall(
)
factory_caller_address = pre.deploy_contract(code=factory_caller_code)

contracts_deployment_tx = Transaction(
to=factory_caller_address,
gas_limit=env.gas_limit,
gas_price=10**6,
data=Hash(num_contracts),
sender=pre.fund_eoa(),
)
with TestPhaseManager.setup():
contracts_deployment_tx = Transaction(
to=factory_caller_address,
gas_limit=env.gas_limit,
gas_price=10**6,
data=Hash(num_contracts),
sender=pre.fund_eoa(),
)

post = {}
deployed_contract_addresses = []
Expand Down Expand Up @@ -224,12 +226,14 @@ def test_xcall(
f"code size {max_contract_size}"
)
opcode_address = pre.deploy_contract(code=attack_code)
opcode_tx = Transaction(
to=opcode_address,
gas_limit=attack_gas_limit,
gas_price=10**9,
sender=pre.fund_eoa(),
)

with TestPhaseManager.execution():
opcode_tx = Transaction(
to=opcode_address,
gas_limit=attack_gas_limit,
gas_price=10**9,
sender=pre.fund_eoa(),
)

blockchain_test(
pre=pre,
Expand Down Expand Up @@ -581,12 +585,13 @@ def test_selfdestruct_existing(
)
factory_caller_address = pre.deploy_contract(code=factory_caller_code)

contracts_deployment_tx = Transaction(
to=factory_caller_address,
gas_limit=env.gas_limit,
data=Hash(num_contracts),
sender=pre.fund_eoa(),
)
with TestPhaseManager.setup():
contracts_deployment_tx = Transaction(
to=factory_caller_address,
gas_limit=env.gas_limit,
data=Hash(num_contracts),
sender=pre.fund_eoa(),
)

code = (
# Setup memory for later CREATE2 address generation loop.
Expand All @@ -609,11 +614,12 @@ def test_selfdestruct_existing(

# The 0 storage slot is initialize to avoid creation costs in SSTORE above.
code_addr = pre.deploy_contract(code=code, storage={0: 1})
opcode_tx = Transaction(
to=code_addr,
gas_limit=attack_gas_limit,
sender=pre.fund_eoa(),
)
with TestPhaseManager.execution():
opcode_tx = Transaction(
to=code_addr,
gas_limit=attack_gas_limit,
sender=pre.fund_eoa(),
)

post = {
factory_address: Account(storage={0: num_contracts}),
Expand Down
Loading