Wire Finality Verifier Pallet Into Runtimes (#696)

* Add Finality Verifier pallet to runtimes

* Implement simple ancestry checker

* Use the new checker in runtimes

* Remove unused import warning

* Bump max allowed ancestry proof size

* Add a few optimization suggestions when verifying ancestry

* Use session length as upper bound for ancestry proof size

* Remove unused time units
This commit is contained in:
Hernando Castano
2021-02-03 14:33:49 -05:00
committed by Bastian Köcher
parent d73100cb30
commit 8c7d0ca35d
9 changed files with 183 additions and 25 deletions
+16 -11
View File
@@ -132,15 +132,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
transaction_version: 1,
};
pub const MILLISECS_PER_BLOCK: u64 = 6000;
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
// These time units are defined in number of blocks.
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
pub const HOURS: BlockNumber = MINUTES * 60;
pub const DAYS: BlockNumber = HOURS * 24;
/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
@@ -236,7 +227,7 @@ impl pallet_grandpa::Config for Runtime {
}
parameter_types! {
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
pub const MinimumPeriod: u64 = bp_millau::SLOT_DURATION / 2;
}
impl pallet_timestamp::Config for Runtime {
@@ -287,7 +278,7 @@ impl pallet_sudo::Config for Runtime {
parameter_types! {
/// Authorities are changing every 5 minutes.
pub const Period: BlockNumber = 5 * MINUTES;
pub const Period: BlockNumber = bp_millau::SESSION_LENGTH;
pub const Offset: BlockNumber = 0;
}
@@ -309,6 +300,19 @@ impl pallet_substrate_bridge::Config for Runtime {
type BridgedChain = bp_rialto::Rialto;
}
parameter_types! {
// We'll use the length of a session on the bridged chain as our bound since GRANDPA is
// guaranteed to produce a justification every session.
pub const MaxHeadersInSingleProof: bp_rialto::BlockNumber = bp_rialto::SESSION_LENGTH;
}
impl pallet_finality_verifier::Config for Runtime {
type BridgedChain = bp_rialto::Rialto;
type HeaderChain = pallet_substrate_bridge::Module<Runtime>;
type AncestryChecker = bp_header_chain::LinearAncestryChecker;
type MaxHeadersInSingleProof = MaxHeadersInSingleProof;
}
impl pallet_shift_session_manager::Config for Runtime {}
parameter_types! {
@@ -362,6 +366,7 @@ construct_runtime!(
BridgeRialto: pallet_substrate_bridge::{Module, Call, Storage, Config<T>},
BridgeRialtoMessageLane: pallet_message_lane::{Module, Call, Storage, Event<T>},
BridgeCallDispatch: pallet_bridge_call_dispatch::{Module, Event<T>},
BridgeFinalityVerifier: pallet_finality_verifier::{Module, Call},
System: frame_system::{Module, Call, Config, Storage, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},