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
+2 -2
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Benchmarks for the BABE Pallet.
//! Benchmarks for the BABE Pezpallet.
#![cfg(feature = "runtime-benchmarks")]
@@ -71,5 +71,5 @@ mod benchmarks {
assert!(pezsp_consensus_babe::check_equivocation_proof::<Header>(equivocation_proof2));
}
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(3), crate::mock::Test,);
impl_benchmark_test_suite!(Pezpallet, crate::mock::new_test_ext(3), 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 Babe Pallet
//! Default weights for the Babe Pezpallet
//! This file was not auto-generated.
use pezframe_support::weights::{
+7 -7
View File
@@ -25,12 +25,12 @@
//!
//! These can be used in an offchain context in order to submit equivocation
//! reporting extrinsics (from the client that's import BABE blocks).
//! And in a runtime context, so that the BABE pallet can validate the
//! And in a runtime context, so that the BABE pezpallet can validate the
//! equivocation proofs in the extrinsic and report the offences.
//!
//! IMPORTANT:
//! When using this module for enabling equivocation reporting it is required
//! that the `ValidateUnsigned` for the BABE pallet is used in the runtime
//! that the `ValidateUnsigned` for the BABE pezpallet is used in the runtime
//! definition.
use alloc::{boxed::Box, vec, vec::Vec};
@@ -52,7 +52,7 @@ use pezsp_staking::{
SessionIndex,
};
use crate::{Call, Config, Error, Pallet, LOG_TARGET};
use crate::{Call, Config, Error, Pezpallet, LOG_TARGET};
/// BABE equivocation offence report.
///
@@ -103,7 +103,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>
@@ -164,7 +164,7 @@ where
evidence: (EquivocationProof<HeaderFor<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();
let slot = equivocation_proof.slot;
@@ -181,7 +181,7 @@ where
// Check that the slot number is consistent with the session index
// in the key ownership proof (i.e. slot is for that epoch)
if Pallet::<T>::session_index_for_epoch(epoch_index) != session_index {
if Pezpallet::<T>::session_index_for_epoch(epoch_index) != session_index {
return Err(Error::<T>::InvalidKeyOwnershipProof.into());
}
@@ -202,7 +202,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
+62 -62
View File
@@ -70,7 +70,7 @@ pub use randomness::{
ParentBlockRandomness, RandomnessFromOneEpochAgo, RandomnessFromTwoEpochsAgo,
};
pub use pallet::*;
pub use pezpallet::*;
pub trait WeightInfo {
fn plan_config_change() -> Weight;
@@ -98,34 +98,34 @@ pub struct SameAuthoritiesForever;
impl EpochChangeTrigger for SameAuthoritiesForever {
fn trigger<T: Config>(now: BlockNumberFor<T>) {
if Pallet::<T>::should_epoch_change(now) {
if Pezpallet::<T>::should_epoch_change(now) {
let authorities = Authorities::<T>::get();
let next_authorities = authorities.clone();
Pallet::<T>::enact_epoch_change(authorities, next_authorities, None);
Pezpallet::<T>::enact_epoch_change(authorities, next_authorities, None);
}
}
}
const UNDER_CONSTRUCTION_SEGMENT_LENGTH: u32 = 256;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
/// The BABE Pallet
#[pallet::pallet]
pub struct Pallet<T>(_);
/// The BABE Pezpallet
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pallet::disable_pezframe_system_supertrait_check]
#[pezpallet::config]
#[pezpallet::disable_pezframe_system_supertrait_check]
pub trait Config: pezpallet_timestamp::Config {
/// The amount of time, in slots, that each epoch should last.
/// NOTE: Currently it is not possible to change the epoch duration after
/// the chain has started. Attempting to do so will brick block production.
#[pallet::constant]
#[pezpallet::constant]
type EpochDuration: Get<u64>;
/// The expected average block time at which BABE should be creating
@@ -133,7 +133,7 @@ pub mod pallet {
/// what the expected average block time should be based on the slot
/// duration and the security parameter `c` (where `1 - c` represents
/// the probability of a slot being empty).
#[pallet::constant]
#[pezpallet::constant]
type ExpectedBlockTime: Get<Self::Moment>;
/// BABE requires some logic to be triggered on every block to query for whether an epoch
@@ -152,11 +152,11 @@ pub mod pallet {
type WeightInfo: WeightInfo;
/// Max number of authorities allowed
#[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 proof of key ownership, used for validating equivocation reports.
@@ -173,7 +173,7 @@ pub mod pallet {
>;
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// An equivocation proof provided as part of an equivocation report is invalid.
InvalidEquivocationProof,
@@ -186,11 +186,11 @@ pub mod pallet {
}
/// Current epoch index.
#[pallet::storage]
#[pezpallet::storage]
pub type EpochIndex<T> = StorageValue<_, u64, ValueQuery>;
/// Current epoch authorities.
#[pallet::storage]
#[pezpallet::storage]
pub type Authorities<T: Config> = StorageValue<
_,
WeakBoundedVec<(AuthorityId, BabeAuthorityWeight), T::MaxAuthorities>,
@@ -199,11 +199,11 @@ pub mod pallet {
/// The slot at which the first epoch actually started. This is 0
/// until the first block of the chain.
#[pallet::storage]
#[pezpallet::storage]
pub type GenesisSlot<T> = StorageValue<_, Slot, ValueQuery>;
/// Current slot number.
#[pallet::storage]
#[pezpallet::storage]
pub type CurrentSlot<T> = StorageValue<_, Slot, ValueQuery>;
/// The epoch randomness for the *current* epoch.
@@ -219,19 +219,19 @@ pub mod pallet {
// NOTE: the following fields don't use the constants to define the
// array size because the metadata API currently doesn't resolve the
// variable to its underlying value.
#[pallet::storage]
#[pezpallet::storage]
pub type Randomness<T> = StorageValue<_, BabeRandomness, ValueQuery>;
/// Pending epoch configuration change that will be applied when the next epoch is enacted.
#[pallet::storage]
#[pezpallet::storage]
pub type PendingEpochConfigChange<T> = StorageValue<_, NextConfigDescriptor>;
/// Next epoch randomness.
#[pallet::storage]
#[pezpallet::storage]
pub type NextRandomness<T> = StorageValue<_, BabeRandomness, ValueQuery>;
/// Next epoch authorities.
#[pallet::storage]
#[pezpallet::storage]
pub type NextAuthorities<T: Config> = StorageValue<
_,
WeakBoundedVec<(AuthorityId, BabeAuthorityWeight), T::MaxAuthorities>,
@@ -247,11 +247,11 @@ pub mod pallet {
/// Once a segment reaches this length, we begin the next one.
/// We reset all segments and return to `0` at the beginning of every
/// epoch.
#[pallet::storage]
#[pezpallet::storage]
pub type SegmentIndex<T> = StorageValue<_, u32, ValueQuery>;
/// TWOX-NOTE: `SegmentIndex` is an increasing integer, so this is okay.
#[pallet::storage]
#[pezpallet::storage]
pub type UnderConstruction<T: Config> = StorageMap<
_,
Twox64Concat,
@@ -262,14 +262,14 @@ pub mod pallet {
/// Temporary value (cleared at block finalization) which is `Some`
/// if per-block initialization has already been called for current block.
#[pallet::storage]
#[pezpallet::storage]
pub type Initialized<T> = StorageValue<_, Option<PreDigest>>;
/// This field should always be populated during block processing unless
/// secondary plain slots are enabled (which don't contain a VRF output).
///
/// It is set in `on_finalize`, before it will contain the value from the last block.
#[pallet::storage]
#[pezpallet::storage]
pub type AuthorVrfRandomness<T> = StorageValue<_, Option<BabeRandomness>, ValueQuery>;
/// The block numbers when the last and current epoch have started, respectively `N-1` and
@@ -277,7 +277,7 @@ pub mod pallet {
/// NOTE: We track this is in order to annotate the block number when a given pool of
/// entropy was fixed (i.e. it was known to chain observers). Since epochs are defined in
/// slots, which may be skipped, the block numbers may not line up with the slot numbers.
#[pallet::storage]
#[pezpallet::storage]
pub type EpochStart<T: Config> =
StorageValue<_, (BlockNumberFor<T>, BlockNumberFor<T>), ValueQuery>;
@@ -286,17 +286,17 @@ pub mod pallet {
/// This entry is populated as part of block execution and is cleaned up
/// on block finalization. Querying this storage entry outside of block
/// execution context should always yield zero.
#[pallet::storage]
#[pezpallet::storage]
pub type Lateness<T: Config> = StorageValue<_, BlockNumberFor<T>, ValueQuery>;
/// The configuration for the current epoch. Should never be `None` as it is initialized in
/// genesis.
#[pallet::storage]
#[pezpallet::storage]
pub type EpochConfig<T> = StorageValue<_, BabeEpochConfiguration>;
/// The configuration for the next epoch, `None` if the config will not change
/// (you can fallback to `EpochConfig` instead in that case).
#[pallet::storage]
#[pezpallet::storage]
pub type NextEpochConfig<T> = StorageValue<_, BabeEpochConfiguration>;
/// A list of the last 100 skipped epochs and the corresponding session index
@@ -307,12 +307,12 @@ pub mod pallet {
/// way to tie together sessions and epoch indices, i.e. we need to validate that
/// a validator was the owner of a given key on a given session, and what the
/// active epoch index was during that session.
#[pallet::storage]
#[pezpallet::storage]
pub type SkippedEpochs<T> =
StorageValue<_, BoundedVec<(u64, SessionIndex), ConstU32<100>>, ValueQuery>;
#[derive(pezframe_support::DefaultNoBound)]
#[pallet::genesis_config]
#[pezpallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub authorities: Vec<(AuthorityId, BabeAuthorityWeight)>,
pub epoch_config: BabeEpochConfiguration,
@@ -320,17 +320,17 @@ pub mod pallet {
pub _config: core::marker::PhantomData<T>,
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
SegmentIndex::<T>::put(0);
Pallet::<T>::initialize_genesis_authorities(&self.authorities);
Pezpallet::<T>::initialize_genesis_authorities(&self.authorities);
EpochConfig::<T>::put(&self.epoch_config);
}
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
/// Initialization
fn on_initialize(now: BlockNumberFor<T>) -> Weight {
Self::initialize(now);
@@ -396,14 +396,14 @@ pub mod pallet {
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Report authority 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 as Config>::WeightInfo::report_equivocation(
#[pezpallet::call_index(0)]
#[pezpallet::weight(<T as Config>::WeightInfo::report_equivocation(
key_owner_proof.validator_count(),
T::MaxNominators::get(),
))]
@@ -429,8 +429,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 as Config>::WeightInfo::report_equivocation(
#[pezpallet::call_index(1)]
#[pezpallet::weight(<T as Config>::WeightInfo::report_equivocation(
key_owner_proof.validator_count(),
T::MaxNominators::get(),
))]
@@ -451,8 +451,8 @@ pub mod pallet {
/// the next call to `enact_epoch_change`. The config will be activated one epoch after.
/// Multiple calls to this method will replace any existing planned config change that had
/// not been enacted yet.
#[pallet::call_index(2)]
#[pallet::weight(<T as Config>::WeightInfo::plan_config_change())]
#[pezpallet::call_index(2)]
#[pezpallet::weight(<T as Config>::WeightInfo::plan_config_change())]
pub fn plan_config_change(
origin: OriginFor<T>,
config: NextConfigDescriptor,
@@ -471,8 +471,8 @@ pub mod pallet {
}
}
#[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 {
Self::validate_unsigned(source, call)
@@ -484,7 +484,7 @@ pub mod pallet {
}
}
impl<T: Config> FindAuthor<u32> for Pallet<T> {
impl<T: Config> FindAuthor<u32> for Pezpallet<T> {
fn find_author<'a, I>(digests: I) -> Option<u32>
where
I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,
@@ -500,24 +500,24 @@ impl<T: Config> FindAuthor<u32> for Pallet<T> {
}
}
impl<T: Config> IsMember<AuthorityId> for Pallet<T> {
impl<T: Config> IsMember<AuthorityId> for Pezpallet<T> {
fn is_member(authority_id: &AuthorityId) -> bool {
Authorities::<T>::get().iter().any(|id| &id.0 == authority_id)
}
}
impl<T: Config> pezpallet_session::ShouldEndSession<BlockNumberFor<T>> for Pallet<T> {
impl<T: Config> pezpallet_session::ShouldEndSession<BlockNumberFor<T>> for Pezpallet<T> {
fn should_end_session(now: BlockNumberFor<T>) -> bool {
// it might be (and it is in current implementation) that session module is calling
// `should_end_session` from it's own `on_initialize` handler, in which case it's
// possible that babe's own `on_initialize` has not run yet, so let's ensure that we
// have initialized the pallet and updated the current slot.
// have initialized the pezpallet and updated the current slot.
Self::initialize(now);
Self::should_epoch_change(now)
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Public function to access epoch_index storage.
pub fn epoch_index() -> u64 {
EpochIndex::<T>::get()
@@ -690,7 +690,7 @@ impl<T: Config> Pallet<T> {
// Update the start blocks of the previous and new current epoch.
EpochStart::<T>::mutate(|(previous_epoch_start_block, current_epoch_start_block)| {
*previous_epoch_start_block = core::mem::take(current_epoch_start_block);
*current_epoch_start_block = <pezframe_system::Pallet<T>>::block_number();
*current_epoch_start_block = <pezframe_system::Pezpallet<T>>::block_number();
});
// After we update the current epoch, we signal the *next* epoch change
@@ -771,7 +771,7 @@ impl<T: Config> Pallet<T> {
fn deposit_consensus<U: Encode>(new: U) {
let log = DigestItem::Consensus(BABE_ENGINE_ID, new.encode());
<pezframe_system::Pallet<T>>::deposit_log(log)
<pezframe_system::Pezpallet<T>>::deposit_log(log)
}
fn deposit_randomness(randomness: &BabeRandomness) {
@@ -828,7 +828,7 @@ impl<T: Config> Pallet<T> {
}
let pre_digest =
<pezframe_system::Pallet<T>>::digest()
<pezframe_system::Pezpallet<T>>::digest()
.logs
.iter()
.filter_map(|s| s.as_pre_runtime())
@@ -927,7 +927,7 @@ impl<T: Config> Pallet<T> {
}
}
impl<T: Config> OnTimestampSet<T::Moment> for Pallet<T> {
impl<T: Config> OnTimestampSet<T::Moment> for Pezpallet<T> {
fn on_timestamp_set(moment: T::Moment) {
let slot_duration = Self::slot_duration();
assert!(!slot_duration.is_zero(), "Babe slot duration cannot be zero.");
@@ -944,7 +944,7 @@ impl<T: Config> OnTimestampSet<T::Moment> for Pallet<T> {
}
impl<T: Config> pezframe_support::traits::EstimateNextSessionRotation<BlockNumberFor<T>>
for Pallet<T>
for Pezpallet<T>
{
fn average_session_length() -> BlockNumberFor<T> {
T::EpochDuration::get().saturated_into()
@@ -971,17 +971,17 @@ impl<T: Config> pezframe_support::traits::EstimateNextSessionRotation<BlockNumbe
}
}
impl<T: Config> pezframe_support::traits::Lateness<BlockNumberFor<T>> for Pallet<T> {
impl<T: Config> pezframe_support::traits::Lateness<BlockNumberFor<T>> for Pezpallet<T> {
fn lateness(&self) -> BlockNumberFor<T> {
Lateness::<T>::get()
}
}
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,
{
@@ -1017,7 +1017,7 @@ where
),
);
let session_index = <pezpallet_session::Pallet<T>>::current_index();
let session_index = <pezpallet_session::Pezpallet<T>>::current_index();
Self::enact_epoch_change(bounded_authorities, next_bounded_authorities, Some(session_index))
}
@@ -1052,7 +1052,7 @@ pub mod migrations {
use super::*;
use pezframe_support::pezpallet_prelude::{StorageValue, ValueQuery};
/// Something that can return the storage prefix of the `Babe` pallet.
/// Something that can return the storage prefix of the `Babe` pezpallet.
pub trait BabePalletPrefix: Config {
fn pezpallet_prefix() -> &'static str;
}
+2 -2
View File
@@ -87,7 +87,7 @@ where
impl_opaque_keys! {
pub struct MockSessionKeys {
pub babe_authority: super::Pallet<Test>,
pub babe_authority: super::Pezpallet<Test>,
}
}
@@ -170,7 +170,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
@@ -160,7 +160,7 @@ impl<T: Config> RandomnessT<Option<T::Hash>, BlockNumberFor<T>> for ParentBlockR
T::Hashing::hash(&subject[..])
});
(random, <pezframe_system::Pallet<T>>::block_number().saturating_sub(One::one()))
(random, <pezframe_system::Pezpallet<T>>::block_number().saturating_sub(One::one()))
}
}
@@ -168,6 +168,6 @@ impl<T: Config> RandomnessT<Option<T::Hash>, BlockNumberFor<T>> for ParentBlockR
impl<T: Config> RandomnessT<Option<T::Hash>, BlockNumberFor<T>> for CurrentBlockRandomness<T> {
fn random(subject: &[u8]) -> (Option<T::Hash>, BlockNumberFor<T>) {
let (random, _) = ParentBlockRandomness::<T>::random(subject);
(random, <pezframe_system::Pallet<T>>::block_number())
(random, <pezframe_system::Pezpallet<T>>::block_number())
}
}
+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_babe
// --pezpallet=pezpallet_babe
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/babe/src/weights.rs
// --wasm-execution=compiled