Skip to content

Commit 34016d2

Browse files
committed
new(tests): EIP 7702: add test_signature_s_out_of_range
1 parent 61a5993 commit 34016d2

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

tests/prague/eip7702_set_code_tx/test_set_code_txs.py

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pytest
1212

1313
from ethereum_test_addresses import SystemContract
14+
from ethereum_test_base_types import HexNumber
1415
from ethereum_test_forks import Fork
1516
from ethereum_test_tools import (
1617
AccessList,
@@ -2204,7 +2205,7 @@ def test_invalid_tx_invalid_auth_signature(
22042205
pytest.param(0, 1, 2**256 - 1, id="s=2**256-1"),
22052206
# All Values
22062207
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"),
22082209
],
22092210
)
22102211
def test_valid_tx_invalid_auth_signature(
@@ -2252,6 +2253,56 @@ def test_valid_tx_invalid_auth_signature(
22522253
)
22532254

22542255

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+
22552306
@pytest.mark.parametrize(
22562307
"chain_id,transaction_exception",
22572308
[

0 commit comments

Comments
 (0)