Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix init-bridge #1900

Merged
merged 1 commit into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/grandpa/src/lib.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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