-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Remove discarded blocks and states from database by default #11983
Remove discarded blocks and states from database by default #11983
Conversation
2.Make PruningMode's default value to ArchiveCanonical.
| .as_ref() | ||
| .map(|s| match s.as_str() { | ||
| "archive" => Ok(PruningMode::ArchiveAll), | ||
| "canonical" => Ok(PruningMode::ArchiveCanonical), |
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.
"canonical" is more of an internal concept, and not a user friendly term. Let's call it "final" or "finalized"
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.
Ok , Let's set it "final".
|
There's no need to change the defult pruning mode. It should remain at 256 block history. |
|
Regarding #11912, adding a CLI for |
Well , I'll rethink where to start... |
|
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions. |
… Corresponds to `blocks_pruning 0` in CLI . 2.Change value `All` to `AllFinalized` in `enum BlocksPruning` and make it to keep full finalized block history.
|
Looks good with some minor comments. One addition that's also required here, is that utils::remove_from_db(
transaction,
&*self.storage.db,
columns::KEY_LOOKUP,
columns::JUSTIFICATIONS,
id,
)?; |
Done. |
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.
Looks good to me. Just got some question suggestion for the Cli and maybe using different names, but did not really have any good ideas.
| /// otherwise, the state can be kept for all of the blocks (i.e 'archive'), | ||
| /// or for all of the canonical blocks (i.e 'archive-canonical'). | ||
| #[clap(alias = "pruning", long, value_name = "PRUNING_MODE")] | ||
| pub state_pruning: Option<String>, |
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.
| .as_ref() | ||
| .map(|s| match s.as_str() { | ||
| "archive" => Ok(PruningMode::ArchiveAll), | ||
| "final" => Ok(PruningMode::ArchiveCanonical), |
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.
In the doc there is also a "archive-canonical" mention that did not look linked, I would maybe use it instead of "final".
But tbh I did not find a good name. Since it is the new default it should be shorter or more attractive than 'archive', but 'final' is not really saying much to me.
If anybody got other ideas?
(ideally former 'archive' becomes 'archive-all' and 'final' wil be 'archive', but it breaks compatibility)
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.
Yeah, it should be called archive-canonical
| /// Specify the number of finalized blocks to keep in the database. | ||
| /// | ||
| /// Default is to keep all blocks. | ||
| /// Default is to keep all of finalized blocks. |
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.
Here we should add that 0 keep all blocks.
Generally this is not very intuitive.
Maybe we should do something like state_pruning: use the same string: 'archive' for 'keep_all' and 'final' fo 'keep_finalized'. (subject to change of name too).
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.
Hmm,,It's really not very intuitive that 0 keep all blocks. IMO it's a compromise approach now.
I agree that change blocks_pruning to be like state_pruning.
| columns::KEY_LOOKUP, | ||
| columns::JUSTIFICATIONS, | ||
| id, | ||
| )?; |
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.
May be worth mentioning in release note that justification are now pruned with block (additionally to the new parameters).
But looks like a good thing to me 👍
bkchr
left a comment
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.
Generally looking good. However, there is no test.
| .as_ref() | ||
| .map(|s| match s.as_str() { | ||
| "archive" => Ok(PruningMode::ArchiveAll), | ||
| "final" => Ok(PruningMode::ArchiveCanonical), |
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.
Yeah, it should be called archive-canonical
| /// Get the block pruning value from the parameters | ||
| pub fn blocks_pruning(&self) -> error::Result<BlocksPruning> { | ||
| Ok(match self.blocks_pruning { | ||
| Some(0) => BlocksPruning::KeepAll, |
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.
Okay that is relative random. That this switches to KeepAll when you give it 0.
Maybe we should not expose KeepAll at all. Or we really need to introduce some new cli flag.
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.
what do you think about that change blocks_pruning to be like state_pruning : use the string keep-all for BlocksPruning::KeepAll and keep-finalized(and default) for BlocksPruning::KeepFinalized ?
And IMO ,It may help to keep the style consistent with state_pruning and be better to be understood .
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.
Using same naming would be good IMO.
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.
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.
And then a number of BlocksPruning::Some(x)?
Sounds good.
yeah, I added before. :D |
Co-authored-by: Bastian Köcher <[email protected]>
| /// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to document the options available.
client/db/src/lib.rs
Outdated
| /// Same function as `new_test_with_tx_storage`,just change the type of `blocks_pruning` to | ||
| /// `BlocksPruning`. | ||
| #[cfg(any(test, feature = "test-helpers"))] | ||
| pub fn new_test_with_tx_storage_2( |
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.
Can we not just change new_test_with_tx_storage to take BlocksPruning by default?
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.
Hmm,,I think that will work too.
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
|
Ty @hzy1919 |
|
bot merge |
|
Error: "Check reviews" status is not passing for paritytech/cumulus#1613 |
|
bot merge |
…ch#11983) * 1.Add pruning param "canonical" in sc-cli. 2.Make PruningMode's default value to ArchiveCanonical. * Update tests in sc-state-db. * Update tests in sc-state-db. * 1.Add a new value `AllWithNonFinalized` in `enum BlocksPruning` which Corresponds to `blocks_pruning 0` in CLI . 2.Change value `All` to `AllFinalized` in `enum BlocksPruning` and make it to keep full finalized block history. * Make some corresponding adjustments based on the content in the conversation. * Update client/db/src/lib.rs Co-authored-by: Bastian Köcher <[email protected]> * Apply suggestions from code review. * 1.Change `blocks_pruning` to be like `state_pruning` . * Fmt and add some doc. * Update client/cli/src/params/pruning_params.rs Co-authored-by: Bastian Köcher <[email protected]> * Update client/cli/src/params/pruning_params.rs Co-authored-by: Bastian Köcher <[email protected]> * Update doc. * Change `new_test_with_tx_storage` to take `BlocksPruning`. * Fmt Co-authored-by: Bastian Köcher <[email protected]>
|
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/polkadot-release-analysis-v0-9-39/2277/1 |
Fixes #11912
1.Add
state_pruning's sub-paramarchive-canonicalin sc-cli.2.Change
blocks_pruningto be likestate_pruning: use the stringarchiveforBlocksPruning::KeepAllandarchive-canonical(and default) forBlocksPruning::KeepFinalizedand then a number of BlocksPruning::Some(x).polkadot companion: paritytech/polkadot#5992
cumulus companion: paritytech/cumulus#1613
Closes: #12094