Extract tower storage details from Tower struct

This commit is contained in:
Michael Vines
2021-07-20 22:25:13 -07:00
parent ca37873e16
commit 397801a2d8
12 changed files with 425 additions and 388 deletions

View File

@@ -5,7 +5,10 @@ use {
jsonrpc_ipc_server::{RequestContext, ServerBuilder},
jsonrpc_server_utils::tokio,
log::*,
solana_core::validator::ValidatorStartProgress,
solana_core::{
consensus::{Tower, TowerStorage},
validator::ValidatorStartProgress,
},
solana_gossip::cluster_info::ClusterInfo,
solana_sdk::{
exit::Exit,
@@ -13,7 +16,7 @@ use {
},
std::{
net::SocketAddr,
path::{Path, PathBuf},
path::Path,
sync::{Arc, RwLock},
thread::{self, Builder},
time::{Duration, SystemTime},
@@ -28,7 +31,7 @@ pub struct AdminRpcRequestMetadata {
pub validator_exit: Arc<RwLock<Exit>>,
pub authorized_voter_keypairs: Arc<RwLock<Vec<Arc<Keypair>>>>,
pub cluster_info: Arc<RwLock<Option<Arc<ClusterInfo>>>>,
pub tower_path: PathBuf,
pub tower_storage: Arc<dyn TowerStorage>,
}
impl Metadata for AdminRpcRequestMetadata {}
@@ -147,13 +150,12 @@ impl AdminRpc for AdminRpcImpl {
// Ensure a Tower exists for the new identity and exit gracefully.
// ReplayStage will be less forgiving if it fails to load the new tower.
solana_core::consensus::Tower::restore(&meta.tower_path, &identity_keypair.pubkey())
.map_err(|err| {
jsonrpc_core::error::Error::invalid_params(format!(
"Unable to load tower file for new identity: {}",
err
))
})?;
Tower::restore(meta.tower_storage.as_ref(), &identity_keypair.pubkey()).map_err(|err| {
jsonrpc_core::error::Error::invalid_params(format!(
"Unable to load tower file for new identity: {}",
err
))
})?;
if let Some(cluster_info) = meta.cluster_info.read().unwrap().as_ref() {
solana_metrics::set_host_id(identity_keypair.pubkey().to_string());

View File

@@ -8,6 +8,7 @@ use {
},
},
solana_client::rpc_client::RpcClient,
solana_core::consensus::FileTowerStorage,
solana_faucet::faucet::{run_local_faucet_with_port, FAUCET_PORT},
solana_rpc::rpc::JsonRpcConfig,
solana_sdk::{
@@ -521,7 +522,7 @@ fn main() {
validator_exit: genesis.validator_exit.clone(),
authorized_voter_keypairs: genesis.authorized_voter_keypairs.clone(),
cluster_info: admin_service_cluster_info.clone(),
tower_path: ledger_path.clone(),
tower_storage: Arc::new(FileTowerStorage::new(ledger_path.clone())),
},
);
let dashboard = if output == Output::Dashboard {

View File

@@ -20,6 +20,7 @@ use {
rpc_request::MAX_MULTIPLE_ACCOUNTS,
},
solana_core::{
consensus::FileTowerStorage,
ledger_cleanup_service::{DEFAULT_MAX_LEDGER_SHREDS, DEFAULT_MIN_MAX_LEDGER_SHREDS},
tpu::DEFAULT_TPU_COALESCE_MS,
validator::{
@@ -2286,11 +2287,13 @@ pub fn main() {
.ok()
.or_else(|| get_cluster_shred_version(&entrypoint_addrs));
let tower_path = value_t!(matches, "tower", PathBuf)
.ok()
.unwrap_or_else(|| ledger_path.clone());
let mut validator_config = ValidatorConfig {
require_tower: matches.is_present("require_tower"),
tower_path: value_t!(matches, "tower", PathBuf)
.ok()
.or_else(|| Some(ledger_path.clone())),
tower_storage: Arc::new(FileTowerStorage::new(tower_path)),
dev_halt_at_slot: value_t!(matches, "dev_halt_at_slot", Slot).ok(),
expected_genesis_hash: matches
.value_of("expected_genesis_hash")
@@ -2577,7 +2580,7 @@ pub fn main() {
start_progress: start_progress.clone(),
authorized_voter_keypairs: authorized_voter_keypairs.clone(),
cluster_info: admin_service_cluster_info.clone(),
tower_path: validator_config.tower_path.clone().unwrap(),
tower_storage: validator_config.tower_storage.clone(),
},
);