Skip to content

Commit

Permalink
refactor: prune everything (#11177)
Browse files Browse the repository at this point in the history
(cherry picked from commit 75bcf47)

# Conflicts:
#	CHANGELOG.md
#	server/config/toml.go
#	server/start.go
#	store/rootmulti/store.go
#	store/types/pruning.go
#	store/v2/multi/store_test.go
  • Loading branch information
alexanderbez authored and mergify-bot committed Feb 23, 2022
1 parent d862c66 commit bc49d4f
Show file tree
Hide file tree
Showing 7 changed files with 1,017 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

<<<<<<< HEAD
=======
* (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.
>>>>>>> 75bcf47f1 (refactor: prune everything (#11177))
* (store) [\#11117](https://github.com/cosmos/cosmos-sdk/pull/11117) Fix data race in store trace component

### Improvements
Expand Down
5 changes: 5 additions & 0 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,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
}
5 changes: 5 additions & 0 deletions server/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ minimum-gas-prices = "{{ .BaseConfig.MinGasPrices }}"
# default: the last 100 states are kept in addition to every 500th state; pruning at 10 block intervals
# nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node)
<<<<<<< HEAD
# everything: all saved states will be deleted, storing only the current state; pruning at 10 block intervals
# custom: allow pruning options to be manually specified through 'pruning-keep-recent', 'pruning-keep-every', and 'pruning-interval'
=======
# 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'
>>>>>>> 75bcf47f1 (refactor: prune everything (#11177))
pruning = "{{ .BaseConfig.Pruning }}"
# These are applied if and only if the pruning strategy is custom.
Expand Down
5 changes: 5 additions & 0 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,13 @@ For '--pruning' the options are as follows:
default: the last 100 states are kept in addition to every 500th state; pruning at 10 block intervals
nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node)
<<<<<<< HEAD
everything: all saved states will be deleted, storing only the current state; pruning at 10 block intervals
custom: allow pruning options to be manually specified through 'pruning-keep-recent', 'pruning-keep-every', and 'pruning-interval'
=======
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'
>>>>>>> 75bcf47f1 (refactor: prune everything (#11177))
Node halting configurations exist in the form of two flags: '--halt-height' and '--halt-time'. During
the ABCI Commit phase, the node will check if the current block height is greater than or equal to
Expand Down
7 changes: 6 additions & 1 deletion store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,17 @@ func (rs *Store) Commit() types.CommitID {
previousHeight = rs.lastCommitInfo.GetVersion()
version = previousHeight + 1
}
<<<<<<< HEAD
=======

rs.lastCommitInfo = commitStores(version, rs.stores, rs.removalMap)
>>>>>>> 75bcf47f1 (refactor: prune everything (#11177))

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

// 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)
// We consider this height to be pruned iff:
//
Expand Down
6 changes: 6 additions & 0 deletions store/types/pruning.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ var (
PruneDefault = NewPruningOptions(362880, 100, 10)

// PruneEverything defines a pruning strategy where all committed heights are
<<<<<<< HEAD
// deleted, storing only the current height and where to-be pruned heights are
// pruned at every 10th height.
PruneEverything = NewPruningOptions(0, 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)
>>>>>>> 75bcf47f1 (refactor: prune everything (#11177))

// PruneNothing defines a pruning strategy where all heights are kept on disk.
PruneNothing = NewPruningOptions(0, 1, 0)
Expand Down
Loading

0 comments on commit bc49d4f

Please sign in to comment.