From 71c4a9d79657f361c9ca6887b105b76656a518bb Mon Sep 17 00:00:00 2001 From: "Tyler.S" Date: Mon, 4 Dec 2023 15:37:37 -0800 Subject: [PATCH 1/2] Only warn/error on RC SDK version if pubnet --- .../src/commands/contract/install.rs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/cmd/soroban-cli/src/commands/contract/install.rs b/cmd/soroban-cli/src/commands/contract/install.rs index ea5719140..20b478f0f 100644 --- a/cmd/soroban-cli/src/commands/contract/install.rs +++ b/cmd/soroban-cli/src/commands/contract/install.rs @@ -15,6 +15,7 @@ use crate::rpc::{self, Client}; use crate::{commands::config, utils, wasm}; const CONTRACT_META_SDK_KEY: &str = "rssdkver"; +const PUBLIC_NETWORK_PASSPHRASE: &str = "Public Global Stellar Network ; September 2015"; #[derive(Parser, Debug, Clone)] #[group(skip)] @@ -70,29 +71,30 @@ impl Cmd { } pub async fn run_and_get_hash(&self) -> Result { + self.run_against_rpc_server(&self.wasm.read()?).await + } + + async fn run_against_rpc_server(&self, contract: &[u8]) -> Result { + let network = self.config.get_network()?; + let client = Client::new(&network.rpc_url)?; + client + .verify_network_passphrase(Some(&network.network_passphrase)) + .await?; let wasm_spec = &self.wasm.parse().map_err(|e| Error::CannotParseWasm { wasm: self.wasm.wasm.clone(), error: e, })?; + // Check Rust SDK version if using the public network. if let Some(rs_sdk_ver) = get_contract_meta_sdk_version(wasm_spec) { - if rs_sdk_ver.contains("rc") && !self.ignore_checks { + if rs_sdk_ver.contains("rc") && !self.ignore_checks && network.network_passphrase == PUBLIC_NETWORK_PASSPHRASE { return Err(Error::ContractCompiledWithReleaseCandidateSdk { wasm: self.wasm.wasm.clone(), version: rs_sdk_ver, }); - } else if rs_sdk_ver.contains("rc") { + } else if rs_sdk_ver.contains("rc") && network.network_passphrase == PUBLIC_NETWORK_PASSPHRASE{ tracing::warn!("the deployed smart contract {path} was built with Soroban Rust SDK v{rs_sdk_ver}, a release candidate version not intended for use with the Stellar Public Network", path = self.wasm.wasm.display()); } } - self.run_against_rpc_server(&self.wasm.read()?).await - } - - async fn run_against_rpc_server(&self, contract: &[u8]) -> Result { - let network = self.config.get_network()?; - let client = Client::new(&network.rpc_url)?; - client - .verify_network_passphrase(Some(&network.network_passphrase)) - .await?; let key = self.config.key_pair()?; // Get the account sequence number From c53e5a1b3560f6472341c6464854104edb31b168 Mon Sep 17 00:00:00 2001 From: "Tyler.S" Date: Mon, 4 Dec 2023 15:42:26 -0800 Subject: [PATCH 2/2] Cargo fmt --- cmd/soroban-cli/src/commands/contract/install.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/soroban-cli/src/commands/contract/install.rs b/cmd/soroban-cli/src/commands/contract/install.rs index 20b478f0f..24e39c6e7 100644 --- a/cmd/soroban-cli/src/commands/contract/install.rs +++ b/cmd/soroban-cli/src/commands/contract/install.rs @@ -86,12 +86,17 @@ impl Cmd { })?; // Check Rust SDK version if using the public network. if let Some(rs_sdk_ver) = get_contract_meta_sdk_version(wasm_spec) { - if rs_sdk_ver.contains("rc") && !self.ignore_checks && network.network_passphrase == PUBLIC_NETWORK_PASSPHRASE { + if rs_sdk_ver.contains("rc") + && !self.ignore_checks + && network.network_passphrase == PUBLIC_NETWORK_PASSPHRASE + { return Err(Error::ContractCompiledWithReleaseCandidateSdk { wasm: self.wasm.wasm.clone(), version: rs_sdk_ver, }); - } else if rs_sdk_ver.contains("rc") && network.network_passphrase == PUBLIC_NETWORK_PASSPHRASE{ + } else if rs_sdk_ver.contains("rc") + && network.network_passphrase == PUBLIC_NETWORK_PASSPHRASE + { tracing::warn!("the deployed smart contract {path} was built with Soroban Rust SDK v{rs_sdk_ver}, a release candidate version not intended for use with the Stellar Public Network", path = self.wasm.wasm.display()); } }