fix(types): support signing version 2 (EIP155) transactions - #698
Open
ping-ke wants to merge 3 commits into
Open
fix(types): support signing version 2 (EIP155) transactions#698ping-ke wants to merge 3 commits into
ping-ke wants to merge 3 commits into
Conversation
EIP155Signer.SignatureValues only encoded the Homestead-style recovery id (recid+27), so signing a version 2 transaction produced a V that Sender could not recover. Encode V as recid + chainId*2 + 35 for version 2, and dispatch Hash() by version so SignTx signs over the EIP155 hash. version 0/1 behaviour is unchanged. Add a version 2 sign/recover round-trip test. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
ping-ke
requested review from
blockchaindevsh,
iteyelmp,
qizhou,
qzhodl and
syntrust
July 30, 2026 04:33
Make the signing side (Hash and SignatureValues) key off tx.NetworkId() for version 2 transactions, mirroring the recovery side in Sender which already derives the chain id from the transaction itself. Previously SignatureValues rejected a version-2 tx whose network id differed from the signer's, which was inconsistent with Sender never enforcing that check for version 2. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
Issue
EIP155Signer.Senderalready supports recovering version 2 transactions using EIP-155 rules, but the corresponding local signing path was incomplete:Hashdid not use the EIP-155 signing hash.SignatureValuesstill encodedVas27/28.The issue was not previously exposed because the current workflow does not use local signing for version 2 transactions, and there was no version 2 signing test. Therefore, it did not affect transaction processing or cause a consensus issue so far.
Changes
core/types/transaction_signing.goSignatureValues: encode version 2Vasrecid + chainId * 2 + 35; keep version 0/1 unchanged.Hash: select the signing hash according to the transaction version.core/types/transaction_signing_test.goTestEIP155SigningVersion2to verify EIP-155Vencoding and sender recovery.