Skip to content

fix: encode authorization r and s as quantities in Authorization.toRpc - #693

Open
gomesalexandre wants to merge 1 commit into
wevm:mainfrom
gomesalexandre:fix_authorization_torpc_quantity
Open

gomesalexandre wants to merge 1 commit into
wevm:mainfrom
gomesalexandre:fix_authorization_torpc_quantity

Conversation

@gomesalexandre

Copy link
Copy Markdown
Contributor

execution-apis types the r and s of an authorization list entry as uint256 (src/schemas/transaction.yaml, pattern ^0x(0|[1-9a-f][0-9a-f]{0,63})$), so nodes expect them without leading zeros. ox keeps them as 32-byte padded hex, and Authorization.toRpc passed them through as is. TransactionRequest.toRpc, Transaction.toRpc and UserOperation.toRpc (eip7702Auth) go through it. So a signed authorization whose r or s has a zero top nibble went out with a leading zero digit. That's about 1 in 16 for r and 1 in 8 for a low-s s, and geth-based nodes reject the request.

I sent a real mainnet authorization (from tx 0x701f5911…7b51, whose s is 62 digits) through TransactionRequest.toRpc into eth_estimateGas on publicnode:

chain before after
Ethereum -32602 ... cannot unmarshal hex number with leading zero digits into Go struct field TransactionArgs.authorizationList.s of type *uint256.Int 0xb52e
Arbitrum One same -32602 0xcfd4
Polygon same -32602 0xb52e
Base, BSC 0xb52e (these backends accept it) 0xb52e

toRpc now encodes r and s with Hex.fromNumber(BigInt(...)), the same way viem's formatAuthorizationList does (numberToHex(BigInt(r))), so zero comes out as 0x0. Transaction.toRpc(Transaction.fromRpc(tx)) now matches the node JSON for the authorization list. Before this change, 43 of 173 live mainnet authorizations didn't match.

The new test round-trips that mainnet authorization and a zero r, and it fails on main. Two existing snapshots change to 0x1 / 0x2: the authorization list in the TxEnvelopeEip7702.toRpc test, and eip7702Auth in the UserOperation.toRpc test. Transaction-level r/s are unchanged: Transaction.toRpc copies them directly, and nodes don't read them from requests.

🤖 Generated with Claude Code

….toRpc`

execution-apis types authorization list `r` and `s` as `uint256`, so
nodes expect them without leading zeros. `Authorization.toRpc` passed
the 32-byte padded values through, and geth-based nodes reject them in
`eth_estimateGas`, `eth_call` and `eth_sendTransaction` ("hex number
with leading zero digits") whenever the top nibble is zero.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown

@gomesalexandre is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant