Skip to content

Commit d527b01

Browse files
feat: add setup and execution transaction label
1 parent f48b0bd commit d527b01

File tree

4 files changed

+76
-59
lines changed

4 files changed

+76
-59
lines changed

tests/benchmark/compute/instruction/test_account_query.py

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
Hash,
3030
JumpLoopGenerator,
3131
Op,
32+
TestPhaseManager,
3233
Transaction,
3334
While,
3435
compute_create2_address,
@@ -254,13 +255,14 @@ def test_extcode_ops(
254255
)
255256
factory_caller_address = pre.deploy_contract(code=factory_caller_code)
256257

257-
contracts_deployment_tx = Transaction(
258-
to=factory_caller_address,
259-
gas_limit=env.gas_limit,
260-
gas_price=10**6,
261-
data=Hash(num_contracts),
262-
sender=pre.fund_eoa(),
263-
)
258+
with TestPhaseManager.setup():
259+
contracts_deployment_tx = Transaction(
260+
to=factory_caller_address,
261+
gas_limit=env.gas_limit,
262+
gas_price=10**6,
263+
data=Hash(num_contracts),
264+
sender=pre.fund_eoa(),
265+
)
264266

265267
post = {}
266268
deployed_contract_addresses = []
@@ -303,12 +305,14 @@ def test_extcode_ops(
303305
f"code size {max_contract_size}"
304306
)
305307
opcode_address = pre.deploy_contract(code=attack_code)
306-
opcode_tx = Transaction(
307-
to=opcode_address,
308-
gas_limit=attack_gas_limit,
309-
gas_price=10**9,
310-
sender=pre.fund_eoa(),
311-
)
308+
309+
with TestPhaseManager.execution():
310+
opcode_tx = Transaction(
311+
to=opcode_address,
312+
gas_limit=attack_gas_limit,
313+
gas_price=10**9,
314+
sender=pre.fund_eoa(),
315+
)
312316

