Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Permits in EthAPI #9298

Closed
mattsse opened this issue Jul 4, 2024 · 2 comments · Fixed by #9363
Closed

Integrate Permits in EthAPI #9298

mattsse opened this issue Jul 4, 2024 · 2 comments · Fixed by #9363
Assignees
Labels
A-rpc Related to the RPC implementation C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started

Comments

@mattsse
Copy link
Collaborator

mattsse commented Jul 4, 2024

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:

struct DebugApiInner<Provider, Eth> {
/// The provider that can interact with the chain.
provider: Provider,
/// The implementation of `eth` API
eth_api: Eth,
// restrict the number of concurrent calls to blocking calls
blocking_task_guard: BlockingTaskGuard,

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

  • integrate guard for ethProof in ethAPI

This needs

  1. a new setting proof_permits: usize in the new function:
    pub fn new(
    provider: Provider,
    pool: Pool,
    network: Network,
    eth_cache: EthStateCache,
    gas_oracle: GasPriceOracle<Provider>,
    gas_cap: impl Into<GasCap>,
    eth_proof_window: u64,
  2. add a guard instance:
    pub struct EthApiInner<Provider, Pool, Network, EvmConfig> {
  3. expose acquire functions in
    pub trait SpawnBlocking: Clone + Send + Sync + 'static {

    similar to
    /// See also [`Semaphore::acquire_owned`]
    pub async fn acquire_owned(self) -> Result<OwnedSemaphorePermit, AcquireError> {
    self.0.acquire_owned().await
    }
    /// See also [`Semaphore::acquire_many_owned`]
    pub async fn acquire_many_owned(self, n: u32) -> Result<OwnedSemaphorePermit, AcquireError> {
    self.0.acquire_many_owned(n).await
    }

Additional context

No response

@mattsse mattsse added C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started A-rpc Related to the RPC implementation labels Jul 4, 2024
@kostekIV
Copy link
Contributor

kostekIV commented Jul 5, 2024

Hi, I would like to work on this if possible

@mattsse
Copy link
Collaborator Author

mattsse commented Jul 5, 2024

assigned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants