Add support for blacklisted rpc endpoints
Component
Anvil
Describe the feature you would like
anvil's api is quite massive and some endpoints are considered "god mode"
there are usecases where these should be restricted.
this should be done on the rpc server level because this is how the server is exposed and the easiest solution here is:
- introduce a blacklist (HashSet of string) of certain endpoints in the config: https://github.com/foundry-rs/foundry/blob/e215f3fdeada259a8886a7611151794d280ca298/crates/anvil/server/src/config.rs#L8-L8
- if at least 1 blacklisted method, install another layer, similar to https://github.com/foundry-rs/foundry/blob/e215f3fdeada259a8886a7611151794d280ca298/crates/anvil/server/src/lib.rs#L76-L78
this layer should deserialize the request and reject disallowed methods, this is likely slightly inefficient but this deserialization overhead should be fine because we only need to check for method.
Additional context
No response
Hi, I would like to give this one a try
related https://github.com/foundry-rs/foundry/issues/8731
@mattsse I have 2 questions:
- What do you think about this usage and command line format:
anvil --blacklist eth_sendTransaction,eth_sendRawTransaction
or is this one better:
anvil --blacklist eth_sendTransaction --blacklist eth_sendRawTransaction
- What should be the expected response for a blacklisted method call - just a regular "Method not found"?
yeah method not found or method not whitelisted
I'd also like to support some presets, like unsafe or something that by makes cli usage easier
I'd also like to support some presets, like
unsafeor something that by makes cli usage easier
@mattsse Could you elaborate on that? Maybe provide an example
just to simplify tracking, going to dupe it in favor of https://github.com/foundry-rs/foundry/issues/8731 which is the same request