From f62773c9efaa5635f55c7a5d44b73048b1dee1dd Mon Sep 17 00:00:00 2001 From: aniketfuryrocks Date: Wed, 14 Jun 2023 07:14:06 +0530 Subject: [PATCH] custom rpc --- Cargo.lock | 172 ++++++++++++++++-- Cargo.toml | 1 + src/bencher.rs | 27 +-- src/cli.rs | 8 +- src/main.rs | 3 +- src/openbook/simulate_place_orders.rs | 26 +-- src/rpc_client.rs | 114 ++++++++++++ src/solana_runtime/accounts_fetching.rs | 27 +-- src/solana_runtime/get_block.rs | 32 +--- src/solana_runtime/get_slot.rs | 32 ++-- .../send_and_get_status_memo.rs | 25 +-- 11 files changed, 335 insertions(+), 132 deletions(-) create mode 100644 src/rpc_client.rs diff --git a/Cargo.lock b/Cargo.lock index da64e06..c4687e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -318,9 +318,9 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-compression" -version = "0.3.15" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942c7cd7ae39e91bde4820d74132e9862e62c2f386c3aa90ccf55949f5bad63a" +checksum = "5b0122885821398cc923ece939e24d1056a2384ee719432397fa9db87230ff11" dependencies = [ "brotli", "flate2", @@ -1283,6 +1283,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.1.0" @@ -1626,15 +1641,28 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.23.2" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" +checksum = "0646026eb1b3eea4cd9ba47912ea5ce9cc07713d105b1a14698f4e6433d348b7" dependencies = [ "http", "hyper", - "rustls", + "rustls 0.21.1", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", ] [[package]] @@ -1991,6 +2019,24 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "nix" version = "0.25.1" @@ -2182,12 +2228,50 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "openssl" +version = "0.10.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69b3f656a17a6cbc115b5c7a40c616947d213ba182135b014d6051b73ab6f019" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2 1.0.56", + "quote 1.0.27", + "syn 2.0.15", +] + [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-sys" +version = "0.9.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2ce0f250f34a308dcfdbb351f511359857d4ed2134ba715a4eadd46e1ffd617" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "os_str_bytes" version = "6.5.0" @@ -2422,7 +2506,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls", + "rustls 0.20.8", "thiserror", "tokio", "tracing", @@ -2439,7 +2523,7 @@ dependencies = [ "rand 0.8.5", "ring", "rustc-hash", - "rustls", + "rustls 0.20.8", "rustls-native-certs", "slab", "thiserror", @@ -2630,9 +2714,9 @@ checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "reqwest" -version = "0.11.17" +version = "0.11.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13293b639a097af28fc8a90f22add145a9c954e49d77da06263d58cf44d5fb91" +checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" dependencies = [ "async-compression", "base64 0.21.0", @@ -2645,20 +2729,23 @@ dependencies = [ "http-body", "hyper", "hyper-rustls", + "hyper-tls", "ipnet", "js-sys", "log", "mime", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", - "rustls", + "rustls 0.21.1", "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "tokio", - "tokio-rustls", + "tokio-native-tls", + "tokio-rustls 0.24.1", "tokio-util", "tower-service", "url", @@ -2770,6 +2857,18 @@ dependencies = [ "webpki", ] +[[package]] +name = "rustls" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c911ba11bc8433e811ce56fde130ccf32f5127cab0e0194e9c68c5a5b671791e" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + [[package]] name = "rustls-native-certs" version = "0.6.2" @@ -2791,6 +2890,16 @@ dependencies = [ "base64 0.21.0", ] +[[package]] +name = "rustls-webpki" +version = "0.100.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.12" @@ -3476,7 +3585,7 @@ dependencies = [ "quinn", "quinn-proto", "quinn-udp", - "rustls", + "rustls 0.20.8", "solana-connection-cache", "solana-measure", "solana-metrics", @@ -3601,6 +3710,7 @@ dependencies = [ "pretty_env_logger", "rand 0.8.5", "rand_chacha 0.3.1", + "reqwest", "serde", "serde_json", "solana-client", @@ -3701,7 +3811,7 @@ dependencies = [ "quinn-udp", "rand 0.7.3", "rcgen", - "rustls", + "rustls 0.20.8", "solana-metrics", "solana-perf", "solana-sdk", @@ -4188,17 +4298,37 @@ dependencies = [ "syn 2.0.15", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ - "rustls", + "rustls 0.20.8", "tokio", "webpki", ] +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls 0.21.1", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.14" @@ -4218,9 +4348,9 @@ checksum = "f714dd15bead90401d77e04243611caec13726c2408afd5b31901dfcdcb3b181" dependencies = [ "futures-util", "log", - "rustls", + "rustls 0.20.8", "tokio", - "tokio-rustls", + "tokio-rustls 0.23.4", "tungstenite", "webpki", "webpki-roots", @@ -4350,7 +4480,7 @@ dependencies = [ "httparse", "log", "rand 0.8.5", - "rustls", + "rustls 0.20.8", "sha-1", "thiserror", "url", @@ -4474,6 +4604,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "vec_map" version = "0.8.2" diff --git a/Cargo.toml b/Cargo.toml index 7a8521a..0d60f0f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,3 +34,4 @@ spl-token = "3.5.0" solana-client = "1.15.2" itertools = "0.10.5" +reqwest = "0.11.18" diff --git a/src/bencher.rs b/src/bencher.rs index 7632b81..bd55f64 100644 --- a/src/bencher.rs +++ b/src/bencher.rs @@ -1,12 +1,12 @@ -use crate::cli::Args; +use crate::{cli::Args, rpc_client::CustomRpcClient}; use itertools::Itertools; -use rand::rngs::StdRng; -use rand::{Rng, SeedableRng}; +use rand::{rngs::StdRng, Rng, SeedableRng}; use serde::Serialize; use solana_program::hash::Hash; -use solana_rpc_client::nonblocking::rpc_client::RpcClient; -use std::sync::Arc; -use std::time::{Duration, Instant}; +use std::{ + sync::Arc, + time::{Duration, Instant}, +}; use tokio::sync::RwLock; pub type BlockHashGetter = Arc>; @@ -15,10 +15,10 @@ pub type BlockHashGetter = Arc>; pub trait Benchmark: Clone + Send + 'static { async fn run( self, - rpc_client: Arc, + rpc_client: &mut CustomRpcClient, duration: Duration, random_number: u64, - ) -> anyhow::Result; + ) -> anyhow::Result<()>; } #[derive(Default, Serialize)] @@ -54,19 +54,22 @@ impl Bencher { let start = Instant::now(); let mut random = StdRng::seed_from_u64(0); let futs = (0..args.threads).map(|_| { - let rpc_client = args.get_rpc_client(); + let mut rpc_client = args.get_rpc_client(); let duration = args.get_duration_to_run_test(); let random_number = random.gen(); let instance = instant.clone(); + tokio::spawn(async move { instance - .run(rpc_client.clone(), duration, random_number) + .run(&mut rpc_client, duration, random_number) .await - .unwrap() + .unwrap(); + + rpc_client.into() }) }); - let all_results = futures::future::try_join_all(futs).await?; + let all_results: Vec = futures::future::try_join_all(futs).await?; let time = start.elapsed(); diff --git a/src/cli.rs b/src/cli.rs index de93719..d96142f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -5,7 +5,7 @@ use futures::StreamExt; use solana_client::{ nonblocking::pubsub_client::PubsubClient, rpc_config::RpcTransactionLogsConfig, }; -use solana_rpc_client::nonblocking::rpc_client::RpcClient; + use solana_sdk::hash::Hash; use tokio::sync::RwLock; @@ -15,7 +15,7 @@ use crate::{ accounts_fetching::AccountsFetchingTests, get_block::GetBlockTest, get_slot::GetSlotTest, send_and_get_status_memo::SendAndConfrimTesting, }, - test_registry::TestRegistry, + test_registry::TestRegistry, rpc_client::CustomRpcClient, }; #[derive(Parser, Debug, Clone)] @@ -122,7 +122,7 @@ impl Args { } #[inline] - pub fn get_rpc_client(&self) -> Arc { - Arc::new(RpcClient::new(self.rpc_addr.clone())) + pub fn get_rpc_client(&self) -> CustomRpcClient { + CustomRpcClient::new(self.rpc_addr.clone()) } } diff --git a/src/main.rs b/src/main.rs index 50b3aac..1f73312 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,11 @@ -pub mod bencher; +mod bencher; mod cli; mod config; mod openbook; mod solana_runtime; mod test_registry; mod utils; +mod rpc_client; use std::{sync::Arc, time::Duration}; diff --git a/src/openbook/simulate_place_orders.rs b/src/openbook/simulate_place_orders.rs index 9246716..701f574 100644 --- a/src/openbook/simulate_place_orders.rs +++ b/src/openbook/simulate_place_orders.rs @@ -1,13 +1,13 @@ use crate::{ - bencher::{Bencher, Benchmark, Run, Stats}, + bencher::{Bencher, Benchmark, Stats}, config::{Market, User}, + rpc_client::CustomRpcClient, test_registry::TestingTask, utils::noop, }; use async_trait::async_trait; use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng}; use serde::{Deserialize, Serialize}; -use solana_rpc_client::nonblocking::rpc_client::RpcClient; use solana_sdk::{ compute_budget, hash::Hash, @@ -102,14 +102,13 @@ pub struct SimulateOpenbookV2PlaceOrderBench { impl Benchmark for SimulateOpenbookV2PlaceOrderBench { async fn run( self, - rpc_client: Arc, + rpc_client: &mut CustomRpcClient, duration: std::time::Duration, random_number: u64, - ) -> anyhow::Result { - let mut result = Run::default(); - + ) -> anyhow::Result<()> { let mut rng = StdRng::seed_from_u64(random_number); let start = Instant::now(); + while start.elapsed() < duration { let mut place_order_ix = self.place_order_cmd.clone(); let market = self.markets.choose(&mut rng).cloned().unwrap(); @@ -186,18 +185,9 @@ impl Benchmark for SimulateOpenbookV2PlaceOrderBench { recent_blockhash, ); - match rpc_client.simulate_transaction(&transaction).await { - Ok(_) => { - result.requests_completed += 1; - result.bytes_received += 0; - } - Err(e) => { - result.requests_failed += 1; - result.errors.push(format!("{:?}", e.kind())); - } - } - result.bytes_sent += 0; + rpc_client.raw_simulate_transaction(transaction).await; } - Ok(result) + + Ok(()) } } diff --git a/src/rpc_client.rs b/src/rpc_client.rs new file mode 100644 index 0000000..7ef9aae --- /dev/null +++ b/src/rpc_client.rs @@ -0,0 +1,114 @@ +use std::sync::atomic::{AtomicU64, Ordering}; + +use bytes::Bytes; +use serde_json::{json, Value}; +use solana_client::rpc_request::RpcRequest; +use solana_program::pubkey::Pubkey; +use solana_rpc_client::nonblocking::rpc_client::RpcClient; +use solana_rpc_client::rpc_client::SerializableTransaction; + +use crate::bencher::Run; + +#[derive(derive_more::Deref)] +pub struct CustomRpcClient { + client: reqwest::Client, + url: String, + id: AtomicU64, + metric: Run, + #[deref] + rpc_client: RpcClient, +} + +// Don't transfer id and bytes_sent +impl Clone for CustomRpcClient { + fn clone(&self) -> Self { + Self::new(self.url.clone()) + } +} + +impl From for Run { + fn from(val: CustomRpcClient) -> Self { + val.metric + } +} + +impl CustomRpcClient { + pub fn new(url: String) -> Self { + let client = reqwest::Client::new(); + Self { + client, + rpc_client: RpcClient::new(url.clone()), + url, + id: 1.into(), + metric: Run::default(), + } + } + + pub async fn raw_get_slot(&mut self) { + self.send(RpcRequest::GetSlot, Value::Null).await + } + + pub async fn raw_get_block(&mut self, slot: impl Into) { + self.send(RpcRequest::GetBlock, json! {[slot.into()]}).await + } + + pub async fn raw_get_multiple_accounts(&mut self, accounts: Vec) { + self.send( + RpcRequest::GetMultipleAccounts, + serde_json::to_value(accounts).unwrap(), + ) + .await + } + + pub async fn raw_send_transaction(&mut self, tx: impl SerializableTransaction) { + self.send(RpcRequest::SendTransaction, json! {[tx]}).await + } + + pub async fn raw_simulate_transaction(&mut self, tx: impl SerializableTransaction) { + self.send(RpcRequest::SimulateTransaction, json! {[tx]}) + .await + } + + pub async fn send(&mut self, request: RpcRequest, params: Value) { + let id = self.id.fetch_add(1, Ordering::Relaxed); + + let req_raw_body = request + .build_request_json(id, params) + .to_string() + .into_bytes(); + + let bytes_sent = req_raw_body.len(); + self.metric.bytes_sent += bytes_sent as u64; + + let err = match self.send_raw(req_raw_body).await { + Ok(res_bytes) => { + self.metric.bytes_received += 1; + + let res: Value = + serde_json::from_slice(&res_bytes).expect("Server invalid response json"); + + if res.get("result").is_some() { + self.metric.requests_completed += 1; + return; + } + + res["error"].to_string() + } + Err(err) => err.to_string(), + }; + + self.metric.errors.push(err); + self.metric.requests_failed += 1; + } + + pub async fn send_raw(&self, req_raw_body: Vec) -> anyhow::Result { + Ok(self + .client + .post(&self.url) + .body(req_raw_body) + .send() + .await? + .bytes() + .await?) + } +} diff --git a/src/solana_runtime/accounts_fetching.rs b/src/solana_runtime/accounts_fetching.rs index 77676aa..8f78469 100644 --- a/src/solana_runtime/accounts_fetching.rs +++ b/src/solana_runtime/accounts_fetching.rs @@ -1,14 +1,14 @@ use async_trait::async_trait; use const_env::from_env; use rand::{seq::IteratorRandom, SeedableRng}; -use solana_rpc_client::nonblocking::rpc_client::RpcClient; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}; -use std::{str::FromStr, sync::Arc}; +use std::str::FromStr; use tokio::time::Instant; use crate::{ - bencher::{Bencher, Benchmark, Run, Stats}, + bencher::{Bencher, Benchmark, Stats}, config::Config, + rpc_client::CustomRpcClient, test_registry::TestingTask, }; @@ -56,15 +56,15 @@ pub struct GetAccountsBench { impl Benchmark for GetAccountsBench { async fn run( self, - rpc_client: Arc, + rpc_client: &mut CustomRpcClient, duration: std::time::Duration, random_number: u64, - ) -> anyhow::Result { - let mut result = Run::default(); + ) -> anyhow::Result<()> { let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(random_number); let number_of_fetched_accounts = NB_OF_ACCOUNTS_FETCHED_PER_TASK.min(self.accounts_list.len()); let start = Instant::now(); + while start.elapsed() < duration { let accounts = self .accounts_list @@ -72,18 +72,9 @@ impl Benchmark for GetAccountsBench { .copied() .choose_multiple(&mut rng, number_of_fetched_accounts); - match rpc_client.get_multiple_accounts(accounts.as_slice()).await { - Ok(_) => { - result.requests_completed += 1; - result.bytes_received += 0; - } - Err(e) => { - result.requests_failed += 1; - result.errors.push(format!("{:?}", e.kind())); - } - } - result.bytes_sent += 0; + rpc_client.raw_get_multiple_accounts(accounts).await } - Ok(result) + + Ok(()) } } diff --git a/src/solana_runtime/get_block.rs b/src/solana_runtime/get_block.rs index ee5fc28..6ca18cf 100644 --- a/src/solana_runtime/get_block.rs +++ b/src/solana_runtime/get_block.rs @@ -1,16 +1,13 @@ -use std::{ - sync::Arc, - time::{Duration, Instant}, -}; +use std::time::{Duration, Instant}; use log::info; -use solana_rpc_client::nonblocking::rpc_client::RpcClient; use solana_sdk::slot_history::Slot; use crate::{ - bencher::{Bencher, Benchmark, Run, Stats}, + bencher::{Bencher, Benchmark, Stats}, cli::Args, config::Config, + rpc_client::CustomRpcClient, test_registry::TestingTask, }; @@ -19,7 +16,7 @@ pub struct GetBlockTest; #[async_trait::async_trait] impl TestingTask for GetBlockTest { async fn test(&self, args: Args, _: Config) -> anyhow::Result { - let slot = { args.get_rpc_client().get_slot().await.unwrap() }; + let slot = args.get_rpc_client().get_slot().await.unwrap(); let instant = GetBlockBench { slot }; let metric = Bencher::bench::(instant, args).await?; info!("{} {}", self.get_name(), serde_json::to_string(&metric)?); @@ -40,27 +37,16 @@ pub struct GetBlockBench { impl Benchmark for GetBlockBench { async fn run( self, - rpc_client: Arc, + rpc_client: &mut CustomRpcClient, duration: Duration, _: u64, - ) -> anyhow::Result { - let mut result = Run::default(); - + ) -> anyhow::Result<()> { let start = Instant::now(); + while start.elapsed() < duration { - match rpc_client.get_block(self.slot).await { - Ok(_) => { - result.requests_completed += 1; - result.bytes_received += 0; - } - Err(e) => { - result.requests_failed += 1; - result.errors.push(format!("{:?}", e.kind())); - } - } - result.bytes_sent += 0; + rpc_client.raw_get_block(self.slot).await; } - Ok(result) + Ok(()) } } diff --git a/src/solana_runtime/get_slot.rs b/src/solana_runtime/get_slot.rs index 9e6cdd9..40808d6 100644 --- a/src/solana_runtime/get_slot.rs +++ b/src/solana_runtime/get_slot.rs @@ -1,11 +1,14 @@ -use std::sync::Arc; use std::time::{Duration, Instant}; use log::info; -use solana_rpc_client::nonblocking::rpc_client::RpcClient; -use crate::bencher::{Bencher, Benchmark, Run, Stats}; -use crate::{cli::Args, config::Config, test_registry::TestingTask}; +use crate::{ + bencher::{Bencher, Benchmark, Stats}, + cli::Args, + config::Config, + rpc_client::CustomRpcClient, + test_registry::TestingTask, +}; #[derive(Clone)] pub struct GetSlotTest; @@ -28,27 +31,16 @@ impl TestingTask for GetSlotTest { impl Benchmark for GetSlotTest { async fn run( self, - rpc_client: Arc, + rpc_client: &mut CustomRpcClient, duration: Duration, _: u64, - ) -> anyhow::Result { - let mut result = Run::default(); - + ) -> anyhow::Result<()> { let start = Instant::now(); + while start.elapsed() < duration { - match rpc_client.get_slot().await { - Ok(_) => { - result.requests_completed += 1; - result.bytes_received += 0; - } - Err(e) => { - result.requests_failed += 1; - result.errors.push(format!("{:?}", e.kind())); - } - } - result.bytes_sent += 0; + rpc_client.raw_get_slot().await; } - Ok(result) + Ok(()) } } diff --git a/src/solana_runtime/send_and_get_status_memo.rs b/src/solana_runtime/send_and_get_status_memo.rs index b636d28..bc1612a 100644 --- a/src/solana_runtime/send_and_get_status_memo.rs +++ b/src/solana_runtime/send_and_get_status_memo.rs @@ -1,10 +1,10 @@ use crate::{ - bencher::{Bencher, Benchmark, Run, Stats}, + bencher::{Bencher, Benchmark, Stats}, + rpc_client::CustomRpcClient, test_registry::TestingTask, }; use async_trait::async_trait; use rand::{distributions::Alphanumeric, prelude::Distribution, seq::SliceRandom, SeedableRng}; -use solana_rpc_client::nonblocking::rpc_client::RpcClient; use solana_sdk::{ hash::Hash, instruction::Instruction, message::Message, pubkey::Pubkey, signature::Keypair, signer::Signer, transaction::Transaction, @@ -61,12 +61,10 @@ struct SendMemoTransactionsBench { impl Benchmark for SendMemoTransactionsBench { async fn run( self, - rpc_client: Arc, + rpc_client: &mut CustomRpcClient, duration: std::time::Duration, random_number: u64, - ) -> anyhow::Result { - let mut result = Run::default(); - + ) -> anyhow::Result<()> { let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(random_number); let start = Instant::now(); while start.elapsed() < duration { @@ -75,18 +73,9 @@ impl Benchmark for SendMemoTransactionsBench { let blockhash = { *self.block_hash.read().await }; let tx = create_memo_tx(&msg, payer, blockhash); - match rpc_client.send_transaction(&tx).await { - Ok(_) => { - result.requests_completed += 1; - result.bytes_received += 0; - } - Err(e) => { - result.requests_failed += 1; - result.errors.push(format!("{:?}", e.kind())); - } - } - result.bytes_sent += 0; + let _ = rpc_client.raw_send_transaction(tx).await; } - Ok(result) + + Ok(()) } }