-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
Please consider to pull latest |
@@ -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<()>>; |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
Looks Good to me!
Regarding this - If for any reason we fail after reverting the BABE structures and end up in an inconsistent node state, we should still be able to re-execute the revert right? |
YES, you can retry. The BABE's "revert" procedure fails only if it cannot find the header of the block we are reverting to (and the headers are still there), so the procedure can be re-executed. The second time the BABE's "revert" procedure is run, no node will be deleted and it will then re-try blockchain state revert. As said, because blockchain-state and BABE revert is not atomic, the only caveat is if the first pass of BABE's "revert" deleted some epoch nodes then the chain state is inconsistent until the blockchain-state is reverted as well. |
@@ -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<()>>; |
There was a problem hiding this comment.
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.
LGTM, just left some minor comments regarding the |
bot merge |
cumulus: 4e95228 polkadot: 975e780ae0d988dc033f400ba822d14b326ee5b9 substrate: 89fcb3e4f62d221d4e161a437768e77d6265889e bump serde_json to 1.0.79 sync changes from paritytech/substrate#11022 Signed-off-by: acatangiu <[email protected]>
cumulus: b468d0c polkadot: 827792ca833396c82c726eda0bc2ad32ecddba73 substrate: 666f39b8a22108f57732215de006518738034ba2 bump serde_json to 1.0.79 sync changes from paritytech/substrate#11022 Signed-off-by: acatangiu <[email protected]>
cumulus: b468d0c polkadot: 827792ca833396c82c726eda0bc2ad32ecddba73 substrate: 666f39b8a22108f57732215de006518738034ba2 bump serde_json to 1.0.79 sync changes from paritytech/substrate#11022 fixed clippy warnings Signed-off-by: acatangiu <[email protected]>
* First rough draft for BABE revert * Proper babe revert test * Cleanup * Test trivial cleanup * Fix to make clippy happy * Check polkadot companion * Check cumulus companion * Remove babe's blocks weight on revert * Handle "empty" blockchain edge case * Run companions * Simplify the filter predicate * Saturating sub is not required * Run pipeline * Run pipeline again...
* First rough draft for BABE revert * Proper babe revert test * Cleanup * Test trivial cleanup * Fix to make clippy happy * Check polkadot companion * Check cumulus companion * Remove babe's blocks weight on revert * Handle "empty" blockchain edge case * Run companions * Simplify the filter predicate * Saturating sub is not required * Run pipeline * Run pipeline again...
* First rough draft for BABE revert * Proper babe revert test * Cleanup * Test trivial cleanup * Fix to make clippy happy * Check polkadot companion * Check cumulus companion * Remove babe's blocks weight on revert * Handle "empty" blockchain edge case * Run companions * Simplify the filter predicate * Saturating sub is not required * Run pipeline * Run pipeline again...
cumulus: b468d0c polkadot: 827792ca833396c82c726eda0bc2ad32ecddba73 substrate: 666f39b8a22108f57732215de006518738034ba2 bump serde_json to 1.0.79 sync changes from paritytech/substrate#11022 fixed clippy warnings Signed-off-by: acatangiu <[email protected]>
* First rough draft for BABE revert * Proper babe revert test * Cleanup * Test trivial cleanup * Fix to make clippy happy * Check polkadot companion * Check cumulus companion * Remove babe's blocks weight on revert * Handle "empty" blockchain edge case * Run companions * Simplify the filter predicate * Saturating sub is not required * Run pipeline * Run pipeline again...
* First rough draft for BABE revert * Proper babe revert test * Cleanup * Test trivial cleanup * Fix to make clippy happy * Check polkadot companion * Check cumulus companion * Remove babe's blocks weight on revert * Handle "empty" blockchain edge case * Run companions * Simplify the filter predicate * Saturating sub is not required * Run pipeline * Run pipeline again...
Partially addresses #10962
This PR addresses the rollback of BABE's data structures on "revert" command.
In particular this involves the removal of some nodes from the
EpochChanges
tree.This functionality is mostly provided via the
ForkTree
newfilter
method.Given a
ForkTree
instance this method allows to remove nodes (and their subtrees) from the overall tree via apredicate
closure.The
predicate
drives the filtering behavior, in particular allows to:When used by the BABE's revert procedure, given the hash of THE block we what to revert to, the passed predicate:
ForkTree
's nodes such that THE block is an ancestor of the block that instanced such nodes (announced the epoch). These nodes (and their subtrees) are removed from the tree (leverages P1);Known limitations
Assuming a strictly monotonic machine clock, revert across more than one epoch breaks BABE's algorithm.
parent_slot
is greater than epoch descriptor start slot (see here and here)Revert is not atomic wrt blockchain state revert procedure. Currently the two procedures are independent and the blockchain state revert may fail after we successfully reverted BABE structures.
polkadot companion: paritytech/polkadot#5109
cumulus companion: paritytech/cumulus#1089