Skip to content

feat(anvil): add optional verbose rpc payload logging #12887

Open
aodhgan wants to merge 31 commits intofoundry-rs:masterfrom
aodhgan:ag/feat/add-verbose-rpc-logging
Open

feat(anvil): add optional verbose rpc payload logging #12887
aodhgan wants to merge 31 commits intofoundry-rs:masterfrom
aodhgan:ag/feat/add-verbose-rpc-logging

Conversation

@aodhgan
Copy link

@aodhgan aodhgan commented Dec 19, 2025

Motivation

Often times when testing client integrations I wish to quickly debug what successful RPC calls (and their params) are made. To get around this I typically resort to setting up a Man In the Middle style proxy to simply log the requests and responses, but this is a nuisance.

Solution

This PR introduces a backward compatible optional --rpc-log flag which, when enabled provides verbose logging of the form:

RPC request [id=10390, method=eth_maxPriorityFeePerGas, peer=127.0.0.1:58496, ts=2025-12-18T01:14:59.489792+00:00]: {"jsonrpc":"2.0","method":"eth_maxPriorityFeePerGas","params":null,"id":10390}
RPC response [id=10390, method=eth_maxPriorityFeePerGas, peer=127.0.0.1:58496, ts=2025-12-18T01:14:59.489792+00:00]: {"result":"0x3b9aca00"}

Specific code changes:

  • Added a --rpc-log CLI flag that feeds into NodeConfig, persists the RPC payload logging preference, and exposes a with_rpc_logging builder to propagate the setting
  • Introduced an RpcCallLogContext (id, method, peer address, timestamp) and a centralized log_rpc_method helper so method banners are suppressed when payload logging is enabled while request/response payloads continue to include contextual metadata
  • Wrapped HTTP RPC handling to capture raw JSON, attach the logging context (including peer/timestamp), and pass everything through to EthApi::execute_with_raw; Otterscan handlers now reuse the shared method-logging helper.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

This PR used ChatGPT's copilot for implementation.

aodhgan and others added 23 commits December 19, 2025 14:16
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
…nstruction

Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
…ary clones

Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
aodhgan and others added 5 commits December 19, 2025 14:16
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Initial plan

* Fix unnecessary Value cloning in RPC payload logging

Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>

* Add clarifying comment about RequestParams clone

Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
…ds checks

Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
…zation

Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
…til logging is enabled

Co-authored-by: aodhgan <36907214+aodhgan@users.noreply.github.com>
@aodhgan aodhgan force-pushed the ag/feat/add-verbose-rpc-logging branch from 6b27547 to 14e8e1f Compare December 19, 2025 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants

Comments