feat: Add a cli cmd to prune old states according to current settings
Description
Closes: #12727
- a command to read pruning options and prune the history states
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.
I have...
- [ ] included the correct type prefix in the PR title
- [ ] added
!to the type prefix if API or client breaking change - [ ] targeted the correct branch (see PR Targeting)
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for building modules
- [ ] included the necessary unit and integration tests
- [ ] added a changelog entry to
CHANGELOG.md - [ ] included comments for documenting Go code
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.
I have...
- [ ] confirmed the correct type prefix in the PR title
- [ ] confirmed
!in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
Could you add a changelog entry. This is now pruning SDK, do you think its worth having something for tendermint as well.
@marbar3778 changelog entry added. I can investigate the tendermint pruning part and update the pr if necessary.
I can investigate the tendermint pruning part and update the pr if necessary.
Here is how it would be done. https://github.com/binaryholdings/cosmprund/blob/master/cmd/pruner.go#L578. But I think there is a cleaner way to do it. https://github.com/binaryholdings/cosmprund/pull/4 Here I copy the data in tendermint into a new db then replace the old db with it. The problem with these commands is they take a very long time to do because compaction is needed to reclaim the space on disk otherwise you are placing delete markers but not actually removing from disk
@marbar3778 thanks for your advice but it seems pruning tendermint db is not an urgent need for me. maybe we can come back to complete the pruning cmd for tendermint db in the future.
utACK. is there a reason we cant backport this to 0.46 and 0.45
I think it's alright to be ported to 0.46 and 0.45 without breaking change. actually I'm already doing this to test on a cronos testing db
Codecov Report
Merging #12742 (d875f88) into main (d638ca3) will increase coverage by
0.00%. The diff coverage is77.77%.
@@ Coverage Diff @@
## main #12742 +/- ##
=======================================
Coverage 53.15% 53.15%
=======================================
Files 641 641
Lines 54871 54877 +6
=======================================
+ Hits 29166 29172 +6
Misses 23382 23382
Partials 2323 2323
| Impacted Files | Coverage Δ | |
|---|---|---|
| store/rootmulti/store.go | 73.35% <76.47%> (+0.19%) |
:arrow_up: |
| simapp/simd/cmd/root.go | 70.51% <100.00%> (+0.11%) |
:arrow_up: |
Is this ready for review again?
Is this ready for review again?
yes, it's ready for another round of review.
pruning-interval: N means to delete old states from disk every Nth block.
@yihuang @alexanderbez
I was thinking that the current pruning-interval allows at most 1/2 of the old states to be pruned(except prune everything).
Could we change its semantics to keep old states every Nth block so we can have more aggressive pruning options, say prune 9/10 of the states and we can delete versions in range, which is more effective?
pruning-interval: N means to delete old states from disk every Nth block.@yihuang @alexanderbez I was thinking that the current
pruning-intervalallows at most 1/2 of the old states to be pruned(except prune everything). Could we change its semantics tokeep old states every Nth blockso we can have more aggressive pruning options, say prune 9/10 of the states and we can delete versions in range, which is more effective?
I think you can try to propose a new flag in a separate issue.
@yihuang can you re-review this please?
Shall we backport?
test-rosetta failed, maybe not related to this PR.
I have backported this to my forked release/v0.46.x and tested this command on a devnet cronos node, the result seems alright:
(base) adudu@CNMAC0342 cronos % bin/cronosd prune --home 'data/cronos_777-1/node0/' --app-db-backend 'goleveldb' --pruning 'custom' --pruning-keep-recent 10 --pruning-interval 10
get pruning options from command flags, strategy: 3, keep-recent: 10
the latest version: 89
pruning heights start from 1, end at 78
successfully pruned the application root multi stores
I have backported this to my forked release/v0.46.x and tested this command on a devnet cronos node, the result seems alright:
(base) adudu@CNMAC0342 cronos % bin/cronosd prune --home 'data/cronos_777-1/node0/' --app-db-backend 'goleveldb' --pruning 'custom' --pruning-keep-recent 10 --pruning-interval 10 get pruning options from command flags, strategy: 3, keep-recent: 10 the latest version: 89 pruning heights start from 1, end at 78 successfully pruned the application root multi stores
want to backport to 45 and 46, we can merge those quickly