diff --git a/crates/node/src/provider_utils/provider.rs b/crates/node/src/provider_utils/provider.rs index 6061b4c..23e1c5e 100644 --- a/crates/node/src/provider_utils/provider.rs +++ b/crates/node/src/provider_utils/provider.rs @@ -10,7 +10,7 @@ use alloy::{ }; use anyhow::{Context, Result}; -use crate::provider_utils::{ConcurrencyLimiterLayer, FallbackGasFiller, ReceiptRetryLayer}; +use crate::provider_utils::{ConcurrencyLimiterLayer, FallbackGasFiller, RetryLayer}; pub type ConcreteProvider = FillProvider< JoinFill< @@ -46,7 +46,7 @@ where let client = ClientBuilder::default() .layer(GLOBAL_CONCURRENCY_LIMITER_LAYER.clone()) - .layer(ReceiptRetryLayer::default()) + .layer(RetryLayer::default()) .connect(rpc_url) .await .context("Failed to construct the RPC client")?; diff --git a/crates/node/src/provider_utils/receipt_retry_layer.rs b/crates/node/src/provider_utils/receipt_retry_layer.rs index 83b72a5..a751b87 100644 --- a/crates/node/src/provider_utils/receipt_retry_layer.rs +++ b/crates/node/src/provider_utils/receipt_retry_layer.rs @@ -20,8 +20,10 @@ use tower::{Layer, Service}; /// considers that a timeout. It attempts to poll for the receipt for the `polling_duration` with an /// interval of `polling_interval` between each poll. If by the end of the `polling_duration` it was /// not able to get the receipt successfully then this is considered to be a timeout. +/// +/// Additionally, this layer allows for retries for other rpc methods such as all tracing methods. #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct ReceiptRetryLayer { +pub struct RetryLayer { /// The amount of time to keep polling for the receipt before considering it a timeout. polling_duration: Duration, @@ -29,7 +31,7 @@ pub struct ReceiptRetryLayer { polling_interval: Duration, } -impl ReceiptRetryLayer { +impl RetryLayer { pub fn new(polling_duration: Duration, polling_interval: Duration) -> Self { Self { polling_duration, @@ -48,7 +50,7 @@ impl ReceiptRetryLayer { } } -impl Default for ReceiptRetryLayer { +impl Default for RetryLayer { fn default() -> Self { Self { polling_duration: Duration::from_secs(90), @@ -57,11 +59,11 @@ impl Default for ReceiptRetryLayer { } } -impl Layer for ReceiptRetryLayer { - type Service = ReceiptRetryService; +impl Layer for RetryLayer { + type Service = RetryService; fn layer(&self, inner: S) -> Self::Service { - ReceiptRetryService { + RetryService { service: inner, polling_duration: self.polling_duration, polling_interval: self.polling_interval, @@ -70,7 +72,7 @@ impl Layer for ReceiptRetryLayer { } #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct ReceiptRetryService { +pub struct RetryService { /// The internal service. service: S, @@ -81,7 +83,7 @@ pub struct ReceiptRetryService { polling_interval: Duration, } -impl Service for ReceiptRetryService +impl Service for RetryService where S: Service, Error = TransportError> + Send