Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0: Remove deprecated SyncClient methods (backport of #1902) #1909

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 0 additions & 18 deletions client/src/thin_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -213,20 +211,6 @@ impl SyncClient for ThinClient {

dispatch!(fn get_minimum_balance_for_rent_exemption(&self, data_len: usize) -> TransportResult<u64>);

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<Option<FeeCalculator>>);

dispatch!(#[allow(deprecated)] fn get_fee_rate_governor(&self) -> TransportResult<FeeRateGovernor>);

dispatch!(fn get_signature_status(
&self,
signature: &Signature
Expand Down Expand Up @@ -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<Hash>);

dispatch!(fn get_latest_blockhash_with_commitment(
Expand Down
52 changes: 0 additions & 52 deletions runtime/src/bank_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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<Option<FeeCalculator>> {
Ok(self
.bank
.get_lamports_per_signature_for_blockhash(blockhash)
.map(FeeCalculator::new))
}

fn get_fee_rate_governor(&self) -> Result<FeeRateGovernor> {
#[allow(deprecated)]
Ok(self.bank.get_fee_rate_governor().clone())
}

fn get_signature_status(
&self,
signature: &Signature,
Expand Down Expand Up @@ -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<EpochInfo> {
Ok(self.bank.get_epoch_info())
}
Expand Down
36 changes: 0 additions & 36 deletions sdk/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use crate::{
clock::Slot,
commitment_config::CommitmentConfig,
epoch_info::EpochInfo,
fee_calculator::{FeeCalculator, FeeRateGovernor},
hash::Hash,
instruction::Instruction,
message::Message,
Expand Down Expand Up @@ -82,35 +81,6 @@ pub trait SyncClient {

fn get_minimum_balance_for_rent_exemption(&self, data_len: usize) -> Result<u64>;

/// 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<Option<FeeCalculator>>;

/// 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<FeeRateGovernor>;

/// Get signature status.
fn get_signature_status(
&self,
Expand Down Expand Up @@ -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<Hash>;

Expand Down
58 changes: 2 additions & 56 deletions thin-client/src/thin_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<Option<FeeCalculator>> {
#[allow(deprecated)]
self.rpc_client()
.get_fee_calculator_for_blockhash(blockhash)
.map_err(|e| e.into())
}

fn get_fee_rate_governor(&self) -> TransportResult<FeeRateGovernor> {
#[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,
Expand Down Expand Up @@ -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<Hash> {
let (blockhash, _) =
self.get_latest_blockhash_with_commitment(CommitmentConfig::default())?;
Expand Down