Skip to content

Commit

Permalink
Adds --no-snapshots to disable generating snapshots (#4836)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Mar 4, 2025
1 parent bf1809c commit ddf50e1
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 31 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Release channels have their own copy of this changelog:

#### Changes
* Account notifications for Geyser are no longer deduplicated when restorting from a snapshot.
* Add `--no-snapshots` to disable generating snapshots.

#### Deprecations
* Using `--snapshot-interval-slots 0` to disable generating snapshots is now deprecated.

### Platform Tools SDK

Expand Down
9 changes: 8 additions & 1 deletion validator/src/commands/run/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,13 @@ pub fn add_args<'a>(app: App<'a, 'a>, default_args: &'a DefaultArgs) -> App<'a,
snapshot available for download from other validators",
),
)
.arg(
Arg::with_name("no_snapshots")
.long("no-snapshots")
.takes_value(false)
.conflicts_with_all(&["no_incremental_snapshots", "snapshot_interval_slots", "full_snapshot_interval_slots"])
.help("Disable all snapshot generation")
)
.arg(
Arg::with_name("no_incremental_snapshots")
.long("no-incremental-snapshots")
Expand All @@ -423,7 +430,7 @@ pub fn add_args<'a>(app: App<'a, 'a>, default_args: &'a DefaultArgs) -> App<'a,
"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.",
To disable all snapshot generation, see --no-snapshots.",
),
)
.arg(
Expand Down
73 changes: 43 additions & 30 deletions validator/src/commands/run/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -913,42 +913,55 @@ pub fn execute(
.transpose()?
.unwrap_or(SnapshotVersion::default());

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) => {
let (full_snapshot_archive_interval_slots, incremental_snapshot_archive_interval_slots) =
if matches.is_present("no_snapshots") {
// 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.",
);
} else {
match (
!matches.is_present("no_incremental_snapshots"),
value_t_or_exit!(matches, "snapshot_interval_slots", u64),
) {
(_, 0) => {
// snapshots are disabled
warn!(
"Snapshot generation was disabled with `--snapshot-interval-slots 0`, \
which is now deprecated. Use `--no-snapshots` instead.",
);
(
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,
)
}
}
(
full_snapshot_interval_slots,
DISABLED_SNAPSHOT_ARCHIVE_INTERVAL,
)
}
};
};

validator_config.snapshot_config = SnapshotConfig {
usage: if full_snapshot_archive_interval_slots == DISABLED_SNAPSHOT_ARCHIVE_INTERVAL {
Expand Down

0 comments on commit ddf50e1

Please sign in to comment.