Skip to content

Commit b2915c8

Browse files
committed
fix gas limits
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
1 parent b7ae79c commit b2915c8

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

tests/zkevm/test_worst_bytecode.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
REFERENCE_SPEC_VERSION = "TODO"
2828

2929
MAX_CONTRACT_SIZE = 24 * 1024 # TODO: This could be a fork property
30-
BLOCK_GAS_LIMIT = 36_000_000 # TODO: Parametrize using the (yet to be implemented) block gas limit
31-
# OPCODE_GAS_LIMIT = BLOCK_GAS_LIMIT # TODO: Reduced in order to run the test in a reasonable time
3230
OPCODE_GAS_LIMIT = 100_000
3331

3432
XOR_TABLE_SIZE = 256
@@ -60,7 +58,7 @@ def test_worst_bytecode_single_opcode(
6058
The test is performed in the last block of the test, and the entire block gas limit is
6159
consumed by repeated opcode executions.
6260
"""
63-
env = Environment(gas_limit=BLOCK_GAS_LIMIT)
61+
env = Environment()
6462

6563
# The initcode will take its address as a starting point to the input to the keccak
6664
# hash function.
@@ -131,14 +129,14 @@ def test_worst_bytecode_single_opcode(
131129

132130
total_contracts_to_deploy = max_number_of_contract_calls
133131
approximate_gas_per_deployment = 4_970_000 # Obtained from evm tracing
134-
contracts_deployed_per_tx = BLOCK_GAS_LIMIT // approximate_gas_per_deployment
132+
contracts_deployed_per_tx = env.gas_limit // approximate_gas_per_deployment
135133

136134
deploy_txs = []
137135

138136
def generate_deploy_tx(contracts_to_deploy: int):
139137
return Transaction(
140138
to=factory_caller_address,
141-
gas_limit=BLOCK_GAS_LIMIT,
139+
gas_limit=env.gas_limit,
142140
gas_price=10**9, # Bump required due to the amount of full blocks
143141
data=Hash(contracts_deployed_per_tx),
144142
sender=pre.fund_eoa(),

tests/zkevm/test_worst_compute.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def test_worst_ecrecover(
195195
+ Op.MSTORE(3 * 32, 0x789D1DD423D25F0772D2748D60F7E4B81BB14D086EBA8E8E8EFB6DCFF8A4AE02)
196196
)
197197

198-
attack_block = Op.STATICCALL(ECRECOVER_GAS_COST, 0x1, 0, 32 * 4, 0, 0) + Op.POP
198+
attack_block = Op.POP(Op.STATICCALL(ECRECOVER_GAS_COST, 0x1, 0, 32 * 4, 0, 0))
199199
code = code_loop_precompile_call(calldata, attack_block)
200200
code_address = pre.deploy_contract(code=bytes(code))
201201

@@ -218,7 +218,7 @@ def test_worst_ecrecover(
218218

219219
def code_loop_precompile_call(calldata: Bytecode, attack_block: Bytecode):
220220
"""Create a code loop that calls a precompile with the given calldata."""
221-
# The attack contract is: JUMPDEST + [attack_block]* + PUSH0 + JUMP
221+
# The attack contract is: CALLDATA_PREP + #JUMPDEST + [attack_block]* + JUMP(#)
222222
jumpdest = Op.JUMPDEST
223223
jump_back = Op.JUMP(len(calldata))
224224
max_iters_loop = (MAX_CODE_SIZE - len(calldata) - len(jumpdest) - len(jump_back)) // len(

0 commit comments

Comments
 (0)