From 39ce96f2f0a7b88872a38e5cae0f68106d1a86e0 Mon Sep 17 00:00:00 2001 From: Kevin Heavey Date: Tue, 24 Dec 2024 22:04:19 +0400 Subject: [PATCH] remove solana-sdk from tps-client (#4173) * remove solana-sdk from tps-client * sort deps --- Cargo.lock | 14 ++++++++++++- tps-client/Cargo.toml | 14 ++++++++++++- tps-client/src/bank_client.rs | 32 ++++++++++++++---------------- tps-client/src/lib.rs | 37 +++++++++++++++-------------------- tps-client/src/rpc_client.rs | 30 +++++++++++++--------------- tps-client/src/tpu_client.rs | 30 +++++++++++++--------------- tps-client/src/utils.rs | 4 +++- 7 files changed, 88 insertions(+), 73 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8ae3412894499d..9ee7494ccc3062 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9584,16 +9584,28 @@ version = "2.2.0" dependencies = [ "log", "serial_test", + "solana-account", "solana-client", + "solana-client-traits", + "solana-clock", + "solana-commitment-config", "solana-connection-cache", + "solana-epoch-info", + "solana-hash", + "solana-keypair", + "solana-message", + "solana-pubkey", "solana-quic-client", "solana-rpc-client", "solana-rpc-client-api", "solana-runtime", - "solana-sdk", + "solana-signature", + "solana-signer", "solana-streamer", "solana-test-validator", "solana-tpu-client", + "solana-transaction", + "solana-transaction-error", "solana-transaction-status", "tempfile", "thiserror 2.0.9", diff --git a/tps-client/Cargo.toml b/tps-client/Cargo.toml index c9bcf76325b5f7..1902b9f762dc73 100644 --- a/tps-client/Cargo.toml +++ b/tps-client/Cargo.toml @@ -10,15 +10,27 @@ edition = { workspace = true } [dependencies] log = { workspace = true } +solana-account = { workspace = true } solana-client = { workspace = true } +solana-client-traits = { workspace = true } +solana-clock = { workspace = true } +solana-commitment-config = { workspace = true } solana-connection-cache = { workspace = true } +solana-epoch-info = { workspace = true } +solana-hash = { workspace = true } +solana-keypair = { workspace = true } +solana-message = { workspace = true } +solana-pubkey = { workspace = true } solana-quic-client = { workspace = true } solana-rpc-client = { workspace = true } solana-rpc-client-api = { workspace = true } solana-runtime = { workspace = true } -solana-sdk = { workspace = true } +solana-signature = { workspace = true } +solana-signer = { workspace = true } solana-streamer = { workspace = true } solana-tpu-client = { workspace = true } +solana-transaction = { workspace = true } +solana-transaction-error = { workspace = true } solana-transaction-status = { workspace = true } thiserror = { workspace = true } diff --git a/tps-client/src/bank_client.rs b/tps-client/src/bank_client.rs index e6ae91e2db9202..95879cacb3750a 100644 --- a/tps-client/src/bank_client.rs +++ b/tps-client/src/bank_client.rs @@ -1,19 +1,17 @@ use { crate::{TpsClient, TpsClientError, TpsClientResult}, + solana_account::Account, + solana_client_traits::{AsyncClient, SyncClient}, + solana_commitment_config::CommitmentConfig, + solana_epoch_info::EpochInfo, + solana_hash::Hash, + solana_message::Message, + solana_pubkey::Pubkey, solana_rpc_client_api::config::RpcBlockConfig, solana_runtime::bank_client::BankClient, - solana_sdk::{ - account::Account, - client::{AsyncClient, SyncClient}, - commitment_config::CommitmentConfig, - epoch_info::EpochInfo, - hash::Hash, - message::Message, - pubkey::Pubkey, - signature::Signature, - slot_history::Slot, - transaction::{Result, Transaction}, - }, + solana_signature::Signature, + solana_transaction::Transaction, + solana_transaction_error::TransactionResult as Result, solana_transaction_status::UiConfirmedBlock, }; @@ -122,22 +120,22 @@ impl TpsClient for BankClient { fn get_slot_with_commitment( &self, commitment_config: CommitmentConfig, - ) -> TpsClientResult { + ) -> TpsClientResult { SyncClient::get_slot_with_commitment(self, commitment_config).map_err(|err| err.into()) } fn get_blocks_with_commitment( &self, - _start_slot: Slot, - _end_slot: Option, + _start_slot: u64, + _end_slot: Option, _commitment_config: CommitmentConfig, - ) -> TpsClientResult> { + ) -> TpsClientResult> { unimplemented!("BankClient doesn't support get_blocks"); } fn get_block_with_config( &self, - _slot: Slot, + _slot: u64, _rpc_block_config: RpcBlockConfig, ) -> TpsClientResult { unimplemented!("BankClient doesn't support get_block_with_config"); diff --git a/tps-client/src/lib.rs b/tps-client/src/lib.rs index 7e5e34bac546ef..180bfc49ef3f63 100644 --- a/tps-client/src/lib.rs +++ b/tps-client/src/lib.rs @@ -1,20 +1,17 @@ use { log::debug, + solana_account::Account, + solana_clock::DEFAULT_MS_PER_SLOT, + solana_commitment_config::CommitmentConfig, + solana_epoch_info::EpochInfo, + solana_hash::Hash, + solana_message::Message, + solana_pubkey::Pubkey, solana_rpc_client_api::{client_error::Error as ClientError, config::RpcBlockConfig}, - solana_sdk::{ - account::Account, - clock::DEFAULT_MS_PER_SLOT, - commitment_config::CommitmentConfig, - epoch_info::EpochInfo, - hash::Hash, - message::Message, - pubkey::Pubkey, - signature::Signature, - slot_history::Slot, - transaction::{Result, Transaction}, - transport::TransportError, - }, + solana_signature::Signature, solana_tpu_client::tpu_client::TpuSenderError, + solana_transaction::Transaction, + solana_transaction_error::{TransactionResult as Result, TransportError}, solana_transaction_status::UiConfirmedBlock, std::{ thread::sleep, @@ -126,21 +123,19 @@ pub trait TpsClient { fn get_multiple_accounts(&self, pubkeys: &[Pubkey]) -> TpsClientResult>>; - fn get_slot_with_commitment( - &self, - commitment_config: CommitmentConfig, - ) -> TpsClientResult; + fn get_slot_with_commitment(&self, commitment_config: CommitmentConfig) + -> TpsClientResult; fn get_blocks_with_commitment( &self, - start_slot: Slot, - end_slot: Option, + start_slot: u64, + end_slot: Option, commitment_config: CommitmentConfig, - ) -> TpsClientResult>; + ) -> TpsClientResult>; fn get_block_with_config( &self, - slot: Slot, + slot: u64, rpc_block_config: RpcBlockConfig, ) -> TpsClientResult; } diff --git a/tps-client/src/rpc_client.rs b/tps-client/src/rpc_client.rs index 0487b0837237bb..c5f3992a190c7c 100644 --- a/tps-client/src/rpc_client.rs +++ b/tps-client/src/rpc_client.rs @@ -1,19 +1,17 @@ use { crate::{TpsClient, TpsClientError, TpsClientResult}, + solana_account::Account, solana_client::rpc_config::RpcSendTransactionConfig, + solana_commitment_config::CommitmentConfig, + solana_epoch_info::EpochInfo, + solana_hash::Hash, + solana_message::Message, + solana_pubkey::Pubkey, solana_rpc_client::rpc_client::RpcClient, solana_rpc_client_api::config::RpcBlockConfig, - solana_sdk::{ - account::Account, - commitment_config::CommitmentConfig, - epoch_info::EpochInfo, - hash::Hash, - message::Message, - pubkey::Pubkey, - signature::Signature, - slot_history::Slot, - transaction::{Result, Transaction}, - }, + solana_signature::Signature, + solana_transaction::Transaction, + solana_transaction_error::TransactionResult as Result, solana_transaction_status::UiConfirmedBlock, }; @@ -134,23 +132,23 @@ impl TpsClient for RpcClient { fn get_slot_with_commitment( &self, commitment_config: CommitmentConfig, - ) -> TpsClientResult { + ) -> TpsClientResult { RpcClient::get_slot_with_commitment(self, commitment_config).map_err(|err| err.into()) } fn get_blocks_with_commitment( &self, - start_slot: Slot, - end_slot: Option, + start_slot: u64, + end_slot: Option, commitment_config: CommitmentConfig, - ) -> TpsClientResult> { + ) -> TpsClientResult> { RpcClient::get_blocks_with_commitment(self, start_slot, end_slot, commitment_config) .map_err(|err| err.into()) } fn get_block_with_config( &self, - slot: Slot, + slot: u64, rpc_block_config: RpcBlockConfig, ) -> TpsClientResult { RpcClient::get_block_with_config(self, slot, rpc_block_config).map_err(|err| err.into()) diff --git a/tps-client/src/tpu_client.rs b/tps-client/src/tpu_client.rs index dd34c0cd152672..296a17616965ec 100644 --- a/tps-client/src/tpu_client.rs +++ b/tps-client/src/tpu_client.rs @@ -1,21 +1,19 @@ use { crate::{TpsClient, TpsClientError, TpsClientResult}, + solana_account::Account, + solana_commitment_config::CommitmentConfig, solana_connection_cache::connection_cache::{ ConnectionManager, ConnectionPool, NewConnectionConfig, }, + solana_epoch_info::EpochInfo, + solana_hash::Hash, + solana_message::Message, + solana_pubkey::Pubkey, solana_rpc_client_api::config::RpcBlockConfig, - solana_sdk::{ - account::Account, - commitment_config::CommitmentConfig, - epoch_info::EpochInfo, - hash::Hash, - message::Message, - pubkey::Pubkey, - signature::Signature, - slot_history::Slot, - transaction::{Result, Transaction}, - }, + solana_signature::Signature, solana_tpu_client::tpu_client::TpuClient, + solana_transaction::Transaction, + solana_transaction_error::TransactionResult as Result, solana_transaction_status::UiConfirmedBlock, }; @@ -155,7 +153,7 @@ where fn get_slot_with_commitment( &self, commitment_config: CommitmentConfig, - ) -> TpsClientResult { + ) -> TpsClientResult { self.rpc_client() .get_slot_with_commitment(commitment_config) .map_err(|err| err.into()) @@ -163,10 +161,10 @@ where fn get_blocks_with_commitment( &self, - start_slot: Slot, - end_slot: Option, + start_slot: u64, + end_slot: Option, commitment_config: CommitmentConfig, - ) -> TpsClientResult> { + ) -> TpsClientResult> { self.rpc_client() .get_blocks_with_commitment(start_slot, end_slot, commitment_config) .map_err(|err| err.into()) @@ -174,7 +172,7 @@ where fn get_block_with_config( &self, - slot: Slot, + slot: u64, rpc_block_config: RpcBlockConfig, ) -> TpsClientResult { self.rpc_client() diff --git a/tps-client/src/utils.rs b/tps-client/src/utils.rs index 02cd622ab1fb8b..bf1d1326d0d571 100644 --- a/tps-client/src/utils.rs +++ b/tps-client/src/utils.rs @@ -1,8 +1,10 @@ use { log::{error, info}, solana_client::connection_cache::ConnectionCache as ClientConnectionCache, + solana_keypair::Keypair, + solana_pubkey::Pubkey, solana_rpc_client::rpc_client::RpcClient, - solana_sdk::{pubkey::Pubkey, signature::Signer, signer::keypair::Keypair}, + solana_signer::Signer, solana_streamer::streamer::StakedNodes, std::{ collections::HashMap,