Move Chain trait to runtime primitives (#403)

* extract ChainBase to bp-runtime

* post-merge fixes

* cargo fmt --all

* compilation fixes

* reexport BlockNumberOf, HashOf, HeaderOf
This commit is contained in:
Svyatoslav Nikolsky
2020-10-07 22:50:43 +03:00
committed by Bastian Köcher
parent ddeb59d336
commit 9e9ac8df3c
17 changed files with 238 additions and 171 deletions
+9 -11
View File
@@ -32,9 +32,7 @@ use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId, AuthorityList as G
use sp_api::impl_runtime_apis;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::traits::{
BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, NumberFor, OpaqueKeys, Saturating, Verify,
};
use sp_runtime::traits::{Block as BlockT, IdentifyAccount, IdentityLookup, NumberFor, OpaqueKeys, Saturating, Verify};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
transaction_validity::{TransactionSource, TransactionValidity},
@@ -84,6 +82,9 @@ pub type Index = u32;
/// A hash of some data used by the chain.
pub type Hash = bp_millau::Hash;
/// Hashing algorithm used by the chain.
pub type Hashing = bp_millau::Hasher;
/// Digest item type.
pub type DigestItem = generic::DigestItem<Hash>;
@@ -97,7 +98,7 @@ pub mod opaque {
pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
/// Opaque block header type.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
pub type Header = generic::Header<BlockNumber, Hashing>;
/// Opaque block type.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// Opaque block identifier type.
@@ -172,9 +173,9 @@ impl frame_system::Trait for Runtime {
/// The type for hashing blocks and tries.
type Hash = Hash;
/// The hashing algorithm used.
type Hashing = BlakeTwo256;
type Hashing = Hashing;
/// The header type.
type Header = generic::Header<BlockNumber, BlakeTwo256>;
type Header = generic::Header<BlockNumber, Hashing>;
/// The ubiquitous event type.
type Event = Event;
/// The ubiquitous origin type.
@@ -309,10 +310,7 @@ impl pallet_session::Trait for Runtime {
}
impl pallet_substrate_bridge::Trait for Runtime {
type BridgedHeader = bp_rialto::Header;
type BridgedBlockNumber = bp_rialto::BlockNumber;
type BridgedBlockHash = bp_rialto::Hash;
type BridgedBlockHasher = bp_rialto::Hasher;
type BridgedChain = bp_rialto::Rialto;
}
impl pallet_shift_session_manager::Trait for Runtime {}
@@ -341,7 +339,7 @@ construct_runtime!(
/// The address format for describing accounts.
pub type Address = AccountId;
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
pub type Header = generic::Header<BlockNumber, Hashing>;
/// Block type as expected by this runtime.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// A Block signed with a Justification