mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 19:51:02 +00:00
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:
committed by
GitHub
parent
dce20644c8
commit
ef816b089d
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user