From 633abc0d600befb84931fd46b182c02a1d31855b Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Sat, 2 Sep 2023 10:59:07 -0700 Subject: [PATCH] make wait_for_best_rpc work for private/4337/groups without head subscriptions --- web3_proxy/src/app/mod.rs | 26 ++++++++++++-------------- web3_proxy/src/rpcs/many.rs | 12 ++++++++++++ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/web3_proxy/src/app/mod.rs b/web3_proxy/src/app/mod.rs index 7fd94568..249f7cc2 100644 --- a/web3_proxy/src/app/mod.rs +++ b/web3_proxy/src/app/mod.rs @@ -1340,20 +1340,18 @@ impl Web3ProxyApp { | "eth_supportedEntryPoints" | "web3_bundlerVersion") => match self.bundler_4337_rpcs.as_ref() { Some(bundler_4337_rpcs) => { - // let x = bundler_4337_rpcs - // .try_send_all_synced_connections::>( - // method, - // params, - // Some(request_metadata), - // None, - // None, - // Some(Duration::from_secs(30)), - // Some(Level::DEBUG.into()), - // Some(1), - // ) - // .await?; - // x.into() - todo!("wip"); + let x = bundler_4337_rpcs + .try_proxy_connection::<_, Box>( + method, + params, + Some(request_metadata), + Some(Duration::from_secs(30)), + None, + None, + ) + .await?; + + x.into() } None => { // TODO: stats even when we error! diff --git a/web3_proxy/src/rpcs/many.rs b/web3_proxy/src/rpcs/many.rs index b78f0359..99f76b47 100644 --- a/web3_proxy/src/rpcs/many.rs +++ b/web3_proxy/src/rpcs/many.rs @@ -538,6 +538,18 @@ impl Web3Rpcs { .and_then(|x| x.authorization.clone()) .unwrap_or_default(); + if self.watch_head_block.is_none() { + // if this group of servers is not watching the head block, we don't know what is "best" based on block height + // TODO: do this without cloning here + let potential_rpcs = self.by_name.read().values().cloned().collect::>(); + + let x = self + ._best_available_rpc(&authorization, error_handler, &potential_rpcs, skip_rpcs) + .await; + + return Ok(x); + } + let mut watch_ranked_rpcs = self.watch_ranked_rpcs.subscribe(); let mut potential_rpcs = Vec::new();