diff --git a/crates/preflight/src/provider/rpc_provider.rs b/crates/preflight/src/provider/rpc_provider.rs index f10cf295..9c91d694 100644 --- a/crates/preflight/src/provider/rpc_provider.rs +++ b/crates/preflight/src/provider/rpc_provider.rs @@ -15,20 +15,31 @@ use crate::provider::query::{AccountRangeQueryResponse, StorageRangeQueryResponse}; use crate::provider::*; use alloy::network::{BlockResponse, HeaderResponse, Network}; -use alloy::providers::{Provider as AlloyProvider, ReqwestProvider}; +use alloy::providers::{Provider as AlloyProvider, ProviderBuilder, RootProvider}; +use alloy::rpc::client::RpcClient; +use alloy::transports::{ + http::{Client, Http}, + layers::{RetryBackoffLayer, RetryBackoffService}, +}; use anyhow::anyhow; use log::{debug, error}; use std::future::IntoFuture; #[derive(Clone, Debug)] pub struct RpcProvider { - http_client: ReqwestProvider, + http_client: RootProvider>, N>, tokio_handle: tokio::runtime::Handle, } impl RpcProvider { pub fn new(rpc_url: String) -> anyhow::Result { - let http_client = ReqwestProvider::new_http(rpc_url.parse()?); + let retry_layer = RetryBackoffLayer::new(10, 100, 330); + + let client = RpcClient::builder() + .layer(retry_layer) + .http(rpc_url.parse()?); + let http_client = ProviderBuilder::new().network().on_client(client); + let tokio_handle = tokio::runtime::Handle::current(); Ok(RpcProvider {