1- """Benchmark code generator classes for creating optimized bytecode patterns."""
1+ """
2+ Benchmark code generator classes for creating
3+ optimized bytecode patterns.
4+ """
25
36from ethereum_test_forks import Fork
47from ethereum_test_specs .benchmark import BenchmarkCodeGenerator
@@ -13,7 +16,8 @@ class JumpLoopGenerator(BenchmarkCodeGenerator):
1316 def deploy_contracts (self , pre : Alloc , fork : Fork ) -> None :
1417 """Deploy the looping contract."""
1518 # Benchmark Test Structure:
16- # setup + JUMPDEST + attack + attack + ... + attack + JUMP(setup_length)
19+ # setup + JUMPDEST + attack + attack + ... +
20+ # attack + JUMP(setup_length)
1721 code = self .generate_repeated_code (self .attack_block , self .setup , fork )
1822 self ._contract_address = pre .deploy_contract (code = code )
1923
@@ -30,13 +34,17 @@ def generate_transaction(self, pre: Alloc, gas_limit: int, fork: Fork) -> Transa
3034
3135
3236class ExtCallGenerator (BenchmarkCodeGenerator ):
33- """Generates bytecode that fills the contract to maximum allowed code size."""
37+ """
38+ Generates bytecode that fills the contract to
39+ maximum allowed code size.
40+ """
3441
3542 def deploy_contracts (self , pre : Alloc , fork : Fork ) -> None :
3643 """Deploy both target and caller contracts."""
3744 # Benchmark Test Structure:
3845 # There are two contracts:
39- # 1. The target contract that executes certain operation but not loop (e.g. PUSH)
46+ # 1. The target contract that executes certain operation
47+ # but not loop (e.g. PUSH)
4048 # 2. The loop contract that calls the target contract in a loop
4149
4250 max_iterations = min (
@@ -49,8 +57,12 @@ def deploy_contracts(self, pre: Alloc, fork: Fork) -> None:
4957 )
5058
5159 # Create caller contract that repeatedly calls the target contract
52- # attack = POP(STATICCALL(GAS, target_contract_address, 0, 0, 0, 0))
53- # setup + JUMPDEST + attack + attack + ... + attack + JUMP(setup_length)
60+ # attack = POP(
61+ # STATICCALL(GAS, target_contract_address, 0, 0, 0, 0)
62+ # )
63+ #
64+ # setup + JUMPDEST + attack + attack + ... + attack +
65+ # JUMP(setup_length)
5466 code_sequence = Op .POP (Op .STATICCALL (Op .GAS , self ._target_contract_address , 0 , 0 , 0 , 0 ))
5567
5668 caller_code = self .generate_repeated_code (code_sequence , Bytecode (), fork )
0 commit comments