mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-24 17:11:05 +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
@@ -1064,6 +1064,43 @@ pub struct AbridgedHrmpChannel {
|
||||
pub mqc_head: Option<Hash>,
|
||||
}
|
||||
|
||||
/// Consensus engine id for polkadot v1 consensus engine.
|
||||
pub const POLKADOT_ENGINE_ID: runtime_primitives::ConsensusEngineId = *b"POL1";
|
||||
|
||||
/// A consensus log item for polkadot validation. To be used with [`POLKADOT_ENGINE_ID`].
|
||||
#[derive(Decode, Encode, Clone, PartialEq, Eq)]
|
||||
pub enum ConsensusLog {
|
||||
/// A parachain or parathread upgraded its code.
|
||||
#[codec(index = 1)]
|
||||
ParaUpgradeCode(Id, Hash),
|
||||
/// A parachain or parathread scheduled a code ugprade.
|
||||
#[codec(index = 2)]
|
||||
ParaScheduleUpgradeCode(Id, Hash, BlockNumber),
|
||||
/// Governance requests to auto-approve every candidate included up to the given block
|
||||
/// number in the current chain, inclusive.
|
||||
#[codec(index = 3)]
|
||||
ForceApprove(BlockNumber),
|
||||
}
|
||||
|
||||
impl ConsensusLog {
|
||||
/// Attempt to convert a reference to a generic digest item into a consensus log.
|
||||
pub fn from_digest_item<H>(digest_item: &runtime_primitives::DigestItem<H>)
|
||||
-> Result<Option<Self>, parity_scale_codec::Error>
|
||||
{
|
||||
match digest_item {
|
||||
runtime_primitives::DigestItem::Consensus(id, encoded) if id == &POLKADOT_ENGINE_ID =>
|
||||
Ok(Some(Self::decode(&mut &encoded[..])?)),
|
||||
_ => Ok(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<H> From<ConsensusLog> for runtime_primitives::DigestItem<H> {
|
||||
fn from(c: ConsensusLog) -> runtime_primitives::DigestItem<H> {
|
||||
Self::Consensus(POLKADOT_ENGINE_ID, c.encode())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user