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,12 +15,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Benchmarking for the message queue pallet.
//! Benchmarking for the message queue pezpallet.
#![cfg(feature = "runtime-benchmarks")]
#![allow(unused_assignments)] // Needed for `ready_ring_knit`.
use super::{mock_helpers::*, Pallet as MessageQueue, *};
use super::{mock_helpers::*, Pezpallet as MessageQueue, *};
use pezframe_benchmarking::v2::*;
use pezframe_support::traits::Get;
@@ -84,7 +84,7 @@ pub struct AhmPrioritizer {
favorite_queue_num_messages: Option<u64>,
}
// The whole `AhmPrioritizer` could be part of the AHM controller pallet.
// The whole `AhmPrioritizer` could be part of the AHM controller pezpallet.
parameter_types! {
pub storage AhmPrioritizerStorage: AhmPrioritizer = AhmPrioritizer::default();
}
@@ -131,7 +131,7 @@ impl AhmPrioritizer {
}
// Our queue did not get a streak since 10 blocks. It must either be empty or starved:
if Pallet::<Test>::footprint(q).pages == 0 {
if Pezpallet::<Test>::footprint(q).pages == 0 {
return meter.consumed();
}
if this.streak_until.map_or(false, |until| until < now.saturating_sub(10)) {
@@ -140,7 +140,7 @@ impl AhmPrioritizer {
}
if this.streak_until.map_or(false, |until| until > now) {
let _ = Pallet::<Test>::force_set_head(&mut meter, &q).defensive();
let _ = Pezpallet::<Test>::force_set_head(&mut meter, &q).defensive();
}
meter.consumed()
@@ -569,7 +569,7 @@ fn next_block() -> Weight {
MessageQueue::on_initialize(System::block_number())
}
/// Assert that the pallet is in the expected post state.
/// Assert that the pezpallet is in the expected post state.
fn post_conditions() {
// All queues are empty.
for (_, book) in BookStateFor::<Test>::iter() {
+60 -60
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Generalized Message Queue Pallet
//! # Generalized Message Queue Pezpallet
//!
//! Provides generalized message queuing and processing capabilities on a per-queue basis for
//! arbitrary use-cases.
@@ -23,9 +23,9 @@
//! # Design Goals
//!
//! 1. Minimal assumptions about `Message`s and `MessageOrigin`s. Both should be MEL bounded blobs.
//! This ensures the generality and reusability of the pallet.
//! This ensures the generality and reusability of the pezpallet.
//! 2. Well known and tightly limited pre-dispatch PoV weights, especially for message execution.
//! This is paramount for the success of the pallet since message execution is done in
//! This is paramount for the success of the pezpallet since message execution is done in
//! `on_initialize` which must _never_ under-estimate its PoV weight. It also needs a frugal PoV
//! footprint since PoV is scarce and this is (possibly) done in every block. This must also hold
//! in the presence of unpredictable message size distributions.
@@ -33,14 +33,14 @@
//!
//! # Design
//!
//! The pallet has means to enqueue, store and process messages. This is implemented by having
//! The pezpallet has means to enqueue, store and process messages. This is implemented by having
//! *queues* which store enqueued messages and can be *served* to process said messages. A queue is
//! identified by its origin in the `BookStateFor`. Each message has an origin which defines into
//! which queue it will be stored. Messages are stored by being appended to the last [`Page`] of a
//! book. Each book keeps track of its pages by indexing `Pages`. The `ReadyRing` contains all
//! queues which hold at least one unprocessed message and are thereby *ready* to be serviced. The
//! `ServiceHead` indicates which *ready* queue is the next to be serviced.
//! The pallet implements [`pezframe_support::traits::EnqueueMessage`],
//! The pezpallet implements [`pezframe_support::traits::EnqueueMessage`],
//! [`pezframe_support::traits::ServiceQueues`] and has [`pezframe_support::traits::ProcessMessage`] and
//! [`OnQueueChanged`] hooks to communicate with the outside world.
//!
@@ -52,29 +52,29 @@
//! logic of how to handle the message since they are blobs. Storage changes are not rolled back on
//! error.
//!
//! A failed message can be temporarily or permanently overweight. The pallet will perpetually try
//! A failed message can be temporarily or permanently overweight. The pezpallet will perpetually try
//! to execute a temporarily overweight message. A permanently overweight message is skipped and
//! must be executed manually.
//!
//! **Reentrancy**
//!
//! This pallet has two entry points for executing (possibly recursive) logic;
//! [`Pallet::service_queues`] and [`Pallet::execute_overweight`]. Both entry points are guarded by
//! This pezpallet has two entry points for executing (possibly recursive) logic;
//! [`Pezpallet::service_queues`] and [`Pezpallet::execute_overweight`]. Both entry points are guarded by
//! the same mutex to error on reentrancy. The only functions that are explicitly **allowed** to be
//! called by a message processor are: [`Pallet::enqueue_message`] and
//! [`Pallet::enqueue_messages`]. All other functions are forbidden and error with
//! called by a message processor are: [`Pezpallet::enqueue_message`] and
//! [`Pezpallet::enqueue_messages`]. All other functions are forbidden and error with
//! [`Error::RecursiveDisallowed`].
//!
//! **Pagination**
//!
//! Queues are stored in a *paged* manner by splitting their messages into [`Page`]s. This results
//! in a lot of complexity when implementing the pallet but is completely necessary to achieve the
//! in a lot of complexity when implementing the pezpallet but is completely necessary to achieve the
//! second #[Design Goal](design-goals). The problem comes from the fact a message can *possibly* be
//! quite large, lets say 64KiB. This then results in a *MEL* of at least 64KiB which results in a
//! PoV of at least 64KiB. Now we have the assumption that most messages are much shorter than their
//! maximum allowed length. This would result in most messages having a pre-dispatch PoV size which
//! is much larger than their post-dispatch PoV size, possibly by a factor of thousand. Disregarding
//! this observation would cripple the processing power of the pallet since it cannot straighten out
//! this observation would cripple the processing power of the pezpallet since it cannot straighten out
//! this discrepancy at runtime. Conceptually, the implementation is packing as many messages into a
//! single bounded vec, as actually fit into the bounds. This reduces the wasted PoV.
//!
@@ -88,10 +88,10 @@
//!
//! **Weight Metering**
//!
//! The pallet utilizes the [`pezsp_weights::WeightMeter`] to manually track its consumption to always
//! The pezpallet utilizes the [`pezsp_weights::WeightMeter`] to manually track its consumption to always
//! stay within the required limit. This implies that the message processor hook can calculate the
//! weight of a message without executing it. This restricts the possible use-cases but is necessary
//! since the pallet runs in `on_initialize` which has a hard weight limit. The weight meter is used
//! since the pezpallet runs in `on_initialize` which has a hard weight limit. The weight meter is used
//! in a way that `can_accrue` and `check_accrue` are always used to check the remaining weight of
//! an operation before committing to it. The process of exiting due to insufficient weight is
//! termed "bailing".
@@ -110,14 +110,14 @@
//!
//! # Scenario: Message processing
//!
//! The pallet runs each block in `on_initialize` or when being manually called through
//! The pezpallet runs each block in `on_initialize` or when being manually called through
//! [`pezframe_support::traits::ServiceQueues::service_queues`].
//!
//! First it tries to "rotate" the `ReadyRing` by one through advancing the `ServiceHead` to the
//! next *ready* queue. It then starts to service this queue by servicing as many pages of it as
//! possible. Servicing a page means to execute as many message of it as possible. Each executed
//! message is marked as *processed* if the [`Config::MessageProcessor`] return Ok. An event
//! [`Event::Processed`] is emitted afterwards. It is possible that the weight limit of the pallet
//! [`Event::Processed`] is emitted afterwards. It is possible that the weight limit of the pezpallet
//! will never allow a specific message to be executed. In this case it remains as unprocessed and
//! is skipped. This process stops if either there are no more messages in the queue or the
//! remaining weight became insufficient to service this queue. If there is enough weight it tries
@@ -139,7 +139,7 @@
//!
//! # Terminology
//!
//! - `Message`: A blob of data into which the pallet has no introspection, defined as
//! - `Message`: A blob of data into which the pezpallet has no introspection, defined as
//! [`BoundedSlice<u8, MaxMessageLenOf<T>>`]. The message length is limited by [`MaxMessageLenOf`]
//! which is calculated from [`Config::HeapSize`] and [`ItemHeader::max_encoded_len()`].
//! - `MessageOrigin`: A generic *origin* of a message, defined as [`MessageOriginOf`]. The
@@ -153,7 +153,7 @@
//! queues via their `ready_neighbours` fields. A `Queue` is *ready* if it contains at least one
//! `Message` which can be processed. Can be empty.
//! - `ServiceHead`: A pointer into the `ReadyRing` to the next `Queue` to be serviced.
//! - (`un`)`processed`: A message is marked as *processed* after it was executed by the pallet. A
//! - (`un`)`processed`: A message is marked as *processed* after it was executed by the pezpallet. A
//! message which was either: not yet executed or could not be executed remains as `unprocessed`
//! which is the default state for a message after being enqueued.
//! - `knitting`/`unknitting`: The means of adding or removing a `Queue` from the `ReadyRing`.
@@ -176,7 +176,7 @@
//!
//! **Progress - Processing**
//!
//! The pallet will execute at least one unprocessed message per block, if there is any. Ensuring
//! The pezpallet will execute at least one unprocessed message per block, if there is any. Ensuring
//! this property needs careful consideration of the concrete weights, since it is possible that the
//! weight limit of `on_initialize` never allows for the execution of even one message; trivially if
//! the limit is set to zero. `integrity_test` can be used to ensure that this property holds.
@@ -219,7 +219,7 @@ use pezframe_support::{
BoundedSlice, CloneNoBound, DefaultNoBound,
};
use pezframe_system::pezpallet_prelude::*;
pub use pallet::*;
pub use pezpallet::*;
use scale_info::TypeInfo;
use pezsp_arithmetic::traits::{BaseArithmetic, Unsigned};
use pezsp_core::{defer, H256};
@@ -494,21 +494,21 @@ pub trait ForceSetHead<O> {
fn force_set_head(weight: &mut WeightMeter, origin: &O) -> Result<bool, ()>;
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
/// The module configuration trait.
#[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>;
/// Weight information for extrinsics in this pallet.
/// Weight information for extrinsics in this pezpallet.
type WeightInfo: WeightInfo;
/// Processor for a message.
@@ -540,7 +540,7 @@ pub mod pallet {
/// removed.
type QueueChangeHandler: OnQueueChanged<<Self::MessageProcessor as ProcessMessage>::Origin>;
/// Queried by the pallet to check whether a queue can be serviced.
/// Queried by the pezpallet to check whether a queue can be serviced.
///
/// This also applies to manual servicing via `execute_overweight` and `service_queues`. The
/// value of this is only polled once before servicing the queue. This means that changes to
@@ -552,13 +552,13 @@ pub mod pallet {
/// A good value depends on the expected message sizes, their weights, the weight that is
/// available for processing them and the maximal needed message size. The maximal message
/// size is slightly lower than this as defined by [`MaxMessageLenOf`].
#[pallet::constant]
#[pezpallet::constant]
type HeapSize: Get<Self::Size>;
/// The maximum number of stale pages (i.e. of overweight messages) allowed before culling
/// can happen. Once there are more stale pages than this, then historical pages may be
/// dropped, even if they contain unprocessed overweight messages.
#[pallet::constant]
#[pezpallet::constant]
type MaxStale: Get<u32>;
/// The amount of weight (if any) which should be provided to the message queue for
@@ -567,7 +567,7 @@ pub mod pallet {
/// This may be legitimately `None` in the case that you will call
/// `ServiceQueues::service_queues` manually or set [`Self::IdleMaxServiceWeight`] to have
/// it run in `on_idle`.
#[pallet::constant]
#[pezpallet::constant]
type ServiceWeight: Get<Option<Weight>>;
/// The maximum amount of weight (if any) to be used from remaining weight `on_idle` which
@@ -575,12 +575,12 @@ pub mod pallet {
/// Useful for teyrchains to process messages at the same block they are received.
///
/// If `None`, it will not call `ServiceQueues::service_queues` in `on_idle`.
#[pallet::constant]
#[pezpallet::constant]
type IdleMaxServiceWeight: Get<Option<Weight>>;
}
#[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> {
/// Message discarded due to an error in the `MessageProcessor` (usually a format error).
ProcessingFailed {
@@ -605,7 +605,7 @@ pub mod pallet {
/// Whether the message was processed.
///
/// Note that this does not mean that the underlying `MessageProcessor` was internally
/// successful. It *solely* means that the MQ pallet will treat this as a success
/// successful. It *solely* means that the MQ pezpallet will treat this as a success
/// condition and discard the message. Any internal error needs to be emitted as events
/// by the `MessageProcessor`.
success: bool,
@@ -630,7 +630,7 @@ pub mod pallet {
},
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Page is not reapable because it has items remaining to be processed and is not old
/// enough.
@@ -659,16 +659,16 @@ pub mod pallet {
}
/// The index of the first and last (non-empty) pages.
#[pallet::storage]
#[pezpallet::storage]
pub type BookStateFor<T: Config> =
StorageMap<_, Twox64Concat, MessageOriginOf<T>, BookState<MessageOriginOf<T>>, ValueQuery>;
/// The origin at which we should begin servicing.
#[pallet::storage]
#[pezpallet::storage]
pub type ServiceHead<T: Config> = StorageValue<_, MessageOriginOf<T>, OptionQuery>;
/// The map of page indices to pages.
#[pallet::storage]
#[pezpallet::storage]
pub type Pages<T: Config> = StorageDoubleMap<
_,
Twox64Concat,
@@ -679,8 +679,8 @@ pub mod pallet {
OptionQuery,
>;
#[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 {
if let Some(weight_limit) = T::ServiceWeight::get() {
Self::service_queues_impl(weight_limit, ServiceQueuesContext::OnInitialize)
@@ -709,15 +709,15 @@ pub mod pallet {
/// Check all compile-time assumptions about [`crate::Config`].
#[cfg(test)]
fn integrity_test() {
Self::do_integrity_test().expect("Pallet config is valid; qed")
Self::do_integrity_test().expect("Pezpallet config is valid; qed")
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Remove a page which has no more messages remaining to be processed or is stale.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::reap_page())]
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::reap_page())]
pub fn reap_page(
origin: OriginFor<T>,
message_origin: MessageOriginOf<T>,
@@ -740,8 +740,8 @@ pub mod pallet {
/// of the message.
///
/// Benchmark complexity considerations: O(index + weight_limit).
#[pallet::call_index(1)]
#[pallet::weight(
#[pezpallet::call_index(1)]
#[pezpallet::weight(
T::WeightInfo::execute_overweight_page_updated().max(
T::WeightInfo::execute_overweight_page_removed()).saturating_add(*weight_limit)
)]
@@ -814,7 +814,7 @@ enum MessageExecutionStatus {
StackLimitReached,
}
/// The context to pass to [`Pallet::service_queues_impl`] through on_idle and on_initialize hooks
/// The context to pass to [`Pezpallet::service_queues_impl`] through on_idle and on_initialize hooks
/// We don't want to throw the defensive message if called from on_idle hook
#[derive(PartialEq)]
enum ServiceQueuesContext {
@@ -826,7 +826,7 @@ enum ServiceQueuesContext {
ServiceQueues,
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Knit `origin` into the ready ring right at the end.
///
/// Return the two ready ring neighbours of `origin`.
@@ -951,7 +951,7 @@ impl<T: Config> Pallet<T> {
.saturating_add(T::WeightInfo::ready_ring_unknit())
}
/// Checks invariants of the pallet config.
/// Checks invariants of the pezpallet config.
///
/// The results of this can only be relied upon if the config values are set to constants.
#[cfg(test)]
@@ -1391,7 +1391,7 @@ impl<T: Config> Pallet<T> {
ItemExecutionStatus::Executed(is_processed)
}
/// Ensure the correctness of state of this pallet.
/// Ensure the correctness of state of this pezpallet.
///
/// # Assumptions-
///
@@ -1679,9 +1679,9 @@ impl<T: Config> Pallet<T> {
}
}
impl<T: Config> ForceSetHead<MessageOriginOf<T>> for Pallet<T> {
impl<T: Config> ForceSetHead<MessageOriginOf<T>> for Pezpallet<T> {
fn force_set_head(weight: &mut WeightMeter, origin: &MessageOriginOf<T>) -> Result<bool, ()> {
Pallet::<T>::set_service_head(weight, origin)
Pezpallet::<T>::set_service_head(weight, origin)
}
}
@@ -1730,13 +1730,13 @@ pub type MaxMessageLenOf<T> =
MaxMessageLen<MessageOriginOf<T>, <T as Config>::Size, <T as Config>::HeapSize>;
/// The maximal encoded origin length.
pub type MaxOriginLenOf<T> = MaxEncodedLenOf<MessageOriginOf<T>>;
/// The `MessageOrigin` of this pallet.
/// The `MessageOrigin` of this pezpallet.
pub type MessageOriginOf<T> = <<T as Config>::MessageProcessor as ProcessMessage>::Origin;
/// The maximal heap size of a page.
pub type HeapSizeU32Of<T> = IntoU32<<T as Config>::HeapSize, <T as Config>::Size>;
/// The [`Page`] of this pallet.
/// The [`Page`] of this pezpallet.
pub type PageOf<T> = Page<<T as Config>::Size, <T as Config>::HeapSize>;
/// The [`BookState`] of this pallet.
/// The [`BookState`] of this pezpallet.
pub type BookStateOf<T> = BookState<MessageOriginOf<T>>;
/// Converts a [`pezsp_core::Get`] with returns a type that can be cast into an `u32` into a `Get`
@@ -1748,7 +1748,7 @@ impl<T: Get<O>, O: Into<u32>> Get<u32> for IntoU32<T, O> {
}
}
impl<T: Config> ServiceQueues for Pallet<T> {
impl<T: Config> ServiceQueues for Pezpallet<T> {
type OverweightMessageAddress = (MessageOriginOf<T>, PageIndex, T::Size);
fn service_queues(weight_limit: Weight) -> Weight {
@@ -1773,7 +1773,7 @@ impl<T: Config> ServiceQueues for Pallet<T> {
return Err(ExecuteOverweightError::InsufficientWeight);
}
Pallet::<T>::do_execute_overweight(message_origin, page, index, weight.remaining()).map_err(
Pezpallet::<T>::do_execute_overweight(message_origin, page, index, weight.remaining()).map_err(
|e| match e {
Error::<T>::InsufficientWeight => ExecuteOverweightError::InsufficientWeight,
Error::<T>::AlreadyProcessed => ExecuteOverweightError::AlreadyProcessed,
@@ -1787,7 +1787,7 @@ impl<T: Config> ServiceQueues for Pallet<T> {
}
}
impl<T: Config> EnqueueMessage<MessageOriginOf<T>> for Pallet<T> {
impl<T: Config> EnqueueMessage<MessageOriginOf<T>> for Pezpallet<T> {
type MaxMessageLen =
MaxMessageLen<<T::MessageProcessor as ProcessMessage>::Origin, T::Size, T::HeapSize>;
@@ -1822,7 +1822,7 @@ impl<T: Config> EnqueueMessage<MessageOriginOf<T>> for Pallet<T> {
}
}
impl<T: Config> QueueFootprintQuery<MessageOriginOf<T>> for Pallet<T> {
impl<T: Config> QueueFootprintQuery<MessageOriginOf<T>> for Pezpallet<T> {
type MaxMessageLen =
MaxMessageLen<<T::MessageProcessor as ProcessMessage>::Origin, T::Size, T::HeapSize>;
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Test helpers and runtime setup for the message queue pallet.
//! Test helpers and runtime setup for the message queue pezpallet.
#![cfg(test)]
@@ -316,7 +316,7 @@ where
NumMessagesErrored::take();
let t = pezframe_system::GenesisConfig::<T>::default().build_storage().unwrap();
let mut ext = pezsp_io::TestExternalities::new(t);
ext.execute_with(|| pezframe_system::Pallet::<T>::set_block_number(1.into()));
ext.execute_with(|| pezframe_system::Pezpallet::<T>::set_block_number(1.into()));
ext
}
@@ -327,7 +327,7 @@ where
{
new_test_ext::<T>().execute_with(|| {
test();
pezpallet_message_queue::Pallet::<T>::do_try_state()
pezpallet_message_queue::Pezpallet::<T>::do_try_state()
.expect("All invariants must hold after a test");
});
}
@@ -369,7 +369,7 @@ pub fn unknit(queue: &MessageOrigin) {
}
pub fn num_overweight_enqueued_events() -> u32 {
pezframe_system::Pallet::<Test>::events()
pezframe_system::Pezpallet::<Test>::events()
.into_iter()
.filter(|e| {
matches!(e.event, RuntimeEvent::MessageQueue(crate::Event::OverweightEnqueued { .. }))
@@ -144,10 +144,10 @@ pub fn book_for<T: Config>(page: &PageOf<T>) -> BookStateOf<T> {
#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))]
pub fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
assert!(
!pezframe_system::Pallet::<T>::block_number().is_zero(),
!pezframe_system::Pezpallet::<T>::block_number().is_zero(),
"The genesis block has n o events"
);
pezframe_system::Pallet::<T>::assert_last_event(generic_event.into());
pezframe_system::Pezpallet::<T>::assert_last_event(generic_event.into());
}
/// Provide a setup for `bump_service_head`.
@@ -155,21 +155,21 @@ pub fn setup_bump_service_head<T: Config>(
current: <<T as Config>::MessageProcessor as ProcessMessage>::Origin,
next: <<T as Config>::MessageProcessor as ProcessMessage>::Origin,
) {
crate::Pallet::<T>::enqueue_message(msg("1"), current);
crate::Pallet::<T>::enqueue_message(msg("1"), next);
crate::Pezpallet::<T>::enqueue_message(msg("1"), current);
crate::Pezpallet::<T>::enqueue_message(msg("1"), next);
}
/// Knit a queue into the ready-ring and write it back to storage.
pub fn knit<T: Config>(o: &<<T as Config>::MessageProcessor as ProcessMessage>::Origin) {
let mut b = BookStateFor::<T>::get(o);
b.ready_neighbours = crate::Pallet::<T>::ready_ring_knit(o).ok().defensive();
b.ready_neighbours = crate::Pezpallet::<T>::ready_ring_knit(o).ok().defensive();
BookStateFor::<T>::insert(o, b);
}
/// Unknit a queue into the ready-ring and write it back to storage.
pub fn unknit<T: Config>(o: &<<T as Config>::MessageProcessor as ProcessMessage>::Origin) {
let mut b = BookStateFor::<T>::get(o);
crate::Pallet::<T>::ready_ring_unknit(o, b.ready_neighbours.unwrap());
crate::Pezpallet::<T>::ready_ring_unknit(o, b.ready_neighbours.unwrap());
b.ready_neighbours = None;
BookStateFor::<T>::insert(o, b);
}
@@ -179,7 +179,7 @@ pub fn build_ring<T: Config>(
queues: &[<<T as Config>::MessageProcessor as ProcessMessage>::Origin],
) {
for queue in queues.iter() {
crate::Pallet::<T>::enqueue_message(msg("1"), queue.clone());
crate::Pezpallet::<T>::enqueue_message(msg("1"), queue.clone());
}
assert_ring::<T>(queues);
}
+17 -17
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Tests for Message Queue Pallet.
//! Tests for Message Queue Pezpallet.
#![cfg(test)]
@@ -473,7 +473,7 @@ fn service_page_works() {
let mut meter = WeightMeter::with_limit(((2 + (3 + 1) * process) as u64).into_weight());
System::reset_events();
let (processed, status) =
crate::Pallet::<Test>::service_page(&Here, &mut book, &mut meter, Weight::MAX);
crate::Pezpallet::<Test>::service_page(&Here, &mut book, &mut meter, Weight::MAX);
assert_eq!(processed as usize, process);
assert_eq!(NumMessagesProcessed::take(), process);
assert_eq!(System::events().len(), process);
@@ -564,7 +564,7 @@ fn service_page_suspension_works() {
// First we process 5 messages from this page.
let mut meter = WeightMeter::with_limit(5.into_weight());
let (_, status) =
crate::Pallet::<Test>::service_page(&Here, &mut book, &mut meter, Weight::MAX);
crate::Pezpallet::<Test>::service_page(&Here, &mut book, &mut meter, Weight::MAX);
assert_eq!(NumMessagesProcessed::take(), 5);
assert!(meter.remaining().is_zero());
@@ -575,7 +575,7 @@ fn service_page_suspension_works() {
YieldingQueues::set(vec![Here]);
// Noting happens...
for _ in 0..5 {
let (_, status) = crate::Pallet::<Test>::service_page(
let (_, status) = crate::Pezpallet::<Test>::service_page(
&Here,
&mut book,
&mut WeightMeter::new(),
@@ -587,7 +587,7 @@ fn service_page_suspension_works() {
// Resume and process all remaining.
YieldingQueues::take();
let (_, status) = crate::Pallet::<Test>::service_page(
let (_, status) = crate::Pezpallet::<Test>::service_page(
&Here,
&mut book,
&mut WeightMeter::new(),
@@ -697,7 +697,7 @@ fn service_page_item_skips_perm_overweight_message() {
set_weight("service_page_item", 2.into_weight());
assert_eq!(
crate::Pallet::<Test>::service_page_item(
crate::Pezpallet::<Test>::service_page_item(
&MessageOrigin::Here,
0,
&mut book_for::<Test>(&page),
@@ -1251,7 +1251,7 @@ fn permanently_overweight_limit_is_valid_basic() {
MessageQueue::service_queues(w.into());
let last_event =
pezframe_system::Pallet::<Test>::events().into_iter().last().expect("No event");
pezframe_system::Pezpallet::<Test>::events().into_iter().last().expect("No event");
// The weight overhead for a single message is set to 50. The message itself needs 200.
// Every weight in range `[50, 249]` should result in a permanently overweight message:
@@ -1311,7 +1311,7 @@ fn permanently_overweight_limit_is_valid_fuzzy() {
MessageQueue::service_queues(w.into());
let last_event =
pezframe_system::Pallet::<Test>::events().into_iter().last().expect("No event");
pezframe_system::Pezpallet::<Test>::events().into_iter().last().expect("No event");
if w < o + 200 {
assert_eq!(
@@ -1858,7 +1858,7 @@ fn process_enqueued_on_idle() {
assert_eq!(BookStateFor::<Test>::iter().count(), 1);
// Process enqueued messages from previous block.
Pallet::<Test>::on_initialize(1);
Pezpallet::<Test>::on_initialize(1);
assert_eq!(
MessagesProcessed::take(),
vec![(b"a".to_vec(), Here), (b"ab".to_vec(), Here), (b"abc".to_vec(), Here),]
@@ -1868,7 +1868,7 @@ fn process_enqueued_on_idle() {
assert_eq!(BookStateFor::<Test>::iter().count(), 2);
// Enough weight to process on idle.
Pallet::<Test>::on_idle(1, Weight::from_parts(100, 100));
Pezpallet::<Test>::on_idle(1, Weight::from_parts(100, 100));
assert_eq!(
MessagesProcessed::take(),
vec![(b"x".to_vec(), There), (b"xy".to_vec(), There), (b"xyz".to_vec(), There)]
@@ -1880,13 +1880,13 @@ fn process_enqueued_on_idle() {
fn process_enqueued_on_idle_requires_enough_weight() {
use MessageOrigin::*;
build_and_execute::<Test>(|| {
Pallet::<Test>::on_initialize(1);
Pezpallet::<Test>::on_initialize(1);
MessageQueue::enqueue_messages(vec![msg("x"), msg("xy"), msg("xyz")].into_iter(), There);
assert_eq!(BookStateFor::<Test>::iter().count(), 1);
// Not enough weight to process on idle.
Pallet::<Test>::on_idle(1, Weight::from_parts(0, 0));
Pezpallet::<Test>::on_idle(1, Weight::from_parts(0, 0));
assert_eq!(MessagesProcessed::take(), vec![]);
assert!(!System::events().into_iter().any(|e| matches!(
@@ -2075,7 +2075,7 @@ fn force_set_head_can_starve_other_queues() {
}};
// But we won't let that happen and instead prioritize it:
assert!(Pallet::<Test>::force_set_head(&mut WeightMeter::new(), &Here).unwrap());
assert!(Pezpallet::<Test>::force_set_head(&mut WeightMeter::new(), &Here).unwrap());
MessageQueue::service_queues(1.into_weight());
assert_eq!(MessagesProcessed::take(), vec![(b"A".to_vec(), Here)]);
@@ -2092,7 +2092,7 @@ fn force_set_head_noop_on_unready_queue() {
assert_ring(&[]);
let _guard = StorageNoopGuard::new();
let was_set = Pallet::<Test>::force_set_head(&mut WeightMeter::new(), &There).unwrap();
let was_set = Pezpallet::<Test>::force_set_head(&mut WeightMeter::new(), &There).unwrap();
assert!(!was_set);
});
}
@@ -2107,7 +2107,7 @@ fn force_set_head_noop_on_current_head() {
assert_ring(&[Here]);
let _guard = StorageNoopGuard::new();
let was_set = Pallet::<Test>::force_set_head(&mut WeightMeter::new(), &Here).unwrap();
let was_set = Pezpallet::<Test>::force_set_head(&mut WeightMeter::new(), &Here).unwrap();
assert!(was_set);
});
}
@@ -2120,7 +2120,7 @@ fn force_set_head_noop_unprocessed_queue() {
assert_ring(&[Here]);
let _guard = StorageNoopGuard::new();
let was_set = Pallet::<Test>::force_set_head(&mut WeightMeter::new(), &Here).unwrap();
let was_set = Pezpallet::<Test>::force_set_head(&mut WeightMeter::new(), &Here).unwrap();
assert!(was_set);
});
}
@@ -2134,7 +2134,7 @@ fn force_set_head_works() {
assert_eq!(ServiceHead::<Test>::get(), Some(Here));
assert_ring(&[Here, There]);
let was_set = Pallet::<Test>::force_set_head(&mut WeightMeter::new(), &There).unwrap();
let was_set = Pezpallet::<Test>::force_set_head(&mut WeightMeter::new(), &There).unwrap();
assert!(was_set);
assert_eq!(ServiceHead::<Test>::get(), Some(There));
@@ -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_message_queue
// --pezpallet=pezpallet_message_queue
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/message-queue/src/weights.rs
// --wasm-execution=compiled