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

Commit

Permalink
Fixes trait bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
gupnik committed Jul 11, 2023
1 parent 838e528 commit 0b0f42f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions bridges/primitives/header-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false }
finality-grandpa = { version = "0.16.2", default-features = false }
num-traits = { version = "0.2", default-features = false }
scale-info = { version = "2.9.0", default-features = false, features = ["derive"] }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }

Expand Down
4 changes: 3 additions & 1 deletion bridges/primitives/header-chain/src/justification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ use bp_runtime::{BlockNumberOf, Chain, HashOf};
use codec::{Decode, Encode, MaxEncodedLen};
use finality_grandpa::voter_set::VoterSet;
use frame_support::RuntimeDebug;
use num_traits::AsPrimitive;
use scale_info::TypeInfo;
use sp_consensus_grandpa::{AuthorityId, AuthoritySignature, SetId};
use sp_runtime::{traits::Header as HeaderT, SaturatedConversion};
use sp_runtime::{traits::{Block as BlockT, Header as HeaderT}, SaturatedConversion};
use sp_std::{
collections::{btree_map::BTreeMap, btree_set::BTreeSet},
prelude::*,
Expand Down Expand Up @@ -76,6 +77,7 @@ impl<H: HeaderT> GrandpaJustification<H> {
pub fn max_reasonable_size<C>(required_precommits: u32) -> u32
where
C: Chain + ChainWithGrandpa,
<<<C as Chain>::Block as BlockT>::Header as HeaderT>::Number: AsPrimitive<usize>
{
// we don't need precise results here - just estimations, so some details
// are removed from computations (e.g. bytes required to encode vector length)
Expand Down
7 changes: 4 additions & 3 deletions bridges/primitives/header-chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ use frame_support::PalletError;
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};
use sp_consensus_grandpa::{AuthorityList, ConsensusLog, SetId, GRANDPA_ENGINE_ID};
use sp_runtime::{traits::Header as HeaderT, Digest, RuntimeDebug};
use sp_runtime::{traits::{Block as BlockT, Header as HeaderT}, Digest, RuntimeDebug};
use sp_std::boxed::Box;
use num_traits::AsPrimitive;

pub mod justification;
pub mod storage_keys;
Expand Down Expand Up @@ -69,7 +70,7 @@ impl<H: HeaderT> StoredHeaderDataBuilder<H::Number, H::Hash> for H {
}

/// Substrate header chain, abstracted from the way it is stored.
pub trait HeaderChain<C: Chain> {
pub trait HeaderChain<C: Chain> where <<<C as Chain>::Block as BlockT>::Header as HeaderT>::Number: AsPrimitive<usize> {
/// Returns state (storage) root of given finalized header.
fn finalized_header_state_root(header_hash: HashOf<C>) -> Option<HashOf<C>>;
/// Get storage proof checker using finalized header.
Expand Down Expand Up @@ -181,7 +182,7 @@ pub type BridgeGrandpaCallOf<C> = BridgeGrandpaCall<HeaderOf<C>>;
///
/// Keep in mind that parachains are relying on relay chain GRANDPA, so they should not implement
/// this trait.
pub trait ChainWithGrandpa: Chain {
pub trait ChainWithGrandpa: Chain where <<<Self as Chain>::Block as BlockT>::Header as HeaderT>::Number: AsPrimitive<usize> {
/// Name of the bridge GRANDPA pallet (used in `construct_runtime` macro call) that is deployed
/// at some other chain to bridge with this `ChainWithGrandpa`.
///
Expand Down

0 comments on commit 0b0f42f

Please sign in to comment.