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.
//! Benchmarks for transaction-storage Pallet
//! Benchmarks for transaction-storage Pezpallet
#![cfg(feature = "runtime-benchmarks")]
@@ -23,7 +23,7 @@ use crate::*;
use alloc::{vec, vec::Vec};
use pezframe_benchmarking::v2::*;
use pezframe_support::traits::{Get, OnFinalize, OnInitialize};
use pezframe_system::{pezpallet_prelude::BlockNumberFor, EventRecord, Pallet as System, RawOrigin};
use pezframe_system::{pezpallet_prelude::BlockNumberFor, EventRecord, Pezpallet as System, RawOrigin};
use pezsp_runtime::traits::{Bounded, CheckedDiv, One, Zero};
use pezsp_transaction_storage_proof::TransactionStorageProof;
@@ -109,14 +109,14 @@ fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
}
pub fn run_to_block<T: Config>(n: pezframe_system::pezpallet_prelude::BlockNumberFor<T>) {
while pezframe_system::Pallet::<T>::block_number() < n {
crate::Pallet::<T>::on_finalize(pezframe_system::Pallet::<T>::block_number());
pezframe_system::Pallet::<T>::on_finalize(pezframe_system::Pallet::<T>::block_number());
pezframe_system::Pallet::<T>::set_block_number(
pezframe_system::Pallet::<T>::block_number() + One::one(),
while pezframe_system::Pezpallet::<T>::block_number() < n {
crate::Pezpallet::<T>::on_finalize(pezframe_system::Pezpallet::<T>::block_number());
pezframe_system::Pezpallet::<T>::on_finalize(pezframe_system::Pezpallet::<T>::block_number());
pezframe_system::Pezpallet::<T>::set_block_number(
pezframe_system::Pezpallet::<T>::block_number() + One::one(),
);
pezframe_system::Pallet::<T>::on_initialize(pezframe_system::Pallet::<T>::block_number());
crate::Pallet::<T>::on_initialize(pezframe_system::Pallet::<T>::block_number());
pezframe_system::Pezpallet::<T>::on_initialize(pezframe_system::Pezpallet::<T>::block_number());
crate::Pezpallet::<T>::on_initialize(pezframe_system::Pezpallet::<T>::block_number());
}
}
@@ -142,7 +142,7 @@ mod benchmarks {
let caller: T::AccountId = whitelisted_caller();
let initial_balance = BalanceOf::<T>::max_value().checked_div(&2u32.into()).unwrap();
T::Currency::set_balance(&caller, initial_balance);
Pallet::<T>::store(
Pezpallet::<T>::store(
RawOrigin::Signed(caller.clone()).into(),
vec![0u8; T::MaxTransactionSize::get() as usize],
)?;
@@ -163,7 +163,7 @@ mod benchmarks {
let initial_balance = BalanceOf::<T>::max_value().checked_div(&2u32.into()).unwrap();
T::Currency::set_balance(&caller, initial_balance);
for _ in 0..T::MaxBlockTransactions::get() {
Pallet::<T>::store(
Pezpallet::<T>::store(
RawOrigin::Signed(caller.clone()).into(),
vec![0u8; T::MaxTransactionSize::get() as usize],
)?;
@@ -180,5 +180,5 @@ mod benchmarks {
Ok(())
}
impl_benchmark_test_suite!(Pallet, mock::new_test_ext(), mock::Test);
impl_benchmark_test_suite!(Pezpallet, mock::new_test_ext(), mock::Test);
}
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Transaction storage pallet. Indexes transactions and manages storage proofs.
//! Transaction storage pezpallet. Indexes transactions and manages storage proofs.
// Ensure we're `no_std` when compiling for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]
@@ -47,13 +47,13 @@ use pezsp_transaction_storage_proof::{
CHUNK_SIZE, INHERENT_IDENTIFIER,
};
/// A type alias for the balance type from this pallet's point of view.
/// A type alias for the balance type from this pezpallet's point of view.
type BalanceOf<T> =
<<T as Config>::Currency as Inspect<<T as pezframe_system::Config>::AccountId>>::Balance;
pub type CreditOf<T> = Credit<<T as pezframe_system::Config>::AccountId, <T as Config>::Currency>;
// Re-export pallet items so that they can be accessed from the crate namespace.
pub use pallet::*;
// Re-export pezpallet items so that they can be accessed from the crate namespace.
pub use pezpallet::*;
pub use weights::WeightInfo;
/// Maximum bytes that can be stored in one transaction.
@@ -96,20 +96,20 @@ impl TransactionInfo {
}
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
/// 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 deposit for the used storage.
StorageFeeHold,
}
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
@@ -119,7 +119,7 @@ pub mod pallet {
+ Dispatchable<RuntimeOrigin = Self::RuntimeOrigin>
+ GetDispatchInfo
+ From<pezframe_system::Call<Self>>;
/// The fungible type for this pallet.
/// The fungible type for this pezpallet.
type Currency: Mutate<Self::AccountId>
+ MutateHold<Self::AccountId, Reason = Self::RuntimeHoldReason>
+ Balanced<Self::AccountId>;
@@ -127,7 +127,7 @@ pub mod pallet {
type RuntimeHoldReason: From<HoldReason>;
/// Handler for the unbalanced decrease when fees are burned.
type FeeDestination: OnUnbalanced<CreditOf<Self>>;
/// Weight information for extrinsics in this pallet.
/// Weight information for extrinsics in this pezpallet.
type WeightInfo: WeightInfo;
/// Maximum number of indexed transactions in the block.
type MaxBlockTransactions: Get<u32>;
@@ -135,7 +135,7 @@ pub mod pallet {
type MaxTransactionSize: Get<u32>;
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Invalid configuration.
NotConfigured,
@@ -163,11 +163,11 @@ pub mod pallet {
BadContext,
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
fn on_initialize(n: BlockNumberFor<T>) -> Weight {
// TODO: https://github.com/pezkuwichain/pezkuwi-sdk/issues/160 - Replace this with benchmarked weights.
let mut weight = Weight::zero();
@@ -192,7 +192,7 @@ pub mod pallet {
assert!(
ProofChecked::<T>::take() || {
// Proof is not required for early or empty blocks.
let number = pezframe_system::Pallet::<T>::block_number();
let number = pezframe_system::Pezpallet::<T>::block_number();
let period = StoragePeriod::<T>::get();
let target_number = number.saturating_sub(period);
@@ -213,15 +213,15 @@ pub mod pallet {
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Index and store data off chain. Minimum data size is 1 bytes, maximum is
/// `MaxTransactionSize`. Data will be removed after `STORAGE_PERIOD` blocks, unless `renew`
/// is called.
/// ## Complexity
/// - O(n*log(n)) of data size, as all data is pushed to an in-memory trie.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::store(data.len() as u32))]
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::store(data.len() as u32))]
pub fn store(origin: OriginFor<T>, data: Vec<u8>) -> DispatchResult {
ensure!(data.len() > 0, Error::<T>::EmptyTransaction);
ensure!(
@@ -238,7 +238,7 @@ pub mod pallet {
let content_hash = pezsp_io::hashing::blake2_256(&data);
let extrinsic_index =
pezframe_system::Pallet::<T>::extrinsic_index().ok_or(Error::<T>::BadContext)?;
pezframe_system::Pezpallet::<T>::extrinsic_index().ok_or(Error::<T>::BadContext)?;
pezsp_io::transaction_index::index(extrinsic_index, data.len() as u32, content_hash);
let mut index = 0;
@@ -268,8 +268,8 @@ pub mod pallet {
/// Applies same fees as `store`.
/// ## Complexity
/// - O(1).
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::renew())]
#[pezpallet::call_index(1)]
#[pezpallet::weight(T::WeightInfo::renew())]
pub fn renew(
origin: OriginFor<T>,
block: BlockNumberFor<T>,
@@ -279,7 +279,7 @@ pub mod pallet {
let transactions = Transactions::<T>::get(block).ok_or(Error::<T>::RenewedNotFound)?;
let info = transactions.get(index as usize).ok_or(Error::<T>::RenewedNotFound)?;
let extrinsic_index =
pezframe_system::Pallet::<T>::extrinsic_index().ok_or(Error::<T>::BadContext)?;
pezframe_system::Pezpallet::<T>::extrinsic_index().ok_or(Error::<T>::BadContext)?;
Self::apply_fee(sender, info.size)?;
@@ -313,8 +313,8 @@ pub mod pallet {
/// - Linear w.r.t the number of indexed transactions in the proved block for random
/// probing.
/// There's a DB read for each transaction.
#[pallet::call_index(2)]
#[pallet::weight((T::WeightInfo::check_proof_max(), DispatchClass::Mandatory))]
#[pezpallet::call_index(2)]
#[pezpallet::weight((T::WeightInfo::check_proof_max(), DispatchClass::Mandatory))]
pub fn check_proof(
origin: OriginFor<T>,
proof: TransactionStorageProof,
@@ -323,7 +323,7 @@ pub mod pallet {
ensure!(!ProofChecked::<T>::get(), Error::<T>::DoubleCheck);
// Get the target block metadata.
let number = pezframe_system::Pallet::<T>::block_number();
let number = pezframe_system::Pezpallet::<T>::block_number();
let period = StoragePeriod::<T>::get();
let target_number = number.saturating_sub(period);
ensure!(!target_number.is_zero(), Error::<T>::UnexpectedProof);
@@ -331,7 +331,7 @@ pub mod pallet {
Transactions::<T>::get(target_number).ok_or(Error::<T>::MissingStateData)?;
// Verify the proof with a "random" chunk (randomness is based on the parent hash).
let parent_hash = pezframe_system::Pallet::<T>::parent_hash();
let parent_hash = pezframe_system::Pezpallet::<T>::parent_hash();
Self::verify_chunk_proof(proof, parent_hash.as_ref(), transactions.to_vec())?;
ProofChecked::<T>::put(true);
Self::deposit_event(Event::ProofChecked);
@@ -339,8 +339,8 @@ pub mod pallet {
}
}
#[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> {
/// Stored data under specified index.
Stored { index: u32 },
@@ -351,7 +351,7 @@ pub mod pallet {
}
/// Collection of transaction metadata by block number.
#[pallet::storage]
#[pezpallet::storage]
pub type Transactions<T: Config> = StorageMap<
_,
Blake2_128Concat,
@@ -360,29 +360,29 @@ pub mod pallet {
OptionQuery,
>;
#[pallet::storage]
#[pezpallet::storage]
/// Storage fee per byte.
pub type ByteFee<T: Config> = StorageValue<_, BalanceOf<T>>;
#[pallet::storage]
#[pezpallet::storage]
/// Storage fee per transaction.
pub type EntryFee<T: Config> = StorageValue<_, BalanceOf<T>>;
/// Storage period for data in blocks. Should match `pezsp_storage_proof::DEFAULT_STORAGE_PERIOD`
/// for block authoring.
#[pallet::storage]
#[pezpallet::storage]
pub type StoragePeriod<T: Config> = StorageValue<_, BlockNumberFor<T>, ValueQuery>;
// Intermediates
#[pallet::storage]
#[pezpallet::storage]
pub type BlockTransactions<T: Config> =
StorageValue<_, BoundedVec<TransactionInfo, T::MaxBlockTransactions>, ValueQuery>;
/// Was the proof checked in this block?
#[pallet::storage]
#[pezpallet::storage]
pub type ProofChecked<T: Config> = StorageValue<_, bool, ValueQuery>;
#[pallet::genesis_config]
#[pezpallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub byte_fee: BalanceOf<T>,
pub entry_fee: BalanceOf<T>,
@@ -399,7 +399,7 @@ pub mod pallet {
}
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
ByteFee::<T>::put(&self.byte_fee);
@@ -408,8 +408,8 @@ pub mod pallet {
}
}
#[pallet::inherent]
impl<T: Config> ProvideInherent for Pallet<T> {
#[pezpallet::inherent]
impl<T: Config> ProvideInherent for Pezpallet<T> {
type Call = Call<T>;
type Error = InherentError;
const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER;
@@ -433,18 +433,18 @@ pub mod pallet {
}
}
impl<T: Config> Pallet<T> {
/// Get transaction storage information from outside of this pallet.
impl<T: Config> Pezpallet<T> {
/// Get transaction storage information from outside of this pezpallet.
pub fn transaction_roots(
block: BlockNumberFor<T>,
) -> Option<BoundedVec<TransactionInfo, T::MaxBlockTransactions>> {
Transactions::<T>::get(block)
}
/// Get ByteFee storage information from outside of this pallet.
/// Get ByteFee storage information from outside of this pezpallet.
pub fn byte_fee() -> Option<BalanceOf<T>> {
ByteFee::<T>::get()
}
/// Get EntryFee storage information from outside of this pallet.
/// Get EntryFee storage information from outside of this pezpallet.
pub fn entry_fee() -> Option<BalanceOf<T>> {
EntryFee::<T>::get()
}
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Test environment for transaction-storage pallet.
//! Test environment for transaction-storage pezpallet.
use crate::{
self as pezpallet_transaction_storage, TransactionStorageProof, DEFAULT_MAX_BLOCK_TRANSACTIONS,
@@ -26,7 +26,7 @@ use pezsp_runtime::{traits::IdentityLookup, BuildStorage};
pub type Block = pezframe_system::mocking::MockBlock<Test>;
// Configure a mock runtime to test the pallet.
// Configure a mock runtime to test the pezpallet.
pezframe_support::construct_runtime!(
pub enum Test
{
@@ -15,9 +15,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Tests for transaction-storage pallet.
//! Tests for transaction-storage pezpallet.
use super::{Pallet as TransactionStorage, *};
use super::{Pezpallet as TransactionStorage, *};
use crate::mock::*;
use pezframe_support::{assert_noop, assert_ok};
use pezframe_system::RawOrigin;
@@ -40,9 +40,9 @@ fn discards_data() {
vec![0u8; 2000 as usize]
));
let proof_provider = || {
let block_num = pezframe_system::Pallet::<Test>::block_number();
let block_num = pezframe_system::Pezpallet::<Test>::block_number();
if block_num == 11 {
let parent_hash = pezframe_system::Pallet::<Test>::parent_hash();
let parent_hash = pezframe_system::Pezpallet::<Test>::parent_hash();
build_proof(parent_hash.as_ref(), vec![vec![0u8; 2000], vec![0u8; 2000]]).unwrap()
} else {
None
@@ -88,7 +88,7 @@ fn checks_proof() {
vec![0u8; MAX_DATA_SIZE as usize]
));
run_to_block(10, || None);
let parent_hash = pezframe_system::Pallet::<Test>::parent_hash();
let parent_hash = pezframe_system::Pezpallet::<Test>::parent_hash();
let proof = build_proof(parent_hash.as_ref(), vec![vec![0u8; MAX_DATA_SIZE as usize]])
.unwrap()
.unwrap();
@@ -97,7 +97,7 @@ fn checks_proof() {
Error::<Test>::UnexpectedProof,
);
run_to_block(11, || None);
let parent_hash = pezframe_system::Pallet::<Test>::parent_hash();
let parent_hash = pezframe_system::Pezpallet::<Test>::parent_hash();
let invalid_proof =
build_proof(parent_hash.as_ref(), vec![vec![0u8; 1000]]).unwrap().unwrap();
@@ -191,9 +191,9 @@ fn renews_data() {
));
assert_eq!(Balances::free_balance(1), 1_000_000_000 - 4000 * 2 - 200 * 2);
let proof_provider = || {
let block_num = pezframe_system::Pallet::<Test>::block_number();
let block_num = pezframe_system::Pezpallet::<Test>::block_number();
if block_num == 11 || block_num == 16 {
let parent_hash = pezframe_system::Pallet::<Test>::parent_hash();
let parent_hash = pezframe_system::Pezpallet::<Test>::parent_hash();
build_proof(parent_hash.as_ref(), vec![vec![0u8; 2000]]).unwrap()
} else {
None
@@ -26,11 +26,11 @@
// Executed Command:
// ./target/production/bizinikiwi-node
// benchmark
// pallet
// pezpallet
// --chain=dev
// --steps=50
// --repeat=20
// --pallet=pezpallet_transaction_storage
// --pezpallet=pezpallet_transaction_storage
// --no-storage-info
// --no-median-slopes
// --no-min-squares