Skip to content

Commit

Permalink
Implement RuntimeDebug for GrandpaJustification (paritytech#2254)
Browse files Browse the repository at this point in the history
  • Loading branch information
serban300 committed Apr 9, 2024
1 parent 61921e8 commit fd214f6
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions bridges/primitives/header-chain/src/justification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::ChainWithGrandpa;
use bp_runtime::{BlockNumberOf, Chain, HashOf};
use codec::{Decode, Encode, MaxEncodedLen};
use finality_grandpa::voter_set::VoterSet;
use frame_support::RuntimeDebug;
use frame_support::{RuntimeDebug, RuntimeDebugNoBound};
use scale_info::TypeInfo;
use sp_consensus_grandpa::{AuthorityId, AuthoritySignature, SetId};
use sp_runtime::{traits::Header as HeaderT, SaturatedConversion};
Expand All @@ -38,7 +38,7 @@ use sp_std::{
///
/// This particular proof is used to prove that headers on a bridged chain
/// (so not our chain) have been finalized correctly.
#[derive(Encode, Decode, Clone, PartialEq, Eq, TypeInfo)]
#[derive(Encode, Decode, Clone, PartialEq, Eq, TypeInfo, RuntimeDebugNoBound)]
pub struct GrandpaJustification<Header: HeaderT> {
/// The round (voting period) this justification is valid for.
pub round: u64,
Expand All @@ -49,25 +49,6 @@ pub struct GrandpaJustification<Header: HeaderT> {
pub votes_ancestries: Vec<Header>,
}

// TODO: remove and use `RuntimeDebug` (https://github.com/paritytech/parity-bridges-common/issues/2136)
impl<Header: HeaderT> sp_std::fmt::Debug for GrandpaJustification<Header> {
fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
#[cfg(feature = "std")]
{
fmt.debug_struct("GrandpaJustification")
.field("round", &self.round)
.field("commit", &self.commit)
.field("votes_ancestries", &self.votes_ancestries)
.finish()
}

#[cfg(not(feature = "std"))]
{
fmt.write_str("<stripped>")
}
}
}

impl<H: HeaderT> GrandpaJustification<H> {
/// Returns reasonable size of justification using constants from the provided chain.
///
Expand Down

0 comments on commit fd214f6

Please sign in to comment.