mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 23:18:01 +00:00
ea5d8662be
* Add skeleton for `pallet-finality-verifier` * Sketch out implementation for importing finality proofs * Get pallet compiling * Introduce skeleton for mock runtime * Start using real Grandpa types in finality pallet * Redefine types in header chain primitives crate * Implement HeaderChain for Substrate bridge pallet * Plug Substrate Bridge Pallet into verifier mock * Fix compilation of `header-chain` primitives * Start writing to base pallet storage * Add first "cross-pallet" test * Move keyring primitives used in tests to shared crate * Stop pulling `std` deps into `no_std` builds * Revert "Stop pulling `std` deps into `no_std` builds" This reverts commit f74dd660652f98b7336936d1534a4e63cc9169a5. * Revert "Move keyring primitives used in tests to shared crate" This reverts commit b774fa730b2cdc40545afff308a66b0840266001. * Use new SS58Prefix type in mock * Start using `bp-test-utils` in finality pallet * Start using real justification code * Get a test working with real justification verification * Add basic tests for invalid proofs * Get rid of AncestryProof config type * Add error types to transaction outcome * Bound number of headers allowed in a single ancestry proof * Disallow invalid authority sets * Remove unused items * Add some documentation * Get rid of Clippy warnings * Rename BaseHeaderChain to TransactionVerifier * Remove unused code * Make dummy trait implementations more generic * Fix more Clippy complaints * Update tests to use fix for duplicate headers * Fix benchmarking compilation * Rename TransactionVerifier to InclusionProofVerifier
81 lines
3.2 KiB
Rust
81 lines
3.2 KiB
Rust
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
|
|
// This file is part of Parity Bridges Common.
|
|
|
|
// Parity Bridges Common is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// Parity Bridges Common is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//! Storage primitives for the Substrate light client (a.k.a bridge) pallet.
|
|
|
|
use bp_header_chain::AuthoritySet;
|
|
use codec::{Decode, Encode};
|
|
use core::default::Default;
|
|
#[cfg(feature = "std")]
|
|
use serde::{Deserialize, Serialize};
|
|
use sp_finality_grandpa::{AuthorityList, SetId};
|
|
use sp_runtime::traits::Header as HeaderT;
|
|
use sp_runtime::RuntimeDebug;
|
|
|
|
/// Data required for initializing the bridge pallet.
|
|
///
|
|
/// The bridge needs to know where to start its sync from, and this provides that initial context.
|
|
#[derive(Default, Encode, Decode, RuntimeDebug, PartialEq, Clone)]
|
|
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
|
pub struct InitializationData<H: HeaderT> {
|
|
/// The header from which we should start syncing.
|
|
pub header: H,
|
|
/// The initial authorities of the pallet.
|
|
pub authority_list: AuthorityList,
|
|
/// The ID of the initial authority set.
|
|
pub set_id: SetId,
|
|
/// The first scheduled authority set change of the pallet.
|
|
pub scheduled_change: Option<ScheduledChange<H::Number>>,
|
|
/// Should the pallet block transaction immediately after initialization.
|
|
pub is_halted: bool,
|
|
}
|
|
|
|
/// Keeps track of when the next GRANDPA authority set change will occur.
|
|
#[derive(Default, Encode, Decode, RuntimeDebug, PartialEq, Clone)]
|
|
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
|
pub struct ScheduledChange<N> {
|
|
/// The authority set that will be used once this change is enacted.
|
|
pub authority_set: AuthoritySet,
|
|
/// The block height at which the authority set should be enacted.
|
|
///
|
|
/// Note: It will only be enacted once a header at this height is finalized.
|
|
pub height: N,
|
|
}
|
|
|
|
/// A more useful representation of a header for storage purposes.
|
|
#[derive(Default, Encode, Decode, Clone, RuntimeDebug, PartialEq)]
|
|
pub struct ImportedHeader<H: HeaderT> {
|
|
/// A plain Substrate header.
|
|
pub header: H,
|
|
/// Does this header enact a new authority set change. If it does
|
|
/// then it will require a justification.
|
|
pub requires_justification: bool,
|
|
/// Has this header been finalized, either explicitly via a justification,
|
|
/// or implicitly via one of its children getting finalized.
|
|
pub is_finalized: bool,
|
|
/// The hash of the header which scheduled a change on this fork. If there are currently
|
|
/// not pending changes on this fork this will be empty.
|
|
pub signal_hash: Option<H::Hash>,
|
|
}
|
|
|
|
impl<H: HeaderT> core::ops::Deref for ImportedHeader<H> {
|
|
type Target = H;
|
|
|
|
fn deref(&self) -> &H {
|
|
&self.header
|
|
}
|
|
}
|