rpc: return error for eth_call on unexecuted blocks instead of stale data#18929
Open
madumas wants to merge 1 commit intoerigontech:mainfrom
Open
rpc: return error for eth_call on unexecuted blocks instead of stale data#18929madumas wants to merge 1 commit intoerigontech:mainfrom
madumas wants to merge 1 commit intoerigontech:mainfrom
Conversation
…data When a node is syncing, eth_call and related RPC methods were returning stale/incorrect data from the Execution stage for blocks that have headers but haven't been executed yet. This fix adds validation to return a clear error message instead. The fix validates execution progress only for explicit block numbers or hashes, while semantic tags (latest, pending, safe, finalized, earliest) continue to work normally during sync. Methods fixed: - eth_call - eth_getBalance - eth_getTransactionCount - eth_getCode - eth_getStorageAt - eth_estimateGas Fixes erigontech#18912
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.
Summary
Fixes #18912
When a node is syncing,
eth_calland related RPC methods were returning stale/incorrect data from the Execution stage for blocks that have headers but haven't been executed yet. This fix adds validation to return a clear error message instead.Key Changes
ShouldValidateExecutionProgress()helper inrpc/rpchelper/helper.goto determine if a block reference requires validation (explicit block number/hash vs semantic tags)CreateStateReader()to validate execution progress for explicit block requestsCreateStateReader(EstimateGas,GetBalance,GetTransactionCount,GetCode,GetStorageAt)Behavior
latesttagpendingtagsafe/finalizedtagMethods Fixed
eth_calleth_getBalanceeth_getTransactionCounteth_getCodeeth_getStorageAteth_estimateGasError Response
{ "jsonrpc": "2.0", "id": 1, "error": { "code": -32000, "message": "state for block 24356887 not available (execution at block 24356849)" } }This is consistent with other clients (Geth, Reth) which return
-32000for similar scenarios.Test Plan