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

refactor: prune everything #11177

Merged
merged 9 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from 8 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* [\#10844](https://github.com/cosmos/cosmos-sdk/pull/10844) Automatic recovering non-consistent keyring storage during public key import
* (store) [\#11177](https://github.com/cosmos/cosmos-sdk/pull/11177) Update the prune `nothing` strategy to store the last two heights.
* [\#10844](https://github.com/cosmos/cosmos-sdk/pull/10844) Automatic recovering non-consistent keyring storage during public key import.
* (store) [\#11117](https://github.com/cosmos/cosmos-sdk/pull/11117) Fix data race in store trace component
* (cli) [\#11065](https://github.com/cosmos/cosmos-sdk/pull/11065) Ensure the `tendermint-validator-set` query command respects the `-o` output flag.
* (grpc) [\#10985](https://github.com/cosmos/cosmos-sdk/pull/10992) The `/cosmos/tx/v1beta1/txs/{hash}` endpoint returns a 404 when a tx does not exist.
Expand Down
5 changes: 5 additions & 0 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ func (c Config) ValidateBasic() error {
if c.BaseConfig.MinGasPrices == "" {
return sdkerrors.ErrAppConfig.Wrap("set min gas price in app.toml or flag or env variable")
}
if c.Pruning == storetypes.PruningOptionEverything && c.StateSync.SnapshotInterval > 0 {
return sdkerrors.ErrAppConfig.Wrapf(
"cannot enable state sync snapshots with '%s' pruning setting", storetypes.PruningOptionEverything,
)
}

return nil
}
2 changes: 1 addition & 1 deletion server/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ minimum-gas-prices = "{{ .BaseConfig.MinGasPrices }}"

# default: the last 362880 states are kept, pruning at 10 block intervals
# nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node)
# everything: all saved states will be deleted, storing only the current state; pruning at 10 block intervals
# everything: all saved states will be deleted, storing only the current and previous state; pruning at 10 block intervals
# custom: allow pruning options to be manually specified through 'pruning-keep-recent' and 'pruning-interval'
pruning = "{{ .BaseConfig.Pruning }}"

Expand Down
2 changes: 1 addition & 1 deletion server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ For '--pruning' the options are as follows:

default: the last 362880 states are kept, pruning at 10 block intervals
nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node)
everything: all saved states will be deleted, storing only the current state; pruning at 10 block intervals
everything: all saved states will be deleted, storing only the current and previous state; pruning at 10 block intervals
custom: allow pruning options to be manually specified through 'pruning-keep-recent' and 'pruning-interval'

Node halting configurations exist in the form of two flags: '--halt-height' and '--halt-time'. During
Expand Down
3 changes: 2 additions & 1 deletion store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ func (rs *Store) Commit() types.CommitID {
previousHeight = rs.lastCommitInfo.GetVersion()
version = previousHeight + 1
}

rs.lastCommitInfo = commitStores(version, rs.stores, rs.removalMap)

// remove remnants of removed stores
Expand All @@ -426,7 +427,7 @@ func (rs *Store) Commit() types.CommitID {

// Determine if pruneHeight height needs to be added to the list of heights to
// be pruned, where pruneHeight = (commitHeight - 1) - KeepRecent.
if int64(rs.pruningOpts.KeepRecent) < previousHeight {
if rs.pruningOpts.Interval > 0 && int64(rs.pruningOpts.KeepRecent) < previousHeight {
pruneHeight := previousHeight - int64(rs.pruningOpts.KeepRecent)
rs.pruneHeights = append(rs.pruneHeights, pruneHeight)
}
Expand Down
6 changes: 3 additions & 3 deletions store/types/pruning.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ var (
PruneDefault = NewPruningOptions(362880, 10)

// PruneEverything defines a pruning strategy where all committed heights are
// deleted, storing only the current height and where to-be pruned heights are
// pruned at every 10th height.
PruneEverything = NewPruningOptions(0, 10)
// deleted, storing only the current and previous height and where to-be pruned
// heights are pruned at every 10th height.
PruneEverything = NewPruningOptions(2, 10)

// PruneNothing defines a pruning strategy where all heights are kept on disk.
PruneNothing = NewPruningOptions(0, 0)
Expand Down
2 changes: 1 addition & 1 deletion store/v2/multi/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func TestPruning(t *testing.T) {
}{
{types.PruningOptions{2, 10}, []uint64{8, 9, 10}},
{types.PruningOptions{0, 10}, []uint64{10}},
{types.PruneEverything, []uint64{10}},
{types.PruneEverything, []uint64{8, 9, 10}},
{types.PruneNothing, []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}},
}

Expand Down