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

Add get_blocks and get_slot methods to bench-tps-client #94

Merged
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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bench-tps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ solana-sdk = { workspace = true }
solana-streamer = { workspace = true }
solana-thin-client = { workspace = true }
solana-tpu-client = { workspace = true }
solana-transaction-status = { workspace = true }
solana-version = { workspace = true }
spl-instruction-padding = { workspace = true }
thiserror = { workspace = true }
Expand Down
22 changes: 19 additions & 3 deletions bench-tps/src/bench_tps_client.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use {
solana_rpc_client_api::client_error::Error as ClientError,
solana_rpc_client_api::{client_error::Error as ClientError, config::RpcBlockConfig},
solana_sdk::{
account::Account, commitment_config::CommitmentConfig, epoch_info::EpochInfo, hash::Hash,
message::Message, pubkey::Pubkey, signature::Signature, transaction::Transaction,
transport::TransportError,
message::Message, pubkey::Pubkey, signature::Signature, slot_history::Slot,
transaction::Transaction, transport::TransportError,
},
solana_tpu_client::tpu_client::TpuSenderError,
solana_transaction_status::UiConfirmedBlock,
thiserror::Error,
};

Expand Down Expand Up @@ -93,6 +94,21 @@ pub trait BenchTpsClient {
) -> Result<Account>;

fn get_multiple_accounts(&self, pubkeys: &[Pubkey]) -> Result<Vec<Option<Account>>>;

fn get_slot_with_commitment(&self, commitment_config: CommitmentConfig) -> Result<Slot>;

fn get_blocks_with_commitment(
&self,
start_slot: Slot,
end_slot: Option<Slot>,
commitment_config: CommitmentConfig,
) -> Result<Vec<Slot>>;

fn get_block_with_config(
&self,
slot: Slot,
rpc_block_config: RpcBlockConfig,
) -> Result<UiConfirmedBlock>;
gregcusack marked this conversation as resolved.
Show resolved Hide resolved
}

