Skip to content

Commit 04ab158

Browse files
committed
Fix EIP-7702 y_parity validation
Fixes #1444
1 parent e082b5f commit 04ab158

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

test/state/state.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ int64_t process_authorization_list(
103103
if (auth.nonce == Account::NonceMax)
104104
continue;
105105

106+
// y_parity must be 0 or 1 for EIP-7702 signatures.
107+
if (auth.v > 1)
108+
continue;
109+
106110
// 3. Verify if the signer has been successfully recovered from the signature.
107111
// authority = ecrecover(...)
108112
if (!auth.signer.has_value())

test/unittests/state_transition_eip7702_test.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@ TEST_F(state_transition, eip7702_set_code_transaction_authority_is_to)
5959
expect.post[To].code = bytes{0xef, 0x01, 0x00} + hex(delegate);
6060
}
6161

62+
TEST_F(state_transition, eip7702_set_code_transaction_invalid_y_parity)
63+
{
64+
rev = EVMC_PRAGUE;
65+
66+
constexpr auto authority = 0xca11ee_address;
67+
constexpr auto delegate = 0xde1e_address;
68+
pre[authority] = {.nonce = 1};
69+
tx.to = To;
70+
tx.type = Transaction::Type::set_code;
71+
tx.authorization_list = {{.addr = delegate, .nonce = 1, .signer = authority, .v = 2}};
72+
pre[To] = {.code = ret(0)};
73+
74+
expect.post[authority].nonce = 1;
75+
expect.post[authority].code = bytes{};
76+
expect.post[To].exists = true;
77+
expect.post[delegate].exists = false;
78+
}
79+
6280
TEST_F(state_transition, eip7702_extcodesize)
6381
{
6482
rev = EVMC_PRAGUE;

0 commit comments

Comments
 (0)