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
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Preimage pallet benchmarking.
//! Preimage pezpallet benchmarking.
use alloc::vec;
use pezframe_benchmarking::v2::*;
@@ -71,7 +71,7 @@ mod benchmarks {
#[extrinsic_call]
_(RawOrigin::Signed(caller), preimage);
assert!(Pallet::<T>::have_preimage(&hash));
assert!(Pezpallet::<T>::have_preimage(&hash));
}
// Cheap note - will not reserve since it was requested.
@@ -79,7 +79,7 @@ mod benchmarks {
fn note_requested_preimage(s: Linear<0, MAX_SIZE>) {
let caller = funded_account::<T>();
let (preimage, hash) = sized_preimage_and_hash::<T>(s);
assert_ok!(Pallet::<T>::request_preimage(
assert_ok!(Pezpallet::<T>::request_preimage(
T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark"),
hash,
@@ -88,7 +88,7 @@ mod benchmarks {
#[extrinsic_call]
note_preimage(RawOrigin::Signed(caller), preimage);
assert!(Pallet::<T>::have_preimage(&hash));
assert!(Pezpallet::<T>::have_preimage(&hash));
}
// Cheap note - will not reserve since it's the manager.
@@ -97,12 +97,12 @@ mod benchmarks {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (preimage, hash) = sized_preimage_and_hash::<T>(s);
assert_ok!(Pallet::<T>::request_preimage(o.clone(), hash,));
assert_ok!(Pezpallet::<T>::request_preimage(o.clone(), hash,));
#[extrinsic_call]
note_preimage(o as T::RuntimeOrigin, preimage);
assert!(Pallet::<T>::have_preimage(&hash));
assert!(Pezpallet::<T>::have_preimage(&hash));
}
// Expensive unnote - will unreserve.
@@ -110,12 +110,12 @@ mod benchmarks {
fn unnote_preimage() {
let caller = funded_account::<T>();
let (preimage, hash) = preimage_and_hash::<T>();
assert_ok!(Pallet::<T>::note_preimage(RawOrigin::Signed(caller.clone()).into(), preimage));
assert_ok!(Pezpallet::<T>::note_preimage(RawOrigin::Signed(caller.clone()).into(), preimage));
#[extrinsic_call]
_(RawOrigin::Signed(caller), hash);
assert!(!Pallet::<T>::have_preimage(&hash));
assert!(!Pezpallet::<T>::have_preimage(&hash));
}
// Cheap unnote - will not unreserve since there's no deposit held.
@@ -124,12 +124,12 @@ mod benchmarks {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (preimage, hash) = preimage_and_hash::<T>();
assert_ok!(Pallet::<T>::note_preimage(o.clone(), preimage,));
assert_ok!(Pezpallet::<T>::note_preimage(o.clone(), preimage,));
#[extrinsic_call]
unnote_preimage(o as T::RuntimeOrigin, hash);
assert!(!Pallet::<T>::have_preimage(&hash));
assert!(!Pezpallet::<T>::have_preimage(&hash));
}
// Expensive request - will unreserve the noter's deposit.
@@ -139,7 +139,7 @@ mod benchmarks {
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (preimage, hash) = preimage_and_hash::<T>();
let noter = funded_account::<T>();
assert_ok!(Pallet::<T>::note_preimage(RawOrigin::Signed(noter.clone()).into(), preimage));
assert_ok!(Pezpallet::<T>::note_preimage(RawOrigin::Signed(noter.clone()).into(), preimage));
#[extrinsic_call]
_(o as T::RuntimeOrigin, hash);
@@ -160,7 +160,7 @@ mod benchmarks {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (preimage, hash) = preimage_and_hash::<T>();
assert_ok!(Pallet::<T>::note_preimage(o.clone(), preimage,));
assert_ok!(Pezpallet::<T>::note_preimage(o.clone(), preimage,));
#[extrinsic_call]
request_preimage(o as T::RuntimeOrigin, hash);
@@ -190,7 +190,7 @@ mod benchmarks {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (_, hash) = preimage_and_hash::<T>();
assert_ok!(Pallet::<T>::request_preimage(o.clone(), hash,));
assert_ok!(Pezpallet::<T>::request_preimage(o.clone(), hash,));
#[extrinsic_call]
request_preimage(o as T::RuntimeOrigin, hash);
@@ -205,8 +205,8 @@ mod benchmarks {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (preimage, hash) = preimage_and_hash::<T>();
assert_ok!(Pallet::<T>::request_preimage(o.clone(), hash,));
assert_ok!(Pallet::<T>::note_preimage(o.clone(), preimage));
assert_ok!(Pezpallet::<T>::request_preimage(o.clone(), hash,));
assert_ok!(Pezpallet::<T>::note_preimage(o.clone(), preimage));
#[extrinsic_call]
_(o as T::RuntimeOrigin, hash);
@@ -220,7 +220,7 @@ mod benchmarks {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (_, hash) = preimage_and_hash::<T>();
assert_ok!(Pallet::<T>::request_preimage(o.clone(), hash,));
assert_ok!(Pezpallet::<T>::request_preimage(o.clone(), hash,));
#[extrinsic_call]
unrequest_preimage(o as T::RuntimeOrigin, hash);
@@ -234,8 +234,8 @@ mod benchmarks {
let o = T::ManagerOrigin::try_successful_origin()
.expect("ManagerOrigin has no successful origin required for the benchmark");
let (_, hash) = preimage_and_hash::<T>();
assert_ok!(Pallet::<T>::request_preimage(o.clone(), hash,));
assert_ok!(Pallet::<T>::request_preimage(o.clone(), hash,));
assert_ok!(Pezpallet::<T>::request_preimage(o.clone(), hash,));
assert_ok!(Pezpallet::<T>::request_preimage(o.clone(), hash,));
#[extrinsic_call]
unrequest_preimage(o as T::RuntimeOrigin, hash);
@@ -259,7 +259,7 @@ mod benchmarks {
}
impl_benchmark_test_suite! {
Pallet,
Pezpallet,
mock::new_test_ext(),
mock::Test
}
+36 -36
View File
@@ -15,14 +15,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Preimage Pallet
//! # Preimage Pezpallet
//!
//! - [`Config`]
//! - [`Call`]
//!
//! ## Overview
//!
//! The Preimage pallet allows for the users and the runtime to store the preimage
//! The Preimage pezpallet allows for the users and the runtime to store the preimage
//! of a hash on chain. This can be used by other pallets for storing and managing
//! large byte-blobs.
@@ -62,7 +62,7 @@ pub use weights::WeightInfo;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
pub use pallet::*;
pub use pezpallet::*;
/// A type to note whether a preimage is owned by a user or the system.
#[derive(
@@ -119,24 +119,24 @@ pub const MAX_SIZE: u32 = 4 * 1024 * 1024;
/// Exists only for benchmarking purposes.
pub const MAX_HASH_UPGRADE_BULK_COUNT: u32 = 1024;
#[pezframe_support::pallet]
#[pezframe_support::pezpallet]
#[allow(deprecated)]
pub mod pallet {
pub mod pezpallet {
use super::*;
/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// The Weight information for this pallet.
/// The Weight information for this pezpallet.
type WeightInfo: weights::WeightInfo;
/// Currency type for this pallet.
/// Currency type for this pezpallet.
// TODO#1569: Remove.
type Currency: ReservableCurrency<Self::AccountId>;
@@ -148,12 +148,12 @@ pub mod pallet {
type Consideration: Consideration<Self::AccountId, Footprint>;
}
#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
#[pezpallet::storage_version(STORAGE_VERSION)]
pub struct Pezpallet<T>(_);
#[pallet::event]
#[pallet::generate_deposit(pub fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub fn deposit_event)]
pub enum Event<T: Config> {
/// A preimage has been noted.
Noted { hash: T::Hash },
@@ -163,7 +163,7 @@ pub mod pallet {
Cleared { hash: T::Hash },
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Preimage is too large to store on-chain.
TooBig,
@@ -183,8 +183,8 @@ pub mod pallet {
TooFew,
}
/// A reason for this pallet placing a hold on funds.
#[pallet::composite_enum]
/// A reason for this pezpallet placing a hold on funds.
#[pezpallet::composite_enum]
pub enum HoldReason {
/// The funds are held as storage deposit for a preimage.
Preimage,
@@ -192,27 +192,27 @@ pub mod pallet {
/// The request status of a given hash.
#[deprecated = "RequestStatusFor"]
#[pallet::storage]
#[pezpallet::storage]
pub type StatusFor<T: Config> =
StorageMap<_, Identity, T::Hash, OldRequestStatus<T::AccountId, BalanceOf<T>>>;
/// The request status of a given hash.
#[pallet::storage]
#[pezpallet::storage]
pub type RequestStatusFor<T: Config> =
StorageMap<_, Identity, T::Hash, RequestStatus<T::AccountId, TicketOf<T>>>;
#[pallet::storage]
#[pezpallet::storage]
pub type PreimageFor<T: Config> =
StorageMap<_, Identity, (T::Hash, u32), BoundedVec<u8, ConstU32<MAX_SIZE>>>;
#[pallet::call(weight = T::WeightInfo)]
impl<T: Config> Pallet<T> {
#[pezpallet::call(weight = T::WeightInfo)]
impl<T: Config> Pezpallet<T> {
/// Register a preimage on-chain.
///
/// If the preimage was previously requested, no fees or deposits are taken for providing
/// the preimage. Otherwise, a deposit is taken proportional to the size of the preimage.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::note_preimage(bytes.len() as u32))]
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::note_preimage(bytes.len() as u32))]
pub fn note_preimage(origin: OriginFor<T>, bytes: Vec<u8>) -> DispatchResultWithPostInfo {
// We accept a signed origin which will pay a deposit, or a root origin where a deposit
// is not taken.
@@ -231,7 +231,7 @@ pub mod pallet {
///
/// - `hash`: The hash of the preimage to be removed from the store.
/// - `len`: The length of the preimage of `hash`.
#[pallet::call_index(1)]
#[pezpallet::call_index(1)]
pub fn unnote_preimage(origin: OriginFor<T>, hash: T::Hash) -> DispatchResult {
let maybe_sender = Self::ensure_signed_or_manager(origin)?;
Self::do_unnote_preimage(&hash, maybe_sender)
@@ -241,7 +241,7 @@ pub mod pallet {
///
/// If the preimage requests has already been provided on-chain, we unreserve any deposit
/// a user may have paid, and take the control of the preimage out of their hands.
#[pallet::call_index(2)]
#[pezpallet::call_index(2)]
pub fn request_preimage(origin: OriginFor<T>, hash: T::Hash) -> DispatchResult {
T::ManagerOrigin::ensure_origin(origin)?;
Self::do_request_preimage(&hash);
@@ -251,7 +251,7 @@ pub mod pallet {
/// Clear a previously made request for a preimage.
///
/// NOTE: THIS MUST NOT BE CALLED ON `hash` MORE TIMES THAN `request_preimage`.
#[pallet::call_index(3)]
#[pezpallet::call_index(3)]
pub fn unrequest_preimage(origin: OriginFor<T>, hash: T::Hash) -> DispatchResult {
T::ManagerOrigin::ensure_origin(origin)?;
Self::do_unrequest_preimage(&hash)
@@ -260,8 +260,8 @@ pub mod pallet {
/// Ensure that the bulk of pre-images is upgraded.
///
/// The caller pays no fee if at least 90% of pre-images were successfully updated.
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::ensure_updated(hashes.len() as u32))]
#[pezpallet::call_index(4)]
#[pezpallet::weight(T::WeightInfo::ensure_updated(hashes.len() as u32))]
pub fn ensure_updated(
origin: OriginFor<T>,
hashes: Vec<T::Hash>,
@@ -279,7 +279,7 @@ pub mod pallet {
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
fn do_ensure_updated(h: &T::Hash) -> bool {
#[allow(deprecated)]
let r = match StatusFor::<T>::take(h) {
@@ -342,7 +342,7 @@ impl<T: Config> Pallet<T> {
///
/// If `maybe_depositor` is `None` then it is also requested. If `Some`, then it is not.
///
/// We verify that the preimage is within the bounds of what the pallet supports.
/// We verify that the preimage is within the bounds of what the pezpallet supports.
///
/// If the preimage was requested to be uploaded, then the user pays no deposits or tx fees.
fn note_bytes(
@@ -514,7 +514,7 @@ impl<T: Config> Pallet<T> {
}
}
impl<T: Config> PreimageProvider<T::Hash> for Pallet<T> {
impl<T: Config> PreimageProvider<T::Hash> for Pezpallet<T> {
fn have_preimage(hash: &T::Hash) -> bool {
Self::have(hash)
}
@@ -538,7 +538,7 @@ impl<T: Config> PreimageProvider<T::Hash> for Pallet<T> {
}
}
impl<T: Config> PreimageRecipient<T::Hash> for Pallet<T> {
impl<T: Config> PreimageRecipient<T::Hash> for Pezpallet<T> {
type MaxSize = ConstU32<MAX_SIZE>; // 2**22
fn note_preimage(bytes: BoundedVec<u8, Self::MaxSize>) {
@@ -554,15 +554,15 @@ impl<T: Config> PreimageRecipient<T::Hash> for Pallet<T> {
}
}
impl<T: Config> QueryPreimage for Pallet<T> {
impl<T: Config> QueryPreimage for Pezpallet<T> {
type H = T::Hashing;
fn len(hash: &T::Hash) -> Option<u32> {
Pallet::<T>::len(hash)
Pezpallet::<T>::len(hash)
}
fn fetch(hash: &T::Hash, len: Option<u32>) -> FetchResult {
Pallet::<T>::fetch(hash, len)
Pezpallet::<T>::fetch(hash, len)
}
fn is_requested(hash: &T::Hash) -> bool {
@@ -580,7 +580,7 @@ impl<T: Config> QueryPreimage for Pallet<T> {
}
}
impl<T: Config> StorePreimage for Pallet<T> {
impl<T: Config> StorePreimage for Pezpallet<T> {
const MAX_LENGTH: usize = MAX_SIZE as usize;
fn note(bytes: Cow<[u8]>) -> Result<T::Hash, DispatchError> {
+10 -10
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Storage migrations for the preimage pallet.
//! Storage migrations for the preimage pezpallet.
use super::*;
use alloc::collections::btree_map::BTreeMap;
@@ -32,7 +32,7 @@ use pezsp_runtime::TryRuntimeError;
/// The log target.
const TARGET: &'static str = "runtime::preimage::migration::v1";
/// The original data layout of the preimage pallet without a specific version number.
/// The original data layout of the preimage pezpallet without a specific version number.
mod v0 {
use super::*;
@@ -44,7 +44,7 @@ mod v0 {
#[storage_alias]
pub type PreimageFor<T: Config> = StorageMap<
Pallet<T>,
Pezpallet<T>,
Identity,
<T as pezframe_system::Config>::Hash,
BoundedVec<u8, ConstU32<MAX_SIZE>>,
@@ -52,7 +52,7 @@ mod v0 {
#[storage_alias]
pub type StatusFor<T: Config> = StorageMap<
Pallet<T>,
Pezpallet<T>,
Identity,
<T as pezframe_system::Config>::Hash,
OldRequestStatus<<T as pezframe_system::Config>::AccountId, BalanceOf<T>>,
@@ -84,7 +84,7 @@ pub mod v1 {
impl<T: Config> OnRuntimeUpgrade for Migration<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
ensure!(StorageVersion::get::<Pallet<T>>() == 0, "can only upgrade from version 0");
ensure!(StorageVersion::get::<Pezpallet<T>>() == 0, "can only upgrade from version 0");
let images = v0::image_count::<T>().expect("v0 storage corrupted");
log::info!(target: TARGET, "Migrating {} images", &images);
@@ -93,7 +93,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 MovePreimagesIntoBuckets: executed on wrong storage version.\
@@ -148,7 +148,7 @@ pub mod v1 {
weight.saturating_accrue(T::DbWeight::get().writes(2));
}
StorageVersion::new(1).put::<Pallet<T>>();
StorageVersion::new(1).put::<Pezpallet<T>>();
weight.saturating_add(T::DbWeight::get().writes(1))
}
@@ -167,7 +167,7 @@ pub mod v1 {
old_images
);
}
ensure!(StorageVersion::get::<Pallet<T>>() == 1, "must upgrade");
ensure!(StorageVersion::get::<Pezpallet<T>>() == 1, "must upgrade");
Ok(())
}
}
@@ -200,7 +200,7 @@ 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 preimages into the v0 storage:
// Case 1: Unrequested without deposit
@@ -230,7 +230,7 @@ mod test {
// V0 and V1 share the same prefix, so `iter_values` still counts the same.
assert_eq!(v0::image_count::<T>(), Some(3));
assert_eq!(v1::image_count::<T>(), Some(3)); // One gets skipped therefore 3.
assert_eq!(StorageVersion::get::<Pallet<T>>(), 1);
assert_eq!(StorageVersion::get::<Pezpallet<T>>(), 1);
// Case 1: Unrequested without deposit becomes system-requested
let (p, h) = preimage::<T>(128);
+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_preimage
// --pezpallet=pezpallet_preimage
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/preimage/src/weights.rs
// --wasm-execution=compiled