chore: regenerate umbrella crate, fix feature propagation
This commit is contained in:
@@ -24,7 +24,9 @@ use pezsp_runtime::traits::{Bounded, Hash, StaticLookup};
|
||||
|
||||
use pezframe_benchmarking::{account, v2::*, BenchmarkError};
|
||||
use pezframe_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable};
|
||||
use pezframe_system::{pezpallet_prelude::BlockNumberFor, Pezpallet as System, RawOrigin as SystemOrigin};
|
||||
use pezframe_system::{
|
||||
pezpallet_prelude::BlockNumberFor, Pezpallet as System, RawOrigin as SystemOrigin,
|
||||
};
|
||||
|
||||
use super::{Call as AllianceCall, Pezpallet as Alliance, *};
|
||||
|
||||
|
||||
@@ -163,7 +163,8 @@ impl<AccountId> IdentityVerifier<AccountId> for () {
|
||||
}
|
||||
}
|
||||
|
||||
/// The provider of a collective action interface, for example an instance of `pezpallet-collective`.
|
||||
/// The provider of a collective action interface, for example an instance of
|
||||
/// `pezpallet-collective`.
|
||||
pub trait ProposalProvider<AccountId, Hash, Proposal> {
|
||||
/// Add a new proposal.
|
||||
/// Returns a proposal length and active proposals count if successful.
|
||||
@@ -430,7 +431,10 @@ pub mod pezpallet {
|
||||
impl<T: Config<I>, I: 'static> BuildGenesisConfig for GenesisConfig<T, I> {
|
||||
fn build(&self) {
|
||||
for m in self.fellows.iter().chain(self.allies.iter()) {
|
||||
assert!(Pezpallet::<T, I>::has_identity(m).is_ok(), "Member does not set identity!");
|
||||
assert!(
|
||||
Pezpallet::<T, I>::has_identity(m).is_ok(),
|
||||
"Member does not set identity!"
|
||||
);
|
||||
}
|
||||
|
||||
if !self.fellows.is_empty() {
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{Config, Pezpallet, Weight, LOG_TARGET};
|
||||
use pezframe_support::{pezpallet_prelude::*, storage::migration, traits::OnRuntimeUpgrade};
|
||||
use log;
|
||||
use pezframe_support::{pezpallet_prelude::*, storage::migration, traits::OnRuntimeUpgrade};
|
||||
|
||||
/// The in-code storage version.
|
||||
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
|
||||
use pezframe_support::{traits::ConstU32, BoundedVec};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::RuntimeDebug;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
/// A Multihash instance that only supports the basic functionality and no hashing.
|
||||
#[derive(
|
||||
|
||||
@@ -74,7 +74,8 @@ pub mod pezpallet {
|
||||
{
|
||||
/// Overarching event type.
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// Type previously used to derive the account ID for a pool. Indicates that the pool's
|
||||
/// liquidity assets are located at this account before the migration.
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
//! - [create a liquidity pool](`Pezpallet::create_pool()`) for 2 assets
|
||||
//! - [provide the liquidity](`Pezpallet::add_liquidity()`) and receive back an LP token
|
||||
//! - [exchange the LP token back to assets](`Pezpallet::remove_liquidity()`)
|
||||
//! - [swap a specific amount of assets for another](`Pezpallet::swap_exact_tokens_for_tokens()`) if
|
||||
//! there is a pool created, or
|
||||
//! - [swap a specific amount of assets for another](`Pezpallet::swap_exact_tokens_for_tokens()`)
|
||||
//! if there is a pool created, or
|
||||
//! - [swap some assets for a specific amount of
|
||||
//! another](`Pezpallet::swap_tokens_for_exact_tokens()`).
|
||||
//! - [query for an exchange price](`AssetConversionApi::quote_price_exact_tokens_for_tokens`) via
|
||||
@@ -112,7 +112,8 @@ pub mod pezpallet {
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// Overarching event type.
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// The type in which the assets for swapping are measured.
|
||||
type Balance: Balance;
|
||||
@@ -149,8 +150,8 @@ pub mod pezpallet {
|
||||
/// Asset class for the lp tokens from [`Self::PoolAssets`].
|
||||
type PoolAssetId: AssetId + PartialOrd + Incrementable + From<u32>;
|
||||
|
||||
/// Registry for the lp tokens. Ideally only this pezpallet should have create permissions on
|
||||
/// the assets.
|
||||
/// Registry for the lp tokens. Ideally only this pezpallet should have create permissions
|
||||
/// on the assets.
|
||||
type PoolAssets: Inspect<Self::AccountId, AssetId = Self::PoolAssetId, Balance = Self::Balance>
|
||||
+ Create<Self::AccountId>
|
||||
+ Mutate<Self::AccountId>
|
||||
@@ -387,8 +388,9 @@ pub mod pezpallet {
|
||||
///
|
||||
/// NOTE: when encountering an incorrect exchange rate and non-withdrawable pool liquidity,
|
||||
/// batch an atomic call with [`Pezpallet::add_liquidity`] and
|
||||
/// [`Pezpallet::swap_exact_tokens_for_tokens`] or [`Pezpallet::swap_tokens_for_exact_tokens`]
|
||||
/// calls to render the liquidity withdrawable and rectify the exchange rate.
|
||||
/// [`Pezpallet::swap_exact_tokens_for_tokens`] or
|
||||
/// [`Pezpallet::swap_tokens_for_exact_tokens`] calls to render the liquidity withdrawable
|
||||
/// and rectify the exchange rate.
|
||||
///
|
||||
/// Once liquidity is added, someone may successfully call
|
||||
/// [`Pezpallet::swap_exact_tokens_for_tokens`].
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
use super::*;
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
use core::marker::PhantomData;
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::traits::TryConvert;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
/// Represents a swap path with associated asset amounts indicating how much of the asset needs to
|
||||
/// be deposited to get the following asset's amount withdrawn (this is inclusive of fees).
|
||||
|
||||
@@ -107,7 +107,8 @@ pub mod pezpallet {
|
||||
|
||||
/// The runtime event type.
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// The origin permissioned to create a conversion rate for an asset.
|
||||
type CreateOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
@@ -57,5 +57,8 @@ impl pezpallet_asset_rate::Config for Test {
|
||||
|
||||
// Build genesis storage according to the mock runtime.
|
||||
pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
|
||||
pezframe_system::GenesisConfig::<Test>::default()
|
||||
.build_storage()
|
||||
.unwrap()
|
||||
.into()
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
use super::*;
|
||||
use crate::pezpallet as pezpallet_asset_rate;
|
||||
use pezframe_support::{assert_noop, assert_ok};
|
||||
use mock::{new_test_ext, AssetRate, RuntimeOrigin, Test};
|
||||
use pezframe_support::{assert_noop, assert_ok};
|
||||
use pezsp_runtime::FixedU128;
|
||||
|
||||
const ASSET_ID: u32 = 42;
|
||||
|
||||
@@ -93,13 +93,13 @@ use pezframe_support::{
|
||||
},
|
||||
PalletId,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_core::Get;
|
||||
use pezsp_runtime::{
|
||||
traits::{BadOrigin, BlockNumberProvider, EnsureAdd, MaybeDisplay, Zero},
|
||||
DispatchError, DispatchResult,
|
||||
};
|
||||
use pezsp_std::boxed::Box;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub mod benchmarking;
|
||||
@@ -221,7 +221,8 @@ pub mod pezpallet {
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// Overarching event type.
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// The pezpallet's unique identifier, used to derive the pool's account ID.
|
||||
///
|
||||
@@ -271,10 +272,10 @@ pub mod pezpallet {
|
||||
/// This provider is used to determine the current block number for the pezpallet.
|
||||
/// It must return monotonically increasing values when called from consecutive blocks.
|
||||
///
|
||||
/// It can be configured to use the local block number (via `pezframe_system::Pezpallet`) or a
|
||||
/// remote block number (e.g., from a relay chain). However, note that using a remote
|
||||
/// block number might have implications for the behavior of the pezpallet, especially if the
|
||||
/// remote block number advances faster than the local block number.
|
||||
/// It can be configured to use the local block number (via `pezframe_system::Pezpallet`) or
|
||||
/// a remote block number (e.g., from a relay chain). However, note that using a remote
|
||||
/// block number might have implications for the behavior of the pezpallet, especially if
|
||||
/// the remote block number advances faster than the local block number.
|
||||
///
|
||||
/// It is recommended to use the local block number for solo chains and relay chains.
|
||||
type BlockNumberProvider: BlockNumberProvider;
|
||||
|
||||
@@ -174,7 +174,9 @@ impl Config for MockRuntime {
|
||||
}
|
||||
|
||||
pub(crate) fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
let mut t = pezframe_system::GenesisConfig::<MockRuntime>::default().build_storage().unwrap();
|
||||
let mut t = pezframe_system::GenesisConfig::<MockRuntime>::default()
|
||||
.build_storage()
|
||||
.unwrap();
|
||||
|
||||
pezpallet_assets::GenesisConfig::<MockRuntime, Instance1> {
|
||||
// Genesis assets: id, owner, is_sufficient, min_balance
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
//!
|
||||
//! This pezpallet provides the following functionality:
|
||||
//!
|
||||
//! - Pezpallet hooks allowing [`pezpallet-assets`] to know the frozen balance for an account on a given
|
||||
//! asset (see [`pezpallet_assets::FrozenBalance`]).
|
||||
//! - Pezpallet hooks allowing [`pezpallet-assets`] to know the frozen balance for an account on a
|
||||
//! given asset (see [`pezpallet_assets::FrozenBalance`]).
|
||||
//! - An implementation of [`fungibles::freeze::Inspect`](InspectFreeze) and
|
||||
//! [`fungibles::freeze::Mutate`](MutateFreeze), allowing other pallets to manage freezes for the
|
||||
//! `pezpallet-assets` assets.
|
||||
@@ -74,7 +74,9 @@ pub mod pezpallet {
|
||||
use super::*;
|
||||
|
||||
#[pezpallet::config(with_default)]
|
||||
pub trait Config<I: 'static = ()>: pezframe_system::Config + pezpallet_assets::Config<I> {
|
||||
pub trait Config<I: 'static = ()>:
|
||||
pezframe_system::Config + pezpallet_assets::Config<I>
|
||||
{
|
||||
/// The overarching freeze reason.
|
||||
#[pezpallet::no_default_bounds]
|
||||
type RuntimeFreezeReason: Parameter + Member + MaxEncodedLen + Copy + VariantCount;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
//! # Assets Holder Pezpallet
|
||||
//!
|
||||
//! A pezpallet capable of holding fungibles from `pezpallet-assets`. This is an extension of
|
||||
//! `pezpallet-assets`, wrapping [`fungibles::Inspect`](`pezframe_support::traits::fungibles::Inspect`).
|
||||
//! It implements both
|
||||
//! `pezpallet-assets`, wrapping
|
||||
//! [`fungibles::Inspect`](`pezframe_support::traits::fungibles::Inspect`). It implements both
|
||||
//! [`fungibles::hold::Inspect`](pezframe_support::traits::fungibles::hold::Inspect),
|
||||
//! [`fungibles::hold::Mutate`](pezframe_support::traits::fungibles::hold::Mutate), and especially
|
||||
//! [`fungibles::hold::Unbalanced`](pezframe_support::traits::fungibles::hold::Unbalanced). The
|
||||
@@ -34,13 +34,13 @@
|
||||
//!
|
||||
//! This pezpallet provides the following functionality:
|
||||
//!
|
||||
//! - Pezpallet hooks allowing [`pezpallet-assets`] to know the balance on hold for an account on a given
|
||||
//! asset (see [`pezpallet_assets::BalanceOnHold`]).
|
||||
//! - Pezpallet hooks allowing [`pezpallet-assets`] to know the balance on hold for an account on a
|
||||
//! given asset (see [`pezpallet_assets::BalanceOnHold`]).
|
||||
//! - An implementation of
|
||||
//! [`fungibles::hold::Inspect`](pezframe_support::traits::fungibles::hold::Inspect),
|
||||
//! [`fungibles::hold::Mutate`](pezframe_support::traits::fungibles::hold::Mutate) and
|
||||
//! [`fungibles::hold::Unbalanced`](pezframe_support::traits::fungibles::hold::Unbalanced), allowing
|
||||
//! other pallets to manage holds for the `pezpallet-assets` assets.
|
||||
//! [`fungibles::hold::Unbalanced`](pezframe_support::traits::fungibles::hold::Unbalanced),
|
||||
//! allowing other pallets to manage holds for the `pezpallet-assets` assets.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ use crate as pezpallet_assets_holder;
|
||||
pub use crate::*;
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
use pezframe_support::{derive_impl, traits::AsEnsureOriginWithArg};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::BuildStorage;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
pub type AccountId = <Test as pezframe_system::Config>::AccountId;
|
||||
pub type Balance = <Test as pezpallet_balances::Config>::Balance;
|
||||
|
||||
@@ -218,8 +218,9 @@ where
|
||||
use pezframe_support::traits::fungibles::Inspect;
|
||||
env.charge(<Runtime as Config<Instance>>::WeightInfo::total_issuance())?;
|
||||
|
||||
let value =
|
||||
Self::to_u256(pezpallet_assets::Pezpallet::<Runtime, Instance>::total_issuance(asset_id))?;
|
||||
let value = Self::to_u256(
|
||||
pezpallet_assets::Pezpallet::<Runtime, Instance>::total_issuance(asset_id),
|
||||
)?;
|
||||
return Ok(IERC20::totalSupplyCall::abi_encode_returns(&value));
|
||||
}
|
||||
|
||||
@@ -232,8 +233,9 @@ where
|
||||
env.charge(<Runtime as Config<Instance>>::WeightInfo::balance())?;
|
||||
let account = call.account.into_array().into();
|
||||
let account = <Runtime as pezpallet_revive::Config>::AddressMapper::to_account_id(&account);
|
||||
let value =
|
||||
Self::to_u256(pezpallet_assets::Pezpallet::<Runtime, Instance>::balance(asset_id, account))?;
|
||||
let value = Self::to_u256(pezpallet_assets::Pezpallet::<Runtime, Instance>::balance(
|
||||
asset_id, account,
|
||||
))?;
|
||||
return Ok(IERC20::balanceOfCall::abi_encode_returns(&value));
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,8 @@ fn balance_of_works() {
|
||||
assert_ok!(Assets::force_create(RuntimeOrigin::root(), asset_id, owner, true, 1));
|
||||
assert_ok!(Assets::mint(RuntimeOrigin::signed(owner), asset_id, owner, 1000));
|
||||
|
||||
let account = <Test as pezpallet_revive::Config>::AddressMapper::to_address(&owner).0.into();
|
||||
let account =
|
||||
<Test as pezpallet_revive::Config>::AddressMapper::to_address(&owner).0.into();
|
||||
let data = IERC20::balanceOfCall { account }.abi_encode();
|
||||
|
||||
let data = pezpallet_revive::Pezpallet::<Test>::bare_call(
|
||||
|
||||
@@ -21,9 +21,9 @@ use super::*;
|
||||
|
||||
/// A mutator type allowing inspection and possible modification of the extra "sidecar" data.
|
||||
///
|
||||
/// This may be used as a `Deref` for the pezpallet's extra data. If mutated (using `DerefMut`), then
|
||||
/// any uncommitted changes (see `commit` function) will be automatically committed to storage when
|
||||
/// dropped. Changes, even after committed, may be reverted to their original values with the
|
||||
/// This may be used as a `Deref` for the pezpallet's extra data. If mutated (using `DerefMut`),
|
||||
/// then any uncommitted changes (see `commit` function) will be automatically committed to storage
|
||||
/// when dropped. Changes, even after committed, may be reverted to their original values with the
|
||||
/// `revert` function.
|
||||
pub struct ExtraMutator<T: Config<I>, I: 'static = ()> {
|
||||
id: T::AssetId,
|
||||
|
||||
@@ -160,7 +160,9 @@ impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
|
||||
if amount < details.min_balance {
|
||||
return DepositConsequence::BelowMinimum;
|
||||
}
|
||||
if !details.is_sufficient && !pezframe_system::Pezpallet::<T>::can_accrue_consumers(who, 2) {
|
||||
if !details.is_sufficient &&
|
||||
!pezframe_system::Pezpallet::<T>::can_accrue_consumers(who, 2)
|
||||
{
|
||||
return DepositConsequence::CannotCreate;
|
||||
}
|
||||
if details.is_sufficient && details.sufficients.checked_add(1).is_none() {
|
||||
|
||||
@@ -30,7 +30,9 @@ use pezframe_support::{
|
||||
|
||||
use super::*;
|
||||
|
||||
impl<T: Config<I>, I: 'static> fungibles::Inspect<<T as SystemConfig>::AccountId> for Pezpallet<T, I> {
|
||||
impl<T: Config<I>, I: 'static> fungibles::Inspect<<T as SystemConfig>::AccountId>
|
||||
for Pezpallet<T, I>
|
||||
{
|
||||
type AssetId = T::AssetId;
|
||||
type Balance = T::Balance;
|
||||
|
||||
@@ -83,7 +85,9 @@ impl<T: Config<I>, I: 'static> fungibles::Inspect<<T as SystemConfig>::AccountId
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config<I>, I: 'static> fungibles::Mutate<<T as SystemConfig>::AccountId> for Pezpallet<T, I> {
|
||||
impl<T: Config<I>, I: 'static> fungibles::Mutate<<T as SystemConfig>::AccountId>
|
||||
for Pezpallet<T, I>
|
||||
{
|
||||
fn done_mint_into(
|
||||
asset_id: Self::AssetId,
|
||||
beneficiary: &<T as SystemConfig>::AccountId,
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
//! [`fungible`](pezframe_support::traits::fungible) traits, via [`fungibles`] traits.
|
||||
//!
|
||||
//! The pezpallet makes heavy use of concepts such as Holds and Freezes from the
|
||||
//! [`pezframe_support::traits::fungible`] traits, therefore you should read and understand those docs
|
||||
//! as a prerequisite to understanding this pezpallet.
|
||||
//! [`pezframe_support::traits::fungible`] traits, therefore you should read and understand those
|
||||
//! docs as a prerequisite to understanding this pezpallet.
|
||||
//!
|
||||
//! See the [`frame_tokens`] reference docs for more information about the place of the
|
||||
//! Assets pezpallet in FRAME.
|
||||
@@ -171,11 +171,11 @@ pub use types::*;
|
||||
extern crate alloc;
|
||||
extern crate core;
|
||||
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::{
|
||||
traits::{AtLeast32BitUnsigned, CheckedAdd, CheckedSub, Saturating, StaticLookup, Zero},
|
||||
ArithmeticError, DispatchError, TokenError,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::{fmt::Debug, marker::PhantomData};
|
||||
@@ -1951,7 +1951,9 @@ pub mod pezpallet {
|
||||
|
||||
/// Implements [`ProvideAssetReserves`] trait for getting the list of trusted reserves for a
|
||||
/// given asset.
|
||||
impl<T: Config<I>, I: 'static> ProvideAssetReserves<T::AssetId, T::ReserveData> for Pezpallet<T, I> {
|
||||
impl<T: Config<I>, I: 'static> ProvideAssetReserves<T::AssetId, T::ReserveData>
|
||||
for Pezpallet<T, I>
|
||||
{
|
||||
/// Provide the configured reserves for asset `id`.
|
||||
fn reserves(id: &T::AssetId) -> Vec<T::ReserveData> {
|
||||
Reserves::<T, I>::get(id).into_inner()
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
// limitations under the License.
|
||||
|
||||
use super::*;
|
||||
use pezframe_support::traits::OnRuntimeUpgrade;
|
||||
use log;
|
||||
use pezframe_support::traits::OnRuntimeUpgrade;
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
use pezsp_runtime::TryRuntimeError;
|
||||
|
||||
@@ -182,7 +182,8 @@ pub mod pezpallet {
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// The overarching event type.
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
/// Swap action.
|
||||
type SwapAction: SwapAction<Self::AccountId, Self> + Parameter + MaxEncodedLen;
|
||||
/// Limit of proof size.
|
||||
|
||||
@@ -42,11 +42,11 @@ extern crate alloc;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
use log;
|
||||
use pezframe_support::{
|
||||
traits::{DisabledValidators, FindAuthor, Get, OnTimestampSet, OneSessionHandler},
|
||||
BoundedSlice, BoundedVec, ConsensusEngineId, Parameter,
|
||||
};
|
||||
use log;
|
||||
use pezsp_consensus_aura::{AuthorityIndex, ConsensusLog, Slot, AURA_ENGINE_ID};
|
||||
use pezsp_runtime::{
|
||||
generic::DigestItem,
|
||||
@@ -101,15 +101,15 @@ pub mod pezpallet {
|
||||
/// Whether to allow block authors to create multiple blocks per slot.
|
||||
///
|
||||
/// If this is `true`, the pezpallet will allow slots to stay the same across sequential
|
||||
/// blocks. If this is `false`, the pezpallet will require that subsequent blocks always have
|
||||
/// higher slots than previous ones.
|
||||
/// blocks. If this is `false`, the pezpallet will require that subsequent blocks always
|
||||
/// have higher slots than previous ones.
|
||||
///
|
||||
/// Regardless of the setting of this storage value, the pezpallet will always enforce the
|
||||
/// invariant that slots don't move backwards as the chain progresses.
|
||||
///
|
||||
/// The typical value for this should be 'false' unless this pezpallet is being augmented by
|
||||
/// another pezpallet which enforces some limitation on the number of blocks authors can create
|
||||
/// using the same slot.
|
||||
/// another pezpallet which enforces some limitation on the number of blocks authors can
|
||||
/// create using the same slot.
|
||||
type AllowMultipleBlocksPerSlot: Get<bool>;
|
||||
|
||||
/// The slot duration Aura should run with, expressed in milliseconds.
|
||||
|
||||
@@ -256,8 +256,8 @@ mod tests {
|
||||
#[test]
|
||||
fn authorities_returns_current_and_next_authority_set() {
|
||||
// The whole authority discovery pezpallet ignores account ids, but we still need them for
|
||||
// `pezpallet_session::OneSessionHandler::on_new_session`, thus its safe to use the same value
|
||||
// everywhere.
|
||||
// `pezpallet_session::OneSessionHandler::on_new_session`, thus its safe to use the same
|
||||
// value everywhere.
|
||||
let account_id = AuthorityPair::from_seed_slice(vec![10; 32].as_ref()).unwrap().public();
|
||||
|
||||
let mut first_authorities: Vec<AuthorityId> = vec![0, 1]
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
//! definition.
|
||||
|
||||
use alloc::{boxed::Box, vec, vec::Vec};
|
||||
use log::{error, info};
|
||||
use pezframe_support::traits::{Get, KeyOwnerProofSystem};
|
||||
use pezframe_system::pezpallet_prelude::HeaderFor;
|
||||
use log::{error, info};
|
||||
|
||||
use pezsp_consensus_babe::{AuthorityId, EquivocationProof, Slot, KEY_TYPE};
|
||||
use pezsp_runtime::{
|
||||
|
||||
@@ -279,7 +279,11 @@ pub fn make_secondary_vrf_pre_digest(
|
||||
vrf_signature: VrfSignature,
|
||||
) -> Digest {
|
||||
let digest_data = pezsp_consensus_babe::digests::PreDigest::SecondaryVRF(
|
||||
pezsp_consensus_babe::digests::SecondaryVRFPreDigest { authority_index, slot, vrf_signature },
|
||||
pezsp_consensus_babe::digests::SecondaryVRFPreDigest {
|
||||
authority_index,
|
||||
slot,
|
||||
vrf_signature,
|
||||
},
|
||||
);
|
||||
let log = DigestItem::PreRuntime(pezsp_consensus_babe::BABE_ENGINE_ID, digest_data.encode());
|
||||
Digest { logs: vec![log] }
|
||||
@@ -289,11 +293,15 @@ pub fn make_vrf_signature_and_randomness(
|
||||
slot: Slot,
|
||||
pair: &pezsp_consensus_babe::AuthorityPair,
|
||||
) -> (VrfSignature, Randomness) {
|
||||
let transcript =
|
||||
pezsp_consensus_babe::make_vrf_transcript(&pezpallet_babe::Randomness::<Test>::get(), slot, 0);
|
||||
let transcript = pezsp_consensus_babe::make_vrf_transcript(
|
||||
&pezpallet_babe::Randomness::<Test>::get(),
|
||||
slot,
|
||||
0,
|
||||
);
|
||||
|
||||
let randomness =
|
||||
pair.as_ref().make_bytes(pezsp_consensus_babe::RANDOMNESS_VRF_CONTEXT, &transcript);
|
||||
let randomness = pair
|
||||
.as_ref()
|
||||
.make_bytes(pezsp_consensus_babe::RANDOMNESS_VRF_CONTEXT, &transcript);
|
||||
|
||||
let signature = pair.as_ref().vrf_sign(&transcript.into());
|
||||
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
//! Consensus extension module tests for BABE consensus.
|
||||
|
||||
use super::{Call, *};
|
||||
use mock::*;
|
||||
use pezframe_support::{
|
||||
assert_err, assert_noop, assert_ok,
|
||||
dispatch::{GetDispatchInfo, Pays},
|
||||
traits::{Currency, EstimateNextSessionRotation, KeyOwnerProofSystem, OnFinalize},
|
||||
};
|
||||
use mock::*;
|
||||
use pezpallet_session::ShouldEndSession;
|
||||
use pezsp_consensus_babe::{
|
||||
AllowedSlots, BabeEpochConfiguration, Slot, VrfSignature, RANDOMNESS_LENGTH,
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
//! More information about `honggfuzz` can be found
|
||||
//! [here](https://docs.rs/honggfuzz/).
|
||||
|
||||
use pezframe_election_provider_support::{SortedListProvider, VoteWeight};
|
||||
use honggfuzz::fuzz;
|
||||
use pezframe_election_provider_support::{SortedListProvider, VoteWeight};
|
||||
use pezpallet_bags_list::mock::{AccountId, BagsList, ExtBuilder};
|
||||
|
||||
const ID_RANGE: AccountId = 25_000;
|
||||
|
||||
@@ -63,7 +63,8 @@ pub fn display_and_check_bags<Runtime: RuntimeT<Instance1>>(
|
||||
let mut seen_in_bags = 0;
|
||||
let mut rebaggable = 0;
|
||||
let mut active_bags = 0;
|
||||
for vote_weight_thresh in <Runtime as pezpallet_bags_list::Config<Instance1>>::BagThresholds::get()
|
||||
for vote_weight_thresh in
|
||||
<Runtime as pezpallet_bags_list::Config<Instance1>>::BagThresholds::get()
|
||||
{
|
||||
let vote_weight_thresh_u64: u64 = (*vote_weight_thresh)
|
||||
.try_into()
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
use crate::{RuntimeT, LOG_TARGET};
|
||||
use pezframe_support::traits::PalletInfoAccess;
|
||||
use pezpallet_staking::Nominators;
|
||||
use remote_externalities::{Builder, Mode, OnlineConfig};
|
||||
use pezsp_runtime::{traits::Block as BlockT, DeserializeOwned};
|
||||
use remote_externalities::{Builder, Mode, OnlineConfig};
|
||||
|
||||
/// Test voter bags migration. `currency_unit` is the number of planks per the the runtimes `UNITS`
|
||||
/// (i.e. number of decimal places per HEZ, KSM etc)
|
||||
@@ -56,7 +56,8 @@ pub async fn execute<Runtime, Block>(
|
||||
);
|
||||
log::info!(target: LOG_TARGET, "Moved {} nominators", moved);
|
||||
|
||||
let voter_list_len = <Runtime as pezpallet_staking::Config>::VoterList::iter().count() as u32;
|
||||
let voter_list_len =
|
||||
<Runtime as pezpallet_staking::Config>::VoterList::iter().count() as u32;
|
||||
let voter_list_count = <Runtime as pezpallet_staking::Config>::VoterList::count();
|
||||
// and confirm it is equal to the length of the `VoterList`.
|
||||
assert_eq!(pre_migrate_nominator_count, voter_list_len);
|
||||
|
||||
@@ -21,11 +21,11 @@ use pezframe_election_provider_support::{
|
||||
SortedListProvider,
|
||||
};
|
||||
use pezframe_support::traits::PalletInfoAccess;
|
||||
use remote_externalities::{Builder, Mode, OnlineConfig};
|
||||
use pezsp_runtime::{
|
||||
traits::{Block as BlockT, Zero},
|
||||
DeserializeOwned,
|
||||
};
|
||||
use remote_externalities::{Builder, Mode, OnlineConfig};
|
||||
|
||||
/// Execute create a snapshot from pezpallet-staking.
|
||||
pub async fn execute<Runtime, Block>(voter_limit: Option<usize>, currency_unit: u64, ws_url: String)
|
||||
@@ -39,10 +39,12 @@ where
|
||||
let mut ext = Builder::<Block>::new()
|
||||
.mode(Mode::Online(OnlineConfig {
|
||||
transport: ws_url.to_string().into(),
|
||||
// NOTE: we don't scrape pezpallet-staking, this kinda ensures that the source of the data
|
||||
// is bags-list.
|
||||
pallets: vec![pezpallet_bags_list::Pezpallet::<Runtime, pezpallet_bags_list::Instance1>::name()
|
||||
.to_string()],
|
||||
// NOTE: we don't scrape pezpallet-staking, this kinda ensures that the source of the
|
||||
// data is bags-list.
|
||||
pallets: vec![
|
||||
pezpallet_bags_list::Pezpallet::<Runtime, pezpallet_bags_list::Instance1>::name()
|
||||
.to_string(),
|
||||
],
|
||||
at: None,
|
||||
hashed_prefixes: vec![
|
||||
<pezpallet_staking::Bonded<Runtime>>::prefix_hash().to_vec(),
|
||||
|
||||
@@ -20,8 +20,8 @@ use pezframe_support::{
|
||||
storage::generator::StorageMap,
|
||||
traits::{Get, PalletInfoAccess},
|
||||
};
|
||||
use remote_externalities::{Builder, Mode, OnlineConfig};
|
||||
use pezsp_runtime::{traits::Block as BlockT, DeserializeOwned};
|
||||
use remote_externalities::{Builder, Mode, OnlineConfig};
|
||||
|
||||
/// Execute the sanity check of the bags-list.
|
||||
pub async fn execute<Runtime, Block>(
|
||||
@@ -36,8 +36,10 @@ pub async fn execute<Runtime, Block>(
|
||||
let mut ext = Builder::<Block>::new()
|
||||
.mode(Mode::Online(OnlineConfig {
|
||||
transport: ws_url.to_string().into(),
|
||||
pallets: vec![pezpallet_bags_list::Pezpallet::<Runtime, pezpallet_bags_list::Instance1>::name()
|
||||
.to_string()],
|
||||
pallets: vec![
|
||||
pezpallet_bags_list::Pezpallet::<Runtime, pezpallet_bags_list::Instance1>::name()
|
||||
.to_string(),
|
||||
],
|
||||
hashed_prefixes: vec![
|
||||
<pezpallet_staking::Bonded<Runtime>>::prefix_hash().to_vec(),
|
||||
<pezpallet_staking::Ledger<Runtime>>::prefix_hash().to_vec(),
|
||||
@@ -49,9 +51,12 @@ pub async fn execute<Runtime, Block>(
|
||||
.unwrap();
|
||||
|
||||
ext.execute_with(|| {
|
||||
pezsp_core::crypto::set_default_ss58_version(Runtime::SS58Prefix::get().try_into().unwrap());
|
||||
pezsp_core::crypto::set_default_ss58_version(
|
||||
Runtime::SS58Prefix::get().try_into().unwrap(),
|
||||
);
|
||||
|
||||
pezpallet_bags_list::Pezpallet::<Runtime, pezpallet_bags_list::Instance1>::do_try_state().unwrap();
|
||||
pezpallet_bags_list::Pezpallet::<Runtime, pezpallet_bags_list::Instance1>::do_try_state()
|
||||
.unwrap();
|
||||
|
||||
log::info!(target: crate::LOG_TARGET, "executed bags-list sanity check with no errors.");
|
||||
|
||||
|
||||
@@ -36,22 +36,22 @@
|
||||
//! including its configuration trait, dispatchables, storage items, events and errors.
|
||||
//!
|
||||
//! This pezpallet provides an implementation of
|
||||
//! [`pezframe_election_provider_support::SortedListProvider`] and it can typically be used by another
|
||||
//! pezpallet via this API.
|
||||
//! [`pezframe_election_provider_support::SortedListProvider`] and it can typically be used by
|
||||
//! another pezpallet via this API.
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! This pezpallet splits `AccountId`s into different bags. Within a bag, these `AccountId`s are stored
|
||||
//! as nodes in a linked-list manner. This pezpallet then provides iteration over all bags, which
|
||||
//! basically allows an infinitely large list of items to be kept in a sorted manner.
|
||||
//! This pezpallet splits `AccountId`s into different bags. Within a bag, these `AccountId`s are
|
||||
//! stored as nodes in a linked-list manner. This pezpallet then provides iteration over all bags,
|
||||
//! which basically allows an infinitely large list of items to be kept in a sorted manner.
|
||||
//!
|
||||
//! Each bags has a upper and lower range of scores, denoted by [`Config::BagThresholds`]. All nodes
|
||||
//! within a bag must be within the range of the bag. If not, the permissionless [`Pezpallet::rebag`]
|
||||
//! can be used to move any node to the right bag.
|
||||
//! within a bag must be within the range of the bag. If not, the permissionless
|
||||
//! [`Pezpallet::rebag`] can be used to move any node to the right bag.
|
||||
//!
|
||||
//! Once a `rebag` happens, the order within a node is still not enforced. To move a node to the
|
||||
//! optimal position in a bag, the [`Pezpallet::put_in_front_of`] or [`Pezpallet::put_in_front_of_other`]
|
||||
//! can be used.
|
||||
//! optimal position in a bag, the [`Pezpallet::put_in_front_of`] or
|
||||
//! [`Pezpallet::put_in_front_of_other`] can be used.
|
||||
//!
|
||||
//! Additional reading, about how this pezpallet is used in the context of Pezkuwi's staking system:
|
||||
//! <https://pezkuwichain.io/blog/staking-update-september-2021/#bags-list-in-depth>
|
||||
@@ -217,7 +217,8 @@ pub mod pezpallet {
|
||||
/// there exists some constant ratio such that `threshold[k + 1] == (threshold[k] *
|
||||
/// constant_ratio).max(threshold[k] + 1)` for all `k`.
|
||||
///
|
||||
/// The helpers in the `/utils/pezframe/pez-generate-bags` module can simplify this calculation.
|
||||
/// The helpers in the `/utils/pezframe/pez-generate-bags` module can simplify this
|
||||
/// calculation.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@@ -332,9 +333,9 @@ pub mod pezpallet {
|
||||
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
|
||||
/// Get the current `score` of a given account.
|
||||
///
|
||||
/// Returns `(current, real_score)`, the former being the current score that this pezpallet is
|
||||
/// aware of, which may or may not be up to date, and the latter being the real score, as
|
||||
/// provided by
|
||||
/// Returns `(current, real_score)`, the former being the current score that this pezpallet
|
||||
/// is aware of, which may or may not be up to date, and the latter being the real score,
|
||||
/// as provided by
|
||||
// [`Config::ScoreProvider`].
|
||||
///
|
||||
/// If the two differ, it means this node is eligible for [`Call::rebag`].
|
||||
|
||||
@@ -37,8 +37,8 @@ use pezframe_support::{
|
||||
traits::{Defensive, DefensiveOption, Get},
|
||||
CloneNoBound, DefaultNoBound, EqNoBound, PalletError, PartialEqNoBound, RuntimeDebugNoBound,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::traits::{Bounded, Zero};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
#[cfg(any(
|
||||
test,
|
||||
@@ -595,7 +595,10 @@ impl<T: Config<I>, I: 'static> List<T, I> {
|
||||
let expected_bag = bags_map
|
||||
.get(&node.bag_upper)
|
||||
.ok_or("bag not found for the node in active bags")?;
|
||||
pezframe_support::ensure!(expected_bag.contains(node.id()), "node not found in the bag");
|
||||
pezframe_support::ensure!(
|
||||
expected_bag.contains(node.id()),
|
||||
"node not found in the bag"
|
||||
);
|
||||
|
||||
// verify node state
|
||||
node.do_try_state()?
|
||||
|
||||
@@ -372,8 +372,11 @@ mod list {
|
||||
// we do some wacky stuff here to get access to the counter, since it is (reasonably)
|
||||
// not exposed as mutable in any sense.
|
||||
#[pezframe_support::storage_alias]
|
||||
type CounterForListNodes<T: Config> =
|
||||
StorageValue<crate::Pezpallet<T>, u32, pezframe_support::pezpallet_prelude::ValueQuery>;
|
||||
type CounterForListNodes<T: Config> = StorageValue<
|
||||
crate::Pezpallet<T>,
|
||||
u32,
|
||||
pezframe_support::pezpallet_prelude::ValueQuery,
|
||||
>;
|
||||
CounterForListNodes::<Runtime>::mutate(|counter| *counter += 1);
|
||||
assert_eq!(crate::ListNodes::<Runtime>::count(), 5);
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
use pezframe_support::{assert_noop, assert_ok, assert_storage_noop, traits::IntegrityTest};
|
||||
|
||||
use super::*;
|
||||
use pezframe_election_provider_support::{SortedListProvider, VoteWeight};
|
||||
use bizinikiwi_test_utils::assert_eq_uvec;
|
||||
use list::Bag;
|
||||
use mock::{test_utils::*, *};
|
||||
use bizinikiwi_test_utils::assert_eq_uvec;
|
||||
use pezframe_election_provider_support::{SortedListProvider, VoteWeight};
|
||||
|
||||
#[docify::export]
|
||||
#[test]
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
//! are expected to be removed in the near future, once migration to `fungible::*` traits is done.
|
||||
|
||||
use super::*;
|
||||
pub use imbalances::{NegativeImbalance, PositiveImbalance};
|
||||
use pezframe_support::{
|
||||
ensure,
|
||||
pezpallet_prelude::DispatchResult,
|
||||
@@ -33,7 +34,6 @@ use pezframe_support::{
|
||||
},
|
||||
};
|
||||
use pezframe_system::pezpallet_prelude::BlockNumberFor;
|
||||
pub use imbalances::{NegativeImbalance, PositiveImbalance};
|
||||
use pezsp_runtime::traits::Bounded;
|
||||
|
||||
// wrapping these imbalances in a private module is necessary to ensure absolute privacy
|
||||
|
||||
@@ -126,8 +126,8 @@ impl<T: Config<I>, I: 'static> fungible::Inspect<T::AccountId> for Pezpallet<T,
|
||||
|
||||
// Provider restriction - total account balance cannot be reduced to zero if it cannot
|
||||
// sustain the loss of a provider reference.
|
||||
// NOTE: This assumes that the pezpallet is a provider (which is true). Is this ever changes,
|
||||
// then this will need to adapt accordingly.
|
||||
// NOTE: This assumes that the pezpallet is a provider (which is true). Is this ever
|
||||
// changes, then this will need to adapt accordingly.
|
||||
let ed = T::ExistentialDeposit::get();
|
||||
let success = if new_free_balance < ed {
|
||||
if pezframe_system::Pezpallet::<T>::can_dec_provider(who) {
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
//! token.
|
||||
//!
|
||||
//! It makes heavy use of concepts such as Holds and Freezes from the
|
||||
//! [`pezframe_support::traits::fungible`] traits, therefore you should read and understand those docs
|
||||
//! as a prerequisite to understanding this pezpallet.
|
||||
//! [`pezframe_support::traits::fungible`] traits, therefore you should read and understand those
|
||||
//! docs as a prerequisite to understanding this pezpallet.
|
||||
//!
|
||||
//! Also see the [`frame_tokens`] reference docs for higher level information regarding the
|
||||
//! place of this palet in FRAME.
|
||||
@@ -81,8 +81,8 @@
|
||||
//!
|
||||
//! ### Examples from the FRAME
|
||||
//!
|
||||
//! The Contract pezpallet uses the `Currency` trait to handle gas payment, and its types inherit from
|
||||
//! `Currency`:
|
||||
//! The Contract pezpallet uses the `Currency` trait to handle gas payment, and its types inherit
|
||||
//! from `Currency`:
|
||||
//!
|
||||
//! ```
|
||||
//! use pezframe_support::traits::Currency;
|
||||
@@ -159,6 +159,7 @@ use alloc::{
|
||||
};
|
||||
use codec::{Codec, MaxEncodedLen};
|
||||
use core::{cmp, fmt::Debug, mem, result};
|
||||
pub use impl_currency::{NegativeImbalance, PositiveImbalance};
|
||||
use pezframe_support::{
|
||||
ensure,
|
||||
pezpallet_prelude::DispatchResult,
|
||||
@@ -175,8 +176,6 @@ use pezframe_support::{
|
||||
BoundedSlice, WeakBoundedVec,
|
||||
};
|
||||
use pezframe_system as system;
|
||||
pub use impl_currency::{NegativeImbalance, PositiveImbalance};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_core::{sr25519::Pair as SrPair, Pair};
|
||||
use pezsp_runtime::{
|
||||
traits::{
|
||||
@@ -185,6 +184,7 @@ use pezsp_runtime::{
|
||||
},
|
||||
ArithmeticError, DispatchError, FixedPointOperand, Perbill, RuntimeDebug, TokenError,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
pub use types::{
|
||||
AccountData, AdjustmentDirection, BalanceLock, DustCleaner, ExtraFlags, Reasons, ReserveData,
|
||||
@@ -288,9 +288,9 @@ pub mod pezpallet {
|
||||
/// The minimum amount required to keep an account open. MUST BE GREATER THAN ZERO!
|
||||
///
|
||||
/// If you *really* need it to be zero, you can enable the feature `insecure_zero_ed` for
|
||||
/// this pezpallet. However, you do so at your own risk: this will open up a major DoS vector.
|
||||
/// In case you have multiple sources of provider references, you may also get unexpected
|
||||
/// behaviour if you set this to zero.
|
||||
/// this pezpallet. However, you do so at your own risk: this will open up a major DoS
|
||||
/// vector. In case you have multiple sources of provider references, you may also get
|
||||
/// unexpected behaviour if you set this to zero.
|
||||
///
|
||||
/// Bottom line: Do yourself a favour and make it at least one!
|
||||
#[pezpallet::constant]
|
||||
@@ -497,8 +497,8 @@ pub mod pezpallet {
|
||||
/// ```
|
||||
///
|
||||
/// But this comes with tradeoffs, storing account balances in the system pezpallet stores
|
||||
/// `pezframe_system` data alongside the account data contrary to storing account balances in the
|
||||
/// `Balances` pezpallet, which uses a `StorageMap` to store balances data only.
|
||||
/// `pezframe_system` data alongside the account data contrary to storing account balances in
|
||||
/// the `Balances` pezpallet, which uses a `StorageMap` to store balances data only.
|
||||
/// NOTE: This is only used in the case that this pezpallet is used to store balances.
|
||||
#[pezpallet::storage]
|
||||
pub type Account<T: Config<I>, I: 'static = ()> =
|
||||
@@ -1151,7 +1151,10 @@ pub mod pezpallet {
|
||||
});
|
||||
}
|
||||
if let Some(amount) = maybe_dust {
|
||||
Pezpallet::<T, I>::deposit_event(Event::DustLost { account: who.clone(), amount });
|
||||
Pezpallet::<T, I>::deposit_event(Event::DustLost {
|
||||
account: who.clone(),
|
||||
amount,
|
||||
});
|
||||
}
|
||||
(result, maybe_dust)
|
||||
})
|
||||
|
||||
@@ -22,8 +22,8 @@ use crate::{
|
||||
AdjustmentDirection::{Decrease as Dec, Increase as Inc},
|
||||
Event,
|
||||
};
|
||||
use pezframe_support::traits::{fungible::Unbalanced, tokens::Preservation::Expendable};
|
||||
use fungible::{hold::Mutate as HoldMutate, Inspect, Mutate};
|
||||
use pezframe_support::traits::{fungible::Unbalanced, tokens::Preservation::Expendable};
|
||||
|
||||
/// Alice account ID for more readable tests.
|
||||
const ALICE: u64 = 1;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
// limitations under the License.
|
||||
|
||||
use super::*;
|
||||
use pezframe_support::traits::fungible::{conformance_tests, Inspect, Mutate};
|
||||
use paste::paste;
|
||||
use pezframe_support::traits::fungible::{conformance_tests, Inspect, Mutate};
|
||||
|
||||
macro_rules! generate_tests {
|
||||
// Handle a conformance test that requires special testing with and without a dust trap.
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
//! Tests regarding the functionality of the `fungible` trait set implementations.
|
||||
|
||||
use super::*;
|
||||
use fungible::{
|
||||
FreezeConsideration, HoldConsideration, Inspect, InspectFreeze, InspectHold,
|
||||
LoneFreezeConsideration, LoneHoldConsideration, Mutate, MutateFreeze, MutateHold, Unbalanced,
|
||||
};
|
||||
use pezframe_support::traits::{
|
||||
tokens::{
|
||||
Fortitude::{Force, Polite},
|
||||
@@ -27,10 +31,6 @@ use pezframe_support::traits::{
|
||||
},
|
||||
Consideration, Footprint, LinearStoragePrice, MaybeConsideration,
|
||||
};
|
||||
use fungible::{
|
||||
FreezeConsideration, HoldConsideration, Inspect, InspectFreeze, InspectHold,
|
||||
LoneFreezeConsideration, LoneHoldConsideration, Mutate, MutateFreeze, MutateHold, Unbalanced,
|
||||
};
|
||||
use pezsp_core::ConstU64;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -36,7 +36,6 @@ use pezframe_support::{
|
||||
};
|
||||
use pezframe_system::{self as system, RawOrigin};
|
||||
use pezpallet_transaction_payment::{ChargeTransactionPayment, FungibleAdapter, Multiplier};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_core::{hexdisplay::HexDisplay, sr25519::Pair as SrPair, Pair};
|
||||
use pezsp_io;
|
||||
use pezsp_runtime::{
|
||||
@@ -44,6 +43,7 @@ use pezsp_runtime::{
|
||||
ArithmeticError, BuildStorage, DispatchError, DispatchResult, FixedPointNumber, RuntimeDebug,
|
||||
TokenError,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
mod consumer_limit_tests;
|
||||
@@ -371,8 +371,8 @@ fn check_whitelist() {
|
||||
assert!(whitelist.contains("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80"));
|
||||
}
|
||||
|
||||
/// This pezpallet runs tests twice, once with system as `type AccountStore` and once this pezpallet. This
|
||||
/// function will return the right value based on the `UseSystem` flag.
|
||||
/// This pezpallet runs tests twice, once with system as `type AccountStore` and once this
|
||||
/// pezpallet. This function will return the right value based on the `UseSystem` flag.
|
||||
pub(crate) fn get_test_account_data(who: AccountId) -> AccountData<Balance> {
|
||||
if UseSystem::get() {
|
||||
<SystemAccountStore as StoredMap<_, _>>::get(&who)
|
||||
@@ -381,8 +381,8 @@ pub(crate) fn get_test_account_data(who: AccountId) -> AccountData<Balance> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Same as `get_test_account_data`, but returns a `pezframe_system::AccountInfo` with the data filled
|
||||
/// in.
|
||||
/// Same as `get_test_account_data`, but returns a `pezframe_system::AccountInfo` with the data
|
||||
/// filled in.
|
||||
pub(crate) fn get_test_account(
|
||||
who: AccountId,
|
||||
) -> pezframe_system::AccountInfo<u32, AccountData<Balance>> {
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
//! Tests regarding the reentrancy functionality.
|
||||
|
||||
use super::*;
|
||||
use fungible::Balanced;
|
||||
use pezframe_support::traits::tokens::{
|
||||
Fortitude::Force,
|
||||
Precision::BestEffort,
|
||||
Preservation::{Expendable, Protect},
|
||||
};
|
||||
use fungible::Balanced;
|
||||
|
||||
#[test]
|
||||
fn transfer_dust_removal_tst1_should_work() {
|
||||
|
||||
@@ -21,8 +21,8 @@ use crate::{Config, CreditOf, Event, Pezpallet};
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
|
||||
use core::ops::BitOr;
|
||||
use pezframe_support::traits::{Imbalance, LockIdentifier, OnUnbalanced, WithdrawReasons};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::{RuntimeDebug, Saturating};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
/// Simplified reasons for withdrawing balance.
|
||||
#[derive(
|
||||
|
||||
@@ -67,7 +67,8 @@ mod weights;
|
||||
/// A BEEFY consensus digest item with MMR root hash.
|
||||
pub struct DepositBeefyDigest<T>(core::marker::PhantomData<T>);
|
||||
|
||||
impl<T> pezpallet_mmr::primitives::OnNewRoot<pezsp_consensus_beefy::MmrRootHash> for DepositBeefyDigest<T>
|
||||
impl<T> pezpallet_mmr::primitives::OnNewRoot<pezsp_consensus_beefy::MmrRootHash>
|
||||
for DepositBeefyDigest<T>
|
||||
where
|
||||
T: pezpallet_mmr::Config<Hashing = pezsp_consensus_beefy::MmrHashing>,
|
||||
T: pezpallet_beefy::Config,
|
||||
@@ -97,7 +98,8 @@ impl Convert<pezsp_consensus_beefy::ecdsa_crypto::AuthorityId, Vec<u8>> for Beef
|
||||
}
|
||||
}
|
||||
|
||||
type MerkleRootOf<T> = <<T as pezpallet_mmr::Config>::Hashing as pezsp_runtime::traits::Hash>::Output;
|
||||
type MerkleRootOf<T> =
|
||||
<<T as pezpallet_mmr::Config>::Hashing as pezsp_runtime::traits::Hash>::Output;
|
||||
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
@@ -126,7 +128,10 @@ pub mod pezpallet {
|
||||
/// and later to Ethereum Addresses (160 bits) to simplify using them on Ethereum chain,
|
||||
/// but the rest of the Bizinikiwi codebase is storing them compressed (33 bytes) for
|
||||
/// efficiency reasons.
|
||||
type BeefyAuthorityToMerkleLeaf: Convert<<Self as pezpallet_beefy::Config>::BeefyId, Vec<u8>>;
|
||||
type BeefyAuthorityToMerkleLeaf: Convert<
|
||||
<Self as pezpallet_beefy::Config>::BeefyId,
|
||||
Vec<u8>,
|
||||
>;
|
||||
|
||||
/// The type expected for the leaf extra data
|
||||
type LeafExtra: Member + codec::FullCodec;
|
||||
@@ -168,7 +173,8 @@ impl<T: Config> LeafDataProvider for Pezpallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> pezsp_consensus_beefy::OnNewValidatorSet<<T as pezpallet_beefy::Config>::BeefyId> for Pezpallet<T>
|
||||
impl<T> pezsp_consensus_beefy::OnNewValidatorSet<<T as pezpallet_beefy::Config>::BeefyId>
|
||||
for Pezpallet<T>
|
||||
where
|
||||
T: pezpallet::Config,
|
||||
{
|
||||
|
||||
@@ -36,9 +36,9 @@
|
||||
|
||||
use alloc::{vec, vec::Vec};
|
||||
use codec::{self as codec, Decode, Encode};
|
||||
use log::{error, info};
|
||||
use pezframe_support::traits::{Get, KeyOwnerProofSystem};
|
||||
use pezframe_system::pezpallet_prelude::{BlockNumberFor, HeaderFor};
|
||||
use log::{error, info};
|
||||
use pezsp_consensus_beefy::{
|
||||
check_commitment_signature, AncestryHelper, DoubleVotingProof, ForkVotingProof,
|
||||
FutureBlockVotingProof, ValidatorSetId, KEY_TYPE as BEEFY_KEY_TYPE,
|
||||
|
||||
@@ -26,7 +26,6 @@ use pezframe_support::{
|
||||
};
|
||||
use pezframe_system::pezpallet_prelude::HeaderFor;
|
||||
use pezpallet_session::historical as pezpallet_session_historical;
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_core::{crypto::KeyTypeId, ConstBool, ConstU128};
|
||||
use pezsp_runtime::{
|
||||
app_crypto::ecdsa::Public,
|
||||
@@ -38,10 +37,13 @@ use pezsp_runtime::{
|
||||
};
|
||||
use pezsp_staking::{EraIndex, SessionIndex};
|
||||
use pezsp_state_machine::BasicExternalities;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
use crate as pezpallet_beefy;
|
||||
|
||||
pub use pezsp_consensus_beefy::{ecdsa_crypto::AuthorityId as BeefyId, ConsensusLog, BEEFY_ENGINE_ID};
|
||||
pub use pezsp_consensus_beefy::{
|
||||
ecdsa_crypto::AuthorityId as BeefyId, ConsensusLog, BEEFY_ENGINE_ID,
|
||||
};
|
||||
use pezsp_consensus_beefy::{AncestryHelper, AncestryHelperWeightInfo, Commitment};
|
||||
|
||||
impl_opaque_keys! {
|
||||
@@ -304,7 +306,9 @@ impl ExtBuilder {
|
||||
|
||||
// controllers are same as stash
|
||||
let stakers: Vec<_> = (0..self.authorities.len())
|
||||
.map(|i| (i as u64, i as u64, 10_000, pezpallet_staking::StakerStatus::<u64>::Validator))
|
||||
.map(|i| {
|
||||
(i as u64, i as u64, 10_000, pezpallet_staking::StakerStatus::<u64>::Validator)
|
||||
})
|
||||
.collect();
|
||||
|
||||
let staking_config = pezpallet_staking::GenesisConfig::<Test> {
|
||||
|
||||
@@ -445,6 +445,9 @@ mod mock {
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
|
||||
pezframe_system::GenesisConfig::<Test>::default()
|
||||
.build_storage()
|
||||
.unwrap()
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! End-to-end testing pezpallet for PoV benchmarking. Should only be deployed in a testing runtime.
|
||||
//! End-to-end testing pezpallet for PoV benchmarking. Should only be deployed in a testing
|
||||
//! runtime.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
@@ -39,7 +40,8 @@ pub mod pezpallet {
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
}
|
||||
|
||||
#[pezpallet::storage]
|
||||
|
||||
@@ -39,9 +39,9 @@ pub mod v1;
|
||||
pub mod __private {
|
||||
pub use alloc::{boxed::Box, str, vec, vec::Vec};
|
||||
pub use codec;
|
||||
pub use pezframe_support::{storage, traits};
|
||||
pub use log;
|
||||
pub use paste;
|
||||
pub use pezframe_support::{storage, traits};
|
||||
pub use pezsp_core::defer;
|
||||
pub use pezsp_io::storage::root as storage_root;
|
||||
pub use pezsp_runtime::{traits::Zero, StateVersion};
|
||||
|
||||
@@ -351,7 +351,10 @@ mod benchmarks {
|
||||
Pezpallet::<Test>::test_benchmark_override_benchmark(),
|
||||
Err(BenchmarkError::Override(_)),
|
||||
));
|
||||
assert_eq!(Pezpallet::<Test>::test_benchmark_skip_benchmark(), Err(BenchmarkError::Skip),);
|
||||
assert_eq!(
|
||||
Pezpallet::<Test>::test_benchmark_skip_benchmark(),
|
||||
Err(BenchmarkError::Skip),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -367,7 +370,10 @@ mod benchmarks {
|
||||
assert_eq!(Value::<Test>::get(), None);
|
||||
|
||||
// It resets when the error happens in the call:
|
||||
assert_err!(Pezpallet::<Test>::test_benchmark_modify_in_call_then_error(), "Should error");
|
||||
assert_err!(
|
||||
Pezpallet::<Test>::test_benchmark_modify_in_call_then_error(),
|
||||
"Should error"
|
||||
);
|
||||
assert_eq!(Value::<Test>::get(), None);
|
||||
|
||||
// It resets when the error happens in the verify:
|
||||
|
||||
@@ -18,10 +18,9 @@
|
||||
//! Interfaces, types and utils for benchmarking a FRAME runtime.
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, Encode};
|
||||
use pezframe_support::{dispatch::DispatchErrorWithPostInfo, pezpallet_prelude::*, traits::StorageInfo};
|
||||
use scale_info::TypeInfo;
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use pezframe_support::{
|
||||
dispatch::DispatchErrorWithPostInfo, pezpallet_prelude::*, traits::StorageInfo,
|
||||
};
|
||||
use pezsp_io::hashing::blake2_256;
|
||||
use pezsp_runtime::{
|
||||
traits::TrailingZeroInput, transaction_validity::TransactionValidityError, DispatchError,
|
||||
@@ -31,6 +30,9 @@ use pezsp_runtime_interface::pass_by::{
|
||||
PassFatPointerAndRead,
|
||||
};
|
||||
use pezsp_storage::TrackedStorageKey;
|
||||
use scale_info::TypeInfo;
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// An alphabet of possible parameters to use for benchmarking.
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
|
||||
@@ -188,7 +188,8 @@ macro_rules! benchmarks {
|
||||
|
||||
/// Same as [`benchmarks`] but for instantiable module.
|
||||
///
|
||||
/// NOTE: For pezpallet declared with [`pezframe_support::pezpallet`], use [`benchmarks_instance_pallet`].
|
||||
/// NOTE: For pezpallet declared with [`pezframe_support::pezpallet`], use
|
||||
/// [`benchmarks_instance_pallet`].
|
||||
#[macro_export]
|
||||
macro_rules! benchmarks_instance {
|
||||
(
|
||||
@@ -1799,9 +1800,9 @@ pub fn show_benchmark_debug_info(
|
||||
///
|
||||
/// At the end of `dispatch_benchmark`, you should return this batches object.
|
||||
///
|
||||
/// In the case where you have multiple instances of a pezpallet that you need to separately benchmark,
|
||||
/// the name of your module struct will be used as a suffix to your outputted weight file. For
|
||||
/// example:
|
||||
/// In the case where you have multiple instances of a pezpallet that you need to separately
|
||||
/// benchmark, the name of your module struct will be used as a suffix to your outputted weight
|
||||
/// file. For example:
|
||||
///
|
||||
/// ```ignore
|
||||
/// add_benchmark!(params, batches, pezpallet_balances, Balances); // pezpallet_balances.rs
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
//! curator or once the bounty is active or payout is pending, resulting in the slash of the
|
||||
//! curator's deposit.
|
||||
//!
|
||||
//! This pezpallet may opt into using a [`ChildBountyManager`] that enables bounties to be split into
|
||||
//! sub-bounties, as children of an established bounty (called the parent in the context of it's
|
||||
//! children).
|
||||
//! This pezpallet may opt into using a [`ChildBountyManager`] that enables bounties to be split
|
||||
//! into sub-bounties, as children of an established bounty (called the parent in the context of
|
||||
//! it's children).
|
||||
//!
|
||||
//! > NOTE: The parent bounty cannot be closed if it has a non-zero number of it has active child
|
||||
//! > bounties associated with it.
|
||||
@@ -232,7 +232,9 @@ pub mod pezpallet {
|
||||
pub struct Pezpallet<T, I = ()>(_);
|
||||
|
||||
#[pezpallet::config]
|
||||
pub trait Config<I: 'static = ()>: pezframe_system::Config + pezpallet_treasury::Config<I> {
|
||||
pub trait Config<I: 'static = ()>:
|
||||
pezframe_system::Config + pezpallet_treasury::Config<I>
|
||||
{
|
||||
/// The amount held on deposit for placing a bounty proposal.
|
||||
#[pezpallet::constant]
|
||||
type BountyDepositBase: Get<BalanceOf<Self, I>>;
|
||||
|
||||
@@ -29,7 +29,8 @@ use pezsp_io::{hashing::twox_128, storage};
|
||||
|
||||
use crate as pezpallet_bounties;
|
||||
|
||||
/// Migrate the storage of the bounties pezpallet to a new prefix, leaving all other storage untouched
|
||||
/// Migrate the storage of the bounties pezpallet to a new prefix, leaving all other storage
|
||||
/// untouched
|
||||
///
|
||||
/// This new prefix must be the same as the one set in construct_runtime. For safety, use
|
||||
/// `PalletInfo` to get it, as:
|
||||
@@ -113,7 +114,11 @@ pub fn migrate<
|
||||
/// `pezframe_support::traits::OnRuntimeUpgrade::pre_upgrade` for further testing.
|
||||
///
|
||||
/// Panics if anything goes wrong.
|
||||
pub fn pre_migration<T: pezpallet_bounties::Config, P: GetStorageVersion + 'static, N: AsRef<str>>(
|
||||
pub fn pre_migration<
|
||||
T: pezpallet_bounties::Config,
|
||||
P: GetStorageVersion + 'static,
|
||||
N: AsRef<str>,
|
||||
>(
|
||||
old_pallet_name: N,
|
||||
new_pallet_name: N,
|
||||
) {
|
||||
@@ -123,7 +128,8 @@ pub fn pre_migration<T: pezpallet_bounties::Config, P: GetStorageVersion + 'stat
|
||||
let storage_prefix_bounties = pezpallet_bounties::Bounties::<T>::storage_prefix();
|
||||
let storage_prefix_bounties_description =
|
||||
pezpallet_bounties::BountyDescriptions::<T>::storage_prefix();
|
||||
let storage_prefix_bounties_approvals = pezpallet_bounties::BountyApprovals::<T>::storage_prefix();
|
||||
let storage_prefix_bounties_approvals =
|
||||
pezpallet_bounties::BountyApprovals::<T>::storage_prefix();
|
||||
log_migration("pre-migration", storage_prefix_bounties_count, old_pallet_name, new_pallet_name);
|
||||
log_migration("pre-migration", storage_prefix_bounties, old_pallet_name, new_pallet_name);
|
||||
log_migration(
|
||||
@@ -177,7 +183,8 @@ pub fn post_migration<T: pezpallet_bounties::Config, P: GetStorageVersion, N: As
|
||||
let storage_prefix_bounties = pezpallet_bounties::Bounties::<T>::storage_prefix();
|
||||
let storage_prefix_bounties_description =
|
||||
pezpallet_bounties::BountyDescriptions::<T>::storage_prefix();
|
||||
let storage_prefix_bounties_approvals = pezpallet_bounties::BountyApprovals::<T>::storage_prefix();
|
||||
let storage_prefix_bounties_approvals =
|
||||
pezpallet_bounties::BountyApprovals::<T>::storage_prefix();
|
||||
log_migration(
|
||||
"post-migration",
|
||||
storage_prefix_bounties_count,
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
|
||||
use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Not};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_core::RuntimeDebug;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
/// The number of bits in the `CoreMask`.
|
||||
pub const CORE_MASK_BITS: usize = 80;
|
||||
|
||||
@@ -21,10 +21,10 @@ use alloc::vec::Vec;
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
|
||||
use core::fmt::Debug;
|
||||
use pezframe_support::Parameter;
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_arithmetic::traits::AtLeast32BitUnsigned;
|
||||
use pezsp_core::RuntimeDebug;
|
||||
use pezsp_runtime::traits::BlockNumberProvider;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
use crate::Timeslice;
|
||||
|
||||
|
||||
@@ -76,7 +76,8 @@ pub mod pezpallet {
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// Weight information for all calls of this pezpallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
|
||||
@@ -26,10 +26,10 @@ use pezframe_support::{
|
||||
},
|
||||
},
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_arithmetic::traits::Zero;
|
||||
use pezsp_core::{Get, TypedGet};
|
||||
use pezsp_runtime::{DispatchError, DispatchResult};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
parameter_types! {
|
||||
static TestAssetOf: BTreeMap<(u32, Vec<u8>), Vec<u8>> = Default::default();
|
||||
|
||||
@@ -24,11 +24,11 @@ use pezframe_support::{
|
||||
BoundedVec,
|
||||
};
|
||||
use pezframe_system::RawOrigin::Root;
|
||||
use pretty_assertions::assert_eq;
|
||||
use pezsp_runtime::{
|
||||
traits::{BadOrigin, Get},
|
||||
Perbill, TokenError,
|
||||
};
|
||||
use pretty_assertions::assert_eq;
|
||||
use CoreAssignment::*;
|
||||
use CoretimeTraceItem::*;
|
||||
use Finality::*;
|
||||
|
||||
@@ -22,10 +22,10 @@ use crate::{
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
|
||||
use pezframe_support::traits::fungible::Inspect;
|
||||
use pezframe_system::Config as SConfig;
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_arithmetic::Perbill;
|
||||
use pezsp_core::{ConstU32, RuntimeDebug};
|
||||
use pezsp_runtime::BoundedVec;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
pub type BalanceOf<T> = <<T as Config>::Currency as Inspect<<T as SConfig>::AccountId>>::Balance;
|
||||
pub type RelayBalanceOf<T> = <<T as Config>::Coretime as CoretimeInterface>::Balance;
|
||||
|
||||
@@ -280,15 +280,15 @@ mod benchmarks {
|
||||
|
||||
// If `BountyUpdatePeriod` overflows the inactivity timeout the benchmark still
|
||||
// executes the slash
|
||||
let origin: T::RuntimeOrigin = if Pezpallet::<T>::treasury_block_number() <= inactivity_timeout
|
||||
{
|
||||
let child_curator = bounty_setup.child_curator;
|
||||
T::RejectOrigin::try_successful_origin()
|
||||
.unwrap_or_else(|_| RawOrigin::Signed(child_curator).into())
|
||||
} else {
|
||||
let caller = whitelisted_caller();
|
||||
RawOrigin::Signed(caller).into()
|
||||
};
|
||||
let origin: T::RuntimeOrigin =
|
||||
if Pezpallet::<T>::treasury_block_number() <= inactivity_timeout {
|
||||
let child_curator = bounty_setup.child_curator;
|
||||
T::RejectOrigin::try_successful_origin()
|
||||
.unwrap_or_else(|_| RawOrigin::Signed(child_curator).into())
|
||||
} else {
|
||||
let caller = whitelisted_caller();
|
||||
RawOrigin::Signed(caller).into()
|
||||
};
|
||||
|
||||
#[extrinsic_call]
|
||||
_(origin as T::RuntimeOrigin, bounty_setup.bounty_id, bounty_setup.child_bounty_id);
|
||||
|
||||
@@ -163,7 +163,8 @@ pub mod pezpallet {
|
||||
|
||||
/// The overarching event type.
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// Weight information for extrinsics in this pezpallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
|
||||
@@ -28,7 +28,8 @@ use pezframe_benchmarking::{
|
||||
v2::*,
|
||||
};
|
||||
use pezframe_system::{
|
||||
pezpallet_prelude::BlockNumberFor, Call as SystemCall, Pezpallet as System, RawOrigin as SystemOrigin,
|
||||
pezpallet_prelude::BlockNumberFor, Call as SystemCall, Pezpallet as System,
|
||||
RawOrigin as SystemOrigin,
|
||||
};
|
||||
|
||||
const SEED: u32 = 0;
|
||||
|
||||
@@ -46,12 +46,12 @@ extern crate alloc;
|
||||
use alloc::{boxed::Box, vec, vec::Vec};
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
|
||||
use core::{marker::PhantomData, result};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_io::storage;
|
||||
use pezsp_runtime::{
|
||||
traits::{Dispatchable, Hash},
|
||||
DispatchError, RuntimeDebug,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
use pezframe_support::{
|
||||
dispatch::{
|
||||
@@ -566,8 +566,8 @@ pub mod pezpallet {
|
||||
///
|
||||
/// # WARNING:
|
||||
///
|
||||
/// The `pezpallet-collective` can also be managed by logic outside of the pezpallet through the
|
||||
/// implementation of the trait [`ChangeMembers`].
|
||||
/// The `pezpallet-collective` can also be managed by logic outside of the pezpallet through
|
||||
/// the implementation of the trait [`ChangeMembers`].
|
||||
/// Any call to `set_members` must be careful that the member set doesn't get out of sync
|
||||
/// with other logic managing the member set.
|
||||
///
|
||||
@@ -1088,7 +1088,10 @@ impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
|
||||
}
|
||||
|
||||
// Only allow actual closing of the proposal after the voting period has ended.
|
||||
ensure!(pezframe_system::Pezpallet::<T>::block_number() >= voting.end, Error::<T, I>::TooEarly);
|
||||
ensure!(
|
||||
pezframe_system::Pezpallet::<T>::block_number() >= voting.end,
|
||||
Error::<T, I>::TooEarly
|
||||
);
|
||||
|
||||
let prime_vote = Prime::<T, I>::get().map(|who| voting.ayes.iter().any(|a| a == &who));
|
||||
|
||||
|
||||
@@ -35,7 +35,11 @@ use pezframe_support::{
|
||||
/// The migration will look into the storage version in order not to trigger a migration on an up
|
||||
/// to date storage. Thus the on chain storage version must be less than 4 in order to trigger the
|
||||
/// migration.
|
||||
pub fn migrate<T: pezframe_system::Config, P: GetStorageVersion + PalletInfoAccess, N: AsRef<str>>(
|
||||
pub fn migrate<
|
||||
T: pezframe_system::Config,
|
||||
P: GetStorageVersion + PalletInfoAccess,
|
||||
N: AsRef<str>,
|
||||
>(
|
||||
old_pallet_name: N,
|
||||
) -> Weight {
|
||||
let old_pallet_name = old_pallet_name.as_ref();
|
||||
|
||||
@@ -35,7 +35,8 @@ pub mod pezpallet {
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type XcmExecutor: ExecuteXcm<Self::RuntimeCall>;
|
||||
}
|
||||
|
||||
|
||||
@@ -841,9 +841,9 @@ fn expand_functions(def: &EnvDef, expand_mode: ExpandMode) -> TokenStream2 {
|
||||
/// The function `bar` is additionally annotated with `unstable` which removes it from the stable
|
||||
/// interface. Check out the README to learn about unstable functions.
|
||||
///
|
||||
/// In legacy versions of pezpallet_contracts, it was a naming convention that all host functions had
|
||||
/// to be named with the `seal_` prefix. For the sake of backwards compatibility, each host function
|
||||
/// now can get a such prefix-named alias function generated by marking it by the
|
||||
/// In legacy versions of pezpallet_contracts, it was a naming convention that all host functions
|
||||
/// had to be named with the `seal_` prefix. For the sake of backwards compatibility, each host
|
||||
/// function now can get a such prefix-named alias function generated by marking it by the
|
||||
/// `#[prefixed_alias]` attribute:
|
||||
///
|
||||
/// ## Example
|
||||
|
||||
@@ -417,7 +417,8 @@ mod benchmarks {
|
||||
StorageVersion::new(latest_version).put::<Pezpallet<T>>();
|
||||
#[block]
|
||||
{
|
||||
<Migration<T, false> as pezframe_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade();
|
||||
<Migration<T, false> as pezframe_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade(
|
||||
);
|
||||
}
|
||||
assert!(MigrationInProgress::<T>::get().is_none());
|
||||
}
|
||||
@@ -432,7 +433,8 @@ mod benchmarks {
|
||||
MigrationInProgress::<T>::set(v.clone());
|
||||
#[block]
|
||||
{
|
||||
<Migration<T, false> as pezframe_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade();
|
||||
<Migration<T, false> as pezframe_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade(
|
||||
);
|
||||
}
|
||||
assert!(MigrationInProgress::<T>::get().is_some());
|
||||
assert_eq!(MigrationInProgress::<T>::get(), v);
|
||||
@@ -446,7 +448,8 @@ mod benchmarks {
|
||||
StorageVersion::new(latest_version - 2).put::<Pezpallet<T>>();
|
||||
#[block]
|
||||
{
|
||||
<Migration<T, false> as pezframe_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade();
|
||||
<Migration<T, false> as pezframe_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade(
|
||||
);
|
||||
}
|
||||
assert!(MigrationInProgress::<T>::get().is_some());
|
||||
}
|
||||
@@ -565,7 +568,10 @@ mod benchmarks {
|
||||
// value and value transferred via call should be removed from the caller
|
||||
assert_eq!(
|
||||
T::Currency::balance(&instance.caller),
|
||||
caller_funding::<T>() - instance.value - value - deposit - Pezpallet::<T>::min_balance(),
|
||||
caller_funding::<T>() -
|
||||
instance.value -
|
||||
value - deposit -
|
||||
Pezpallet::<T>::min_balance(),
|
||||
);
|
||||
// contract should have received the value
|
||||
assert_eq!(T::Currency::balance(&instance.account_id), before + value);
|
||||
@@ -1830,8 +1836,8 @@ mod benchmarks {
|
||||
|
||||
let key_type = pezsp_core::crypto::KeyTypeId(*b"code");
|
||||
let pub_key = pezsp_io::crypto::sr25519_generate(key_type, None);
|
||||
let sig =
|
||||
pezsp_io::crypto::sr25519_sign(key_type, &pub_key, &message).expect("Generates signature");
|
||||
let sig = pezsp_io::crypto::sr25519_sign(key_type, &pub_key, &message)
|
||||
.expect("Generates signature");
|
||||
let sig = AsRef::<[u8; 64]>::as_ref(&sig).to_vec();
|
||||
let sig_len = sig.len() as u32;
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ use pezframe_support::{
|
||||
Blake2_128Concat, BoundedVec, StorageHasher,
|
||||
};
|
||||
use pezframe_system::{pezpallet_prelude::BlockNumberFor, RawOrigin};
|
||||
use smallvec::{Array, SmallVec};
|
||||
use pezsp_core::{
|
||||
ecdsa::Public as ECDSAPublic,
|
||||
sr25519::{Public as SR25519Public, Signature as SR25519Signature},
|
||||
@@ -52,6 +51,7 @@ use pezsp_runtime::{
|
||||
traits::{Convert, Dispatchable, Zero},
|
||||
DispatchError,
|
||||
};
|
||||
use smallvec::{Array, SmallVec};
|
||||
|
||||
pub type AccountIdOf<T> = <T as pezframe_system::Config>::AccountId;
|
||||
pub type MomentOf<T> = <<T as Config>::Time as Time>::Moment;
|
||||
@@ -1723,8 +1723,8 @@ mod tests {
|
||||
use pezframe_support::{assert_err, assert_ok, parameter_types};
|
||||
use pezframe_system::{EventRecord, Phase};
|
||||
use pezpallet_contracts_uapi::ReturnFlags;
|
||||
use pretty_assertions::assert_eq;
|
||||
use pezsp_runtime::{traits::Hash, DispatchError};
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::{cell::RefCell, collections::hash_map::HashMap, rc::Rc};
|
||||
|
||||
type System = pezframe_system::Pezpallet<Test>;
|
||||
|
||||
@@ -27,8 +27,9 @@
|
||||
//!
|
||||
//! This module extends accounts based on the [`pezframe_support::traits::fungible`] traits to have
|
||||
//! smart-contract functionality. It can be used with other modules that implement accounts based on
|
||||
//! the [`pezframe_support::traits::fungible`] traits. These "smart-contract accounts" have the ability
|
||||
//! to instantiate smart-contracts and make calls to other contract and non-contract accounts.
|
||||
//! the [`pezframe_support::traits::fungible`] traits. These "smart-contract accounts" have the
|
||||
//! ability to instantiate smart-contracts and make calls to other contract and non-contract
|
||||
//! accounts.
|
||||
//!
|
||||
//! The smart-contract code is stored once, and later retrievable via its hash.
|
||||
//! This means that multiple smart-contracts can be instantiated from the same hash, without
|
||||
@@ -71,8 +72,8 @@
|
||||
//! code an existing `code_hash` is supplied.
|
||||
//! * [`Pezpallet::call`] - Makes a call to an account, optionally transferring some balance.
|
||||
//! * [`Pezpallet::upload_code`] - Uploads new code without instantiating a contract from it.
|
||||
//! * [`Pezpallet::remove_code`] - Removes the stored code and refunds the deposit to its owner. Only
|
||||
//! allowed to code owner.
|
||||
//! * [`Pezpallet::remove_code`] - Removes the stored code and refunds the deposit to its owner.
|
||||
//! Only allowed to code owner.
|
||||
//! * [`Pezpallet::set_code`] - Changes the code of an existing contract. Only allowed to `Root`
|
||||
//! origin.
|
||||
//! * [`Pezpallet::migrate`] - Runs migration steps of current multi-block migration in priority,
|
||||
@@ -134,12 +135,12 @@ use pezframe_system::{
|
||||
pezpallet_prelude::{BlockNumberFor, OriginFor},
|
||||
EventRecord, Pezpallet as System,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
use smallvec::Array;
|
||||
use pezsp_runtime::{
|
||||
traits::{BadOrigin, Convert, Dispatchable, Saturating, StaticLookup, Zero},
|
||||
DispatchError, RuntimeDebug,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
use smallvec::Array;
|
||||
|
||||
pub use crate::{
|
||||
address::{AddressGenerator, DefaultAddressGenerator},
|
||||
@@ -167,8 +168,8 @@ type EventRecordOf<T> =
|
||||
|
||||
/// The old weight type.
|
||||
///
|
||||
/// This is a copy of the [`pezframe_support::weights::OldWeight`] type since the contracts pezpallet
|
||||
/// needs to support it indefinitely.
|
||||
/// This is a copy of the [`pezframe_support::weights::OldWeight`] type since the contracts
|
||||
/// pezpallet needs to support it indefinitely.
|
||||
type OldWeight = u64;
|
||||
|
||||
/// Used as a sentinel value when reading and writing contract memory.
|
||||
@@ -277,7 +278,8 @@ pub mod pezpallet {
|
||||
/// The overarching event type.
|
||||
#[pezpallet::no_default_bounds]
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// The overarching call type.
|
||||
#[pezpallet::no_default_bounds]
|
||||
@@ -1270,8 +1272,8 @@ pub mod pezpallet {
|
||||
TerminatedInConstructor,
|
||||
/// A call tried to invoke a contract that is flagged as non-reentrant.
|
||||
/// The only other cause is that a call from a contract into the runtime tried to call back
|
||||
/// into `pezpallet-contracts`. This would make the whole pezpallet reentrant with regard to
|
||||
/// contract code execution which is not supported.
|
||||
/// into `pezpallet-contracts`. This would make the whole pezpallet reentrant with regard
|
||||
/// to contract code execution which is not supported.
|
||||
ReentranceDenied,
|
||||
/// A contract attempted to invoke a state modifying API while being in read-only mode.
|
||||
StateChangeDenied,
|
||||
|
||||
@@ -67,7 +67,9 @@ pub mod v15;
|
||||
pub mod v16;
|
||||
include!(concat!(env!("OUT_DIR"), "/migration_codegen.rs"));
|
||||
|
||||
use crate::{weights::WeightInfo, Config, Error, MigrationInProgress, Pezpallet, Weight, LOG_TARGET};
|
||||
use crate::{
|
||||
weights::WeightInfo, Config, Error, MigrationInProgress, Pezpallet, Weight, LOG_TARGET,
|
||||
};
|
||||
use codec::{Codec, Decode};
|
||||
use core::marker::PhantomData;
|
||||
use pezframe_support::{
|
||||
@@ -578,7 +580,10 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_storage_version_matches_last_migration_file() {
|
||||
assert_eq!(StorageVersion::new(LATEST_MIGRATION_VERSION), crate::pezpallet::STORAGE_VERSION);
|
||||
assert_eq!(
|
||||
StorageVersion::new(LATEST_MIGRATION_VERSION),
|
||||
crate::pezpallet::STORAGE_VERSION
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -63,7 +63,8 @@ pub fn fill_old_queue<T: Config>(len: usize) {
|
||||
type DeletionQueue<T: Config> = StorageMap<Pezpallet<T>, Twox64Concat, u32, TrieId>;
|
||||
|
||||
#[storage_alias]
|
||||
type DeletionQueueCounter<T: Config> = StorageValue<Pezpallet<T>, DeletionQueueManager<T>, ValueQuery>;
|
||||
type DeletionQueueCounter<T: Config> =
|
||||
StorageValue<Pezpallet<T>, DeletionQueueManager<T>, ValueQuery>;
|
||||
|
||||
#[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)]
|
||||
pub struct Migration<T: Config> {
|
||||
|
||||
@@ -29,11 +29,11 @@ use pezframe_support::{
|
||||
pezpallet_prelude::*, storage_alias, traits::ReservableCurrency, weights::WeightMeter,
|
||||
DefaultNoBound, Identity,
|
||||
};
|
||||
use scale_info::prelude::format;
|
||||
use pezsp_core::hexdisplay::HexDisplay;
|
||||
#[cfg(feature = "try-runtime")]
|
||||
use pezsp_runtime::TryRuntimeError;
|
||||
use pezsp_runtime::{traits::Zero, FixedPointNumber, FixedU128, Saturating};
|
||||
use scale_info::prelude::format;
|
||||
|
||||
mod v11 {
|
||||
use super::*;
|
||||
|
||||
@@ -72,8 +72,12 @@ pub fn store_old_contract_info<T: Config>(account: T::AccountId, info: crate::Co
|
||||
}
|
||||
|
||||
#[storage_alias]
|
||||
pub type ContractInfoOf<T: Config> =
|
||||
StorageMap<Pezpallet<T>, Twox64Concat, <T as pezframe_system::Config>::AccountId, ContractInfo<T>>;
|
||||
pub type ContractInfoOf<T: Config> = StorageMap<
|
||||
Pezpallet<T>,
|
||||
Twox64Concat,
|
||||
<T as pezframe_system::Config>::AccountId,
|
||||
ContractInfo<T>,
|
||||
>;
|
||||
|
||||
#[derive(Encode, Decode, CloneNoBound, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
||||
#[scale_info(skip_type_params(T))]
|
||||
|
||||
@@ -111,8 +111,12 @@ struct ContractInfo<T: Config> {
|
||||
}
|
||||
|
||||
#[storage_alias]
|
||||
type ContractInfoOf<T: Config> =
|
||||
StorageMap<Pezpallet<T>, Twox64Concat, <T as pezframe_system::Config>::AccountId, ContractInfo<T>>;
|
||||
type ContractInfoOf<T: Config> = StorageMap<
|
||||
Pezpallet<T>,
|
||||
Twox64Concat,
|
||||
<T as pezframe_system::Config>::AccountId,
|
||||
ContractInfo<T>,
|
||||
>;
|
||||
|
||||
#[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)]
|
||||
pub struct Migration<T: Config> {
|
||||
|
||||
@@ -51,8 +51,12 @@ pub fn store_old_contract_info<T: Config>(
|
||||
}
|
||||
|
||||
#[storage_alias]
|
||||
pub type ContractInfoOf<T: Config> =
|
||||
StorageMap<Pezpallet<T>, Twox64Concat, <T as pezframe_system::Config>::AccountId, ContractInfo<T>>;
|
||||
pub type ContractInfoOf<T: Config> = StorageMap<
|
||||
Pezpallet<T>,
|
||||
Twox64Concat,
|
||||
<T as pezframe_system::Config>::AccountId,
|
||||
ContractInfo<T>,
|
||||
>;
|
||||
|
||||
#[derive(Encode, Decode, CloneNoBound, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
||||
#[scale_info(skip_type_params(T))]
|
||||
|
||||
@@ -21,11 +21,11 @@ use alloc::vec::Vec;
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
use pezframe_support::weights::Weight;
|
||||
use pezpallet_contracts_uapi::ReturnFlags;
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::{
|
||||
traits::{Saturating, Zero},
|
||||
DispatchError, RuntimeDebug,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
/// Result type of a `bare_call` or `bare_instantiate` call as well as `ContractsApi::call` and
|
||||
/// `ContractsApi::instantiate`.
|
||||
|
||||
@@ -33,13 +33,13 @@ use pezframe_support::{
|
||||
weights::{Weight, WeightMeter},
|
||||
CloneNoBound, DefaultNoBound,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_core::Get;
|
||||
use pezsp_io::KillStorageResult;
|
||||
use pezsp_runtime::{
|
||||
traits::{Hash, Saturating, Zero},
|
||||
BoundedBTreeMap, DispatchError, DispatchResult, RuntimeDebug,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
use self::meter::Diff;
|
||||
|
||||
@@ -458,7 +458,8 @@ impl<T: Config> DeletionQueueManager<T> {
|
||||
///
|
||||
/// Note:
|
||||
/// we use the delete counter to get the next value to read from the queue and thus don't pay
|
||||
/// the cost of an extra call to `pezsp_io::storage::next_key` to lookup the next entry in the map
|
||||
/// the cost of an extra call to `pezsp_io::storage::next_key` to lookup the next entry in the
|
||||
/// map
|
||||
fn next(&mut self) -> Option<DeletionQueueEntry<'_, T>> {
|
||||
if self.is_empty() {
|
||||
return None;
|
||||
|
||||
@@ -23,8 +23,8 @@ use crate::{
|
||||
};
|
||||
use codec::{Encode, HasCompact};
|
||||
use core::fmt::Debug;
|
||||
use pezframe_support::pezpallet_prelude::DispatchResultWithPostInfo;
|
||||
use paste::paste;
|
||||
use pezframe_support::pezpallet_prelude::DispatchResultWithPostInfo;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
/// Helper macro to generate a builder for contract API calls.
|
||||
|
||||
@@ -45,8 +45,8 @@ use pezframe_support::{
|
||||
assert_err, assert_err_ignore_postinfo, assert_err_with_weight, assert_noop, assert_ok,
|
||||
derive_impl,
|
||||
dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo},
|
||||
pezpallet_prelude::EnsureOrigin,
|
||||
parameter_types,
|
||||
pezpallet_prelude::EnsureOrigin,
|
||||
storage::child,
|
||||
traits::{
|
||||
fungible::{BalancedHold, Inspect, Mutate, MutateHold},
|
||||
@@ -57,7 +57,6 @@ use pezframe_support::{
|
||||
};
|
||||
use pezframe_system::{EventRecord, Phase};
|
||||
use pezpallet_contracts_fixtures::compile_module;
|
||||
use pretty_assertions::{assert_eq, assert_ne};
|
||||
use pezsp_core::ByteArray;
|
||||
use pezsp_io::hashing::blake2_256;
|
||||
use pezsp_keystore::{testing::MemoryKeystore, KeystoreExt};
|
||||
@@ -66,6 +65,7 @@ use pezsp_runtime::{
|
||||
traits::{BlakeTwo256, Convert, IdentityLookup},
|
||||
AccountId32, BuildStorage, DispatchError, Perbill, TokenError,
|
||||
};
|
||||
use pretty_assertions::{assert_eq, assert_ne};
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Test>;
|
||||
|
||||
@@ -4533,7 +4533,8 @@ fn read_only_subsequent_call_cannot_store() {
|
||||
builder::bare_instantiate(Code::Upload(wasm_callee)).build_and_unwrap_account_id();
|
||||
|
||||
// Subsequent call input.
|
||||
let input = (&addr_callee, pezpallet_contracts_uapi::CallFlags::empty().bits(), 0u64, 100u32);
|
||||
let input =
|
||||
(&addr_callee, pezpallet_contracts_uapi::CallFlags::empty().bits(), 0u64, 100u32);
|
||||
|
||||
// Read-only call fails when modifying storage.
|
||||
assert_err_ignore_postinfo!(
|
||||
|
||||
@@ -520,9 +520,9 @@ mod tests {
|
||||
};
|
||||
use pezframe_system::pezpallet_prelude::BlockNumberFor;
|
||||
use pezpallet_contracts_uapi::ReturnFlags;
|
||||
use pretty_assertions::assert_eq;
|
||||
use pezsp_core::H256;
|
||||
use pezsp_runtime::DispatchError;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::{
|
||||
borrow::BorrowMut,
|
||||
cell::RefCell,
|
||||
|
||||
@@ -28,7 +28,7 @@ use alloc::{boxed::Box, vec, vec::Vec};
|
||||
use codec::{Decode, DecodeLimit, Encode, MaxEncodedLen};
|
||||
use core::fmt;
|
||||
use pezframe_support::{
|
||||
dispatch::DispatchInfo, ensure, pezpallet_prelude::DispatchResultWithPostInfo, parameter_types,
|
||||
dispatch::DispatchInfo, ensure, parameter_types, pezpallet_prelude::DispatchResultWithPostInfo,
|
||||
traits::Get, weights::Weight,
|
||||
};
|
||||
use pezpallet_contracts_proc_macro::define_env;
|
||||
@@ -61,8 +61,8 @@ pub enum AllowUnstableInterface {
|
||||
Yes,
|
||||
}
|
||||
|
||||
/// Trait implemented by the [`define_env`](pezpallet_contracts_proc_macro::define_env) macro for the
|
||||
/// emitted `Env` struct.
|
||||
/// Trait implemented by the [`define_env`](pezpallet_contracts_proc_macro::define_env) macro for
|
||||
/// the emitted `Env` struct.
|
||||
pub trait Environment<HostState> {
|
||||
/// Adds all declared functions to the supplied [`Linker`](wasmi::Linker) and
|
||||
/// [`Store`](wasmi::Store).
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
//! The conviction datatype.
|
||||
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::{
|
||||
traits::{Bounded, CheckedDiv, CheckedMul, Zero},
|
||||
RuntimeDebug,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
use crate::types::Delegations;
|
||||
|
||||
|
||||
@@ -173,8 +173,8 @@ pub mod pezpallet {
|
||||
>;
|
||||
|
||||
/// The voting classes which have a non-zero lock requirement and the lock amounts which they
|
||||
/// require. The actual amount locked on behalf of this pezpallet should always be the maximum of
|
||||
/// this list.
|
||||
/// require. The actual amount locked on behalf of this pezpallet should always be the maximum
|
||||
/// of this list.
|
||||
#[pezpallet::storage]
|
||||
pub type ClassLocksFor<T: Config<I>, I: 'static = ()> = StorageMap<
|
||||
_,
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
use crate::AccountVote;
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
|
||||
use pezframe_support::dispatch::DispatchResult;
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::RuntimeDebug;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
/// Represents the differents states of a referendum.
|
||||
#[derive(
|
||||
|
||||
@@ -22,11 +22,11 @@ use core::{fmt::Debug, marker::PhantomData};
|
||||
use pezframe_support::{
|
||||
traits::VoteTally, CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::{
|
||||
traits::{Saturating, Zero},
|
||||
RuntimeDebug,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
use super::*;
|
||||
use crate::{AccountVote, Conviction, Vote};
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
use crate::{Conviction, Delegations};
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode, EncodeLike, Input, MaxEncodedLen, Output};
|
||||
use pezframe_support::{pezpallet_prelude::Get, BoundedVec};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::{
|
||||
traits::{Saturating, Zero},
|
||||
RuntimeDebug,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
/// A number of lock periods, plus a vote, one way or the other.
|
||||
#[derive(
|
||||
|
||||
@@ -40,15 +40,15 @@
|
||||
//! - Pre-existing members may call `import_member` on themselves (formerly `import`) to have their
|
||||
//! rank recognised and be inducted into this pezpallet (to gain a salary and allow for eventual
|
||||
//! promotion).
|
||||
//! - If, externally to this pezpallet, a member or candidate has their rank removed completely, then
|
||||
//! `offboard` may be called to remove them entirely from this pezpallet.
|
||||
//! - If, externally to this pezpallet, a member or candidate has their rank removed completely,
|
||||
//! then `offboard` may be called to remove them entirely from this pezpallet.
|
||||
//!
|
||||
//! Note there is a difference between having a rank of 0 (whereby the account is a *candidate*) and
|
||||
//! having no rank at all (whereby we consider it *unranked*). An account can be demoted from rank
|
||||
//! 0 to become unranked. This process is called being offboarded and there is an extrinsic to do
|
||||
//! this explicitly when external factors to this pezpallet have caused the tracked account to become
|
||||
//! unranked. At rank 0, there is not a "demotion" period after which the account may be bumped to
|
||||
//! become offboarded but rather an "offboard timeout".
|
||||
//! this explicitly when external factors to this pezpallet have caused the tracked account to
|
||||
//! become unranked. At rank 0, there is not a "demotion" period after which the account may be
|
||||
//! bumped to become offboarded but rather an "offboard timeout".
|
||||
//!
|
||||
//! Candidates may be introduced (i.e. an account to go from unranked to rank of 0) by an origin
|
||||
//! of a different privilege to that for promotion. This allows the possibility for even a single
|
||||
@@ -64,9 +64,9 @@ extern crate alloc;
|
||||
use alloc::boxed::Box;
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
|
||||
use core::{fmt::Debug, marker::PhantomData};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_arithmetic::traits::{Saturating, Zero};
|
||||
use pezsp_runtime::RuntimeDebug;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
use pezframe_support::{
|
||||
defensive,
|
||||
@@ -219,8 +219,9 @@ pub mod pezpallet {
|
||||
/// The origin which has permission update the parameters.
|
||||
type ParamsOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// The origin which has permission to move a candidate into being tracked in this pezpallet.
|
||||
/// Generally a very low-permission, such as a pre-existing member of rank 1 or above.
|
||||
/// The origin which has permission to move a candidate into being tracked in this
|
||||
/// pezpallet. Generally a very low-permission, such as a pre-existing member of rank 1 or
|
||||
/// above.
|
||||
///
|
||||
/// This allows the candidate to deposit evidence for their request to be promoted to a
|
||||
/// member.
|
||||
@@ -739,7 +740,9 @@ pub mod pezpallet {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config<I>, I: 'static> GetSalary<RankOf<T, I>, T::AccountId, T::Balance> for Pezpallet<T, I> {
|
||||
impl<T: Config<I>, I: 'static> GetSalary<RankOf<T, I>, T::AccountId, T::Balance>
|
||||
for Pezpallet<T, I>
|
||||
{
|
||||
fn get_salary(rank: RankOf<T, I>, who: &T::AccountId) -> T::Balance {
|
||||
let index = match Self::rank_to_index(rank) {
|
||||
Some(i) => i,
|
||||
@@ -822,7 +825,8 @@ impl<T: Config<I>, I: 'static> RankedMembersSwapHandler<T::AccountId, u16> for P
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl<T: Config<I>, I: 'static>
|
||||
pezpallet_ranked_collective::BenchmarkSetup<<T as pezframe_system::Config>::AccountId> for Pezpallet<T, I>
|
||||
pezpallet_ranked_collective::BenchmarkSetup<<T as pezframe_system::Config>::AccountId>
|
||||
for Pezpallet<T, I>
|
||||
{
|
||||
fn ensure_member(who: &<T as pezframe_system::Config>::AccountId) {
|
||||
#[allow(deprecated)]
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
use pezframe_support::{
|
||||
assert_noop, assert_ok, derive_impl, hypothetically, hypothetically_ok, ord_parameter_types,
|
||||
pezpallet_prelude::Weight,
|
||||
parameter_types,
|
||||
pezpallet_prelude::Weight,
|
||||
traits::{ConstU16, EitherOf, IsInVec, MapSuccess, NoOpPoll, TryMapSuccess},
|
||||
};
|
||||
use pezframe_system::{pezpallet_prelude::BlockNumberFor, EnsureSignedBy};
|
||||
|
||||
@@ -23,13 +23,14 @@ use std::collections::BTreeMap;
|
||||
|
||||
use core::cell::RefCell;
|
||||
use pezframe_support::{
|
||||
assert_noop, assert_ok, derive_impl, hypothetically, ord_parameter_types,
|
||||
assert_noop, assert_ok, derive_impl, hypothetically, ord_parameter_types, parameter_types,
|
||||
pezpallet_prelude::Weight,
|
||||
parameter_types,
|
||||
traits::{tokens::GetSalary, ConstU16, ConstU32, IsInVec, TryMapSuccess},
|
||||
};
|
||||
use pezframe_system::EnsureSignedBy;
|
||||
use pezsp_runtime::{bounded_vec, traits::TryMorphInto, BuildStorage, DispatchError, DispatchResult};
|
||||
use pezsp_runtime::{
|
||||
bounded_vec, traits::TryMorphInto, BuildStorage, DispatchError, DispatchResult,
|
||||
};
|
||||
|
||||
use crate as pezpallet_core_fellowship;
|
||||
use crate::*;
|
||||
|
||||
@@ -107,7 +107,10 @@ impl<T: Config> DelegationMigrator for Pezpallet<T> {
|
||||
agent: Agent<Self::AccountId>,
|
||||
reward_account: &Self::AccountId,
|
||||
) -> DispatchResult {
|
||||
Pezpallet::<T>::migrate_to_agent(RawOrigin::Signed(agent.get()).into(), reward_account.clone())
|
||||
Pezpallet::<T>::migrate_to_agent(
|
||||
RawOrigin::Signed(agent.get()).into(),
|
||||
reward_account.clone(),
|
||||
)
|
||||
}
|
||||
fn migrate_delegation(
|
||||
agent: Agent<Self::AccountId>,
|
||||
|
||||
@@ -38,13 +38,13 @@
|
||||
//!
|
||||
//! ## Goals
|
||||
//!
|
||||
//! Direct nomination on the Staking pezpallet does not scale well. Nominations pools were created to
|
||||
//! address this by pooling delegator funds into one account and then staking it. This though had
|
||||
//! Direct nomination on the Staking pezpallet does not scale well. Nominations pools were created
|
||||
//! to address this by pooling delegator funds into one account and then staking it. This though had
|
||||
//! a very critical limitation that the funds were moved from delegator account to pool account
|
||||
//! and hence the delegator lost control over their funds for using it for other purposes such as
|
||||
//! governance. This pezpallet aims to solve this by extending the staking pezpallet to support a new
|
||||
//! primitive function: delegation of funds to an `agent` with the intent of staking. The agent can
|
||||
//! then stake the delegated funds to [`Config::CoreStaking`] on behalf of the delegators.
|
||||
//! governance. This pezpallet aims to solve this by extending the staking pezpallet to support a
|
||||
//! new primitive function: delegation of funds to an `agent` with the intent of staking. The agent
|
||||
//! can then stake the delegated funds to [`Config::CoreStaking`] on behalf of the delegators.
|
||||
//!
|
||||
//! ### Withdrawal Management
|
||||
//! Agent unbonding does not regulate ordering of consequent withdrawal for delegators. This is upto
|
||||
@@ -55,10 +55,10 @@
|
||||
//! This pezpallet does not enforce any specific strategy for how rewards or slashes are applied. It
|
||||
//! is upto the `agent` account to decide how to apply the rewards and slashes.
|
||||
//!
|
||||
//! This importantly allows clients of this pezpallet to build their own strategies for reward/slashes.
|
||||
//! For example, an `agent` account can choose to first slash the reward pot before slashing the
|
||||
//! delegators. Or part of the reward can go to an insurance fund that can be used to cover any
|
||||
//! potential future slashes. The goal is to eventually allow foreign MultiLocations
|
||||
//! This importantly allows clients of this pezpallet to build their own strategies for
|
||||
//! reward/slashes. For example, an `agent` account can choose to first slash the reward pot before
|
||||
//! slashing the delegators. Or part of the reward can go to an insurance fund that can be used to
|
||||
//! cover any potential future slashes. The goal is to eventually allow foreign MultiLocations
|
||||
//! (smart contracts or pallets on another chain) to build their own pooled staking solutions
|
||||
//! similar to `NominationPools`.
|
||||
|
||||
@@ -78,8 +78,8 @@
|
||||
//! One of the reasons why direct nominators on staking pezpallet cannot scale well is because all
|
||||
//! nominators are slashed at the same time. This is expensive and needs to be bounded operation.
|
||||
//!
|
||||
//! This pezpallet implements a lazy slashing mechanism. Any slashes to the `agent` are posted in its
|
||||
//! `AgentLedger` as a pending slash. Since the actual amount is held in the multiple
|
||||
//! This pezpallet implements a lazy slashing mechanism. Any slashes to the `agent` are posted in
|
||||
//! its `AgentLedger` as a pending slash. Since the actual amount is held in the multiple
|
||||
//! `delegator` accounts, this pezpallet has no way to know how to apply slash. It is the `agent`'s
|
||||
//! responsibility to apply slashes for each delegator, one at a time. Staking pezpallet ensures the
|
||||
//! pending slash never exceeds staked amount and would freeze further withdraws until all pending
|
||||
@@ -93,8 +93,8 @@
|
||||
//!
|
||||
//! ## Nomination Pool vs Delegation Staking
|
||||
//! This pezpallet is not a replacement for Nomination Pool but adds a new primitive in addition to
|
||||
//! staking pezpallet that can be used by Nomination Pool to support delegation based staking. It can
|
||||
//! be thought of as an extension to the Staking Pezpallet in relation to Nomination Pools.
|
||||
//! staking pezpallet that can be used by Nomination Pool to support delegation based staking. It
|
||||
//! can be thought of as an extension to the Staking Pezpallet in relation to Nomination Pools.
|
||||
//! Technically, these changes could be made in one of those pallets as well but that would have
|
||||
//! meant significant refactoring and high chances of introducing a regression. With this approach,
|
||||
//! we can keep the existing pallets with minimal changes and introduce a new pezpallet that can be
|
||||
@@ -191,7 +191,8 @@ pub mod pezpallet {
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// The overarching event type.
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// Injected identifier for the pezpallet.
|
||||
#[pezpallet::constant]
|
||||
@@ -787,7 +788,8 @@ impl<T: Config> Pezpallet<T> {
|
||||
ensure!(
|
||||
matches!(
|
||||
T::CoreStaking::status(&agent).expect("agent should be bonded"),
|
||||
pezsp_staking::StakerStatus::Nominator(_) | pezsp_staking::StakerStatus::Idle
|
||||
pezsp_staking::StakerStatus::Nominator(_) |
|
||||
pezsp_staking::StakerStatus::Idle
|
||||
),
|
||||
"agent should be bonded and not validator"
|
||||
);
|
||||
|
||||
@@ -84,7 +84,8 @@ pub mod unversioned {
|
||||
|
||||
Agents::<T>::iter_keys().take(MaxAgents::get() as usize).for_each(|agent| {
|
||||
let old_proxy: T::AccountId = old_proxy_delegator(agent.clone());
|
||||
let held_balance = Pezpallet::<T>::held_balance_of(Delegator::from(old_proxy.clone()));
|
||||
let held_balance =
|
||||
Pezpallet::<T>::held_balance_of(Delegator::from(old_proxy.clone()));
|
||||
let delegation = Delegation::<T>::get(&old_proxy);
|
||||
if delegation.is_some() || !held_balance.is_zero() {
|
||||
log!(
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
|
||||
use crate::{self as delegated_staking, types::AgentLedgerOuter};
|
||||
use pezframe_support::{
|
||||
assert_ok, derive_impl,
|
||||
assert_ok, derive_impl, parameter_types,
|
||||
pezpallet_prelude::*,
|
||||
parameter_types,
|
||||
traits::{ConstU64, Currency, VariantCountOf},
|
||||
PalletId,
|
||||
};
|
||||
|
||||
@@ -650,8 +650,8 @@ mod staking_integration {
|
||||
DelegatedStaking::generate_proxy_delegator(Agent::from(agent)).get();
|
||||
|
||||
assert_ok!(DelegatedStaking::migrate_to_agent(RawOrigin::Signed(agent).into(), 201));
|
||||
// after migration, no provider left since free balance is 0 and staking pezpallet released
|
||||
// all funds.
|
||||
// after migration, no provider left since free balance is 0 and staking pezpallet
|
||||
// released all funds.
|
||||
assert_eq!(System::providers(&agent), 0);
|
||||
assert_eq!(Balances::free_balance(agent), 0);
|
||||
// proxy delegator has one provider as well with no free balance.
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
use crate::types::Delegations;
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
|
||||
use core::result::Result;
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::{
|
||||
traits::{Bounded, CheckedDiv, CheckedMul, Zero},
|
||||
RuntimeDebug,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
/// A value denoting the strength of conviction of a vote.
|
||||
#[derive(
|
||||
|
||||
@@ -223,7 +223,8 @@ pub mod pezpallet {
|
||||
pub trait Config: pezframe_system::Config + Sized {
|
||||
type WeightInfo: WeightInfo;
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// The Scheduler.
|
||||
type Scheduler: ScheduleNamed<
|
||||
@@ -841,8 +842,8 @@ pub mod pezpallet {
|
||||
.try_insert(insert_position, who.clone())
|
||||
.map_err(|_| Error::<T>::TooMany)?;
|
||||
|
||||
let until =
|
||||
pezframe_system::Pezpallet::<T>::block_number().saturating_add(T::CooloffPeriod::get());
|
||||
let until = 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 });
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user