mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 07:31:08 +00:00
update light aux storage when GRANDPA set changes (#5861)
This commit is contained in:
committed by
GitHub
parent
9acf88f58b
commit
11f144ee65
@@ -219,7 +219,7 @@ pub struct FinalityEffects<Header: HeaderT> {
|
||||
/// 2) headers sub-chain (B; F] if B != F;
|
||||
/// 3) proof of GRANDPA::authorities() if the set changes at block F.
|
||||
#[derive(Debug, PartialEq, Encode, Decode)]
|
||||
struct FinalityProofFragment<Header: HeaderT> {
|
||||
pub(crate) struct FinalityProofFragment<Header: HeaderT> {
|
||||
/// The hash of block F for which justification is provided.
|
||||
pub block: Header::Hash,
|
||||
/// Justification of the block F.
|
||||
@@ -425,26 +425,7 @@ pub(crate) fn prove_finality<Block: BlockT, B: BlockchainBackend<Block>, J>(
|
||||
///
|
||||
/// Returns the vector of headers that MUST be validated + imported
|
||||
/// AND if at least one of those headers is invalid, all other MUST be considered invalid.
|
||||
pub(crate) fn check_finality_proof<Block: BlockT, B>(
|
||||
blockchain: &B,
|
||||
current_set_id: u64,
|
||||
current_authorities: AuthorityList,
|
||||
authorities_provider: &dyn AuthoritySetForFinalityChecker<Block>,
|
||||
remote_proof: Vec<u8>,
|
||||
) -> ClientResult<FinalityEffects<Block::Header>>
|
||||
where
|
||||
NumberFor<Block>: BlockNumberOps,
|
||||
B: BlockchainBackend<Block>,
|
||||
{
|
||||
do_check_finality_proof::<_, _, GrandpaJustification<Block>>(
|
||||
blockchain,
|
||||
current_set_id,
|
||||
current_authorities,
|
||||
authorities_provider,
|
||||
remote_proof)
|
||||
}
|
||||
|
||||
fn do_check_finality_proof<Block: BlockT, B, J>(
|
||||
pub(crate) fn check_finality_proof<Block: BlockT, B, J>(
|
||||
blockchain: &B,
|
||||
current_set_id: u64,
|
||||
current_authorities: AuthorityList,
|
||||
@@ -605,7 +586,7 @@ pub(crate) mod tests {
|
||||
use super::*;
|
||||
use sp_core::crypto::Public;
|
||||
|
||||
type FinalityProof = super::FinalityProof<Header>;
|
||||
pub(crate) type FinalityProof = super::FinalityProof<Header>;
|
||||
|
||||
impl<GetAuthorities, ProveAuthorities> AuthoritySetForFinalityProver<Block> for (GetAuthorities, ProveAuthorities)
|
||||
where
|
||||
@@ -621,7 +602,7 @@ pub(crate) mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
struct ClosureAuthoritySetForFinalityChecker<Closure>(pub Closure);
|
||||
pub(crate) struct ClosureAuthoritySetForFinalityChecker<Closure>(pub Closure);
|
||||
|
||||
impl<Closure> AuthoritySetForFinalityChecker<Block> for ClosureAuthoritySetForFinalityChecker<Closure>
|
||||
where
|
||||
@@ -887,7 +868,7 @@ pub(crate) mod tests {
|
||||
blockchain.insert(header(4).hash(), header(4), None, None, NewBlockState::Final).unwrap();
|
||||
blockchain.insert(header(5).hash(), header(5), None, None, NewBlockState::Final).unwrap();
|
||||
blockchain.insert(header(6).hash(), header(6), None, None, NewBlockState::Final).unwrap();
|
||||
let effects = do_check_finality_proof::<_, _, TestJustification>(
|
||||
let effects = check_finality_proof::<_, _, TestJustification>(
|
||||
&blockchain,
|
||||
0,
|
||||
auth3,
|
||||
@@ -915,7 +896,7 @@ pub(crate) mod tests {
|
||||
let blockchain = test_blockchain();
|
||||
|
||||
// when we can't decode proof from Vec<u8>
|
||||
do_check_finality_proof::<_, _, TestJustification>(
|
||||
check_finality_proof::<_, _, TestJustification>(
|
||||
&blockchain,
|
||||
1,
|
||||
vec![(AuthorityId::from_slice(&[3u8; 32]), 1u64)],
|
||||
@@ -929,7 +910,7 @@ pub(crate) mod tests {
|
||||
let blockchain = test_blockchain();
|
||||
|
||||
// when decoded proof has zero length
|
||||
do_check_finality_proof::<_, _, TestJustification>(
|
||||
check_finality_proof::<_, _, TestJustification>(
|
||||
&blockchain,
|
||||
1,
|
||||
vec![(AuthorityId::from_slice(&[3u8; 32]), 1u64)],
|
||||
@@ -944,7 +925,7 @@ pub(crate) mod tests {
|
||||
|
||||
// when intermediate (#0) fragment has non-empty unknown headers
|
||||
let authorities = vec![(AuthorityId::from_slice(&[3u8; 32]), 1u64)];
|
||||
do_check_finality_proof::<_, _, TestJustification>(
|
||||
check_finality_proof::<_, _, TestJustification>(
|
||||
&blockchain,
|
||||
1,
|
||||
authorities.clone(),
|
||||
@@ -969,7 +950,7 @@ pub(crate) mod tests {
|
||||
|
||||
// when intermediate (#0) fragment has empty authorities proof
|
||||
let authorities = vec![(AuthorityId::from_slice(&[3u8; 32]), 1u64)];
|
||||
do_check_finality_proof::<_, _, TestJustification>(
|
||||
check_finality_proof::<_, _, TestJustification>(
|
||||
&blockchain,
|
||||
1,
|
||||
authorities.clone(),
|
||||
@@ -994,7 +975,7 @@ pub(crate) mod tests {
|
||||
|
||||
let initial_authorities = vec![(AuthorityId::from_slice(&[3u8; 32]), 1u64)];
|
||||
let next_authorities = vec![(AuthorityId::from_slice(&[4u8; 32]), 1u64)];
|
||||
let effects = do_check_finality_proof::<_, _, TestJustification>(
|
||||
let effects = check_finality_proof::<_, _, TestJustification>(
|
||||
&blockchain,
|
||||
1,
|
||||
initial_authorities.clone(),
|
||||
|
||||
Reference in New Issue
Block a user