difftreelog
fix runtime benchmarks, `payout_stakers` logic, bencmarkr for payout_stakers
in: master
15 files changed
pallets/app-promotion/Cargo.tomldiffbeforeafterboth20 'frame-benchmarking',20 'frame-benchmarking',21 'frame-support/runtime-benchmarks',21 'frame-support/runtime-benchmarks',22 'frame-system/runtime-benchmarks',22 'frame-system/runtime-benchmarks',23 # 'pallet-unique/runtime-benchmarks',23]24]24std = [25std = [25 'codec/std',26 'codec/std',26 'serde/std',27 'frame-benchmarking/std',27 'frame-support/std',28 'frame-support/std',28 'frame-system/std',29 'frame-system/std',29 'pallet-balances/std',30 'pallet-balances/std',30 'pallet-timestamp/std',31 'pallet-timestamp/std',31 'pallet-randomness-collective-flip/std',32 'pallet-randomness-collective-flip/std',33 'pallet-evm/std',34 'sp-io/std',32 'sp-std/std',35 'sp-std/std',33 'sp-runtime/std',36 'sp-runtime/std',34 'frame-benchmarking/std',37 'sp-core/std',38 'serde/std',3935]40]3641pallets/app-promotion/src/benchmarking.rsdiffbeforeafterboth28use pallet_unique::benchmarking::create_nft_collection;28use pallet_unique::benchmarking::create_nft_collection;29use pallet_evm_migration::Pallet as EvmMigrationPallet;29use pallet_evm_migration::Pallet as EvmMigrationPallet;3031// trait BenchmarkingConfig: Config + pallet_unique::Config { }3233// impl<T: Config + pallet_unique::Config> BenchmarkingConfig for T { }343035const SEED: u32 = 0;31const SEED: u32 = 0;3253 } : {PromototionPallet::<T>::set_admin_address(RawOrigin::Root.into(), T::CrossAccountId::from_sub(pallet_admin))?}50 } : {PromototionPallet::<T>::set_admin_address(RawOrigin::Root.into(), T::CrossAccountId::from_sub(pallet_admin))?}545155 payout_stakers{52 payout_stakers{53 let b in 1..101;5456 let pallet_admin = account::<T::AccountId>("admin", 0, SEED);55 let pallet_admin = account::<T::AccountId>("admin", 0, SEED);57 let share = Perbill::from_rational(1u32, 100);56 let share = Perbill::from_rational(1u32, 20);58 PromototionPallet::<T>::set_admin_address(RawOrigin::Root.into(), T::CrossAccountId::from_sub(pallet_admin.clone()))?;57 PromototionPallet::<T>::set_admin_address(RawOrigin::Root.into(), T::CrossAccountId::from_sub(pallet_admin.clone()))?;59 let _ = <T as Config>::Currency::make_free_balance_be(&pallet_admin, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());58 <T as Config>::Currency::make_free_balance_be(&pallet_admin, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());5960 let staker: T::AccountId = account("caller", 0, SEED);60 let staker: T::AccountId = account("caller", 0, SEED);61 <T as Config>::Currency::make_free_balance_be(&staker, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());61 let stakers: Vec<T::AccountId> = (0..100).map(|index| account("staker", index, SEED)).collect();62 let stakers: Vec<T::AccountId> = (0..b).map(|index| account("staker", index, SEED)).collect();62 stakers.iter().for_each(|staker| {63 stakers.iter().for_each(|staker| {63 <T as Config>::Currency::make_free_balance_be(&staker, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());64 <T as Config>::Currency::make_free_balance_be(&staker, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());64 });65 });65 let _ = <T as Config>::Currency::make_free_balance_be(&staker, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());66 (0..10).try_for_each(|_| {67 stakers.iter()68 .map(|staker| {69 66 let _ = PromototionPallet::<T>::stake(RawOrigin::Signed(staker.clone()).into(), share * <T as Config>::Currency::total_balance(&staker))?;70 PromototionPallet::<T>::stake(RawOrigin::Signed(staker.clone()).into(), Into::<BalanceOf<T>>::into(100u128) * T::Nominal::get())71 }).collect::<Result<Vec<_>, _>>()?;72 <frame_system::Pallet<T>>::finalize();73 Result::<(), sp_runtime::DispatchError>::Ok(())74 })?;7576 // let _ = <T as Config>::Currency::make_free_balance_be(&staker, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());77 // let _ = PromototionPallet::<T>::stake(RawOrigin::Signed(staker.clone()).into(), share * <T as Config>::Currency::total_balance(&staker))?;67 } : {PromototionPallet::<T>::payout_stakers(RawOrigin::Signed(pallet_admin.clone()).into(), Some(1))?}78 } : {PromototionPallet::<T>::payout_stakers(RawOrigin::Signed(pallet_admin.clone()).into(), Some(b as u8))?}687969 stake {80 stake {70 let caller = account::<T::AccountId>("caller", 0, SEED);81 let caller = account::<T::AccountId>("caller", 0, SEED);76 let caller = account::<T::AccountId>("caller", 0, SEED);87 let caller = account::<T::AccountId>("caller", 0, SEED);77 let share = Perbill::from_rational(1u32, 20);88 let share = Perbill::from_rational(1u32, 20);78 let _ = <T as Config>::Currency::make_free_balance_be(&caller, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());89 let _ = <T as Config>::Currency::make_free_balance_be(&caller, Perbill::from_rational(1u32, 2) * BalanceOf::<T>::max_value());79 (0..10).map(|_| PromototionPallet::<T>::stake(RawOrigin::Signed(caller.clone()).into(), share * <T as Config>::Currency::total_balance(&caller))).collect::<Result<Vec<_>, _>>()?;90 (0..10).map(|_| {91 <frame_system::Pallet<T>>::finalize();92 PromototionPallet::<T>::stake(RawOrigin::Signed(caller.clone()).into(), share * <T as Config>::Currency::total_balance(&caller))93 }).collect::<Result<Vec<_>, _>>()?;809481 } : {PromototionPallet::<T>::unstake(RawOrigin::Signed(caller.clone()).into())?}95 } : {PromototionPallet::<T>::unstake(RawOrigin::Signed(caller.clone()).into())?}8296pallets/app-promotion/src/lib.rsdiffbeforeafterboth157 /// No permission to perform an action157 /// No permission to perform an action158 NoPermission,158 NoPermission,159 /// Insufficient funds to perform an action159 /// Insufficient funds to perform an action160 NotSufficientFounds,160 NotSufficientFunds,161 PendingForBlockOverflow,161 PendingForBlockOverflow,162 /// An error related to the fact that an invalid argument was passed to perform an action162 /// An error related to the fact that an invalid argument was passed to perform an action163 InvalidArgument,163 InvalidArgument,285 <<T as Config>::Currency as Currency<T::AccountId>>::ensure_can_withdraw(285 <<T as Config>::Currency as Currency<T::AccountId>>::ensure_can_withdraw(286 &staker_id,286 &staker_id,287 amount,287 amount,288 WithdrawReasons::all(),288 WithdrawReasons::RESERVE,289 balance - amount,289 balance - amount,290 )?;290 )?;291291292 Self::add_lock_balance(&staker_id, amount)?;292 Self::add_lock_balance(&staker_id, amount)?;293293294 let block_number = T::RelayBlockNumberProvider::current_block_number();294 let block_number = T::RelayBlockNumberProvider::current_block_number();295296 let recalculate_after_interval: T::BlockNumber =297 if block_number % T::RecalculationInterval::get() == 0u32.into() {298 1u32.into()299 } else {300 2u32.into()301 };302295 let recalc_block = (block_number / T::RecalculationInterval::get() + 2u32.into())303 let recalc_block = (block_number / T::RecalculationInterval::get()304 + recalculate_after_interval)296 * T::RecalculationInterval::get();305 * T::RecalculationInterval::get();297306298 <Staked<T>>::insert((&staker_id, block_number), {307 <Staked<T>>::insert((&staker_id, block_number), {428 T::ContractHandler::remove_contract_sponsor(contract_id)437 T::ContractHandler::remove_contract_sponsor(contract_id)429 }438 }430439431 #[pallet::weight(0)]440 #[pallet::weight(T::WeightInfo::payout_stakers(stakers_number.unwrap_or(20) as u32))]432 pub fn payout_stakers(admin: OriginFor<T>, stakers_number: Option<u8>) -> DispatchResult {441 pub fn payout_stakers(admin: OriginFor<T>, stakers_number: Option<u8>) -> DispatchResult {433 let admin_id = ensure_signed(admin)?;442 let admin_id = ensure_signed(admin)?;434443495 // }504 // }496 // }505 // }506507 // {508 // let mut stakers_number = stakers_number.unwrap_or(20);509 // let last_id = RefCell::new(None);510 // let income_acc = RefCell::new(BalanceOf::<T>::default());511 // let amount_acc = RefCell::new(BalanceOf::<T>::default());512513 // let flush_stake = || -> DispatchResult {514 // if let Some(last_id) = &*last_id.borrow() {515 // if !income_acc.borrow().is_zero() {516 // <T::Currency as Currency<T::AccountId>>::transfer(517 // &T::TreasuryAccountId::get(),518 // last_id,519 // *income_acc.borrow(),520 // ExistenceRequirement::KeepAlive,521 // )522 // .and_then(|_| {523 // Self::add_lock_balance(last_id, *income_acc.borrow());524 // <TotalStaked<T>>::try_mutate(|staked| {525 // staked526 // .checked_add(&*income_acc.borrow())527 // .ok_or(ArithmeticError::Overflow.into())528 // })529 // })?;530531 // Self::deposit_event(Event::StakingRecalculation(532 // last_id.clone(),533 // *amount_acc.borrow(),534 // *income_acc.borrow(),535 // ));536 // }537538 // *income_acc.borrow_mut() = BalanceOf::<T>::default();539 // *amount_acc.borrow_mut() = BalanceOf::<T>::default();540 // }541 // Ok(())542 // };543544 // while let Some((545 // (current_id, staked_block),546 // (amount, next_recalc_block_for_stake),547 // )) = storage_iterator.next()548 // {549 // if stakers_number == 0 {550 // NextCalculatedRecord::<T>::set(Some((current_id, staked_block)));551 // break;552 // }553 // stakers_number -= 1;554 // if last_id.borrow().as_ref() != Some(¤t_id) {555 // flush_stake()?;556 // };557 // *last_id.borrow_mut() = Some(current_id.clone());558 // if current_recalc_block >= next_recalc_block_for_stake {559 // *amount_acc.borrow_mut() += amount;560 // Self::recalculate_and_insert_stake(561 // ¤t_id,562 // staked_block,563 // next_recalc_block,564 // amount,565 // ((current_recalc_block - next_recalc_block_for_stake)566 // / T::RecalculationInterval::get())567 // .into() + 1,568 // &mut *income_acc.borrow_mut(),569 // );570 // }571 // }572 // flush_stake()?;573 // }497574498 {575 {499 let mut stakers_number = stakers_number.unwrap_or(20);576 let mut stakers_number = stakers_number.unwrap_or(20);510 *income_acc.borrow(),587 *income_acc.borrow(),511 ExistenceRequirement::KeepAlive,588 ExistenceRequirement::KeepAlive,512 )589 )513 .and_then(|_| Self::add_lock_balance(last_id, *income_acc.borrow()))?;590 .and_then(|_| {591 Self::add_lock_balance(last_id, *income_acc.borrow())?;592 <TotalStaked<T>>::try_mutate(|staked| {593 staked594 .checked_add(&*income_acc.borrow())595 .ok_or(ArithmeticError::Overflow.into())596 })597 })?;514598515 Self::deposit_event(Event::StakingRecalculation(599 Self::deposit_event(Event::StakingRecalculation(516 last_id.clone(),600 last_id.clone(),534 NextCalculatedRecord::<T>::set(Some((current_id, staked_block)));618 NextCalculatedRecord::<T>::set(Some((current_id, staked_block)));535 break;619 break;536 }620 }537 stakers_number -= 1;538 if last_id.borrow().as_ref() != Some(¤t_id) {621 if last_id.borrow().as_ref() != Some(¤t_id) {539 flush_stake()?;622 flush_stake()?;623 *last_id.borrow_mut() = Some(current_id.clone());624 stakers_number -= 1;540 };625 };541 *last_id.borrow_mut() = Some(current_id.clone());542 if current_recalc_block >= next_recalc_block_for_stake {626 if current_recalc_block >= next_recalc_block_for_stake {543 *amount_acc.borrow_mut() += amount;627 *amount_acc.borrow_mut() += amount;544 Self::recalculate_and_insert_stake(628 Self::recalculate_and_insert_stake(pallets/app-promotion/src/types.rsdiffbeforeafterboth1use codec::EncodeLike;1use codec::EncodeLike;2use frame_support::{2use frame_support::{traits::LockableCurrency, WeakBoundedVec, Parameter, dispatch::DispatchResult};3 traits::LockableCurrency, WeakBoundedVec, Parameter, dispatch::DispatchResult, ensure,4};536use pallet_balances::{BalanceLock, Config as BalancesConfig, Pallet as PalletBalances};4use pallet_balances::{BalanceLock, Config as BalancesConfig, Pallet as PalletBalances};pallets/app-promotion/src/weights.rsdiffbeforeafterboth3//! Autogenerated weights for pallet_app_promotion3//! Autogenerated weights for pallet_app_promotion4//!4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2022-09-01, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`6//! DATE: 2022-09-06, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 10247//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024889// Executed Command:9// Executed Command:35/// Weight functions needed for pallet_app_promotion.35/// Weight functions needed for pallet_app_promotion.36pub trait WeightInfo {36pub trait WeightInfo {37 fn set_admin_address() -> Weight;37 fn set_admin_address() -> Weight;38 fn payout_stakers() -> Weight;38 fn payout_stakers(b: u32, ) -> Weight;39 fn stake() -> Weight;39 fn stake() -> Weight;40 fn unstake() -> Weight;40 fn unstake() -> Weight;41 fn sponsor_collection() -> Weight;41 fn sponsor_collection() -> Weight;47/// Weights for pallet_app_promotion using the Substrate node and recommended hardware.47/// Weights for pallet_app_promotion using the Substrate node and recommended hardware.48pub struct SubstrateWeight<T>(PhantomData<T>);48pub struct SubstrateWeight<T>(PhantomData<T>);49impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {49impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {50 // Storage: Promotion Admin (r:0 w:1)50 // Storage: AppPromotion Admin (r:0 w:1)51 fn set_admin_address() -> Weight {51 fn set_admin_address() -> Weight {52 (515_000 as Weight)52 (5_297_000 as Weight)53 .saturating_add(T::DbWeight::get().writes(1 as Weight))53 .saturating_add(T::DbWeight::get().writes(1 as Weight))54 }54 }55 // Storage: Promotion Admin (r:1 w:0)55 // Storage: AppPromotion Admin (r:1 w:0)56 // Storage: ParachainSystem ValidationData (r:1 w:0)56 // Storage: ParachainSystem ValidationData (r:1 w:0)57 // Storage: Promotion NextCalculatedRecord (r:1 w:1)57 // Storage: AppPromotion NextCalculatedRecord (r:1 w:1)58 // Storage: Promotion Staked (r:2 w:0)58 // Storage: AppPromotion Staked (r:2 w:0)59 fn payout_stakers() -> Weight {59 fn payout_stakers(b: u32, ) -> Weight {60 (8_045_000 as Weight)61 // Standard Error: 19_00062 .saturating_add((4_778_000 as Weight).saturating_mul(b as Weight))60 (8_475_000 as Weight)63 .saturating_add(T::DbWeight::get().reads(4 as Weight))61 .saturating_add(T::DbWeight::get().reads(5 as Weight))64 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))62 .saturating_add(T::DbWeight::get().writes(1 as Weight))65 .saturating_add(T::DbWeight::get().writes(1 as Weight))63 }66 }64 // Storage: System Account (r:1 w:1)67 // Storage: System Account (r:1 w:1)65 // Storage: Promotion StakesPerAccount (r:1 w:1)68 // Storage: AppPromotion StakesPerAccount (r:1 w:1)66 // Storage: Balances Locks (r:1 w:1)69 // Storage: Balances Locks (r:1 w:1)67 // Storage: ParachainSystem ValidationData (r:1 w:0)70 // Storage: ParachainSystem ValidationData (r:1 w:0)68 // Storage: Promotion Staked (r:1 w:1)71 // Storage: AppPromotion Staked (r:1 w:1)69 // Storage: Promotion TotalStaked (r:1 w:1)72 // Storage: AppPromotion TotalStaked (r:1 w:1)70 fn stake() -> Weight {73 fn stake() -> Weight {71 (12_266_000 as Weight)74 (17_623_000 as Weight)72 .saturating_add(T::DbWeight::get().reads(6 as Weight))75 .saturating_add(T::DbWeight::get().reads(6 as Weight))73 .saturating_add(T::DbWeight::get().writes(5 as Weight))76 .saturating_add(T::DbWeight::get().writes(5 as Weight))74 }77 }78 // Storage: AppPromotion PendingUnstake (r:1 w:1)75 // Storage: Promotion Staked (r:2 w:1)79 // Storage: AppPromotion Staked (r:2 w:1)76 // Storage: ParachainSystem ValidationData (r:1 w:0)80 // Storage: Balances Locks (r:1 w:1)77 // Storage: Promotion PendingUnstake (r:1 w:1)81 // Storage: System Account (r:1 w:1)78 // Storage: Promotion TotalStaked (r:1 w:1)82 // Storage: AppPromotion TotalStaked (r:1 w:1)79 // Storage: Promotion StakesPerAccount (r:0 w:1)83 // Storage: AppPromotion StakesPerAccount (r:0 w:1)80 fn unstake() -> Weight {84 fn unstake() -> Weight {81 (10_663_000 as Weight)85 (27_190_000 as Weight)82 .saturating_add(T::DbWeight::get().reads(5 as Weight))86 .saturating_add(T::DbWeight::get().reads(6 as Weight))83 .saturating_add(T::DbWeight::get().writes(4 as Weight))87 .saturating_add(T::DbWeight::get().writes(6 as Weight))84 }88 }85 // Storage: Promotion Admin (r:1 w:0)89 // Storage: AppPromotion Admin (r:1 w:0)86 // Storage: Common CollectionById (r:1 w:1)90 // Storage: Common CollectionById (r:1 w:1)87 fn sponsor_collection() -> Weight {91 fn sponsor_collection() -> Weight {88 (10_879_000 as Weight)92 (11_351_000 as Weight)89 .saturating_add(T::DbWeight::get().reads(2 as Weight))93 .saturating_add(T::DbWeight::get().reads(2 as Weight))90 .saturating_add(T::DbWeight::get().writes(1 as Weight))94 .saturating_add(T::DbWeight::get().writes(1 as Weight))91 }95 }92 // Storage: Promotion Admin (r:1 w:0)96 // Storage: AppPromotion Admin (r:1 w:0)93 // Storage: Common CollectionById (r:1 w:1)97 // Storage: Common CollectionById (r:1 w:1)94 fn stop_sponsoring_collection() -> Weight {98 fn stop_sponsoring_collection() -> Weight {95 (10_548_000 as Weight)99 (10_687_000 as Weight)96 .saturating_add(T::DbWeight::get().reads(2 as Weight))100 .saturating_add(T::DbWeight::get().reads(2 as Weight))97 .saturating_add(T::DbWeight::get().writes(1 as Weight))101 .saturating_add(T::DbWeight::get().writes(1 as Weight))98 }102 }99 // Storage: Promotion Admin (r:1 w:0)103 // Storage: AppPromotion Admin (r:1 w:0)100 // Storage: EvmContractHelpers Sponsoring (r:0 w:1)104 // Storage: EvmContractHelpers Sponsoring (r:0 w:1)101 fn sponsor_contract() -> Weight {105 fn sponsor_contract() -> Weight {102 (2_130_000 as Weight)106 (2_332_000 as Weight)103 .saturating_add(T::DbWeight::get().reads(1 as Weight))107 .saturating_add(T::DbWeight::get().reads(1 as Weight))104 .saturating_add(T::DbWeight::get().writes(1 as Weight))108 .saturating_add(T::DbWeight::get().writes(1 as Weight))105 }109 }106 // Storage: Promotion Admin (r:1 w:0)110 // Storage: AppPromotion Admin (r:1 w:0)107 // Storage: EvmContractHelpers Sponsoring (r:1 w:1)111 // Storage: EvmContractHelpers Sponsoring (r:1 w:1)108 fn stop_sponsoring_contract() -> Weight {112 fn stop_sponsoring_contract() -> Weight {109 (3_509_000 as Weight)113 (3_712_000 as Weight)110 .saturating_add(T::DbWeight::get().reads(2 as Weight))114 .saturating_add(T::DbWeight::get().reads(2 as Weight))111 .saturating_add(T::DbWeight::get().writes(1 as Weight))115 .saturating_add(T::DbWeight::get().writes(1 as Weight))112 }116 }113}117}114118115// For backwards compatibility and tests119// For backwards compatibility and tests116impl WeightInfo for () {120impl WeightInfo for () {117 // Storage: Promotion Admin (r:0 w:1)121 // Storage: AppPromotion Admin (r:0 w:1)118 fn set_admin_address() -> Weight {122 fn set_admin_address() -> Weight {119 (515_000 as Weight)123 (5_297_000 as Weight)120 .saturating_add(RocksDbWeight::get().writes(1 as Weight))124 .saturating_add(RocksDbWeight::get().writes(1 as Weight))121 }125 }122 // Storage: Promotion Admin (r:1 w:0)126 // Storage: AppPromotion Admin (r:1 w:0)123 // Storage: ParachainSystem ValidationData (r:1 w:0)127 // Storage: ParachainSystem ValidationData (r:1 w:0)124 // Storage: Promotion NextCalculatedRecord (r:1 w:1)128 // Storage: AppPromotion NextCalculatedRecord (r:1 w:1)125 // Storage: Promotion Staked (r:2 w:0)129 // Storage: AppPromotion Staked (r:2 w:0)126 fn payout_stakers() -> Weight {130 fn payout_stakers(b: u32, ) -> Weight {131 (8_045_000 as Weight)132 // Standard Error: 19_000133 .saturating_add((4_778_000 as Weight).saturating_mul(b as Weight))127 (8_475_000 as Weight)134 .saturating_add(RocksDbWeight::get().reads(4 as Weight))128 .saturating_add(RocksDbWeight::get().reads(5 as Weight))135 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))129 .saturating_add(RocksDbWeight::get().writes(1 as Weight))136 .saturating_add(RocksDbWeight::get().writes(1 as Weight))130 }137 }131 // Storage: System Account (r:1 w:1)138 // Storage: System Account (r:1 w:1)132 // Storage: Promotion StakesPerAccount (r:1 w:1)139 // Storage: AppPromotion StakesPerAccount (r:1 w:1)133 // Storage: Balances Locks (r:1 w:1)140 // Storage: Balances Locks (r:1 w:1)134 // Storage: ParachainSystem ValidationData (r:1 w:0)141 // Storage: ParachainSystem ValidationData (r:1 w:0)135 // Storage: Promotion Staked (r:1 w:1)142 // Storage: AppPromotion Staked (r:1 w:1)136 // Storage: Promotion TotalStaked (r:1 w:1)143 // Storage: AppPromotion TotalStaked (r:1 w:1)137 fn stake() -> Weight {144 fn stake() -> Weight {138 (12_266_000 as Weight)145 (17_623_000 as Weight)139 .saturating_add(RocksDbWeight::get().reads(6 as Weight))146 .saturating_add(RocksDbWeight::get().reads(6 as Weight))140 .saturating_add(RocksDbWeight::get().writes(5 as Weight))147 .saturating_add(RocksDbWeight::get().writes(5 as Weight))141 }148 }149 // Storage: AppPromotion PendingUnstake (r:1 w:1)142 // Storage: Promotion Staked (r:2 w:1)150 // Storage: AppPromotion Staked (r:2 w:1)143 // Storage: ParachainSystem ValidationData (r:1 w:0)151 // Storage: Balances Locks (r:1 w:1)144 // Storage: Promotion PendingUnstake (r:1 w:1)152 // Storage: System Account (r:1 w:1)145 // Storage: Promotion TotalStaked (r:1 w:1)153 // Storage: AppPromotion TotalStaked (r:1 w:1)146 // Storage: Promotion StakesPerAccount (r:0 w:1)154 // Storage: AppPromotion StakesPerAccount (r:0 w:1)147 fn unstake() -> Weight {155 fn unstake() -> Weight {148 (10_663_000 as Weight)156 (27_190_000 as Weight)149 .saturating_add(RocksDbWeight::get().reads(5 as Weight))157 .saturating_add(RocksDbWeight::get().reads(6 as Weight))150 .saturating_add(RocksDbWeight::get().writes(4 as Weight))158 .saturating_add(RocksDbWeight::get().writes(6 as Weight))151 }159 }152 // Storage: Promotion Admin (r:1 w:0)160 // Storage: AppPromotion Admin (r:1 w:0)153 // Storage: Common CollectionById (r:1 w:1)161 // Storage: Common CollectionById (r:1 w:1)154 fn sponsor_collection() -> Weight {162 fn sponsor_collection() -> Weight {155 (10_879_000 as Weight)163 (11_351_000 as Weight)156 .saturating_add(RocksDbWeight::get().reads(2 as Weight))164 .saturating_add(RocksDbWeight::get().reads(2 as Weight))157 .saturating_add(RocksDbWeight::get().writes(1 as Weight))165 .saturating_add(RocksDbWeight::get().writes(1 as Weight))158 }166 }159 // Storage: Promotion Admin (r:1 w:0)167 // Storage: AppPromotion Admin (r:1 w:0)160 // Storage: Common CollectionById (r:1 w:1)168 // Storage: Common CollectionById (r:1 w:1)161 fn stop_sponsoring_collection() -> Weight {169 fn stop_sponsoring_collection() -> Weight {162 (10_548_000 as Weight)170 (10_687_000 as Weight)163 .saturating_add(RocksDbWeight::get().reads(2 as Weight))171 .saturating_add(RocksDbWeight::get().reads(2 as Weight))164 .saturating_add(RocksDbWeight::get().writes(1 as Weight))172 .saturating_add(RocksDbWeight::get().writes(1 as Weight))165 }173 }166 // Storage: Promotion Admin (r:1 w:0)174 // Storage: AppPromotion Admin (r:1 w:0)167 // Storage: EvmContractHelpers Sponsoring (r:0 w:1)175 // Storage: EvmContractHelpers Sponsoring (r:0 w:1)168 fn sponsor_contract() -> Weight {176 fn sponsor_contract() -> Weight {169 (2_130_000 as Weight)177 (2_332_000 as Weight)170 .saturating_add(RocksDbWeight::get().reads(1 as Weight))178 .saturating_add(RocksDbWeight::get().reads(1 as Weight))171 .saturating_add(RocksDbWeight::get().writes(1 as Weight))179 .saturating_add(RocksDbWeight::get().writes(1 as Weight))172 }180 }173 // Storage: Promotion Admin (r:1 w:0)181 // Storage: AppPromotion Admin (r:1 w:0)174 // Storage: EvmContractHelpers Sponsoring (r:1 w:1)182 // Storage: EvmContractHelpers Sponsoring (r:1 w:1)175 fn stop_sponsoring_contract() -> Weight {183 fn stop_sponsoring_contract() -> Weight {176 (3_509_000 as Weight)184 (3_712_000 as Weight)177 .saturating_add(RocksDbWeight::get().reads(2 as Weight))185 .saturating_add(RocksDbWeight::get().reads(2 as Weight))178 .saturating_add(RocksDbWeight::get().writes(1 as Weight))186 .saturating_add(RocksDbWeight::get().writes(1 as Weight))179 }187 }pallets/common/Cargo.tomldiffbeforeafterboth40 "up-data-structs/std",40 "up-data-structs/std",41 "pallet-evm/std",41 "pallet-evm/std",42]42]43runtime-benchmarks = ["frame-benchmarking"]43runtime-benchmarks = [44 "frame-benchmarking/runtime-benchmarks",45 "up-data-structs/runtime-benchmarks",46]4447runtime/common/config/pallets/app_promotion.rsdiffbeforeafterbothno syntactic changes
runtime/common/runtime_apis.rsdiffbeforeafterboth680 list_benchmark!(list, extra, pallet_unique, Unique);680 list_benchmark!(list, extra, pallet_unique, Unique);681 list_benchmark!(list, extra, pallet_structure, Structure);681 list_benchmark!(list, extra, pallet_structure, Structure);682 list_benchmark!(list, extra, pallet_inflation, Inflation);682 list_benchmark!(list, extra, pallet_inflation, Inflation);683 list_benchmark!(list, extra, pallet_app_promotion, Promotion);683 list_benchmark!(list, extra, pallet_app_promotion, AppPromotion);684 list_benchmark!(list, extra, pallet_fungible, Fungible);684 list_benchmark!(list, extra, pallet_fungible, Fungible);685 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);685 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);686686736 add_benchmark!(params, batches, pallet_unique, Unique);736 add_benchmark!(params, batches, pallet_unique, Unique);737 add_benchmark!(params, batches, pallet_structure, Structure);737 add_benchmark!(params, batches, pallet_structure, Structure);738 add_benchmark!(params, batches, pallet_inflation, Inflation);738 add_benchmark!(params, batches, pallet_inflation, Inflation);739 add_benchmark!(params, batches, pallet_app_promotion, Promotion);739 add_benchmark!(params, batches, pallet_app_promotion, AppPromotion);740 add_benchmark!(params, batches, pallet_fungible, Fungible);740 add_benchmark!(params, batches, pallet_fungible, Fungible);741 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);741 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);742742tests/src/interfaces/augment-api-consts.tsdiffbeforeafterboth16declare module '@polkadot/api-base/types/consts' {16declare module '@polkadot/api-base/types/consts' {17 interface AugmentedConsts<ApiType extends ApiTypes> {17 interface AugmentedConsts<ApiType extends ApiTypes> {18 appPromotion: {18 appPromotion: {19 /**20 * In chain blocks.21 **/22 day: u32 & AugmentedConst<ApiType>;23 intervalIncome: Perbill & AugmentedConst<ApiType>;19 intervalIncome: Perbill & AugmentedConst<ApiType>;24 nominal: u128 & AugmentedConst<ApiType>;20 nominal: u128 & AugmentedConst<ApiType>;25 /**21 /**tests/src/interfaces/augment-api-errors.tsdiffbeforeafterboth27 /**27 /**28 * Insufficient funds to perform an action28 * Insufficient funds to perform an action29 **/29 **/30 NotSufficientFounds: AugmentedError<ApiType>;30 NotSufficientFunds: AugmentedError<ApiType>;31 PendingForBlockOverflow: AugmentedError<ApiType>;31 PendingForBlockOverflow: AugmentedError<ApiType>;32 /**32 /**33 * Generic error33 * Generic errortests/src/interfaces/augment-api-events.tsdiffbeforeafterboth16declare module '@polkadot/api-base/types/events' {16declare module '@polkadot/api-base/types/events' {17 interface AugmentedEvents<ApiType extends ApiTypes> {17 interface AugmentedEvents<ApiType extends ApiTypes> {18 appPromotion: {18 appPromotion: {19 SetAdmin: AugmentedEvent<ApiType, [AccountId32]>;20 Stake: AugmentedEvent<ApiType, [AccountId32, u128]>;19 StakingRecalculation: AugmentedEvent<ApiType, [AccountId32, u128, u128]>;21 StakingRecalculation: AugmentedEvent<ApiType, [AccountId32, u128, u128]>;22 Unstake: AugmentedEvent<ApiType, [AccountId32, u128]>;20 /**23 /**21 * Generic event24 * Generic event22 **/25 **/tests/src/interfaces/augment-api-query.tsdiffbeforeafterboth36 * Amount of stakes for an Account36 * Amount of stakes for an Account37 **/37 **/38 stakesPerAccount: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<u8>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;38 stakesPerAccount: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<u8>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;39 /**40 * A block when app-promotion has started .I think this is redundant, because we only need `NextInterestBlock`.41 **/42 startBlock: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;43 totalStaked: AugmentedQuery<ApiType, () => Observable<u128>, []> & QueryableStorageEntry<ApiType, []>;39 totalStaked: AugmentedQuery<ApiType, () => Observable<u128>, []> & QueryableStorageEntry<ApiType, []>;44 /**40 /**45 * Generic query41 * Generic querytests/src/interfaces/default/types.tsdiffbeforeafterboth844export interface PalletAppPromotionError extends Enum {844export interface PalletAppPromotionError extends Enum {845 readonly isAdminNotSet: boolean;845 readonly isAdminNotSet: boolean;846 readonly isNoPermission: boolean;846 readonly isNoPermission: boolean;847 readonly isNotSufficientFounds: boolean;847 readonly isNotSufficientFunds: boolean;848 readonly isPendingForBlockOverflow: boolean;848 readonly isPendingForBlockOverflow: boolean;849 readonly isInvalidArgument: boolean;849 readonly isInvalidArgument: boolean;850 readonly type: 'AdminNotSet' | 'NoPermission' | 'NotSufficientFounds' | 'PendingForBlockOverflow' | 'InvalidArgument';850 readonly type: 'AdminNotSet' | 'NoPermission' | 'NotSufficientFunds' | 'PendingForBlockOverflow' | 'InvalidArgument';851}851}852852853/** @name PalletAppPromotionEvent */853/** @name PalletAppPromotionEvent */854export interface PalletAppPromotionEvent extends Enum {854export interface PalletAppPromotionEvent extends Enum {855 readonly isStakingRecalculation: boolean;855 readonly isStakingRecalculation: boolean;856 readonly asStakingRecalculation: ITuple<[AccountId32, u128, u128]>;856 readonly asStakingRecalculation: ITuple<[AccountId32, u128, u128]>;857 readonly isStake: boolean;858 readonly asStake: ITuple<[AccountId32, u128]>;859 readonly isUnstake: boolean;860 readonly asUnstake: ITuple<[AccountId32, u128]>;861 readonly isSetAdmin: boolean;862 readonly asSetAdmin: AccountId32;857 readonly type: 'StakingRecalculation';863 readonly type: 'StakingRecalculation' | 'Stake' | 'Unstake' | 'SetAdmin';858}864}859865860/** @name PalletBalancesAccountData */866/** @name PalletBalancesAccountData */tests/src/interfaces/lookup.tsdiffbeforeafterboth1061 **/1061 **/1062 PalletAppPromotionEvent: {1062 PalletAppPromotionEvent: {1063 _enum: {1063 _enum: {1064 StakingRecalculation: '(AccountId32,u128,u128)'1064 StakingRecalculation: '(AccountId32,u128,u128)',1065 Stake: '(AccountId32,u128)',1066 Unstake: '(AccountId32,u128)',1067 SetAdmin: 'AccountId32'1065 }1068 }1066 },1069 },1067 /**1070 /**3102 * Lookup415: pallet_app_promotion::pallet::Error<T>3105 * Lookup415: pallet_app_promotion::pallet::Error<T>3103 **/3106 **/3104 PalletAppPromotionError: {3107 PalletAppPromotionError: {3105 _enum: ['AdminNotSet', 'NoPermission', 'NotSufficientFounds', 'PendingForBlockOverflow', 'InvalidArgument']3108 _enum: ['AdminNotSet', 'NoPermission', 'NotSufficientFunds', 'PendingForBlockOverflow', 'InvalidArgument']3106 },3109 },3107 /**3110 /**3108 * Lookup418: pallet_evm::pallet::Error<T>3111 * Lookup418: pallet_evm::pallet::Error<T>tests/src/interfaces/types-lookup.tsdiffbeforeafterboth1202 interface PalletAppPromotionEvent extends Enum {1202 interface PalletAppPromotionEvent extends Enum {1203 readonly isStakingRecalculation: boolean;1203 readonly isStakingRecalculation: boolean;1204 readonly asStakingRecalculation: ITuple<[AccountId32, u128, u128]>;1204 readonly asStakingRecalculation: ITuple<[AccountId32, u128, u128]>;1205 readonly isStake: boolean;1206 readonly asStake: ITuple<[AccountId32, u128]>;1207 readonly isUnstake: boolean;1208 readonly asUnstake: ITuple<[AccountId32, u128]>;1209 readonly isSetAdmin: boolean;1210 readonly asSetAdmin: AccountId32;1205 readonly type: 'StakingRecalculation';1211 readonly type: 'StakingRecalculation' | 'Stake' | 'Unstake' | 'SetAdmin';1206 }1212 }120712131208 /** @name PalletEvmEvent (104) */1214 /** @name PalletEvmEvent (104) */3290 interface PalletAppPromotionError extends Enum {3296 interface PalletAppPromotionError extends Enum {3291 readonly isAdminNotSet: boolean;3297 readonly isAdminNotSet: boolean;3292 readonly isNoPermission: boolean;3298 readonly isNoPermission: boolean;3293 readonly isNotSufficientFounds: boolean;3299 readonly isNotSufficientFunds: boolean;3294 readonly isPendingForBlockOverflow: boolean;3300 readonly isPendingForBlockOverflow: boolean;3295 readonly isInvalidArgument: boolean;3301 readonly isInvalidArgument: boolean;3296 readonly type: 'AdminNotSet' | 'NoPermission' | 'NotSufficientFounds' | 'PendingForBlockOverflow' | 'InvalidArgument';3302 readonly type: 'AdminNotSet' | 'NoPermission' | 'NotSufficientFunds' | 'PendingForBlockOverflow' | 'InvalidArgument';3297 }3303 }329833043299 /** @name PalletEvmError (418) */3305 /** @name PalletEvmError (418) */