mod bank_client;
Expand Down
24 changes: 24 additions & 0 deletions bench-tps/src/bench_tps_client/bank_client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use {
crate::bench_tps_client::{BenchTpsClient, BenchTpsError, Result},
solana_rpc_client_api::config::RpcBlockConfig,
solana_runtime::bank_client::BankClient,
solana_sdk::{
account::Account,
Expand All @@ -10,8 +11,10 @@ use {
message::Message,
pubkey::Pubkey,
signature::Signature,
slot_history::Slot,
transaction::Transaction,
},
solana_transaction_status::UiConfirmedBlock,
};

impl BenchTpsClient for BankClient {
Expand Down Expand Up @@ -111,4 +114,25 @@ impl BenchTpsClient for BankClient {
fn get_multiple_accounts(&self, _pubkeys: &[Pubkey]) -> Result<Vec<Option<Account>>> {
unimplemented!("BankClient doesn't support get_multiple_accounts");
}

fn get_slot_with_commitment(&self, commitment_config: CommitmentConfig) -> Result<Slot> {
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<Slot>,
_commitment_config: CommitmentConfig,
) -> Result<Vec<Slot>> {
unimplemented!("BankClient doesn't support get_blocks");
}

fn get_block_with_config(
&self,
_slot: Slot,
_rpc_block_config: RpcBlockConfig,
) -> Result<UiConfirmedBlock> {
unimplemented!("BankClient doesn't support get_block_with_config");
}
}
27 changes: 26 additions & 1 deletion bench-tps/src/bench_tps_client/rpc_client.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use {
crate::bench_tps_client::{BenchTpsClient, BenchTpsError, Result},
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, transaction::Transaction,
message::Message, pubkey::Pubkey, signature::Signature, slot_history::Slot,
transaction::Transaction,
},
solana_transaction_status::UiConfirmedBlock,
};

impl BenchTpsClient for RpcClient {
Expand Down Expand Up @@ -104,4 +107,26 @@ impl BenchTpsClient for RpcClient {
fn get_multiple_accounts(&self, pubkeys: &[Pubkey]) -> Result<Vec<Option<Account>>> {
RpcClient::get_multiple_accounts(self, pubkeys).map_err(|err| err.into())
}

fn get_slot_with_commitment(&self, commitment_config: CommitmentConfig) -> Result<Slot> {
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<Slot>,
commitment_config: CommitmentConfig,
) -> Result<Vec<Slot>> {
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,
rpc_block_config: RpcBlockConfig,
) -> Result<UiConfirmedBlock> {
RpcClient::get_block_with_config(self, slot, rpc_block_config).map_err(|err| err.into())
}
}
30 changes: 30 additions & 0 deletions bench-tps/src/bench_tps_client/thin_client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plan is still for ThinClient to be deprecated then deleted, right?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, been deprecated in PR: #35365. Fully removing it from other parts is WIP

crate::bench_tps_client::{BenchTpsClient, BenchTpsError, Result},
solana_client::thin_client::ThinClient,
solana_rpc_client_api::config::RpcBlockConfig,
solana_sdk::{
account::Account,
client::{AsyncClient, Client, SyncClient},
Expand All @@ -10,8 +11,10 @@ use {
message::Message,
pubkey::Pubkey,
signature::Signature,
slot_history::Slot,
transaction::Transaction,
},
solana_transaction_status::UiConfirmedBlock,
};

impl BenchTpsClient for ThinClient {
Expand Down Expand Up @@ -110,4 +113,31 @@ impl BenchTpsClient for ThinClient {
.get_multiple_accounts(pubkeys)
.map_err(|err| err.into())
}

fn get_slot_with_commitment(&self, commitment_config: CommitmentConfig) -> Result<Slot> {
self.rpc_client()
.get_slot_with_commitment(commitment_config)
.map_err(|err| err.into())
}

fn get_blocks_with_commitment(
&self,
start_slot: Slot,
end_slot: Option<Slot>,
commitment_config: CommitmentConfig,
) -> Result<Vec<Slot>> {
self.rpc_client()
.get_blocks_with_commitment(start_slot, end_slot, commitment_config)
.map_err(|err| err.into())
}

fn get_block_with_config(
&self,
slot: Slot,
rpc_block_config: RpcBlockConfig,
) -> Result<UiConfirmedBlock> {
self.rpc_client()
.get_block_with_config(slot, rpc_block_config)
.map_err(|err| err.into())
}
}
32 changes: 31 additions & 1 deletion bench-tps/src/bench_tps_client/tpu_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ use {
solana_connection_cache::connection_cache::{
ConnectionManager, ConnectionPool, NewConnectionConfig,
},
solana_rpc_client_api::config::RpcBlockConfig,
solana_sdk::{
account::Account, commitment_config::CommitmentConfig, epoch_info::EpochInfo, hash::Hash,
message::Message, pubkey::Pubkey, signature::Signature, transaction::Transaction,
message::Message, pubkey::Pubkey, signature::Signature, slot_history::Slot,
transaction::Transaction,
},
solana_transaction_status::UiConfirmedBlock,
};

impl<P, M, C> BenchTpsClient for TpuClient<P, M, C>
Expand Down Expand Up @@ -130,4 +133,31 @@ where
.get_multiple_accounts(pubkeys)
.map_err(|err| err.into())
}

fn get_slot_with_commitment(&self, commitment_config: CommitmentConfig) -> Result<Slot> {
self.rpc_client()
.get_slot_with_commitment(commitment_config)
.map_err(|err| err.into())
}

fn get_blocks_with_commitment(
&self,
start_slot: Slot,
end_slot: Option<Slot>,
commitment_config: CommitmentConfig,
) -> Result<Vec<Slot>> {
self.rpc_client()
.get_blocks_with_commitment(start_slot, end_slot, commitment_config)
.map_err(|err| err.into())
}

fn get_block_with_config(
&self,
slot: Slot,
rpc_block_config: RpcBlockConfig,
) -> Result<UiConfirmedBlock> {
self.rpc_client()
.get_block_with_config(slot, rpc_block_config)
.map_err(|err| err.into())
}
}
Loading