From 356d1a35a1b860656b4ef14993acdc09a1842f18 Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Thu, 5 Jan 2023 02:54:47 +0800 Subject: [PATCH 1/2] Add keep-blocks archive params --- ...uning_works.rs => remember_pruning_works.rs} | 17 +++++++++++++++++ .../frame/benchmarking-cli/src/block/README.md | 4 +++- utils/frame/benchmarking-cli/src/block/cmd.rs | 2 +- .../frame/benchmarking-cli/src/shared/README.md | 1 + 4 files changed, 22 insertions(+), 2 deletions(-) rename bin/node/cli/tests/{remember_state_pruning_works.rs => remember_pruning_works.rs} (72%) 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..2f0b08e787757 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 `--state-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. From c622b3accbc9cd6a63dab96ae5200e1eb6764876 Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Thu, 5 Jan 2023 11:08:08 +1300 Subject: [PATCH 2/2] Update bin/node/cli/tests/remember_pruning_works.rs --- bin/node/cli/tests/remember_pruning_works.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/node/cli/tests/remember_pruning_works.rs b/bin/node/cli/tests/remember_pruning_works.rs index 2f0b08e787757..57fe6e29179b5 100644 --- a/bin/node/cli/tests/remember_pruning_works.rs +++ b/bin/node/cli/tests/remember_pruning_works.rs @@ -42,7 +42,7 @@ async fn remember_state_pruning_works() { async fn remember_blocks_pruning_works() { let base_path = tempdir().expect("could not create a temp dir"); - // First run with `--state-pruning=archive`. + // First run with `--blocks-pruning=archive`. common::run_node_for_a_while( base_path.path(), &["--dev", "--blocks-pruning=archive", "--no-hardware-benchmarks"],