Repository navigation
fix: encode legacy v above 255 in Transaction.toRpc - #691
Open
gomesalexandre wants to merge 1 commit into
Open
gomesalexandre wants to merge 1 commit into
gomesalexandre wants to merge 1 commit into
Conversation
`Transaction.toRpc` encoded `v` with `size: 1` for every transaction type. A legacy EIP-155 `v` is `chainId * 2 + 35 + yParity`, so from chain ID 110 on (Polygon, Base, Arbitrum, ...) it passes 255 and `toRpc` threw `Hex.IntegerOutOfRangeError`. `toRpc(fromRpc(tx))` failed on real legacy transactions from those chains. execution-apis types the legacy `v` as `uint` and the typed `v` as `byte`, so legacy now encodes it without a size and typed transactions keep the single byte. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Transaction.toRpcencodedvwith{ size: 1 }for every transaction type. A legacy EIP-155vischainId * 2 + 35 + yParity, so it passes 255 from chain ID 110 on (110 with an oddy, every chain from 111) andtoRpcthrewHex.IntegerOutOfRangeError. That covers Polygon (v309/310), Base (v0x422d/0x422e), Arbitrum, Optimism and so on.Block.toRpcsends every full transaction throughTransaction.toRpc, so one legacy transaction makes the whole block throw.execution-apis types the two
vs differently (src/schemas/transaction.yaml):TransactionLegacySigned.visuint(^0x(0|[1-9a-f][0-9a-f]*)$), with no size limit.visbyte(^0x[0-9a-f]{1,2}$).So legacy now encodes
vwith no size, and typed transactions keep the single byte. The typed snapshots ("v": "0x00") are unchanged.TxEnvelopeLegacy.toRpcandTransactionRequest.toRpcalready encodevwithout a size, so this matches them.I ran
Transaction.toRpc(Transaction.fromRpc(tx))on every legacy transaction in a livelatestblock from publicnode:Number 309 is not in safe 8-bit unsigned integer range), andBlock.toRpcof the full block throwsvis the node'sv, andBlock.toRpcis okv=0x422dthrows, and so doesBlock.toRpcof the full blockBlock.toRpcis okThe new test round-trips a real Polygon legacy transaction (
v: '0x136'). It throws onmainand passes with this change. The two legacybehavior: nullish/behavior: pendingfixtures usev: 0, and their snapshots go from"0x00"to"0x0", which is theuintform.If you'd rather drop
{ size: 1 }for every type, that works too, sincebytealso accepts0x0, and the zod typed schemas already emit0x0. It only changes more snapshots, so I kept this PR to legacy.The same
{ size: 1 }is on0.x(Hex.fromNumber(transaction.v, { size: 1 })insrc/core/Transaction.ts), so it probably wants the same fix there.🤖 Generated with Claude Code