Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental ledger pruning #2881

Merged
merged 125 commits into from
Nov 6, 2020

Conversation

SergiySW
Copy link
Contributor

@SergiySW SergiySW commented Aug 13, 2020

This is the initial, experimental implementation of pruning, related to #1094. Node ledger pruning is designed to safely discard parts of the ledger. Now ledger size can be reduced from 23.8 GB to 7.5GB after vacuum. And from 18.8 GB to 5.2 GB after database rebuild.

Configuration and considerations

  • This version of ledger pruning is for experimental use only:
  • Enable optional ledger pruning with node CLI --debug_prune for manual pruning & node launch flag --enable_pruning for automatic node background actions.
  • Pruning rules can be configured in [node.experimental] config with “max_pruning_age” (Time in seconds to limit for blocks age after pruning. Also period for automatic node pruning task, default 1 day, 5 minutes for beta network) & “max_pruning_depth” (Limit for full blocks in chain after pruning, default 0 - unlimited). By default all confirmed blocks older than 1 day can be pruned, except genesis block & last confirmed block in each account chain.
  • Last confirmed block in account chain & all unconfirmed blocks cannot be pruned from ledger. Pruning is relying on confirmation height, so confirmation height reset or too low online_weight_minimum config can cause issues.
  • Pruned blocks hashes are located in database table “pruned” & can be used by node internally ([Pruning] Basic pruning blocks storage & database upgrade #2946).

RPC, CLI and other changes

Other notes

Additional updates being reviewed

  • Include pruned count in telemetry.
  • Improve RocksDB pruned block count calculation.

Configuration and considerations
- This version of ledger pruning is for experimental use only:
- Enable optional ledger pruning with node CLI --debug_prune for manual pruning & node launch flag --enable_pruning for automatic node background actions.
- Pruning rules can be configured in [node.experimental] config with “max_pruning_age” (Time in seconds to limit for blocks age after pruning. Also period for automatic node pruning task, default 1 day) & “max_pruning_depth” (Limit for full blocks in chain after pruning, default 0 - unlimited). By default all confirmed blocks older than 1 day can be pruned, except genesis block & last confirmed block in each account chain.
- Last confirmed block in account chain & all unconfirmed blocks cannot be pruned from ledger. Pruning is relying on confirmation height, so confirmation height reset or too low online_weight_minimum config can cause issues.
- Pruned blocks hashes are located in database table “pruned” & can be used by node internally. There is no specific RPC call to check pruned block existence, but we can add it if necessary.

RPC, CLI and other changes
- Several RPC calls are modified to support pruned blocks related to main request block.
- RPC “history”: if previous block is pruned, “amount” field is not returned for all blocks, “account” field is not returned for state blocks, also state block type/subtype is “unknown” . If source is pruned, then “account” field is not returned for receive/open legacy & for receive/open state blocks.
- RPC “block_info”/“blocks_info”: if previous block is pruned, “amount” field is not returned. RPC “block_count”: for nodes with enabled pruning returns 2 new fields: “full” blocks & “pruned” blocks. “full” + “pruned” = total “blocks”.
- Block count for CLI/RPC/telemetry is sum of full blocks & pruned blocks.

Other notes
- Node is aggressively pruning ledger during initial bootstrap (until hardcoded block count) to limit node disk space usage, pruning config settings are ignored. If you want to avoid this behavior, finish full bootstrap before pruning start.
-  --enable_pruning flag & config option “enable_voting” are mutually exclusive to prevent representatives start with pruned ledger. Pruning is not available for any representatives.

Additional updates being reviewed
- Include pruned count in telemetry.
@SergiySW SergiySW added enhancement major This item indicates the need for or supplies a major or notable change beta testing wanted rpc refactor database Relates to lmdb or rocksdb database structure If the database changes it needs updating in the nanodb repository breaking Change to node APIs (separate label) which impacts existing implementation, integrations impacted. labels Aug 13, 2020
@SergiySW SergiySW added this to the V22.0 milestone Aug 13, 2020
@SergiySW SergiySW self-assigned this Aug 13, 2020
@SergiySW SergiySW removed rpc refactor semantic Change to node APIs (separate label) which impacts interpretation of data, integrations impacted. labels Oct 12, 2020
@SergiySW SergiySW added documentation This item indicates the need for or supplies updated or expanded documentation rpc Changes related to Remote Procedure Calls labels Oct 13, 2020
wezrule
wezrule previously approved these changes Oct 14, 2020
wezrule
wezrule previously approved these changes Oct 29, 2020
@zhyatt zhyatt added this to Pending testing evaluation in V22.0DB10 via automation Nov 6, 2020
@zhyatt zhyatt moved this from Pending targeted testing to Testing deferred to future DB in V22.0DB7&8 Nov 6, 2020
@SergiySW SergiySW merged commit 8e5f426 into nanocurrency:develop Nov 6, 2020
@zhyatt zhyatt moved this from Pending testing evaluation to Pending targeted testing in V22.0DB10 Nov 9, 2020
@qwahzi qwahzi mentioned this pull request Jan 10, 2023
@qwahzi qwahzi moved this from V22.0 (Complete) to Backlog in Nano Roadmap Aug 18, 2023
@qwahzi qwahzi removed this from Research for Future in Nano Roadmap Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Changes related to the Command Line Interface documentation This item indicates the need for or supplies updated or expanded documentation enhancement major This item indicates the need for or supplies a major or notable change rpc Changes related to Remote Procedure Calls
Projects
No open projects
V22.0DB10
Pending targeted testing
V22.0DB7&8
Testing deferred to future DB
Development

Successfully merging this pull request may close these issues.

None yet

4 participants