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
+4 -1
View File
@@ -8,7 +8,10 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[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 }
impl-codec = { version = "0.6", 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.
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
#[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`
/// runtime method.
pub const [<$chain:upper _ACCEPTED_ $consensus:upper _FINALITY_PROOFS_METHOD>]: &str =
stringify!([<$chain:camel FinalityApi_accepted_ $consensus:lower _finality_proofs>]);
pub const [<$chain:upper _SYNCED_HEADERS_ $consensus:upper _INFO_METHOD>]: &str =
stringify!([<$chain:camel FinalityApi_synced_headers_ $consensus:lower _info>]);
)?
sp_api::decl_runtime_apis! {
@@ -310,7 +310,7 @@ macro_rules! decl_bridge_finality_runtime_apis {
$(
/// Returns the justifications accepted in the current block.
fn [<accepted_ $consensus:lower _finality_proofs>](
fn [<synced_headers_ $consensus:lower _info>](
) -> Vec<$justification_type>;
)?
}
@@ -321,7 +321,7 @@ macro_rules! decl_bridge_finality_runtime_apis {
}
};
($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>);
};
}