You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: alloy.rs
    path of file: ./repos/foundry/crates/common/src/provider
    
    the code of the file until where you have to start completion: //! Commonly used helpers to construct `Provider`s

use crate::{
    provider::runtime_transport::RuntimeTransportBuilder, ALCHEMY_FREE_TIER_CUPS, REQUEST_TIMEOUT,
};
use alloy_primitives::U256;
use alloy_providers::tmp::{Provider, TempProvider};
use alloy_rpc_client::ClientBuilder;
use ethers_middleware::gas_oracle::{GasCategory, GasOracle, Polygon};
use eyre::{Result, WrapErr};
use foundry_common::types::ToAlloy;
use foundry_config::NamedChain;
use reqwest::Url;
use std::{
    path::{Path, PathBuf},
    time::Duration,
};
use url::ParseError;

use super::{
    runtime_transport::RuntimeTransport,
    tower::{RetryBackoffLayer, RetryBackoffService},
};

/// Helper type alias for a retry provider
pub type RetryProvider = P
    
    pub fn new(url_str: &str) -> Self {
        // a copy is needed for the next lines to work
        let mut url_str = url_str;

        // invalid url: non-prefixed URL scheme is not allowed, so we prepend the default http
        // prefix
        let storage;
        if url_str.starts_with("localhost:") {
            storage = format!("http://{url_str}");
            url_str = storage.as_str();
        }

        let url = Url::parse(url_str)
            .or_else(|err| match err {
                ParseError::RelativeUrlWithoutBase => {
                    let path = Path::new(url_str);

                    if let Ok(path) = resolve_path(path) {
                        Url::parse(&format!("file://{}", path.display()))
                    } else {
                        Err(err)
                    }
                }
                _ => Err(err),
            })
            .wrap_err_with(|| format!("invalid provider URL: {url_str:?}"));

        Self {
            url,
            chain: NamedChain::Mainnet,
            max_retry: 8,
            timeout_retry: 8,
            initial_backoff: 800,
            timeout: REQUEST_TIMEOUT,
            // alchemy max cpus <https://docs.alchemy.com/reference/compute-units#what-are-cups-compute-units-per-second>
            compute_units_per_second: ALCHEMY_FREE_TIER_CUPS,
            jwt: None,
            headers: vec![],
        }
    }