pruning

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 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) GetOptions

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

GetOptions fetches the pruning strategy from the manager.

func (*Manager) GetPruningHeight

func (m *Manager) GetPruningHeight(height int64) int64

GetPruningHeight returns the height which can prune upto if it is able to prune at the given height.

func (*Manager) HandleSnapshotHeight

func (m *Manager) HandleSnapshotHeight(height int64)

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

func (*Manager) LoadSnapshotHeights

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

LoadSnapshotHeights loads the snapshot 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.

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

Jump to

Keyboard shortcuts

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