This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Remove discarded blocks and states from database by default #11983
Merged
paritytech-processbot
merged 25 commits into
paritytech:master
from
hzy1919:Remove-discarded-blocks-and-states-from-database
Sep 26, 2022
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
bc5ba8e
1.Add pruning param "canonical" in sc-cli.
hzy1919 d762b63
Merge branch 'master' into Remove-discarded-blocks-and-states-from-da…
hzy1919 e425634
Update tests in sc-state-db.
hzy1919 70b21b8
Merge branch 'master' into Remove-discarded-blocks-and-states-from-da…
hzy1919 124f586
Merge branch 'master' into Remove-discarded-blocks-and-states-from-da…
hzy1919 e2c5674
Update tests in sc-state-db.
hzy1919 7bff3cb
Merge branch 'master' into Remove-discarded-blocks-and-states-from-da…
hzy1919 da0c426
Merge branch 'master' into Remove-discarded-blocks-and-states-from-da…
hzy1919 c519937
Merge branch 'master' into Remove-discarded-blocks-and-states-from-da…
hzy1919 3f03c82
1.Add a new value `AllWithNonFinalized` in `enum BlocksPruning` which…
hzy1919 940d9db
Merge branch 'master' into Remove-discarded-blocks-and-states-from-da…
hzy1919 458e078
Make some corresponding adjustments based on the content in the conve…
hzy1919 a228701
Update client/db/src/lib.rs
hzy1919 6ae25a1
Apply suggestions from code review.
hzy1919 54a5a2b
Merge branch 'master' into Remove-discarded-blocks-and-states-from-da…
hzy1919 9e3e8eb
1.Change `blocks_pruning` to be like `state_pruning` .
hzy1919 ac58113
Merge branch 'master' into Remove-discarded-blocks-and-states-from-da…
hzy1919 4c3810c
Fmt and add some doc.
hzy1919 f4ea09b
Merge branch 'master' into Remove-discarded-blocks-and-states-from-da…
hzy1919 2b0c25c
Update client/cli/src/params/pruning_params.rs
hzy1919 6cbc62e
Update client/cli/src/params/pruning_params.rs
hzy1919 df5ffec
Update doc.
hzy1919 cb62c23
Change `new_test_with_tx_storage` to take `BlocksPruning`.
hzy1919 79afe8b
Merge branch 'master' into Remove-discarded-blocks-and-states-from-da…
hzy1919 3dff0f0
Fmt
hzy1919 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,13 +30,16 @@ pub struct PruningParams { | |
/// or for all of the canonical blocks (i.e 'archive-canonical'). | ||
#[clap(alias = "pruning", long, value_name = "PRUNING_MODE")] | ||
pub state_pruning: Option<String>, | ||
/// Specify the number of finalized blocks to keep in the database. | ||
/// Specify the blocks pruning mode, a number of blocks to keep or 'archive'. | ||
/// | ||
/// Default is to keep all blocks. | ||
/// Default is to keep all finalized blocks. | ||
/// otherwise, all blocks can be kept (i.e 'archive'), | ||
/// or for all canonical blocks (i.e 'archive-canonical'), | ||
/// or for the last N blocks (i.e a number). | ||
/// | ||
/// NOTE: only finalized blocks are subject for removal! | ||
#[clap(alias = "keep-blocks", long, value_name = "COUNT")] | ||
pub blocks_pruning: Option<u32>, | ||
pub blocks_pruning: Option<String>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You also need to document the options available. |
||
} | ||
|
||
impl PruningParams { | ||
|
@@ -46,19 +49,31 @@ impl PruningParams { | |
.as_ref() | ||
.map(|s| match s.as_str() { | ||
"archive" => Ok(PruningMode::ArchiveAll), | ||
"archive-canonical" => Ok(PruningMode::ArchiveCanonical), | ||
bc => bc | ||
.parse() | ||
.map_err(|_| error::Error::Input("Invalid pruning mode specified".to_string())) | ||
.map_err(|_| { | ||
error::Error::Input("Invalid state pruning mode specified".to_string()) | ||
}) | ||
.map(PruningMode::blocks_pruning), | ||
}) | ||
.transpose() | ||
} | ||
|
||
/// Get the block pruning value from the parameters | ||
pub fn blocks_pruning(&self) -> error::Result<BlocksPruning> { | ||
Ok(match self.blocks_pruning { | ||
Some(n) => BlocksPruning::Some(n), | ||
None => BlocksPruning::All, | ||
}) | ||
match self.blocks_pruning.as_ref() { | ||
Some(bp) => match bp.as_str() { | ||
"archive" => Ok(BlocksPruning::KeepAll), | ||
"archive-canonical" => Ok(BlocksPruning::KeepFinalized), | ||
bc => bc | ||
.parse() | ||
.map_err(|_| { | ||
error::Error::Input("Invalid blocks pruning mode specified".to_string()) | ||
}) | ||
.map(BlocksPruning::Some), | ||
}, | ||
None => Ok(BlocksPruning::KeepFinalized), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc for this param should be updated with the new
final
option.