From 0fbf1dfb4a19eff7e3519c0918d1f2e790771a3b Mon Sep 17 00:00:00 2001 From: Tyera Date: Thu, 27 Jun 2024 23:28:55 -0600 Subject: [PATCH] Remove deprecated SyncClient methods (#1902) * Remove deprecated methods from SyncClient trait * Add line to changelog (cherry picked from commit 3d3faf5dee7a4b730f2bdb63dd850e4258211712) --- CHANGELOG.md | 1 + client/src/thin_client.rs | 18 ----------- runtime/src/bank_client.rs | 52 ------------------------------ sdk/src/client.rs | 36 --------------------- thin-client/src/thin_client.rs | 58 ++-------------------------------- 5 files changed, 3 insertions(+), 162 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb5d17f29fe16c..b07b2485937e89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Release channels have their own copy of this changelog: * Breaking * SDK: Support for Borsh v0.9 removed, please use v1 or v0.10 (#1440) * SDK: `Copy` is no longer derived on `Rent` and `EpochSchedule`, please switch to using `clone()` (solana-labs#32767) + * SDK: deprecated SyncClient trait methods removed * RPC: obsolete and deprecated v1 endpoints are removed. These endpoints are: confirmTransaction, getSignatureStatus, getSignatureConfirmation, getTotalSupply, getConfirmedSignaturesForAddress, getConfirmedBlock, getConfirmedBlocks, getConfirmedBlocksWithLimit, diff --git a/client/src/thin_client.rs b/client/src/thin_client.rs index 61f24018e8c778..596c9a13a6dbd3 100644 --- a/client/src/thin_client.rs +++ b/client/src/thin_client.rs @@ -11,10 +11,8 @@ use { solana_sdk::{ account::Account, client::{AsyncClient, Client, SyncClient}, - clock::Slot, commitment_config::CommitmentConfig, epoch_info::EpochInfo, - fee_calculator::{FeeCalculator, FeeRateGovernor}, hash::Hash, instruction::Instruction, message::Message, @@ -213,20 +211,6 @@ impl SyncClient for ThinClient { dispatch!(fn get_minimum_balance_for_rent_exemption(&self, data_len: usize) -> TransportResult); - dispatch!(#[allow(deprecated)] fn get_recent_blockhash(&self) -> TransportResult<(Hash, FeeCalculator)>); - - dispatch!(#[allow(deprecated)] fn get_recent_blockhash_with_commitment( - &self, - commitment_config: CommitmentConfig - ) -> TransportResult<(Hash, FeeCalculator, Slot)>); - - dispatch!(#[allow(deprecated)] fn get_fee_calculator_for_blockhash( - &self, - blockhash: &Hash - ) -> TransportResult>); - - dispatch!(#[allow(deprecated)] fn get_fee_rate_governor(&self) -> TransportResult); - dispatch!(fn get_signature_status( &self, signature: &Signature @@ -262,8 +246,6 @@ impl SyncClient for ThinClient { dispatch!(fn poll_for_signature(&self, signature: &Signature) -> TransportResult<()>); - dispatch!(#[allow(deprecated)] fn get_new_blockhash(&self, blockhash: &Hash) -> TransportResult<(Hash, FeeCalculator)>); - dispatch!(fn get_latest_blockhash(&self) -> TransportResult); dispatch!(fn get_latest_blockhash_with_commitment( diff --git a/runtime/src/bank_client.rs b/runtime/src/bank_client.rs index 634cb0e28b09ab..e8c8f7774ec66e 100644 --- a/runtime/src/bank_client.rs +++ b/runtime/src/bank_client.rs @@ -6,7 +6,6 @@ use { client::{AsyncClient, Client, SyncClient}, commitment_config::CommitmentConfig, epoch_info::EpochInfo, - fee_calculator::{FeeCalculator, FeeRateGovernor}, hash::Hash, instruction::Instruction, message::{Message, SanitizedMessage}, @@ -120,42 +119,6 @@ impl SyncClient for BankClient { Ok(self.bank.get_minimum_balance_for_rent_exemption(data_len)) } - fn get_recent_blockhash(&self) -> Result<(Hash, FeeCalculator)> { - Ok(( - self.bank.last_blockhash(), - FeeCalculator::new(self.bank.get_lamports_per_signature()), - )) - } - - fn get_recent_blockhash_with_commitment( - &self, - _commitment_config: CommitmentConfig, - ) -> Result<(Hash, FeeCalculator, u64)> { - let blockhash = self.bank.last_blockhash(); - #[allow(deprecated)] - let last_valid_slot = self - .bank - .get_blockhash_last_valid_slot(&blockhash) - .expect("bank blockhash queue should contain blockhash"); - Ok(( - blockhash, - FeeCalculator::new(self.bank.get_lamports_per_signature()), - last_valid_slot, - )) - } - - fn get_fee_calculator_for_blockhash(&self, blockhash: &Hash) -> Result> { - Ok(self - .bank - .get_lamports_per_signature_for_blockhash(blockhash) - .map(FeeCalculator::new)) - } - - fn get_fee_rate_governor(&self) -> Result { - #[allow(deprecated)] - Ok(self.bank.get_fee_rate_governor().clone()) - } - fn get_signature_status( &self, signature: &Signature, @@ -241,21 +204,6 @@ impl SyncClient for BankClient { Ok(()) } - fn get_new_blockhash(&self, blockhash: &Hash) -> Result<(Hash, FeeCalculator)> { - let recent_blockhash = self.get_latest_blockhash()?; - if recent_blockhash != *blockhash { - Ok(( - recent_blockhash, - FeeCalculator::new(self.bank.get_lamports_per_signature()), - )) - } else { - Err(TransportError::IoError(io::Error::new( - io::ErrorKind::Other, - "Unable to get new blockhash", - ))) - } - } - fn get_epoch_info(&self) -> Result { Ok(self.bank.get_epoch_info()) } diff --git a/sdk/src/client.rs b/sdk/src/client.rs index f9e435c81d0b66..185b9aeeb0d40b 100644 --- a/sdk/src/client.rs +++ b/sdk/src/client.rs @@ -14,7 +14,6 @@ use crate::{ clock::Slot, commitment_config::CommitmentConfig, epoch_info::EpochInfo, - fee_calculator::{FeeCalculator, FeeRateGovernor}, hash::Hash, instruction::Instruction, message::Message, @@ -82,35 +81,6 @@ pub trait SyncClient { fn get_minimum_balance_for_rent_exemption(&self, data_len: usize) -> Result; - /// Get recent blockhash - #[deprecated(since = "1.9.0", note = "Please use `get_latest_blockhash` instead")] - fn get_recent_blockhash(&self) -> Result<(Hash, FeeCalculator)>; - - /// Get recent blockhash. Uses explicit commitment configuration. - #[deprecated( - since = "1.9.0", - note = "Please use `get_latest_blockhash_with_commitment` and `get_latest_blockhash_with_commitment` instead" - )] - fn get_recent_blockhash_with_commitment( - &self, - commitment_config: CommitmentConfig, - ) -> Result<(Hash, FeeCalculator, Slot)>; - - /// Get `Some(FeeCalculator)` associated with `blockhash` if it is still in - /// the BlockhashQueue`, otherwise `None` - #[deprecated( - since = "1.9.0", - note = "Please use `get_fee_for_message` or `is_blockhash_valid` instead" - )] - fn get_fee_calculator_for_blockhash(&self, blockhash: &Hash) -> Result>; - - /// Get recent fee rate governor - #[deprecated( - since = "1.9.0", - note = "Please do not use, will no longer be available in the future" - )] - fn get_fee_rate_governor(&self) -> Result; - /// Get signature status. fn get_signature_status( &self, @@ -151,12 +121,6 @@ pub trait SyncClient { /// Poll to confirm a transaction. fn poll_for_signature(&self, signature: &Signature) -> Result<()>; - #[deprecated( - since = "1.9.0", - note = "Please do not use, will no longer be available in the future" - )] - fn get_new_blockhash(&self, blockhash: &Hash) -> Result<(Hash, FeeCalculator)>; - /// Get last known blockhash fn get_latest_blockhash(&self) -> Result; diff --git a/thin-client/src/thin_client.rs b/thin-client/src/thin_client.rs index 9e226c254c7a20..065363e1a462c0 100644 --- a/thin-client/src/thin_client.rs +++ b/thin-client/src/thin_client.rs @@ -13,14 +13,13 @@ use { }, }, solana_rpc_client::rpc_client::RpcClient, - solana_rpc_client_api::{config::RpcProgramAccountsConfig, response::Response}, + solana_rpc_client_api::config::RpcProgramAccountsConfig, solana_sdk::{ account::Account, client::{AsyncClient, Client, SyncClient}, - clock::{Slot, MAX_PROCESSING_AGE}, + clock::MAX_PROCESSING_AGE, commitment_config::CommitmentConfig, epoch_info::EpochInfo, - fee_calculator::{FeeCalculator, FeeRateGovernor}, hash::Hash, instruction::Instruction, message::Message, @@ -419,52 +418,6 @@ where .map_err(|e| e.into()) } - fn get_recent_blockhash(&self) -> TransportResult<(Hash, FeeCalculator)> { - #[allow(deprecated)] - let (blockhash, fee_calculator, _last_valid_slot) = - self.get_recent_blockhash_with_commitment(CommitmentConfig::default())?; - Ok((blockhash, fee_calculator)) - } - - fn get_recent_blockhash_with_commitment( - &self, - commitment_config: CommitmentConfig, - ) -> TransportResult<(Hash, FeeCalculator, Slot)> { - let index = self.optimizer.experiment(); - let now = Instant::now(); - #[allow(deprecated)] - let recent_blockhash = - self.rpc_clients[index].get_recent_blockhash_with_commitment(commitment_config); - match recent_blockhash { - Ok(Response { value, .. }) => { - self.optimizer.report(index, duration_as_ms(&now.elapsed())); - Ok((value.0, value.1, value.2)) - } - Err(e) => { - self.optimizer.report(index, u64::MAX); - Err(e.into()) - } - } - } - - fn get_fee_calculator_for_blockhash( - &self, - blockhash: &Hash, - ) -> TransportResult> { - #[allow(deprecated)] - self.rpc_client() - .get_fee_calculator_for_blockhash(blockhash) - .map_err(|e| e.into()) - } - - fn get_fee_rate_governor(&self) -> TransportResult { - #[allow(deprecated)] - self.rpc_client() - .get_fee_rate_governor() - .map_err(|e| e.into()) - .map(|r| r.value) - } - fn get_signature_status( &self, signature: &Signature, @@ -575,13 +528,6 @@ where .map_err(|e| e.into()) } - fn get_new_blockhash(&self, blockhash: &Hash) -> TransportResult<(Hash, FeeCalculator)> { - #[allow(deprecated)] - self.rpc_client() - .get_new_blockhash(blockhash) - .map_err(|e| e.into()) - } - fn get_latest_blockhash(&self) -> TransportResult { let (blockhash, _) = self.get_latest_blockhash_with_commitment(CommitmentConfig::default())?;