diff --git a/sequencer/api/public-env-vars.toml b/sequencer/api/public-env-vars.toml index c58af6c35c..d3d9d1004d 100644 --- a/sequencer/api/public-env-vars.toml +++ b/sequencer/api/public-env-vars.toml @@ -68,10 +68,14 @@ variables = [ "ESPRESSO_SEQUENCER_HOTSHOT_EVENT_STREAMING_API_PORT", "ESPRESSO_SEQUENCER_IS_DA", "ESPRESSO_SEQUENCER_L1_BLOCKS_CACHE_SIZE", + "ESPRESSO_SEQUENCER_L1_CONSECUTIVE_FAILURE_TOLERANCE", "ESPRESSO_SEQUENCER_L1_EVENTS_CHANNEL_CAPACITY", "ESPRESSO_SEQUENCER_L1_EVENTS_MAX_BLOCK_RANGE", + "ESPRESSO_SEQUENCER_L1_FREQUENT_FAILURE_TOLERANCE", "ESPRESSO_SEQUENCER_L1_POLLING_INTERVAL", + "ESPRESSO_SEQUENCER_L1_RATE_LIMIT_DELAY", "ESPRESSO_SEQUENCER_L1_RETRY_DELAY", + "ESPRESSO_SEQUENCER_L1_SUBSCRIPTION_TIMEOUT", "ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS", "ESPRESSO_SEQUENCER_LIBP2P_BIND_ADDRESS", "ESPRESSO_SEQUENCER_MAX_CONNECTIONS", diff --git a/types/src/v0/impls/l1.rs b/types/src/v0/impls/l1.rs index 04caea2f9a..e3cc65b0c1 100644 --- a/types/src/v0/impls/l1.rs +++ b/types/src/v0/impls/l1.rs @@ -131,9 +131,9 @@ impl L1ClientMetrics { } impl L1Provider { - fn new(url: Url, failures: &dyn CounterFamily) -> Self { + fn new(index: usize, url: Url, failures: &dyn CounterFamily) -> Self { Self { - failures: failures.create(vec![url.to_string()]), + failures: failures.create(vec![index.to_string()]), inner: Http::new(url), } } @@ -157,7 +157,8 @@ impl MultiRpcClient { clients: Arc::new( clients .into_iter() - .map(|url| L1Provider::new(url, &*failures)) + .enumerate() + .map(|(i, url)| L1Provider::new(i, url, &*failures)) .collect(), ), status: Default::default(), @@ -226,12 +227,13 @@ impl JsonRpcClient for MultiRpcClient { status.client }; - let client = &self.clients[current % self.clients.len()]; + let provider = current % self.clients.len(); + let client = &self.clients[provider]; match client.request(method, ¶ms).await { Ok(res) => Ok(res), Err(err) => { let t = Instant::now(); - tracing::warn!(?t, method, ?params, "L1 client error: {err:#}"); + tracing::warn!(?t, method, ?params, provider, "L1 client error: {err:#}"); client.failures.add(1); // Keep track of failures, failing over to the next client if necessary. @@ -344,11 +346,12 @@ impl L1Client { Some(urls) => { // Use a new WebSockets host each time we retry in case there is a // problem with one of the hosts specifically. - let url = &urls[i % urls.len()]; + let provider = i % urls.len(); + let url = &urls[provider]; ws = match Provider::::connect(url.clone()).await { Ok(ws) => ws, Err(err) => { - tracing::warn!(%url, "failed to connect WebSockets provider: {err:#}"); + tracing::warn!(provider, "failed to connect WebSockets provider: {err:#}"); sleep(retry_delay).await; continue; }