diff --git a/bin/node/cli/tests/remember_state_pruning_works.rs b/bin/node/cli/tests/remember_pruning_works.rs similarity index 72% rename from bin/node/cli/tests/remember_state_pruning_works.rs rename to bin/node/cli/tests/remember_pruning_works.rs index 5b8e34cc7a00d..57fe6e29179b5 100644 --- a/bin/node/cli/tests/remember_state_pruning_works.rs +++ b/bin/node/cli/tests/remember_pruning_works.rs @@ -36,3 +36,20 @@ async fn remember_state_pruning_works() { // This should load state pruning settings from the db. common::run_node_for_a_while(base_path.path(), &["--dev", "--no-hardware-benchmarks"]).await; } + +#[tokio::test] +#[cfg(unix)] +async fn remember_blocks_pruning_works() { + let base_path = tempdir().expect("could not create a temp dir"); + + // First run with `--blocks-pruning=archive`. + common::run_node_for_a_while( + base_path.path(), + &["--dev", "--blocks-pruning=archive", "--no-hardware-benchmarks"], + ) + .await; + + // Then run again without specifying the state pruning. + // This should load state pruning settings from the db. + common::run_node_for_a_while(base_path.path(), &["--dev", "--no-hardware-benchmarks"]).await; +} diff --git a/utils/frame/benchmarking-cli/src/block/README.md b/utils/frame/benchmarking-cli/src/block/README.md index 7e99f0df9d43b..15a9e8137e773 100644 --- a/utils/frame/benchmarking-cli/src/block/README.md +++ b/utils/frame/benchmarking-cli/src/block/README.md @@ -87,7 +87,7 @@ You should see after some seconds that it started to produce blocks: ``` You can now kill the node with `Ctrl+C`. Then measure how long it takes to execute these blocks: ```sh -cargo run --profile=production -- benchmark block --from 1 --to 1 --dev -d /tmp/dev --pruning archive +cargo run --profile=production -- benchmark block --from 1 --to 1 --dev -d /tmp/dev --pruning archive --keep-blocks archive ``` This will benchmark the first block. If you killed the node at a later point, you can measure multiple blocks. ```pre @@ -105,6 +105,7 @@ Since this block is empty, its not very interesting. - `--repeat` How often each block should be measured. - [`--db`] - [`--pruning`] +- [`--keep-blocks`] License: Apache-2.0 @@ -116,3 +117,4 @@ License: Apache-2.0 [`--db`]: ../shared/README.md#arguments [`--pruning`]: ../shared/README.md#arguments +[`--keep-blocks`]: ../shared/README.md#arguments diff --git a/utils/frame/benchmarking-cli/src/block/cmd.rs b/utils/frame/benchmarking-cli/src/block/cmd.rs index 8bac04110f7ab..af2cc7db2f9eb 100644 --- a/utils/frame/benchmarking-cli/src/block/cmd.rs +++ b/utils/frame/benchmarking-cli/src/block/cmd.rs @@ -44,7 +44,7 @@ use super::bench::{Benchmark, BenchmarkParams}; /// And wait some time to let it produce 3 blocks. Then benchmark them with: /// /// $ substrate benchmark-block --from 1 --to 3 --dev -d /tmp/my-dev -/// --execution wasm --wasm-execution compiled --pruning archive +/// --execution wasm --wasm-execution compiled --pruning archive --keep-blocks archive /// /// The output will be similar to this: /// diff --git a/utils/frame/benchmarking-cli/src/shared/README.md b/utils/frame/benchmarking-cli/src/shared/README.md index 08e25b0e08f76..97999648a7fb3 100644 --- a/utils/frame/benchmarking-cli/src/shared/README.md +++ b/utils/frame/benchmarking-cli/src/shared/README.md @@ -10,6 +10,7 @@ Contains code that is shared among multiple sub-commands. - `--weight-path` Set the file or directory to write the weight files to. - `--db` The database backend to use. This depends on your snapshot. - `--pruning` Set the pruning mode of the node. Some benchmarks require you to set this to `archive`. +- `--keep-blocks` Set the pruning mode of the node. Some benchmarks require you to set this to `archive`. - `--base-path` The location on the disk that should be used for the benchmarks. You can try this on different disks or even on a mounted RAM-disk. It is important to use the same location that will later-on be used to store the chain data to get the correct results. - `--header` Optional file header which will be prepended to the weight output file. Can be used for adding LICENSE headers.