-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eth_call
targeting an unknown block hash returns "unknown block number"
#7368
Comments
eth_call
targeting an unknown block hash returns "unknown block number"
we can map the error to a more specific error, but those are also not consistent across clients |
What about something like changing /// When an unknown block is encountered
#[error("unknown block id: {0:?}")]
UnknownBlockId(BlockId), Since that error is used in a lot of spots I'd probably first add the new error and deprecate the old error just to keep the initial PR smaller, then do a follow-on to update everywhere it's used. If that sounds like a reasonable plan assign this to me, I just setup a new system for |
Hmm, actually my suggestion above doesn't quite work, for a couple reasons: First off, this generates errors like:
So would probably need to implement /// Executes the call request (`eth_call`) and returns the output
pub async fn call(
&self,
request: TransactionRequest,
at: Option<BlockId>,
overrides: EvmOverrides,
) -> EthResult<Bytes> {
let at = at.unwrap_or(BlockId::Number(BlockNumberOrTag::Latest));
let (res, _env) =
self.transact_call_at(request, at, overrides).await.map_err(|e| match e {
EthApiError::UnknownBlockNumber => EthApiError::UnknownBlockId(at),
_ => e,
})?;
ensure_success(res.result)
} The reason is that often when we are returning |
Hmm, but |
checked geth error for reference: https://github.com/ethereum/go-ethereum/blob/767b00b0b514771a663f3362dd0310fc28d40c25/eth/api_backend.go#L216-L233 also relevant https://eips.ethereum.org/EIPS/eip-1474#block-identifier but idk if this is enforced by other clients tbh @ryanschneider you can solve this with a wrapper error type, or customize the into ErrorObject impl |
@mattsse RE: the EIP-1474 link, are you referring to returning I went with customizing the
And:
I'll start a PR hopefully later today. |
Draft PR: #7416 |
This issue is stale because it has been open for 21 days with no activity. |
I am applying to this issue via OnlyDust platform. My background and how it can be leveragedI have experience in Ethereum development and smart contract deployment, with a focus on Solidity and Rust. I have worked on deploying contracts on both Ethereum and Layer 2 solutions, and I have experience with blockchain node implementation and RPC protocols. How I plan on tackling this issueTo address the issue where eth_call targeting an unknown block hash returns "unknown block number" instead of "block hash not found," I would first review the current implementation of the eth_call method in the Reth codebase to understand the existing error handling mechanism. Then, I would implement logic to differentiate between block numbers and block hashes based on their format and update the error handling code to provide specific error messages for unknown block hashes and block numbers. Finally, I would test the changes thoroughly to ensure the correct error messages are returned in each scenario. |
Describe the bug
When making an
eth_call
targeting a block by hash that does not exist returnsunknown block number
, instead of reporting the block hash as not found.Steps to reproduce
reth
node.curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0x9 008d19f58aabd9ed0d60971565aa8510560ab41","data":"0xf698da25","value":"0x0"},"0x230d842afd1faceaa3c5c0dacd24228747565c4 41ed5e1e3a9306c2c6b55d619"],"id":1}' http://localhost:8545
{"jsonrpc":"2.0","error":{"code":-32001,"message":"unknown block number"},"id":1}
Compare the above with:
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0x9 008d19f58aabd9ed0d60971565aa8510560ab41","data":"0xf698da25","value":"0x0"},"0x230d842afd1faceaa3c5c0dacd24228747565c4 41ed5e1e3a9306c2c6b55d619"],"id":1}' https://rpc.mevblocker.io
{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"block 230d842afd1faceaa3c5c0dacd24228747565c441ed5e1e3a9306c2c6b55d619 not found"}}
Node logs
No response
Platform(s)
Linux (x86)
What version/commit are you on?
v0.2.0-beta.3
What database version are you on?
Current database version: 2
Local database version: 2
What type of node are you running?
Archive (default)
What prune config do you use, if any?
No response
If you've built Reth from source, provide the full command you used
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: