Skip to content

fix(types): support signing version 2 (EIP155) transactions - #698

Open
ping-ke wants to merge 3 commits into
masterfrom
fix/eip155-signer-sign
Open

fix(types): support signing version 2 (EIP155) transactions#698
ping-ke wants to merge 3 commits into
masterfrom
fix/eip155-signer-sign

Conversation

@ping-ke

@ping-ke ping-ke commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Issue

EIP155Signer.Sender already supports recovering version 2 transactions using EIP-155 rules, but the corresponding local signing path was incomplete:

  • Hash did not use the EIP-155 signing hash.
  • SignatureValues still encoded V as 27/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.go
    • SignatureValues: encode version 2 V as recid + chainId * 2 + 35; keep version 0/1 unchanged.
    • Hash: select the signing hash according to the transaction version.
    • Validate that the version 2 transaction network ID matches the signer network ID.
  • core/types/transaction_signing_test.go
    • Add TestEIP155SigningVersion2 to verify EIP-155 V encoding and sender recovery.
    • Add a test covering mismatched version 2 network IDs.

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]>
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]>
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