Skip to content

Commit

Permalink
Fix init-bridge (paritytech#1900)
Browse files Browse the repository at this point in the history
  • Loading branch information
serban300 committed Feb 23, 2023
1 parent 3c15c36 commit 2d83d63
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion modules/grandpa/src/lib.rs
Expand Up @@ -181,7 +181,7 @@ pub mod pallet {
let is_authorities_change_enacted =
try_enact_authority_change::<T, I>(&finality_target, set_id)?;
let may_refund_call_fee = is_authorities_change_enacted &&
submit_finality_proof_info_from_args::<T, I>(&*finality_target, &justification)
submit_finality_proof_info_from_args::<T, I>(&finality_target, &justification)
.fits_limits();
<RequestCount<T, I>>::mutate(|count| *count += 1);
insert_header::<T, I>(*finality_target, hash);
Expand Down
2 changes: 1 addition & 1 deletion primitives/header-chain/src/justification.rs
Expand Up @@ -135,7 +135,7 @@ pub fn decode_justification_target<Header: HeaderT>(
}

/// Verify and optimize given justification by removing unknown and duplicate votes.
pub fn optimize_justification<Header: HeaderT>(
pub fn verify_and_optimize_justification<Header: HeaderT>(
finalized_target: (Header::Hash, Header::Number),
authorities_set_id: SetId,
authorities_set: &VoterSet<AuthorityId>,
Expand Down
11 changes: 6 additions & 5 deletions primitives/header-chain/tests/justification.rs
Expand Up @@ -17,7 +17,8 @@
//! Tests for Grandpa Justification code.

use bp_header_chain::justification::{
optimize_justification, required_justification_precommits, verify_justification, Error,
required_justification_precommits, verify_and_optimize_justification, verify_justification,
Error,
};
use bp_test_utils::*;

Expand Down Expand Up @@ -199,7 +200,7 @@ fn optimizer_does_noting_with_minimal_justification() {
let justification = make_default_justification::<TestHeader>(&test_header(1));

let num_precommits_before = justification.commit.precommits.len();
let justification = optimize_justification::<TestHeader>(
let justification = verify_and_optimize_justification::<TestHeader>(
header_id::<TestHeader>(1),
TEST_GRANDPA_SET_ID,
&voter_set(),
Expand All @@ -222,7 +223,7 @@ fn unknown_authority_votes_are_removed_by_optimizer() {
));

let num_precommits_before = justification.commit.precommits.len();
let justification = optimize_justification::<TestHeader>(
let justification = verify_and_optimize_justification::<TestHeader>(
header_id::<TestHeader>(1),
TEST_GRANDPA_SET_ID,
&voter_set(),
Expand All @@ -243,7 +244,7 @@ fn duplicate_authority_votes_are_removed_by_optimizer() {
.push(justification.commit.precommits.first().cloned().unwrap());

let num_precommits_before = justification.commit.precommits.len();
let justification = optimize_justification::<TestHeader>(
let justification = verify_and_optimize_justification::<TestHeader>(
header_id::<TestHeader>(1),
TEST_GRANDPA_SET_ID,
&voter_set(),
Expand All @@ -266,7 +267,7 @@ fn redundant_authority_votes_are_removed_by_optimizer() {
));

let num_precommits_before = justification.commit.precommits.len();
let justification = optimize_justification::<TestHeader>(
let justification = verify_and_optimize_justification::<TestHeader>(
header_id::<TestHeader>(1),
TEST_GRANDPA_SET_ID,
&voter_set(),
Expand Down
8 changes: 4 additions & 4 deletions relays/lib-substrate-relay/src/finality/engine.rs
Expand Up @@ -19,7 +19,7 @@
use crate::error::Error;
use async_trait::async_trait;
use bp_header_chain::{
justification::{verify_justification, GrandpaJustification},
justification::{verify_and_optimize_justification, GrandpaJustification},
ConsensusLogReader, FinalityProof, GrandpaConsensusLogReader,
};
use bp_runtime::{BasicOperatingMode, HeaderIdProvider, OperatingMode};
Expand Down Expand Up @@ -172,7 +172,7 @@ impl<C: ChainWithGrandpa> Engine<C> for Grandpa<C> {
// actual authorities set (which we have read now) may have changed, so this
// `optimize_justification` may fail. But if target chain is configured properly, it'll fail
// anyway, after we submit transaction and failing earlier is better. So - it is fine
bp_header_chain::justification::optimize_justification(
verify_and_optimize_justification(
(header.hash(), *header.number()),
authority_set_id,
&authority_set,
Expand Down Expand Up @@ -272,11 +272,11 @@ impl<C: ChainWithGrandpa> Engine<C> for Grandpa<C> {
initial_authorities_set_id,
);

let is_valid_set_id = verify_justification::<C::Header>(
let is_valid_set_id = verify_and_optimize_justification(
(initial_header_hash, initial_header_number),
initial_authorities_set_id,
&authorities_for_verification,
&justification,
justification.clone(),
)
.is_ok();

Expand Down

0 comments on commit 2d83d63

Please sign in to comment.