diff --git a/config/example.toml b/config/example.toml index 3cf01124..da00451d 100644 --- a/config/example.toml +++ b/config/example.toml @@ -6,3 +6,20 @@ url = "ws://127.0.0.1:8546" soft_limit = 200_000 +[private_rpcs] + + [private_rpcs.eden] + url = "https://api.edennetwork.io/v1/" + soft_limit = 1_805 + + [private_rpcs.eden_beta] + url = "https://api.edennetwork.io/v1/beta" + soft_limit = 5_861 + + [private_rpcs.ethermine] + url = "https://rpc.ethermine.org" + soft_limit = 5_861 + + [private_rpcs.flashbots] + url = "https://rpc.flashbots.net" + soft_limit = 7074 diff --git a/web3-proxy/src/app.rs b/web3-proxy/src/app.rs index 14d010f5..11e4169c 100644 --- a/web3-proxy/src/app.rs +++ b/web3-proxy/src/app.rs @@ -85,6 +85,7 @@ impl Web3ProxyApp { balanced_rpc_tier, Some(http_client.clone()), &clock, + true, ) })) .await @@ -103,6 +104,7 @@ impl Web3ProxyApp { private_rpcs, Some(http_client), &clock, + false, ) .await?, ) diff --git a/web3-proxy/src/connections.rs b/web3-proxy/src/connections.rs index f4e67454..a5c184b5 100644 --- a/web3-proxy/src/connections.rs +++ b/web3-proxy/src/connections.rs @@ -65,6 +65,7 @@ impl Web3Connections { servers: Vec, http_client: Option, clock: &QuantaClock, + subscribe_heads: bool, ) -> anyhow::Result> { let mut connections = vec![]; @@ -85,19 +86,21 @@ impl Web3Connections { synced_connections: RwLock::new(SyncedConnections::new(num_connections)), }); - for connection in connections.inner.iter() { - // subscribe to new heads in a spawned future - // TODO: channel instead. then we can have one future with write access to a left-right? - let connection = Arc::clone(connection); - let connections = connections.clone(); - tokio::spawn(async move { - let url = connection.url().to_string(); + if subscribe_heads { + for connection in connections.inner.iter() { + // subscribe to new heads in a spawned future + // TODO: channel instead. then we can have one future with write access to a left-right? + let connection = Arc::clone(connection); + let connections = connections.clone(); + tokio::spawn(async move { + let url = connection.url().to_string(); - // TODO: instead of passing Some(connections), pass Some(channel_sender). Then listen on the receiver below to keep local heads up-to-date - if let Err(e) = connection.new_heads(Some(connections)).await { - warn!("new_heads error on {}: {:?}", url, e); - } - }); + // TODO: instead of passing Some(connections), pass Some(channel_sender). Then listen on the receiver below to keep local heads up-to-date + if let Err(e) = connection.new_heads(Some(connections)).await { + warn!("new_heads error on {}: {:?}", url, e); + } + }); + } } Ok(connections) diff --git a/web3-proxy/src/jsonrpc.rs b/web3-proxy/src/jsonrpc.rs index c17cea30..6bcd2cad 100644 --- a/web3-proxy/src/jsonrpc.rs +++ b/web3-proxy/src/jsonrpc.rs @@ -62,7 +62,6 @@ impl<'de> Deserialize<'de> for JsonRpcRequestEnum { let mut batch: Vec = Vec::with_capacity(seq.size_hint().unwrap_or(10)); - // this was easier than expected while let Ok(Some(s)) = seq.next_element::() { batch.push(s); } @@ -107,6 +106,7 @@ impl<'de> Deserialize<'de> for JsonRpcRequestEnum { } } } + let id = id.ok_or_else(|| de::Error::missing_field("id"))?; let method = method.ok_or_else(|| de::Error::missing_field("method"))?; let params = params.ok_or_else(|| de::Error::missing_field("params"))?;