From ea8f6091f9463383116b8bba7ceeb444ef170490 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Wed, 14 Sep 2022 06:41:34 +0000 Subject: [PATCH] improve (but disable) rate limits --- redis-rate-limit/src/lib.rs | 2 +- web3_proxy/src/app.rs | 6 +++--- web3_proxy/src/frontend/rate_limit.rs | 3 +++ web3_proxy/src/rpcs/blockchain.rs | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/redis-rate-limit/src/lib.rs b/redis-rate-limit/src/lib.rs index c737eb9a..ecca74b9 100644 --- a/redis-rate-limit/src/lib.rs +++ b/redis-rate-limit/src/lib.rs @@ -72,7 +72,7 @@ impl RedisRateLimit { let throttle_key = format!("{}:{}:{}", self.key_prefix, label, period_id); - let mut conn = self.pool.get().await?; + let mut conn = self.pool.get().await.context("throttle")?; // TODO: at high concurency, i think this is giving errors // TODO: i'm starting to think that bb8 has a bug diff --git a/web3_proxy/src/app.rs b/web3_proxy/src/app.rs index c959004b..2369c998 100644 --- a/web3_proxy/src/app.rs +++ b/web3_proxy/src/app.rs @@ -218,13 +218,13 @@ impl Web3ProxyApp { .unwrap_or(num_workers * 2); // TODO: what are reasonable timeouts + // TODO: set a wait timeout? maybe somehow just emit a warning if this is long let redis_pool = RedisConfig::from_url(redis_url) .builder()? - .create_timeout(Some(Duration::from_secs(2))) + .create_timeout(Some(Duration::from_secs(5))) .max_size(redis_max_connections) - .recycle_timeout(Some(Duration::from_secs(2))) + .recycle_timeout(Some(Duration::from_secs(5))) .runtime(Runtime::Tokio1) - .wait_timeout(Some(Duration::from_secs(2))) .build()?; // test the pool diff --git a/web3_proxy/src/frontend/rate_limit.rs b/web3_proxy/src/frontend/rate_limit.rs index 007ff97a..0e290ec6 100644 --- a/web3_proxy/src/frontend/rate_limit.rs +++ b/web3_proxy/src/frontend/rate_limit.rs @@ -170,6 +170,9 @@ impl Web3ProxyApp { return Ok(RateLimitResult::UnknownKey); } + // TODO: turn back on rate limiting once our alpha test is complete + return Ok(RateLimitResult::AllowedUser(user_data.user_id)); + // user key is valid. now check rate limits // TODO: this is throwing errors when curve-api hits us with high concurrency. investigate i think its bb8's fault if let Some(rate_limiter) = &self.frontend_rate_limiter { diff --git a/web3_proxy/src/rpcs/blockchain.rs b/web3_proxy/src/rpcs/blockchain.rs index 84f4c41e..83768739 100644 --- a/web3_proxy/src/rpcs/blockchain.rs +++ b/web3_proxy/src/rpcs/blockchain.rs @@ -287,7 +287,7 @@ impl Web3Connections { let conn_head_block = if let Some(x) = self.block_hashes.get(connection_head_hash) { x } else { - // TODO: why does this happen?!?! + // TODO: why does this happen?!?! seems to only happen with uncled blocks. maybe a check on total difficulty skipped it? // TODO: maybe we should do get_with? // TODO: maybe we should just continue. this only seems to happen when an older block is received warn!(%connection_head_hash, %conn_name, %rpc, "Missing connection_head_block in block_hashes. Fetching now");