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's I'm online pallet"
description = "FRAME's I'm online pezpallet"
readme = "README.md"
documentation = "https://docs.rs/pezpallet-im-online"
+9 -9
View File
@@ -28,24 +28,24 @@ It is submitted as an Unsigned Transaction via off-chain workers.
```rust
use pallet_im_online::{self as im_online};
#[frame_support::pallet]
pub mod pallet {
#[frame_support::pezpallet]
pub mod pezpallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: frame_system::Config + im_online::Config {}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::weight(0)]
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
#[pezpallet::weight(0)]
pub fn is_online(origin: OriginFor<T>, authority_index: u32) -> DispatchResult {
let _sender = ensure_signed(origin)?;
let _is_online = <im_online::Pallet<T>>::is_online(authority_index);
let _is_online = <im_online::Pezpallet<T>>::is_online(authority_index);
Ok(())
}
}
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! I'm Online pallet benchmarking.
//! I'm Online pezpallet benchmarking.
#![cfg(feature = "runtime-benchmarks")]
@@ -83,7 +83,7 @@ mod benchmarks {
#[block]
{
Pallet::<T>::validate_unsigned(TransactionSource::InBlock, &call)
Pezpallet::<T>::validate_unsigned(TransactionSource::InBlock, &call)
.map_err(<&str>::from)?;
}
@@ -100,7 +100,7 @@ mod benchmarks {
#[block]
{
Pallet::<T>::validate_unsigned(TransactionSource::InBlock, &call)
Pezpallet::<T>::validate_unsigned(TransactionSource::InBlock, &call)
.map_err(<&str>::from)?;
<Call<T> as Decode>::decode(&mut &*call_enc)
.expect("call is encoded above, encoding must be correct")
@@ -111,7 +111,7 @@ mod benchmarks {
}
impl_benchmark_test_suite! {
Pallet,
Pezpallet,
mock::new_test_ext(),
mock::Runtime
}
+47 -47
View File
@@ -15,14 +15,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # I'm online Pallet
//! # I'm online Pezpallet
//!
//! If the local node is a validator (i.e. contains an authority key), this pallet
//! If the local node is a validator (i.e. contains an authority key), this pezpallet
//! gossips a heartbeat transaction with each new session. The heartbeat functions
//! as a simple mechanism to signal that the node is online in the current era.
//!
//! Received heartbeats are tracked for one era and reset with each new era. The
//! pallet exposes two public functions to query if a heartbeat has been received
//! pezpallet exposes two public functions to query if a heartbeat has been received
//! in the current era or session.
//!
//! The heartbeat is a signed transaction, which was signed using the session key
@@ -31,7 +31,7 @@
//!
//! - [`Config`]
//! - [`Call`]
//! - [`Pallet`]
//! - [`Pezpallet`]
//!
//! ## Interface
//!
@@ -44,24 +44,24 @@
//! ```
//! use pezpallet_im_online::{self as im_online};
//!
//! #[pezframe_support::pallet]
//! pub mod pallet {
//! #[pezframe_support::pezpallet]
//! pub mod pezpallet {
//! use super::*;
//! use pezframe_support::pezpallet_prelude::*;
//! use pezframe_system::pezpallet_prelude::*;
//!
//! #[pallet::pallet]
//! pub struct Pallet<T>(_);
//! #[pezpallet::pezpallet]
//! pub struct Pezpallet<T>(_);
//!
//! #[pallet::config]
//! #[pezpallet::config]
//! pub trait Config: pezframe_system::Config + im_online::Config {}
//!
//! #[pallet::call]
//! impl<T: Config> Pallet<T> {
//! #[pallet::weight(0)]
//! #[pezpallet::call]
//! impl<T: Config> Pezpallet<T> {
//! #[pezpallet::weight(0)]
//! pub fn is_online(origin: OriginFor<T>, authority_index: u32) -> DispatchResult {
//! let _sender = ensure_signed(origin)?;
//! let _is_online = <im_online::Pallet<T>>::is_online(authority_index);
//! let _is_online = <im_online::Pezpallet<T>>::is_online(authority_index);
//! Ok(())
//! }
//! }
@@ -71,7 +71,7 @@
//!
//! ## Dependencies
//!
//! This pallet depends on the [Session pallet](../pezpallet_session/index.html).
//! This pezpallet depends on the [Session pezpallet](../pezpallet_session/index.html).
// Ensure we're `no_std` when compiling for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]
@@ -98,7 +98,7 @@ use pezframe_system::{
offchain::{CreateBare, SubmitTransaction},
pezpallet_prelude::*,
};
pub use pallet::*;
pub use pezpallet::*;
use scale_info::TypeInfo;
use pezsp_application_crypto::RuntimeAppPublic;
use pezsp_runtime::{
@@ -249,18 +249,18 @@ pub type IdentificationTuple<T> = (
type OffchainResult<T, A> = Result<A, OffchainErr<BlockNumberFor<T>>>;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
#[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: CreateBare<Call<Self>> + pezframe_system::Config {
/// The identifier type for an authority.
type AuthorityId: Member
@@ -303,15 +303,15 @@ pub mod pallet {
///
/// This is exposed so that it can be tuned for particular runtime, when
/// multiple pallets send unsigned transactions.
#[pallet::constant]
#[pezpallet::constant]
type UnsignedPriority: Get<TransactionPriority>;
/// Weight information for extrinsics in this pallet.
/// Weight information for extrinsics in this pezpallet.
type WeightInfo: WeightInfo;
}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A new heartbeat was received from `AuthorityId`.
HeartbeatReceived { authority_id: T::AuthorityId },
@@ -321,7 +321,7 @@ pub mod pallet {
SomeOffline { offline: Vec<IdentificationTuple<T>> },
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Non existent public key.
InvalidKey,
@@ -340,22 +340,22 @@ pub mod pallet {
/// This value will only be used as a fallback if we fail to get a proper session
/// progress estimate from `NextSessionRotation`, as those estimates should be
/// more accurate then the value we calculate for `HeartbeatAfter`.
#[pallet::storage]
#[pezpallet::storage]
pub type HeartbeatAfter<T: Config> = StorageValue<_, BlockNumberFor<T>, ValueQuery>;
/// The current set of keys that may issue a heartbeat.
#[pallet::storage]
#[pezpallet::storage]
pub type Keys<T: Config> =
StorageValue<_, WeakBoundedVec<T::AuthorityId, T::MaxKeys>, ValueQuery>;
/// For each session index, we keep a mapping of `SessionIndex` and `AuthIndex`.
#[pallet::storage]
#[pezpallet::storage]
pub type ReceivedHeartbeats<T: Config> =
StorageDoubleMap<_, Twox64Concat, SessionIndex, Twox64Concat, AuthIndex, bool>;
/// For each session index, we keep a mapping of `ValidatorId<T>` to the
/// number of blocks authored by the given authority.
#[pallet::storage]
#[pezpallet::storage]
pub type AuthoredBlocks<T: Config> = StorageDoubleMap<
_,
Twox64Concat,
@@ -366,28 +366,28 @@ pub mod pallet {
ValueQuery,
>;
#[pallet::genesis_config]
#[pezpallet::genesis_config]
#[derive(pezframe_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub keys: Vec<T::AuthorityId>,
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
Pallet::<T>::initialize_keys(&self.keys);
Pezpallet::<T>::initialize_keys(&self.keys);
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// ## Complexity:
/// - `O(K)` where K is length of `Keys` (heartbeat.validators_len)
/// - `O(K)`: decoding of length `K`
// NOTE: the weight includes the cost of validate_unsigned as it is part of the cost to
// import block with such an extrinsic.
#[pallet::call_index(0)]
#[pallet::weight(<T as Config>::WeightInfo::validate_unsigned_and_then_heartbeat(
#[pezpallet::call_index(0)]
#[pezpallet::weight(<T as Config>::WeightInfo::validate_unsigned_and_then_heartbeat(
heartbeat.validators_len,
))]
pub fn heartbeat(
@@ -418,8 +418,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 offchain_worker(now: BlockNumberFor<T>) {
// Only send messages if we are a potential validator.
if pezsp_io::offchain::is_validator() {
@@ -447,13 +447,13 @@ pub mod pallet {
/// incorrect.
pub(crate) const INVALID_VALIDATORS_LEN: u8 = 10;
#[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 {
if let Call::heartbeat { heartbeat, signature } = call {
if <Pallet<T>>::is_online(heartbeat.authority_index) {
if <Pezpallet<T>>::is_online(heartbeat.authority_index) {
// we already received a heartbeat for this authority
return InvalidTransaction::Stale.into();
}
@@ -504,14 +504,14 @@ pub mod pallet {
/// Keep track of number of authored blocks per authority, uncles are counted as
/// well since they're a valid proof of being online.
impl<T: Config + pezpallet_authorship::Config>
pezpallet_authorship::EventHandler<ValidatorId<T>, BlockNumberFor<T>> for Pallet<T>
pezpallet_authorship::EventHandler<ValidatorId<T>, BlockNumberFor<T>> for Pezpallet<T>
{
fn note_author(author: ValidatorId<T>) {
Self::note_authorship(author);
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Returns `true` if a heartbeat has been received for the authority at
/// `authority_index` in the authorities series or if the authority has
/// authored at least one block, during the current session. Otherwise
@@ -736,11 +736,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 = T::AuthorityId;
}
impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
impl<T: Config> OneSessionHandler<T::AccountId> for Pezpallet<T> {
type Key = T::AuthorityId;
fn on_genesis_session<'a, I: 'a>(validators: I)
@@ -758,7 +758,7 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
// Tell the offchain worker to start making the next session's heartbeats.
// Since we consider producing blocks as being online,
// the heartbeat is deferred a bit to prevent spamming.
let block_number = <pezframe_system::Pallet<T>>::block_number();
let block_number = <pezframe_system::Pezpallet<T>>::block_number();
let half_session = T::NextSessionRotation::average_session_length() / 2u32.into();
<HeartbeatAfter<T>>::put(block_number + half_session);
+11 -11
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Storage migrations for the im-online pallet.
//! Storage migrations for the im-online pezpallet.
use super::*;
use alloc::vec::Vec;
@@ -29,7 +29,7 @@ use pezsp_runtime::TryRuntimeError;
/// The log target.
const TARGET: &str = "runtime::im-online::migration::v1";
/// The original data layout of the im-online pallet (`ReceivedHeartbeats` storage item).
/// The original data layout of the im-online pezpallet (`ReceivedHeartbeats` storage item).
mod v0 {
use super::*;
use pezframe_support::traits::WrapperOpaque;
@@ -44,7 +44,7 @@ mod v0 {
#[storage_alias]
pub(super) type ReceivedHeartbeats<T: Config> = StorageDoubleMap<
Pallet<T>,
Pezpallet<T>,
Twox64Concat,
SessionIndex,
Twox64Concat,
@@ -70,7 +70,7 @@ pub mod v1 {
fn on_runtime_upgrade() -> Weight {
let mut weight = T::DbWeight::get().reads(1);
if StorageVersion::get::<Pallet<T>>() != 0 {
if StorageVersion::get::<Pezpallet<T>>() != 0 {
log::warn!(
target: TARGET,
"Skipping migration because in-code storage version is not 0"
@@ -92,7 +92,7 @@ pub mod v1 {
crate::ReceivedHeartbeats::<T>::insert(session_index, auth_index, true);
}
StorageVersion::new(1).put::<Pallet<T>>();
StorageVersion::new(1).put::<Pezpallet<T>>();
weight.saturating_add(T::DbWeight::get().writes(1))
}
@@ -110,17 +110,17 @@ pub mod v1 {
old_received_heartbeats
);
}
ensure!(StorageVersion::get::<Pallet<T>>() >= 1, "must upgrade");
ensure!(StorageVersion::get::<Pezpallet<T>>() >= 1, "must upgrade");
Ok(())
}
}
}
/// Clears the pallet's offchain storage.
/// Clears the pezpallet's offchain storage.
///
/// Must be put in `OffchainWorkerApi::offchain_worker` after
/// the pallet was removed.
/// the pezpallet was removed.
pub fn clear_offchain_storage(validator_set_size: u32) {
(0..validator_set_size).for_each(|idx| {
let key = {
@@ -141,10 +141,10 @@ mod test {
#[test]
fn migration_works() {
new_test_ext().execute_with(|| {
assert_eq!(StorageVersion::get::<Pallet<T>>(), 0);
assert_eq!(StorageVersion::get::<Pezpallet<T>>(), 0);
// Insert some received heartbeats into the v0 storage:
let current_session = <T as pallet::Config>::ValidatorSet::session_index();
let current_session = <T as pezpallet::Config>::ValidatorSet::session_index();
v0::ReceivedHeartbeats::<T>::insert(
&current_session,
0,
@@ -171,7 +171,7 @@ mod test {
assert!(crate::ReceivedHeartbeats::<T>::contains_key(&current_session, 0));
assert_eq!(Some(true), crate::ReceivedHeartbeats::<T>::get(&current_session, 1));
assert_eq!(StorageVersion::get::<Pallet<T>>(), 1);
assert_eq!(StorageVersion::get::<Pezpallet<T>>(), 1);
});
}
}
+2 -2
View File
@@ -261,14 +261,14 @@ fn should_cleanup_received_heartbeats_on_session_end() {
let _ = heartbeat(1, 2, 0, 1.into(), Session::validators()).unwrap();
// the heartbeat is stored
assert!(!super::pallet::ReceivedHeartbeats::<Runtime>::get(2, 0).is_none());
assert!(!super::pezpallet::ReceivedHeartbeats::<Runtime>::get(2, 0).is_none());
advance_session();
// after the session has ended we have already processed the heartbeat
// message, so any messages received on the previous session should have
// been pruned.
assert!(super::pallet::ReceivedHeartbeats::<Runtime>::get(2, 0).is_none());
assert!(super::pezpallet::ReceivedHeartbeats::<Runtime>::get(2, 0).is_none());
});
}
+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_im_online
// --pezpallet=pezpallet_im_online
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/im-online/src/weights.rs
// --wasm-execution=compiled