313317
blockchain_test(
314318
pre=pre,
@@ -467,11 +471,12 @@ def test_ext_account_query_cold(
467471
code=factory_code, balance=10**18
468472
)
469473

470-
setup_tx = Transaction(
471-
to=factory_address,
472-
gas_limit=env.gas_limit,
473-
sender=pre.fund_eoa(),
474-
)
474+
with TestPhaseManager.setup():
475+
setup_tx = Transaction(
476+
to=factory_address,
477+
gas_limit=env.gas_limit,
478+
sender=pre.fund_eoa(),
479+
)
475480
blocks.append(Block(txs=[setup_tx]))
476481

477482
for i in range(num_target_accounts):
@@ -489,11 +494,13 @@ def test_ext_account_query_cold(
489494
+ Op.ISZERO,
490495
)
491496
op_address = pre.deploy_contract(code=op_code)
492-
op_tx = Transaction(
493-
to=op_address,
494-
gas_limit=attack_gas_limit,
495-
sender=pre.fund_eoa(),
496-
)
497+
498+
with TestPhaseManager.execution():
499+
op_tx = Transaction(
500+
to=op_address,
501+
gas_limit=attack_gas_limit,
502+
sender=pre.fund_eoa(),
503+
)
497504
blocks.append(Block(txs=[op_tx]))
498505

499506
benchmark_test(

tests/benchmark/compute/instruction/test_block_context.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
Block,
2020
ExtCallGenerator,
2121
Op,
22+
TestPhaseManager,
2223
)
2324

2425

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

5557
benchmark_test(
5658
setup_blocks=blocks,

tests/benchmark/compute/instruction/test_storage.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -267,22 +267,24 @@ def test_storage_access_cold(
267267
+ Op.RETURN(0, Op.MSIZE)
268268
)
269269
sender_addr = pre.fund_eoa()
270-
setup_tx = Transaction(
271-
to=None,
272-
gas_limit=env.gas_limit,
273-
data=creation_code,
274-
sender=sender_addr,
275-
)
270+
with TestPhaseManager.setup():
271+
setup_tx = Transaction(
272+
to=None,
273+
gas_limit=env.gas_limit,
274+
data=creation_code,
275+
sender=sender_addr,
276+
)
276277

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

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

281-
op_tx = Transaction(
282-
to=contract_address,
283-
gas_limit=gas_benchmark_value,
284-
sender=pre.fund_eoa(),
285-
)
282+
with TestPhaseManager.execution():
283+
op_tx = Transaction(
284+
to=contract_address,
285+
gas_limit=gas_benchmark_value,
286+
sender=pre.fund_eoa(),
287+
)
286288
blocks.append(Block(txs=[op_tx]))
287289

288290
benchmark_test(

tests/benchmark/compute/instruction/test_system.py

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
JumpLoopGenerator,
3030
Op,
3131
StateTestFiller,
32+
TestPhaseManager,
3233
Transaction,
3334
While,
3435
compute_create2_address,
@@ -175,13 +176,14 @@ def test_xcall(
175176
)
176177
factory_caller_address = pre.deploy_contract(code=factory_caller_code)
177178

178-
contracts_deployment_tx = Transaction(
179-
to=factory_caller_address,
180-
gas_limit=20 * gas_benchmark_value,
181-
gas_price=10**6,
182-
data=Hash(num_contracts),
183-
sender=pre.fund_eoa(),
184-
)
179+
with TestPhaseManager.setup():
180+
contracts_deployment_tx = Transaction(
181+
to=factory_caller_address,
182+
gas_limit=20 * gas_benchmark_value,
183+
gas_price=10**6,
184+
data=Hash(num_contracts),
185+
sender=pre.fund_eoa(),
186+
)
185187

186188
post = {}
187189
deployed_contract_addresses = []
@@ -224,12 +226,14 @@ def test_xcall(
224226
f"code size {max_contract_size}"
225227
)
226228
opcode_address = pre.deploy_contract(code=attack_code)
227-
opcode_tx = Transaction(
228-
to=opcode_address,
229-
gas_limit=attack_gas_limit,
230-
gas_price=10**9,
231-
sender=pre.fund_eoa(),
232-
)
229+
230+
with TestPhaseManager.execution():
231+
opcode_tx = Transaction(
232+
to=opcode_address,
233+
gas_limit=attack_gas_limit,
234+
gas_price=10**9,
235+
sender=pre.fund_eoa(),
236+
)
233237

234238
blockchain_test(
235239
pre=pre,
@@ -581,12 +585,13 @@ def test_selfdestruct_existing(
581585
)
582586
factory_caller_address = pre.deploy_contract(code=factory_caller_code)
583587

584-
contracts_deployment_tx = Transaction(
585-
to=factory_caller_address,
586-
gas_limit=env.gas_limit,
587-
data=Hash(num_contracts),
588-
sender=pre.fund_eoa(),
589-
)
588+
with TestPhaseManager.setup():
589+
contracts_deployment_tx = Transaction(
590+
to=factory_caller_address,
591+
gas_limit=env.gas_limit,
592+
data=Hash(num_contracts),
593+
sender=pre.fund_eoa(),
594+
)
590595

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

610615
# The 0 storage slot is initialize to avoid creation costs in SSTORE above.
611616
code_addr = pre.deploy_contract(code=code, storage={0: 1})
612-
opcode_tx = Transaction(
613-
to=code_addr,
614-
gas_limit=attack_gas_limit,
615-
sender=pre.fund_eoa(),
616-
)
617+
with TestPhaseManager.execution():
618+
opcode_tx = Transaction(
619+
to=code_addr,
620+
gas_limit=attack_gas_limit,
621+
sender=pre.fund_eoa(),
622+
)
617623

618624
post = {
619625
factory_address: Account(storage={0: num_contracts}),

0 commit comments

Comments
 (0)