From 3ef7b56bd086ce55111961b0a15c4dd27447b1ca Mon Sep 17 00:00:00 2001 From: Jonathan LEI Date: Tue, 16 Apr 2024 02:16:29 +0800 Subject: [PATCH] feat: remove goerli networks --- book/src/providers.md | 5 ++--- book/src/tutorials/starkli-101.md | 2 +- src/casm.rs | 8 +++---- src/network.rs | 14 ------------ src/provider.rs | 37 ++++--------------------------- 5 files changed, 10 insertions(+), 56 deletions(-) diff --git a/book/src/providers.md b/book/src/providers.md index cf3017b..a049d29 100644 --- a/book/src/providers.md +++ b/book/src/providers.md @@ -16,9 +16,9 @@ There are two ways to specify a JSON-RPC provider, either [directly](#using-an-r > ℹ️ **Note** > -> When no provider option is supplied, Starkli falls back to using the `goerli` network. If the network is not already defined, a [free RPC vendor](#free-rpc-vendors) is used. +> When no provider option is supplied, Starkli falls back to using the `sepolia` network. If the network is not already defined, a [free RPC vendor](#free-rpc-vendors) is used. > -> You're advised against relying on the fallback to use the `goerli` network, as the default network might change over time. Therefore, a warning is shown each time the fallback is used. +> You're advised against relying on the fallback to use the `sepolia` network, as the default network might change over time. Therefore, a warning is shown each time the fallback is used. ## Using an RPC URL directly @@ -88,7 +88,6 @@ Historically, the now-deprecated-and-removed sequencer gateway provider allowed The following 3 networks are eligible for free RPC vendors: - `mainnet` -- `goerli` - `sepolia` When using these networks, **and when the network is not already defined in the active profile**, a free vendor will be randomly chosen from below: diff --git a/book/src/tutorials/starkli-101.md b/book/src/tutorials/starkli-101.md index eb29b39..37a997a 100644 --- a/book/src/tutorials/starkli-101.md +++ b/book/src/tutorials/starkli-101.md @@ -9,7 +9,7 @@ In this tutorial, you will be guided from scratch to deploy contracts on the Sta > ℹ️ **Note** > -> To make it easier to get started, this tutorial skips the step of choosing a provider and uses the `goerli` network fallback with [free RPC vendor](../providers.md#free-rpc-vendors), but relying on the network fallback is discouraged in practice. +> To make it easier to get started, this tutorial skips the step of choosing a provider and uses the `sepolia` network fallback with [free RPC vendor](../providers.md#free-rpc-vendors), but relying on the network fallback is discouraged in practice. > > Make sure to visit the [providers](../providers.md) page to learn more once you finish the tutorial. diff --git a/src/casm.rs b/src/casm.rs index 6ec8c22..8ab6228 100644 --- a/src/casm.rs +++ b/src/casm.rs @@ -72,11 +72,9 @@ impl CasmArgs { match network { Some(network) => { let auto_version = match network { - Network::Goerli - | Network::Sepolia - | Network::GoerliIntegration - | Network::SepoliaIntegration - | Network::Mainnet => CompilerVersion::V2_6_2, + Network::Sepolia | Network::SepoliaIntegration | Network::Mainnet => { + CompilerVersion::V2_6_2 + } }; eprintln!( diff --git a/src/network.rs b/src/network.rs index 7315209..9c9a0af 100644 --- a/src/network.rs +++ b/src/network.rs @@ -10,9 +10,7 @@ use crate::provider::ExtendedProvider; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Network { Mainnet, - Goerli, Sepolia, - GoerliIntegration, SepoliaIntegration, } @@ -29,10 +27,7 @@ impl FromStr for Network { fn from_str(s: &str) -> Result { match s { "mainnet" | "alpha-mainnet" => Ok(Self::Mainnet), - "goerli" | "goerli1" | "goerli-1" | "alpha-goerli" | "alpha-goerli1" - | "alpha-goerli-1" => Ok(Self::Goerli), "sepolia" | "alpha-sepolia" | "sepolia-testnet" => Ok(Self::Sepolia), - "goerli-integration" | "integration" => Ok(Self::GoerliIntegration), "sepolia-integration" => Ok(Self::SepoliaIntegration), _ => Err(anyhow::anyhow!("unknown network: {}", s)), } @@ -43,9 +38,7 @@ impl Display for Network { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Mainnet => write!(f, "mainnet"), - Self::Goerli => write!(f, "goerli"), Self::Sepolia => write!(f, "sepolia"), - Self::GoerliIntegration => write!(f, "goerli-integration"), Self::SepoliaIntegration => write!(f, "sepolia-integration"), } } @@ -56,16 +49,9 @@ impl Display for Network { impl NetworkSource for ExtendedProvider { async fn get_network(&self) -> Result> { let chain_id = self.chain_id().await?; - let is_integration = self.is_integration(); Ok(if chain_id == starknet::core::chain_id::MAINNET { Some(Network::Mainnet) - } else if chain_id == starknet::core::chain_id::TESTNET { - if is_integration { - Some(Network::GoerliIntegration) - } else { - Some(Network::Goerli) - } } else if chain_id == short_string!("SN_SEPOLIA") { Some(Network::Sepolia) } else if chain_id == short_string!("SN_INTEGRATION_SEPOLIA") { diff --git a/src/provider.rs b/src/provider.rs index 467090f..73e2a0e 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -21,7 +21,6 @@ use crate::{ }; const CHAIN_ID_MAINNET: FieldElement = short_string!("SN_MAIN"); -const CHAIN_ID_GOERLI: FieldElement = short_string!("SN_GOERLI"); const CHAIN_ID_SEPOLIA: FieldElement = short_string!("SN_SEPOLIA"); #[derive(Debug, Clone, Parser)] @@ -36,16 +35,8 @@ pub struct ProviderArgs { network: Option, } -/// This type was created because integration network has the same chain ID as `goerli`. We would -/// otherwise has no way of telling them apart. We could generally just ignore this, but it would -/// actually cause issues when deciding what Sierra compiler version to use depending on network, so -/// we still need this. -/// -/// Now the type also internally stores the RPC version of the endpoint, which is useful for showing -/// warnings whens using methods that contain breaking changes between versions. pub struct ExtendedProvider { provider: AnyProvider, - is_integration: bool, rpc_version: OnceCell, } @@ -54,7 +45,6 @@ impl ProviderArgs { Ok(match (self.rpc, self.network) { (Some(rpc), None) => ExtendedProvider::new( AnyProvider::JsonRpcHttp(JsonRpcClient::new(HttpTransport::new(rpc))), - false, None, ), (Some(rpc), Some(_)) => { @@ -68,7 +58,6 @@ impl ProviderArgs { ExtendedProvider::new( AnyProvider::JsonRpcHttp(JsonRpcClient::new(HttpTransport::new(rpc))), - false, None, ) } @@ -77,12 +66,12 @@ impl ProviderArgs { eprintln!( "{}", "WARNING: you're using neither --rpc (STARKNET_RPC) nor --network \ - (STARKNET_NETWORK). The `goerli` network is used by default. See \ + (STARKNET_NETWORK). The `sepolia` network is used by default. See \ https://book.starkli.rs/providers for more details." .bright_magenta() ); - Self::resolve_network("goerli")? + Self::resolve_network("sepolia")? } }) } @@ -168,14 +157,6 @@ impl ProviderArgs { &builtin_network, )), }, - Network::Goerli => crate::profile::Network { - name: Some("Starknet Goerli Testnet".into()), - chain_id: CHAIN_ID_GOERLI, - is_integration: false, - provider: NetworkProvider::Free(choose_vendor( - &builtin_network, - )), - }, Network::Sepolia => crate::profile::Network { name: Some("Starknet Sepolia Testnet".into()), chain_id: CHAIN_ID_SEPOLIA, @@ -184,7 +165,7 @@ impl ProviderArgs { &builtin_network, )), }, - Network::GoerliIntegration | Network::SepoliaIntegration => { + Network::SepoliaIntegration => { anyhow::bail!( "network {} cannot be used without being configured", network @@ -221,8 +202,6 @@ impl ProviderArgs { FreeProviderVendor::Blast => { if matched_network.chain_id == CHAIN_ID_MAINNET { Some("https://starknet-mainnet.public.blastapi.io/rpc/v0_6") - } else if matched_network.chain_id == CHAIN_ID_GOERLI { - Some("https://starknet-testnet.public.blastapi.io/rpc/v0_6") } else if matched_network.chain_id == CHAIN_ID_SEPOLIA { Some("https://starknet-sepolia.public.blastapi.io/rpc/v0_6") } else { @@ -232,8 +211,6 @@ impl ProviderArgs { FreeProviderVendor::Nethermind => { if matched_network.chain_id == CHAIN_ID_MAINNET { Some("https://free-rpc.nethermind.io/mainnet-juno/rpc/v0_6") - } else if matched_network.chain_id == CHAIN_ID_GOERLI { - Some("https://free-rpc.nethermind.io/goerli-juno/rpc/v0_6") } else if matched_network.chain_id == CHAIN_ID_SEPOLIA { Some("https://free-rpc.nethermind.io/sepolia-juno/rpc/v0_6") } else { @@ -267,7 +244,6 @@ impl ProviderArgs { let provider = ExtendedProvider::new( AnyProvider::JsonRpcHttp(JsonRpcClient::new(HttpTransport::new(rpc_url))), - matched_network.is_integration, rpc_version, ); @@ -280,10 +256,9 @@ impl ProviderArgs { } impl ExtendedProvider { - pub fn new(provider: AnyProvider, is_integration: bool, rpc_version: Option) -> Self { + pub fn new(provider: AnyProvider, rpc_version: Option) -> Self { Self { provider, - is_integration, rpc_version: match rpc_version { Some(rpc_version) => OnceCell::from(rpc_version), None => OnceCell::new(), @@ -294,10 +269,6 @@ impl ExtendedProvider { pub fn is_rpc(&self) -> bool { matches!(self.provider, AnyProvider::JsonRpcHttp(_)) } - - pub fn is_integration(&self) -> bool { - self.is_integration - } } #[cfg_attr(not(target_arch = "wasm32"), async_trait)]