Grandpa: Store the authority set changes (#2336) (#2337)

* Grandpa: Store the authority set changes
This commit is contained in:
Serban Iorga
2023-08-08 15:27:07 +03:00
committed by Bastian Köcher
parent f42b883745
commit bccd6e893e
17 changed files with 128 additions and 69 deletions
+6 -6
View File
@@ -883,9 +883,9 @@ impl_runtime_apis! {
BridgeRialtoGrandpa::best_finalized() BridgeRialtoGrandpa::best_finalized()
} }
fn accepted_grandpa_finality_proofs( fn synced_headers_grandpa_info(
) -> Vec<bp_header_chain::justification::GrandpaJustification<bp_rialto::Header>> { ) -> Vec<bp_header_chain::HeaderGrandpaInfo<bp_rialto::Header>> {
BridgeRialtoGrandpa::accepted_finality_proofs() BridgeRialtoGrandpa::synced_headers_grandpa_info()
} }
} }
@@ -894,9 +894,9 @@ impl_runtime_apis! {
BridgeWestendGrandpa::best_finalized() BridgeWestendGrandpa::best_finalized()
} }
fn accepted_grandpa_finality_proofs( fn synced_headers_grandpa_info(
) -> Vec<bp_header_chain::justification::GrandpaJustification<bp_westend::Header>> { ) -> Vec<bp_header_chain::HeaderGrandpaInfo<bp_westend::Header>> {
BridgeWestendGrandpa::accepted_finality_proofs() BridgeWestendGrandpa::synced_headers_grandpa_info()
} }
} }
@@ -747,9 +747,9 @@ impl_runtime_apis! {
BridgeMillauGrandpa::best_finalized() BridgeMillauGrandpa::best_finalized()
} }
fn accepted_grandpa_finality_proofs( fn synced_headers_grandpa_info(
) -> Vec<bp_header_chain::justification::GrandpaJustification<bp_millau::Header>> { ) -> Vec<bp_header_chain::HeaderGrandpaInfo<bp_millau::Header>> {
BridgeMillauGrandpa::accepted_finality_proofs() BridgeMillauGrandpa::synced_headers_grandpa_info()
} }
} }
+3 -3
View File
@@ -695,9 +695,9 @@ impl_runtime_apis! {
BridgeMillauGrandpa::best_finalized() BridgeMillauGrandpa::best_finalized()
} }
fn accepted_grandpa_finality_proofs( fn synced_headers_grandpa_info(
) -> Vec<bp_header_chain::justification::GrandpaJustification<bp_millau::Header>> { ) -> Vec<bp_header_chain::HeaderGrandpaInfo<bp_millau::Header>> {
BridgeMillauGrandpa::accepted_finality_proofs() BridgeMillauGrandpa::synced_headers_grandpa_info()
} }
} }
+56 -19
View File
@@ -39,8 +39,8 @@
pub use storage_types::StoredAuthoritySet; pub use storage_types::StoredAuthoritySet;
use bp_header_chain::{ use bp_header_chain::{
justification::GrandpaJustification, ChainWithGrandpa, GrandpaConsensusLogReader, HeaderChain, justification::GrandpaJustification, AuthoritySet, ChainWithGrandpa, GrandpaConsensusLogReader,
InitializationData, StoredHeaderData, StoredHeaderDataBuilder, HeaderChain, HeaderGrandpaInfo, InitializationData, StoredHeaderData, StoredHeaderDataBuilder,
}; };
use bp_runtime::{BlockNumberOf, HashOf, HasherOf, HeaderId, HeaderOf, OwnedBridgeModule}; use bp_runtime::{BlockNumberOf, HashOf, HasherOf, HeaderId, HeaderOf, OwnedBridgeModule};
use finality_grandpa::voter_set::VoterSet; use finality_grandpa::voter_set::VoterSet;
@@ -194,11 +194,12 @@ pub mod pallet {
let authority_set = <CurrentAuthoritySet<T, I>>::get(); let authority_set = <CurrentAuthoritySet<T, I>>::get();
let unused_proof_size = authority_set.unused_proof_size(); let unused_proof_size = authority_set.unused_proof_size();
let set_id = authority_set.set_id; let set_id = authority_set.set_id;
verify_justification::<T, I>(&justification, hash, number, authority_set.into())?; let authority_set: AuthoritySet = authority_set.into();
verify_justification::<T, I>(&justification, hash, number, authority_set)?;
let is_authorities_change_enacted = let maybe_new_authority_set =
try_enact_authority_change::<T, I>(&finality_target, set_id)?; try_enact_authority_change::<T, I>(&finality_target, set_id)?;
let may_refund_call_fee = is_authorities_change_enacted && let may_refund_call_fee = maybe_new_authority_set.is_some() &&
// if we have seen too many mandatory headers in this block, we don't want to refund // if we have seen too many mandatory headers in this block, we don't want to refund
Self::free_mandatory_headers_remaining() > 0 && Self::free_mandatory_headers_remaining() > 0 &&
// if arguments out of expected bounds, we don't want to refund // if arguments out of expected bounds, we don't want to refund
@@ -237,7 +238,14 @@ pub mod pallet {
let actual_weight = pre_dispatch_weight let actual_weight = pre_dispatch_weight
.set_proof_size(pre_dispatch_weight.proof_size().saturating_sub(unused_proof_size)); .set_proof_size(pre_dispatch_weight.proof_size().saturating_sub(unused_proof_size));
Self::deposit_event(Event::UpdatedBestFinalizedHeader { number, hash, justification }); Self::deposit_event(Event::UpdatedBestFinalizedHeader {
number,
hash,
grandpa_info: HeaderGrandpaInfo {
justification,
authority_set: maybe_new_authority_set,
},
});
Ok(PostDispatchInfo { actual_weight: Some(actual_weight), pays_fee }) Ok(PostDispatchInfo { actual_weight: Some(actual_weight), pays_fee })
} }
@@ -402,8 +410,8 @@ pub mod pallet {
UpdatedBestFinalizedHeader { UpdatedBestFinalizedHeader {
number: BridgedBlockNumber<T, I>, number: BridgedBlockNumber<T, I>,
hash: BridgedBlockHash<T, I>, hash: BridgedBlockHash<T, I>,
/// Justification. /// The Grandpa info associated to the new best finalized header.
justification: GrandpaJustification<BridgedHeader<T, I>>, grandpa_info: HeaderGrandpaInfo<BridgedHeader<T, I>>,
}, },
} }
@@ -439,9 +447,7 @@ pub mod pallet {
pub(crate) fn try_enact_authority_change<T: Config<I>, I: 'static>( pub(crate) fn try_enact_authority_change<T: Config<I>, I: 'static>(
header: &BridgedHeader<T, I>, header: &BridgedHeader<T, I>,
current_set_id: sp_consensus_grandpa::SetId, current_set_id: sp_consensus_grandpa::SetId,
) -> Result<bool, sp_runtime::DispatchError> { ) -> Result<Option<AuthoritySet>, DispatchError> {
let mut change_enacted = false;
// We don't support forced changes - at that point governance intervention is required. // We don't support forced changes - at that point governance intervention is required.
ensure!( ensure!(
GrandpaConsensusLogReader::<BridgedBlockNumber<T, I>>::find_forced_change( GrandpaConsensusLogReader::<BridgedBlockNumber<T, I>>::find_forced_change(
@@ -470,7 +476,6 @@ pub mod pallet {
// Since our header schedules a change and we know the delay is 0, it must also enact // Since our header schedules a change and we know the delay is 0, it must also enact
// the change. // the change.
<CurrentAuthoritySet<T, I>>::put(&next_authorities); <CurrentAuthoritySet<T, I>>::put(&next_authorities);
change_enacted = true;
log::info!( log::info!(
target: LOG_TARGET, target: LOG_TARGET,
@@ -479,9 +484,11 @@ pub mod pallet {
current_set_id + 1, current_set_id + 1,
next_authorities, next_authorities,
); );
return Ok(Some(next_authorities.into()))
}; };
Ok(change_enacted) Ok(None)
} }
/// Verify a GRANDPA justification (finality proof) for a given header. /// Verify a GRANDPA justification (finality proof) for a given header.
@@ -610,13 +617,13 @@ where
<T as frame_system::Config>::RuntimeEvent: TryInto<Event<T, I>>, <T as frame_system::Config>::RuntimeEvent: TryInto<Event<T, I>>,
{ {
/// Get the GRANDPA justifications accepted in the current block. /// Get the GRANDPA justifications accepted in the current block.
pub fn accepted_finality_proofs() -> Vec<GrandpaJustification<BridgedHeader<T, I>>> { pub fn synced_headers_grandpa_info() -> Vec<HeaderGrandpaInfo<BridgedHeader<T, I>>> {
frame_system::Pallet::<T>::read_events_no_consensus() frame_system::Pallet::<T>::read_events_no_consensus()
.filter_map(|event| { .filter_map(|event| {
if let Event::<T, I>::UpdatedBestFinalizedHeader { justification, .. } = if let Event::<T, I>::UpdatedBestFinalizedHeader { grandpa_info, .. } =
event.event.try_into().ok()? event.event.try_into().ok()?
{ {
return Some(justification) return Some(grandpa_info)
} }
None None
}) })
@@ -927,12 +934,18 @@ mod tests {
event: TestEvent::Grandpa(Event::UpdatedBestFinalizedHeader { event: TestEvent::Grandpa(Event::UpdatedBestFinalizedHeader {
number: *header.number(), number: *header.number(),
hash: header.hash(), hash: header.hash(),
justification: justification.clone(), grandpa_info: HeaderGrandpaInfo {
justification: justification.clone(),
authority_set: None,
},
}), }),
topics: vec![], topics: vec![],
}], }],
); );
assert_eq!(Pallet::<TestRuntime>::accepted_finality_proofs(), vec![justification]); assert_eq!(
Pallet::<TestRuntime>::synced_headers_grandpa_info(),
vec![HeaderGrandpaInfo { justification, authority_set: None }]
);
}) })
} }
@@ -1038,7 +1051,7 @@ mod tests {
let result = Pallet::<TestRuntime>::submit_finality_proof( let result = Pallet::<TestRuntime>::submit_finality_proof(
RuntimeOrigin::signed(1), RuntimeOrigin::signed(1),
Box::new(header.clone()), Box::new(header.clone()),
justification, justification.clone(),
); );
assert_ok!(result); assert_ok!(result);
assert_eq!(result.unwrap().pays_fee, frame_support::dispatch::Pays::No); assert_eq!(result.unwrap().pays_fee, frame_support::dispatch::Pays::No);
@@ -1053,6 +1066,30 @@ mod tests {
StoredAuthoritySet::<TestRuntime, ()>::try_new(next_authorities, next_set_id) StoredAuthoritySet::<TestRuntime, ()>::try_new(next_authorities, next_set_id)
.unwrap(), .unwrap(),
); );
// Here
assert_eq!(
System::events(),
vec![EventRecord {
phase: Phase::Initialization,
event: TestEvent::Grandpa(Event::UpdatedBestFinalizedHeader {
number: *header.number(),
hash: header.hash(),
grandpa_info: HeaderGrandpaInfo {
justification: justification.clone(),
authority_set: Some(<CurrentAuthoritySet<TestRuntime>>::get().into()),
},
}),
topics: vec![],
}],
);
assert_eq!(
Pallet::<TestRuntime>::synced_headers_grandpa_info(),
vec![HeaderGrandpaInfo {
justification,
authority_set: Some(<CurrentAuthoritySet<TestRuntime>>::get().into()),
}]
);
}) })
} }
+2 -2
View File
@@ -20,7 +20,7 @@ use crate::{Config, Error};
use bp_header_chain::{AuthoritySet, ChainWithGrandpa}; use bp_header_chain::{AuthoritySet, ChainWithGrandpa};
use codec::{Decode, Encode, MaxEncodedLen}; use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{traits::Get, BoundedVec, RuntimeDebugNoBound}; use frame_support::{traits::Get, BoundedVec, CloneNoBound, RuntimeDebugNoBound};
use scale_info::TypeInfo; use scale_info::TypeInfo;
use sp_consensus_grandpa::{AuthorityId, AuthorityList, AuthorityWeight, SetId}; use sp_consensus_grandpa::{AuthorityId, AuthorityList, AuthorityWeight, SetId};
use sp_std::marker::PhantomData; use sp_std::marker::PhantomData;
@@ -39,7 +39,7 @@ impl<T: Config<I>, I: 'static> Get<u32> for StoredAuthorityListLimit<T, I> {
} }
/// A bounded GRANDPA Authority List and ID. /// A bounded GRANDPA Authority List and ID.
#[derive(Clone, Decode, Encode, Eq, TypeInfo, MaxEncodedLen, RuntimeDebugNoBound)] #[derive(CloneNoBound, Decode, Encode, Eq, TypeInfo, MaxEncodedLen, RuntimeDebugNoBound)]
#[scale_info(skip_type_params(T, I))] #[scale_info(skip_type_params(T, I))]
pub struct StoredAuthoritySet<T: Config<I>, I: 'static> { pub struct StoredAuthoritySet<T: Config<I>, I: 'static> {
/// List of GRANDPA authorities for the current round. /// List of GRANDPA authorities for the current round.
+17 -5
View File
@@ -697,7 +697,7 @@ pub(crate) mod tests {
use bp_test_utils::prepare_parachain_heads_proof; use bp_test_utils::prepare_parachain_heads_proof;
use codec::Encode; use codec::Encode;
use bp_header_chain::justification::GrandpaJustification; use bp_header_chain::{justification::GrandpaJustification, HeaderGrandpaInfo};
use bp_parachains::{ use bp_parachains::{
BestParaHeadHash, BridgeParachainCall, ImportedParaHeadsKeyProvider, ParasInfoKeyProvider, BestParaHeadHash, BridgeParachainCall, ImportedParaHeadsKeyProvider, ParasInfoKeyProvider,
}; };
@@ -1036,7 +1036,10 @@ pub(crate) mod tests {
pallet_bridge_grandpa::Event::UpdatedBestFinalizedHeader { pallet_bridge_grandpa::Event::UpdatedBestFinalizedHeader {
number: 1, number: 1,
hash: relay_1_hash, hash: relay_1_hash,
justification grandpa_info: HeaderGrandpaInfo {
justification,
authority_set: None,
},
} }
), ),
topics: vec![], topics: vec![],
@@ -1174,7 +1177,10 @@ pub(crate) mod tests {
pallet_bridge_grandpa::Event::UpdatedBestFinalizedHeader { pallet_bridge_grandpa::Event::UpdatedBestFinalizedHeader {
number: 1, number: 1,
hash: relay_1_hash, hash: relay_1_hash,
justification grandpa_info: HeaderGrandpaInfo {
justification,
authority_set: None,
}
} }
), ),
topics: vec![], topics: vec![],
@@ -1224,7 +1230,10 @@ pub(crate) mod tests {
pallet_bridge_grandpa::Event::UpdatedBestFinalizedHeader { pallet_bridge_grandpa::Event::UpdatedBestFinalizedHeader {
number: 1, number: 1,
hash: relay_1_hash, hash: relay_1_hash,
justification: justification.clone() grandpa_info: HeaderGrandpaInfo {
justification: justification.clone(),
authority_set: None,
}
} }
), ),
topics: vec![], topics: vec![],
@@ -1262,7 +1271,10 @@ pub(crate) mod tests {
pallet_bridge_grandpa::Event::UpdatedBestFinalizedHeader { pallet_bridge_grandpa::Event::UpdatedBestFinalizedHeader {
number: 1, number: 1,
hash: relay_1_hash, hash: relay_1_hash,
justification grandpa_info: HeaderGrandpaInfo {
justification,
authority_set: None,
}
} }
), ),
topics: vec![], topics: vec![],
+4 -1
View File
@@ -8,7 +8,10 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies] [dependencies]
fixed-hash = { version = "0.8.0", default-features = false } # TODO: Consume `fixed-hash` from crates.io when the following fix is published:
# https://github.com/paritytech/parity-common/commit/d3a9327124a66e52ca1114bb8640c02c18c134b8
# Expected in a version > 0.8.0
fixed-hash = { git = "https://github.com/paritytech/parity-common", branch = "master", default-features = false }
hash256-std-hasher = { version = "0.15.2", default-features = false } hash256-std-hasher = { version = "0.15.2", default-features = false }
impl-codec = { version = "0.6", default-features = false } impl-codec = { version = "0.6", default-features = false }
impl-serde = { version = "0.4.0", default-features = false } impl-serde = { version = "0.4.0", default-features = false }
@@ -172,6 +172,15 @@ impl<Number: Codec> ConsensusLogReader for GrandpaConsensusLogReader<Number> {
} }
} }
/// The Grandpa-related info associated to a header.
#[derive(Encode, Decode, Debug, PartialEq, Clone, TypeInfo)]
pub struct HeaderGrandpaInfo<Header: HeaderT> {
/// The header justification
pub justification: justification::GrandpaJustification<Header>,
/// The authority set introduced by the header.
pub authority_set: Option<AuthoritySet>,
}
/// A minimized version of `pallet-bridge-grandpa::Call` that can be used without a runtime. /// A minimized version of `pallet-bridge-grandpa::Call` that can be used without a runtime.
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
+4 -4
View File
@@ -295,8 +295,8 @@ macro_rules! decl_bridge_finality_runtime_apis {
$( $(
/// Name of the `<ThisChain>FinalityApi::accepted_<consensus>_finality_proofs` /// Name of the `<ThisChain>FinalityApi::accepted_<consensus>_finality_proofs`
/// runtime method. /// runtime method.
pub const [<$chain:upper _ACCEPTED_ $consensus:upper _FINALITY_PROOFS_METHOD>]: &str = pub const [<$chain:upper _SYNCED_HEADERS_ $consensus:upper _INFO_METHOD>]: &str =
stringify!([<$chain:camel FinalityApi_accepted_ $consensus:lower _finality_proofs>]); stringify!([<$chain:camel FinalityApi_synced_headers_ $consensus:lower _info>]);
)? )?
sp_api::decl_runtime_apis! { sp_api::decl_runtime_apis! {
@@ -310,7 +310,7 @@ macro_rules! decl_bridge_finality_runtime_apis {
$( $(
/// Returns the justifications accepted in the current block. /// Returns the justifications accepted in the current block.
fn [<accepted_ $consensus:lower _finality_proofs>]( fn [<synced_headers_ $consensus:lower _info>](
) -> Vec<$justification_type>; ) -> Vec<$justification_type>;
)? )?
} }
@@ -321,7 +321,7 @@ macro_rules! decl_bridge_finality_runtime_apis {
} }
}; };
($chain: ident, grandpa) => { ($chain: ident, grandpa) => {
decl_bridge_finality_runtime_apis!($chain, grandpa => bp_header_chain::justification::GrandpaJustification<Header>); decl_bridge_finality_runtime_apis!($chain, grandpa => bp_header_chain::HeaderGrandpaInfo<Header>);
}; };
} }
+3 -3
View File
@@ -16,7 +16,7 @@
//! Types used to connect to the Kusama chain. //! Types used to connect to the Kusama chain.
use bp_kusama::{AccountInfoStorageMapKeyProvider, KUSAMA_ACCEPTED_GRANDPA_FINALITY_PROOFS_METHOD}; use bp_kusama::{AccountInfoStorageMapKeyProvider, KUSAMA_SYNCED_HEADERS_GRANDPA_INFO_METHOD};
use bp_runtime::ChainId; use bp_runtime::ChainId;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider, Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider,
@@ -50,8 +50,8 @@ impl Chain for Kusama {
} }
impl ChainWithGrandpa for Kusama { impl ChainWithGrandpa for Kusama {
const ACCEPTED_FINALITY_PROOFS_METHOD: &'static str = const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
KUSAMA_ACCEPTED_GRANDPA_FINALITY_PROOFS_METHOD; KUSAMA_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
} }
impl ChainWithBalances for Kusama { impl ChainWithBalances for Kusama {
+3 -3
View File
@@ -17,7 +17,7 @@
//! Types used to connect to the Millau-Substrate chain. //! Types used to connect to the Millau-Substrate chain.
use bp_messages::MessageNonce; use bp_messages::MessageNonce;
use bp_millau::MILLAU_ACCEPTED_GRANDPA_FINALITY_PROOFS_METHOD; use bp_millau::MILLAU_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
use bp_runtime::ChainId; use bp_runtime::ChainId;
use codec::{Compact, Decode, Encode}; use codec::{Compact, Decode, Encode};
use relay_substrate_client::{ use relay_substrate_client::{
@@ -67,8 +67,8 @@ impl Chain for Millau {
} }
impl ChainWithGrandpa for Millau { impl ChainWithGrandpa for Millau {
const ACCEPTED_FINALITY_PROOFS_METHOD: &'static str = const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
MILLAU_ACCEPTED_GRANDPA_FINALITY_PROOFS_METHOD; MILLAU_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
} }
impl ChainWithBalances for Millau { impl ChainWithBalances for Millau {
+3 -5
View File
@@ -16,9 +16,7 @@
//! Types used to connect to the Polkadot chain. //! Types used to connect to the Polkadot chain.
use bp_polkadot::{ use bp_polkadot::{AccountInfoStorageMapKeyProvider, POLKADOT_SYNCED_HEADERS_GRANDPA_INFO_METHOD};
AccountInfoStorageMapKeyProvider, POLKADOT_ACCEPTED_GRANDPA_FINALITY_PROOFS_METHOD,
};
use bp_runtime::ChainId; use bp_runtime::ChainId;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider, Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider,
@@ -52,8 +50,8 @@ impl Chain for Polkadot {
} }
impl ChainWithGrandpa for Polkadot { impl ChainWithGrandpa for Polkadot {
const ACCEPTED_FINALITY_PROOFS_METHOD: &'static str = const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
POLKADOT_ACCEPTED_GRANDPA_FINALITY_PROOFS_METHOD; POLKADOT_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
} }
impl ChainWithBalances for Polkadot { impl ChainWithBalances for Polkadot {
+3 -3
View File
@@ -17,7 +17,7 @@
//! Types used to connect to the Rialto-Substrate chain. //! Types used to connect to the Rialto-Substrate chain.
use bp_messages::MessageNonce; use bp_messages::MessageNonce;
use bp_rialto::RIALTO_ACCEPTED_GRANDPA_FINALITY_PROOFS_METHOD; use bp_rialto::RIALTO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
use bp_runtime::ChainId; use bp_runtime::ChainId;
use codec::{Compact, Decode, Encode}; use codec::{Compact, Decode, Encode};
use relay_substrate_client::{ use relay_substrate_client::{
@@ -52,8 +52,8 @@ impl Chain for Rialto {
} }
impl ChainWithGrandpa for Rialto { impl ChainWithGrandpa for Rialto {
const ACCEPTED_FINALITY_PROOFS_METHOD: &'static str = const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
RIALTO_ACCEPTED_GRANDPA_FINALITY_PROOFS_METHOD; RIALTO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
} }
impl RelayChain for Rialto { impl RelayChain for Rialto {
+3 -3
View File
@@ -16,7 +16,7 @@
//! Types used to connect to the Rococo-Substrate chain. //! Types used to connect to the Rococo-Substrate chain.
use bp_rococo::ROCOCO_ACCEPTED_GRANDPA_FINALITY_PROOFS_METHOD; use bp_rococo::ROCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
use bp_runtime::ChainId; use bp_runtime::ChainId;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider, Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider,
@@ -50,8 +50,8 @@ impl Chain for Rococo {
} }
impl ChainWithGrandpa for Rococo { impl ChainWithGrandpa for Rococo {
const ACCEPTED_FINALITY_PROOFS_METHOD: &'static str = const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
ROCOCO_ACCEPTED_GRANDPA_FINALITY_PROOFS_METHOD; ROCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
} }
impl ChainWithBalances for Rococo { impl ChainWithBalances for Rococo {
+3 -3
View File
@@ -79,12 +79,12 @@ pub trait RelayChain: Chain {
/// Keep in mind that parachains are relying on relay chain GRANDPA, so they should not implement /// Keep in mind that parachains are relying on relay chain GRANDPA, so they should not implement
/// this trait. /// this trait.
pub trait ChainWithGrandpa: Chain + UnderlyingChainWithGrandpaProvider { pub trait ChainWithGrandpa: Chain + UnderlyingChainWithGrandpaProvider {
/// Name of the runtime API method that is returning the GRANDPA justifications accepted /// Name of the runtime API method that is returning the GRANDPA info associated with the
/// by the `submit_finality_proofs` extrinsic in the queried block. /// headers accepted by the `submit_finality_proofs` extrinsic in the queried block.
/// ///
/// Keep in mind that this method is normally provided by the other chain, which is /// Keep in mind that this method is normally provided by the other chain, which is
/// bridged with this chain. /// bridged with this chain.
const ACCEPTED_FINALITY_PROOFS_METHOD: &'static str; const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str;
} }
/// Substrate-based parachain from minimal relay-client point of view. /// Substrate-based parachain from minimal relay-client point of view.
+3 -3
View File
@@ -17,7 +17,7 @@
//! Types used to connect to the Westend chain. //! Types used to connect to the Westend chain.
use bp_runtime::ChainId; use bp_runtime::ChainId;
use bp_westend::WESTEND_ACCEPTED_GRANDPA_FINALITY_PROOFS_METHOD; use bp_westend::WESTEND_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider, Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider,
}; };
@@ -50,8 +50,8 @@ impl Chain for Westend {
} }
impl ChainWithGrandpa for Westend { impl ChainWithGrandpa for Westend {
const ACCEPTED_FINALITY_PROOFS_METHOD: &'static str = const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
WESTEND_ACCEPTED_GRANDPA_FINALITY_PROOFS_METHOD; WESTEND_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
} }
impl RelayChain for Westend { impl RelayChain for Westend {
+3 -3
View File
@@ -17,7 +17,7 @@
//! Types used to connect to the Wococo-Substrate chain. //! Types used to connect to the Wococo-Substrate chain.
use bp_runtime::ChainId; use bp_runtime::ChainId;
use bp_wococo::WOCOCO_ACCEPTED_GRANDPA_FINALITY_PROOFS_METHOD; use bp_wococo::WOCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider, Chain, ChainWithBalances, ChainWithGrandpa, RelayChain, UnderlyingChainProvider,
}; };
@@ -50,8 +50,8 @@ impl Chain for Wococo {
} }
impl ChainWithGrandpa for Wococo { impl ChainWithGrandpa for Wococo {
const ACCEPTED_FINALITY_PROOFS_METHOD: &'static str = const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
WOCOCO_ACCEPTED_GRANDPA_FINALITY_PROOFS_METHOD; WOCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
} }
impl ChainWithBalances for Wococo { impl ChainWithBalances for Wococo {