// Copyright 2019-2021 Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.
// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see .
//! Primitives that are used to interact with BEEFY bridge pallet.
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs)]
pub use beefy_merkle_tree::{merkle_root, Keccak256 as BeefyKeccak256};
pub use beefy_primitives::{
crypto::{AuthorityId as EcdsaValidatorId, AuthoritySignature as EcdsaValidatorSignature},
known_payloads::MMR_ROOT_ID as MMR_ROOT_PAYLOAD_ID,
mmr::{BeefyAuthoritySet, MmrLeafVersion},
BeefyAuthorityId, BeefyVerify, Commitment, Payload as BeefyPayload, SignedCommitment,
ValidatorSet, ValidatorSetId, BEEFY_ENGINE_ID,
};
pub use pallet_beefy_mmr::BeefyEcdsaToEthereum;
pub use pallet_mmr::{
primitives::{DataOrHash as MmrDataOrHash, Proof as MmrProof},
verify_leaves_proof as verify_mmr_leaves_proof,
};
use bp_runtime::{BasicOperatingMode, BlockNumberOf, Chain, HashOf};
use codec::{Decode, Encode};
use frame_support::Parameter;
use scale_info::TypeInfo;
use sp_runtime::{
traits::{Convert, MaybeSerializeDeserialize},
RuntimeDebug,
};
use sp_std::prelude::*;
/// Substrate-based chain with BEEFY && MMR pallets deployed.
///
/// Both BEEFY and MMR pallets and their clients may be configured to use different
/// primitives. Some of types can be configured in low-level pallets, but are constrained
/// when BEEFY+MMR bundle is used.
pub trait ChainWithBeefy: Chain {
/// The hashing algorithm used to compute the digest of the BEEFY commitment.
///
/// Corresponds to the hashing algorithm, used by `beefy_gadget::BeefyKeystore`.
type CommitmentHasher: sp_runtime::traits::Hash;
/// The hashing algorithm used to build the MMR.
///
/// The same algorithm is also used to compute merkle roots in BEEFY
/// (e.g. validator addresses root in leaf data).
///
/// Corresponds to the `Hashing` field of the `pallet-mmr` configuration.
type MmrHashing: sp_runtime::traits::Hash