From 9c6f4b7b492c32808a0a3633a3b1941ce9c82a9a Mon Sep 17 00:00:00 2001 From: Ryo Onodera Date: Tue, 20 Aug 2024 09:28:26 +0900 Subject: [PATCH] Switch block verification to the unified scheduler (#2653) --- CHANGELOG.md | 1 + Cargo.lock | 1 + core/src/validator.rs | 8 +++++--- local-cluster/Cargo.toml | 1 + local-cluster/tests/local_cluster.rs | 18 +++++++++--------- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66aadb9b702c2c..8c809f2b78b115 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Release channels have their own copy of this changelog: * `agave-validator`: Update PoH speed check to compare against current hash rate from a Bank (#2447) * `solana-test-validator`: Add `--clone-feature-set` flag to mimic features from a target cluster (#2480) * `solana-genesis`: the `--cluster-type` parameter now clones the feature set from the target cluster (#2587) + * `unified-scheduler` as default option for `--block-verification-method` (#2653) ## [2.0.0] * Breaking diff --git a/Cargo.lock b/Cargo.lock index cef70349fec932..496c5633b958a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6707,6 +6707,7 @@ dependencies = [ "solana-vote", "solana-vote-program", "static_assertions", + "strum", "tempfile", "trees", ] diff --git a/core/src/validator.rs b/core/src/validator.rs index 373eebf4ae1be2..016514dd817166 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -138,7 +138,7 @@ use { time::{Duration, Instant}, }, strum::VariantNames, - strum_macros::{Display, EnumString, EnumVariantNames, IntoStaticStr}, + strum_macros::{Display, EnumCount, EnumIter, EnumString, EnumVariantNames, IntoStaticStr}, thiserror::Error, tokio::runtime::Runtime as TokioRuntime, }; @@ -151,11 +151,13 @@ const WAIT_FOR_SUPERMAJORITY_THRESHOLD_PERCENT: u64 = 80; const WAIT_FOR_WEN_RESTART_SUPERMAJORITY_THRESHOLD_PERCENT: u64 = WAIT_FOR_SUPERMAJORITY_THRESHOLD_PERCENT; -#[derive(Clone, EnumString, EnumVariantNames, Default, IntoStaticStr, Display)] +#[derive( + Clone, EnumCount, EnumIter, EnumString, EnumVariantNames, Default, IntoStaticStr, Display, +)] #[strum(serialize_all = "kebab-case")] pub enum BlockVerificationMethod { - #[default] BlockstoreProcessor, + #[default] UnifiedScheduler, } diff --git a/local-cluster/Cargo.toml b/local-cluster/Cargo.toml index 3e4cbc0e366531..cd8e2bf6523152 100644 --- a/local-cluster/Cargo.toml +++ b/local-cluster/Cargo.toml @@ -37,6 +37,7 @@ solana-turbine = { workspace = true } solana-vote = { workspace = true } solana-vote-program = { workspace = true } static_assertions = { workspace = true } +strum = { workspace = true, features = ["derive"] } tempfile = { workspace = true } trees = { workspace = true } diff --git a/local-cluster/tests/local_cluster.rs b/local-cluster/tests/local_cluster.rs index 1e62835f91b1a2..a4c767e22ede52 100644 --- a/local-cluster/tests/local_cluster.rs +++ b/local-cluster/tests/local_cluster.rs @@ -5,7 +5,7 @@ use { gag::BufferRedirect, itertools::Itertools, log::*, - rand::seq::IteratorRandom, + rand::seq::SliceRandom, serial_test::serial, solana_accounts_db::{ hardened_unpack::open_genesis_config, utils::create_accounts_run_and_snapshot_dirs, @@ -95,6 +95,7 @@ use { thread::{sleep, Builder, JoinHandle}, time::{Duration, Instant}, }, + strum::{EnumCount, IntoEnumIterator}, }; #[test] @@ -5710,20 +5711,19 @@ fn test_randomly_mixed_block_verification_methods_between_bootstrap_and_not() { info", ); - let num_nodes = 2; + let num_nodes = BlockVerificationMethod::COUNT; let mut config = ClusterConfig::new_with_equal_stakes( num_nodes, DEFAULT_CLUSTER_LAMPORTS, DEFAULT_NODE_STAKE, ); - // Randomly switch to use unified scheduler - config - .validator_configs - .iter_mut() - .choose(&mut rand::thread_rng()) - .unwrap() - .block_verification_method = BlockVerificationMethod::UnifiedScheduler; + // Overwrite block_verification_method with shuffled variants + let mut methods = BlockVerificationMethod::iter().collect::>(); + methods.shuffle(&mut rand::thread_rng()); + for (validator_config, method) in config.validator_configs.iter_mut().zip_eq(methods) { + validator_config.block_verification_method = method; + } let local = LocalCluster::new(&mut config, SocketAddrSpace::Unspecified); cluster_tests::spend_and_verify_all_nodes(