From 66bdefd17873e5a8c0bc02c53e8b2eb5904d0ccc Mon Sep 17 00:00:00 2001 From: Yihau Chen Date: Tue, 25 Jun 2024 03:04:23 +0800 Subject: [PATCH] chore: add dcou to apply_votes_to_tower (#1831) * add dcou to apply_votes_to_tower * cargo sort * fix fmt --- Cargo.lock | 1 + local-cluster/Cargo.toml | 1 + local-cluster/src/cluster_tests.rs | 15 ++++++++++----- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e783abc88d0d14..1879e9426c4210 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6555,6 +6555,7 @@ dependencies = [ "solana-entry", "solana-gossip", "solana-ledger", + "solana-local-cluster", "solana-logger", "solana-pubsub-client", "solana-quic-client", diff --git a/local-cluster/Cargo.toml b/local-cluster/Cargo.toml index 0d72a867c60ac1..3e4cbc0e366531 100644 --- a/local-cluster/Cargo.toml +++ b/local-cluster/Cargo.toml @@ -48,6 +48,7 @@ serial_test = { workspace = true } solana-core = { workspace = true, features = ["dev-context-only-utils"] } solana-download-utils = { workspace = true } solana-ledger = { workspace = true, features = ["dev-context-only-utils"] } +solana-local-cluster = { path = ".", features = ["dev-context-only-utils"] } solana-runtime = { workspace = true, features = ["dev-context-only-utils"] } [package.metadata.docs.rs] diff --git a/local-cluster/src/cluster_tests.rs b/local-cluster/src/cluster_tests.rs index e297457dcc3bd5..9b80c15824f494 100644 --- a/local-cluster/src/cluster_tests.rs +++ b/local-cluster/src/cluster_tests.rs @@ -8,10 +8,7 @@ use { rand::{thread_rng, Rng}, rayon::{prelude::*, ThreadPool}, solana_client::connection_cache::{ConnectionCache, Protocol}, - solana_core::consensus::{ - tower_storage::{FileTowerStorage, SavedTower, SavedTowerVersions, TowerStorage}, - VOTE_THRESHOLD_DEPTH, - }, + solana_core::consensus::VOTE_THRESHOLD_DEPTH, solana_entry::entry::{self, Entry, EntrySlice}, solana_gossip::{ cluster_info::{self, ClusterInfo}, @@ -44,7 +41,7 @@ use { std::{ collections::{HashMap, HashSet, VecDeque}, net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener}, - path::{Path, PathBuf}, + path::Path, sync::{ atomic::{AtomicBool, Ordering}, Arc, RwLock, @@ -53,6 +50,13 @@ use { time::{Duration, Instant}, }, }; +#[cfg(feature = "dev-context-only-utils")] +use { + solana_core::consensus::tower_storage::{ + FileTowerStorage, SavedTower, SavedTowerVersions, TowerStorage, + }, + std::path::PathBuf, +}; pub fn get_client_facing_addr( protocol: Protocol, @@ -348,6 +352,7 @@ pub fn kill_entry_and_spend_and_verify_rest( } } +#[cfg(feature = "dev-context-only-utils")] pub fn apply_votes_to_tower(node_keypair: &Keypair, votes: Vec<(Slot, Hash)>, tower_path: PathBuf) { let tower_storage = FileTowerStorage::new(tower_path); let mut tower = tower_storage.load(&node_keypair.pubkey()).unwrap();