Przeglądaj źródła

Remove deprecated BanksClient methods and dependent ProgramTest methods (#1956)

* Remove deprecated Banks client/interface methods

* Remove dependent deprecated program-test methods
Tyera 1 rok temu
rodzic
commit
6e4e82eb2a

+ 1 - 42
banks-client/src/lib.rs

@@ -17,8 +17,7 @@ use {
         BanksTransactionResultWithSimulation,
     },
     solana_program::{
-        clock::Slot, fee_calculator::FeeCalculator, hash::Hash, program_pack::Pack, pubkey::Pubkey,
-        rent::Rent, sysvar::Sysvar,
+        clock::Slot, hash::Hash, program_pack::Pack, pubkey::Pubkey, rent::Rent, sysvar::Sysvar,
     },
     solana_sdk::{
         account::{from_account, Account},
@@ -69,21 +68,6 @@ impl BanksClient {
             .map_err(Into::into)
     }
 
-    #[deprecated(
-        since = "1.9.0",
-        note = "Please use `get_fee_for_message` or `is_blockhash_valid` instead"
-    )]
-    pub fn get_fees_with_commitment_and_context(
-        &mut self,
-        ctx: Context,
-        commitment: CommitmentLevel,
-    ) -> impl Future<Output = Result<(FeeCalculator, Hash, u64), BanksClientError>> + '_ {
-        #[allow(deprecated)]
-        self.inner
-            .get_fees_with_commitment_and_context(ctx, commitment)
-            .map_err(Into::into)
-    }
-
     pub fn get_transaction_status_with_context(
         &mut self,
         ctx: Context,
@@ -185,20 +169,6 @@ impl BanksClient {
         self.send_transaction_with_context(context::current(), transaction.into())
     }
 
-    /// Return the fee parameters associated with a recent, rooted blockhash. The cluster
-    /// will use the transaction's blockhash to look up these same fee parameters and
-    /// use them to calculate the transaction fee.
-    #[deprecated(
-        since = "1.9.0",
-        note = "Please use `get_fee_for_message` or `is_blockhash_valid` instead"
-    )]
-    pub fn get_fees(
-        &mut self,
-    ) -> impl Future<Output = Result<(FeeCalculator, Hash, u64), BanksClientError>> + '_ {
-        #[allow(deprecated)]
-        self.get_fees_with_commitment_and_context(context::current(), CommitmentLevel::default())
-    }
-
     /// Return the cluster Sysvar
     pub fn get_sysvar<T: Sysvar>(
         &mut self,
@@ -216,17 +186,6 @@ impl BanksClient {
         self.get_sysvar::<Rent>()
     }
 
-    /// Return a recent, rooted blockhash from the server. The cluster will only accept
-    /// transactions with a blockhash that has not yet expired. Use the `get_fees`
-    /// method to get both a blockhash and the blockhash's last valid slot.
-    #[deprecated(since = "1.9.0", note = "Please use `get_latest_blockhash` instead")]
-    pub fn get_recent_blockhash(
-        &mut self,
-    ) -> impl Future<Output = Result<Hash, BanksClientError>> + '_ {
-        #[allow(deprecated)]
-        self.get_fees().map(|result| Ok(result?.1))
-    }
-
     /// Send a transaction and return after the transaction has been rejected or
     /// reached the given level of commitment.
     pub fn process_transaction_with_commitment(

+ 0 - 8
banks-interface/src/lib.rs

@@ -6,7 +6,6 @@ use {
         account::Account,
         clock::Slot,
         commitment_config::CommitmentLevel,
-        fee_calculator::FeeCalculator,
         hash::Hash,
         inner_instruction::InnerInstructions,
         message::Message,
@@ -64,13 +63,6 @@ pub struct BanksTransactionResultWithMetadata {
 #[tarpc::service]
 pub trait Banks {
     async fn send_transaction_with_context(transaction: VersionedTransaction);
-    #[deprecated(
-        since = "1.9.0",
-        note = "Please use `get_fee_for_message_with_commitment_and_context` instead"
-    )]
-    async fn get_fees_with_commitment_and_context(
-        commitment: CommitmentLevel,
-    ) -> (FeeCalculator, Hash, Slot);
     async fn get_transaction_status_with_context(signature: Signature)
         -> Option<TransactionStatus>;
     async fn get_slot_with_context(commitment: CommitmentLevel) -> Slot;

+ 0 - 19
banks-server/src/banks_server.rs

@@ -18,7 +18,6 @@ use {
         clock::Slot,
         commitment_config::CommitmentLevel,
         feature_set::FeatureSet,
-        fee_calculator::FeeCalculator,
         hash::Hash,
         message::{Message, SanitizedMessage},
         pubkey::Pubkey,
@@ -232,24 +231,6 @@ impl Banks for BanksServer {
         self.transaction_sender.send(info).unwrap();
     }
 
-    async fn get_fees_with_commitment_and_context(
-        self,
-        _: Context,
-        commitment: CommitmentLevel,
-    ) -> (FeeCalculator, Hash, u64) {
-        let bank = self.bank(commitment);
-        let blockhash = bank.last_blockhash();
-        let lamports_per_signature = bank.get_lamports_per_signature();
-        let last_valid_block_height = bank
-            .get_blockhash_last_valid_block_height(&blockhash)
-            .unwrap();
-        (
-            FeeCalculator::new(lamports_per_signature),
-            blockhash,
-            last_valid_block_height,
-        )
-    }
-
     async fn get_transaction_status_with_context(
         self,
         _: Context,

+ 1 - 36
program-test/src/lib.rs

@@ -34,7 +34,7 @@ use {
         clock::{Epoch, Slot},
         entrypoint::{deserialize, ProgramResult, SUCCESS},
         feature_set::FEATURE_NAMES,
-        fee_calculator::{FeeCalculator, FeeRateGovernor, DEFAULT_TARGET_LAMPORTS_PER_SIGNATURE},
+        fee_calculator::{FeeRateGovernor, DEFAULT_TARGET_LAMPORTS_PER_SIGNATURE},
         genesis_config::{ClusterType, GenesisConfig},
         hash::Hash,
         instruction::{Instruction, InstructionError},
@@ -973,47 +973,12 @@ impl ProgramTest {
 
 #[async_trait]
 pub trait ProgramTestBanksClientExt {
-    /// Get a new blockhash, similar in spirit to RpcClient::get_new_blockhash()
-    ///
-    /// This probably should eventually be moved into BanksClient proper in some form
-    #[deprecated(
-        since = "1.9.0",
-        note = "Please use `get_new_latest_blockhash `instead"
-    )]
-    async fn get_new_blockhash(&mut self, blockhash: &Hash) -> io::Result<(Hash, FeeCalculator)>;
     /// Get a new latest blockhash, similar in spirit to RpcClient::get_latest_blockhash()
     async fn get_new_latest_blockhash(&mut self, blockhash: &Hash) -> io::Result<Hash>;
 }
 
 #[async_trait]
 impl ProgramTestBanksClientExt for BanksClient {
-    async fn get_new_blockhash(&mut self, blockhash: &Hash) -> io::Result<(Hash, FeeCalculator)> {
-        let mut num_retries = 0;
-        let start = Instant::now();
-        while start.elapsed().as_secs() < 5 {
-            #[allow(deprecated)]
-            if let Ok((fee_calculator, new_blockhash, _slot)) = self.get_fees().await {
-                if new_blockhash != *blockhash {
-                    return Ok((new_blockhash, fee_calculator));
-                }
-            }
-            debug!("Got same blockhash ({:?}), will retry...", blockhash);
-
-            tokio::time::sleep(Duration::from_millis(200)).await;
-            num_retries += 1;
-        }
-
-        Err(io::Error::new(
-            io::ErrorKind::Other,
-            format!(
-                "Unable to get new blockhash after {}ms (retried {} times), stuck at {}",
-                start.elapsed().as_millis(),
-                num_retries,
-                blockhash
-            ),
-        ))
-    }
-
     async fn get_new_latest_blockhash(&mut self, blockhash: &Hash) -> io::Result<Hash> {
         let mut num_retries = 0;
         let start = Instant::now();