diff --git a/CHANGELOG.md b/CHANGELOG.md index 97e7a3736..4ebb300f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Next release +- fix(l1): removed free l1 endpoint list - fix(metrics): removed influx and added l2_state_size data - fix: command to start the Madara client - refactor: database error unification diff --git a/crates/client/sync/src/utils/constant.rs b/crates/client/sync/src/utils/constant.rs index 351e163eb..d5f2c2fe8 100644 --- a/crates/client/sync/src/utils/constant.rs +++ b/crates/client/sync/src/utils/constant.rs @@ -9,59 +9,3 @@ pub mod starknet_core_address { } pub const LOG_STATE_UPDTATE_TOPIC: &str = "0xd342ddf7a308dec111745b00315c14b7efb2bdae570a6856e088ed0c65a3576c"; - -// This a list of free RPC URLs for Ethereum mainnet. -// -// It is used whenever no --l1-endpoint is provided. -// It should be used only for testing purposes. -// -// The list comes from DefiLlama's chainlist repository: -// https://github.com/DefiLlama/chainlist -pub const L1_FREE_RPC_URLS: &[&str] = &[ - "https://endpoints.omniatech.io/v1/eth/mainnet/public", - "https://rpc.ankr.com/eth", - "https://go.getblock.io/aefd01aa907c4805ba3c00a9e5b48c6b", - "https://eth-mainnet.nodereal.io/v1/1659dfb40aa24bbb8153a677b98064d7", - "https://ethereum-rpc.publicnode.com", - "wss://ethereum-rpc.publicnode.com", - "https://1rpc.io/eth", - "https://rpc.builder0x69.io/", - "https://rpc.mevblocker.io", - "https://rpc.flashbots.net/", - "https://cloudflare-eth.com/", - "https://eth-mainnet.public.blastapi.io", - "https://api.securerpc.com/v1", - "https://openapi.bitstack.com/v1/wNFxbiJyQsSeLrX8RRCHi7NpRxrlErZk/DjShIqLishPCTB9HiMkPHXjUM9CNM9Na/ETH/mainnet", - "https://eth-pokt.nodies.app", - "https://eth-mainnet-public.unifra.io", - "https://ethereum.blockpi.network/v1/rpc/public", - "https://rpc.payload.de", - "https://api.zmok.io/mainnet/oaen6dy8ff6hju9k", - "https://eth-mainnet.g.alchemy.com/v2/demo", - "https://eth.api.onfinality.io/public", - "https://core.gashawk.io/rpc", - "https://mainnet.eth.cloud.ava.do/", - "https://ethereumnodelight.app.runonflux.io", - "https://eth-mainnet.rpcfast.com?api_key=xbhWBI1Wkguk8SNMu1bvvLurPGLXmgwYeC4S6g2H7WdwFigZSmPWVZRxrskEQwIf", - "https://main-light.eth.linkpool.io", - "https://rpc.eth.gateway.fm", - "https://rpc.chain49.com/ethereum?api_key=14d1a8b86d8a4b4797938332394203dc", - "https://eth.meowrpc.com", - "https://eth.drpc.org", - "https://api.zan.top/node/v1/eth/mainnet/public", - "https://eth-mainnet.diamondswap.org/rpc", - "https://rpc.notadegen.com/eth", - "https://eth.merkle.io", - "https://rpc.lokibuilder.xyz/wallet", - "https://services.tokenview.io/vipapi/nodeservice/eth?apikey=qVHq2o6jpaakcw3lRstl", - "https://eth.nodeconnect.org/", - "https://api.stateless.solutions/ethereum/v1/demo", - "https://rpc.polysplit.cloud/v1/chain/1", - "https://public.stackup.sh/api/v1/node/ethereum-mainnet", - "https://api.tatum.io/v3/blockchain/node/ethereum-mainnet", - "https://eth.nownodes.io", - "https://rpc.nodifi.ai/api/rpc/free", - "https://ethereum.rpc.subquery.network/public", - "https://rpc.graffiti.farm", - "https://rpc.public.curie.radiumblock.co/http/ethereum", -]; diff --git a/crates/client/sync/src/utils/utility.rs b/crates/client/sync/src/utils/utility.rs index 36631cbb5..de4c39a54 100644 --- a/crates/client/sync/src/utils/utility.rs +++ b/crates/client/sync/src/utils/utility.rs @@ -1,13 +1,9 @@ //! Utility functions for Deoxys. -use std::time::Instant; - -use super::constant::L1_FREE_RPC_URLS; use anyhow::{bail, Context}; use ethers::types::{I256, U256}; use rand::seq::SliceRandom; use rand::thread_rng; -use reqwest::Client; use serde_json::Value; use starknet_api::hash::StarkFelt; use starknet_types_core::felt::Felt; @@ -55,67 +51,6 @@ pub enum RpcError { NoSuitableUrl, } -struct RpcChecker { - client: Client, - urls: &'static [&'static str], - best_url: Option<&'static str>, - best_latency: u128, -} - -impl RpcChecker { - fn new(urls: &'static [&'static str]) -> Self { - RpcChecker { client: Client::new(), urls, best_url: None, best_latency: u128::MAX } - } - - async fn l1_free_rpc_check(&self, url: &str) -> Result { - let start = Instant::now(); - let response = self.client.get(url).send().await?; - if response.status().is_success() { - Ok(start.elapsed().as_millis()) - } else { - Ok(u128::MAX) - } - } - - async fn l1_free_rpc_best(&mut self) -> Result<&'static str, RpcError> { - log::warn!("Looking for the best available free Ethereum RPC endpoints online, as none has been provided."); - log::warn!("This should be for testing purposes only. We recommend providing your own L1 RPC endpoint using `--l1-endpoint `."); - for &url in self.urls.iter() { - match self.l1_free_rpc_check(url).await { - Ok(latency) if latency < self.best_latency => { - log::debug!("New best URL found: {} with latency {} ms", url, latency); - self.best_latency = latency; - self.best_url = Some(url); - } - Ok(latency) => { - log::debug!( - "URL {} has latency {} ms, which is not better than the current best {} ms", - url, - latency, - self.best_latency - ); - } - Err(e) => { - log::debug!("Failed to check latency for URL {}: {:?}", url, e); - } - } - } - - match self.best_url { - Some(best_url) => { - log::info!("🔗 Using best L1 free RPC url found: {}", best_url); - Ok(best_url) - } - None => Err(RpcError::NoSuitableUrl), - } - } -} - -pub async fn l1_free_rpc_get() -> Result<&'static str, RpcError> { - let mut rpc_checker = RpcChecker::new(L1_FREE_RPC_URLS); - rpc_checker.l1_free_rpc_best().await -} - pub fn trim_hash(hash: &Felt) -> String { let hash_str = format!("{:#x}", hash); let hash_len = hash_str.len(); diff --git a/crates/node/src/service/sync.rs b/crates/node/src/service/sync.rs index 8616de0dd..03a34fbb4 100644 --- a/crates/node/src/service/sync.rs +++ b/crates/node/src/service/sync.rs @@ -7,7 +7,6 @@ use dc_db::{DatabaseService, DeoxysBackend}; use dc_metrics::MetricsRegistry; use dc_sync::fetch::fetchers::FetchConfig; use dc_sync::metrics::block_metrics::BlockMetrics; -use dc_sync::utility::l1_free_rpc_get; use dc_telemetry::TelemetryHandle; use primitive_types::H160; use starknet_types_core::felt::Felt; @@ -47,8 +46,9 @@ impl SyncService { if let Some(l1_rpc_url) = &config.l1_endpoint { Some(l1_rpc_url.clone()) } else { - let l1_rpc_url = l1_free_rpc_get().await.expect("finding the best RPC URL"); - Some(Url::parse(l1_rpc_url).expect("parsing the RPC URL")) + return Err(anyhow::anyhow!( + "❗ No L1 endpoint provided. You must provide one in order to verify the synced state." + )); } } else { None