fix: normalize zero-tuple fee payer placeholder for Rust/alloy interop - #104
Closed
brendanjryan wants to merge 2 commits into
Closed
fix: normalize zero-tuple fee payer placeholder for Rust/alloy interop#104brendanjryan wants to merge 2 commits into
brendanjryan wants to merge 2 commits into
Conversation
Rust/alloy encodes the fee payer placeholder as Some(Signature::default()),
which RLP-serializes to [0x80, 0x80, 0x80]. ox's deserialize only recognizes
its own 0x00 sentinel and parses the zero-tuple as a real signature object
{ r: 0n, s: 0n }, causing getSignPayload to produce a different hash than
what the sender signed over. This breaks sender recovery and fee payer
co-signing for cross-client transactions.
Adds a shared cosignFeePayer helper that:
1. Deserializes via ox and normalizes zero-tuple → null
2. Recovers sender from the user's signature (all 4 sig types)
3. Computes fee payer sign payload with 0x78 magic byte
4. Re-serializes with the real fee payer signature
Replaces the previous viem signTransaction approach in Charge and Chain,
which re-serialized the transaction and could produce mismatched payloads.
commit: |
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.
Problem
When a Rust/alloy client sends a fee-payer-sponsored transaction, it encodes the placeholder as
Some(Signature::default())— an RLP list of zeros[0x80, 0x80, 0x80](c3 80 80 80). This is the spec-compliant encoding.However, ox's
TxEnvelopeTempo.deserializeonly recognises its own0x00sentinel and parses the zero-tuple as a real signature object{ r: 0n, s: 0n, yParity: 0 }. This causesgetSignPayloadto produce a 4-byte RLP list instead of the 1-byte0x00placeholder, breaking:insufficient fundsFix
Adds a shared
cosignFeePayerhelper (src/tempo/internal/cosignFeePayer.ts) that:r === 0n && s === 0n) →null0x78magic byteReplaces the previous
viem.signTransactionapproach inCharge.tsandChain.ts.Upstream
The root cause is in ox's
TxEnvelopeTempo.deserialize— it should recognise the zero-valued signature tuple as a placeholder. Will file upstream fix at wevm/ox.Spec Reference
Some(Signature::default())per Transaction Flow section