Skip to content

Commit 63bc826

Browse files
authored
feat(tests): add modexp overflow test (#1096)
Tests the case where a large base[^1] is added to 96. Both Geth and Nethermind correctly revert the precompile call with an out-of-gas error, but EELS crashes with an `OverflowError`. [^1]: `0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0` Reported-by: Omik
1 parent 1a5b060 commit 63bc826

File tree

1 file changed

+138
-0
lines changed

1 file changed

+138
-0
lines changed

tests/byzantium/eip198_modexp_precompile/test_modexp.py

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,144 @@
146146
),
147147
id="EIP-198-case5-raw-input",
148148
),
149+
pytest.param(
150+
Bytes(
151+
"0000000000000000000000000000000000000000000000000000000000000001"
152+
"0000000000000000000000000000000000000000000000008000000000000020"
153+
"0000000000000000000000000000000000000000000000000000000000000001"
154+
"80"
155+
),
156+
ModExpOutput(
157+
call_success=False,
158+
returned_data="0000000000000000000000000000000000000000000000000000000000000000",
159+
),
160+
id="large-exponent-length-0x80000000-out-of-gas",
161+
),
162+
pytest.param(
163+
Bytes(
164+
"0000000000000000000000000000000000000000000000000000000000000001"
165+
"0000000000000000000000000000000000000000000000004000000000000020"
166+
"0000000000000000000000000000000000000000000000000000000000000001"
167+
"80"
168+
),
169+
ModExpOutput(
170+
call_success=False,
171+
returned_data="0000000000000000000000000000000000000000000000000000000000000000",
172+
),
173+
id="large-exponent-length-0x40000000-out-of-gas",
174+
),
175+
pytest.param(
176+
Bytes(
177+
"0000000000000000000000000000000000000000000000000000000000000001"
178+
"0000000000000000000000000000000000000000000000002000000000000020"
179+
"0000000000000000000000000000000000000000000000000000000000000001"
180+
"80"
181+
),
182+
ModExpOutput(
183+
call_success=False,
184+
returned_data="0000000000000000000000000000000000000000000000000000000000000000",
185+
),
186+
id="large-exponent-length-0x20000000-out-of-gas",
187+
),
188+
pytest.param(
189+
Bytes(
190+
"0000000000000000000000000000000000000000000000000000000000000001"
191+
"0000000000000000000000000000000000000000000000001000000000000020"
192+
"0000000000000000000000000000000000000000000000000000000000000001"
193+
"80"
194+
),
195+
ModExpOutput(
196+
call_success=False,
197+
returned_data="0000000000000000000000000000000000000000000000000000000000000000",
198+
),
199+
id="large-exponent-length-0x10000000-out-of-gas",
200+
),
201+
pytest.param(
202+
Bytes(
203+
"0000000000000000000000000000000000000000000000000000000000000001"
204+
"0000000000000000000000000000000000000000000000000000000080000020"
205+
"0000000000000000000000000000000000000000000000000000000000000001"
206+
"80"
207+
),
208+
ModExpOutput(
209+
call_success=False,
210+
returned_data="0000000000000000000000000000000000000000000000000000000000000000",
211+
),
212+
id="large-modulus-length-0x80000020-out-of-gas",
213+
),
214+
pytest.param(
215+
Bytes(
216+
"0000000000000000000000000000000000000000000000000000000000000001"
217+
"0000000000000000000000000000000000000000000000000000000040000020"
218+
"0000000000000000000000000000000000000000000000000000000000000001"
219+
"80"
220+
),
221+
ModExpOutput(
222+
call_success=False,
223+
returned_data="0000000000000000000000000000000000000000000000000000000000000000",
224+
),
225+
id="large-modulus-length-0x40000020-out-of-gas",
226+
),
227+
pytest.param(
228+
Bytes(
229+
"0000000000000000000000000000000000000000000000000000000000000001"
230+
"0000000000000000000000000000000000000000000000000000000020000020"
231+
"0000000000000000000000000000000000000000000000000000000000000001"
232+
"80"
233+
),
234+
ModExpOutput(
235+
call_success=False,
236+
returned_data="0000000000000000000000000000000000000000000000000000000000000000",
237+
),
238+
id="large-modulus-length-0x20000020-out-of-gas",
239+
),
240+
pytest.param(
241+
Bytes(
242+
"0000000000000000000000000000000000000000000000000000000000000001"
243+
"0000000000000000000000000000000000000000000000000000000000000040"
244+
"00000000000000000000000000000000000000000000000000000000ffffffff"
245+
"80"
246+
),
247+
ModExpOutput(
248+
call_success=False,
249+
returned_data="0000000000000000000000000000000000000000000000000000000000000000",
250+
),
251+
id="large-modulus-length-0xffffffff-out-of-gas",
252+
),
253+
pytest.param(
254+
Bytes(
255+
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9"
256+
"0000000000000000000000000000000000000000000000000000000000000001"
257+
"0000000000000000000000000000000000000000000000000000000000000001"
258+
),
259+
ModExpOutput(
260+
call_success=False,
261+
returned_data="0000000000000000000000000000000000000000000000000000000000000000",
262+
),
263+
# FIXME
264+
marks=pytest.mark.skip(
265+
reason=(
266+
"EELS bug: U256 overflow in modexp pointer arithmetic "
267+
"before Osaka - see github.com/ethereum/execution-specs/issues/1465"
268+
)
269+
),
270+
id="max-base-length-overflow-out-of-gas",
271+
),
272+
pytest.param(
273+
Bytes("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0"),
274+
ModExpOutput(
275+
call_success=False,
276+
returned_data="0000000000000000000000000000000000000000000000000000000000000000",
277+
),
278+
# FIXME
279+
marks=pytest.mark.skip(
280+
reason=(
281+
"EELS bug: U256 overflow in modexp pointer arithmetic "
282+
"before Osaka - see github.com/ethereum/execution-specs/issues/1465"
283+
)
284+
),
285+
id="immunefi-38958-by-omik-overflow",
286+
),
149287
],
150288
ids=lambda param: param.__repr__(), # only required to remove parameter
151289
# names (input/output)

0 commit comments

Comments
 (0)