8000 [LivePruning] LivePruning switching by hyunsooda · Pull Request #2004 · klaytn/klaytn · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Aug 19, 2024. It is now read-only.

[LivePruning] LivePruning switching #2004

Merged
merged 19 commits into from
Nov 13, 2023
Merged

Conversation

hyunsooda
Copy link
Contributor
@hyunsooda hyunsooda commented Oct 23, 2023

Proposed changes

Initially, LivePruning was only available for nodes starting from the genesis block, but not for those with non-empty chaindata (current block number > genesis block). This PR now allows for easy switching between LivePruning and non-LivePruning, enabling greater flexibility. The following description explains how this feature functions.


----bz(P)---------bx(LP)---------bc(P)--------bv(LP))-------- ...
  1. S           1. SU           1. S         1. SU           
                 2. RM                        2. RM           

*LP = LivePrunign on
*bn = block Number n
*S = Store zero-exenteded hash or legacy hash
*SU = Store unique extended hash 
*RM = Remove a dirty extended hash

In the example chain, LivePruning was initially disabled. Subsequently, the node operator restarted the node with LivePruning at block number bx.

Before LivePruning, the node stored hashes with 32 bytes (legacy node) or 39 bytes (seven zero bytes). After block number bx, it switched to storing unique 39-byte hashes and began removing dirty trie nodes.

The operator later restarted the node without LivePruning at block bc, then re-enabled LivePruning at block bv. After this point, the cleaner loop only removes hashes with a unique counter, within the range of bx to bc-1 and bv to the current block. This ensures that nodes potentially referenced by others are not removed.

Usage

  • To turn on live pruning:
    ken --state.live-pruning 
    
  • To turn off live pruning:
    ken // --state.live-pruning absent
    ken --state.live-pruning  --state.live-pruning-retention=0 // exceptional case.
    

Changed
Removed database write and delete operations that indicate LivePruning enable and disable.

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Related issues

  • Please leave the issue numbers or links related to this PR here.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

8000

hyunsooda and others added 2 commits October 27, 2023 09:38
Co-authored-by: Yunjong Jeong (ollie) <jeongyoonjong@gmail.com>
blukat29
blukat29 previously approved these changes Oct 27, 2023
@blukat29
Copy link
Contributor

@jeongkyun-oh @aidan-kwon @ethan-kr PTAL

Copy link
Contributor
@hyeonLewis hyeonLewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the proposed changes, I think bx to bc-1 and bv to the current is the correct explanation. Isn't it?

@hyunsooda
Copy link
Contributor Author

@hyeonLewis, Exactly. Thank you. Updated.

blukat29
blukat29 previously approved these changes Nov 8, 2023
Co-authored-by: Yunjong Jeong (ollie) <jeongyoonjong@gmail.com>
@hyunsooda hyunsooda merged commit 3076aa7 into klaytn:dev Nov 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0