From 07fbd3c71d234d46354890ad3a59c2a9067d666e Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Sat, 28 May 2022 18:45:45 +0000 Subject: [PATCH] todos --- TODO.md | 12 ++++++------ web3-proxy/src/app.rs | 2 +- web3-proxy/src/connections.rs | 5 ++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/TODO.md b/TODO.md index 4d576c3f..5d840656 100644 --- a/TODO.md +++ b/TODO.md @@ -1,30 +1,30 @@ # Todo -- [ ] use redis and redis-cell for rate limits +- [x] use redis and redis-cell for rate limits +- [ ] if we don't cache errors, then in-flight request caching is going to bottleneck - [x] some production configs are occassionally stuck waiting at 100% cpu - they stop processing new blocks. i'm guessing 2 blocks arrive at the same time, but i thought our locks would handle that - even after removing a bunch of the locks, the deadlock still happens. i can't reliably reproduce. i just let it run for awhile and it happens. - running gdb shows the thread at tokio tungstenite thread is spinning near 100% cpu and none of the rest of the program is proceeding - fixed by https://github.com/gakonst/ethers-rs/pull/1287 -- [ ] should we use ethers-rs' quorum provider for the private rpcs? i think it would work well, but won't work with our current reconnect logic - [ ] improve caching - [ ] if the eth_call (or similar) params include a block, we can cache for longer - [ ] if the call is something simple like "symbol" or "decimals", cache that too - [ ] when we receive a block, we should store it for later eth_getBlockByNumber, eth_blockNumber, and similar calls -- [ ] eth_sendRawTransaction should return the most common result, not the first -- [ ] if chain split detected, don't send transactions +- [x] eth_sendRawTransaction should return the most common result, not the first +- [ ] if chain split detected, don't send transactions? - [ ] if a rpc fails to connect at start, retry later instead of skipping it forever - [ ] endpoint for health checks. if no synced servers, give a 502 error - [x] move from warp to auxm? - [ ] proper logging with useful instrumentation -- [ ] handle websocket disconnect and reconnect +- [x] handle websocket disconnect and reconnect - [ ] warning if no blocks for too long. maybe reconnect automatically? - [ ] if the fastest server has hit rate limits, we won't be able to serve any traffic until another server is synced. - thundering herd problem if we only allow a lag of 0 blocks - we can fix this by only `publish`ing the sorted list once a certain sync limit is reached - [ ] tarpit hard_ratelimit at the start, but reject if incoming requests is super high? - [ ] add the backend server to the header? -- [ ] the web3proxyapp object gets cloned for every call. why do we need any arcs inside that? shouldn't they be able to connect to the app's? can we just use static lifetimes +- [x] the web3proxyapp object gets cloned for every call. why do we need any arcs inside that? shouldn't they be able to connect to the app's? can we just use static lifetimes - [ ] think more about how multiple rpc tiers should work - [ ] if a request gets a socket timeout, try on another server - maybe always try at least two servers in parallel? and then return the first? or only if the first one doesn't respond very quickly? diff --git a/web3-proxy/src/app.rs b/web3-proxy/src/app.rs index dcb2401f..f68676c5 100644 --- a/web3-proxy/src/app.rs +++ b/web3-proxy/src/app.rs @@ -302,7 +302,7 @@ impl Web3ProxyApp { } } - // TODO: move this whole match to a function on self.balanced_rpcs + // TODO: move this whole match to a function on self.balanced_rpcs. incoming requests checks makes it awkward match self.balanced_rpcs.next_upstream_server().await { Ok(active_request_handle) => { let response = active_request_handle diff --git a/web3-proxy/src/connections.rs b/web3-proxy/src/connections.rs index 14fa1881..98c58cdc 100644 --- a/web3-proxy/src/connections.rs +++ b/web3-proxy/src/connections.rs @@ -180,7 +180,7 @@ impl Web3Connections { .collect::, ProviderError>>>() .await; - // TODO: Strings are not great keys, but we can't use RawValue or ProviderError as keys + // TODO: Strings are not great keys, but we can't use RawValue or ProviderError as keys because they don't implement Hash or Eq let mut count_map: HashMap, ProviderError>> = HashMap::new(); let mut counts: Counter = Counter::new(); let mut any_ok = false; @@ -199,7 +199,6 @@ impl Web3Connections { } for (most_common, _) in counts.most_common_ordered() { - // TODO: how do we take this? let most_common = count_map.remove(&most_common).unwrap(); if any_ok && most_common.is_err() { @@ -466,7 +465,7 @@ impl Web3Connections { Err(None) => { // TODO: return a 502? // TODO: i don't think this will ever happen - return Err(anyhow::anyhow!("no private rpcs!")); + return Err(anyhow::anyhow!("no available rpcs!")); } Err(Some(retry_after)) => { // TODO: move this to a helper function