Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@
* careful enabling this network wide. If this is enabled and all states on disk
* have deserialization bugs, then all nodes will delete all state copies and the
* network will restart from genesis.
* @param validateInitialState If false then do not do ISS validation on the state loaded from disk at startup.
* @param validateInitialState If false, then do not do ISS validation on the state loaded from disk at startup.
* This should always be enabled in production environments. Disabling initial
* state validation is intended to be a test-only feature.
* @param periodicSnapshotsEnabled If true, then create periodic snapshots of the signed state.
*
*/
@ConfigData("state")
public record StateConfig(
Expand All @@ -81,7 +83,8 @@ public record StateConfig(
@ConfigProperty(defaultValue = "false") boolean stateHistoryEnabled,
@ConfigProperty(defaultValue = "false") boolean debugStackTracesEnabled,
@ConfigProperty(defaultValue = "false") boolean deleteInvalidStateFiles,
@ConfigProperty(defaultValue = "true") boolean validateInitialState) {
@ConfigProperty(defaultValue = "true") boolean validateInitialState,
@ConfigProperty(defaultValue = "true") boolean periodicSnapshotsEnabled) {

/**
* Get the main class name that should be used for signed states.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,13 @@ private StateToDiskReason shouldSaveToDisk(
return FIRST_ROUND_AFTER_GENESIS;
}

if ((signedState.getConsensusTimestamp().getEpochSecond() / saveStatePeriod)
> (previousTimestamp.getEpochSecond() / saveStatePeriod)) {
final boolean periodicSnapshotsEnabled = stateConfig.periodicSnapshotsEnabled();
if (periodicSnapshotsEnabled
&& (signedState.getConsensusTimestamp().getEpochSecond() / saveStatePeriod)
> (previousTimestamp.getEpochSecond() / saveStatePeriod)) {
return PERIODIC_SNAPSHOT;
} else {
// the period hasn't yet elapsed
// the period hasn't yet elapsed or periodic snapshots are disabled
return null;
}
}
Expand Down
Loading