Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Prev Previous commit
Next Next commit
Cleanup
  • Loading branch information
davxy committed Mar 14, 2022
commit 3e95228011917feb41d25bd08232e669261cfcac
6 changes: 2 additions & 4 deletions bin/node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,8 @@ pub fn run() -> Result<()> {
let PartialComponents { client, task_manager, backend, .. } = new_partial(&config)?;
let client_clone = client.clone();
let revert_aux = Box::new(move |blocks| {
sc_consensus_babe::revert::<node_primitives::Block, service::FullClient>(
client_clone,
blocks,
)?;
sc_consensus_babe::revert(client_clone, blocks)?;
// TODO: grandpa
Ok(())
});

Expand Down
1 change: 1 addition & 0 deletions client/cli/src/commands/revert_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ 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<()>>;
Copy link
Member Author

@davxy davxy Mar 14, 2022

Choose a reason for hiding this comment

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

The aux data revert can be made atomic by returning a Vec<(Vec<u8>, Option<Vec<u8>>)>.

This vector has the same purpose of BlockImportParams::auxiliary for block import, i.e. perform a bunch of operations on aux data atomically together with blockchain state operations.

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 AuxRevertHandler multiple times as well (once for each reverted block)

Copy link
Contributor

Choose a reason for hiding this comment

The 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 {
Expand Down