ChainWithGrandpa in primitives (#1885)

* ChainWithGrandpa in primitives

* clippy ++ spelling

* fix benchmarks comppilation
This commit is contained in:
Svyatoslav Nikolsky
2023-02-16 15:20:45 +03:00
committed by Bastian Köcher
parent 914213d0af
commit c6c39be967
33 changed files with 421 additions and 139 deletions
@@ -21,6 +21,7 @@
mod millau_hash;
use bp_beefy::ChainWithBeefy;
use bp_header_chain::ChainWithGrandpa;
use bp_messages::{
InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails,
};
@@ -83,6 +84,27 @@ pub const SESSION_LENGTH: BlockNumber = 5 * time_units::MINUTES;
/// Maximal number of GRANDPA authorities at Millau.
pub const MAX_AUTHORITIES_COUNT: u32 = 5;
/// Reasonable number of headers in the `votes_ancestries` on Millau chain.
///
/// See [`bp_header_chain::ChainWithGrandpa`] for more details.
pub const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = 8;
/// Approximate average header size in `votes_ancestries` field of justification on Millau chain.
///
/// See [`bp_header_chain::ChainWithGrandpa`] for more details.
pub const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = 256;
/// Approximate maximal header size on Millau chain.
///
/// We expect maximal header to have digest item with the new authorities set for every consensus
/// engine (GRANDPA, Babe, BEEFY, ...) - so we multiply it by 3. And also
/// `AVERAGE_HEADER_SIZE_IN_JUSTIFICATION` bytes for other stuff.
///
/// See [`bp_header_chain::ChainWithGrandpa`] for more details.
pub const MAX_HEADER_SIZE: u32 = MAX_AUTHORITIES_COUNT
.saturating_mul(3)
.saturating_add(AVERAGE_HEADER_SIZE_IN_JUSTIFICATION);
/// Re-export `time_units` to make usage easier.
pub use time_units::*;
@@ -156,6 +178,15 @@ impl Chain for Millau {
}
}
impl ChainWithGrandpa for Millau {
const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = WITH_MILLAU_GRANDPA_PALLET_NAME;
const MAX_AUTHORITIES_COUNT: u32 = MAX_AUTHORITIES_COUNT;
const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 =
REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY;
const MAX_HEADER_SIZE: u32 = MAX_HEADER_SIZE;
const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = AVERAGE_HEADER_SIZE_IN_JUSTIFICATION;
}
impl ChainWithBeefy for Millau {
type CommitmentHasher = Keccak256;
type MmrHashing = Keccak256;