|
11 | 11 | import pytest
|
12 | 12 |
|
13 | 13 | from ethereum_test_addresses import SystemContract
|
| 14 | +from ethereum_test_base_types import HexNumber |
14 | 15 | from ethereum_test_forks import Fork
|
15 | 16 | from ethereum_test_tools import (
|
16 | 17 | AccessList,
|
@@ -2204,7 +2205,7 @@ def test_invalid_tx_invalid_auth_signature(
|
2204 | 2205 | pytest.param(0, 1, 2**256 - 1, id="s=2**256-1"),
|
2205 | 2206 | # All Values
|
2206 | 2207 | pytest.param(0, 0, 0, id="v=r=s=0"),
|
2207 |
| - pytest.param(2**256 - 1, 2**256 - 1, 2**256 - 1, id="v=r=s=2**256-1"), |
| 2208 | + pytest.param(2**8 - 1, 2**256 - 1, 2**256 - 1, id="v=2**8-1,r=s=2**256-1"), |
2208 | 2209 | ],
|
2209 | 2210 | )
|
2210 | 2211 | def test_valid_tx_invalid_auth_signature(
|
@@ -2252,6 +2253,56 @@ def test_valid_tx_invalid_auth_signature(
|
2252 | 2253 | )
|
2253 | 2254 |
|
2254 | 2255 |
|
| 2256 | +def test_signature_s_out_of_range( |
| 2257 | + state_test: StateTestFiller, |
| 2258 | + pre: Alloc, |
| 2259 | +): |
| 2260 | + """ |
| 2261 | + Test sending a transaction with an authorization tuple where the signature s value is out of |
| 2262 | + range by modifying its value to be `SECP256K1N - S` and flipping the v value. |
| 2263 | + """ |
| 2264 | + auth_signer = pre.fund_eoa(0) |
| 2265 | + |
| 2266 | + set_code = Op.STOP |
| 2267 | + set_code_to_address = pre.deploy_contract(set_code) |
| 2268 | + |
| 2269 | + authorization_tuple = AuthorizationTuple( |
| 2270 | + address=set_code_to_address, |
| 2271 | + nonce=0, |
| 2272 | + chain_id=1, |
| 2273 | + signer=auth_signer, |
| 2274 | + ) |
| 2275 | + |
| 2276 | + authorization_tuple.s = HexNumber(SECP256K1N - authorization_tuple.s) |
| 2277 | + authorization_tuple.v = HexNumber(1 - authorization_tuple.v) |
| 2278 | + |
| 2279 | + assert authorization_tuple.s > SECP256K1N_OVER_2 |
| 2280 | + |
| 2281 | + success_slot = 1 |
| 2282 | + entry_code = Op.SSTORE(success_slot, 1) + Op.STOP |
| 2283 | + entry_address = pre.deploy_contract(entry_code) |
| 2284 | + |
| 2285 | + tx = Transaction( |
| 2286 | + gas_limit=100_000, |
| 2287 | + to=entry_address, |
| 2288 | + value=0, |
| 2289 | + authorization_list=[authorization_tuple], |
| 2290 | + sender=pre.fund_eoa(), |
| 2291 | + ) |
| 2292 | + |
| 2293 | + state_test( |
| 2294 | + env=Environment(), |
| 2295 | + pre=pre, |
| 2296 | + tx=tx, |
| 2297 | + post={ |
| 2298 | + auth_signer: Account.NONEXISTENT, |
| 2299 | + entry_address: Account( |
| 2300 | + storage={success_slot: 1}, |
| 2301 | + ), |
| 2302 | + }, |
| 2303 | + ) |
| 2304 | + |
| 2305 | + |
2255 | 2306 | @pytest.mark.parametrize(
|
2256 | 2307 | "chain_id,transaction_exception",
|
2257 | 2308 | [
|
|
0 commit comments