From 0626a201070caa854bf707c3258b55e6cbce91bb Mon Sep 17 00:00:00 2001 From: Philippe Delrieu Date: Tue, 18 Jun 2024 16:04:31 +0200 Subject: [PATCH] update from origin branch because of a too important git divergence --- Cargo.lock | 127 ++++++----------- networks/suzuka/suzuka-client/Cargo.toml | 8 +- .../{basicalicebob.rs => basic_alice_bob.rs} | 20 +-- .../bin/{demoscenario.rs => demo_scenario.rs} | 13 +- .../src/load_soak_testing/mod.rs | 133 +++++++++--------- .../src/load_soak_testing/scenario.rs | 3 +- .../suzuka-full-node/process-compose.load.yml | 2 +- .../settlement/mcr/client/Cargo.toml | 25 ++-- 8 files changed, 144 insertions(+), 187 deletions(-) rename networks/suzuka/suzuka-client/bin/{basicalicebob.rs => basic_alice_bob.rs} (91%) rename networks/suzuka/suzuka-client/bin/{demoscenario.rs => demo_scenario.rs} (79%) diff --git a/Cargo.lock b/Cargo.lock index 0010ae1f0..8e8144ce7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,42 +116,32 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-consensus", "alloy-contract", "alloy-core", "alloy-eips", - "alloy-genesis", + "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f)", "alloy-provider", "alloy-pubsub", "alloy-rpc-client", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f)", "alloy-signer", "alloy-signer-wallet", "alloy-transport-http", "reqwest 0.12.4", ] -[[package]] -name = "alloy-chains" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03fd095a9d70f4b1c5c102c84a4c782867a5c6416dbf6dcd42a63e7c7a89d3c8" -dependencies = [ - "num_enum", - "strum 0.26.2", -] - [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f)", "c-kzg", "serde", ] @@ -159,7 +149,7 @@ dependencies = [ [[package]] name = "alloy-contract" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -207,24 +197,35 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f)", "c-kzg", "once_cell", "serde", "sha2 0.10.8", ] +[[package]] +name = "alloy-genesis" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" +dependencies = [ + "alloy-primitives", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f)", + "serde", + "serde_json", +] + [[package]] name = "alloy-genesis" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" dependencies = [ "alloy-primitives", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy.git)", "serde", "serde_json", ] @@ -244,7 +245,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-primitives", "serde", @@ -256,7 +257,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-consensus", "alloy-eips", @@ -266,7 +267,6 @@ dependencies = [ "alloy-signer", "alloy-sol-types", "async-trait", - "auto_impl", "futures-utils-wasm", "thiserror", ] @@ -276,7 +276,7 @@ name = "alloy-node-bindings" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" dependencies = [ - "alloy-genesis", + "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy.git)", "alloy-primitives", "k256", "serde_json", @@ -311,10 +311,8 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ - "alloy-chains", - "alloy-consensus", "alloy-eips", "alloy-json-rpc", "alloy-network", @@ -335,7 +333,6 @@ dependencies = [ "lru 0.12.3", "pin-project", "reqwest 0.12.4", - "serde", "serde_json", "tokio", "tracing", @@ -345,7 +342,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -385,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -408,14 +405,14 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-consensus", "alloy-eips", - "alloy-genesis", + "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f)", "alloy-primitives", "alloy-rlp", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f)", "alloy-sol-types", "itertools 0.12.1", "serde", @@ -426,11 +423,21 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-primitives", "alloy-rpc-types", - "alloy-serde", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f)", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-serde" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" +dependencies = [ + "alloy-primitives", "serde", "serde_json", ] @@ -448,7 +455,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-primitives", "async-trait", @@ -461,7 +468,7 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-consensus", "alloy-network", @@ -550,7 +557,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -568,7 +575,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -582,7 +589,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy.git#f6ebef272c5bd2783bae3fe7ef6ebc1dc3cee015" +source = "git+https://github.com/alloy-rs/alloy.git?rev=607359a8d7ba7543d702da5d406b7bc78eff3d9f#607359a8d7ba7543d702da5d406b7bc78eff3d9f" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -8240,26 +8247,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num_enum" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" -dependencies = [ - "proc-macro2 1.0.85", - "quote 1.0.36", - "syn 2.0.66", -] - [[package]] name = "num_threads" version = "0.1.7" @@ -10801,15 +10788,6 @@ dependencies = [ "strum_macros 0.25.3", ] -[[package]] -name = "strum" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" -dependencies = [ - "strum_macros 0.26.4", -] - [[package]] name = "strum_macros" version = "0.24.3" @@ -10836,19 +10814,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "strum_macros" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" -dependencies = [ - "heck 0.5.0", - "proc-macro2 1.0.85", - "quote 1.0.36", - "rustversion", - "syn 2.0.66", -] - [[package]] name = "subtle" version = "2.5.0" diff --git a/networks/suzuka/suzuka-client/Cargo.toml b/networks/suzuka/suzuka-client/Cargo.toml index ec6d67f3b..b5286793f 100644 --- a/networks/suzuka/suzuka-client/Cargo.toml +++ b/networks/suzuka/suzuka-client/Cargo.toml @@ -11,11 +11,11 @@ rust-version = { workspace = true } ### define here all scenarios execution binaries [[bin]] -name = "demoscenario" -path = "bin/demoscenario.rs" +name = "demo_scenario" +path = "bin/demo_scenario.rs" [[bin]] -name = "basicalicebob" -path = "bin/basicalicebob.rs" +name = "basic_alice_bob" +path = "bin/basic_alice_bob.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/networks/suzuka/suzuka-client/bin/basicalicebob.rs b/networks/suzuka/suzuka-client/bin/basic_alice_bob.rs similarity index 91% rename from networks/suzuka/suzuka-client/bin/basicalicebob.rs rename to networks/suzuka/suzuka-client/bin/basic_alice_bob.rs index bd63c803d..04952a89a 100644 --- a/networks/suzuka/suzuka-client/bin/basicalicebob.rs +++ b/networks/suzuka/suzuka-client/bin/basic_alice_bob.rs @@ -6,10 +6,7 @@ use aptos_sdk::{ }; use std::str::FromStr; use std::sync::Arc; -use suzuka_client::load_soak_testing::execute_test; -use suzuka_client::load_soak_testing::init_test; -use suzuka_client::load_soak_testing::ExecutionConfig; -use suzuka_client::load_soak_testing::Scenario; +use suzuka_client::load_soak_testing::{execute_test, init_test, ExecutionConfig, Scenario}; use url::Url; fn main() { @@ -41,36 +38,27 @@ impl BasicScenario { } } -// Scenario trait implementation. #[async_trait::async_trait] impl Scenario for BasicScenario { async fn run(self: Box) -> Result<()> { - // let _ = - // tokio::time::sleep(tokio::time::Duration::from_millis(1000 * (self.id as u64))).await; - let suzuka_config = maptos_execution_util::config::Config::try_from_env() .context("Failed to create the suzuka_config")?; let node_url = Url::from_str( format!("http://{}", suzuka_config.aptos_config.aptos_rest_listen_url.as_str()) .as_str(), - ) - .unwrap(); + )?; let faucet_url = Url::from_str( format!("http://{}", suzuka_config.aptos_config.aptos_faucet_listen_url.as_str()) .as_str(), - ) - .unwrap(); + )?; - // :!:>section_1a let rest_client = Client::new(node_url.clone()); let faucet_client = FaucetClient::new(faucet_url.clone(), node_url.clone()); // <:!:section_1a - // :!:>section_1b let coin_client = CoinClient::new(&rest_client); // <:!:section_1b // Create two accounts locally, Alice and Bob. - // :!:>section_2 let mut alice = LocalAccount::generate(&mut rand::rngs::OsRng); let bob = LocalAccount::generate(&mut rand::rngs::OsRng); // <:!:section_2 @@ -85,7 +73,6 @@ impl Scenario for BasicScenario { tracing::info!("{} Before alice fund", self.id); self.log_exec_info(&format!("{} Before alice fund", self.id)); // Create the accounts on chain, but only fund Alice. - // :!:>section_3 faucet_client.fund(alice.address(), 100_000_000).await?; tracing::info!("{} Before Bod create_account", self.id); self.log_exec_info(&format!("{} Before Bod create_account", self.id)); @@ -158,7 +145,6 @@ impl Scenario for BasicScenario { ); // Have Alice send Bob some more coins. - // :!:>section_5 let txn_hash = coin_client .transfer(&mut alice, bob.address(), 1_000, None) .await diff --git a/networks/suzuka/suzuka-client/bin/demoscenario.rs b/networks/suzuka/suzuka-client/bin/demo_scenario.rs similarity index 79% rename from networks/suzuka/suzuka-client/bin/demoscenario.rs rename to networks/suzuka/suzuka-client/bin/demo_scenario.rs index f7d5862fc..665050838 100644 --- a/networks/suzuka/suzuka-client/bin/demoscenario.rs +++ b/networks/suzuka/suzuka-client/bin/demo_scenario.rs @@ -1,12 +1,10 @@ use anyhow::Result; use std::sync::Arc; /// A simple demo scenario that sleep a few milli second and log some messages. -/// To run it use: cargo run --release --bin demoscenario -use suzuka_client::load_soak_testing::execute_test; -use suzuka_client::load_soak_testing::init_test; -use suzuka_client::load_soak_testing::ExecutionConfig; -use suzuka_client::load_soak_testing::Scenario; -use suzuka_client::load_soak_testing::TestKind; +/// To run it use: cargo run --release --bin demo_scenario +use suzuka_client::load_soak_testing::{ + execute_test, init_test, ExecutionConfig, Scenario, TestKind, +}; fn main() { // Define the Test config. Use the default parameters. @@ -17,7 +15,7 @@ fn main() { min_scenarios: 6, max_scenarios: 10, duration: std::time::Duration::from_secs(20), - nb_clycle: 4, + number_cycle: 4, }; // Init the Test before execution @@ -45,7 +43,6 @@ impl ScenarioDemo { } } -// Scenario trait implementation. #[async_trait::async_trait] impl Scenario for ScenarioDemo { async fn run(self: Box) -> Result<()> { diff --git a/networks/suzuka/suzuka-client/src/load_soak_testing/mod.rs b/networks/suzuka/suzuka-client/src/load_soak_testing/mod.rs index b69986d87..1f42b236e 100644 --- a/networks/suzuka/suzuka-client/src/load_soak_testing/mod.rs +++ b/networks/suzuka/suzuka-client/src/load_soak_testing/mod.rs @@ -10,8 +10,8 @@ pub use scenario::Scenario; const EXEC_LOG_FILTER: &str = "exec"; -/// Initialize all test's components with the configuration. -/// Must be call before the test start: execute_test +/// Initialize all test components with the configuration. +/// Must be called before the tests start: execute_test pub fn init_test(config: &ExecutionConfig) -> Result<(), std::io::Error> { //do some verification on the config config.verify_config(); @@ -51,32 +51,32 @@ pub fn init_test(config: &ExecutionConfig) -> Result<(), std::io::Error> { Ok(()) } -/// Define how the test will be run: -/// * kind: Type of test to run -/// * logfile_path: the file where log WARN and ERROR are written -/// * execfile_path: File where execution data are written to be processed later. -/// * define the number of started scenario per client. nb_scenarios / nb_scenario_per_client define the number of client. +/// Defines how the test will be run: #[derive(Clone, Debug)] pub struct ExecutionConfig { + /// Type of test to run pub kind: TestKind, + /// The path to the file where log WARN and ERROR are written pub logfile: String, + /// The path to the file where execution data are written to be processed later. pub execfile: String, - pub nb_scenario_per_client: usize, + /// The number of started scenarios per client. number_scenarios / number_scenario_per_client defines the number of clients. + pub number_scenario_per_client: usize, } impl ExecutionConfig { fn verify_config(&self) { match self.kind { - TestKind::Load { nb_scenarios } => { + TestKind::Load { number_scenarios } => { assert!( - nb_scenarios >= self.nb_scenario_per_client, + number_scenarios >= self.number_scenario_per_client, "Number of running scenario less than the number if scenario per client." ); } TestKind::Soak { min_scenarios, max_scenarios, .. } => { assert!(max_scenarios >= min_scenarios, "max scenarios less than min scenarios"); assert!( - min_scenarios >= self.nb_scenario_per_client, + min_scenarios >= self.number_scenario_per_client, "Number of min running scenario less than the number if scenario per client." ); } @@ -86,70 +86,69 @@ impl ExecutionConfig { impl Default for ExecutionConfig { fn default() -> Self { - let nb_scenarios: usize = std::env::var("LOADTEST_NB_SCENARIO") - .unwrap_or("10".to_string()) - .parse() + let number_scenarios: usize = std::env::var("LOADTEST_NUMBER_SCENARIO") + .map_err(|err| err.to_string()) + .and_then(|val| val.parse().map_err(|err: std::num::ParseIntError| err.to_string())) .unwrap_or(10); - let nb_scenario_per_client: usize = std::env::var("LOADTEST_NB_SCENARIO_PER_CLIENT") - .unwrap_or("2".to_string()) - .parse() - .unwrap_or(2); + let number_scenario_per_client: usize = + std::env::var("LOADTEST_NUMBER_SCENARIO_PER_CLIENT") + .unwrap_or("2".to_string()) + .parse() + .unwrap_or(2); ExecutionConfig { - kind: TestKind::build_load_test(nb_scenarios), + kind: TestKind::build_load_test(number_scenarios), logfile: "log_file.txt".to_string(), execfile: "test_result.txt".to_string(), - nb_scenario_per_client, + number_scenario_per_client, } } } /// Define the type of test to run: -/// * Load: try to run all scenario (nb_scenarios) concurrently -/// * Soak: start min_scenarios at first then increase the number to max_scenarios then decrease and do nb_clycle during duration #[derive(Clone, Debug)] pub enum TestKind { - Load { - nb_scenarios: usize, - }, + /// Load: try to run all scenario (number_scenarios) concurrently + Load { number_scenarios: usize }, + /// Soak: start min_scenarios at first then increase the number to max_scenarios then decrease and do number_cycle during duration Soak { min_scenarios: usize, max_scenarios: usize, duration: std::time::Duration, - nb_clycle: u32, + number_cycle: u32, }, } impl TestKind { - pub fn build_load_test(nb_scenarios: usize) -> Self { - TestKind::Load { nb_scenarios } + pub fn build_load_test(number_scenarios: usize) -> Self { + TestKind::Load { number_scenarios } } pub fn build_soak_test( min_scenarios: usize, max_scenarios: usize, duration: std::time::Duration, - nb_clycle: u32, + number_cycle: u32, ) -> Self { - TestKind::Soak { min_scenarios, max_scenarios, duration, nb_clycle } + TestKind::Soak { min_scenarios, max_scenarios, duration, number_cycle } } } -/// Execute the test scenarios define in the specified configuration. -/// scenarios are executed by chunk. Chunk execution of scenario is done by a client. +/// Execute the test scenarios defined in the specified configuration. +/// scenarios are executed by chunk. Each chunk of execution is done by a client. /// All clients are executed in a different thread in parallel. -/// Clients execute scenario in a Tokio runtime concurrently. +/// Clients execute scenarios in a Tokio runtime concurrently. pub fn execute_test(config: ExecutionConfig, create_scenario: Arc) { tracing::info!("Start test scenario execution."); - let nb_scenarios = match config.kind { - TestKind::Load { nb_scenarios } => nb_scenarios, + let number_scenarios = match config.kind { + TestKind::Load { number_scenarios } => number_scenarios, TestKind::Soak { max_scenarios, .. } => max_scenarios, }; //build chunk of ids. Start at 1. 0 mean in result execution fail before scenario can execute. - let ids: Vec<_> = (1..=nb_scenarios).collect(); + let ids: Vec<_> = (1..=number_scenarios).collect(); let chunks: Vec<_> = ids .into_iter() - .chunks(config.nb_scenario_per_client) + .chunks(config.number_scenario_per_client) .into_iter() .map(|chunk| { (config.kind.clone(), chunk.into_iter().collect::>(), create_scenario.clone()) @@ -168,21 +167,25 @@ pub fn execute_test(config: ExecutionConfig, create_scenario: Arc 0).then_some(res)) .collect(); - - let average_exec_time = no_zero_exec_time - .iter() - .map(|res| res.average_execution_time_milli) - .sum::() - / no_zero_exec_time.len() as u128; - let metrics_average_exec_time = serde_json::to_string(&average_exec_time) - .unwrap_or("Metric execution result serialization error.".to_string()); - tracing::info!(target:EXEC_LOG_FILTER, metrics_average_exec_time); - tracing::info!("Scenarios execution average_exec_time:{metrics_average_exec_time}"); + if no_zero_exec_time.len() > 0 { + let average_exec_time = no_zero_exec_time + .iter() + .map(|res| res.average_execution_time_milli) + .sum::() + / no_zero_exec_time.len() as u128; + let metrics_average_exec_time = serde_json::to_string(&average_exec_time) + .unwrap_or("Metric execution result serialization error.".to_string()); + tracing::info!(target:EXEC_LOG_FILTER, metrics_average_exec_time); + tracing::info!("Scenarios execution average_exec_time:{metrics_average_exec_time}"); + } else { + tracing::info!(target:EXEC_LOG_FILTER, "No scenario has been executed"); + tracing::info!("Scenarios execution: No scenario has been executed"); + }; tracing::info!("End test scenario execution."); } -/// Run the specified scenarios concurrently using Tokio. +/// Runs the specified scenarios concurrently using Tokio. #[derive(Default)] struct TestClient { scenario_chunk: Vec, @@ -199,10 +202,13 @@ impl TestClient { create_scanario: Arc, ) -> ClientExecResult { // Start the Tokio runtime on the current thread - let rt = tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap(); + let rt = match tokio::runtime::Builder::new_current_thread().enable_all().build() { + Ok(rt) => rt, + Err(err) => panic!("Tokio RT runtime fail to start because of this error:{err}"), + }; let scenario_results = match kind { TestKind::Load { .. } => rt.block_on(self.load_runner(create_scanario.clone())), - TestKind::Soak { min_scenarios, max_scenarios, duration, nb_clycle } => { + TestKind::Soak { min_scenarios, max_scenarios, duration, number_cycle } => { // The scenario that run all the time and part time are divided using the client. // min_scenarios first ids are run permanently, the others client run part time. //ids start at 1. @@ -216,10 +222,10 @@ impl TestClient { // min_scenarios run all the time. // The others scenarios start after some time (start delta time) then run the same time: Part-time scenario duration // max_scenarios - min_scenarios scenarios run part-time depending on the number of cycle. - // Part-time scenario duration max: Duration / (nbcycle * 2) + // Part-time scenario duration max: Duration / (number_cycle * 2) // scenario start delta: (Part-time scenario duration max * scenario index / nb scenario) + (Duration * current cycle / nb cycle) - let nb_parttime_scenario: u32 = (max_scenarios - min_scenarios) as u32; - let parttime_scenario_duration = duration / (nb_clycle * 2); + let number_part_time_scenario: u32 = (max_scenarios - min_scenarios) as u32; + let parttime_scenario_duration = duration / (number_cycle * 2); vec![] } } @@ -247,16 +253,16 @@ impl TestClient { while let Some(res) = set.join_next().await { let elapse = start_time.elapsed().as_millis(); let metrics = match res { - Ok((id, Ok(()))) => ScenarioExecMetric::new_ok(id, elapse), + Ok((id, Ok(()))) => ScenarioExecMetric::new(id, elapse, ScenarioExecResult::Ok), Ok((id, Err(err))) => { let log = format!("Scenario:{id} execution failed because: {err}"); tracing::info!(target:EXEC_LOG_FILTER, log); tracing::warn!(log); - ScenarioExecMetric::new_err(id, elapse) + ScenarioExecMetric::new(id, elapse, ScenarioExecResult::Fail) } Err(err) => { tracing::warn!("Error during scenario spawning: {err}"); - ScenarioExecMetric::new_err(0, elapse) + ScenarioExecMetric::new(0, elapse, ScenarioExecResult::Fail) } }; let metrics_scenario = serde_json::to_string(&metrics) @@ -287,18 +293,18 @@ impl TestClient { let mut scenario_results = vec![]; while let Some(res) = set.join_next().await { let metrics = match res { - Ok((id, Ok(elapse))) => ScenarioExecMetric::new_ok(id, elapse), + Ok((id, Ok(elapse))) => ScenarioExecMetric::new(id, elapse, ScenarioExecResult::Ok), Ok((id, Err(err))) => { let log = format!("Scenario:{id} execution failed because: {err}"); tracing::info!(target:EXEC_LOG_FILTER, log); tracing::warn!(log); let elapse = initial_start_time.elapsed().as_millis(); - ScenarioExecMetric::new_err(id, elapse) + ScenarioExecMetric::new(id, elapse, ScenarioExecResult::Fail) } Err(err) => { tracing::warn!("Error during scenario spawning: {err}"); let elapse = initial_start_time.elapsed().as_millis(); - ScenarioExecMetric::new_err(0, elapse) + ScenarioExecMetric::new(0, elapse, ScenarioExecResult::Fail) } }; let metrics_scenario = serde_json::to_string(&metrics) @@ -314,7 +320,7 @@ async fn run_scenarion_in_loop( id: usize, create_scanario: Arc, duration: Duration, -) -> anyhow::Result { +) -> Result { let start_time = std::time::Instant::now(); let mut average_time = 0; loop { @@ -346,11 +352,8 @@ struct ScenarioExecMetric { } impl ScenarioExecMetric { - fn new_ok(scenario_id: usize, elapse_millli: u128) -> Self { - ScenarioExecMetric { scenario_id, elapse_millli, result: ScenarioExecResult::Ok } - } - fn new_err(scenario_id: usize, elapse_millli: u128) -> Self { - ScenarioExecMetric { scenario_id, elapse_millli, result: ScenarioExecResult::Fail } + fn new(scenario_id: usize, elapse_millli: u128, result: ScenarioExecResult) -> Self { + ScenarioExecMetric { scenario_id, elapse_millli, result } } fn is_ok(&self) -> bool { diff --git a/networks/suzuka/suzuka-client/src/load_soak_testing/scenario.rs b/networks/suzuka/suzuka-client/src/load_soak_testing/scenario.rs index 430eef4cf..6d061e803 100644 --- a/networks/suzuka/suzuka-client/src/load_soak_testing/scenario.rs +++ b/networks/suzuka/suzuka-client/src/load_soak_testing/scenario.rs @@ -1,5 +1,4 @@ use super::EXEC_LOG_FILTER; -use anyhow::Result; /// A scenario is any struct that implements the Scenario trait. /// To ease scenario execution and logs, an id (usize) is provided during creation. @@ -14,7 +13,7 @@ use anyhow::Result; /// Return the execution result. If the scenario fails, return an error. #[async_trait::async_trait] pub trait Scenario { - async fn run(self: Box) -> Result<()>; + async fn run(self: Box) -> Result<(), anyhow::Error>; fn log_exec_info(&self, msg: &str) { tracing::info!(target:EXEC_LOG_FILTER, msg); diff --git a/process-compose/suzuka-full-node/process-compose.load.yml b/process-compose/suzuka-full-node/process-compose.load.yml index 9fea0a0e5..618145dc0 100644 --- a/process-compose/suzuka-full-node/process-compose.load.yml +++ b/process-compose/suzuka-full-node/process-compose.load.yml @@ -6,7 +6,7 @@ processes: suzuka-client-loadtests: command: | - LOADTEST_NB_SCENARIO=1 LOADTEST_NB_SCENARIO_PER_CLIENT=1 cargo run -p suzuka-client --bin basicalicebob + LOADTEST_NUMBER_SCENARIO=1 LOADTEST_NUMBER_SCENARIO_PER_CLIENT=1 cargo run -p suzuka-client --bin basic_alice_bob depends_on: suzuka-full-node: condition: process_healthy diff --git a/protocol-units/settlement/mcr/client/Cargo.toml b/protocol-units/settlement/mcr/client/Cargo.toml index 070e7b8d0..9bf656b7a 100644 --- a/protocol-units/settlement/mcr/client/Cargo.toml +++ b/protocol-units/settlement/mcr/client/Cargo.toml @@ -13,17 +13,24 @@ rust-version = { workspace = true } [dependencies] #move to workspace when impl is done. -alloy = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy", features = ["pubsub", "signers", "signer-wallet", "signer-yubihsm"]} +alloy = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy", rev = "607359a8d7ba7543d702da5d406b7bc78eff3d9f", features = [ + "pubsub", + "signers", + "signer-wallet", + "signer-yubihsm", +] } alloy-primitives = { version = "0.7.2", default-features = false } -alloy_provider = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-provider", features = ["ws"]} +alloy_provider = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-provider", rev = "607359a8d7ba7543d702da5d406b7bc78eff3d9f", features = [ + "ws", +] } alloy-sol-types = { version = "0.7.2", features = ["json"] } -alloy_network = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-network"} -alloy_transport = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-transport"} -alloy_transport_http = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-transport-http"} -alloy_contract = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-contract"} -alloy_signer_wallet = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-signer-wallet"} -alloy_rpc_types = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-rpc-types"} -alloy_transport_ws = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-transport-ws"} +alloy_network = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-network", rev = "607359a8d7ba7543d702da5d406b7bc78eff3d9f" } +alloy_transport = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-transport", rev = "607359a8d7ba7543d702da5d406b7bc78eff3d9f" } +alloy_transport_http = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-transport-http", rev = "607359a8d7ba7543d702da5d406b7bc78eff3d9f" } +alloy_contract = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-contract", rev = "607359a8d7ba7543d702da5d406b7bc78eff3d9f" } +alloy_signer_wallet = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-signer-wallet", rev = "607359a8d7ba7543d702da5d406b7bc78eff3d9f" } +alloy_rpc_types = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-rpc-types", rev = "607359a8d7ba7543d702da5d406b7bc78eff3d9f" } +alloy_transport_ws = { git = "https://github.com/alloy-rs/alloy.git", package = "alloy-transport-ws", rev = "607359a8d7ba7543d702da5d406b7bc78eff3d9f" } thiserror = "1.0.60"