Skip to content

Commit

Permalink
update pallet_mmr config in beefy mock and cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhavyas committed Apr 11, 2024
1 parent 2fb5e4c commit bb88cde
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions substrate/frame/beefy-mmr/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ impl pallet_mmr::Config for Test {

type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest<Test>;

type BlockHashProvider = pallet_mmr::DefaultBlockHashProvider<Test>;

type WeightInfo = ();
}

Expand Down
13 changes: 9 additions & 4 deletions substrate/frame/merkle-mountain-range/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,18 @@ impl<T: frame_system::Config> LeafDataProvider for ParentNumberAndHash<T> {
}

/// Block hash provider for a given block number.
pub trait BlockHashProvider<BlockNumber, BlockHash>{
pub trait BlockHashProvider<BlockNumber, BlockHash> {
fn block_hash_for(block_number: BlockNumber) -> BlockHash;
}

/// Default implementation of BlockHashProvider using frame_system.
pub struct DefaultBlockHashProvider<T: frame_system::Config>{
pub struct DefaultBlockHashProvider<T: frame_system::Config> {
_phantom: sp_std::marker::PhantomData<T>,
}

impl<T: frame_system::Config> BlockHashProvider<BlockNumberFor<T>, T::Hash> for DefaultBlockHashProvider<T> {
impl<T: frame_system::Config> BlockHashProvider<BlockNumberFor<T>, T::Hash>
for DefaultBlockHashProvider<T>
{
fn block_hash_for(block_number: BlockNumberFor<T>) -> T::Hash {
frame_system::Pallet::<T>::block_hash(block_number)
}
Expand Down Expand Up @@ -194,7 +196,10 @@ pub mod pallet {
type OnNewRoot: primitives::OnNewRoot<HashOf<Self, I>>;

/// Block hash provider for a given block number.
type BlockHashProvider: BlockHashProvider<BlockNumberFor<Self>, <Self as frame_system::Config>::Hash>;
type BlockHashProvider: BlockHashProvider<
BlockNumberFor<Self>,
<Self as frame_system::Config>::Hash,
>;

/// Weights for this pallet.
type WeightInfo: WeightInfo;
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/merkle-mountain-range/src/mmr/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use sp_std::prelude::*;
use crate::{
mmr::{Node, NodeOf},
primitives::{self, NodeIndex},
Config, Nodes, NumberOfLeaves, Pallet, BlockHashProvider
BlockHashProvider, Config, Nodes, NumberOfLeaves, Pallet,
};

/// A marker type for runtime-specific storage implementation.
Expand Down

0 comments on commit bb88cde

Please sign in to comment.