cosmos/cosmos-sdk

functional pruning strategy implementation

Closed this issue · 4 comments

Summary

We need change existing pruning code

	// Release an old version of history, if not a sync waypoint.
	previous := version - 1
	if st.numRecent < previous {
		toRelease := previous - st.numRecent
		if st.storeEvery == 0 || toRelease%st.storeEvery != 0 {
			err := st.Tree.DeleteVersion(toRelease)
			if err != nil && err.(cmn.Error).Data() != iavl.ErrVersionDoesNotExist {
				panic(err)
			}
		}
	}

into proposal here https://docs.google.com/document/d/15MFsQtNA0MGBv7F096FFWRDzQ1vR6_dics5Y49vF8JU/edit?usp=sharing:

	type PruningStrategy interface {
		Prune(version, latestVersion uint64) bool
	}

	func (tree *VersionTree) Prune(ps PruningStrategy) {
	for _, v := tree.versions {
		if ps.Prune(v, tree.latestVersion) {
			tree.DeleteVersion(v)
		}
	}

To support more flexible app pruning logic. This is required by our application's state syncing. (we only save some state once per day, (height between two days might different), we need make those height syncable.

Problem Definition

Proposal


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

performance is biggest concern, if in the end of day it's turn out to be an issue, we might can still only check numRecent (make it configurable) versions

@ackratos Thank you very much for looking into this! We def need some more configurability here.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

this was recently refactored for store v1.