Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add MMR pallet to Millau runtime
  • Loading branch information
acatangiu committed Nov 30, 2021
commit d3d21ee20b0d0ca725f96ec784855db9de0ed8e8
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions bin/millau/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pallet-aura = { git = "https://github.com/paritytech/substrate", branch = "maste
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-beefy = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-mmr = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand Down Expand Up @@ -87,6 +88,7 @@ std = [
"pallet-bridge-messages/std",
"pallet-bridge-token-swap/std",
"pallet-grandpa/std",
"pallet-mmr/std",
"pallet-randomness-collective-flip/std",
"pallet-session/std",
"pallet-shift-session-manager/std",
Expand Down
29 changes: 28 additions & 1 deletion bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{Block as BlockT, IdentityLookup, NumberFor, OpaqueKeys},
traits::{Block as BlockT, IdentityLookup, Keccak256, NumberFor, OpaqueKeys},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedPointNumber, MultiSignature, MultiSigner, Perquintill,
};
Expand Down Expand Up @@ -247,6 +247,32 @@ impl pallet_grandpa::Config for Runtime {
type MaxAuthorities = MaxAuthorities;
}

type MmrHash = bp_millau::Hash;

// TODO: use `pallet_beefy_mmr::DepositBeefyDigest` instead of `DepositLog` below.

/// A BEEFY consensus digest item with MMR root hash.
pub struct DepositLog;
impl pallet_mmr::primitives::OnNewRoot<Hash> for DepositLog {
fn on_new_root(root: &Hash) {
let digest = DigestItem::Consensus(
beefy_primitives::BEEFY_ENGINE_ID,
codec::Encode::encode(&beefy_primitives::ConsensusLog::<BeefyId>::MmrRoot(*root)),
);
<frame_system::Pallet<Runtime>>::deposit_log(digest);
}
}

/// Configure Merkle Mountain Range pallet.
impl pallet_mmr::Config for Runtime {
const INDEXING_PREFIX: &'static [u8] = b"mmr";
type Hashing = Hashing;
type Hash = Hash;
type OnNewRoot = DepositLog;
type WeightInfo = ();
type LeafData = frame_system::Pallet<Self>;
}

parameter_types! {
pub const MinimumPeriod: u64 = bp_millau::SLOT_DURATION / 2;
}
Expand Down Expand Up @@ -468,6 +494,7 @@ construct_runtime!(

// Bridges support.
Beefy: pallet_beefy::{Pallet, Storage, Config<T>},
Mmr: pallet_mmr::{Pallet, Storage},

// Rialto bridge modules.
BridgeRialtoGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage},
Expand Down