foundry-rs / foundry-rs/foundry

feat(`anvil`): add the ability to disable specific RPC methods and cheatcodes in Anvil

Open
#8,731 5 comments 0 reactions 0 assignees View on GitHub
A-cheatcodes A-reth-anvil C-anvil T-feature
Dominant language
Rust
Stars
10.6k
Forks
2.6k
Avg merge
18h 20m
Merged PRs (30d)
510

Description

### Component

Anvil

### Describe the feature you would like

Description:

Currently, Anvil provides a robust set of RPC methods, including several non-standard methods that are extremely useful for development and testing. However, in certain scenarios, especially in environments that require stricter security and control, it would be beneficial to have the ability to disable specific RPC methods to prevent unintended use or tampering.

Motivation:

The ability to disable specific RPC methods would allow users to:

Ensure that certain RPC methods, which could be potentially dangerous in a controlled environment (e.g., anvil_reset, anvil_autoImpersonateAccount), are not accessible.
Improve security in environments where strict RPC method control is necessary.
Provide more granular control over the Anvil node configuration, aligning it with more restrictive deployment requirements.
Proposed Solution:

Introduce a configuration option, either via a command-line argument or a configuration file, that allows users to specify a list of RPC methods to disable when starting the Anvil node. This could be implemented as follows:

A command-line argument such as --disable-rpc-methods "method1,method2" to disable specific methods.
Alternatively, a configuration file option where users can list methods to be disabled.

Additionally, as requested in #8699 it would be beneficial to disable certain cheatcodes from being used in Anvil.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.