pruning

package
v0.47.16-ics-lsm Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

Pruning

Overview

Pruning is the mechanism for deleting old application heights from the disk. Depending on the use case, nodes may require different pruning strategies. For example, archive nodes must keep all the states and prune nothing. On the other hand, a regular validator node may want to only keep 100 latest heights for performance reasons.

Strategies

The strategies are configured in app.toml, with the format pruning = "<strategy>" where the options are:

  • default: only the last 362,880 states(approximately 3.5 weeks worth of state) are kept; pruning at 10 block intervals
  • nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node)
  • everything: 2 latest states will be kept; pruning at 10 block intervals.
  • custom: allow pruning options to be manually specified through 'pruning-keep-recent', and 'pruning-interval'

If no strategy is given to the BaseApp, nothing is selected. However, we perform validation on the CLI layer to require these to be always set in the config file.

Custom Pruning

These are applied if and only if the pruning strategy is custom:

  • pruning-keep-recent: N means to keep all of the last N states
  • pruning-interval: N means to delete old states from disk every Nth block.

Relationship to State Sync Snapshots

Snapshot settings are optional. However, if set, they have an effect on how pruning is done by persisting the heights that are multiples of state-sync.snapshot-interval until after the snapshot is complete. See the "Relationship to Pruning" section in snapshots/README.md for more details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is an abstraction to handle the logic needed for determining when to prune old heights of the store based on the strategy described by the pruning options.

func NewManager

func NewManager(db dbm.DB, logger log.Logger) *Manager

NewManager returns a new Manager with the given db and logger. The retuned manager uses a pruning strategy of "nothing" which keeps all heights. Users of the Manager may change the strategy by calling SetOptions.

func (*Manager) GetFlushAndResetPruningHeights

func (m *Manager) GetFlushAndResetPruningHeights() ([]int64, error)

GetFlushAndResetPruningHeights returns all heights to be pruned during the next call to Prune(). It also flushes and resets the pruning heights.

func (*Manager) GetOptions

func (m *Manager) GetOptions() types.PruningOptions

GetOptions fetches the pruning strategy from the manager.

func (*Manager) HandleHeight

func (m *Manager) HandleHeight(previousHeight int64) int64

HandleHeight determines if previousHeight height needs to be kept for pruning at the right interval prescribed by the pruning strategy. Returns previousHeight, if it was kept to be pruned at the next call to Prune(), 0 otherwise. previousHeight must be greater than 0 for the handling to take effect since valid heights start at 1 and 0 represents the latest height. The latest height cannot be pruned. As a result, if previousHeight is less than or equal to 0, 0 is returned.

func (*Manager) HandleHeightSnapshot

func (m *Manager) HandleHeightSnapshot(height int64)

HandleHeightSnapshot persists the snapshot height to be pruned at the next appropriate height defined by the pruning strategy. Flushes the update to disk and panics if the flush fails The input height must be greater than 0 and pruning strategy any but pruning nothing. If one of these conditions is not met, this function does nothing.

func (*Manager) LoadPruningHeights

func (m *Manager) LoadPruningHeights(db dbm.DB) error

LoadPruningHeights loads the pruning heights from the database as a crash recovery.

func (*Manager) SetOptions

func (m *Manager) SetOptions(opts types.PruningOptions)

SetOptions sets the pruning strategy on the manager.

func (*Manager) SetSnapshotInterval

func (m *Manager) SetSnapshotInterval(snapshotInterval uint64)

SetSnapshotInterval sets the interval at which the snapshots are taken.

func (*Manager) ShouldPruneAtHeight

func (m *Manager) ShouldPruneAtHeight(height int64) bool

ShouldPruneAtHeight return true if the given height should be pruned, false otherwise

type NegativeHeightsError

type NegativeHeightsError struct {
	Height int64
}

NegativeHeightsError is returned when a negative height is provided to the manager.

func (*NegativeHeightsError) Error

func (e *NegativeHeightsError) Error() string

Directories

Path Synopsis
Package mock_db is a generated GoMock package.
Package mock_db is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL