Add ChainId to legacy transactions in RPC responses derived from signature#9453
Merged
LukaszRozmej merged 3 commits intomasterfrom Oct 14, 2025
Merged
Conversation
Co-authored-by: MarekM25 <9356351+MarekM25@users.noreply.github.com>
Co-authored-by: MarekM25 <9356351+MarekM25@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add ChainID support for legacy transactions in RPC
Add ChainId to legacy transactions in RPC responses derived from signature
Oct 13, 2025
MarekM25
approved these changes
Oct 14, 2025
smartprogrammer93
approved these changes
Oct 14, 2025
LukaszRozmej
approved these changes
Oct 14, 2025
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.
Description
Fixes legacy transaction RPC responses to include the
chainIdfield when it can be derived from the transaction signature, even whentransaction.ChainIdis null.According to the Ethereum JSON-RPC specification and Hive test expectations, legacy transactions (type 0x0) should include the
chainIdfield in RPC responses when the transaction is signed with EIP-155 (where chainId is encoded in the V value of the signature).Changes
Core Implementation
Modified
LegacyTransactionForRpcconstructor to populateChainIdfrom the signature whentransaction.ChainIdis null:The
Signatureclass already has logic to extract chainId from the V value for EIP-155 transactions:chainIdis nullchainId = (V + (V % 2) - 36) / 2Testing
Example
For a legacy transaction with V = 0x18e5bb3abd109f (from the Hive test):
{ "type": "0x0", "nonce": "0x9a", "chainId": "0xc72dd9d5e883e", // Now correctly included "v": "0x18e5bb3abd109f", "r": "0x551fe45ccebb0318196e31dbc60da87c43dc60b8fb01afb3286693fa09878730", "s": "0x40d33e9afecfe1516b045d61a3272bddbc83f482a7f2c749311248b50fe62e81" }Impact
This change ensures Nethermind's RPC responses are compliant with Ethereum JSON-RPC specifications and pass Hive conformance tests for legacy transactions.
Resolves issue where Hive expected chainId to be returned for legacy transactions.
Original prompt
This section details on the original issue you should resolve
<issue_title>ChainID for legacy transactions in RPC</issue_title>
<issue_description>```
Fixes #9372
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.