Add --tower argument to specify where tower files are persisted

This commit is contained in:
Michael Vines 2021-05-04 20:49:18 -07:00
parent 769136f586
commit 9ba2c53b85
3 changed files with 18 additions and 5 deletions

View File

@ -115,6 +115,7 @@ pub struct ValidatorConfig {
pub poh_verify: bool, // Perform PoH verification during blockstore processing at boo
pub cuda: bool,
pub require_tower: bool,
pub tower_path: Option<PathBuf>,
pub debug_keys: Option<Arc<HashSet<Pubkey>>>,
pub contact_debug_interval: u64,
pub contact_save_interval: u64,
@ -170,6 +171,7 @@ impl Default for ValidatorConfig {
poh_verify: true,
cuda: false,
require_tower: false,
tower_path: None,
debug_keys: None,
contact_debug_interval: DEFAULT_CONTACT_DEBUG_INTERVAL_MILLIS,
contact_save_interval: DEFAULT_CONTACT_SAVE_INTERVAL_MILLIS,
@ -932,7 +934,7 @@ fn post_process_restored_tower(
validator_identity: &Pubkey,
vote_account: &Pubkey,
config: &ValidatorConfig,
ledger_path: &Path,
tower_path: &Path,
bank_forks: &BankForks,
) -> Tower {
let mut should_require_tower = config.require_tower;
@ -1011,7 +1013,7 @@ fn post_process_restored_tower(
Tower::new_from_bankforks(
&bank_forks,
&ledger_path,
tower_path,
&validator_identity,
&vote_account,
)
@ -1074,7 +1076,9 @@ fn new_banks_from_ledger(
.expect("Failed to open ledger database");
blockstore.set_no_compaction(config.no_rocksdb_compaction);
let restored_tower = Tower::restore(ledger_path, &validator_identity);
let tower_path = config.tower_path.as_deref().unwrap_or(ledger_path);
let restored_tower = Tower::restore(tower_path, &validator_identity);
if let Ok(tower) = &restored_tower {
reconcile_blockstore_roots_with_tower(&tower, &blockstore).unwrap_or_else(|err| {
error!("Failed to reconcile blockstore with tower: {:?}", err);
@ -1172,7 +1176,7 @@ fn new_banks_from_ledger(
&validator_identity,
&vote_account,
&config,
&ledger_path,
tower_path,
&bank_forks,
);

View File

@ -37,6 +37,7 @@ pub fn safe_clone_config(config: &ValidatorConfig) -> ValidatorConfig {
poh_verify: config.poh_verify,
cuda: config.cuda,
require_tower: config.require_tower,
tower_path: config.tower_path.clone(),
debug_keys: config.debug_keys.clone(),
contact_debug_interval: config.contact_debug_interval,
contact_save_interval: config.contact_save_interval,

View File

@ -1253,7 +1253,14 @@ pub fn main() {
.long("snapshots")
.value_name("DIR")
.takes_value(true)
.help("Use DIR as persistent snapshot [default: --ledger value]"),
.help("Use DIR as snapshot location [default: --ledger value]"),
)
.arg(
Arg::with_name("tower")
.long("tower")
.value_name("DIR")
.takes_value(true)
.help("Use DIR as tower location [default: --ledger value]"),
)
.arg(
Arg::with_name("gossip_port")
@ -2040,6 +2047,7 @@ pub fn main() {
let restricted_repair_only_mode = matches.is_present("restricted_repair_only_mode");
let mut validator_config = ValidatorConfig {
require_tower: matches.is_present("require_tower"),
tower_path: value_t!(matches, "tower", PathBuf).ok(),
dev_halt_at_slot: value_t!(matches, "dev_halt_at_slot", Slot).ok(),
cuda: matches.is_present("cuda"),
expected_genesis_hash: matches