Skip to content
New issue

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

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

Already on GitHub? # to your account

[Pruning] Support pruned chains in RPC & QT wallet #2977

Merged
merged 4 commits into from
Oct 2, 2020

Conversation

SergiySW
Copy link
Contributor

Splitting #2881

  • 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”.
  • QT wallet history support for pruned chains

Splitting nanocurrency#2881

* 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”.
* QT wallet history support for pruned chains
@SergiySW SergiySW added enhancement rpc refactor breaking Change to node APIs (separate label) which impacts existing implementation, integrations impacted. labels Sep 24, 2020
@SergiySW SergiySW added this to the V22.0 milestone Sep 24, 2020
@SergiySW SergiySW self-assigned this Sep 24, 2020
wezrule
wezrule previously approved these changes Sep 25, 2020
@guilhermelawless guilhermelawless added rpc Changes related to Remote Procedure Calls and removed rpc refactor labels Sep 25, 2020
@SergiySW SergiySW added the documentation This item indicates the need for or supplies updated or expanded documentation label Oct 2, 2020
@SergiySW SergiySW merged commit 8462acb into nanocurrency:develop Oct 2, 2020
SergiySW added a commit that referenced this pull request Nov 6, 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 (#2946).

RPC, CLI and other changes
- Several RPC calls are modified to support pruned blocks related to main request block (#2977).
- 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 (#2977).
- Same as above for QT wallet history (#2977).
- 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” (#2977).
- Block count for CLI/RPC/telemetry is sum of full blocks & pruned blocks (#2977).
- RPC "pruned_exists" to chekc pruned block existence in local database.

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 (#2947).
- Pruned node can serve as bootstrap server for remaining blocks in ledger (#2976).
- Multiple internal functions are modified to use pruned blocks in block processor (#2974), internal node wallet actions (#2992), confirmation height processor (#2978) and rep crawler (#2975).
- Development: consider using ledger safe functions for code with possible pruned blocks (#2968).

Additional updates being reviewed
- Include pruned count in telemetry.
- Improve RocksDB pruned block count calculation.

Co-authored-by: Wesley Shillingford <650038+wezrule@users.noreply.github.com>
Co-authored-by: Guilherme Lawless <guilherme@nano.org>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
breaking Change to node APIs (separate label) which impacts existing implementation, integrations impacted. documentation This item indicates the need for or supplies updated or expanded documentation enhancement rpc Changes related to Remote Procedure Calls
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants