mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 05:51:02 +00:00
Move BEEFY code to consensus (#13484)
* Move beefy primitives to consensus dir * Move beefy gadget to client consensus folder * Rename beefy crates
This commit is contained in:
@@ -36,13 +36,13 @@
|
||||
|
||||
use sp_std::prelude::*;
|
||||
|
||||
use beefy_primitives::{EquivocationProof, ValidatorSetId};
|
||||
use codec::{self as codec, Decode, Encode};
|
||||
use frame_support::{
|
||||
log,
|
||||
traits::{Get, KeyOwnerProofSystem},
|
||||
};
|
||||
use frame_system::pallet_prelude::BlockNumberFor;
|
||||
use sp_consensus_beefy::{EquivocationProof, ValidatorSetId};
|
||||
use sp_runtime::{
|
||||
transaction_validity::{
|
||||
InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity,
|
||||
@@ -271,7 +271,7 @@ fn is_known_offence<T: Config>(
|
||||
) -> Result<(), TransactionValidityError> {
|
||||
// check the membership proof to extract the offender's id,
|
||||
// equivocation validity will be fully checked during the call.
|
||||
let key = (beefy_primitives::KEY_TYPE, equivocation_proof.offender_id().clone());
|
||||
let key = (sp_consensus_beefy::KEY_TYPE, equivocation_proof.offender_id().clone());
|
||||
|
||||
let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof.clone())
|
||||
.ok_or(InvalidTransaction::BadProof)?;
|
||||
|
||||
@@ -40,7 +40,7 @@ use sp_session::{GetSessionNumber, GetValidatorCount};
|
||||
use sp_staking::SessionIndex;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
use beefy_primitives::{
|
||||
use sp_consensus_beefy::{
|
||||
AuthorityIndex, BeefyAuthorityId, ConsensusLog, EquivocationProof, OnNewValidatorSet,
|
||||
ValidatorSet, BEEFY_ENGINE_ID, GENESIS_AUTHORITY_SET_ID,
|
||||
};
|
||||
@@ -135,7 +135,7 @@ pub mod pallet {
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn validator_set_id)]
|
||||
pub(super) type ValidatorSetId<T: Config> =
|
||||
StorageValue<_, beefy_primitives::ValidatorSetId, ValueQuery>;
|
||||
StorageValue<_, sp_consensus_beefy::ValidatorSetId, ValueQuery>;
|
||||
|
||||
/// Authorities set scheduled to be used with the next session
|
||||
#[pallet::storage]
|
||||
@@ -156,7 +156,7 @@ pub mod pallet {
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn session_for_set)]
|
||||
pub(super) type SetIdSession<T: Config> =
|
||||
StorageMap<_, Twox64Concat, beefy_primitives::ValidatorSetId, SessionIndex>;
|
||||
StorageMap<_, Twox64Concat, sp_consensus_beefy::ValidatorSetId, SessionIndex>;
|
||||
|
||||
/// Block number where BEEFY consensus is enabled/started.
|
||||
/// If changing this, make sure `Self::ValidatorSetId` is also reset to
|
||||
@@ -280,7 +280,7 @@ impl<T: Config> Pallet<T> {
|
||||
/// Return the current active BEEFY validator set.
|
||||
pub fn validator_set() -> Option<ValidatorSet<T::BeefyId>> {
|
||||
let validators: BoundedVec<T::BeefyId, T::MaxAuthorities> = Self::authorities();
|
||||
let id: beefy_primitives::ValidatorSetId = Self::validator_set_id();
|
||||
let id: sp_consensus_beefy::ValidatorSetId = Self::validator_set_id();
|
||||
ValidatorSet::<T::BeefyId>::new(validators, id)
|
||||
}
|
||||
|
||||
@@ -390,13 +390,13 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
// validate the key ownership proof extracting the id of the offender.
|
||||
let offender = T::KeyOwnerProofSystem::check_proof(
|
||||
(beefy_primitives::KEY_TYPE, offender_id),
|
||||
(sp_consensus_beefy::KEY_TYPE, offender_id),
|
||||
key_owner_proof,
|
||||
)
|
||||
.ok_or(Error::<T>::InvalidKeyOwnershipProof)?;
|
||||
|
||||
// validate equivocation proof (check votes are different and signatures are valid).
|
||||
if !beefy_primitives::check_equivocation_proof(&equivocation_proof) {
|
||||
if !sp_consensus_beefy::check_equivocation_proof(&equivocation_proof) {
|
||||
return Err(Error::<T>::InvalidEquivocationProof.into())
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ use sp_staking::{EraIndex, SessionIndex};
|
||||
|
||||
use crate as pallet_beefy;
|
||||
|
||||
pub use beefy_primitives::{
|
||||
pub use sp_consensus_beefy::{
|
||||
crypto::{AuthorityId as BeefyId, AuthoritySignature as BeefySignature},
|
||||
ConsensusLog, EquivocationProof, BEEFY_ENGINE_ID,
|
||||
};
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
|
||||
use std::vec;
|
||||
|
||||
use beefy_primitives::{
|
||||
use codec::Encode;
|
||||
use sp_consensus_beefy::{
|
||||
check_equivocation_proof, generate_equivocation_proof, known_payloads::MMR_ROOT_ID,
|
||||
Keyring as BeefyKeyring, Payload, ValidatorSet,
|
||||
};
|
||||
use codec::Encode;
|
||||
|
||||
use sp_runtime::DigestItem;
|
||||
|
||||
@@ -298,7 +298,7 @@ fn report_equivocation_current_set_works() {
|
||||
|
||||
// create the key ownership proof
|
||||
let key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
|
||||
// report the equivocation and the tx should be dispatched successfully
|
||||
assert_ok!(Beefy::report_equivocation_unsigned(
|
||||
@@ -355,7 +355,7 @@ fn report_equivocation_old_set_works() {
|
||||
|
||||
// create the key ownership proof in the "old" set
|
||||
let key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
|
||||
start_era(2);
|
||||
|
||||
@@ -437,7 +437,7 @@ fn report_equivocation_invalid_set_id() {
|
||||
let equivocation_keyring = BeefyKeyring::from_public(equivocation_key).unwrap();
|
||||
|
||||
let key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
|
||||
let payload1 = Payload::from_single_entry(MMR_ROOT_ID, vec![42]);
|
||||
let payload2 = Payload::from_single_entry(MMR_ROOT_ID, vec![128]);
|
||||
@@ -476,7 +476,7 @@ fn report_equivocation_invalid_session() {
|
||||
|
||||
// generate a key ownership proof at current era set id
|
||||
let key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
|
||||
start_era(2);
|
||||
|
||||
@@ -520,7 +520,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((beefy_primitives::KEY_TYPE, &invalid_owner_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &invalid_owner_key)).unwrap();
|
||||
|
||||
let equivocation_authority_index = 0;
|
||||
let equivocation_key = &authorities[equivocation_authority_index];
|
||||
@@ -569,7 +569,7 @@ fn report_equivocation_invalid_equivocation_proof() {
|
||||
|
||||
// generate a key ownership proof at set id in era 1
|
||||
let key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
|
||||
let assert_invalid_equivocation_proof = |equivocation_proof| {
|
||||
assert_err!(
|
||||
@@ -650,7 +650,7 @@ fn report_equivocation_validate_unsigned_prevents_duplicates() {
|
||||
);
|
||||
|
||||
let key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
|
||||
let call = Call::report_equivocation_unsigned {
|
||||
equivocation_proof: Box::new(equivocation_proof.clone()),
|
||||
@@ -756,7 +756,7 @@ fn valid_equivocation_reports_dont_pay_fees() {
|
||||
|
||||
// create the key ownership proof.
|
||||
let key_owner_proof =
|
||||
Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap();
|
||||
|
||||
// check the dispatch info for the call.
|
||||
let info = Call::<Test>::report_equivocation_unsigned {
|
||||
|
||||
Reference in New Issue
Block a user