-
Notifications
You must be signed in to change notification settings - Fork 2.6k
BABE's revert procedure #11022
BABE's revert procedure #11022
Changes from 6 commits
a80baae
a494b12
e8c1640
3e95228
cbbd61f
301f55a
2cf3e1c
71ae24d
c052a28
81f8f85
a418f81
de1ede9
41b192e
042b0ea
b9d1549
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ use crate::{ | |
| use clap::Parser; | ||
| use sc_client_api::{Backend, UsageProvider}; | ||
| use sc_service::chain_ops::revert_chain; | ||
| use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; | ||
| use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; | ||
| use std::{fmt::Debug, str::FromStr, sync::Arc}; | ||
|
|
||
| /// The `revert` command used revert the chain to a previous state. | ||
|
|
@@ -43,16 +43,27 @@ pub struct RevertCmd { | |
| pub pruning_params: PruningParams, | ||
| } | ||
|
|
||
| /// Revert handler for auxiliary data (e.g. consensus). | ||
| type AuxRevertHandler<B> = Box<dyn FnOnce(NumberFor<B>) -> error::Result<()>>; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The aux data revert can be made atomic by returning a This vector has the same purpose of The only drawback is that currently the blockchain state is reverted one block at a time (see here). If we want an "atomic" revert of "aux-data + blockchain-state" then we will have to call
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am surprised we do not support begin/commit/rollback transaction for batching multiple mutations across aux and main state storage already. |
||
|
|
||
| impl RevertCmd { | ||
| /// Run the revert command | ||
| pub async fn run<B, BA, C>(&self, client: Arc<C>, backend: Arc<BA>) -> error::Result<()> | ||
| pub async fn run<B, BA, C>( | ||
| &self, | ||
| client: Arc<C>, | ||
| backend: Arc<BA>, | ||
| aux_revert: Option<AuxRevertHandler<B>>, | ||
| ) -> error::Result<()> | ||
| where | ||
| B: BlockT, | ||
| BA: Backend<B>, | ||
| C: UsageProvider<B>, | ||
| <<<B as BlockT>::Header as HeaderT>::Number as FromStr>::Err: Debug, | ||
| { | ||
| let blocks = self.num.parse()?; | ||
| if let Some(aux_revert) = aux_revert { | ||
| aux_revert(blocks)?; | ||
| } | ||
| revert_chain(client, backend, blocks)?; | ||
|
|
||
| Ok(()) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.