From 337f5bc1f8b92b8f17b34506def32486ca7303d8 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Tue, 25 Oct 2022 04:34:24 +0000 Subject: [PATCH] sort configs --- config/example.toml | 2 ++ web3_proxy/src/config.rs | 37 +++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/config/example.toml b/config/example.toml index 35b6a2e6..33c01348 100644 --- a/config/example.toml +++ b/config/example.toml @@ -15,6 +15,8 @@ volatile_redis_url = "redis://dev-vredis:6379/" redirect_public_url = "https://llamanodes.com/free-rpc-stats" redirect_user_url = "https://llamanodes.com/user-rpc-stats/{{user_id}}" +# 0 = block all public requests +public_max_concurrent_requests = 5 # 0 = block all public requests public_requests_per_minute = 0 diff --git a/web3_proxy/src/config.rs b/web3_proxy/src/config.rs index 50559a4f..79328e26 100644 --- a/web3_proxy/src/config.rs +++ b/web3_proxy/src/config.rs @@ -51,6 +51,7 @@ pub struct TopConfig { #[serde(deny_unknown_fields)] pub struct AppConfig { /// Request limit for allowed origins for anonymous users. + /// These requests get rate limited by IP. pub allowed_origin_requests_per_minute: HashMap, /// EVM chain id. 1 for ETH @@ -78,6 +79,11 @@ pub struct AppConfig { /// None = no code needed pub invite_code: Option, + /// Rate limit for the login entrypoint. + /// This is separate from the rpc limits. + #[serde(default = "default_login_rate_limit_per_minute")] + pub login_rate_limit_per_minute: u64, + /// The soft limit prevents thundering herds as new blocks are seen. #[serde(default = "default_min_sum_soft_limit")] pub min_sum_soft_limit: u32, @@ -86,30 +92,17 @@ pub struct AppConfig { #[serde(default = "default_min_synced_rpcs")] pub min_synced_rpcs: usize, - /// Request limit for anonymous users. - /// Some(0) = block all requests - /// None = allow all requests - #[serde(default = "default_public_requests_per_minute")] - pub public_requests_per_minute: Option, - /// Concurrent request limit for anonymous users. /// Some(0) = block all requests /// None = allow all requests #[serde(default = "default_public_max_concurrent_requests")] pub public_max_concurrent_requests: Option, - /// Rate limit for the login entrypoint. - /// This is separate from the rpc limits. - #[serde(default = "default_login_rate_limit_per_minute")] - pub login_rate_limit_per_minute: u64, - - /// Track rate limits in a redis (or compatible backend) - /// It is okay if this data is lost. - pub volatile_redis_url: Option, - - /// maximum size of the connection pool for the cache - /// If none, the minimum * 2 is used - pub volatile_redis_max_connections: Option, + /// Request limit for anonymous users. + /// Some(0) = block all requests + /// None = allow all requests + #[serde(default = "default_public_requests_per_minute")] + pub public_requests_per_minute: Option, /// RPC responses are cached locally #[serde(default = "default_response_cache_max_bytes")] @@ -123,6 +116,14 @@ pub struct AppConfig { /// Optionally send errors to pub sentry_url: Option, + + /// Track rate limits in a redis (or compatible backend) + /// It is okay if this data is lost. + pub volatile_redis_url: Option, + + /// maximum size of the connection pool for the cache + /// If none, the minimum * 2 is used + pub volatile_redis_max_connections: Option, } /// This might cause a thundering herd!