@@ -26,7 +26,7 @@ def gas_new() -> int | None:
26
26
27
27
@pytest .fixture
28
28
def call_opcode () -> Op :
29
- """Return call operationused to call the precompile."""
29
+ """Return call operation used to call the precompile."""
30
30
return Op .CALL
31
31
32
32
@@ -59,7 +59,16 @@ def gas_measure_contract(
59
59
call_contract_post_storage : Storage ,
60
60
call_succeeds : bool ,
61
61
) -> Address :
62
- """Deploys a contract that measures ModExp gas consumption and execution result."""
62
+ """
63
+ Deploys a contract that measures ModExp gas consumption and execution result.
64
+
65
+ Always stored:
66
+ storage[0]: precompile call success
67
+ storage[1]: return data length from precompile
68
+ Only if the precompile call succeeds:
69
+ storage[2]: gas consumed by precompile
70
+ storage[3]: hash of return data from precompile
71
+ """
63
72
assert call_opcode in [Op .CALL , Op .CALLCODE , Op .DELEGATECALL , Op .STATICCALL ]
64
73
value = [0 ] if call_opcode in [Op .CALL , Op .CALLCODE ] else []
65
74
@@ -134,11 +143,16 @@ def precompile_gas(
134
143
expected_gas = gas_old if fork < Osaka else gas_new
135
144
assert calculated_gas == expected_gas , (
136
145
f"Calculated gas { calculated_gas } != Vector gas { expected_gas } \n "
146
+ f"Lengths: base: { hex (len (modexp_input .base ))} ({ len (modexp_input .base )} ), "
147
+ f"exponent: { hex (len (modexp_input .exponent ))} ({ len (modexp_input .exponent )} ), "
148
+ f"modulus: { hex (len (modexp_input .modulus ))} ({ len (modexp_input .modulus )} )\n "
149
+ f"Exponent: { modexp_input .exponent } "
150
+ f"({ int .from_bytes (modexp_input .exponent , byteorder = 'big' )} )"
137
151
)
138
152
return calculated_gas
139
153
except Exception as e :
140
- print (f"Error calculating gas: { e } " )
141
- return 0
154
+ print (f"Warning: Error calculating gas, using minimum : { e } " )
155
+ return 500 if fork >= Osaka else 200
142
156
143
157
144
158
@pytest .fixture
0 commit comments