diff --git a/validator/src/cli.rs b/validator/src/cli.rs index d7f886ecb2e631..690483cff4c668 100644 --- a/validator/src/cli.rs +++ b/validator/src/cli.rs @@ -499,20 +499,21 @@ pub fn app<'a>(version: &'a str, default_args: &'a DefaultArgs) -> App<'a, 'a> { .long("no-incremental-snapshots") .takes_value(false) .help("Disable incremental snapshots") - .long_help( - "Disable incremental snapshots by setting this flag. When enabled, \ - --snapshot-interval-slots will set the incremental snapshot interval. To set \ - the full snapshot interval, use --full-snapshot-interval-slots.", - ), ) .arg( - Arg::with_name("incremental_snapshot_interval_slots") - .long("incremental-snapshot-interval-slots") - .alias("snapshot-interval-slots") + Arg::with_name("snapshot_interval_slots") + .long("snapshot-interval-slots") + .alias("incremental-snapshot-interval-slots") .value_name("NUMBER") .takes_value(true) .default_value(&default_args.incremental_snapshot_archive_interval_slots) - .help("Number of slots between generating snapshots, 0 to disable snapshots"), + .help("Number of slots between generating snapshots") + .long_help( + "Number of slots between generating snapshots. \ + If incremental snapshots are enabled, this sets the incremental snapshot interval. \ + If incremental snapshots are disabled, this sets the full snapshot interval. \ + Setting this to 0 disables all snapshots.", + ), ) .arg( Arg::with_name("full_snapshot_interval_slots") @@ -520,9 +521,10 @@ pub fn app<'a>(version: &'a str, default_args: &'a DefaultArgs) -> App<'a, 'a> { .value_name("NUMBER") .takes_value(true) .default_value(&default_args.full_snapshot_archive_interval_slots) - .help( + .help("Number of slots between generating full snapshots") + .long_help( "Number of slots between generating full snapshots. Must be a multiple of the \ - incremental snapshot interval.", + incremental snapshot interval. Only used when incremental snapshots are enabled.", ), ) .arg( diff --git a/validator/src/main.rs b/validator/src/main.rs index a730e27e559e81..047ef25dea5740 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -1665,27 +1665,42 @@ pub fn main() { }) }); - let incremental_snapshot_interval_slots = - value_t_or_exit!(matches, "incremental_snapshot_interval_slots", u64); - let (full_snapshot_archive_interval_slots, incremental_snapshot_archive_interval_slots) = - if incremental_snapshot_interval_slots > 0 { - if !matches.is_present("no_incremental_snapshots") { - ( - value_t_or_exit!(matches, "full_snapshot_interval_slots", u64), - incremental_snapshot_interval_slots, - ) - } else { - ( - incremental_snapshot_interval_slots, - DISABLED_SNAPSHOT_ARCHIVE_INTERVAL, - ) - } - } else { + let (full_snapshot_archive_interval_slots, incremental_snapshot_archive_interval_slots) = match ( + !matches.is_present("no_incremental_snapshots"), + value_t_or_exit!(matches, "snapshot_interval_slots", u64), + ) { + (_, 0) => { + // snapshots are disabled ( DISABLED_SNAPSHOT_ARCHIVE_INTERVAL, DISABLED_SNAPSHOT_ARCHIVE_INTERVAL, ) - }; + } + (true, incremental_snapshot_interval_slots) => { + // incremental snapshots are enabled + // use --snapshot-interval-slots for the incremental snapshot interval + ( + value_t_or_exit!(matches, "full_snapshot_interval_slots", u64), + incremental_snapshot_interval_slots, + ) + } + (false, full_snapshot_interval_slots) => { + // incremental snapshots are *disabled* + // use --snapshot-interval-slots for the *full* snapshot interval + // also warn if --full-snapshot-interval-slots was specified + if matches.occurrences_of("full_snapshot_interval_slots") > 0 { + warn!( + "Incremental snapshots are disabled, yet --full-snapshot-interval-slots was specified! \ + Note that --full-snapshot-interval-slots is *ignored* when incremental snapshots are disabled. \ + Use --snapshot-interval-slots instead.", + ); + } + ( + full_snapshot_interval_slots, + DISABLED_SNAPSHOT_ARCHIVE_INTERVAL, + ) + } + }; validator_config.snapshot_config = SnapshotConfig { usage: if full_snapshot_archive_interval_slots == DISABLED_SNAPSHOT_ARCHIVE_INTERVAL { @@ -1712,29 +1727,30 @@ pub fn main() { incremental_snapshot_archive_interval_slots, ); + info!( + "Snapshot configuration: full snapshot interval: {} slots, incremental snapshot interval: {} slots", + if full_snapshot_archive_interval_slots == DISABLED_SNAPSHOT_ARCHIVE_INTERVAL { + "disabled".to_string() + } else { + full_snapshot_archive_interval_slots.to_string() + }, + if incremental_snapshot_archive_interval_slots == DISABLED_SNAPSHOT_ARCHIVE_INTERVAL { + "disabled".to_string() + } else { + incremental_snapshot_archive_interval_slots.to_string() + }, + ); + if !is_snapshot_config_valid( &validator_config.snapshot_config, validator_config.accounts_hash_interval_slots, ) { eprintln!( "Invalid snapshot configuration provided: snapshot intervals are incompatible. \ - \n\t- full snapshot interval MUST be a multiple of incremental snapshot interval (if \ - enabled)\ - \n\t- full snapshot interval MUST be larger than incremental snapshot \ - interval (if enabled)\ - \nSnapshot configuration values:\ - \n\tfull snapshot interval: {}\ - \n\tincremental snapshot interval: {}", - if full_snapshot_archive_interval_slots == DISABLED_SNAPSHOT_ARCHIVE_INTERVAL { - "disabled".to_string() - } else { - full_snapshot_archive_interval_slots.to_string() - }, - if incremental_snapshot_archive_interval_slots == DISABLED_SNAPSHOT_ARCHIVE_INTERVAL { - "disabled".to_string() - } else { - incremental_snapshot_archive_interval_slots.to_string() - }, + \n\t- full snapshot interval MUST be a multiple of incremental snapshot interval \ + (if enabled) \ + \n\t- full snapshot interval MUST be larger than incremental snapshot interval \ + (if enabled)", ); exit(1); }