-
Notifications
You must be signed in to change notification settings - Fork 11.4k
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 AuthorityAggregatorBuilder #5233
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ use prometheus::Registry; | |
use rand::seq::SliceRandom; | ||
use std::path::PathBuf; | ||
use std::sync::Arc; | ||
use std::time::Duration; | ||
use strum_macros::EnumString; | ||
use sui_benchmark::drivers::bench_driver::BenchDriver; | ||
use sui_benchmark::drivers::driver::Driver; | ||
|
@@ -21,17 +20,9 @@ use sui_benchmark::workloads::workload::get_latest; | |
use sui_benchmark::workloads::{ | ||
make_combination_workload, make_shared_counter_workload, make_transfer_object_workload, | ||
}; | ||
use sui_config::gateway::GatewayConfig; | ||
use sui_config::Config; | ||
use sui_config::PersistedConfig; | ||
use sui_core::authority_aggregator::AuthAggMetrics; | ||
use sui_core::authority_aggregator::{reconfig_from_genesis, AuthorityAggregator}; | ||
use sui_core::authority_client::make_authority_clients; | ||
use sui_core::authority_aggregator::{reconfig_from_genesis, AuthorityAggregatorBuilder}; | ||
use sui_core::authority_client::AuthorityAPI; | ||
use sui_core::authority_client::NetworkAuthorityClient; | ||
use sui_core::epoch::committee_store::CommitteeStore; | ||
use sui_core::safe_client::SafeClientMetrics; | ||
use sui_core::validator_info::make_committee; | ||
use sui_node::metrics; | ||
use sui_types::base_types::ObjectID; | ||
use sui_types::base_types::SuiAddress; | ||
|
@@ -42,7 +33,6 @@ use sui_types::messages::BatchInfoResponseItem; | |
use sui_types::messages::TransactionInfoRequest; | ||
use tracing::log::info; | ||
|
||
use sui_core::authority_client::NetworkAuthorityClientMetrics; | ||
use test_utils::authority::spawn_test_authorities; | ||
use test_utils::authority::test_and_configure_authority_configs; | ||
use test_utils::objects::generate_gas_objects_with_owner; | ||
|
@@ -69,15 +59,16 @@ struct Opts { | |
pub num_client_threads: u64, | ||
#[clap(long, default_value = "", global = true)] | ||
pub log_path: String, | ||
/// Path where gateway config is stored when running remote benchmark | ||
/// This is also the path where gateway config is stored during local | ||
/// benchmark | ||
#[clap(long, default_value = "/tmp/gateway.yaml", global = true)] | ||
pub gateway_config_path: String, | ||
/// [Required for remote benchmark] | ||
/// Path where genesis.blob is stored when running remote benchmark | ||
#[clap(long, default_value = "/tmp/genesis.blob", global = true)] | ||
pub genesis_blob_path: String, | ||
/// [Required for remote benchmark] | ||
/// Path where keypair for primary gas account is stored. The format of | ||
/// this file is same as what `sui keytool generate` outputs | ||
#[clap(long, default_value = "", global = true)] | ||
pub keystore_path: String, | ||
/// [Required for remote benchmark] | ||
/// Object id of the primary gas coin used for benchmark | ||
/// NOTE: THe remote network should have this coin in its genesis config | ||
/// with large enough gas i.e. u64::MAX | ||
|
@@ -87,7 +78,7 @@ struct Opts { | |
pub primary_gas_objects: u64, | ||
/// Whether to run local or remote benchmark | ||
/// NOTE: For running remote benchmark we must have the following | ||
/// gateway_config_path, keypair_path and primary_gas_id | ||
/// genesis_blob_path, keypair_path and primary_gas_id | ||
#[clap(long, parse(try_from_str), default_value = "true", global = true)] | ||
pub local: bool, | ||
/// Default workload is 100% transfer object | ||
|
@@ -253,12 +244,11 @@ async fn main() -> Result<()> { | |
config.log_file = Some(opts.log_path); | ||
} | ||
let _guard = config.with_env().init(); | ||
let registry: Registry = metrics::start_prometheus_server( | ||
let registry: Arc<Registry> = Arc::new(metrics::start_prometheus_server( | ||
format!("{}:{}", opts.client_metric_host, opts.client_metric_port) | ||
.parse() | ||
.unwrap(), | ||
); | ||
let network_authority_client_metrics = Arc::new(NetworkAuthorityClientMetrics::new(®istry)); | ||
)); | ||
let barrier = Arc::new(Barrier::new(2)); | ||
let cloned_barrier = barrier.clone(); | ||
let (primary_gas_id, owner, keypair, aggregator) = if opts.local { | ||
|
@@ -274,39 +264,19 @@ async fn main() -> Result<()> { | |
}); | ||
Arc::new(configs) | ||
}; | ||
let gateway_config = GatewayConfig { | ||
epoch: 0, | ||
validator_set: configs.validator_set().to_vec(), | ||
send_timeout: Duration::from_secs(4), | ||
recv_timeout: Duration::from_secs(4), | ||
buffer_size: 650000, | ||
db_folder_path: PathBuf::from("/tmp/client_db"), | ||
}; | ||
gateway_config.save(&opts.gateway_config_path)?; | ||
|
||
// bring up servers .. | ||
let (owner, keypair): (SuiAddress, AccountKeyPair) = test_account_keys().pop().unwrap(); | ||
let primary_gas = generate_gas_objects_with_owner(1, owner); | ||
let primary_gas_id = primary_gas.get(0).unwrap().id(); | ||
// Make the client runtime wait until we are done creating genesis objects | ||
let cloned_config = configs; | ||
let cloned_config = configs.clone(); | ||
let cloned_gas = primary_gas; | ||
let auth_clients = make_authority_clients( | ||
&gateway_config.validator_set, | ||
gateway_config.send_timeout, | ||
gateway_config.recv_timeout, | ||
Comment on lines
-295
to
-296
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^ |
||
network_authority_client_metrics.clone(), | ||
); | ||
|
||
let committee = make_committee(gateway_config.epoch, &gateway_config.validator_set)?; | ||
let committee_store = Arc::new(CommitteeStore::new_for_testing(&committee)); | ||
let aggregator = Arc::new(AuthorityAggregator::new( | ||
committee, | ||
committee_store, | ||
auth_clients.clone(), | ||
AuthAggMetrics::new(®istry), | ||
Arc::new(SafeClientMetrics::new(®istry)), | ||
network_authority_client_metrics.clone(), | ||
)); | ||
let (aggregator, auth_clients) = AuthorityAggregatorBuilder::from_network_config(&configs) | ||
.with_registry(registry.clone()) | ||
.build() | ||
.unwrap(); | ||
|
||
// spawn a thread to spin up sui nodes on the multi-threaded server runtime | ||
let _ = std::thread::spawn(move || { | ||
|
@@ -341,7 +311,12 @@ async fn main() -> Result<()> { | |
join_all(follower_handles).await; | ||
}); | ||
}); | ||
(primary_gas_id, owner, Arc::new(keypair), aggregator) | ||
( | ||
primary_gas_id, | ||
owner, | ||
Arc::new(keypair), | ||
Arc::new(aggregator), | ||
) | ||
} else { | ||
eprintln!("Configuring remote benchmark.."); | ||
std::thread::spawn(move || { | ||
|
@@ -352,33 +327,13 @@ async fn main() -> Result<()> { | |
cloned_barrier.wait().await; | ||
}); | ||
}); | ||
let config_path = Some(&opts.gateway_config_path) | ||
.filter(|s| !s.is_empty()) | ||
.map(PathBuf::from) | ||
.ok_or_else(|| { | ||
anyhow!(format!( | ||
"Failed to find gateway config at path: {}", | ||
opts.gateway_config_path | ||
)) | ||
})?; | ||
let config: GatewayConfig = PersistedConfig::read(&config_path)?; | ||
let committee = make_committee(config.epoch, &config.validator_set)?; | ||
let genesis = sui_config::node::Genesis::new_from_file(&opts.genesis_blob_path); | ||
let genesis = genesis.genesis()?; | ||
let (aggregator, _) = AuthorityAggregatorBuilder::from_genesis(genesis) | ||
.with_registry(registry.clone()) | ||
.build() | ||
.unwrap(); | ||
|
||
let authority_clients = make_authority_clients( | ||
&config.validator_set, | ||
config.send_timeout, | ||
config.recv_timeout, | ||
network_authority_client_metrics.clone(), | ||
); | ||
let committee_store = Arc::new(CommitteeStore::new_for_testing(&committee)); | ||
let aggregator = AuthorityAggregator::new( | ||
committee, | ||
committee_store, | ||
authority_clients, | ||
AuthAggMetrics::new(®istry), | ||
Arc::new(SafeClientMetrics::new(®istry)), | ||
network_authority_client_metrics.clone(), | ||
); | ||
let aggregator = Arc::new(reconfig_from_genesis(aggregator).await?); | ||
eprintln!( | ||
"Reconfiguration - Reconfiguration to epoch {} is done", | ||
|
@@ -426,6 +381,7 @@ async fn main() -> Result<()> { | |
let prev_benchmark_stats_path = opts.compare_with.clone(); | ||
let curr_benchmark_stats_path = opts.benchmark_stats_path.clone(); | ||
let arc_agg = aggregator.clone(); | ||
let registry_clone = registry.clone(); | ||
let handle = std::thread::spawn(move || { | ||
client_runtime.block_on(async move { | ||
match opts.run_spec { | ||
|
@@ -502,7 +458,7 @@ async fn main() -> Result<()> { | |
let show_progress = interval.is_unbounded(); | ||
let driver = BenchDriver::new(stat_collection_interval); | ||
driver | ||
.run(workloads, arc_agg, ®istry, show_progress, interval) | ||
.run(workloads, arc_agg, ®istry_clone, show_progress, interval) | ||
.await | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no clue for why this is causing more timeout errors, let's just try setting this to 30s.