Skip to content

Commit ddf50e1

Browse files
authored
Adds --no-snapshots to disable generating snapshots (anza-xyz#4836)
1 parent bf1809c commit ddf50e1

File tree

3 files changed

+55
-31
lines changed

3 files changed

+55
-31
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ Release channels have their own copy of this changelog:
1919

2020
#### Changes
2121
* Account notifications for Geyser are no longer deduplicated when restorting from a snapshot.
22+
* Add `--no-snapshots` to disable generating snapshots.
23+
24+
#### Deprecations
25+
* Using `--snapshot-interval-slots 0` to disable generating snapshots is now deprecated.
2226

2327
### Platform Tools SDK
2428

validator/src/commands/run/args.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,13 @@ pub fn add_args<'a>(app: App<'a, 'a>, default_args: &'a DefaultArgs) -> App<'a,
405405
snapshot available for download from other validators",
406406
),
407407
)
408+
.arg(
409+
Arg::with_name("no_snapshots")
410+
.long("no-snapshots")
411+
.takes_value(false)
412+
.conflicts_with_all(&["no_incremental_snapshots", "snapshot_interval_slots", "full_snapshot_interval_slots"])
413+
.help("Disable all snapshot generation")
414+
)
408415
.arg(
409416
Arg::with_name("no_incremental_snapshots")
410417
.long("no-incremental-snapshots")
@@ -423,7 +430,7 @@ pub fn add_args<'a>(app: App<'a, 'a>, default_args: &'a DefaultArgs) -> App<'a,
423430
"Number of slots between generating snapshots. \
424431
If incremental snapshots are enabled, this sets the incremental snapshot interval. \
425432
If incremental snapshots are disabled, this sets the full snapshot interval. \
426-
Setting this to 0 disables all snapshots.",
433+
To disable all snapshot generation, see --no-snapshots.",
427434
),
428435
)
429436
.arg(

validator/src/commands/run/execute.rs

+43-30
Original file line numberDiff line numberDiff line change
@@ -913,42 +913,55 @@ pub fn execute(
913913
.transpose()?
914914
.unwrap_or(SnapshotVersion::default());
915915

916-
let (full_snapshot_archive_interval_slots, incremental_snapshot_archive_interval_slots) = match (
917-
!matches.is_present("no_incremental_snapshots"),
918-
value_t_or_exit!(matches, "snapshot_interval_slots", u64),
919-
) {
920-
(_, 0) => {
916+
let (full_snapshot_archive_interval_slots, incremental_snapshot_archive_interval_slots) =
917+
if matches.is_present("no_snapshots") {
921918
// snapshots are disabled
922919
(
923920
DISABLED_SNAPSHOT_ARCHIVE_INTERVAL,
924921
DISABLED_SNAPSHOT_ARCHIVE_INTERVAL,
925922
)
926-
}
927-
(true, incremental_snapshot_interval_slots) => {
928-
// incremental snapshots are enabled
929-
// use --snapshot-interval-slots for the incremental snapshot interval
930-
(
931-
value_t_or_exit!(matches, "full_snapshot_interval_slots", u64),
932-
incremental_snapshot_interval_slots,
933-
)
934-
}
935-
(false, full_snapshot_interval_slots) => {
936-
// incremental snapshots are *disabled*
937-
// use --snapshot-interval-slots for the *full* snapshot interval
938-
// also warn if --full-snapshot-interval-slots was specified
939-
if matches.occurrences_of("full_snapshot_interval_slots") > 0 {
940-
warn!(
941-
"Incremental snapshots are disabled, yet --full-snapshot-interval-slots was specified! \
942-
Note that --full-snapshot-interval-slots is *ignored* when incremental snapshots are disabled. \
943-
Use --snapshot-interval-slots instead.",
944-
);
923+
} else {
924+
match (
925+
!matches.is_present("no_incremental_snapshots"),
926+
value_t_or_exit!(matches, "snapshot_interval_slots", u64),
927+
) {
928+
(_, 0) => {
929+
// snapshots are disabled
930+
warn!(
931+
"Snapshot generation was disabled with `--snapshot-interval-slots 0`, \
932+
which is now deprecated. Use `--no-snapshots` instead.",
933+
);
934+
(
935+
DISABLED_SNAPSHOT_ARCHIVE_INTERVAL,
936+
DISABLED_SNAPSHOT_ARCHIVE_INTERVAL,
937+
)
938+
}
939+
(true, incremental_snapshot_interval_slots) => {
940+
// incremental snapshots are enabled
941+
// use --snapshot-interval-slots for the incremental snapshot interval
942+
(
943+
value_t_or_exit!(matches, "full_snapshot_interval_slots", u64),
944+
incremental_snapshot_interval_slots,
945+
)
946+
}
947+
(false, full_snapshot_interval_slots) => {
948+
// incremental snapshots are *disabled*
949+
// use --snapshot-interval-slots for the *full* snapshot interval
950+
// also warn if --full-snapshot-interval-slots was specified
951+
if matches.occurrences_of("full_snapshot_interval_slots") > 0 {
952+
warn!(
953+
"Incremental snapshots are disabled, yet --full-snapshot-interval-slots was specified! \
954+
Note that --full-snapshot-interval-slots is *ignored* when incremental snapshots are disabled. \
955+
Use --snapshot-interval-slots instead.",
956+
);
957+
}
958+
(
959+
full_snapshot_interval_slots,
960+
DISABLED_SNAPSHOT_ARCHIVE_INTERVAL,
961+
)
962+
}
945963
}
946-
(
947-
full_snapshot_interval_slots,
948-
DISABLED_SNAPSHOT_ARCHIVE_INTERVAL,
949-
)
950-
}
951-
};
964+
};
952965

953966
validator_config.snapshot_config = SnapshotConfig {
954967
usage: if full_snapshot_archive_interval_slots == DISABLED_SNAPSHOT_ARCHIVE_INTERVAL {

0 commit comments

Comments
 (0)