Skip to content

Commit

Permalink
Create handle_transaction_for_testing to use transaction trait to mea…
Browse files Browse the repository at this point in the history
…sure signing performance
  • Loading branch information
Zhe Wu authored and Zhe Wu committed Oct 11, 2023
1 parent ca899f4 commit 1f6d845
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
10 changes: 10 additions & 0 deletions crates/sui-core/src/authority_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ impl ValidatorService {
.into_inner()
}

pub async fn handle_transaction_for_testing(
&self,
transaction: Transaction,
) -> HandleTransactionResponse {
self.transaction(tonic::Request::new(transaction))
.await
.unwrap()
.into_inner()
}

async fn handle_transaction(
self,
request: tonic::Request<Transaction>,
Expand Down
9 changes: 7 additions & 2 deletions crates/sui-single-node-benchmark/src/benchmark_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::sync::Arc;
use sui_types::base_types::{ObjectID, ObjectRef, SuiAddress, SUI_ADDRESS_LENGTH};
use sui_types::crypto::{get_account_key_pair, AccountKeyPair};
use sui_types::effects::TransactionEffects;
use sui_types::messages_grpc::HandleTransactionResponse;
use sui_types::object::Object;
use sui_types::transaction::{CertifiedTransaction, SignedTransaction, Transaction};
use tracing::info;
Expand Down Expand Up @@ -228,7 +229,10 @@ impl BenchmarkContext {
}
}

pub(crate) async fn validator_sign_transactions(&self, transactions: Vec<Transaction>) {
pub(crate) async fn validator_sign_transactions(
&self,
transactions: Vec<Transaction>,
) -> Vec<HandleTransactionResponse> {
info!(
"Started signing {} transactions. You can now attach a profiler",
transactions.len(),
Expand All @@ -240,6 +244,7 @@ impl BenchmarkContext {
tokio::spawn(async move { validator.sign_transaction(tx).await })
})
.collect();
let _results: Vec<_> = tasks.collect().await;
let results: Vec<_> = tasks.collect().await;
results.into_iter().map(|r| r.unwrap()).collect()
}
}
4 changes: 2 additions & 2 deletions crates/sui-single-node-benchmark/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ async fn benchmark_transaction_signing(ctx: &BenchmarkContext, transactions: Vec
ctx.validator_sign_transactions(transactions).await;
let elapsed = start_time.elapsed().as_millis() as f64 / 1000f64;
info!(
"Transaction signing finished in {}s, TPS={}",
"Transaction signing finished in {}s, TPS={}.",
elapsed,
tx_count as f64 / elapsed
tx_count as f64 / elapsed,
);
}
10 changes: 2 additions & 8 deletions crates/sui-single-node-benchmark/src/single_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,8 @@ impl SingleValidator {
}

pub async fn sign_transaction(&self, transaction: Transaction) -> HandleTransactionResponse {
let result = self
.get_validator()
.handle_transaction(
&self.epoch_store,
VerifiedTransaction::new_unchecked(transaction),
)
self.validator_service
.handle_transaction_for_testing(transaction)
.await
.unwrap();
result
}
}

0 comments on commit 1f6d845

Please sign in to comment.