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

fix comments: prune ancient compatibility, add prune ancient comments #1253

Merged
merged 1 commit into from
Dec 22, 2022

Conversation

joeylichang
Copy link
Contributor

Description

This PR, optimized the behavior of the pruneancient flag, making the meaning of 'pruneancient' clearer, and fixed the compatibility issue between pruneancient flag and the snap prune-blocks tool, the changes include the following points:

  1. If set the pruneancient flag, the ${datadir}/geth/chaindata/ancient dir will be removed. Restart without the pruneancient flag, the ancient data will start with the previous point that the oldest unpruned block number. This change makes the ‘pruneancient’ clearer and better compatible with the snap prune-blocks tool.
  2. Before this PR once the pruneancient flag is set, it needs to be set every time it starts. Since the ancient data still exists, it will be regarded as part of the blockchain database, but it will destroy the continuity of the database, so the startup will fail. With the implementation of the first point, this problem is solved. There are no restrictions on whether a user enabled the pruneancient flag or not.
  3. The snap prune-blocks tool will change the frozen number, causing compatibility issues with the pruneancient flag. It is resolved by tracking the frozen number.
  4. The behavior of the pruneancient flag and the applicable audience are described in detail in code comments and command line notes.

Rationale

Some maintainers of bsc nodes feel confused by the ancient data still exists after enable the pruneancient flag, and the reserved ancient data also introduces the incompatibility with snap prune-blocks tool. It is necessary to delete ancient data that is no longer needed.

Some maintainers of bsc nodes may switch between enabling and disabling the pruneancient flag, and maybe use the snap prune-blocks tool, so they need compatibility.

The pruneancient flag adds the behavior of deleting ancient data, and the compatibility has been specifically improved, so it is necessary to describe it in detail in code comments and command line notes.

Example

NA

Changes

Notable changes:

  • delete the ancient dir in newPrunedFreezer.
  • add frozen number compatibility in NewDatabaseWithFreezer.
  • add WriteOffSetOfCurrentAncientFreezer in prunedfreezer TruncateAncients to tracking the offset for snap prune-blocks tool.

@brilliant-lx brilliant-lx added the r4r ready for review label Dec 22, 2022
@brilliant-lx brilliant-lx merged commit 3036989 into develop Dec 22, 2022
@joeylichang joeylichang deleted the prune_ancient branch September 7, 2023 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r4r ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants