paradigmxyz / reth

Modular, contributor-friendly and blazing-fast implementation of the Ethereum protocol, in Rust
https://reth.rs/
Apache License 2.0
3.54k stars 918 forks source link

Integrate Permits in EthAPI #9298

Closed mattsse closed 2 days ago

mattsse commented 6 days ago

Describe the feature

with ethProof the EthApi now has an expensive endpoint that should be ratelimited.

the tracing endpoints, like debug already have a shared BlockingTaskGuard:

https://github.com/paradigmxyz/reth/blob/edbbc9636eca770102f6ff33779130deb7b38360/crates/rpc/rpc/src/debug.rs#L1024-L1030

However, these are aimed at the CPU, while eth_proof focuses more on the memory. we can solve this with an additional guard in ethAPI itself. we want to explicitly restrict eth_getproof without interfering too much with the regular tracing calls.

TODO

This needs 1) a new setting proof_permits: usize in the new function: https://github.com/paradigmxyz/reth/blob/edbbc9636eca770102f6ff33779130deb7b38360/crates/rpc/rpc/src/eth/core.rs#L40-L47 2) add a guard instance: https://github.com/paradigmxyz/reth/blob/edbbc9636eca770102f6ff33779130deb7b38360/crates/rpc/rpc/src/eth/core.rs#L156-L156 3) expose acquire functions in https://github.com/paradigmxyz/reth/blob/edbbc9636eca770102f6ff33779130deb7b38360/crates/rpc/rpc-eth-api/src/helpers/blocking_task.rs#L10-L10 similar to https://github.com/paradigmxyz/reth/blob/edbbc9636eca770102f6ff33779130deb7b38360/crates/tasks/src/pool.rs#L31-L39

Additional context

No response

kostekIV commented 5 days ago

Hi, I would like to work on this if possible

mattsse commented 5 days ago

assigned