説明
General note
SnapshotConfig is currently fine as-is; this task is a cleanup task that would be good for someone dipping their toes into Rust and/or as a learning experience to see all the places that touch snapshots within the validator client. If any potential readers have interest in picking up this task, feel free to indicate in a comment.
Problem
Validators can run with varying levels of what is enabled / disabled in regards to snapshots. Some of the variations:
- Validator can choose ONLY load from snapshot and NOT generate any snapshots
- Technically, validators can load from genesis but on mainnet/testnet/devnet, this is not practical
- Validators can generate ONLY full snapshots without incremental snapshots
- Validators can generate full AND incremental snapshots
However, the SnapshotConfig field also contains some fields that must be specified. So, the validator always has a SnapshotConfig struct, and some fields just get ignored or set to sentinel values.
Proposed Solution
Rework the SnapshotConfig parameter to better reflect the different modes of operation. After a little chatter with @brooksprumo and @apfitzge on some PR's that spawned this conversation (https://github.com/solana-labs/solana/pull/32236 and https://github.com/solana-labs/solana/pull/32237), one potential idea might look something like:
pub enum SnapshotMode {
Disabled
LoadOnly(Config)
LoadAndGenerate(Config)
}
And then within the Config struct (actual PR should pick a better name, just using short name here for illustration), use appropriate types to represent items are not always required (ie Option<T>) or may have specific requirements (ie NonZero types if the value must explicitly be greater than 0`).