Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
pallet-beefy-mmr: fix when using custom hashing (#14273)
Browse files Browse the repository at this point in the history
`Hash` is no longer part of `pallet_mmr::Config`, but this code
would still build because it assumes we're referring to underlying
`<pallet_mmr::Config as frame_system::Config>::Hash` which is not
what we want when using different hashing between `frame_system`
and `pallet_mmr`.

Disambiguate by using correct `pallet_mmr::Config::Hashing` type.

Signed-off-by: acatangiu <adrian@parity.io>
  • Loading branch information
acatangiu authored May 31, 2023
1 parent 655b81c commit 5aa4677
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frame/beefy-mmr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub struct DepositBeefyDigest<T>(sp_std::marker::PhantomData<T>);

impl<T> pallet_mmr::primitives::OnNewRoot<sp_consensus_beefy::MmrRootHash> for DepositBeefyDigest<T>
where
T: pallet_mmr::Config<Hash = sp_consensus_beefy::MmrRootHash>,
T: pallet_mmr::Config<Hashing = sp_consensus_beefy::MmrHashing>,
T: pallet_beefy::Config,
{
fn on_new_root(root: &sp_consensus_beefy::MmrRootHash) {
Expand Down
4 changes: 3 additions & 1 deletion primitives/consensus/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use codec::{Codec, Decode, Encode};
use scale_info::TypeInfo;
use sp_application_crypto::RuntimeAppPublic;
use sp_core::H256;
use sp_runtime::traits::{Hash, NumberFor};
use sp_runtime::traits::{Hash, Keccak256, NumberFor};
use sp_std::prelude::*;

/// Key type for BEEFY module.
Expand Down Expand Up @@ -156,6 +156,8 @@ impl<AuthorityId> ValidatorSet<AuthorityId> {
/// The index of an authority.
pub type AuthorityIndex = u32;

/// The Hashing used within MMR.
pub type MmrHashing = Keccak256;
/// The type used to represent an MMR root hash.
pub type MmrRootHash = H256;

Expand Down

0 comments on commit 5aa4677

Please sign in to comment.