Remove discarded blocks and states from database by default (#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 <git@kchr.de>

* 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 <git@kchr.de>

* Update client/cli/src/params/pruning_params.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update doc.

* Change `new_test_with_tx_storage` to take `BlocksPruning`.

* Fmt

Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
ZhiYong
2022-09-26 15:46:59 +08:00
committed by GitHub
parent 6fee4cb3f2
commit 11fa9af104
10 changed files with 211 additions and 58 deletions
+3 -2
View File
@@ -26,7 +26,7 @@ pub use sc_client_api::{
execution_extensions::{ExecutionExtensions, ExecutionStrategies},
BadBlocks, ForkBlocks,
};
pub use sc_client_db::{self, Backend};
pub use sc_client_db::{self, Backend, BlocksPruning};
pub use sc_executor::{self, NativeElseWasmExecutor, WasmExecutionMethod};
pub use sc_service::{client, RpcHandlers};
pub use sp_consensus;
@@ -102,7 +102,8 @@ impl<Block: BlockT, ExecutorDispatch, G: GenesisInit>
/// Create new `TestClientBuilder` with default backend and storage chain mode
pub fn with_tx_storage(blocks_pruning: u32) -> Self {
let backend = Arc::new(Backend::new_test_with_tx_storage(blocks_pruning, 0));
let backend =
Arc::new(Backend::new_test_with_tx_storage(BlocksPruning::Some(blocks_pruning), 0));
Self::with_backend(backend)
}
}