Move grandpa crates to consensus folder (#13458)

* Move grandpa under consensus dir
* Rename grandpa folder
* Finish grandpa renaming
* Minor tweaks
* Cargo fmt
* Adjust path to chain spec
This commit is contained in:
Davide Galassi
2023-02-27 17:15:08 +01:00
committed by GitHub
parent 91c595bc78
commit 40c36c0c8a
62 changed files with 356 additions and 356 deletions
+3 -3
View File
@@ -50,14 +50,14 @@ benchmarks! {
251, 129, 29, 45, 32, 29, 6
];
let equivocation_proof1: sp_finality_grandpa::EquivocationProof<H256, u64> =
let equivocation_proof1: sp_consensus_grandpa::EquivocationProof<H256, u64> =
Decode::decode(&mut &EQUIVOCATION_PROOF_BLOB[..]).unwrap();
let equivocation_proof2 = equivocation_proof1.clone();
}: {
sp_finality_grandpa::check_equivocation_proof(equivocation_proof1);
sp_consensus_grandpa::check_equivocation_proof(equivocation_proof1);
} verify {
assert!(sp_finality_grandpa::check_equivocation_proof(equivocation_proof2));
assert!(sp_consensus_grandpa::check_equivocation_proof(equivocation_proof2));
}
note_stalled {
+2 -2
View File
@@ -39,7 +39,7 @@ use sp_std::prelude::*;
use codec::{self as codec, Decode, Encode};
use frame_support::traits::{Get, KeyOwnerProofSystem};
use sp_finality_grandpa::{EquivocationProof, RoundNumber, SetId};
use sp_consensus_grandpa::{EquivocationProof, RoundNumber, SetId};
use sp_runtime::{
transaction_validity::{
InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity,
@@ -251,7 +251,7 @@ fn is_known_offence<T: Config>(
key_owner_proof: &T::KeyOwnerProof,
) -> Result<(), TransactionValidityError> {
// check the membership proof to extract the offender's id
let key = (sp_finality_grandpa::KEY_TYPE, equivocation_proof.offender().clone());
let key = (sp_consensus_grandpa::KEY_TYPE, equivocation_proof.offender().clone());
let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof.clone())
.ok_or(InvalidTransaction::BadProof)?;
+2 -2
View File
@@ -29,7 +29,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
// re-export since this is necessary for `impl_apis` in runtime.
pub use sp_finality_grandpa as fg_primitives;
pub use sp_consensus_grandpa as fg_primitives;
use sp_std::prelude::*;
@@ -555,7 +555,7 @@ impl<T: Config> Pallet<T> {
// validate equivocation proof (check votes are different and
// signatures are valid).
if !sp_finality_grandpa::check_equivocation_proof(equivocation_proof) {
if !sp_consensus_grandpa::check_equivocation_proof(equivocation_proof) {
return Err(Error::<T>::InvalidEquivocationProof.into())
}
+5 -5
View File
@@ -30,8 +30,8 @@ use frame_support::{
},
};
use pallet_session::historical as pallet_session_historical;
use sp_consensus_grandpa::{RoundNumber, SetId, GRANDPA_ENGINE_ID};
use sp_core::{crypto::KeyTypeId, H256};
use sp_finality_grandpa::{RoundNumber, SetId, GRANDPA_ENGINE_ID};
use sp_keyring::Ed25519Keyring;
use sp_runtime::{
curve::PiecewiseLinear,
@@ -354,12 +354,12 @@ pub fn generate_equivocation_proof(
set_id: SetId,
vote1: (RoundNumber, H256, u64, &Ed25519Keyring),
vote2: (RoundNumber, H256, u64, &Ed25519Keyring),
) -> sp_finality_grandpa::EquivocationProof<H256, u64> {
) -> sp_consensus_grandpa::EquivocationProof<H256, u64> {
let signed_prevote = |round, hash, number, keyring: &Ed25519Keyring| {
let prevote = finality_grandpa::Prevote { target_hash: hash, target_number: number };
let prevote_msg = finality_grandpa::Message::Prevote(prevote.clone());
let payload = sp_finality_grandpa::localized_payload(round, set_id, &prevote_msg);
let payload = sp_consensus_grandpa::localized_payload(round, set_id, &prevote_msg);
let signed = keyring.sign(&payload).into();
(prevote, signed)
};
@@ -367,9 +367,9 @@ pub fn generate_equivocation_proof(
let (prevote1, signed1) = signed_prevote(vote1.0, vote1.1, vote1.2, vote1.3);
let (prevote2, signed2) = signed_prevote(vote2.0, vote2.1, vote2.2, vote2.3);
sp_finality_grandpa::EquivocationProof::new(
sp_consensus_grandpa::EquivocationProof::new(
set_id,
sp_finality_grandpa::Equivocation::Prevote(finality_grandpa::Equivocation {
sp_consensus_grandpa::Equivocation::Prevote(finality_grandpa::Equivocation {
round_number: vote1.0,
identity: vote1.3.public().into(),
first: (prevote1, signed1),
+8 -8
View File
@@ -355,7 +355,7 @@ fn report_equivocation_current_set_works() {
// create the key ownership proof
let key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
// report the equivocation and the tx should be dispatched successfully
assert_ok!(Grandpa::report_equivocation_unsigned(
@@ -408,7 +408,7 @@ fn report_equivocation_old_set_works() {
// create the key ownership proof in the "old" set
let key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
start_era(2);
@@ -486,7 +486,7 @@ fn report_equivocation_invalid_set_id() {
let equivocation_keyring = extract_keyring(equivocation_key);
let key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
let set_id = Grandpa::current_set_id();
@@ -524,7 +524,7 @@ fn report_equivocation_invalid_session() {
// generate a key ownership proof at set id = 1
let key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
start_era(2);
@@ -563,7 +563,7 @@ fn report_equivocation_invalid_key_owner_proof() {
// generate a key ownership proof for the authority at index 1
let invalid_key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &invalid_owner_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &invalid_owner_key)).unwrap();
let equivocation_authority_index = 0;
let equivocation_key = &authorities[equivocation_authority_index].0;
@@ -610,7 +610,7 @@ fn report_equivocation_invalid_equivocation_proof() {
// generate a key ownership proof at set id = 1
let key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
let set_id = Grandpa::current_set_id();
@@ -685,7 +685,7 @@ fn report_equivocation_validate_unsigned_prevents_duplicates() {
);
let key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
let call = Call::report_equivocation_unsigned {
equivocation_proof: Box::new(equivocation_proof.clone()),
@@ -873,7 +873,7 @@ fn valid_equivocation_reports_dont_pay_fees() {
// create the key ownership proof.
let key_owner_proof =
Historical::prove((sp_finality_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
Historical::prove((sp_consensus_grandpa::KEY_TYPE, &equivocation_key)).unwrap();
// check the dispatch info for the call.
let info = Call::<Test>::report_equivocation_unsigned {