difftreelog
fix runtime benchmarks, `payout_stakers` logic, bencmarkr for payout_stakers
in: master
15 files changed
pallets/app-promotion/Cargo.tomldiffbeforeafterboth--- a/pallets/app-promotion/Cargo.toml
+++ b/pallets/app-promotion/Cargo.toml
@@ -20,18 +20,23 @@
'frame-benchmarking',
'frame-support/runtime-benchmarks',
'frame-system/runtime-benchmarks',
+ # 'pallet-unique/runtime-benchmarks',
]
std = [
'codec/std',
- 'serde/std',
+ 'frame-benchmarking/std',
'frame-support/std',
'frame-system/std',
'pallet-balances/std',
'pallet-timestamp/std',
'pallet-randomness-collective-flip/std',
+ 'pallet-evm/std',
+ 'sp-io/std',
'sp-std/std',
'sp-runtime/std',
- 'frame-benchmarking/std',
+ 'sp-core/std',
+ 'serde/std',
+
]
################################################################################
@@ -108,24 +113,24 @@
# local dependencies
[dependencies.up-data-structs]
default-features = false
-path = "../../primitives/data-structs"
+path = "../../primitives/data-structs"
[dependencies.pallet-common]
default-features = false
-path = "../common"
+path = "../common"
[dependencies.pallet-unique]
default-features = false
-path = "../unique"
+path = "../unique"
[dependencies.pallet-evm-contract-helpers]
default-features = false
-path = "../evm-contract-helpers"
+path = "../evm-contract-helpers"
[dev-dependencies]
[dependencies.pallet-evm-migration]
default-features = false
-path = "../evm-migration"
+path = "../evm-migration"
################################################################################
pallets/app-promotion/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/app-promotion/src/benchmarking.rs
+++ b/pallets/app-promotion/src/benchmarking.rs
@@ -28,11 +28,8 @@
use pallet_unique::benchmarking::create_nft_collection;
use pallet_evm_migration::Pallet as EvmMigrationPallet;
-// trait BenchmarkingConfig: Config + pallet_unique::Config { }
-
-// impl<T: Config + pallet_unique::Config> BenchmarkingConfig for T { }
+const SEED: u32 = 0;
-const SEED: u32 = 0;
benchmarks! {
where_clause{
where T: Config + pallet_unique::Config + pallet_evm_migration::Config ,
@@ -53,18 +50,32 @@
} : {PromototionPallet::<T>::set_admin_address(RawOrigin::Root.into(), T::CrossAccountId::from_sub(pallet_admin))?}
payout_stakers{
+ let b in 1..101;
+
let pallet_admin = account::<T::AccountId>("admin", 0, SEED);
- let share = Perbill::from_rational(1u32, 100);
+ let share = Perbill::from_rational(1u32, 20);
PromototionPallet::<T>::set_admin_address(RawOrigin::Root.into(), T::CrossAccountId::from_sub(pallet_admin.clone()))?;
- let _ = <T as Config>::Currency::make_free_balance_be(&pallet_admin, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());
+ <T as Config>::Currency::make_free_balance_be(&pallet_admin, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());
+
let staker: T::AccountId = account("caller", 0, SEED);
- let stakers: Vec<T::AccountId> = (0..100).map(|index| account("staker", index, SEED)).collect();
+ <T as Config>::Currency::make_free_balance_be(&staker, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());
+ let stakers: Vec<T::AccountId> = (0..b).map(|index| account("staker", index, SEED)).collect();
stakers.iter().for_each(|staker| {
<T as Config>::Currency::make_free_balance_be(&staker, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());
});
- let _ = <T as Config>::Currency::make_free_balance_be(&staker, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());
- let _ = PromototionPallet::<T>::stake(RawOrigin::Signed(staker.clone()).into(), share * <T as Config>::Currency::total_balance(&staker))?;
- } : {PromototionPallet::<T>::payout_stakers(RawOrigin::Signed(pallet_admin.clone()).into(), Some(1))?}
+ (0..10).try_for_each(|_| {
+ stakers.iter()
+ .map(|staker| {
+
+ PromototionPallet::<T>::stake(RawOrigin::Signed(staker.clone()).into(), Into::<BalanceOf<T>>::into(100u128) * T::Nominal::get())
+ }).collect::<Result<Vec<_>, _>>()?;
+ <frame_system::Pallet<T>>::finalize();
+ Result::<(), sp_runtime::DispatchError>::Ok(())
+ })?;
+
+ // let _ = <T as Config>::Currency::make_free_balance_be(&staker, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());
+ // let _ = PromototionPallet::<T>::stake(RawOrigin::Signed(staker.clone()).into(), share * <T as Config>::Currency::total_balance(&staker))?;
+ } : {PromototionPallet::<T>::payout_stakers(RawOrigin::Signed(pallet_admin.clone()).into(), Some(b as u8))?}
stake {
let caller = account::<T::AccountId>("caller", 0, SEED);
@@ -76,7 +87,10 @@
let caller = account::<T::AccountId>("caller", 0, SEED);
let share = Perbill::from_rational(1u32, 20);
let _ = <T as Config>::Currency::make_free_balance_be(&caller, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());
- (0..10).map(|_| PromototionPallet::<T>::stake(RawOrigin::Signed(caller.clone()).into(), share * <T as Config>::Currency::total_balance(&caller))).collect::<Result<Vec<_>, _>>()?;
+ (0..10).map(|_| {
+ <frame_system::Pallet<T>>::finalize();
+ PromototionPallet::<T>::stake(RawOrigin::Signed(caller.clone()).into(), share * <T as Config>::Currency::total_balance(&caller))
+ }).collect::<Result<Vec<_>, _>>()?;
} : {PromototionPallet::<T>::unstake(RawOrigin::Signed(caller.clone()).into())?}
pallets/app-promotion/src/lib.rsdiffbeforeafterboth--- a/pallets/app-promotion/src/lib.rs
+++ b/pallets/app-promotion/src/lib.rs
@@ -157,7 +157,7 @@
/// No permission to perform an action
NoPermission,
/// Insufficient funds to perform an action
- NotSufficientFounds,
+ NotSufficientFunds,
PendingForBlockOverflow,
/// An error related to the fact that an invalid argument was passed to perform an action
InvalidArgument,
@@ -285,14 +285,23 @@
<<T as Config>::Currency as Currency<T::AccountId>>::ensure_can_withdraw(
&staker_id,
amount,
- WithdrawReasons::all(),
+ WithdrawReasons::RESERVE,
balance - amount,
)?;
Self::add_lock_balance(&staker_id, amount)?;
let block_number = T::RelayBlockNumberProvider::current_block_number();
- let recalc_block = (block_number / T::RecalculationInterval::get() + 2u32.into())
+
+ let recalculate_after_interval: T::BlockNumber =
+ if block_number % T::RecalculationInterval::get() == 0u32.into() {
+ 1u32.into()
+ } else {
+ 2u32.into()
+ };
+
+ let recalc_block = (block_number / T::RecalculationInterval::get()
+ + recalculate_after_interval)
* T::RecalculationInterval::get();
<Staked<T>>::insert((&staker_id, block_number), {
@@ -428,7 +437,7 @@
T::ContractHandler::remove_contract_sponsor(contract_id)
}
- #[pallet::weight(0)]
+ #[pallet::weight(T::WeightInfo::payout_stakers(stakers_number.unwrap_or(20) as u32))]
pub fn payout_stakers(admin: OriginFor<T>, stakers_number: Option<u8>) -> DispatchResult {
let admin_id = ensure_signed(admin)?;
@@ -495,6 +504,74 @@
// }
// }
+ // {
+ // let mut stakers_number = stakers_number.unwrap_or(20);
+ // let last_id = RefCell::new(None);
+ // let income_acc = RefCell::new(BalanceOf::<T>::default());
+ // let amount_acc = RefCell::new(BalanceOf::<T>::default());
+
+ // let flush_stake = || -> DispatchResult {
+ // if let Some(last_id) = &*last_id.borrow() {
+ // if !income_acc.borrow().is_zero() {
+ // <T::Currency as Currency<T::AccountId>>::transfer(
+ // &T::TreasuryAccountId::get(),
+ // last_id,
+ // *income_acc.borrow(),
+ // ExistenceRequirement::KeepAlive,
+ // )
+ // .and_then(|_| {
+ // Self::add_lock_balance(last_id, *income_acc.borrow());
+ // <TotalStaked<T>>::try_mutate(|staked| {
+ // staked
+ // .checked_add(&*income_acc.borrow())
+ // .ok_or(ArithmeticError::Overflow.into())
+ // })
+ // })?;
+
+ // Self::deposit_event(Event::StakingRecalculation(
+ // last_id.clone(),
+ // *amount_acc.borrow(),
+ // *income_acc.borrow(),
+ // ));
+ // }
+
+ // *income_acc.borrow_mut() = BalanceOf::<T>::default();
+ // *amount_acc.borrow_mut() = BalanceOf::<T>::default();
+ // }
+ // Ok(())
+ // };
+
+ // while let Some((
+ // (current_id, staked_block),
+ // (amount, next_recalc_block_for_stake),
+ // )) = storage_iterator.next()
+ // {
+ // if stakers_number == 0 {
+ // NextCalculatedRecord::<T>::set(Some((current_id, staked_block)));
+ // break;
+ // }
+ // stakers_number -= 1;
+ // if last_id.borrow().as_ref() != Some(¤t_id) {
+ // flush_stake()?;
+ // };
+ // *last_id.borrow_mut() = Some(current_id.clone());
+ // if current_recalc_block >= next_recalc_block_for_stake {
+ // *amount_acc.borrow_mut() += amount;
+ // Self::recalculate_and_insert_stake(
+ // ¤t_id,
+ // staked_block,
+ // next_recalc_block,
+ // amount,
+ // ((current_recalc_block - next_recalc_block_for_stake)
+ // / T::RecalculationInterval::get())
+ // .into() + 1,
+ // &mut *income_acc.borrow_mut(),
+ // );
+ // }
+ // }
+ // flush_stake()?;
+ // }
+
{
let mut stakers_number = stakers_number.unwrap_or(20);
let last_id = RefCell::new(None);
@@ -510,7 +587,14 @@
*income_acc.borrow(),
ExistenceRequirement::KeepAlive,
)
- .and_then(|_| Self::add_lock_balance(last_id, *income_acc.borrow()))?;
+ .and_then(|_| {
+ Self::add_lock_balance(last_id, *income_acc.borrow())?;
+ <TotalStaked<T>>::try_mutate(|staked| {
+ staked
+ .checked_add(&*income_acc.borrow())
+ .ok_or(ArithmeticError::Overflow.into())
+ })
+ })?;
Self::deposit_event(Event::StakingRecalculation(
last_id.clone(),
@@ -534,11 +618,11 @@
NextCalculatedRecord::<T>::set(Some((current_id, staked_block)));
break;
}
- stakers_number -= 1;
if last_id.borrow().as_ref() != Some(¤t_id) {
flush_stake()?;
+ *last_id.borrow_mut() = Some(current_id.clone());
+ stakers_number -= 1;
};
- *last_id.borrow_mut() = Some(current_id.clone());
if current_recalc_block >= next_recalc_block_for_stake {
*amount_acc.borrow_mut() += amount;
Self::recalculate_and_insert_stake(
pallets/app-promotion/src/types.rsdiffbeforeafterboth--- a/pallets/app-promotion/src/types.rs
+++ b/pallets/app-promotion/src/types.rs
@@ -1,7 +1,5 @@
use codec::EncodeLike;
-use frame_support::{
- traits::LockableCurrency, WeakBoundedVec, Parameter, dispatch::DispatchResult, ensure,
-};
+use frame_support::{traits::LockableCurrency, WeakBoundedVec, Parameter, dispatch::DispatchResult};
use pallet_balances::{BalanceLock, Config as BalancesConfig, Pallet as PalletBalances};
use pallet_common::CollectionHandle;
pallets/app-promotion/src/weights.rsdiffbeforeafterboth--- a/pallets/app-promotion/src/weights.rs
+++ b/pallets/app-promotion/src/weights.rs
@@ -3,7 +3,7 @@
//! Autogenerated weights for pallet_app_promotion
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2022-09-01, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2022-09-06, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
// Executed Command:
@@ -35,7 +35,7 @@
/// Weight functions needed for pallet_app_promotion.
pub trait WeightInfo {
fn set_admin_address() -> Weight;
- fn payout_stakers() -> Weight;
+ fn payout_stakers(b: u32, ) -> Weight;
fn stake() -> Weight;
fn unstake() -> Weight;
fn sponsor_collection() -> Weight;
@@ -47,66 +47,70 @@
/// Weights for pallet_app_promotion using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
- // Storage: Promotion Admin (r:0 w:1)
+ // Storage: AppPromotion Admin (r:0 w:1)
fn set_admin_address() -> Weight {
- (515_000 as Weight)
+ (5_297_000 as Weight)
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
- // Storage: Promotion Admin (r:1 w:0)
+ // Storage: AppPromotion Admin (r:1 w:0)
// Storage: ParachainSystem ValidationData (r:1 w:0)
- // Storage: Promotion NextCalculatedRecord (r:1 w:1)
- // Storage: Promotion Staked (r:2 w:0)
- fn payout_stakers() -> Weight {
- (8_475_000 as Weight)
- .saturating_add(T::DbWeight::get().reads(5 as Weight))
+ // Storage: AppPromotion NextCalculatedRecord (r:1 w:1)
+ // Storage: AppPromotion Staked (r:2 w:0)
+ fn payout_stakers(b: u32, ) -> Weight {
+ (8_045_000 as Weight)
+ // Standard Error: 19_000
+ .saturating_add((4_778_000 as Weight).saturating_mul(b as Weight))
+ .saturating_add(T::DbWeight::get().reads(4 as Weight))
+ .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: System Account (r:1 w:1)
- // Storage: Promotion StakesPerAccount (r:1 w:1)
+ // Storage: AppPromotion StakesPerAccount (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: ParachainSystem ValidationData (r:1 w:0)
- // Storage: Promotion Staked (r:1 w:1)
- // Storage: Promotion TotalStaked (r:1 w:1)
+ // Storage: AppPromotion Staked (r:1 w:1)
+ // Storage: AppPromotion TotalStaked (r:1 w:1)
fn stake() -> Weight {
- (12_266_000 as Weight)
+ (17_623_000 as Weight)
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(5 as Weight))
}
- // Storage: Promotion Staked (r:2 w:1)
- // Storage: ParachainSystem ValidationData (r:1 w:0)
- // Storage: Promotion PendingUnstake (r:1 w:1)
- // Storage: Promotion TotalStaked (r:1 w:1)
- // Storage: Promotion StakesPerAccount (r:0 w:1)
+ // Storage: AppPromotion PendingUnstake (r:1 w:1)
+ // Storage: AppPromotion Staked (r:2 w:1)
+ // Storage: Balances Locks (r:1 w:1)
+ // Storage: System Account (r:1 w:1)
+ // Storage: AppPromotion TotalStaked (r:1 w:1)
+ // Storage: AppPromotion StakesPerAccount (r:0 w:1)
fn unstake() -> Weight {
- (10_663_000 as Weight)
- .saturating_add(T::DbWeight::get().reads(5 as Weight))
- .saturating_add(T::DbWeight::get().writes(4 as Weight))
+ (27_190_000 as Weight)
+ .saturating_add(T::DbWeight::get().reads(6 as Weight))
+ .saturating_add(T::DbWeight::get().writes(6 as Weight))
}
- // Storage: Promotion Admin (r:1 w:0)
+ // Storage: AppPromotion Admin (r:1 w:0)
// Storage: Common CollectionById (r:1 w:1)
fn sponsor_collection() -> Weight {
- (10_879_000 as Weight)
+ (11_351_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
- // Storage: Promotion Admin (r:1 w:0)
+ // Storage: AppPromotion Admin (r:1 w:0)
// Storage: Common CollectionById (r:1 w:1)
fn stop_sponsoring_collection() -> Weight {
- (10_548_000 as Weight)
+ (10_687_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
- // Storage: Promotion Admin (r:1 w:0)
+ // Storage: AppPromotion Admin (r:1 w:0)
// Storage: EvmContractHelpers Sponsoring (r:0 w:1)
fn sponsor_contract() -> Weight {
- (2_130_000 as Weight)
+ (2_332_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
- // Storage: Promotion Admin (r:1 w:0)
+ // Storage: AppPromotion Admin (r:1 w:0)
// Storage: EvmContractHelpers Sponsoring (r:1 w:1)
fn stop_sponsoring_contract() -> Weight {
- (3_509_000 as Weight)
+ (3_712_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -114,66 +118,70 @@
// For backwards compatibility and tests
impl WeightInfo for () {
- // Storage: Promotion Admin (r:0 w:1)
+ // Storage: AppPromotion Admin (r:0 w:1)
fn set_admin_address() -> Weight {
- (515_000 as Weight)
+ (5_297_000 as Weight)
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
- // Storage: Promotion Admin (r:1 w:0)
+ // Storage: AppPromotion Admin (r:1 w:0)
// Storage: ParachainSystem ValidationData (r:1 w:0)
- // Storage: Promotion NextCalculatedRecord (r:1 w:1)
- // Storage: Promotion Staked (r:2 w:0)
- fn payout_stakers() -> Weight {
- (8_475_000 as Weight)
- .saturating_add(RocksDbWeight::get().reads(5 as Weight))
+ // Storage: AppPromotion NextCalculatedRecord (r:1 w:1)
+ // Storage: AppPromotion Staked (r:2 w:0)
+ fn payout_stakers(b: u32, ) -> Weight {
+ (8_045_000 as Weight)
+ // Standard Error: 19_000
+ .saturating_add((4_778_000 as Weight).saturating_mul(b as Weight))
+ .saturating_add(RocksDbWeight::get().reads(4 as Weight))
+ .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
// Storage: System Account (r:1 w:1)
- // Storage: Promotion StakesPerAccount (r:1 w:1)
+ // Storage: AppPromotion StakesPerAccount (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: ParachainSystem ValidationData (r:1 w:0)
- // Storage: Promotion Staked (r:1 w:1)
- // Storage: Promotion TotalStaked (r:1 w:1)
+ // Storage: AppPromotion Staked (r:1 w:1)
+ // Storage: AppPromotion TotalStaked (r:1 w:1)
fn stake() -> Weight {
- (12_266_000 as Weight)
+ (17_623_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
.saturating_add(RocksDbWeight::get().writes(5 as Weight))
}
- // Storage: Promotion Staked (r:2 w:1)
- // Storage: ParachainSystem ValidationData (r:1 w:0)
- // Storage: Promotion PendingUnstake (r:1 w:1)
- // Storage: Promotion TotalStaked (r:1 w:1)
- // Storage: Promotion StakesPerAccount (r:0 w:1)
+ // Storage: AppPromotion PendingUnstake (r:1 w:1)
+ // Storage: AppPromotion Staked (r:2 w:1)
+ // Storage: Balances Locks (r:1 w:1)
+ // Storage: System Account (r:1 w:1)
+ // Storage: AppPromotion TotalStaked (r:1 w:1)
+ // Storage: AppPromotion StakesPerAccount (r:0 w:1)
fn unstake() -> Weight {
- (10_663_000 as Weight)
- .saturating_add(RocksDbWeight::get().reads(5 as Weight))
- .saturating_add(RocksDbWeight::get().writes(4 as Weight))
+ (27_190_000 as Weight)
+ .saturating_add(RocksDbWeight::get().reads(6 as Weight))
+ .saturating_add(RocksDbWeight::get().writes(6 as Weight))
}
- // Storage: Promotion Admin (r:1 w:0)
+ // Storage: AppPromotion Admin (r:1 w:0)
// Storage: Common CollectionById (r:1 w:1)
fn sponsor_collection() -> Weight {
- (10_879_000 as Weight)
+ (11_351_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
- // Storage: Promotion Admin (r:1 w:0)
+ // Storage: AppPromotion Admin (r:1 w:0)
// Storage: Common CollectionById (r:1 w:1)
fn stop_sponsoring_collection() -> Weight {
- (10_548_000 as Weight)
+ (10_687_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
- // Storage: Promotion Admin (r:1 w:0)
+ // Storage: AppPromotion Admin (r:1 w:0)
// Storage: EvmContractHelpers Sponsoring (r:0 w:1)
fn sponsor_contract() -> Weight {
- (2_130_000 as Weight)
+ (2_332_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
- // Storage: Promotion Admin (r:1 w:0)
+ // Storage: AppPromotion Admin (r:1 w:0)
// Storage: EvmContractHelpers Sponsoring (r:1 w:1)
fn stop_sponsoring_contract() -> Weight {
- (3_509_000 as Weight)
+ (3_712_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
pallets/common/Cargo.tomldiffbeforeafterboth--- a/pallets/common/Cargo.toml
+++ b/pallets/common/Cargo.toml
@@ -40,4 +40,7 @@
"up-data-structs/std",
"pallet-evm/std",
]
-runtime-benchmarks = ["frame-benchmarking"]
+runtime-benchmarks = [
+ "frame-benchmarking/runtime-benchmarks",
+ "up-data-structs/runtime-benchmarks",
+]
runtime/common/config/pallets/app_promotion.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/app_promotion.rs
+++ b/runtime/common/config/pallets/app_promotion.rs
@@ -22,7 +22,7 @@
use frame_support::{parameter_types, PalletId};
use sp_arithmetic::Perbill;
use up_common::{
- constants::{ UNIQUE, RELAY_DAYS},
+ constants::{UNIQUE, RELAY_DAYS},
types::Balance,
};
runtime/common/runtime_apis.rsdiffbeforeafterboth--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -680,7 +680,7 @@
list_benchmark!(list, extra, pallet_unique, Unique);
list_benchmark!(list, extra, pallet_structure, Structure);
list_benchmark!(list, extra, pallet_inflation, Inflation);
- list_benchmark!(list, extra, pallet_app_promotion, Promotion);
+ list_benchmark!(list, extra, pallet_app_promotion, AppPromotion);
list_benchmark!(list, extra, pallet_fungible, Fungible);
list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);
@@ -736,7 +736,7 @@
add_benchmark!(params, batches, pallet_unique, Unique);
add_benchmark!(params, batches, pallet_structure, Structure);
add_benchmark!(params, batches, pallet_inflation, Inflation);
- add_benchmark!(params, batches, pallet_app_promotion, Promotion);
+ add_benchmark!(params, batches, pallet_app_promotion, AppPromotion);
add_benchmark!(params, batches, pallet_fungible, Fungible);
add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);
tests/src/interfaces/augment-api-consts.tsdiffbeforeafterboth1// Auto-generated via `yarn polkadot-types-from-chain`, do not edit2/* eslint-disable */34// import type lookup before we augment - in some environments5// this is required to allow for ambient/previous definitions6import '@polkadot/api-base/types/consts';78import type { ApiTypes, AugmentedConst } from '@polkadot/api-base/types';9import type { Option, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';10import type { Codec } from '@polkadot/types-codec/types';11import type { Perbill, Permill } from '@polkadot/types/interfaces/runtime';12import type { FrameSupportPalletId, FrameSupportWeightsRuntimeDbWeight, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, SpVersionRuntimeVersion } from '@polkadot/types/lookup';1314export type __AugmentedConst<ApiType extends ApiTypes> = AugmentedConst<ApiType>;1516declare module '@polkadot/api-base/types/consts' {17 interface AugmentedConsts<ApiType extends ApiTypes> {18 appPromotion: {19 /**20 * In chain blocks.21 **/22 day: u32 & AugmentedConst<ApiType>;23 intervalIncome: Perbill & AugmentedConst<ApiType>;24 nominal: u128 & AugmentedConst<ApiType>;25 /**26 * The app's pallet id, used for deriving its sovereign account ID.27 **/28 palletId: FrameSupportPalletId & AugmentedConst<ApiType>;29 /**30 * In relay blocks.31 **/32 pendingInterval: u32 & AugmentedConst<ApiType>;33 /**34 * In relay blocks.35 **/36 recalculationInterval: u32 & AugmentedConst<ApiType>;37 /**38 * Generic const39 **/40 [key: string]: Codec;41 };42 balances: {43 /**44 * The minimum amount required to keep an account open.45 **/46 existentialDeposit: u128 & AugmentedConst<ApiType>;47 /**48 * The maximum number of locks that should exist on an account.49 * Not strictly enforced, but used for weight estimation.50 **/51 maxLocks: u32 & AugmentedConst<ApiType>;52 /**53 * The maximum number of named reserves that can exist on an account.54 **/55 maxReserves: u32 & AugmentedConst<ApiType>;56 /**57 * Generic const58 **/59 [key: string]: Codec;60 };61 common: {62 /**63 * Maximum admins per collection.64 **/65 collectionAdminsLimit: u32 & AugmentedConst<ApiType>;66 /**67 * Set price to create a collection.68 **/69 collectionCreationPrice: u128 & AugmentedConst<ApiType>;70 /**71 * Generic const72 **/73 [key: string]: Codec;74 };75 configuration: {76 defaultMinGasPrice: u64 & AugmentedConst<ApiType>;77 defaultWeightToFeeCoefficient: u32 & AugmentedConst<ApiType>;78 /**79 * Generic const80 **/81 [key: string]: Codec;82 };83 inflation: {84 /**85 * Number of blocks that pass between treasury balance updates due to inflation86 **/87 inflationBlockInterval: u32 & AugmentedConst<ApiType>;88 /**89 * Generic const90 **/91 [key: string]: Codec;92 };93 scheduler: {94 /**95 * The maximum weight that may be scheduled per block for any dispatchables of less96 * priority than `schedule::HARD_DEADLINE`.97 **/98 maximumWeight: u64 & AugmentedConst<ApiType>;99 /**100 * The maximum number of scheduled calls in the queue for a single block.101 * Not strictly enforced, but used for weight estimation.102 **/103 maxScheduledPerBlock: u32 & AugmentedConst<ApiType>;104 /**105 * Generic const106 **/107 [key: string]: Codec;108 };109 system: {110 /**111 * Maximum number of block number to block hash mappings to keep (oldest pruned first).112 **/113 blockHashCount: u32 & AugmentedConst<ApiType>;114 /**115 * The maximum length of a block (in bytes).116 **/117 blockLength: FrameSystemLimitsBlockLength & AugmentedConst<ApiType>;118 /**119 * Block & extrinsics weights: base values and limits.120 **/121 blockWeights: FrameSystemLimitsBlockWeights & AugmentedConst<ApiType>;122 /**123 * The weight of runtime database operations the runtime can invoke.124 **/125 dbWeight: FrameSupportWeightsRuntimeDbWeight & AugmentedConst<ApiType>;126 /**127 * The designated SS85 prefix of this chain.128 * 129 * This replaces the "ss58Format" property declared in the chain spec. Reason is130 * that the runtime should know about the prefix in order to make use of it as131 * an identifier of the chain.132 **/133 ss58Prefix: u16 & AugmentedConst<ApiType>;134 /**135 * Get the chain's current version.136 **/137 version: SpVersionRuntimeVersion & AugmentedConst<ApiType>;138 /**139 * Generic const140 **/141 [key: string]: Codec;142 };143 timestamp: {144 /**145 * The minimum period between blocks. Beware that this is different to the *expected*146 * period that the block production apparatus provides. Your chosen consensus system will147 * generally work with this to determine a sensible block time. e.g. For Aura, it will be148 * double this period on default settings.149 **/150 minimumPeriod: u64 & AugmentedConst<ApiType>;151 /**152 * Generic const153 **/154 [key: string]: Codec;155 };156 transactionPayment: {157 /**158 * A fee mulitplier for `Operational` extrinsics to compute "virtual tip" to boost their159 * `priority`160 * 161 * This value is multipled by the `final_fee` to obtain a "virtual tip" that is later162 * added to a tip component in regular `priority` calculations.163 * It means that a `Normal` transaction can front-run a similarly-sized `Operational`164 * extrinsic (with no tip), by including a tip value greater than the virtual tip.165 * 166 * ```rust,ignore167 * // For `Normal`168 * let priority = priority_calc(tip);169 * 170 * // For `Operational`171 * let virtual_tip = (inclusion_fee + tip) * OperationalFeeMultiplier;172 * let priority = priority_calc(tip + virtual_tip);173 * ```174 * 175 * Note that since we use `final_fee` the multiplier applies also to the regular `tip`176 * sent with the transaction. So, not only does the transaction get a priority bump based177 * on the `inclusion_fee`, but we also amplify the impact of tips applied to `Operational`178 * transactions.179 **/180 operationalFeeMultiplier: u8 & AugmentedConst<ApiType>;181 /**182 * Generic const183 **/184 [key: string]: Codec;185 };186 treasury: {187 /**188 * Percentage of spare funds (if any) that are burnt per spend period.189 **/190 burn: Permill & AugmentedConst<ApiType>;191 /**192 * The maximum number of approvals that can wait in the spending queue.193 * 194 * NOTE: This parameter is also used within the Bounties Pallet extension if enabled.195 **/196 maxApprovals: u32 & AugmentedConst<ApiType>;197 /**198 * The treasury's pallet id, used for deriving its sovereign account ID.199 **/200 palletId: FrameSupportPalletId & AugmentedConst<ApiType>;201 /**202 * Fraction of a proposal's value that should be bonded in order to place the proposal.203 * An accepted proposal gets these back. A rejected proposal does not.204 **/205 proposalBond: Permill & AugmentedConst<ApiType>;206 /**207 * Maximum amount of funds that should be placed in a deposit for making a proposal.208 **/209 proposalBondMaximum: Option<u128> & AugmentedConst<ApiType>;210 /**211 * Minimum amount of funds that should be placed in a deposit for making a proposal.212 **/213 proposalBondMinimum: u128 & AugmentedConst<ApiType>;214 /**215 * Period between successive spends.216 **/217 spendPeriod: u32 & AugmentedConst<ApiType>;218 /**219 * Generic const220 **/221 [key: string]: Codec;222 };223 vesting: {224 /**225 * The minimum amount transferred to call `vested_transfer`.226 **/227 minVestedTransfer: u128 & AugmentedConst<ApiType>;228 /**229 * Generic const230 **/231 [key: string]: Codec;232 };233 } // AugmentedConsts234} // declare module1// Auto-generated via `yarn polkadot-types-from-chain`, do not edit2/* eslint-disable */34// import type lookup before we augment - in some environments5// this is required to allow for ambient/previous definitions6import '@polkadot/api-base/types/consts';78import type { ApiTypes, AugmentedConst } from '@polkadot/api-base/types';9import type { Option, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';10import type { Codec } from '@polkadot/types-codec/types';11import type { Perbill, Permill } from '@polkadot/types/interfaces/runtime';12import type { FrameSupportPalletId, FrameSupportWeightsRuntimeDbWeight, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, SpVersionRuntimeVersion } from '@polkadot/types/lookup';1314export type __AugmentedConst<ApiType extends ApiTypes> = AugmentedConst<ApiType>;1516declare module '@polkadot/api-base/types/consts' {17 interface AugmentedConsts<ApiType extends ApiTypes> {18 appPromotion: {19 intervalIncome: Perbill & AugmentedConst<ApiType>;20 nominal: u128 & AugmentedConst<ApiType>;21 /**22 * The app's pallet id, used for deriving its sovereign account ID.23 **/24 palletId: FrameSupportPalletId & AugmentedConst<ApiType>;25 /**26 * In relay blocks.27 **/28 pendingInterval: u32 & AugmentedConst<ApiType>;29 /**30 * In relay blocks.31 **/32 recalculationInterval: u32 & AugmentedConst<ApiType>;33 /**34 * Generic const35 **/36 [key: string]: Codec;37 };38 balances: {39 /**40 * The minimum amount required to keep an account open.41 **/42 existentialDeposit: u128 & AugmentedConst<ApiType>;43 /**44 * The maximum number of locks that should exist on an account.45 * Not strictly enforced, but used for weight estimation.46 **/47 maxLocks: u32 & AugmentedConst<ApiType>;48 /**49 * The maximum number of named reserves that can exist on an account.50 **/51 maxReserves: u32 & AugmentedConst<ApiType>;52 /**53 * Generic const54 **/55 [key: string]: Codec;56 };57 common: {58 /**59 * Maximum admins per collection.60 **/61 collectionAdminsLimit: u32 & AugmentedConst<ApiType>;62 /**63 * Set price to create a collection.64 **/65 collectionCreationPrice: u128 & AugmentedConst<ApiType>;66 /**67 * Generic const68 **/69 [key: string]: Codec;70 };71 configuration: {72 defaultMinGasPrice: u64 & AugmentedConst<ApiType>;73 defaultWeightToFeeCoefficient: u32 & AugmentedConst<ApiType>;74 /**75 * Generic const76 **/77 [key: string]: Codec;78 };79 inflation: {80 /**81 * Number of blocks that pass between treasury balance updates due to inflation82 **/83 inflationBlockInterval: u32 & AugmentedConst<ApiType>;84 /**85 * Generic const86 **/87 [key: string]: Codec;88 };89 scheduler: {90 /**91 * The maximum weight that may be scheduled per block for any dispatchables of less92 * priority than `schedule::HARD_DEADLINE`.93 **/94 maximumWeight: u64 & AugmentedConst<ApiType>;95 /**96 * The maximum number of scheduled calls in the queue for a single block.97 * Not strictly enforced, but used for weight estimation.98 **/99 maxScheduledPerBlock: u32 & AugmentedConst<ApiType>;100 /**101 * Generic const102 **/103 [key: string]: Codec;104 };105 system: {106 /**107 * Maximum number of block number to block hash mappings to keep (oldest pruned first).108 **/109 blockHashCount: u32 & AugmentedConst<ApiType>;110 /**111 * The maximum length of a block (in bytes).112 **/113 blockLength: FrameSystemLimitsBlockLength & AugmentedConst<ApiType>;114 /**115 * Block & extrinsics weights: base values and limits.116 **/117 blockWeights: FrameSystemLimitsBlockWeights & AugmentedConst<ApiType>;118 /**119 * The weight of runtime database operations the runtime can invoke.120 **/121 dbWeight: FrameSupportWeightsRuntimeDbWeight & AugmentedConst<ApiType>;122 /**123 * The designated SS85 prefix of this chain.124 * 125 * This replaces the "ss58Format" property declared in the chain spec. Reason is126 * that the runtime should know about the prefix in order to make use of it as127 * an identifier of the chain.128 **/129 ss58Prefix: u16 & AugmentedConst<ApiType>;130 /**131 * Get the chain's current version.132 **/133 version: SpVersionRuntimeVersion & AugmentedConst<ApiType>;134 /**135 * Generic const136 **/137 [key: string]: Codec;138 };139 timestamp: {140 /**141 * The minimum period between blocks. Beware that this is different to the *expected*142 * period that the block production apparatus provides. Your chosen consensus system will143 * generally work with this to determine a sensible block time. e.g. For Aura, it will be144 * double this period on default settings.145 **/146 minimumPeriod: u64 & AugmentedConst<ApiType>;147 /**148 * Generic const149 **/150 [key: string]: Codec;151 };152 transactionPayment: {153 /**154 * A fee mulitplier for `Operational` extrinsics to compute "virtual tip" to boost their155 * `priority`156 * 157 * This value is multipled by the `final_fee` to obtain a "virtual tip" that is later158 * added to a tip component in regular `priority` calculations.159 * It means that a `Normal` transaction can front-run a similarly-sized `Operational`160 * extrinsic (with no tip), by including a tip value greater than the virtual tip.161 * 162 * ```rust,ignore163 * // For `Normal`164 * let priority = priority_calc(tip);165 * 166 * // For `Operational`167 * let virtual_tip = (inclusion_fee + tip) * OperationalFeeMultiplier;168 * let priority = priority_calc(tip + virtual_tip);169 * ```170 * 171 * Note that since we use `final_fee` the multiplier applies also to the regular `tip`172 * sent with the transaction. So, not only does the transaction get a priority bump based173 * on the `inclusion_fee`, but we also amplify the impact of tips applied to `Operational`174 * transactions.175 **/176 operationalFeeMultiplier: u8 & AugmentedConst<ApiType>;177 /**178 * Generic const179 **/180 [key: string]: Codec;181 };182 treasury: {183 /**184 * Percentage of spare funds (if any) that are burnt per spend period.185 **/186 burn: Permill & AugmentedConst<ApiType>;187 /**188 * The maximum number of approvals that can wait in the spending queue.189 * 190 * NOTE: This parameter is also used within the Bounties Pallet extension if enabled.191 **/192 maxApprovals: u32 & AugmentedConst<ApiType>;193 /**194 * The treasury's pallet id, used for deriving its sovereign account ID.195 **/196 palletId: FrameSupportPalletId & AugmentedConst<ApiType>;197 /**198 * Fraction of a proposal's value that should be bonded in order to place the proposal.199 * An accepted proposal gets these back. A rejected proposal does not.200 **/201 proposalBond: Permill & AugmentedConst<ApiType>;202 /**203 * Maximum amount of funds that should be placed in a deposit for making a proposal.204 **/205 proposalBondMaximum: Option<u128> & AugmentedConst<ApiType>;206 /**207 * Minimum amount of funds that should be placed in a deposit for making a proposal.208 **/209 proposalBondMinimum: u128 & AugmentedConst<ApiType>;210 /**211 * Period between successive spends.212 **/213 spendPeriod: u32 & AugmentedConst<ApiType>;214 /**215 * Generic const216 **/217 [key: string]: Codec;218 };219 vesting: {220 /**221 * The minimum amount transferred to call `vested_transfer`.222 **/223 minVestedTransfer: u128 & AugmentedConst<ApiType>;224 /**225 * Generic const226 **/227 [key: string]: Codec;228 };229 } // AugmentedConsts230} // declare moduletests/src/interfaces/augment-api-errors.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-errors.ts
+++ b/tests/src/interfaces/augment-api-errors.ts
@@ -27,7 +27,7 @@
/**
* Insufficient funds to perform an action
**/
- NotSufficientFounds: AugmentedError<ApiType>;
+ NotSufficientFunds: AugmentedError<ApiType>;
PendingForBlockOverflow: AugmentedError<ApiType>;
/**
* Generic error
tests/src/interfaces/augment-api-events.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-events.ts
+++ b/tests/src/interfaces/augment-api-events.ts
@@ -16,7 +16,10 @@
declare module '@polkadot/api-base/types/events' {
interface AugmentedEvents<ApiType extends ApiTypes> {
appPromotion: {
+ SetAdmin: AugmentedEvent<ApiType, [AccountId32]>;
+ Stake: AugmentedEvent<ApiType, [AccountId32, u128]>;
StakingRecalculation: AugmentedEvent<ApiType, [AccountId32, u128, u128]>;
+ Unstake: AugmentedEvent<ApiType, [AccountId32, u128]>;
/**
* Generic event
**/
tests/src/interfaces/augment-api-query.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-query.ts
+++ b/tests/src/interfaces/augment-api-query.ts
@@ -36,10 +36,6 @@
* Amount of stakes for an Account
**/
stakesPerAccount: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<u8>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
- /**
- * A block when app-promotion has started .I think this is redundant, because we only need `NextInterestBlock`.
- **/
- startBlock: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
totalStaked: AugmentedQuery<ApiType, () => Observable<u128>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Generic query
tests/src/interfaces/default/types.tsdiffbeforeafterboth--- a/tests/src/interfaces/default/types.ts
+++ b/tests/src/interfaces/default/types.ts
@@ -844,17 +844,23 @@
export interface PalletAppPromotionError extends Enum {
readonly isAdminNotSet: boolean;
readonly isNoPermission: boolean;
- readonly isNotSufficientFounds: boolean;
+ readonly isNotSufficientFunds: boolean;
readonly isPendingForBlockOverflow: boolean;
readonly isInvalidArgument: boolean;
- readonly type: 'AdminNotSet' | 'NoPermission' | 'NotSufficientFounds' | 'PendingForBlockOverflow' | 'InvalidArgument';
+ readonly type: 'AdminNotSet' | 'NoPermission' | 'NotSufficientFunds' | 'PendingForBlockOverflow' | 'InvalidArgument';
}
/** @name PalletAppPromotionEvent */
export interface PalletAppPromotionEvent extends Enum {
readonly isStakingRecalculation: boolean;
readonly asStakingRecalculation: ITuple<[AccountId32, u128, u128]>;
- readonly type: 'StakingRecalculation';
+ readonly isStake: boolean;
+ readonly asStake: ITuple<[AccountId32, u128]>;
+ readonly isUnstake: boolean;
+ readonly asUnstake: ITuple<[AccountId32, u128]>;
+ readonly isSetAdmin: boolean;
+ readonly asSetAdmin: AccountId32;
+ readonly type: 'StakingRecalculation' | 'Stake' | 'Unstake' | 'SetAdmin';
}
/** @name PalletBalancesAccountData */
tests/src/interfaces/lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -1061,7 +1061,10 @@
**/
PalletAppPromotionEvent: {
_enum: {
- StakingRecalculation: '(AccountId32,u128,u128)'
+ StakingRecalculation: '(AccountId32,u128,u128)',
+ Stake: '(AccountId32,u128)',
+ Unstake: '(AccountId32,u128)',
+ SetAdmin: 'AccountId32'
}
},
/**
@@ -3102,7 +3105,7 @@
* Lookup415: pallet_app_promotion::pallet::Error<T>
**/
PalletAppPromotionError: {
- _enum: ['AdminNotSet', 'NoPermission', 'NotSufficientFounds', 'PendingForBlockOverflow', 'InvalidArgument']
+ _enum: ['AdminNotSet', 'NoPermission', 'NotSufficientFunds', 'PendingForBlockOverflow', 'InvalidArgument']
},
/**
* Lookup418: pallet_evm::pallet::Error<T>
tests/src/interfaces/types-lookup.tsdiffbeforeafterboth--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -1202,7 +1202,13 @@
interface PalletAppPromotionEvent extends Enum {
readonly isStakingRecalculation: boolean;
readonly asStakingRecalculation: ITuple<[AccountId32, u128, u128]>;
- readonly type: 'StakingRecalculation';
+ readonly isStake: boolean;
+ readonly asStake: ITuple<[AccountId32, u128]>;
+ readonly isUnstake: boolean;
+ readonly asUnstake: ITuple<[AccountId32, u128]>;
+ readonly isSetAdmin: boolean;
+ readonly asSetAdmin: AccountId32;
+ readonly type: 'StakingRecalculation' | 'Stake' | 'Unstake' | 'SetAdmin';
}
/** @name PalletEvmEvent (104) */
@@ -3290,10 +3296,10 @@
interface PalletAppPromotionError extends Enum {
readonly isAdminNotSet: boolean;
readonly isNoPermission: boolean;
- readonly isNotSufficientFounds: boolean;
+ readonly isNotSufficientFunds: boolean;
readonly isPendingForBlockOverflow: boolean;
readonly isInvalidArgument: boolean;
- readonly type: 'AdminNotSet' | 'NoPermission' | 'NotSufficientFounds' | 'PendingForBlockOverflow' | 'InvalidArgument';
+ readonly type: 'AdminNotSet' | 'NoPermission' | 'NotSufficientFunds' | 'PendingForBlockOverflow' | 'InvalidArgument';
}
/** @name PalletEvmError (418) */