fix: Complete snowbridge pezpallet rebrand and critical bug fixes

- snowbridge-pezpallet-* → pezsnowbridge-pezpallet-* (201 refs)
- pallet/ directories → pezpallet/ (4 locations)
- Fixed pezpallet.rs self-include recursion bug
- Fixed sc-chain-spec hardcoded crate name in derive macro
- Reverted .pezpallet_by_name() to .pallet_by_name() (subxt API)
- Added BizinikiwiConfig type alias for zombienet tests
- Deleted obsolete session state files

Verified: pezsnowbridge-pezpallet-*, pezpallet-staking,
pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
This commit is contained in:
2025-12-16 09:57:23 +03:00
parent eea003e14d
commit 3139ffa25e
3022 changed files with 42157 additions and 23579 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME pallet for GRANDPA finality gadget"
description = "FRAME pezpallet for GRANDPA finality gadget"
readme = "README.md"
documentation = "https://docs.rs/pezpallet-grandpa"
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Benchmarks for the GRANDPA pallet.
//! Benchmarks for the GRANDPA pezpallet.
use super::*;
use pezframe_benchmarking::v2::*;
@@ -73,7 +73,7 @@ mod benchmarks {
}
impl_benchmark_test_suite!(
Pallet,
Pezpallet,
crate::mock::new_test_ext(vec![(1, 1), (2, 1), (3, 1)]),
crate::mock::Test,
);
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Default weights for the GRANDPA Pallet
//! Default weights for the GRANDPA Pezpallet
//! This file was not auto-generated.
use pezframe_support::weights::{
@@ -32,7 +32,7 @@
//!
//! IMPORTANT:
//! When using this module for enabling equivocation reporting it is required
//! that the `ValidateUnsigned` for the GRANDPA pallet is used in the runtime
//! that the `ValidateUnsigned` for the GRANDPA pezpallet is used in the runtime
//! definition.
use alloc::{boxed::Box, vec, vec::Vec};
@@ -54,7 +54,7 @@ use pezsp_staking::{
SessionIndex,
};
use super::{Call, Config, Error, Pallet, LOG_TARGET};
use super::{Call, Config, Error, Pezpallet, LOG_TARGET};
/// A round number and set id which point on the time of an offence.
#[derive(Copy, Clone, PartialOrd, Ord, Eq, PartialEq, Encode, Decode)]
@@ -113,7 +113,7 @@ impl<Offender: Clone> Offence<Offender> for EquivocationOffence<Offender> {
/// `offchain::CreateTransactionBase`.
/// - On-chain validity checks and processing are mostly delegated to the user provided generic
/// types implementing `KeyOwnerProofSystem` and `ReportOffence` traits.
/// - Offence reporter for unsigned transactions is fetched via the the authorship pallet.
/// - Offence reporter for unsigned transactions is fetched via the the authorship pezpallet.
pub struct EquivocationReportSystem<T, R, P, L>(core::marker::PhantomData<(T, R, P, L)>);
impl<T, R, P, L>
@@ -177,7 +177,7 @@ where
evidence: (EquivocationProof<T::Hash, BlockNumberFor<T>>, T::KeyOwnerProof),
) -> Result<(), DispatchError> {
let (equivocation_proof, key_owner_proof) = evidence;
let reporter = reporter.or_else(|| pezpallet_authorship::Pallet::<T>::author());
let reporter = reporter.or_else(|| pezpallet_authorship::Pezpallet::<T>::author());
let offender = equivocation_proof.offender().clone();
// We check the equivocation within the context of its set id (and
@@ -239,7 +239,7 @@ where
/// It restricts calls to `report_equivocation_unsigned` to local calls (i.e. extrinsics generated
/// on this node) or that already in a block. This guarantees that only block authors can include
/// unsigned equivocation reports.
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
pub fn validate_unsigned(source: TransactionSource, call: &Call<T>) -> TransactionValidity {
if let Call::report_equivocation_unsigned { equivocation_proof, key_owner_proof } = call {
// discard equivocation report not coming from the local node
+45 -45
View File
@@ -67,10 +67,10 @@ mod tests;
pub use equivocation::{EquivocationOffence, EquivocationReportSystem, TimeSlot};
pub use pallet::*;
pub use pezpallet::*;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::{dispatch::DispatchResult, pezpallet_prelude::*};
use pezframe_system::pezpallet_prelude::*;
@@ -78,11 +78,11 @@ pub mod pallet {
/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(5);
#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
#[pezpallet::storage_version(STORAGE_VERSION)]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// The event type of this module.
#[allow(deprecated)]
@@ -90,15 +90,15 @@ pub mod pallet {
+ Into<<Self as pezframe_system::Config>::RuntimeEvent>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// Weights for this pallet.
/// Weights for this pezpallet.
type WeightInfo: WeightInfo;
/// Max Authorities in use
#[pallet::constant]
#[pezpallet::constant]
type MaxAuthorities: Get<u32>;
/// The maximum number of nominators for each validator.
#[pallet::constant]
#[pezpallet::constant]
type MaxNominators: Get<u32>;
/// The maximum number of entries to keep in the set id to session index mapping.
@@ -107,7 +107,7 @@ pub mod pallet {
/// value should relate to the bonding duration of whatever staking system is
/// being used (if any). If equivocation handling is not enabled then this value
/// can be zero.
#[pallet::constant]
#[pezpallet::constant]
type MaxSetIdSessionEntries: Get<u64>;
/// The proof of key ownership, used for validating equivocation reports
@@ -124,8 +124,8 @@ pub mod pallet {
>;
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
fn on_finalize(block_number: BlockNumberFor<T>) {
// check for scheduled pending authority set changes
if let Some(pending_change) = PendingChange::<T>::get() {
@@ -186,14 +186,14 @@ pub mod pallet {
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Report voter equivocation/misbehavior. This method will verify the
/// equivocation proof and validate the given key ownership proof
/// against the extracted offender. If both are valid, the offence
/// will be reported.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::report_equivocation(
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::report_equivocation(
key_owner_proof.validator_count(),
T::MaxNominators::get(),
))]
@@ -221,8 +221,8 @@ pub mod pallet {
/// block authors will call it (validated in `ValidateUnsigned`), as such
/// if the block author is defined it will be defined as the equivocation
/// reporter.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::report_equivocation(
#[pezpallet::call_index(1)]
#[pezpallet::weight(T::WeightInfo::report_equivocation(
key_owner_proof.validator_count(),
T::MaxNominators::get(),
))]
@@ -252,8 +252,8 @@ pub mod pallet {
/// block of all validators of the new authority set.
///
/// Only callable by root.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::note_stalled())]
#[pezpallet::call_index(2)]
#[pezpallet::weight(T::WeightInfo::note_stalled())]
pub fn note_stalled(
origin: OriginFor<T>,
delay: BlockNumberFor<T>,
@@ -266,8 +266,8 @@ pub mod pallet {
}
}
#[pallet::event]
#[pallet::generate_deposit(fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(fn deposit_event)]
pub enum Event {
/// New authority set has been applied.
NewAuthorities { authority_set: AuthorityList },
@@ -277,7 +277,7 @@ pub mod pallet {
Resumed,
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Attempt to signal GRANDPA pause when the authority set isn't live
/// (either paused or already pending pause).
@@ -297,32 +297,32 @@ pub mod pallet {
DuplicateOffenceReport,
}
#[pallet::type_value]
#[pezpallet::type_value]
pub fn DefaultForState<T: Config>() -> StoredState<BlockNumberFor<T>> {
StoredState::Live
}
/// State of the current authority set.
#[pallet::storage]
#[pezpallet::storage]
pub type State<T: Config> =
StorageValue<_, StoredState<BlockNumberFor<T>>, ValueQuery, DefaultForState<T>>;
/// Pending change: (signaled at, scheduled change).
#[pallet::storage]
#[pezpallet::storage]
pub type PendingChange<T: Config> =
StorageValue<_, StoredPendingChange<BlockNumberFor<T>, T::MaxAuthorities>>;
/// next block number where we can force a change.
#[pallet::storage]
#[pezpallet::storage]
pub type NextForced<T: Config> = StorageValue<_, BlockNumberFor<T>>;
/// `true` if we are currently stalled.
#[pallet::storage]
#[pezpallet::storage]
pub type Stalled<T: Config> = StorageValue<_, (BlockNumberFor<T>, BlockNumberFor<T>)>;
/// The number of changes (both in terms of keys and underlying economic responsibilities)
/// in the "set" of Grandpa validators from genesis.
#[pallet::storage]
#[pezpallet::storage]
pub type CurrentSetId<T: Config> = StorageValue<_, SetId, ValueQuery>;
/// A mapping from grandpa set ID to the index of the *most recent* session for which its
@@ -335,32 +335,32 @@ pub mod pallet {
/// during that session.
///
/// TWOX-NOTE: `SetId` is not under user control.
#[pallet::storage]
#[pezpallet::storage]
pub type SetIdSession<T: Config> = StorageMap<_, Twox64Concat, SetId, SessionIndex>;
/// The current list of authorities.
#[pallet::storage]
#[pezpallet::storage]
pub type Authorities<T: Config> =
StorageValue<_, BoundedAuthorityList<T::MaxAuthorities>, ValueQuery>;
#[derive(pezframe_support::DefaultNoBound)]
#[pallet::genesis_config]
#[pezpallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub authorities: AuthorityList,
#[serde(skip)]
pub _config: core::marker::PhantomData<T>,
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
CurrentSetId::<T>::put(SetId::default());
Pallet::<T>::initialize(self.authorities.clone())
Pezpallet::<T>::initialize(self.authorities.clone())
}
}
#[pallet::validate_unsigned]
impl<T: Config> ValidateUnsigned for Pallet<T> {
#[pezpallet::validate_unsigned]
impl<T: Config> ValidateUnsigned for Pezpallet<T> {
type Call = Call<T>;
fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity {
@@ -426,7 +426,7 @@ pub enum StoredState<N> {
},
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// State of the current authority set.
pub fn state() -> StoredState<BlockNumberFor<T>> {
State::<T>::get()
@@ -474,7 +474,7 @@ impl<T: Config> Pallet<T> {
/// Cannot be done when already paused.
pub fn schedule_pause(in_blocks: BlockNumberFor<T>) -> DispatchResult {
if let StoredState::Live = State::<T>::get() {
let scheduled_at = pezframe_system::Pallet::<T>::block_number();
let scheduled_at = pezframe_system::Pezpallet::<T>::block_number();
State::<T>::put(StoredState::PendingPause { delay: in_blocks, scheduled_at });
Ok(())
@@ -486,7 +486,7 @@ impl<T: Config> Pallet<T> {
/// Schedule a resume of GRANDPA after pausing.
pub fn schedule_resume(in_blocks: BlockNumberFor<T>) -> DispatchResult {
if let StoredState::Paused = State::<T>::get() {
let scheduled_at = pezframe_system::Pallet::<T>::block_number();
let scheduled_at = pezframe_system::Pezpallet::<T>::block_number();
State::<T>::put(StoredState::PendingResume { delay: in_blocks, scheduled_at });
Ok(())
@@ -515,7 +515,7 @@ impl<T: Config> Pallet<T> {
forced: Option<BlockNumberFor<T>>,
) -> DispatchResult {
if !PendingChange::<T>::exists() {
let scheduled_at = pezframe_system::Pallet::<T>::block_number();
let scheduled_at = pezframe_system::Pezpallet::<T>::block_number();
if forced.is_some() {
if NextForced::<T>::get().map_or(false, |next| next > scheduled_at) {
@@ -551,7 +551,7 @@ impl<T: Config> Pallet<T> {
/// Deposit one of this module's logs.
fn deposit_log(log: ConsensusLog<BlockNumberFor<T>>) {
let log = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode());
pezframe_system::Pallet::<T>::deposit_log(log);
pezframe_system::Pezpallet::<T>::deposit_log(log);
}
// Perform module initialization, abstracted so that it can be called either through genesis
@@ -591,11 +591,11 @@ impl<T: Config> Pallet<T> {
}
}
impl<T: Config> pezsp_runtime::BoundToRuntimeAppPublic for Pallet<T> {
impl<T: Config> pezsp_runtime::BoundToRuntimeAppPublic for Pezpallet<T> {
type Public = AuthorityId;
}
impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T>
impl<T: Config> OneSessionHandler<T::AccountId> for Pezpallet<T>
where
T: pezpallet_session::Config,
{
@@ -651,7 +651,7 @@ where
// update the mapping to note that the current set corresponds to the
// latest equivalent session (i.e. now).
let session_index = pezpallet_session::Pallet::<T>::current_index();
let session_index = pezpallet_session::Pezpallet::<T>::current_index();
SetIdSession::<T>::insert(current_set_id, &session_index);
}
@@ -33,7 +33,7 @@ mod v5;
/// will be kept.
///
/// This migration should be added with a runtime upgrade that introduces the
/// `MaxSetIdSessionEntries` constant to the pallet (although it could also be
/// `MaxSetIdSessionEntries` constant to the pezpallet (although it could also be
/// done later on).
pub struct CleanupSetIdSessionMap<T>(core::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for CleanupSetIdSessionMap<T> {
@@ -25,7 +25,7 @@ use pezsp_io::hashing::twox_128;
/// The old prefix.
pub const OLD_PREFIX: &[u8] = b"GrandpaFinality";
/// Migrate the entire storage of this pallet to a new prefix.
/// Migrate the entire storage of this pezpallet to a new prefix.
///
/// This new prefix must be the same as the one set in construct_runtime. For safety, use
/// `PalletInfo` to get it, as:
@@ -36,11 +36,11 @@ pub fn migrate<T: crate::Config, N: AsRef<str>>(new_pallet_name: N) -> Weight {
if new_pallet_name.as_ref().as_bytes() == OLD_PREFIX {
log::info!(
target: LOG_TARGET,
"New pallet name is equal to the old prefix. No migration needs to be done.",
"New pezpallet name is equal to the old prefix. No migration needs to be done.",
);
return Weight::zero();
}
let storage_version = StorageVersion::get::<crate::Pallet<T>>();
let storage_version = StorageVersion::get::<crate::Pezpallet<T>>();
log::info!(
target: LOG_TARGET,
"Running migration to v3.1 for grandpa with storage version {:?}",
@@ -54,7 +54,7 @@ pub fn migrate<T: crate::Config, N: AsRef<str>>(new_pallet_name: N) -> Weight {
new_pallet_name.as_ref().as_bytes(),
);
StorageVersion::new(4).put::<crate::Pallet<T>>();
StorageVersion::new(4).put::<crate::Pezpallet<T>>();
<T as pezframe_system::Config>::BlockWeights::get().max_block
} else {
@@ -74,8 +74,8 @@ pub fn pre_migration<T: crate::Config, N: AsRef<str>>(new: N) {
let next_key = pezsp_io::storage::next_key(&twox_128(OLD_PREFIX)).unwrap();
assert!(next_key.starts_with(&twox_128(OLD_PREFIX)));
// The pallet version is already stored using the pallet name
let storage_key = StorageVersion::storage_key::<crate::Pallet<T>>();
// The pezpallet version is already stored using the pezpallet name
let storage_key = StorageVersion::storage_key::<crate::Pezpallet<T>>();
// ensure nothing is stored in the new prefix.
assert!(
@@ -83,7 +83,7 @@ pub fn pre_migration<T: crate::Config, N: AsRef<str>>(new: N) {
// either nothing is there
true,
// or we ensure that it has no common prefix with twox_128(new),
// or isn't the pallet version that is already stored using the pallet name
// or isn't the pezpallet version that is already stored using the pezpallet name
|next_key| {
!next_key.starts_with(&twox_128(new.as_bytes())) || next_key == storage_key
},
@@ -95,7 +95,7 @@ pub fn pre_migration<T: crate::Config, N: AsRef<str>>(new: N) {
),
);
// ensure storage version is 3.
assert_eq!(StorageVersion::get::<crate::Pallet<T>>(), 3);
assert_eq!(StorageVersion::get::<crate::Pezpallet<T>>(), 3);
}
/// Some checks for after migration. This can be linked to
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{BoundedAuthorityList, Pallet};
use crate::{BoundedAuthorityList, Pezpallet};
use alloc::vec::Vec;
use codec::Decode;
use core::marker::PhantomData;
@@ -64,7 +64,7 @@ impl<T: crate::Config> UncheckedOnRuntimeUpgrade for UncheckedMigrateImpl<T> {
let len = u32::decode(&mut &state[..]).unwrap();
pezframe_support::ensure!(
len == crate::Pallet::<T>::grandpa_authorities().len() as u32,
len == crate::Pezpallet::<T>::grandpa_authorities().len() as u32,
"Grandpa: pre-migrated and post-migrated list should have the same length"
);
@@ -97,6 +97,6 @@ pub type MigrateV4ToV5<T> = VersionedMigration<
4,
5,
UncheckedMigrateImpl<T>,
Pallet<T>,
Pezpallet<T>,
<T as pezframe_system::Config>::DbWeight,
>;
+2 -2
View File
@@ -62,7 +62,7 @@ pezframe_support::construct_runtime!(
impl_opaque_keys! {
pub struct TestSessionKeys {
pub grandpa_authority: super::Pallet<Test>,
pub grandpa_authority: super::Pezpallet<Test>,
}
}
@@ -175,7 +175,7 @@ impl pezpallet_staking::Config for Test {
type BondingDuration = BondingDuration;
type AdminOrigin = pezframe_system::EnsureRoot<Self::AccountId>;
type SessionInterface = Self;
type UnixTime = pezpallet_timestamp::Pallet<Test>;
type UnixTime = pezpallet_timestamp::Pezpallet<Test>;
type EraPayout = pezpallet_staking::ConvertCurve<RewardCurve>;
type NextNewSession = Session;
type ElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
+2 -2
View File
@@ -44,10 +44,10 @@
// frame-omni-bencher
// v1
// benchmark
// pallet
// pezpallet
// --extrinsic=*
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
// --pallet=pezpallet_grandpa
// --pezpallet=pezpallet_grandpa
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/grandpa/src/weights.rs
// --wasm-execution=compiled