Skip to content

test_modexp_legacy_oversized_inputs()

Documentation for tests/osaka/eip7883_modexp_gas_increase/test_modexp_thresholds.py::test_modexp_legacy_oversized_inputs@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/osaka/eip7883_modexp_gas_increase/test_modexp_thresholds.py::test_modexp_legacy_oversized_inputs --fork Amsterdam

Test ModExp with legacy modexpFiller cases that have oversized declared lengths. EIP-7823 rejects inputs with any declared length exceeding 1024 bytes.

Source code in tests/osaka/eip7883_modexp_gas_increase/test_modexp_thresholds.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
@pytest.mark.parametrize(
    "modexp_input,",
    [
        pytest.param(
            # base_len=0, exp_len=32, mod_len=2^256-1
            bytes.fromhex(
                "0000000000000000000000000000000000000000000000000000000000000000"
                "0000000000000000000000000000000000000000000000000000000000000020"
                "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
                "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
                "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd"
            ),
            id="legacy-case-2",
        ),
        pytest.param(
            # base_len=4TiB, exp_len=0, mod_len=0
            bytes.fromhex(
                "0000000000000000000000000000000000000000000000000000040000000000"
                "0000000000000000000000000000000000000000000000000000000000000000"
            ),
            id="legacy-case-28",
        ),
        pytest.param(
            # base_len=0, exp_len=4TiB, mod_len=0
            bytes.fromhex(
                "0000000000000000000000000000000000000000000000000000000000000000"
                "0000000000000000000000000000000000000000000000000000040000000000"
            ),
            id="legacy-case-29",
        ),
        pytest.param(
            # base_len=0, exp_len=2^255, mod_len=0
            bytes.fromhex(
                "0000000000000000000000000000000000000000000000000000000000000000"
                "8000000000000000000000000000000000000000000000000000000000000000"
                "0000000000000000000000000000000000000000000000000000000000000000"
            ),
            id="legacy-case-30",
        ),
        pytest.param(
            # base_len=255, exp_len overflows gas calculation (Oct 2017)
            bytes.fromhex(
                "00000000000000000000000000000000000000000000000000000000000000ff"
                "2a1e530000000000000000000000000000000000000000000000000000000000"
                "0000000000000000000000000000000000000000000000000000000000000000"
            ),
            id="legacy-case-36",
        ),
        pytest.param(
            # base_len=1, exp_len overflows gas calculation (July 2022)
            bytes.fromhex(
                "0000000000000000000000000000000000000000000000000000000000000001"
                "2000000000000000000000000000000000000000000000000000000000000020"
                "0000000000000000000000000000000000000000000000000000000000000001"
                "0000000000000000000000000000000000000000000000000000000000000000"
                "010001"
            ),
            id="legacy-case-37",
        ),
    ],
)
@pytest.mark.parametrize(
    "modexp_expected,call_succeeds",
    [
        pytest.param(bytes(), False),
    ],
    ids=[""],
)
@EIPChecklist.Precompile.Test.Inputs.Invalid()
@pytest.mark.valid_from("Osaka")
def test_modexp_legacy_oversized_inputs(
    state_test: StateTestFiller,
    pre: Alloc,
    tx: Transaction,
    post: Dict,
) -> None:
    """
    Test ModExp with legacy modexpFiller cases that have oversized declared
    lengths. EIP-7823 rejects inputs with any declared length exceeding
    1024 bytes.
    """
    state_test(
        pre=pre,
        tx=tx,
        post=post,
    )

Parametrized Test Cases

This test generates 6 parametrized test cases across 2 forks.