Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(baseapp): fix snapshot interval bug #14049

Merged
merged 4 commits into from
Nov 28, 2022
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ extension interfaces. `module.Manager.Modules` is now of type `map[string]interf
* (server) [#13778](https://github.com/cosmos/cosmos-sdk/pull/13778) Set Cosmos SDK default endpoints to localhost to avoid unknown exposure of endpoints.
* (x/auth) [#13877](https://github.com/cosmos/cosmos-sdk/pull/13877) Handle missing account numbers during `InitGenesis`.
* (x/gov) [#13918](https://github.com/cosmos/cosmos-sdk/pull/13918) Fix propagation of message errors when executing a proposal.
* (baseapp)[#14049](https://github.com/cosmos/cosmos-sdk/pull/14049) Fix state sync when interval is zero.

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion baseapp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (app *BaseApp) SetSnapshot(snapshotStore *snapshots.Store, opts snapshottyp
if app.sealed {
panic("SetSnapshot() on sealed BaseApp")
}
if snapshotStore == nil || opts.Interval == snapshottypes.SnapshotIntervalOff {
if snapshotStore == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove this, then SnapshotIntervalOff is never used anywhere. Maybe we can remove this const as well.

When opts.Interval is not set / 0, everything will be pruned.

// We consider this height to be pruned iff:
//
// - snapshotInterval is zero as that means that all heights should be pruned.
// - snapshotInterval % (height - KeepRecent) != 0 as that means the height is not
// a 'snapshot' height.
if m.snapshotInterval == 0 || pruneHeight%int64(m.snapshotInterval) != 0 {

app.snapshotManager = nil
return
}
Expand Down
4 changes: 0 additions & 4 deletions snapshots/types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ type SnapshotOptions struct {
KeepRecent uint32
}

// SnapshotIntervalOff represents the snapshot interval, at which
// no snapshots are taken.
const SnapshotIntervalOff uint64 = 0

func NewSnapshotOptions(interval uint64, keepRecent uint32) SnapshotOptions {
return SnapshotOptions{
Interval: interval,
Expand Down