Skip to content

Commit

Permalink
Implement RuntimeDebug for GrandpaJustification (#2254)
Browse files Browse the repository at this point in the history
  • Loading branch information
serban300 authored Jul 10, 2023
1 parent 8c9e59b commit 7065bba
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions 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 7065bba

Please sign in to comment.