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.
//! Democracy pallet benchmarking.
//! Democracy pezpallet benchmarking.
#![cfg(feature = "runtime-benchmarks")]
@@ -29,7 +29,7 @@ use pezframe_support::{
use pezframe_system::{pezpallet_prelude::BlockNumberFor, RawOrigin};
use pezsp_runtime::{traits::Bounded, BoundedVec};
use crate::Pallet as Democracy;
use crate::Pezpallet as Democracy;
const REFERENDUM_COUNT_HINT: u32 = 10;
const SEED: u32 = 0;
@@ -78,11 +78,11 @@ fn account_vote<T: Config>(b: BalanceOf<T>) -> AccountVote<BalanceOf<T>> {
}
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
pezframe_system::Pallet::<T>::assert_last_event(generic_event.into());
pezframe_system::Pezpallet::<T>::assert_last_event(generic_event.into());
}
fn assert_has_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
pezframe_system::Pallet::<T>::assert_has_event(generic_event.into());
pezframe_system::Pezpallet::<T>::assert_has_event(generic_event.into());
}
// note a new preimage.
+98 -98
View File
@@ -15,21 +15,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Democracy Pallet
//! # Democracy Pezpallet
//!
//! - [`Config`]
//! - [`Call`]
//!
//! ## Overview
//!
//! The Democracy pallet handles the administration of general stakeholder voting.
//! The Democracy pezpallet handles the administration of general stakeholder voting.
//!
//! There are two different queues that a proposal can be added to before it
//! becomes a referendum, 1) the proposal queue consisting of all public proposals
//! and 2) the external queue consisting of a single proposal that originates
//! from one of the _external_ origins (such as a collective group).
//!
//! Every launch period - a length defined in the runtime - the Democracy pallet
//! Every launch period - a length defined in the runtime - the Democracy pezpallet
//! launches a referendum from a proposal that it takes from either the proposal
//! queue or the external queue in turn. Any token holder in the system can vote
//! on referenda. The voting system
@@ -178,7 +178,7 @@ mod vote;
mod vote_threshold;
pub mod weights;
pub use conviction::Conviction;
pub use pallet::*;
pub use pezpallet::*;
pub use types::{
Delegations, MetadataOwner, PropIndex, ReferendumIndex, ReferendumInfo, ReferendumStatus,
Tally, UnvoteScope,
@@ -206,8 +206,8 @@ pub type CallOf<T> = <T as pezframe_system::Config>::RuntimeCall;
pub type BoundedCallOf<T> = Bounded<CallOf<T>, <T as pezframe_system::Config>::Hashing>;
type AccountIdLookupOf<T> = <<T as pezframe_system::Config>::Lookup as StaticLookup>::Source;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::{DispatchResult, *};
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
@@ -215,11 +215,11 @@ pub mod pallet {
/// 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: pezframe_system::Config + Sized {
type WeightInfo: WeightInfo;
#[allow(deprecated)]
@@ -236,7 +236,7 @@ pub mod pallet {
/// The Preimage provider.
type Preimages: QueryPreimage<H = Self::Hashing> + StorePreimage;
/// Currency type for this pallet.
/// Currency type for this pezpallet.
type Currency: ReservableCurrency<Self::AccountId>
+ LockableCurrency<Self::AccountId, Moment = BlockNumberFor<Self>>;
@@ -245,59 +245,59 @@ pub mod pallet {
/// It should generally be a little more than the unstake period to ensure that
/// voting stakers have an opportunity to remove themselves from the system in the case
/// where they are on the losing side of a vote.
#[pallet::constant]
#[pezpallet::constant]
type EnactmentPeriod: Get<BlockNumberFor<Self>>;
/// How often (in blocks) new public referenda are launched.
#[pallet::constant]
#[pezpallet::constant]
type LaunchPeriod: Get<BlockNumberFor<Self>>;
/// How often (in blocks) to check for new votes.
#[pallet::constant]
#[pezpallet::constant]
type VotingPeriod: Get<BlockNumberFor<Self>>;
/// The minimum period of vote locking.
///
/// It should be no shorter than enactment period to ensure that in the case of an approval,
/// those successful voters are locked into the consequences that their votes entail.
#[pallet::constant]
#[pezpallet::constant]
type VoteLockingPeriod: Get<BlockNumberFor<Self>>;
/// The minimum amount to be used as a deposit for a public referendum proposal.
#[pallet::constant]
#[pezpallet::constant]
type MinimumDeposit: Get<BalanceOf<Self>>;
/// Indicator for whether an emergency origin is even allowed to happen. Some chains may
/// want to set this permanently to `false`, others may want to condition it on things such
/// as an upgrade having happened recently.
#[pallet::constant]
#[pezpallet::constant]
type InstantAllowed: Get<bool>;
/// Minimum voting period allowed for a fast-track referendum.
#[pallet::constant]
#[pezpallet::constant]
type FastTrackVotingPeriod: Get<BlockNumberFor<Self>>;
/// Period in blocks where an external proposal may not be re-submitted after being vetoed.
#[pallet::constant]
#[pezpallet::constant]
type CooloffPeriod: Get<BlockNumberFor<Self>>;
/// The maximum number of votes for an account.
///
/// Also used to compute weight, an overly big value can
/// lead to extrinsic with very big weight: see `delegate` for instance.
#[pallet::constant]
#[pezpallet::constant]
type MaxVotes: Get<u32>;
/// The maximum number of public proposals that can exist at any time.
#[pallet::constant]
#[pezpallet::constant]
type MaxProposals: Get<u32>;
/// The maximum number of deposits a public proposal may have at any time.
#[pallet::constant]
#[pezpallet::constant]
type MaxDeposits: Get<u32>;
/// The maximum number of items which can be blacklisted.
#[pallet::constant]
#[pezpallet::constant]
type MaxBlacklisted: Get<u32>;
/// Origin from which the next tabled referendum may be forced. This is a normal
@@ -347,11 +347,11 @@ pub mod pallet {
}
/// The number of (public) proposals that have been made so far.
#[pallet::storage]
#[pezpallet::storage]
pub type PublicPropCount<T> = StorageValue<_, PropIndex, ValueQuery>;
/// The public proposals. Unsorted. The second item is the proposal.
#[pallet::storage]
#[pezpallet::storage]
pub type PublicProps<T: Config> = StorageValue<
_,
BoundedVec<(PropIndex, BoundedCallOf<T>, T::AccountId), T::MaxProposals>,
@@ -361,7 +361,7 @@ pub mod pallet {
/// Those who have locked a deposit.
///
/// TWOX-NOTE: Safe, as increasing integer keys are safe.
#[pallet::storage]
#[pezpallet::storage]
pub type DepositOf<T: Config> = StorageMap<
_,
Twox64Concat,
@@ -370,18 +370,18 @@ pub mod pallet {
>;
/// The next free referendum index, aka the number of referenda started so far.
#[pallet::storage]
#[pezpallet::storage]
pub type ReferendumCount<T> = StorageValue<_, ReferendumIndex, ValueQuery>;
/// The lowest referendum index representing an unbaked referendum. Equal to
/// `ReferendumCount` if there isn't a unbaked referendum.
#[pallet::storage]
#[pezpallet::storage]
pub type LowestUnbaked<T> = StorageValue<_, ReferendumIndex, ValueQuery>;
/// Information concerning any given referendum.
///
/// TWOX-NOTE: SAFE as indexes are not under an attackers control.
#[pallet::storage]
#[pezpallet::storage]
pub type ReferendumInfoOf<T: Config> = StorageMap<
_,
Twox64Concat,
@@ -393,7 +393,7 @@ pub mod pallet {
/// have recorded. The second item is the total amount of delegations, that will be added.
///
/// TWOX-NOTE: SAFE as `AccountId`s are crypto hashes anyway.
#[pallet::storage]
#[pezpallet::storage]
pub type VotingOf<T: Config> = StorageMap<
_,
Twox64Concat,
@@ -404,19 +404,19 @@ pub mod pallet {
/// True if the last referendum tabled was submitted externally. False if it was a public
/// proposal.
#[pallet::storage]
#[pezpallet::storage]
pub type LastTabledWasExternal<T> = StorageValue<_, bool, ValueQuery>;
/// The referendum to be tabled whenever it would be valid to table an external proposal.
/// This happens when a referendum needs to be tabled and one of two conditions are met:
/// - `LastTabledWasExternal` is `false`; or
/// - `PublicProps` is empty.
#[pallet::storage]
#[pezpallet::storage]
pub type NextExternal<T: Config> = StorageValue<_, (BoundedCallOf<T>, VoteThreshold)>;
/// A record of who vetoed what. Maps proposal hash to a possible existent block number
/// (until when it may not be resubmitted) and who vetoed it.
#[pallet::storage]
#[pezpallet::storage]
pub type Blacklist<T: Config> = StorageMap<
_,
Identity,
@@ -425,7 +425,7 @@ pub mod pallet {
>;
/// Record of all proposals that have been subject to emergency cancellation.
#[pallet::storage]
#[pezpallet::storage]
pub type Cancellations<T: Config> = StorageMap<_, Identity, T::Hash, bool, ValueQuery>;
/// General information concerning any proposal or referendum.
@@ -434,17 +434,17 @@ pub mod pallet {
///
/// Consider a garbage collection for a metadata of finished referendums to `unrequest` (remove)
/// large preimages.
#[pallet::storage]
#[pezpallet::storage]
pub type MetadataOf<T: Config> = StorageMap<_, Blake2_128Concat, MetadataOwner, T::Hash>;
#[pallet::genesis_config]
#[pezpallet::genesis_config]
#[derive(pezframe_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
#[serde(skip)]
_config: core::marker::PhantomData<T>,
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
PublicPropCount::<T>::put(0 as PropIndex);
@@ -453,8 +453,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> {
/// A motion has been proposed by a public account.
Proposed { proposal_index: PropIndex, deposit: BalanceOf<T> },
@@ -509,7 +509,7 @@ pub mod pallet {
},
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Value too low
ValueLow,
@@ -562,16 +562,16 @@ pub mod pallet {
PreimageNotExist,
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
/// Weight: see `begin_block`
fn on_initialize(n: BlockNumberFor<T>) -> Weight {
Self::begin_block(n)
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Propose a sensitive action to be taken.
///
/// The dispatch origin of this call must be _Signed_ and the sender must
@@ -581,12 +581,12 @@ pub mod pallet {
/// - `value`: The amount of deposit (must be at least `MinimumDeposit`).
///
/// Emits `Proposed`.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::propose())]
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::propose())]
pub fn propose(
origin: OriginFor<T>,
proposal: BoundedCallOf<T>,
#[pallet::compact] value: BalanceOf<T>,
#[pezpallet::compact] value: BalanceOf<T>,
) -> DispatchResult {
let who = T::SubmitOrigin::ensure_origin(origin)?;
ensure!(value >= T::MinimumDeposit::get(), Error::<T>::ValueLow);
@@ -599,7 +599,7 @@ pub mod pallet {
if let Some((until, _)) = Blacklist::<T>::get(proposal_hash) {
ensure!(
pezframe_system::Pallet::<T>::block_number() >= until,
pezframe_system::Pezpallet::<T>::block_number() >= until,
Error::<T>::ProposalBlacklisted,
);
}
@@ -624,11 +624,11 @@ pub mod pallet {
/// must have funds to cover the deposit, equal to the original deposit.
///
/// - `proposal`: The index of the proposal to second.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::second())]
#[pezpallet::call_index(1)]
#[pezpallet::weight(T::WeightInfo::second())]
pub fn second(
origin: OriginFor<T>,
#[pallet::compact] proposal: PropIndex,
#[pezpallet::compact] proposal: PropIndex,
) -> DispatchResult {
let who = ensure_signed(origin)?;
@@ -650,11 +650,11 @@ pub mod pallet {
///
/// - `ref_index`: The index of the referendum to vote for.
/// - `vote`: The vote configuration.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::vote_new().max(T::WeightInfo::vote_existing()))]
#[pezpallet::call_index(2)]
#[pezpallet::weight(T::WeightInfo::vote_new().max(T::WeightInfo::vote_existing()))]
pub fn vote(
origin: OriginFor<T>,
#[pallet::compact] ref_index: ReferendumIndex,
#[pezpallet::compact] ref_index: ReferendumIndex,
vote: AccountVote<BalanceOf<T>>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
@@ -669,8 +669,8 @@ pub mod pallet {
/// -`ref_index`: The index of the referendum to cancel.
///
/// Weight: `O(1)`.
#[pallet::call_index(3)]
#[pallet::weight((T::WeightInfo::emergency_cancel(), DispatchClass::Operational))]
#[pezpallet::call_index(3)]
#[pezpallet::weight((T::WeightInfo::emergency_cancel(), DispatchClass::Operational))]
pub fn emergency_cancel(
origin: OriginFor<T>,
ref_index: ReferendumIndex,
@@ -692,8 +692,8 @@ pub mod pallet {
/// The dispatch origin of this call must be `ExternalOrigin`.
///
/// - `proposal_hash`: The preimage hash of the proposal.
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::external_propose())]
#[pezpallet::call_index(4)]
#[pezpallet::weight(T::WeightInfo::external_propose())]
pub fn external_propose(
origin: OriginFor<T>,
proposal: BoundedCallOf<T>,
@@ -702,7 +702,7 @@ pub mod pallet {
ensure!(!NextExternal::<T>::exists(), Error::<T>::DuplicateProposal);
if let Some((until, _)) = Blacklist::<T>::get(proposal.hash()) {
ensure!(
pezframe_system::Pallet::<T>::block_number() >= until,
pezframe_system::Pezpallet::<T>::block_number() >= until,
Error::<T>::ProposalBlacklisted,
);
}
@@ -721,8 +721,8 @@ pub mod pallet {
/// pre-scheduled `external_propose` call.
///
/// Weight: `O(1)`
#[pallet::call_index(5)]
#[pallet::weight(T::WeightInfo::external_propose_majority())]
#[pezpallet::call_index(5)]
#[pezpallet::weight(T::WeightInfo::external_propose_majority())]
pub fn external_propose_majority(
origin: OriginFor<T>,
proposal: BoundedCallOf<T>,
@@ -743,8 +743,8 @@ pub mod pallet {
/// pre-scheduled `external_propose` call.
///
/// Weight: `O(1)`
#[pallet::call_index(6)]
#[pallet::weight(T::WeightInfo::external_propose_default())]
#[pezpallet::call_index(6)]
#[pezpallet::weight(T::WeightInfo::external_propose_default())]
pub fn external_propose_default(
origin: OriginFor<T>,
proposal: BoundedCallOf<T>,
@@ -770,8 +770,8 @@ pub mod pallet {
/// Emits `Started`.
///
/// Weight: `O(1)`
#[pallet::call_index(7)]
#[pallet::weight(T::WeightInfo::fast_track())]
#[pezpallet::call_index(7)]
#[pezpallet::weight(T::WeightInfo::fast_track())]
pub fn fast_track(
origin: OriginFor<T>,
proposal_hash: T::Hash,
@@ -802,7 +802,7 @@ pub mod pallet {
ensure!(proposal_hash == ext_proposal.hash(), Error::<T>::InvalidHash);
NextExternal::<T>::kill();
let now = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<T>::block_number();
let ref_index = Self::inject_referendum(
now.saturating_add(voting_period),
ext_proposal,
@@ -822,8 +822,8 @@ pub mod pallet {
/// Emits `Vetoed`.
///
/// Weight: `O(V + log(V))` where V is number of `existing vetoers`
#[pallet::call_index(8)]
#[pallet::weight(T::WeightInfo::veto_external())]
#[pezpallet::call_index(8)]
#[pezpallet::weight(T::WeightInfo::veto_external())]
pub fn veto_external(origin: OriginFor<T>, proposal_hash: T::Hash) -> DispatchResult {
let who = T::VetoOrigin::ensure_origin(origin)?;
@@ -842,7 +842,7 @@ pub mod pallet {
.map_err(|_| Error::<T>::TooMany)?;
let until =
pezframe_system::Pallet::<T>::block_number().saturating_add(T::CooloffPeriod::get());
pezframe_system::Pezpallet::<T>::block_number().saturating_add(T::CooloffPeriod::get());
Blacklist::<T>::insert(&proposal_hash, (until, existing_vetoers));
Self::deposit_event(Event::<T>::Vetoed { who, proposal_hash, until });
@@ -858,11 +858,11 @@ pub mod pallet {
/// - `ref_index`: The index of the referendum to cancel.
///
/// # Weight: `O(1)`.
#[pallet::call_index(9)]
#[pallet::weight(T::WeightInfo::cancel_referendum())]
#[pezpallet::call_index(9)]
#[pezpallet::weight(T::WeightInfo::cancel_referendum())]
pub fn cancel_referendum(
origin: OriginFor<T>,
#[pallet::compact] ref_index: ReferendumIndex,
#[pezpallet::compact] ref_index: ReferendumIndex,
) -> DispatchResult {
ensure_root(origin)?;
Self::internal_cancel_referendum(ref_index);
@@ -891,8 +891,8 @@ pub mod pallet {
/// voted on. Weight is charged as if maximum votes.
// NOTE: weight must cover an incorrect voting of origin with max votes, this is ensure
// because a valid delegation cover decoding a direct voting with max votes.
#[pallet::call_index(10)]
#[pallet::weight(T::WeightInfo::delegate(T::MaxVotes::get()))]
#[pezpallet::call_index(10)]
#[pezpallet::weight(T::WeightInfo::delegate(T::MaxVotes::get()))]
pub fn delegate(
origin: OriginFor<T>,
to: AccountIdLookupOf<T>,
@@ -920,8 +920,8 @@ pub mod pallet {
/// voted on. Weight is charged as if maximum votes.
// NOTE: weight must cover an incorrect voting of origin with max votes, this is ensure
// because a valid delegation cover decoding a direct voting with max votes.
#[pallet::call_index(11)]
#[pallet::weight(T::WeightInfo::undelegate(T::MaxVotes::get()))]
#[pezpallet::call_index(11)]
#[pezpallet::weight(T::WeightInfo::undelegate(T::MaxVotes::get()))]
pub fn undelegate(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
let votes = Self::try_undelegate(who)?;
@@ -933,8 +933,8 @@ pub mod pallet {
/// The dispatch origin of this call must be _Root_.
///
/// Weight: `O(1)`.
#[pallet::call_index(12)]
#[pallet::weight(T::WeightInfo::clear_public_proposals())]
#[pezpallet::call_index(12)]
#[pezpallet::weight(T::WeightInfo::clear_public_proposals())]
pub fn clear_public_proposals(origin: OriginFor<T>) -> DispatchResult {
ensure_root(origin)?;
PublicProps::<T>::kill();
@@ -948,8 +948,8 @@ pub mod pallet {
/// - `target`: The account to remove the lock on.
///
/// Weight: `O(R)` with R number of vote of target.
#[pallet::call_index(13)]
#[pallet::weight(T::WeightInfo::unlock_set(T::MaxVotes::get()).max(T::WeightInfo::unlock_remove(T::MaxVotes::get())))]
#[pezpallet::call_index(13)]
#[pezpallet::weight(T::WeightInfo::unlock_set(T::MaxVotes::get()).max(T::WeightInfo::unlock_remove(T::MaxVotes::get())))]
pub fn unlock(origin: OriginFor<T>, target: AccountIdLookupOf<T>) -> DispatchResult {
ensure_signed(origin)?;
let target = T::Lookup::lookup(target)?;
@@ -984,8 +984,8 @@ pub mod pallet {
///
/// Weight: `O(R + log R)` where R is the number of referenda that `target` has voted on.
/// Weight is calculated for the maximum number of vote.
#[pallet::call_index(14)]
#[pallet::weight(T::WeightInfo::remove_vote(T::MaxVotes::get()))]
#[pezpallet::call_index(14)]
#[pezpallet::weight(T::WeightInfo::remove_vote(T::MaxVotes::get()))]
pub fn remove_vote(origin: OriginFor<T>, index: ReferendumIndex) -> DispatchResult {
let who = ensure_signed(origin)?;
Self::try_remove_vote(&who, index, UnvoteScope::Any)
@@ -1006,8 +1006,8 @@ pub mod pallet {
///
/// Weight: `O(R + log R)` where R is the number of referenda that `target` has voted on.
/// Weight is calculated for the maximum number of vote.
#[pallet::call_index(15)]
#[pallet::weight(T::WeightInfo::remove_other_vote(T::MaxVotes::get()))]
#[pezpallet::call_index(15)]
#[pezpallet::weight(T::WeightInfo::remove_other_vote(T::MaxVotes::get()))]
pub fn remove_other_vote(
origin: OriginFor<T>,
target: AccountIdLookupOf<T>,
@@ -1035,8 +1035,8 @@ pub mod pallet {
///
/// Weight: `O(p)` (though as this is an high-privilege dispatch, we assume it has a
/// reasonable value).
#[pallet::call_index(16)]
#[pallet::weight((T::WeightInfo::blacklist(), DispatchClass::Operational))]
#[pezpallet::call_index(16)]
#[pezpallet::weight((T::WeightInfo::blacklist(), DispatchClass::Operational))]
pub fn blacklist(
origin: OriginFor<T>,
proposal_hash: T::Hash,
@@ -1088,11 +1088,11 @@ pub mod pallet {
/// - `prop_index`: The index of the proposal to cancel.
///
/// Weight: `O(p)` where `p = PublicProps::<T>::decode_len()`
#[pallet::call_index(17)]
#[pallet::weight(T::WeightInfo::cancel_proposal())]
#[pezpallet::call_index(17)]
#[pezpallet::weight(T::WeightInfo::cancel_proposal())]
pub fn cancel_proposal(
origin: OriginFor<T>,
#[pallet::compact] prop_index: PropIndex,
#[pezpallet::compact] prop_index: PropIndex,
) -> DispatchResult {
T::CancelProposalOrigin::ensure_origin(origin)?;
@@ -1122,8 +1122,8 @@ pub mod pallet {
/// - `Root` to set a metadata for an ongoing referendum.
/// - `owner`: an identifier of a metadata owner.
/// - `maybe_hash`: The hash of an on-chain stored preimage. `None` to clear a metadata.
#[pallet::call_index(18)]
#[pallet::weight(
#[pezpallet::call_index(18)]
#[pezpallet::weight(
match (owner, maybe_hash) {
(MetadataOwner::External, Some(_)) => T::WeightInfo::set_external_metadata(),
(MetadataOwner::External, None) => T::WeightInfo::clear_external_metadata(),
@@ -1189,7 +1189,7 @@ pub trait EncodeInto: Encode {
}
impl<T: Encode> EncodeInto for T {}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
// exposed immutables.
/// Get the amount locked in support of `proposal`; `None` if proposal isn't a valid proposal
@@ -1232,8 +1232,8 @@ impl<T: Config> Pallet<T> {
threshold: VoteThreshold,
delay: BlockNumberFor<T>,
) -> ReferendumIndex {
Pallet::<T>::inject_referendum(
pezframe_system::Pallet::<T>::block_number().saturating_add(T::VotingPeriod::get()),
Pezpallet::<T>::inject_referendum(
pezframe_system::Pezpallet::<T>::block_number().saturating_add(T::VotingPeriod::get()),
proposal,
threshold,
delay,
@@ -1348,7 +1348,7 @@ impl<T: Config> Pallet<T> {
let unlock_at = end.saturating_add(
T::VoteLockingPeriod::get().saturating_mul(lock_periods.into()),
);
let now = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<T>::block_number();
if now < unlock_at {
ensure!(
matches!(scope, UnvoteScope::Any),
@@ -1441,7 +1441,7 @@ impl<T: Config> Pallet<T> {
} => {
// remove any delegation votes to our current target.
Self::reduce_upstream_delegation(&target, conviction.votes(balance));
let now = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<T>::block_number();
let lock_periods = conviction.lock_periods().into();
let unlock_block = now
.saturating_add(T::VoteLockingPeriod::get().saturating_mul(lock_periods));
@@ -1481,7 +1481,7 @@ impl<T: Config> Pallet<T> {
// remove any delegation votes to our current target.
let votes =
Self::reduce_upstream_delegation(&target, conviction.votes(balance));
let now = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<T>::block_number();
let lock_periods = conviction.lock_periods().into();
let unlock_block = now
.saturating_add(T::VoteLockingPeriod::get().saturating_mul(lock_periods));
@@ -1501,7 +1501,7 @@ impl<T: Config> Pallet<T> {
/// a security hole) but may be reduced from what they are currently.
fn update_lock(who: &T::AccountId) {
let lock_needed = VotingOf::<T>::mutate(who, |voting| {
voting.rejig(pezframe_system::Pallet::<T>::block_number());
voting.rejig(pezframe_system::Pezpallet::<T>::block_number());
voting.locked_balance()
});
if lock_needed.is_zero() {
@@ -13,10 +13,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! All migrations of this pallet.
//! All migrations of this pezpallet.
/// Migration to unlock and unreserve all pallet funds.
/// Migration to unlock and unreserve all pezpallet funds.
pub mod unlock_and_unreserve_all_funds;
/// V1 storage migrations for the preimage pallet.
/// V1 storage migrations for the preimage pezpallet.
pub mod v1;
@@ -16,7 +16,7 @@
// limitations under the License.
//! A migration that unreserves all deposit and unlocks all stake held in the context of this
//! pallet.
//! pezpallet.
use crate::{PropIndex, Voting, DEMOCRACY_ID};
use alloc::{collections::btree_map::BTreeMap, vec::Vec};
@@ -42,9 +42,9 @@ pub trait UnlockConfig: 'static {
type AccountId: Parameter + Ord;
/// The currency type used in the runtime.
///
/// Should match the currency type previously used for the pallet, if applicable.
/// Should match the currency type previously used for the pezpallet, if applicable.
type Currency: LockableCurrency<Self::AccountId> + ReservableCurrency<Self::AccountId>;
/// The name of the pallet as previously configured in
/// The name of the pezpallet as previously configured in
/// [`construct_runtime!`](pezframe_support::construct_runtime).
type PalletName: Get<&'static str>;
/// The maximum number of votes as configured previously in the runtime.
@@ -80,18 +80,18 @@ type VotingOf<T: UnlockConfig> = StorageMap<
>;
/// A migration that unreserves all deposit and unlocks all stake held in the context of this
/// pallet.
/// pezpallet.
///
/// Useful to prevent funds from being locked up when the pallet is being deprecated.
/// Useful to prevent funds from being locked up when the pezpallet is being deprecated.
///
/// The pallet should be made inoperable before this migration is run.
/// The pezpallet should be made inoperable before this migration is run.
///
/// (See also [`RemovePallet`][pezframe_support::migrations::RemovePallet])
pub struct UnlockAndUnreserveAllFunds<T: UnlockConfig>(core::marker::PhantomData<T>);
impl<T: UnlockConfig> UnlockAndUnreserveAllFunds<T> {
/// Calculates and returns the total amounts reserved by each account by this pallet, and all
/// accounts with locks in the context of this pallet.
/// Calculates and returns the total amounts reserved by each account by this pezpallet, and all
/// accounts with locks in the context of this pezpallet.
///
/// There is no need to return the amount locked, because the entire lock is removed (always
/// should be zero post-migration). We need to return the amounts reserved to check that the
@@ -102,9 +102,9 @@ impl<T: UnlockConfig> UnlockAndUnreserveAllFunds<T> {
/// This function returns a tuple of two `BTreeMap` collections and the weight of the reads:
///
/// * `BTreeMap<T::AccountId, BalanceOf<T>>`: Map of account IDs to their respective total
/// reserved balance by this pallet
/// reserved balance by this pezpallet
/// * `BTreeMap<T::AccountId, BalanceOf<T>>`: Map of account IDs to their respective total
/// locked balance by this pallet
/// locked balance by this pezpallet
/// * `pezframe_support::weights::Weight`: the weight consumed by this call.
fn get_account_deposits_and_locks() -> (
BTreeMap<T::AccountId, BalanceOf<T>>,
@@ -160,20 +160,20 @@ where
/// checks the integrity of deposited and reserved balances.
///
/// Steps:
/// 1. Gets the deposited balances for each account stored in this pallet.
/// 1. Gets the deposited balances for each account stored in this pezpallet.
/// 2. Collects actual pre-migration reserved balances for each account.
/// 3. Checks the integrity of the deposited balances.
/// 4. Prints summary statistics about the state to be migrated.
/// 5. Encodes and returns pre-migration data to be used in post_upgrade.
///
/// Fails with a `TryRuntimeError` if somehow the amount reserved by this pallet is greater than
/// Fails with a `TryRuntimeError` if somehow the amount reserved by this pezpallet is greater than
/// the actual total reserved amount for any accounts.
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, pezsp_runtime::TryRuntimeError> {
use alloc::collections::btree_set::BTreeSet;
use codec::Encode;
// Get staked and deposited balances as reported by this pallet.
// Get staked and deposited balances as reported by this pezpallet.
let (account_deposits, account_locks, _) = Self::get_account_deposits_and_locks();
let all_accounts = account_deposits
@@ -187,7 +187,7 @@ where
.collect();
// Total deposited for each account *should* be less than or equal to the total reserved,
// however this does not hold for all cases due to bugs in the reserve logic of this pallet.
// however this does not hold for all cases due to bugs in the reserve logic of this pezpallet.
let bugged_deposits = all_accounts
.iter()
.filter(|account| {
@@ -220,11 +220,11 @@ where
/// Executes the migration.
///
/// Steps:
/// 1. Retrieves the deposit and accounts with locks for the pallet.
/// 1. Retrieves the deposit and accounts with locks for the pezpallet.
/// 2. Unreserves the deposited funds for each account.
/// 3. Unlocks the staked funds for each account.
fn on_runtime_upgrade() -> pezframe_support::weights::Weight {
// Get staked and deposited balances as reported by this pallet.
// Get staked and deposited balances as reported by this pezpallet.
let (account_deposits, account_stakes, initial_reads) =
Self::get_account_deposits_and_locks();
@@ -252,7 +252,7 @@ where
/// Performs post-upgrade sanity checks:
///
/// 1. No locks remain for this pallet in Balances.
/// 1. No locks remain for this pezpallet in Balances.
/// 2. The reserved balance for each account has been reduced by the expected amount.
#[cfg(feature = "try-runtime")]
fn post_upgrade(
@@ -264,7 +264,7 @@ where
BTreeMap::<T::AccountId, BalanceOf<T>>::decode(&mut &account_reserved_before_bytes[..])
.map_err(|_| "Failed to decode account_reserved_before_bytes")?;
// Get staked and deposited balances as reported by this pallet.
// Get staked and deposited balances as reported by this pezpallet.
let (account_deposits, _, _) = Self::get_account_deposits_and_locks();
// Check that the reserved balance is reduced by the expected deposited amount.
@@ -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 crate::*;
use pezframe_support::{pezpallet_prelude::*, storage_alias, traits::OnRuntimeUpgrade, BoundedVec};
@@ -25,25 +25,25 @@ use pezsp_core::H256;
/// The log target.
const TARGET: &'static str = "runtime::democracy::migration::v1";
/// The original data layout of the democracy pallet without a specific version number.
/// The original data layout of the democracy pezpallet without a specific version number.
mod v0 {
use super::*;
#[storage_alias]
pub type PublicProps<T: Config> = StorageValue<
Pallet<T>,
Pezpallet<T>,
Vec<(PropIndex, <T as pezframe_system::Config>::Hash, <T as pezframe_system::Config>::AccountId)>,
ValueQuery,
>;
#[storage_alias]
pub type NextExternal<T: Config> =
StorageValue<Pallet<T>, (<T as pezframe_system::Config>::Hash, VoteThreshold)>;
StorageValue<Pezpallet<T>, (<T as pezframe_system::Config>::Hash, VoteThreshold)>;
#[cfg(feature = "try-runtime")]
#[storage_alias]
pub type ReferendumInfoOf<T: Config> = StorageMap<
Pallet<T>,
Pezpallet<T>,
pezframe_support::Twox64Concat,
ReferendumIndex,
ReferendumInfo<BlockNumberFor<T>, <T as pezframe_system::Config>::Hash, BalanceOf<T>>,
@@ -59,7 +59,7 @@ pub mod v1 {
impl<T: Config + pezframe_system::Config<Hash = H256>> OnRuntimeUpgrade for Migration<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, pezsp_runtime::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 props_count = v0::PublicProps::<T>::get().len();
log::info!(target: TARGET, "{} public proposals will be migrated.", props_count,);
@@ -74,7 +74,7 @@ pub mod v1 {
#[allow(deprecated)]
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 on_runtime_upgrade: executed on wrong storage version.\
@@ -124,14 +124,14 @@ pub mod v1 {
NextExternal::<T>::put((Bounded::from_legacy_hash(hash), threshold));
}
StorageVersion::new(1).put::<Pallet<T>>();
StorageVersion::new(1).put::<Pezpallet<T>>();
weight.saturating_add(T::DbWeight::get().reads_writes(1, 3))
}
#[cfg(feature = "try-runtime")]
fn post_upgrade(state: Vec<u8>) -> Result<(), pezsp_runtime::TryRuntimeError> {
ensure!(StorageVersion::get::<Pallet<T>>() == 1, "must upgrade");
ensure!(StorageVersion::get::<Pezpallet<T>>() == 1, "must upgrade");
let (old_props_count, old_ref_count): (u32, u32) =
Decode::decode(&mut &state[..]).expect("pre_upgrade provides a valid state; qed");
@@ -165,7 +165,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 values into the v0 storage:
// Case 1: Ongoing referendum
+2 -2
View File
@@ -106,7 +106,7 @@ impl pezpallet_scheduler::Config for Test {
type WeightInfo = ();
type OriginPrivilegeCmp = EqualPrivilegeOnly;
type Preimages = ();
type BlockNumberProvider = pezframe_system::Pallet<Test>;
type BlockNumberProvider = pezframe_system::Pezpallet<Test>;
}
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
@@ -136,7 +136,7 @@ impl SortedMembers<u64> for OneToFive {
impl Config for Test {
type RuntimeEvent = RuntimeEvent;
type Currency = pezpallet_balances::Pallet<Self>;
type Currency = pezpallet_balances::Pezpallet<Self>;
type EnactmentPeriod = ConstU64<2>;
type LaunchPeriod = ConstU64<2>;
type VotingPeriod = ConstU64<2>;
+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_democracy
// --pezpallet=pezpallet_democracy
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/democracy/src/weights.rs
// --wasm-execution=compiled