Approval voting failsafe (#2675)

* add consensus log type

* origin and issue force_approve

* add origin in runtimes

* ref API

* scrape force_approve digest from header

* add parent_hash to BlockEntry

* add block_number to block entry and force_approve skeleton

* implement and plug in force-approve

* test force_approve

* test force_approve extraction

* westend runtime

* Update node/core/approval-voting/src/approval_db/v1/mod.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* rename

* Update runtime/parachains/src/initializer.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
Robert Habermeier
2021-03-28 01:57:04 +01:00
committed by GitHub
parent dce20644c8
commit ef816b089d
10 changed files with 382 additions and 32 deletions
+15 -2
View File
@@ -20,8 +20,9 @@
//! This module can throw fatal errors if session-change notifications are received after initialization.
use sp_std::prelude::*;
use frame_support::weights::Weight;
use primitives::v1::{ValidatorId, SessionIndex};
use frame_support::weights::{Weight, DispatchClass};
use frame_support::traits::EnsureOrigin;
use primitives::v1::{ValidatorId, SessionIndex, ConsensusLog, BlockNumber};
use frame_support::{
decl_storage, decl_module, decl_error, traits::{OneSessionHandler, Randomness},
};
@@ -82,6 +83,8 @@ pub trait Config:
{
/// A randomness beacon.
type Randomness: Randomness<Self::Hash, Self::BlockNumber>;
/// An origin which is allowed to force updates to parachains.
type ForceOrigin: EnsureOrigin<<Self as frame_system::Config>::Origin>;
}
decl_storage! {
@@ -168,6 +171,16 @@ decl_module! {
HasInitialized::take();
}
/// Issue a signal to the consensus engine to forcibly act as though all parachain
/// blocks in all relay chain blocks up to and including the given number in the current
/// chain are valid and should be finalized.
#[weight = (0, DispatchClass::Operational)]
fn force_approve(origin, up_to: BlockNumber) {
T::ForceOrigin::ensure_origin(origin)?;
frame_system::Pallet::<T>::deposit_log(ConsensusLog::ForceApprove(up_to).into());
}
}
}
+1
View File
@@ -102,6 +102,7 @@ impl pallet_balances::Config for Test {
impl crate::initializer::Config for Test {
type Randomness = TestRandomness<Self>;
type ForceOrigin = frame_system::EnsureRoot<u64>;
}
impl crate::configuration::Config for Test { }