Skip to content

Conversation

sashass1315
Copy link
Contributor

Motivation

The codebase had three RPC handler methods (protocol_version, hashrate, author) that were implemented in EthApi but were effectively dead code because they were not exposed through the JSON-RPC interface. These methods existed with proper documentation indicating they were handlers for standard Ethereum RPC calls (eth_protocolVersion, eth_hashrate, eth_coinbase), but they were never wired up in the EthRequest enum or the execute() dispatcher. This meant clients expecting these standard RPC endpoints would receive "method not found" errors, reducing Anvil's compatibility with Ethereum tooling and clients.

Solution

  1. Adding missing EthRequest variants in crates/anvil/core/src/eth/mod.rs:
  • EthProtocolVersion(()) for eth_protocolVersion
  • EthHashrate(()) for eth_hashrate
  • EthCoinbase(()) for eth_coinbase
  1. Wiring the handlers in EthApi::execute() in crates/anvil/src/eth/api.rs:
  • EthProtocolVersion(_) => self.protocol_version().to_rpc_result()
  • EthHashrate(_) => self.hashrate().to_rpc_result()
  • EthCoinbase(_) => self.author().to_rpc_result()

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@sashass1315
Copy link
Contributor Author

forgot to make changes to api.rs ... sory for noise

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesnt hurt

@mattsse mattsse enabled auto-merge (squash) October 2, 2025 20:58
@mattsse mattsse merged commit 2bb29fb into foundry-rs:master Oct 2, 2025
16 checks passed
@github-project-automation github-project-automation bot moved this to Done in Foundry Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants