Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Remove the --unsafe-pruning CLI-argument (step 1) #10995

Conversation

RGafiyatullin
Copy link
Contributor

@RGafiyatullin RGafiyatullin commented Mar 8, 2022

This PR addresses the #8103.

It does not remove CLI-argument completely in order not to break the existing scripts that may use this argument.
Instead it emits a warning when the argument is used. Other than that the argument will take no effect on the execution.

NB: It will be necessary to remove any notion of unsafe-pruning in further releases.

cumulus companion: paritytech/cumulus#1162
polkadot companion: paritytech/polkadot#5446

@RGafiyatullin RGafiyatullin added A0-please_review Pull request needs code review. B3-apinoteworthy C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Mar 8, 2022
@RGafiyatullin RGafiyatullin added this to In Progress in SDK Node (deprecated) via automation Mar 8, 2022
@RGafiyatullin RGafiyatullin marked this pull request as ready for review March 8, 2022 20:47
Copy link
Member

@davxy davxy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

SDK Node (deprecated) automation moved this from In Progress to Reviewed Mar 9, 2022
Copy link
Contributor

@wigy-opensource-developer wigy-opensource-developer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the one annoying rustdoc lint it looks fine. The issue #8103 stays open until step 2, I guess.

Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't include the required changes regarding continue working as archive node for validators, but new validator nodes should start as pruned node. So, that we don't change any behavior. (The same applies, if you already used unsafe pruning you just continue working as pruned node)

SDK Node (deprecated) automation moved this from Reviewed to In Progress Mar 9, 2022
@wigy-opensource-developer wigy-opensource-developer dismissed their stale review March 9, 2022 09:58

Read the original issue 😊

@RGafiyatullin RGafiyatullin marked this pull request as draft March 28, 2022 12:23
@RGafiyatullin
Copy link
Contributor Author

The PR summary:

  • the CLI argument --pruning archive|<block-num> is exposed to the application as Option<PruningMode> (as opposed to previously used PruningMode);
  • the sc-client-database::Backend and sc-state-db::StateDb are aware when they are initialised for the first time:
    • an explicit argument should_init: bool is passed to the constructors;
    • the latter argument's value is decided upon the attempt to open the underlying dyn Database;
    • for the test-database DatabaseSource::Custom the flag should_init is to be passed explicitely;
  • the StateDb stores the value of the PruningMode that was last to be successfully used;
  • the StateDb instead of the pruning_mode: PruningMode argument accepts requested_pruning_mode: Option<PruningMode>
    • that argument's value reflects the --pruning CLI-argument closely;
    • the actual pruning-mode that would be used is decided like that
// client/state-db/src/lib.rs: StateDb::open(...)
let (should_update_meta, selected_mode) = match (should_init, stored_mode, requested_mode) ...

@RGafiyatullin RGafiyatullin marked this pull request as ready for review April 4, 2022 21:42
@RGafiyatullin

This comment was marked as resolved.

@RGafiyatullin

This comment was marked as resolved.

client/db/Cargo.toml Outdated Show resolved Hide resolved
client/db/src/state_db_meta.rs Outdated Show resolved Hide resolved
client/db/src/lib.rs Outdated Show resolved Hide resolved
client/cli/src/config.rs Outdated Show resolved Hide resolved
client/cli/src/params/pruning_params.rs Outdated Show resolved Hide resolved
client/state-db/src/lib.rs Outdated Show resolved Hide resolved
client/state-db/src/lib.rs Outdated Show resolved Hide resolved
client/state-db/src/lib.rs Show resolved Hide resolved
client/state-db/src/lib.rs Outdated Show resolved Hide resolved
client/state-db/src/lib.rs Outdated Show resolved Hide resolved
@RGafiyatullin RGafiyatullin requested a review from bkchr May 5, 2022 08:59
Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ty!

Looks good besides some last nitpicks.

Comment on lines 784 to 787
if client.requires_full_sync() &&
!matches!(config.network.sync_mode, sc_network::config::SyncMode::Full)
{
return Err("The backend settings require the full-sync mode".into())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if client.requires_full_sync() &&
!matches!(config.network.sync_mode, sc_network::config::SyncMode::Full)
{
return Err("The backend settings require the full-sync mode".into())
if client.requires_full_sync() {
match config.network.sync_mode {
SyncMode::Fast { .. } => return Err("Fast sync doesn't work for archive nodes".into()),
SyncMode::Warp => return Err("Warp sync doesn't work for archive nodes".into()),
SyncMode::Full => {},
};

I think these error messages are little bit more clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those wordings are definitely more clear, but they just happen to tell the truth with the current implementation of requires_full_sync(&self) -> bool.

Perhaps the "question" to the client should be formulated as is_archive_node(&self) -> bool in that case...

(I couldn't expose the exact PruningMode via any of the sc-client-api interfaces because I didn't see it fit to add another dependency to that crate: either sc-state-db or sc-client-db).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those wordings are definitely more clear, but they just happen to tell the truth with the current implementation of requires_full_sync(&self) -> bool.

Perhaps the "question" to the client should be formulated as is_archive_node(&self) -> bool in that case...

Yes that is being correct. I mean we could change the error message to not contain for archive nodes and replace that with something like "when the backed requires full sync mode".

Or we expose the pruning mode to make it work like before.

client/state-db/src/lib.rs Outdated Show resolved Hide resolved
client/state-db/src/lib.rs Outdated Show resolved Hide resolved
@RGafiyatullin
Copy link
Contributor Author

bot merge

@paritytech-processbot paritytech-processbot bot merged commit 43d8c87 into paritytech:master May 6, 2022
paritytech-processbot bot pushed a commit to paritytech/polkadot that referenced this pull request May 6, 2022
* Add BlockBackend::requires_full_sync() implementation

* do not specify --pruning explicitly

* update lockfile for {"substrate"}

* Please re-run the CI

* Please re-run the CI

Co-authored-by: Roman Gafiyatullin <rg@rgmbp-16-m1.lan>
Co-authored-by: parity-processbot <>
paritytech-processbot bot pushed a commit to paritytech/cumulus that referenced this pull request May 6, 2022
* Substrate API change: paritytech/substrate#8103

* fix fallout of paritytech/polkadot#5454

* update lockfile for {"polkadot"}

Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>
Co-authored-by: parity-processbot <>
godcodehunter pushed a commit to sensoriumxr/substrate that referenced this pull request Jun 22, 2022
* sc-client-db: utils::open_database(...) — return OpenDbError so that the caller could tell the `OpenDbError::DoesNotExist` clearly

* sc-client-db: utils::open_database(..) — accept the `create: bool` argument

* sc-client-db: pruning — optional argument in the DatabaseSettings

* sc-state-db: Split `Error<E>` into separate `Error<E>` and `StateDbError`

* StateDb::open: choose the pruning-mode depending on the requested and stored values

* sc-state-db: test for different combinations of stored and requested pruning-modes

* CLI-argument: mark the unsafe-pruning as deprecated

* Fix tests

* tests: do not specify --pruning when running the substrate over the existing storage

* fix types for benches

* cargo fmt

* Check whether the pruning-mode and sync-mode are compatible

* cargo fmt

* parity-db: 0.3.11 -> 0.3.12

* sc-state-db: MetaDb::set_meta — a better doc-test

* cargo fmt

* make MetaDb read-only again!

* Remove the stray newline (and run the CI once again please)

* Last nitpicks

* A more comprehensive error message
DaviRain-Su pushed a commit to octopus-network/substrate that referenced this pull request Aug 23, 2022
* sc-client-db: utils::open_database(...) — return OpenDbError so that the caller could tell the `OpenDbError::DoesNotExist` clearly

* sc-client-db: utils::open_database(..) — accept the `create: bool` argument

* sc-client-db: pruning — optional argument in the DatabaseSettings

* sc-state-db: Split `Error<E>` into separate `Error<E>` and `StateDbError`

* StateDb::open: choose the pruning-mode depending on the requested and stored values

* sc-state-db: test for different combinations of stored and requested pruning-modes

* CLI-argument: mark the unsafe-pruning as deprecated

* Fix tests

* tests: do not specify --pruning when running the substrate over the existing storage

* fix types for benches

* cargo fmt

* Check whether the pruning-mode and sync-mode are compatible

* cargo fmt

* parity-db: 0.3.11 -> 0.3.12

* sc-state-db: MetaDb::set_meta — a better doc-test

* cargo fmt

* make MetaDb read-only again!

* Remove the stray newline (and run the CI once again please)

* Last nitpicks

* A more comprehensive error message
WebWizrd8 added a commit to WebWizrd8/cumulus that referenced this pull request Nov 21, 2022
* Substrate API change: paritytech/substrate#8103

* fix fallout of paritytech/polkadot#5454

* update lockfile for {"polkadot"}

Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>
Co-authored-by: parity-processbot <>
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
* sc-client-db: utils::open_database(...) — return OpenDbError so that the caller could tell the `OpenDbError::DoesNotExist` clearly

* sc-client-db: utils::open_database(..) — accept the `create: bool` argument

* sc-client-db: pruning — optional argument in the DatabaseSettings

* sc-state-db: Split `Error<E>` into separate `Error<E>` and `StateDbError`

* StateDb::open: choose the pruning-mode depending on the requested and stored values

* sc-state-db: test for different combinations of stored and requested pruning-modes

* CLI-argument: mark the unsafe-pruning as deprecated

* Fix tests

* tests: do not specify --pruning when running the substrate over the existing storage

* fix types for benches

* cargo fmt

* Check whether the pruning-mode and sync-mode are compatible

* cargo fmt

* parity-db: 0.3.11 -> 0.3.12

* sc-state-db: MetaDb::set_meta — a better doc-test

* cargo fmt

* make MetaDb read-only again!

* Remove the stray newline (and run the CI once again please)

* Last nitpicks

* A more comprehensive error message
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. D2-breaksapi D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
Status: done
Development

Successfully merging this pull request may close these issues.

None yet

7 participants