From e65062ff1797a2e813d20116f11d0e3ebacb3a21 Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Fri, 2 Feb 2024 15:27:51 +0100 Subject: [PATCH 01/14] dApp staking v3 & Tokenomics 2.0 - Shiden Integration --- Cargo.lock | 9 +- runtime/shiden/Cargo.toml | 28 +- runtime/shiden/src/lib.rs | 330 ++++++++++--- runtime/shiden/src/precompiles.rs | 6 +- runtime/shiden/src/weights/mod.rs | 2 + .../src/weights/pallet_dapp_staking_v3.rs | 432 ++++++++++++++++++ .../shiden/src/weights/pallet_inflation.rs | 102 +++++ 7 files changed, 832 insertions(+), 77 deletions(-) create mode 100644 runtime/shiden/src/weights/pallet_dapp_staking_v3.rs create mode 100644 runtime/shiden/src/weights/pallet_inflation.rs diff --git a/Cargo.lock b/Cargo.lock index 1049277c7d..717e1ccedb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13314,6 +13314,7 @@ dependencies = [ "cumulus-primitives-core", "cumulus-primitives-timestamp", "cumulus-primitives-utility", + "dapp-staking-v3-runtime-api", "fp-rpc", "fp-self-contained", "frame-benchmarking", @@ -13335,11 +13336,12 @@ dependencies = [ "pallet-aura", "pallet-authorship", "pallet-balances", - "pallet-block-rewards-hybrid", "pallet-collator-selection", "pallet-collective", "pallet-contracts", "pallet-contracts-primitives", + "pallet-dapp-staking-migration", + "pallet-dapp-staking-v3", "pallet-dapps-staking", "pallet-dynamic-evm-base-fee", "pallet-ethereum", @@ -13347,7 +13349,7 @@ dependencies = [ "pallet-evm-precompile-assets-erc20", "pallet-evm-precompile-blake2", "pallet-evm-precompile-bn128", - "pallet-evm-precompile-dapps-staking", + "pallet-evm-precompile-dapp-staking-v3", "pallet-evm-precompile-dispatch", "pallet-evm-precompile-ed25519", "pallet-evm-precompile-modexp", @@ -13357,10 +13359,12 @@ dependencies = [ "pallet-evm-precompile-substrate-ecdsa", "pallet-evm-precompile-xcm", "pallet-identity", + "pallet-inflation", "pallet-insecure-randomness-collective-flip", "pallet-multisig", "pallet-proxy", "pallet-session", + "pallet-static-price-provider", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", @@ -13378,6 +13382,7 @@ dependencies = [ "scale-info", "smallvec 1.11.0", "sp-api", + "sp-arithmetic", "sp-block-builder", "sp-consensus-aura", "sp-core", diff --git a/runtime/shiden/Cargo.toml b/runtime/shiden/Cargo.toml index 400c0cb5b8..964588cdce 100644 --- a/runtime/shiden/Cargo.toml +++ b/runtime/shiden/Cargo.toml @@ -21,6 +21,7 @@ fp-rpc = { workspace = true } fp-self-contained = { workspace = true } sp-api = { workspace = true } +sp-arithmetic = { workspace = true } sp-block-builder = { workspace = true } sp-consensus-aura = { workspace = true } sp-core = { workspace = true } @@ -101,17 +102,22 @@ frame-try-runtime = { workspace = true, optional = true } # Astar pallets astar-primitives = { workspace = true } -pallet-block-rewards-hybrid = { workspace = true } pallet-collator-selection = { workspace = true } +pallet-dapp-staking-migration = { workspace = true } +pallet-dapp-staking-v3 = { workspace = true } pallet-dapps-staking = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } -pallet-evm-precompile-dapps-staking = { workspace = true } +pallet-evm-precompile-dapp-staking-v3 = { workspace = true } pallet-evm-precompile-sr25519 = { workspace = true } pallet-evm-precompile-substrate-ecdsa = { workspace = true } pallet-evm-precompile-xcm = { workspace = true } +pallet-inflation = { workspace = true } +pallet-static-price-provider = { workspace = true } pallet-xc-asset-config = { workspace = true } pallet-xcm = { workspace = true } +dapp-staking-v3-runtime-api = { workspace = true } + precompile-utils = { workspace = true } # Moonbeam tracing @@ -132,8 +138,10 @@ std = [ "sp-api/std", "sp-core/std", "sp-consensus-aura/std", + "sp-arithmetic/std", "sp-io/std", "sp-runtime/std", + "pallet-static-price-provider/std", "sp-runtime-interface/std", "sp-version/std", "sp-block-builder/std", @@ -150,7 +158,6 @@ std = [ "pallet-contracts/std", "pallet-collective/std", "pallet-contracts-primitives/std", - "pallet-block-rewards-hybrid/std", "pallet-dynamic-evm-base-fee/std", "pallet-ethereum/std", "pallet-evm/std", @@ -162,7 +169,11 @@ std = [ "pallet-evm-precompile-modexp/std", "pallet-evm-precompile-sha3fips/std", "pallet-dapps-staking/std", - "pallet-evm-precompile-dapps-staking/std", + "pallet-dapp-staking-v3/std", + "pallet-dapp-staking-migration/std", + "dapp-staking-v3-runtime-api/std", + "pallet-inflation/std", + "pallet-evm-precompile-dapp-staking-v3/std", "pallet-evm-precompile-sr25519/std", "pallet-evm-precompile-assets-erc20/std", "pallet-evm-precompile-substrate-ecdsa/std", @@ -216,7 +227,9 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-dapps-staking/runtime-benchmarks", - "pallet-block-rewards-hybrid/runtime-benchmarks", + "pallet-dapp-staking-v3/runtime-benchmarks", + "pallet-dapp-staking-migration/runtime-benchmarks", + "pallet-inflation/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-collective/runtime-benchmarks", "pallet-ethereum/runtime-benchmarks", @@ -237,13 +250,16 @@ try-runtime = [ "frame-system/try-runtime", "pallet-aura/try-runtime", "pallet-balances/try-runtime", - "pallet-block-rewards-hybrid/try-runtime", + "pallet-dapp-staking-v3/try-runtime", + "pallet-dapp-staking-migration/try-runtime", + "pallet-inflation/try-runtime", "pallet-dapps-staking/try-runtime", "pallet-sudo/try-runtime", "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-utility/try-runtime", "pallet-vesting/try-runtime", + "pallet-static-price-provider/try-runtime", "pallet-ethereum/try-runtime", "pallet-xc-asset-config/try-runtime", "pallet-assets/try-runtime", diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 602b930ba5..036d6be689 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -52,6 +52,7 @@ use pallet_transaction_payment::{ use parity_scale_codec::{Compact, Decode, Encode, MaxEncodedLen}; use polkadot_runtime_common::BlockHashCount; use sp_api::impl_runtime_apis; +use sp_arithmetic::fixed_point::FixedU64; use sp_core::{ConstBool, OpaqueMetadata, H160, H256, U256}; use sp_inherents::{CheckInherentsResult, InherentData}; use sp_runtime::{ @@ -63,14 +64,21 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, ApplyExtrinsicResult, FixedPointNumber, Perbill, Permill, Perquintill, RuntimeDebug, }; -use sp_std::prelude::*; +use sp_std::{collections::btree_map::BTreeMap, prelude::*}; -pub use crate::precompiles::WhitelistedCalls; -pub use astar_primitives::{ - evm::EvmRevertCodeHandler, xcm::AssetLocationIdConverter, AccountId, Address, AssetId, Balance, - BlockNumber, Hash, Header, Index, Signature, +use astar_primitives::{ + dapp_staking::{CycleConfiguration, DAppId, EraNumber, PeriodNumber, SmartContract, TierId}, + evm::{EvmRevertCodeHandler, HashedDefaultMappings}, + xcm::AssetLocationIdConverter, + Address, AssetId, BlockNumber, Hash, Header, Index, }; -pub use pallet_block_rewards_hybrid::RewardDistributionConfig; +pub use astar_primitives::{AccountId, Balance, Signature}; + +pub use pallet_dapp_staking_v3::TierThreshold; +pub use pallet_inflation::InflationParameters; + +pub use crate::precompiles::WhitelistedCalls; + use pallet_evm_precompile_assets_erc20::AddressToAssetId; #[cfg(any(feature = "std", test))] @@ -265,7 +273,7 @@ parameter_types! { impl pallet_timestamp::Config for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; - type OnTimestampSet = BlockReward; + type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; type WeightInfo = pallet_timestamp::weights::SubstrateWeight; } @@ -339,28 +347,109 @@ impl pallet_dapps_staking::Config for Runtime { type UnbondingPeriod = UnbondingPeriod; type MaxEraStakeValues = MaxEraStakeValues; type UnregisteredDappRewardRetention = ConstU32<7>; + // Needed so benchmark can use the pallets extrinsics + #[cfg(feature = "runtime-benchmarks")] type ForcePalletDisabled = ConstBool; + #[cfg(not(feature = "runtime-benchmarks"))] + type ForcePalletDisabled = ConstBool; // Fee required to claim rewards for another account. Calculated & tested manually. type DelegateClaimFee = ConstU128<000_579_268_481_141_871>; } -/// Multi-VM pointer to smart contract instance. -#[derive( - PartialEq, Eq, Copy, Clone, Encode, Decode, RuntimeDebug, MaxEncodedLen, scale_info::TypeInfo, -)] -pub enum SmartContract { - /// EVM smart contract instance. - Evm(sp_core::H160), - /// Wasm smart contract instance. - Wasm(AccountId), +impl pallet_static_price_provider::Config for Runtime { + type RuntimeEvent = RuntimeEvent; } -impl Default for SmartContract { - fn default() -> Self { - SmartContract::Evm(H160::repeat_byte(0x00)) +#[cfg(feature = "runtime-benchmarks")] +pub struct BenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); +#[cfg(feature = "runtime-benchmarks")] +impl pallet_dapp_staking_v3::BenchmarkHelper, AccountId> + for BenchmarkHelper, AccountId> +{ + fn get_smart_contract(id: u32) -> SmartContract { + let id_bytes = id.to_le_bytes(); + let mut account = [0u8; 32]; + account[..id_bytes.len()].copy_from_slice(&id_bytes); + + SmartContract::Wasm(AccountId::from(account)) + } + + fn set_balance(account: &AccountId, amount: Balance) { + use frame_support::traits::fungible::Unbalanced as FunUnbalanced; + Balances::write_balance(account, amount) + .expect("Must succeed in test/benchmark environment."); + } +} + +impl pallet_dapp_staking_v3::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeFreezeReason = RuntimeFreezeReason; + type Currency = Balances; + type SmartContract = SmartContract; + type ManagerOrigin = frame_system::EnsureRoot; + type NativePriceProvider = StaticPriceProvider; + type StakingRewardHandler = Inflation; + type CycleConfiguration = InflationCycleConfig; + type Observers = Inflation; + type EraRewardSpanLength = ConstU32<16>; + type RewardRetentionInPeriods = ConstU32<3>; + type MaxNumberOfContracts = ConstU32<500>; + type MaxUnlockingChunks = ConstU32<8>; + type MinimumLockedAmount = MinimumStakingAmount; + type UnlockingPeriod = ConstU32<4>; + type MaxNumberOfStakedContracts = ConstU32<16>; + type MinimumStakeAmount = MinimumStakingAmount; + type NumberOfTiers = ConstU32<4>; + type WeightInfo = weights::pallet_dapp_staking_v3::SubstrateWeight; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = BenchmarkHelper, AccountId>; +} + +pub struct InflationPayoutPerBlock; +impl pallet_inflation::PayoutPerBlock for InflationPayoutPerBlock { + fn treasury(reward: NegativeImbalance) { + Balances::resolve_creating(&TreasuryPalletId::get().into_account_truncating(), reward); + } + + fn collators(reward: NegativeImbalance) { + ToStakingPot::on_unbalanced(reward); + } +} + +pub struct InflationCycleConfig; +impl CycleConfiguration for InflationCycleConfig { + fn periods_per_cycle() -> u32 { + 6 + } + + fn eras_per_voting_subperiod() -> u32 { + 6 + } + + fn eras_per_build_and_earn_subperiod() -> u32 { + 55 } + + fn blocks_per_era() -> BlockNumber { + 24 * HOURS + } +} + +impl pallet_inflation::Config for Runtime { + type Currency = Balances; + type PayoutPerBlock = InflationPayoutPerBlock; + type CycleConfiguration = InflationCycleConfig; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_inflation::weights::SubstrateWeight; } +impl pallet_dapp_staking_migration::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_dapp_staking_migration::weights::SubstrateWeight; +} + +// TODO: use benchmarked values for the new pallets! + impl pallet_utility::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; @@ -463,41 +552,6 @@ impl OnUnbalanced for ToStakingPot { } } -pub struct DappsStakingTvlProvider(); -impl Get for DappsStakingTvlProvider { - fn get() -> Balance { - DappsStaking::tvl() - } -} - -pub struct BeneficiaryPayout(); -impl pallet_block_rewards_hybrid::BeneficiaryPayout for BeneficiaryPayout { - fn treasury(reward: NegativeImbalance) { - Balances::resolve_creating(&TreasuryPalletId::get().into_account_truncating(), reward); - } - - fn collators(reward: NegativeImbalance) { - ToStakingPot::on_unbalanced(reward); - } - - fn dapps_staking(stakers: NegativeImbalance, dapps: NegativeImbalance) { - DappsStaking::rewards(stakers, dapps) - } -} - -parameter_types! { - pub const MaxBlockRewardAmount: Balance = 2_313_789 * MICROSDN; -} - -impl pallet_block_rewards_hybrid::Config for Runtime { - type Currency = Balances; - type DappsStakingTvlProvider = DappsStakingTvlProvider; - type BeneficiaryPayout = BeneficiaryPayout; - type MaxBlockRewardAmount = MaxBlockRewardAmount; - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_block_rewards_hybrid::weights::SubstrateWeight; -} - parameter_types! { pub const ExistentialDeposit: Balance = 1_000_000; pub const MaxLocks: u32 = 50; @@ -515,9 +569,9 @@ impl pallet_balances::Config for Runtime { type AccountStore = frame_system::Pallet; type WeightInfo = pallet_balances::weights::SubstrateWeight; type HoldIdentifier = (); - type FreezeIdentifier = (); + type FreezeIdentifier = RuntimeFreezeReason; type MaxHolds = ConstU32<0>; - type MaxFreezes = ConstU32<0>; + type MaxFreezes = ConstU32<1>; } impl AddressToAssetId for Runtime { @@ -859,7 +913,7 @@ pub enum ProxyType { /// Only reject_announcement call from pallet proxy allowed for proxy account CancelProxy, /// All runtime calls from pallet DappStaking allowed for proxy account - DappsStaking, + DappStaking, /// Only claim_staker call from pallet DappStaking allowed for proxy account StakerRewardClaim, } @@ -891,7 +945,7 @@ impl InstanceFilter for ProxyType { | RuntimeCall::Vesting(pallet_vesting::Call::vest{..}) | RuntimeCall::Vesting(pallet_vesting::Call::vest_other{..}) // Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer` - | RuntimeCall::DappsStaking(..) + | RuntimeCall::DappStaking(..) // Skip entire Assets pallet | RuntimeCall::CollatorSelection(..) | RuntimeCall::Session(..) @@ -923,13 +977,15 @@ impl InstanceFilter for ProxyType { RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) ) } - ProxyType::DappsStaking => { - matches!(c, RuntimeCall::DappsStaking(..)) + ProxyType::DappStaking => { + matches!(c, RuntimeCall::DappStaking(..)) } ProxyType::StakerRewardClaim => { matches!( c, - RuntimeCall::DappsStaking(pallet_dapps_staking::Call::claim_staker { .. }) + RuntimeCall::DappStaking( + pallet_dapp_staking_v3::Call::claim_staker_rewards { .. } + ) ) } } @@ -940,7 +996,7 @@ impl InstanceFilter for ProxyType { (x, y) if x == y => true, (ProxyType::Any, _) => true, (_, ProxyType::Any) => false, - (ProxyType::DappsStaking, ProxyType::StakerRewardClaim) => true, + (ProxyType::DappStaking, ProxyType::StakerRewardClaim) => true, _ => false, } } @@ -991,8 +1047,8 @@ construct_runtime!( TransactionPayment: pallet_transaction_payment = 30, Balances: pallet_balances = 31, Vesting: pallet_vesting = 32, - DappsStaking: pallet_dapps_staking = 34, - BlockReward: pallet_block_rewards_hybrid = 35, + DappStaking: pallet_dapp_staking_v3 = 34, + Inflation: pallet_inflation = 35, Assets: pallet_assets = 36, Authorship: pallet_authorship = 40, @@ -1016,6 +1072,13 @@ construct_runtime!( RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip = 71, Sudo: pallet_sudo = 99, + + // To be removed & cleaned up once proper oracle is implemented + StaticPriceProvider: pallet_static_price_provider = 253, + // To be removed & cleaned up after migration has been finished + DappStakingMigration: pallet_dapp_staking_migration = 254, + // Legacy dApps staking v2, to be removed after migration has been finished + DappsStaking: pallet_dapps_staking = 255, } ); @@ -1053,10 +1116,121 @@ pub type Executive = frame_executive::Executive< Migrations, >; +parameter_types! { + pub const BlockRewardName: &'static str = "BlockReward"; +} /// All migrations that will run on the next runtime upgrade. /// /// Once done, migrations should be removed from the tuple. -pub type Migrations = (); +pub type Migrations = ( + pallet_inflation::PalletInflationInitConfig, + pallet_dapp_staking_v3::migrations::DAppStakingV3InitConfig, + frame_support::migrations::RemovePallet< + BlockRewardName, + ::DbWeight, + >, + // This will handle new pallet storage version setting & it will put the new pallet into maintenance mode. + // But it's most important for testing with try-runtime. + pallet_dapp_staking_migration::DappStakingMigrationHandler, +); + +// TODO: add static price provider migration too + +/// Used to initialize inflation parameters for the runtime. +pub struct InitInflationParams; +impl Get for InitInflationParams { + fn get() -> pallet_inflation::InflationParameters { + pallet_inflation::InflationParameters { + // Recalculation is done every two weeks, hence the small %. + max_inflation_rate: Perquintill::from_percent(7), + treasury_part: Perquintill::from_percent(5), + collators_part: Perquintill::from_rational(32_u64, 1000), + dapps_part: Perquintill::from_percent(13), + base_stakers_part: Perquintill::from_percent(10), + adjustable_stakers_part: Perquintill::from_rational(588_u64, 1000), + bonus_part: Perquintill::from_percent(10), + ideal_staking_rate: Perquintill::from_percent(50), + } + } +} + +use frame_support::BoundedVec; +use pallet_dapp_staking_v3::{TierParameters, TiersConfiguration}; +type NumberOfTiers = ::NumberOfTiers; +/// Used to initialize dApp staking parameters for the runtime. +pub struct InitDappStakingV3Params; +impl + Get<( + EraNumber, + TierParameters, + TiersConfiguration, + )> for InitDappStakingV3Params +{ + fn get() -> ( + EraNumber, + TierParameters, + TiersConfiguration, + ) { + // 1. Prepare init values + + // Init era of dApp staking v3 should be the next era after dApp staking v2 + let init_era = pallet_dapps_staking::CurrentEra::::get().saturating_add(1); + + // Reward portions according to the Tokenomics 2.0 report + let reward_portion = BoundedVec::try_from(vec![ + Permill::from_percent(25), + Permill::from_percent(47), + Permill::from_percent(25), + Permill::from_percent(3), + ]) + .unwrap_or_default(); + + // TODO: check if this is automatically adjusted post-upgrade! + // Tier thresholds adjusted according to numbers observed on Shibuya + let tier_thresholds = BoundedVec::try_from(vec![ + TierThreshold::DynamicTvlAmount { + amount: SDN.saturating_mul(3_000_000), + minimum_amount: SDN.saturating_mul(2_000_000), + }, + TierThreshold::DynamicTvlAmount { + amount: SDN.saturating_mul(750_000), + minimum_amount: SDN.saturating_mul(500_000), + }, + TierThreshold::DynamicTvlAmount { + amount: SDN.saturating_mul(200_000), + minimum_amount: SDN.saturating_mul(150_000), + }, + TierThreshold::FixedTvlAmount { + amount: SDN.saturating_mul(50_000), + }, + ]) + .unwrap_or_default(); + + // 2. Tier params + let tier_params = + TierParameters::<::NumberOfTiers> { + reward_portion: reward_portion.clone(), + slot_distribution: BoundedVec::try_from(vec![ + Permill::from_percent(5), + Permill::from_percent(20), + Permill::from_percent(30), + Permill::from_percent(45), + ]) + .unwrap_or_default(), + tier_thresholds: tier_thresholds.clone(), + }; + + // 3. Init tier config + let init_tier_config = TiersConfiguration { + number_of_slots: 100, + slots_per_tier: BoundedVec::try_from(vec![5, 20, 30, 45]).unwrap_or_default(), + reward_portion, + tier_thresholds, + }; + + (init_era, tier_params, init_tier_config) + } +} type EventRecord = frame_system::EventRecord< ::RuntimeEvent, @@ -1134,7 +1308,9 @@ mod benches { [pallet_balances, Balances] [pallet_timestamp, Timestamp] [pallet_dapps_staking, DappsStaking] - [block_rewards_hybrid, BlockReward] + [pallet_dapp_staking_v3, DappStaking] + [pallet_inflation, Inflation] + [pallet_dapp_staking_migration, DappStakingMigration] [pallet_xc_asset_config, XcAssetConfig] [pallet_collator_selection, CollatorSelection] [pallet_xcm, PolkadotXcm] @@ -1596,6 +1772,28 @@ impl_runtime_apis! { } } + impl dapp_staking_v3_runtime_api::DappStakingApi for Runtime { + fn periods_per_cycle() -> PeriodNumber { + InflationCycleConfig::periods_per_cycle() + } + + fn eras_per_voting_subperiod() -> EraNumber { + InflationCycleConfig::eras_per_voting_subperiod() + } + + fn eras_per_build_and_earn_subperiod() -> EraNumber { + InflationCycleConfig::eras_per_build_and_earn_subperiod() + } + + fn blocks_per_era() -> BlockNumber { + InflationCycleConfig::blocks_per_era() + } + + fn get_dapp_tier_assignment() -> BTreeMap { + DappStaking::get_dapp_tier_assignment() + } + } + #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { fn benchmark_metadata(extra: bool) -> ( diff --git a/runtime/shiden/src/precompiles.rs b/runtime/shiden/src/precompiles.rs index 6a8cb319ca..e3f858af5f 100644 --- a/runtime/shiden/src/precompiles.rs +++ b/runtime/shiden/src/precompiles.rs @@ -24,7 +24,7 @@ use frame_support::{parameter_types, traits::Contains}; use pallet_evm_precompile_assets_erc20::Erc20AssetsPrecompileSet; use pallet_evm_precompile_blake2::Blake2F; use pallet_evm_precompile_bn128::{Bn128Add, Bn128Mul, Bn128Pairing}; -use pallet_evm_precompile_dapps_staking::DappsStakingWrapper; +use pallet_evm_precompile_dapp_staking_v3::DappStakingV3Precompile; use pallet_evm_precompile_dispatch::Dispatch; use pallet_evm_precompile_ed25519::Ed25519Verify; use pallet_evm_precompile_modexp::Modexp; @@ -57,7 +57,7 @@ impl Contains for WhitelistedCalls { | RuntimeCall::Utility(pallet_utility::Call::batch_all { calls }) => { calls.iter().all(|call| WhitelistedCalls::contains(call)) } - RuntimeCall::DappsStaking(_) => true, + RuntimeCall::DappStaking(_) => true, RuntimeCall::Assets(pallet_assets::Call::transfer { .. }) => true, _ => false, } @@ -91,7 +91,7 @@ pub type ShidenPrecompilesSetAt = ( // Astar specific precompiles: PrecompileAt< AddressU64<20481>, - DappsStakingWrapper, + DappStakingV3Precompile, (CallableByContract, CallableByPrecompile), >, PrecompileAt< diff --git a/runtime/shiden/src/weights/mod.rs b/runtime/shiden/src/weights/mod.rs index 6471081ec8..23a0bb4e9b 100644 --- a/runtime/shiden/src/weights/mod.rs +++ b/runtime/shiden/src/weights/mod.rs @@ -17,4 +17,6 @@ // along with Astar. If not, see . pub mod pallet_assets; +pub mod pallet_dapp_staking_v3; +pub mod pallet_inflation; pub mod pallet_xcm; diff --git a/runtime/shiden/src/weights/pallet_dapp_staking_v3.rs b/runtime/shiden/src/weights/pallet_dapp_staking_v3.rs new file mode 100644 index 0000000000..88fdf31674 --- /dev/null +++ b/runtime/shiden/src/weights/pallet_dapp_staking_v3.rs @@ -0,0 +1,432 @@ + +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Astar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Astar. If not, see . + +//! Autogenerated weights for pallet_dapp_staking_v3 +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shibuya-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/astar-collator +// benchmark +// pallet +// --chain=shibuya-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_dapp_staking_v3 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./benchmark-results/shibuya-dev/dapp_staking_v3_weights.rs +// --template=./scripts/templates/weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use core::marker::PhantomData; +use pallet_dapp_staking_v3::WeightInfo; + +/// Weights for pallet_dapp_staking_v3 using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn maintenance_mode() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_765_000 picoseconds. + Weight::from_parts(9_104_000, 0) + } + /// Storage: DappStaking IntegratedDApps (r:1 w:1) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Storage: DappStaking CounterForIntegratedDApps (r:1 w:1) + /// Proof: DappStaking CounterForIntegratedDApps (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: DappStaking NextDAppId (r:1 w:1) + /// Proof: DappStaking NextDAppId (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + fn register() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `3091` + // Minimum execution time: 17_156_000 picoseconds. + Weight::from_parts(17_426_000, 3091) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: DappStaking IntegratedDApps (r:1 w:1) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + fn set_dapp_reward_beneficiary() -> Weight { + // Proof Size summary in bytes: + // Measured: `75` + // Estimated: `3091` + // Minimum execution time: 13_565_000 picoseconds. + Weight::from_parts(13_804_000, 3091) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: DappStaking IntegratedDApps (r:1 w:1) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + fn set_dapp_owner() -> Weight { + // Proof Size summary in bytes: + // Measured: `75` + // Estimated: `3091` + // Minimum execution time: 13_824_000 picoseconds. + Weight::from_parts(14_132_000, 3091) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: DappStaking IntegratedDApps (r:1 w:1) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Storage: DappStaking ContractStake (r:0 w:1) + /// Proof: DappStaking ContractStake (max_values: Some(65535), max_size: Some(91), added: 2071, mode: MaxEncodedLen) + fn unregister() -> Weight { + // Proof Size summary in bytes: + // Measured: `75` + // Estimated: `3091` + // Minimum execution time: 17_255_000 picoseconds. + Weight::from_parts(17_659_000, 3091) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:1) + /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:0) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: DappStaking CurrentEraInfo (r:1 w:1) + /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) + fn lock() -> Weight { + // Proof Size summary in bytes: + // Measured: `12` + // Estimated: `4764` + // Minimum execution time: 33_281_000 picoseconds. + Weight::from_parts(33_759_000, 4764) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:1) + /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:0) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: DappStaking CurrentEraInfo (r:1 w:1) + /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) + fn unlock() -> Weight { + // Proof Size summary in bytes: + // Measured: `156` + // Estimated: `4764` + // Minimum execution time: 34_451_000 picoseconds. + Weight::from_parts(34_926_000, 4764) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:1) + /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:0) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: DappStaking CurrentEraInfo (r:1 w:1) + /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) + /// The range of component `x` is `[0, 8]`. + fn claim_unlocked(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `187` + // Estimated: `4764` + // Minimum execution time: 37_641_000 picoseconds. + Weight::from_parts(38_890_045, 4764) + // Standard Error: 7_639 + .saturating_add(Weight::from_parts(183_994, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:1) + /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:0) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: DappStaking CurrentEraInfo (r:1 w:1) + /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) + fn relock_unlocking() -> Weight { + // Proof Size summary in bytes: + // Measured: `182` + // Estimated: `4764` + // Minimum execution time: 33_528_000 picoseconds. + Weight::from_parts(33_929_000, 4764) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: DappStaking IntegratedDApps (r:1 w:0) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: DappStaking StakerInfo (r:1 w:1) + /// Proof: DappStaking StakerInfo (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) + /// Storage: DappStaking ContractStake (r:1 w:1) + /// Proof: DappStaking ContractStake (max_values: Some(65535), max_size: Some(91), added: 2071, mode: MaxEncodedLen) + /// Storage: DappStaking CurrentEraInfo (r:1 w:1) + /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:1) + /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:0) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + fn stake() -> Weight { + // Proof Size summary in bytes: + // Measured: `250` + // Estimated: `4764` + // Minimum execution time: 45_984_000 picoseconds. + Weight::from_parts(46_329_000, 4764) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: DappStaking IntegratedDApps (r:1 w:0) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: DappStaking StakerInfo (r:1 w:1) + /// Proof: DappStaking StakerInfo (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) + /// Storage: DappStaking ContractStake (r:1 w:1) + /// Proof: DappStaking ContractStake (max_values: Some(65535), max_size: Some(91), added: 2071, mode: MaxEncodedLen) + /// Storage: DappStaking CurrentEraInfo (r:1 w:1) + /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:1) + /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:0) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + fn unstake() -> Weight { + // Proof Size summary in bytes: + // Measured: `427` + // Estimated: `4764` + // Minimum execution time: 48_584_000 picoseconds. + Weight::from_parts(49_635_000, 4764) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: DappStaking EraRewards (r:1 w:0) + /// Proof: DappStaking EraRewards (max_values: None, max_size: Some(789), added: 3264, mode: MaxEncodedLen) + /// Storage: DappStaking PeriodEnd (r:1 w:0) + /// Proof: DappStaking PeriodEnd (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:1) + /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:0) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// The range of component `x` is `[1, 16]`. + fn claim_staker_rewards_past_period(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `560` + // Estimated: `4764` + // Minimum execution time: 51_711_000 picoseconds. + Weight::from_parts(50_255_137, 4764) + // Standard Error: 5_418 + .saturating_add(Weight::from_parts(3_166_243, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: DappStaking EraRewards (r:1 w:0) + /// Proof: DappStaking EraRewards (max_values: None, max_size: Some(789), added: 3264, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:1) + /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:0) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// The range of component `x` is `[1, 16]`. + fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `501` + // Estimated: `4764` + // Minimum execution time: 48_656_000 picoseconds. + Weight::from_parts(46_590_994, 4764) + // Standard Error: 4_829 + .saturating_add(Weight::from_parts(3_197_956, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: DappStaking StakerInfo (r:1 w:1) + /// Proof: DappStaking StakerInfo (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) + /// Storage: DappStaking PeriodEnd (r:1 w:0) + /// Proof: DappStaking PeriodEnd (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + fn claim_bonus_reward() -> Weight { + // Proof Size summary in bytes: + // Measured: `267` + // Estimated: `3775` + // Minimum execution time: 41_921_000 picoseconds. + Weight::from_parts(42_440_000, 3775) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: DappStaking IntegratedDApps (r:1 w:0) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Storage: DappStaking DAppTiers (r:1 w:1) + /// Proof: DappStaking DAppTiers (max_values: None, max_size: Some(1583), added: 4058, mode: MaxEncodedLen) + fn claim_dapp_reward() -> Weight { + // Proof Size summary in bytes: + // Measured: `2585` + // Estimated: `5048` + // Minimum execution time: 58_409_000 picoseconds. + Weight::from_parts(60_103_000, 5048) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: DappStaking IntegratedDApps (r:1 w:0) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Storage: DappStaking StakerInfo (r:1 w:1) + /// Proof: DappStaking StakerInfo (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: DappStaking CurrentEraInfo (r:1 w:1) + /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:1) + /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:0) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + fn unstake_from_unregistered() -> Weight { + // Proof Size summary in bytes: + // Measured: `389` + // Estimated: `4764` + // Minimum execution time: 43_579_000 picoseconds. + Weight::from_parts(44_128_000, 4764) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: DappStaking StakerInfo (r:9 w:8) + /// Proof: DappStaking StakerInfo (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:1) + /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:0) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// The range of component `x` is `[1, 8]`. + fn cleanup_expired_entries(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `255 + x * (69 ±0)` + // Estimated: `4764 + x * (2613 ±0)` + // Minimum execution time: 43_019_000 picoseconds. + Weight::from_parts(39_628_074, 4764) + // Standard Error: 15_327 + .saturating_add(Weight::from_parts(4_990_892, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(x.into()))) + .saturating_add(Weight::from_parts(0, 2613).saturating_mul(x.into())) + } + fn force() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 11_301_000 picoseconds. + Weight::from_parts(11_607_000, 0) + } + /// Storage: DappStaking CurrentEraInfo (r:1 w:1) + /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) + /// Storage: DappStaking EraRewards (r:1 w:1) + /// Proof: DappStaking EraRewards (max_values: None, max_size: Some(789), added: 3264, mode: MaxEncodedLen) + fn on_initialize_voting_to_build_and_earn() -> Weight { + // Proof Size summary in bytes: + // Measured: `16` + // Estimated: `4254` + // Minimum execution time: 17_997_000 picoseconds. + Weight::from_parts(18_491_000, 4254) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: DappStaking CurrentEraInfo (r:1 w:1) + /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) + /// Storage: DappStaking StaticTierParams (r:1 w:0) + /// Proof: DappStaking StaticTierParams (max_values: Some(1), max_size: Some(167), added: 662, mode: MaxEncodedLen) + /// Storage: DappStaking TierConfig (r:1 w:1) + /// Proof: DappStaking TierConfig (max_values: Some(1), max_size: Some(161), added: 656, mode: MaxEncodedLen) + /// Storage: DappStaking PeriodEnd (r:1 w:2) + /// Proof: DappStaking PeriodEnd (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: DappStaking HistoryCleanupMarker (r:1 w:1) + /// Proof: DappStaking HistoryCleanupMarker (max_values: Some(1), max_size: Some(12), added: 507, mode: MaxEncodedLen) + /// Storage: DappStaking EraRewards (r:1 w:1) + /// Proof: DappStaking EraRewards (max_values: None, max_size: Some(789), added: 3264, mode: MaxEncodedLen) + /// Storage: DappStaking DAppTiers (r:0 w:1) + /// Proof: DappStaking DAppTiers (max_values: None, max_size: Some(1583), added: 4058, mode: MaxEncodedLen) + fn on_initialize_build_and_earn_to_voting() -> Weight { + // Proof Size summary in bytes: + // Measured: `627` + // Estimated: `4254` + // Minimum execution time: 45_396_000 picoseconds. + Weight::from_parts(46_230_000, 4254) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) + } + /// Storage: DappStaking CurrentEraInfo (r:1 w:1) + /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) + /// Storage: DappStaking EraRewards (r:1 w:1) + /// Proof: DappStaking EraRewards (max_values: None, max_size: Some(789), added: 3264, mode: MaxEncodedLen) + /// Storage: DappStaking DAppTiers (r:0 w:1) + /// Proof: DappStaking DAppTiers (max_values: None, max_size: Some(1583), added: 4058, mode: MaxEncodedLen) + fn on_initialize_build_and_earn_to_build_and_earn() -> Weight { + // Proof Size summary in bytes: + // Measured: `68` + // Estimated: `4254` + // Minimum execution time: 24_161_000 picoseconds. + Weight::from_parts(24_565_000, 4254) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: DappStaking ContractStake (r:101 w:0) + /// Proof: DappStaking ContractStake (max_values: Some(65535), max_size: Some(91), added: 2071, mode: MaxEncodedLen) + /// Storage: DappStaking TierConfig (r:1 w:0) + /// Proof: DappStaking TierConfig (max_values: Some(1), max_size: Some(161), added: 656, mode: MaxEncodedLen) + /// The range of component `x` is `[0, 100]`. + fn dapp_tier_assignment(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `152 + x * (32 ±0)` + // Estimated: `3061 + x * (2071 ±0)` + // Minimum execution time: 7_878_000 picoseconds. + Weight::from_parts(12_213_692, 3061) + // Standard Error: 3_051 + .saturating_add(Weight::from_parts(2_363_936, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) + } + /// Storage: DappStaking HistoryCleanupMarker (r:1 w:1) + /// Proof: DappStaking HistoryCleanupMarker (max_values: Some(1), max_size: Some(12), added: 507, mode: MaxEncodedLen) + /// Storage: DappStaking EraRewards (r:1 w:1) + /// Proof: DappStaking EraRewards (max_values: None, max_size: Some(789), added: 3264, mode: MaxEncodedLen) + /// Storage: DappStaking DAppTiers (r:0 w:1) + /// Proof: DappStaking DAppTiers (max_values: None, max_size: Some(1583), added: 4058, mode: MaxEncodedLen) + fn on_idle_cleanup() -> Weight { + // Proof Size summary in bytes: + // Measured: `293` + // Estimated: `4254` + // Minimum execution time: 8_839_000 picoseconds. + Weight::from_parts(8_975_000, 4254) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } +} \ No newline at end of file diff --git a/runtime/shiden/src/weights/pallet_inflation.rs b/runtime/shiden/src/weights/pallet_inflation.rs new file mode 100644 index 0000000000..1fdb896f5c --- /dev/null +++ b/runtime/shiden/src/weights/pallet_inflation.rs @@ -0,0 +1,102 @@ + +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Astar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Astar. If not, see . + +//! Autogenerated weights for pallet_inflation +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shibuya-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/astar-collator +// benchmark +// pallet +// --chain=shibuya-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_inflation +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./benchmark-results/shibuya-dev/inflation_weights.rs +// --template=./scripts/templates/weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use core::marker::PhantomData; +use pallet_inflation::WeightInfo; + +/// Weights for pallet_inflation using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: Inflation InflationParams (r:0 w:1) + /// Proof: Inflation InflationParams (max_values: Some(1), max_size: Some(64), added: 559, mode: MaxEncodedLen) + fn force_set_inflation_params() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 9_487_000 picoseconds. + Weight::from_parts(9_652_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + fn force_set_inflation_config() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 9_168_000 picoseconds. + Weight::from_parts(9_436_000, 0) + } + /// Storage: Inflation InflationParams (r:1 w:0) + /// Proof: Inflation InflationParams (max_values: Some(1), max_size: Some(64), added: 559, mode: MaxEncodedLen) + fn force_inflation_recalculation() -> Weight { + // Proof Size summary in bytes: + // Measured: `40` + // Estimated: `1549` + // Minimum execution time: 13_496_000 picoseconds. + Weight::from_parts(13_762_000, 1549) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: Inflation InflationParams (r:1 w:0) + /// Proof: Inflation InflationParams (max_values: Some(1), max_size: Some(64), added: 559, mode: MaxEncodedLen) + fn recalculation() -> Weight { + // Proof Size summary in bytes: + // Measured: `58` + // Estimated: `1549` + // Minimum execution time: 13_811_000 picoseconds. + Weight::from_parts(13_995_000, 1549) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: System Account (r:2 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn hooks_without_recalculation() -> Weight { + // Proof Size summary in bytes: + // Measured: `174` + // Estimated: `6196` + // Minimum execution time: 21_351_000 picoseconds. + Weight::from_parts(21_749_000, 6196) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} \ No newline at end of file From 56b1184a805be5a871824b8b2571aa4838e478cd Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Fri, 2 Feb 2024 17:44:21 +0100 Subject: [PATCH 02/14] Full integration --- .../src/parachain/chain_spec/shibuya.rs | 2 - .../src/parachain/chain_spec/shiden.rs | 51 ++++++++++++++----- runtime/shiden/src/lib.rs | 32 ++++++------ tests/integration/src/dapp_staking_v3.rs | 1 + tests/integration/src/lib.rs | 10 ++-- tests/integration/src/setup.rs | 14 ++--- 6 files changed, 67 insertions(+), 43 deletions(-) diff --git a/bin/collator/src/parachain/chain_spec/shibuya.rs b/bin/collator/src/parachain/chain_spec/shibuya.rs index 200d324631..6266e4dc30 100644 --- a/bin/collator/src/parachain/chain_spec/shibuya.rs +++ b/bin/collator/src/parachain/chain_spec/shibuya.rs @@ -176,7 +176,6 @@ fn make_genesis( Permill::from_percent(30), Permill::from_percent(40), ], - // TODO: adjust this if needed tier_thresholds: vec![ TierThreshold::DynamicTvlAmount { amount: 100 * SBY, @@ -194,7 +193,6 @@ fn make_genesis( ], slots_per_tier: vec![10, 20, 30, 40], }, - // TODO: adjust this if needed inflation: InflationConfig { params: InflationParameters::default(), }, diff --git a/bin/collator/src/parachain/chain_spec/shiden.rs b/bin/collator/src/parachain/chain_spec/shiden.rs index e305f994c4..2f47228419 100644 --- a/bin/collator/src/parachain/chain_spec/shiden.rs +++ b/bin/collator/src/parachain/chain_spec/shiden.rs @@ -21,14 +21,15 @@ use cumulus_primitives_core::ParaId; use sc_service::ChainType; use shiden_runtime::{ - wasm_binary_unwrap, AccountId, AuraId, Balance, BlockRewardConfig, EVMConfig, - ParachainInfoConfig, Precompiles, RewardDistributionConfig, Signature, SystemConfig, SDN, + wasm_binary_unwrap, AccountId, AuraId, Balance, DappStakingConfig, EVMConfig, InflationConfig, + InflationParameters, ParachainInfoConfig, Precompiles, Signature, SystemConfig, TierThreshold, + SDN, }; use sp_core::{sr25519, Pair, Public}; use sp_runtime::{ traits::{IdentifyAccount, Verify}, - Perbill, + Permill, }; use super::{get_from_seed, Extensions}; @@ -111,17 +112,6 @@ fn make_genesis( }, parachain_info: ParachainInfoConfig { parachain_id }, balances: shiden_runtime::BalancesConfig { balances }, - block_reward: BlockRewardConfig { - // Make sure sum is 100 - reward_config: RewardDistributionConfig { - treasury_percent: Perbill::from_percent(40), - base_staker_percent: Perbill::from_percent(25), - dapps_percent: Perbill::from_percent(25), - collators_percent: Perbill::from_percent(10), - adjustable_percent: Perbill::from_percent(0), - ideal_dapps_staking_tvl: Perbill::from_percent(0), - }, - }, vesting: shiden_runtime::VestingConfig { vesting: vec![] }, session: shiden_runtime::SessionConfig { keys: authorities @@ -160,6 +150,39 @@ fn make_genesis( assets: Default::default(), parachain_system: Default::default(), transaction_payment: Default::default(), + dapp_staking: DappStakingConfig { + reward_portion: vec![ + Permill::from_percent(40), + Permill::from_percent(30), + Permill::from_percent(20), + Permill::from_percent(10), + ], + slot_distribution: vec![ + Permill::from_percent(10), + Permill::from_percent(20), + Permill::from_percent(30), + Permill::from_percent(40), + ], + tier_thresholds: vec![ + TierThreshold::DynamicTvlAmount { + amount: 30000 * SDN, + minimum_amount: 20000 * SDN, + }, + TierThreshold::DynamicTvlAmount { + amount: 7500 * SDN, + minimum_amount: 5000 * SDN, + }, + TierThreshold::DynamicTvlAmount { + amount: 20000 * SDN, + minimum_amount: 15000 * SDN, + }, + TierThreshold::FixedTvlAmount { amount: 5000 * SDN }, + ], + slots_per_tier: vec![10, 20, 30, 40], + }, + inflation: InflationConfig { + params: InflationParameters::default(), + }, } } diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 036d6be689..d6a5a150f3 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -52,7 +52,6 @@ use pallet_transaction_payment::{ use parity_scale_codec::{Compact, Decode, Encode, MaxEncodedLen}; use polkadot_runtime_common::BlockHashCount; use sp_api::impl_runtime_apis; -use sp_arithmetic::fixed_point::FixedU64; use sp_core::{ConstBool, OpaqueMetadata, H160, H256, U256}; use sp_inherents::{CheckInherentsResult, InherentData}; use sp_runtime::{ @@ -68,7 +67,7 @@ use sp_std::{collections::btree_map::BTreeMap, prelude::*}; use astar_primitives::{ dapp_staking::{CycleConfiguration, DAppId, EraNumber, PeriodNumber, SmartContract, TierId}, - evm::{EvmRevertCodeHandler, HashedDefaultMappings}, + evm::EvmRevertCodeHandler, xcm::AssetLocationIdConverter, Address, AssetId, BlockNumber, Hash, Header, Index, }; @@ -1138,19 +1137,22 @@ pub type Migrations = ( /// Used to initialize inflation parameters for the runtime. pub struct InitInflationParams; -impl Get for InitInflationParams { - fn get() -> pallet_inflation::InflationParameters { - pallet_inflation::InflationParameters { - // Recalculation is done every two weeks, hence the small %. - max_inflation_rate: Perquintill::from_percent(7), - treasury_part: Perquintill::from_percent(5), - collators_part: Perquintill::from_rational(32_u64, 1000), - dapps_part: Perquintill::from_percent(13), - base_stakers_part: Perquintill::from_percent(10), - adjustable_stakers_part: Perquintill::from_rational(588_u64, 1000), - bonus_part: Perquintill::from_percent(10), - ideal_staking_rate: Perquintill::from_percent(50), - } +impl Get<(pallet_inflation::InflationParameters, EraNumber)> for InitInflationParams { + fn get() -> (pallet_inflation::InflationParameters, EraNumber) { + ( + pallet_inflation::InflationParameters { + // Recalculation is done every two weeks, hence the small %. + max_inflation_rate: Perquintill::from_percent(7), + treasury_part: Perquintill::from_percent(5), + collators_part: Perquintill::from_rational(32_u64, 1000), + dapps_part: Perquintill::from_percent(13), + base_stakers_part: Perquintill::from_percent(10), + adjustable_stakers_part: Perquintill::from_rational(588_u64, 1000), + bonus_part: Perquintill::from_percent(10), + ideal_staking_rate: Perquintill::from_percent(50), + }, + pallet_dapps_staking::CurrentEra::::get().saturating_add(1), + ) } } diff --git a/tests/integration/src/dapp_staking_v3.rs b/tests/integration/src/dapp_staking_v3.rs index 1a79c9ccbc..8bcd6b3d7b 100644 --- a/tests/integration/src/dapp_staking_v3.rs +++ b/tests/integration/src/dapp_staking_v3.rs @@ -28,6 +28,7 @@ fn dapp_staking_triggers_inflation_recalculation() { let init_inflation_config = pallet_inflation::ActiveInflationConfig::::get(); let recalculation_era = init_inflation_config.recalculation_era; + println!("Recalculation era: {}", recalculation_era); // It's not feasible to run through all the blocks needed to trigger all the eras. // Instead, we force the era to change on a block by block basis. diff --git a/tests/integration/src/lib.rs b/tests/integration/src/lib.rs index 747cc8ff4a..7f12e9903d 100644 --- a/tests/integration/src/lib.rs +++ b/tests/integration/src/lib.rs @@ -23,11 +23,11 @@ #[cfg(any(feature = "shibuya", feature = "shiden", feature = "astar"))] mod setup; -#[cfg(any(feature = "shibuya"))] +#[cfg(any(feature = "shibuya", feature = "shiden"))] mod proxy_new; // Remove this once dApp staking v3 is integrated into Shiden & Astar -#[cfg(any(feature = "shiden", feature = "astar"))] +#[cfg(any(feature = "astar"))] mod proxy_old; #[cfg(any(feature = "shibuya", feature = "shiden", feature = "astar"))] @@ -36,17 +36,17 @@ mod assets; #[cfg(feature = "shibuya")] mod xvm; -#[cfg(any(feature = "shibuya"))] +#[cfg(any(feature = "shibuya", feature = "shiden"))] mod dispatch_precompile_filter_new; // Remove this once dApp staking v3 is integrated into Shiden & Astar -#[cfg(any(feature = "shiden", feature = "astar"))] +#[cfg(any(feature = "astar"))] mod dispatch_precompile_filter_old; #[cfg(feature = "shibuya")] mod unified_accounts; -#[cfg(feature = "shibuya")] +#[cfg(any(feature = "shibuya", feature = "shiden"))] mod dapp_staking_v3; #[cfg(any(feature = "shibuya"))] diff --git a/tests/integration/src/setup.rs b/tests/integration/src/setup.rs index 5ce81c65d2..083a560ceb 100644 --- a/tests/integration/src/setup.rs +++ b/tests/integration/src/setup.rs @@ -191,7 +191,7 @@ impl ExtBuilder { .assimilate_storage(&mut t) .unwrap(); - #[cfg(any(feature = "shibuya"))] + #[cfg(any(feature = "shibuya", feature = "shiden"))] // Needed to trigger initial inflation config setting. >::assimilate_storage( &pallet_inflation::GenesisConfig::default(), @@ -222,9 +222,9 @@ pub fn run_to_block(n: BlockNumber) { while System::block_number() < n { let block_number = System::block_number(); TransactionPayment::on_finalize(block_number); - #[cfg(any(feature = "shibuya"))] + #[cfg(any(feature = "shibuya", feature = "shiden"))] DappStaking::on_finalize(block_number); - #[cfg(any(feature = "astar", feature = "shiden"))] + #[cfg(any(feature = "astar"))] DappsStaking::on_finalize(block_number); Authorship::on_finalize(block_number); Session::on_finalize(block_number); @@ -232,19 +232,19 @@ pub fn run_to_block(n: BlockNumber) { PolkadotXcm::on_finalize(block_number); Ethereum::on_finalize(block_number); DynamicEvmBaseFee::on_finalize(block_number); - #[cfg(any(feature = "shibuya"))] + #[cfg(any(feature = "shibuya", feature = "shiden"))] Inflation::on_finalize(block_number); System::set_block_number(block_number + 1); let block_number = System::block_number(); - #[cfg(any(feature = "shibuya"))] + #[cfg(any(feature = "shibuya", feature = "shiden"))] Inflation::on_initialize(block_number); Timestamp::set_timestamp(block_number as u64 * BLOCK_TIME); TransactionPayment::on_initialize(block_number); - #[cfg(any(feature = "shibuya"))] + #[cfg(any(feature = "shibuya", feature = "shiden"))] DappStaking::on_initialize(block_number); - #[cfg(any(feature = "astar", feature = "shiden"))] + #[cfg(any(feature = "astar"))] DappsStaking::on_initialize(block_number); Authorship::on_initialize(block_number); Aura::on_initialize(block_number); From 6e3757b845cb3392e43947738b4c694bad5a3d9b Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Fri, 2 Feb 2024 17:54:43 +0100 Subject: [PATCH 03/14] Changes --- pallets/inflation/src/lib.rs | 12 +++++++----- runtime/shiden/src/lib.rs | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/pallets/inflation/src/lib.rs b/pallets/inflation/src/lib.rs index 303472ac96..3a1f6acf24 100644 --- a/pallets/inflation/src/lib.rs +++ b/pallets/inflation/src/lib.rs @@ -636,9 +636,9 @@ pub trait PayoutPerBlock { /// `OnRuntimeUpgrade` logic for integrating this pallet into the live network. #[cfg(feature = "try-runtime")] use sp_std::vec::Vec; -pub struct PalletInflationInitConfig(PhantomData<(T, P)>); -impl> OnRuntimeUpgrade - for PalletInflationInitConfig +pub struct PalletInflationInitConfig(PhantomData<(T, P, W)>); +impl> OnRuntimeUpgrade + for PalletInflationInitConfig { fn on_runtime_upgrade() -> Weight { if Pallet::::on_chain_storage_version() >= STORAGE_VERSION { @@ -646,7 +646,7 @@ impl> OnRuntimeUpgrade } // 1. Get & set inflation parameters - let (inflation_params, next_era) = P::get(); + let (inflation_params, next_era, extra_weight) = P::get(); InflationParams::::put(inflation_params.clone()); // 2. Calculation inflation config, set it & deposit event @@ -660,7 +660,9 @@ impl> OnRuntimeUpgrade log::info!("Inflation pallet storage initialized."); - T::WeightInfo::recalculation().saturating_add(T::DbWeight::get().reads_writes(1, 2)) + T::WeightInfo::recalculation() + .saturating_add(T::DbWeight::get().reads_writes(1, 2)) + .saturating_add(extra_weight) } #[cfg(feature = "try-runtime")] diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index d6a5a150f3..daf8b5566e 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -644,7 +644,6 @@ impl pallet_vesting::Config for Runtime { const MAX_VESTING_SCHEDULES: u32 = 28; } -// TODO: changing depost per item and per byte to `deposit` function will require storage migration it seems parameter_types! { pub const DepositPerItem: Balance = contracts_deposit(1, 0); pub const DepositPerByte: Balance = contracts_deposit(0, 1); @@ -1122,7 +1121,7 @@ parameter_types! { /// /// Once done, migrations should be removed from the tuple. pub type Migrations = ( - pallet_inflation::PalletInflationInitConfig, + pallet_inflation::PalletInflationInitConfig, pallet_dapp_staking_v3::migrations::DAppStakingV3InitConfig, frame_support::migrations::RemovePallet< BlockRewardName, @@ -1131,13 +1130,20 @@ pub type Migrations = ( // This will handle new pallet storage version setting & it will put the new pallet into maintenance mode. // But it's most important for testing with try-runtime. pallet_dapp_staking_migration::DappStakingMigrationHandler, + pallet_static_price_provider::InitActivePrice, ); -// TODO: add static price provider migration too +pub struct InitActivePriceGet; +impl Get for InitActivePriceGet { + fn get() -> FixedU64 { + // TODO: set this to the correct value + FixedU64::from_rational(1, 10) + } +} /// Used to initialize inflation parameters for the runtime. -pub struct InitInflationParams; -impl Get<(pallet_inflation::InflationParameters, EraNumber)> for InitInflationParams { +pub struct InitInflationParamsHelper; +impl Get<(pallet_inflation::InflationParameters, EraNumber)> for InitInflationParamsHelper { fn get() -> (pallet_inflation::InflationParameters, EraNumber) { ( pallet_inflation::InflationParameters { @@ -1152,6 +1158,7 @@ impl Get<(pallet_inflation::InflationParameters, EraNumber)> for InitInflationPa ideal_staking_rate: Perquintill::from_percent(50), }, pallet_dapps_staking::CurrentEra::::get().saturating_add(1), + T::DbWeight::get().reads(1), ) } } From 6a5b177ab687473676994cc1faa0970fbbe7e7c6 Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Fri, 2 Feb 2024 18:02:39 +0100 Subject: [PATCH 04/14] Fix --- pallets/inflation/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/inflation/src/lib.rs b/pallets/inflation/src/lib.rs index 3a1f6acf24..e4911c1981 100644 --- a/pallets/inflation/src/lib.rs +++ b/pallets/inflation/src/lib.rs @@ -636,7 +636,7 @@ pub trait PayoutPerBlock { /// `OnRuntimeUpgrade` logic for integrating this pallet into the live network. #[cfg(feature = "try-runtime")] use sp_std::vec::Vec; -pub struct PalletInflationInitConfig(PhantomData<(T, P, W)>); +pub struct PalletInflationInitConfig(PhantomData<(T, P, W)>); impl> OnRuntimeUpgrade for PalletInflationInitConfig { From a47794c2d0117d78931ebadb8fd53e95fb80d056 Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Fri, 2 Feb 2024 18:16:19 +0100 Subject: [PATCH 05/14] Proper fix, really --- pallets/inflation/src/lib.rs | 4 ++-- runtime/shiden/src/lib.rs | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pallets/inflation/src/lib.rs b/pallets/inflation/src/lib.rs index e4911c1981..1ea770ab2b 100644 --- a/pallets/inflation/src/lib.rs +++ b/pallets/inflation/src/lib.rs @@ -636,9 +636,9 @@ pub trait PayoutPerBlock { /// `OnRuntimeUpgrade` logic for integrating this pallet into the live network. #[cfg(feature = "try-runtime")] use sp_std::vec::Vec; -pub struct PalletInflationInitConfig(PhantomData<(T, P, W)>); +pub struct PalletInflationInitConfig(PhantomData<(T, P, Weight)>); impl> OnRuntimeUpgrade - for PalletInflationInitConfig + for PalletInflationInitConfig { fn on_runtime_upgrade() -> Weight { if Pallet::::on_chain_storage_version() >= STORAGE_VERSION { diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index daf8b5566e..663441fa73 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -1133,6 +1133,7 @@ pub type Migrations = ( pallet_static_price_provider::InitActivePrice, ); +use sp_arithmetic::fixed_point::FixedU64; pub struct InitActivePriceGet; impl Get for InitActivePriceGet { fn get() -> FixedU64 { @@ -1143,8 +1144,8 @@ impl Get for InitActivePriceGet { /// Used to initialize inflation parameters for the runtime. pub struct InitInflationParamsHelper; -impl Get<(pallet_inflation::InflationParameters, EraNumber)> for InitInflationParamsHelper { - fn get() -> (pallet_inflation::InflationParameters, EraNumber) { +impl Get<(pallet_inflation::InflationParameters, EraNumber, Weight)> for InitInflationParamsHelper { + fn get() -> (pallet_inflation::InflationParameters, EraNumber, Weight) { ( pallet_inflation::InflationParameters { // Recalculation is done every two weeks, hence the small %. @@ -1158,7 +1159,7 @@ impl Get<(pallet_inflation::InflationParameters, EraNumber)> for InitInflationPa ideal_staking_rate: Perquintill::from_percent(50), }, pallet_dapps_staking::CurrentEra::::get().saturating_add(1), - T::DbWeight::get().reads(1), + ::DbWeight::get().reads(1), ) } } From 1a414080851567809690536fb7091e46dad9cd2e Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Sun, 4 Feb 2024 15:36:09 +0100 Subject: [PATCH 06/14] Fix for ed issue --- pallets/inflation/src/benchmarking.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/pallets/inflation/src/benchmarking.rs b/pallets/inflation/src/benchmarking.rs index 184ae5cc64..eabfeb10a0 100644 --- a/pallets/inflation/src/benchmarking.rs +++ b/pallets/inflation/src/benchmarking.rs @@ -21,6 +21,8 @@ use super::*; use frame_benchmarking::v2::*; use frame_system::{Pallet as System, RawOrigin}; +const UNIT: u128 = 1_000_000_000_000_000_000; + /// Assert that the last event equals the provided one. fn assert_last_event(generic_event: ::RuntimeEvent) { System::::assert_last_event(generic_event.into()); @@ -48,12 +50,12 @@ fn initial_config() { let config = InflationConfiguration { recalculation_era: 123, issuance_safety_cap, - collator_reward_per_block: 11111, - treasury_reward_per_block: 33333, - dapp_reward_pool_per_era: 55555, - base_staker_reward_pool_per_era: 77777, - adjustable_staker_reward_pool_per_era: 99999, - bonus_reward_pool_per_period: 123987, + collator_reward_per_block: 11111 * UNIT, + treasury_reward_per_block: 33333 * UNIT, + dapp_reward_pool_per_era: 55555 * UNIT, + base_staker_reward_pool_per_era: 77777 * UNIT, + adjustable_staker_reward_pool_per_era: 99999 * UNIT, + bonus_reward_pool_per_period: 123987 * UNIT, ideal_staking_rate: Perquintill::from_percent(50), }; @@ -85,7 +87,18 @@ mod benchmarks { #[benchmark] fn force_set_inflation_config() { initial_config::(); - let config = InflationConfiguration::default(); + let config = InflationConfiguration { + recalculation_era: 456, + issuance_safety_cap: 112233, + collator_reward_per_block: 777, + treasury_reward_per_block: 444, + dapp_reward_pool_per_era: 55555, + base_staker_reward_pool_per_era: 77777, + adjustable_staker_reward_pool_per_era: 99999, + bonus_reward_pool_per_period: 123987, + ideal_staking_rate: Perquintill::from_percent(37), + }; + #[extrinsic_call] _(RawOrigin::Root, config.clone()); From dbcebd7bebba4f9a8c6cc629ca8bef9cbabda3d0 Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Sun, 4 Feb 2024 16:22:00 +0100 Subject: [PATCH 07/14] Fix formatting --- pallets/inflation/src/benchmarking.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/inflation/src/benchmarking.rs b/pallets/inflation/src/benchmarking.rs index eabfeb10a0..6f38537996 100644 --- a/pallets/inflation/src/benchmarking.rs +++ b/pallets/inflation/src/benchmarking.rs @@ -98,7 +98,6 @@ mod benchmarks { bonus_reward_pool_per_period: 123987, ideal_staking_rate: Perquintill::from_percent(37), }; - #[extrinsic_call] _(RawOrigin::Root, config.clone()); From 93ce72741cb6366a1e0aa4fb6ea09152f3b6144a Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Sun, 4 Feb 2024 20:16:12 +0100 Subject: [PATCH 08/14] Weights --- pallets/dapp-staking-migration/src/weights.rs | 78 +++---- .../src/weights/pallet_dapp_staking_v3.rs | 190 +++++++++--------- .../shiden/src/weights/pallet_inflation.rs | 38 ++-- 3 files changed, 154 insertions(+), 152 deletions(-) diff --git a/pallets/dapp-staking-migration/src/weights.rs b/pallets/dapp-staking-migration/src/weights.rs index ae0519c236..15db668cc8 100644 --- a/pallets/dapp-staking-migration/src/weights.rs +++ b/pallets/dapp-staking-migration/src/weights.rs @@ -20,16 +20,16 @@ //! Autogenerated weights for pallet_dapp_staking_migration //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-02-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shibuya-dev"), DB CACHE: 1024 +//! HOSTNAME: `gh-runner-01-ovh`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shiden-dev"), DB CACHE: 1024 // Executed Command: // ./target/release/astar-collator // benchmark // pallet -// --chain=shibuya-dev +// --chain=shiden-dev // --steps=50 // --repeat=20 // --pallet=pallet_dapp_staking_migration @@ -37,7 +37,7 @@ // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./benchmark-results/shibuya-dev/dapp_staking_migration_weights.rs +// --output=./benchmark-results/shiden-dev/dapp_staking_migration_weights.rs // --template=./scripts/templates/weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -65,7 +65,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking CounterForIntegratedDApps (r:1 w:1) /// Proof: DappStaking CounterForIntegratedDApps (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: DappStaking NextDAppId (r:1 w:1) @@ -74,8 +74,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `558` // Estimated: `6112` - // Minimum execution time: 46_832_000 picoseconds. - Weight::from_parts(47_613_000, 6112) + // Minimum execution time: 48_037_000 picoseconds. + Weight::from_parts(49_209_000, 6112) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -85,8 +85,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3551` - // Minimum execution time: 6_296_000 picoseconds. - Weight::from_parts(6_626_000, 3551) + // Minimum execution time: 3_226_000 picoseconds. + Weight::from_parts(3_424_000, 3551) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: DappsStaking Ledger (r:2 w:1) @@ -103,10 +103,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) fn migrate_ledger_success() -> Weight { // Proof Size summary in bytes: - // Measured: `1748` + // Measured: `1749` // Estimated: `6472` - // Minimum execution time: 70_686_000 picoseconds. - Weight::from_parts(71_976_000, 6472) + // Minimum execution time: 69_988_000 picoseconds. + Weight::from_parts(70_437_000, 6472) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -116,8 +116,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3731` - // Minimum execution time: 2_801_000 picoseconds. - Weight::from_parts(3_072_000, 3731) + // Minimum execution time: 3_019_000 picoseconds. + Weight::from_parts(3_197_000, 3731) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: DappsStaking Ledger (r:6 w:5) @@ -125,12 +125,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[1, 5]`. fn cleanup_old_storage_success(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `699 + x * (39 ±0)` + // Measured: `700 + x * (40 ±0)` // Estimated: `3731 + x * (2741 ±0)` - // Minimum execution time: 7_303_000 picoseconds. - Weight::from_parts(6_916_878, 3731) - // Standard Error: 7_249 - .saturating_add(Weight::from_parts(675_810, 0).saturating_mul(x.into())) + // Minimum execution time: 6_873_000 picoseconds. + Weight::from_parts(6_629_732, 3731) + // Standard Error: 7_063 + .saturating_add(Weight::from_parts(688_886, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(x.into()))) @@ -140,8 +140,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_094_000 picoseconds. - Weight::from_parts(2_182_000, 0) + // Minimum execution time: 2_144_000 picoseconds. + Weight::from_parts(2_233_000, 0) } } @@ -152,7 +152,7 @@ impl WeightInfo for () { /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking CounterForIntegratedDApps (r:1 w:1) /// Proof: DappStaking CounterForIntegratedDApps (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: DappStaking NextDAppId (r:1 w:1) @@ -161,8 +161,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `558` // Estimated: `6112` - // Minimum execution time: 46_832_000 picoseconds. - Weight::from_parts(47_613_000, 6112) + // Minimum execution time: 48_037_000 picoseconds. + Weight::from_parts(49_209_000, 6112) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -172,8 +172,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3551` - // Minimum execution time: 6_296_000 picoseconds. - Weight::from_parts(6_626_000, 3551) + // Minimum execution time: 3_226_000 picoseconds. + Weight::from_parts(3_424_000, 3551) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: DappsStaking Ledger (r:2 w:1) @@ -190,10 +190,10 @@ impl WeightInfo for () { /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) fn migrate_ledger_success() -> Weight { // Proof Size summary in bytes: - // Measured: `1748` + // Measured: `1749` // Estimated: `6472` - // Minimum execution time: 70_686_000 picoseconds. - Weight::from_parts(71_976_000, 6472) + // Minimum execution time: 69_988_000 picoseconds. + Weight::from_parts(70_437_000, 6472) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -203,8 +203,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3731` - // Minimum execution time: 2_801_000 picoseconds. - Weight::from_parts(3_072_000, 3731) + // Minimum execution time: 3_019_000 picoseconds. + Weight::from_parts(3_197_000, 3731) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: DappsStaking Ledger (r:6 w:5) @@ -212,12 +212,12 @@ impl WeightInfo for () { /// The range of component `x` is `[1, 5]`. fn cleanup_old_storage_success(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `699 + x * (39 ±0)` + // Measured: `700 + x * (40 ±0)` // Estimated: `3731 + x * (2741 ±0)` - // Minimum execution time: 7_303_000 picoseconds. - Weight::from_parts(6_916_878, 3731) - // Standard Error: 7_249 - .saturating_add(Weight::from_parts(675_810, 0).saturating_mul(x.into())) + // Minimum execution time: 6_873_000 picoseconds. + Weight::from_parts(6_629_732, 3731) + // Standard Error: 7_063 + .saturating_add(Weight::from_parts(688_886, 0).saturating_mul(x.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(x.into()))) @@ -227,7 +227,7 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_094_000 picoseconds. - Weight::from_parts(2_182_000, 0) + // Minimum execution time: 2_144_000 picoseconds. + Weight::from_parts(2_233_000, 0) } } diff --git a/runtime/shiden/src/weights/pallet_dapp_staking_v3.rs b/runtime/shiden/src/weights/pallet_dapp_staking_v3.rs index 88fdf31674..e6bbef634d 100644 --- a/runtime/shiden/src/weights/pallet_dapp_staking_v3.rs +++ b/runtime/shiden/src/weights/pallet_dapp_staking_v3.rs @@ -20,16 +20,16 @@ //! Autogenerated weights for pallet_dapp_staking_v3 //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-02-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shibuya-dev"), DB CACHE: 1024 +//! HOSTNAME: `gh-runner-01-ovh`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shiden-dev"), DB CACHE: 1024 // Executed Command: // ./target/release/astar-collator // benchmark // pallet -// --chain=shibuya-dev +// --chain=shiden-dev // --steps=50 // --repeat=20 // --pallet=pallet_dapp_staking_v3 @@ -37,7 +37,7 @@ // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./benchmark-results/shibuya-dev/dapp_staking_v3_weights.rs +// --output=./benchmark-results/shiden-dev/dapp_staking_v3_weights.rs // --template=./scripts/templates/weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -55,11 +55,11 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_765_000 picoseconds. - Weight::from_parts(9_104_000, 0) + // Minimum execution time: 9_090_000 picoseconds. + Weight::from_parts(9_358_000, 0) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking CounterForIntegratedDApps (r:1 w:1) /// Proof: DappStaking CounterForIntegratedDApps (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: DappStaking NextDAppId (r:1 w:1) @@ -67,46 +67,48 @@ impl WeightInfo for SubstrateWeight { fn register() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `3091` - // Minimum execution time: 17_156_000 picoseconds. - Weight::from_parts(17_426_000, 3091) + // Estimated: `3086` + // Minimum execution time: 17_212_000 picoseconds. + Weight::from_parts(17_529_000, 3086) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) fn set_dapp_reward_beneficiary() -> Weight { // Proof Size summary in bytes: - // Measured: `75` - // Estimated: `3091` - // Minimum execution time: 13_565_000 picoseconds. - Weight::from_parts(13_804_000, 3091) + // Measured: `74` + // Estimated: `3086` + // Minimum execution time: 13_417_000 picoseconds. + Weight::from_parts(13_573_000, 3086) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) fn set_dapp_owner() -> Weight { // Proof Size summary in bytes: - // Measured: `75` - // Estimated: `3091` - // Minimum execution time: 13_824_000 picoseconds. - Weight::from_parts(14_132_000, 3091) + // Measured: `74` + // Estimated: `3086` + // Minimum execution time: 13_737_000 picoseconds. + Weight::from_parts(13_916_000, 3086) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) + /// Storage: DappStaking CounterForIntegratedDApps (r:1 w:1) + /// Proof: DappStaking CounterForIntegratedDApps (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: DappStaking ContractStake (r:0 w:1) /// Proof: DappStaking ContractStake (max_values: Some(65535), max_size: Some(91), added: 2071, mode: MaxEncodedLen) fn unregister() -> Weight { // Proof Size summary in bytes: - // Measured: `75` - // Estimated: `3091` - // Minimum execution time: 17_255_000 picoseconds. - Weight::from_parts(17_659_000, 3091) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `74` + // Estimated: `3086` + // Minimum execution time: 18_180_000 picoseconds. + Weight::from_parts(18_463_000, 3086) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) @@ -120,8 +122,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `12` // Estimated: `4764` - // Minimum execution time: 33_281_000 picoseconds. - Weight::from_parts(33_759_000, 4764) + // Minimum execution time: 32_874_000 picoseconds. + Weight::from_parts(33_274_000, 4764) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -135,10 +137,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) fn unlock() -> Weight { // Proof Size summary in bytes: - // Measured: `156` + // Measured: `158` // Estimated: `4764` - // Minimum execution time: 34_451_000 picoseconds. - Weight::from_parts(34_926_000, 4764) + // Minimum execution time: 34_421_000 picoseconds. + Weight::from_parts(35_413_000, 4764) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -150,15 +152,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: DappStaking CurrentEraInfo (r:1 w:1) /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) - /// The range of component `x` is `[0, 8]`. + /// The range of component `x` is `[0, 16]`. fn claim_unlocked(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `187` + // Measured: `191` // Estimated: `4764` - // Minimum execution time: 37_641_000 picoseconds. - Weight::from_parts(38_890_045, 4764) - // Standard Error: 7_639 - .saturating_add(Weight::from_parts(183_994, 0).saturating_mul(x.into())) + // Minimum execution time: 37_435_000 picoseconds. + Weight::from_parts(39_113_839, 4764) + // Standard Error: 3_446 + .saturating_add(Weight::from_parts(118_027, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -172,15 +174,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) fn relock_unlocking() -> Weight { // Proof Size summary in bytes: - // Measured: `182` + // Measured: `200` // Estimated: `4764` - // Minimum execution time: 33_528_000 picoseconds. - Weight::from_parts(33_929_000, 4764) + // Minimum execution time: 33_192_000 picoseconds. + Weight::from_parts(33_631_000, 4764) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) /// Storage: DappStaking StakerInfo (r:1 w:1) @@ -195,15 +197,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn stake() -> Weight { // Proof Size summary in bytes: - // Measured: `250` + // Measured: `251` // Estimated: `4764` - // Minimum execution time: 45_984_000 picoseconds. - Weight::from_parts(46_329_000, 4764) + // Minimum execution time: 45_619_000 picoseconds. + Weight::from_parts(45_985_000, 4764) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) /// Storage: DappStaking StakerInfo (r:1 w:1) @@ -218,10 +220,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn unstake() -> Weight { // Proof Size summary in bytes: - // Measured: `427` + // Measured: `432` // Estimated: `4764` - // Minimum execution time: 48_584_000 picoseconds. - Weight::from_parts(49_635_000, 4764) + // Minimum execution time: 48_932_000 picoseconds. + Weight::from_parts(49_757_000, 4764) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -238,12 +240,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_past_period(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `560` + // Measured: `541` // Estimated: `4764` - // Minimum execution time: 51_711_000 picoseconds. - Weight::from_parts(50_255_137, 4764) - // Standard Error: 5_418 - .saturating_add(Weight::from_parts(3_166_243, 0).saturating_mul(x.into())) + // Minimum execution time: 51_777_000 picoseconds. + Weight::from_parts(49_689_608, 4764) + // Standard Error: 6_426 + .saturating_add(Weight::from_parts(3_298_280, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -258,12 +260,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `501` + // Measured: `519` // Estimated: `4764` - // Minimum execution time: 48_656_000 picoseconds. - Weight::from_parts(46_590_994, 4764) - // Standard Error: 4_829 - .saturating_add(Weight::from_parts(3_197_956, 0).saturating_mul(x.into())) + // Minimum execution time: 49_515_000 picoseconds. + Weight::from_parts(47_526_163, 4764) + // Standard Error: 5_683 + .saturating_add(Weight::from_parts(3_267_803, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -275,28 +277,28 @@ impl WeightInfo for SubstrateWeight { /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) fn claim_bonus_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `267` + // Measured: `271` // Estimated: `3775` - // Minimum execution time: 41_921_000 picoseconds. - Weight::from_parts(42_440_000, 3775) + // Minimum execution time: 42_226_000 picoseconds. + Weight::from_parts(42_414_000, 3775) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking DAppTiers (r:1 w:1) /// Proof: DappStaking DAppTiers (max_values: None, max_size: Some(1583), added: 4058, mode: MaxEncodedLen) fn claim_dapp_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `2585` + // Measured: `2584` // Estimated: `5048` - // Minimum execution time: 58_409_000 picoseconds. - Weight::from_parts(60_103_000, 5048) + // Minimum execution time: 57_523_000 picoseconds. + Weight::from_parts(59_818_000, 5048) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking StakerInfo (r:1 w:1) /// Proof: DappStaking StakerInfo (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) @@ -309,14 +311,14 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn unstake_from_unregistered() -> Weight { // Proof Size summary in bytes: - // Measured: `389` + // Measured: `318` // Estimated: `4764` - // Minimum execution time: 43_579_000 picoseconds. - Weight::from_parts(44_128_000, 4764) + // Minimum execution time: 41_488_000 picoseconds. + Weight::from_parts(42_872_000, 4764) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } - /// Storage: DappStaking StakerInfo (r:9 w:8) + /// Storage: DappStaking StakerInfo (r:17 w:16) /// Proof: DappStaking StakerInfo (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) @@ -324,15 +326,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) /// Storage: Balances Locks (r:1 w:0) /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// The range of component `x` is `[1, 8]`. + /// The range of component `x` is `[1, 16]`. fn cleanup_expired_entries(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `255 + x * (69 ±0)` + // Measured: `256 + x * (69 ±0)` // Estimated: `4764 + x * (2613 ±0)` - // Minimum execution time: 43_019_000 picoseconds. - Weight::from_parts(39_628_074, 4764) - // Standard Error: 15_327 - .saturating_add(Weight::from_parts(4_990_892, 0).saturating_mul(x.into())) + // Minimum execution time: 42_933_000 picoseconds. + Weight::from_parts(39_506_127, 4764) + // Standard Error: 7_450 + .saturating_add(Weight::from_parts(5_115_797, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -343,8 +345,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_301_000 picoseconds. - Weight::from_parts(11_607_000, 0) + // Minimum execution time: 11_323_000 picoseconds. + Weight::from_parts(11_592_000, 0) } /// Storage: DappStaking CurrentEraInfo (r:1 w:1) /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) @@ -354,8 +356,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `16` // Estimated: `4254` - // Minimum execution time: 17_997_000 picoseconds. - Weight::from_parts(18_491_000, 4254) + // Minimum execution time: 17_474_000 picoseconds. + Weight::from_parts(17_913_000, 4254) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -375,10 +377,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: DappStaking DAppTiers (max_values: None, max_size: Some(1583), added: 4058, mode: MaxEncodedLen) fn on_initialize_build_and_earn_to_voting() -> Weight { // Proof Size summary in bytes: - // Measured: `627` + // Measured: `839` // Estimated: `4254` - // Minimum execution time: 45_396_000 picoseconds. - Weight::from_parts(46_230_000, 4254) + // Minimum execution time: 47_997_000 picoseconds. + Weight::from_parts(49_198_000, 4254) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -392,8 +394,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `68` // Estimated: `4254` - // Minimum execution time: 24_161_000 picoseconds. - Weight::from_parts(24_565_000, 4254) + // Minimum execution time: 23_840_000 picoseconds. + Weight::from_parts(24_333_000, 4254) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -406,10 +408,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `152 + x * (32 ±0)` // Estimated: `3061 + x * (2071 ±0)` - // Minimum execution time: 7_878_000 picoseconds. - Weight::from_parts(12_213_692, 3061) - // Standard Error: 3_051 - .saturating_add(Weight::from_parts(2_363_936, 0).saturating_mul(x.into())) + // Minimum execution time: 7_372_000 picoseconds. + Weight::from_parts(12_387_768, 3061) + // Standard Error: 3_378 + .saturating_add(Weight::from_parts(2_365_111, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) @@ -424,9 +426,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `293` // Estimated: `4254` - // Minimum execution time: 8_839_000 picoseconds. - Weight::from_parts(8_975_000, 4254) + // Minimum execution time: 8_292_000 picoseconds. + Weight::from_parts(8_593_000, 4254) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } -} \ No newline at end of file +} diff --git a/runtime/shiden/src/weights/pallet_inflation.rs b/runtime/shiden/src/weights/pallet_inflation.rs index 1fdb896f5c..beaa686a86 100644 --- a/runtime/shiden/src/weights/pallet_inflation.rs +++ b/runtime/shiden/src/weights/pallet_inflation.rs @@ -20,16 +20,16 @@ //! Autogenerated weights for pallet_inflation //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-02-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shibuya-dev"), DB CACHE: 1024 +//! HOSTNAME: `gh-runner-01-ovh`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shiden-dev"), DB CACHE: 1024 // Executed Command: // ./target/release/astar-collator // benchmark // pallet -// --chain=shibuya-dev +// --chain=shiden-dev // --steps=50 // --repeat=20 // --pallet=pallet_inflation @@ -37,7 +37,7 @@ // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./benchmark-results/shibuya-dev/inflation_weights.rs +// --output=./benchmark-results/shiden-dev/inflation_weights.rs // --template=./scripts/templates/weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -57,16 +57,16 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_487_000 picoseconds. - Weight::from_parts(9_652_000, 0) + // Minimum execution time: 9_034_000 picoseconds. + Weight::from_parts(9_303_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } fn force_set_inflation_config() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_168_000 picoseconds. - Weight::from_parts(9_436_000, 0) + // Minimum execution time: 9_559_000 picoseconds. + Weight::from_parts(9_789_000, 0) } /// Storage: Inflation InflationParams (r:1 w:0) /// Proof: Inflation InflationParams (max_values: Some(1), max_size: Some(64), added: 559, mode: MaxEncodedLen) @@ -74,8 +74,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `40` // Estimated: `1549` - // Minimum execution time: 13_496_000 picoseconds. - Weight::from_parts(13_762_000, 1549) + // Minimum execution time: 13_548_000 picoseconds. + Weight::from_parts(13_796_000, 1549) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Inflation InflationParams (r:1 w:0) @@ -84,19 +84,19 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `58` // Estimated: `1549` - // Minimum execution time: 13_811_000 picoseconds. - Weight::from_parts(13_995_000, 1549) + // Minimum execution time: 13_421_000 picoseconds. + Weight::from_parts(13_808_000, 1549) .saturating_add(T::DbWeight::get().reads(1_u64)) } - /// Storage: System Account (r:2 w:1) + /// Storage: System Account (r:2 w:2) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn hooks_without_recalculation() -> Weight { // Proof Size summary in bytes: - // Measured: `174` + // Measured: `39` // Estimated: `6196` - // Minimum execution time: 21_351_000 picoseconds. - Weight::from_parts(21_749_000, 6196) + // Minimum execution time: 40_566_000 picoseconds. + Weight::from_parts(40_980_000, 6196) .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } -} \ No newline at end of file +} From d3d34df47494b915280d844d7fba26133d8bba15 Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Mon, 5 Feb 2024 07:42:06 +0100 Subject: [PATCH 09/14] Resolve TODOs --- runtime/shiden/src/lib.rs | 9 ++++----- tests/integration/src/dapp_staking_v3.rs | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 663441fa73..ebfb20ac07 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -439,7 +439,7 @@ impl pallet_inflation::Config for Runtime { type PayoutPerBlock = InflationPayoutPerBlock; type CycleConfiguration = InflationCycleConfig; type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_inflation::weights::SubstrateWeight; + type WeightInfo = weights::pallet_inflation::SubstrateWeight; } impl pallet_dapp_staking_migration::Config for Runtime { @@ -447,8 +447,6 @@ impl pallet_dapp_staking_migration::Config for Runtime { type WeightInfo = pallet_dapp_staking_migration::weights::SubstrateWeight; } -// TODO: use benchmarked values for the new pallets! - impl pallet_utility::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; @@ -1137,8 +1135,9 @@ use sp_arithmetic::fixed_point::FixedU64; pub struct InitActivePriceGet; impl Get for InitActivePriceGet { fn get() -> FixedU64 { - // TODO: set this to the correct value - FixedU64::from_rational(1, 10) + // SDN is now around 0.4 USD, but to provide meaningful rewards with the current implementation, we hardcode it to 0.01 USD. + // This means there will be less available slots, but the rewards will be higher, compensating for low SDN value compared to its total issuance. + FixedU64::from_rational(1, 100) } } diff --git a/tests/integration/src/dapp_staking_v3.rs b/tests/integration/src/dapp_staking_v3.rs index 8bcd6b3d7b..1a79c9ccbc 100644 --- a/tests/integration/src/dapp_staking_v3.rs +++ b/tests/integration/src/dapp_staking_v3.rs @@ -28,7 +28,6 @@ fn dapp_staking_triggers_inflation_recalculation() { let init_inflation_config = pallet_inflation::ActiveInflationConfig::::get(); let recalculation_era = init_inflation_config.recalculation_era; - println!("Recalculation era: {}", recalculation_era); // It's not feasible to run through all the blocks needed to trigger all the eras. // Instead, we force the era to change on a block by block basis. From bc4eba3cbd0d25f07779984286c9b6a488b8dbc7 Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Mon, 5 Feb 2024 12:51:42 +0100 Subject: [PATCH 10/14] Minor changes --- pallets/dapp-staking-v3/src/migrations.rs | 56 ++++------------------- runtime/shibuya/src/lib.rs | 3 +- runtime/shiden/src/lib.rs | 18 +++++--- 3 files changed, 20 insertions(+), 57 deletions(-) diff --git a/pallets/dapp-staking-v3/src/migrations.rs b/pallets/dapp-staking-v3/src/migrations.rs index 300b580688..e44f0704ac 100644 --- a/pallets/dapp-staking-v3/src/migrations.rs +++ b/pallets/dapp-staking-v3/src/migrations.rs @@ -17,9 +17,10 @@ // along with Astar. If not, see . use super::*; +use sp_arithmetic::fixed_point::FixedU64; /// `OnRuntimeUpgrade` logic used to set & configure init dApp staking v3 storage items. -pub struct DAppStakingV3InitConfig(PhantomData<(T, G)>); +pub struct DAppStakingV3InitConfig(PhantomData<(T, G, P)>); impl< T: Config, G: Get<( @@ -27,7 +28,8 @@ impl< TierParameters, TiersConfiguration, )>, - > OnRuntimeUpgrade for DAppStakingV3InitConfig + P: Get, + > OnRuntimeUpgrade for DAppStakingV3InitConfig { fn on_runtime_upgrade() -> Weight { if Pallet::::on_chain_storage_version() >= STORAGE_VERSION { @@ -35,7 +37,7 @@ impl< } // 0. Unwrap arguments - let (init_era, tier_params, init_tier_config) = G::get(); + let (init_era, tier_params, base_tier_config) = G::get(); // 1. Prepare init active protocol state let now = frame_system::Pallet::::block_number(); @@ -71,6 +73,9 @@ impl< }, }; + let average_price = P::get(); + let init_tier_config = base_tier_config.calculate_new(average_price, &tier_params); + // 3. Write necessary items into storage ActiveProtocolState::::put(protocol_state); StaticTierParams::::put(tier_params); @@ -120,48 +125,3 @@ impl< Ok(()) } } - -/// State in which some dApp is in. -#[derive(Encode, Decode, MaxEncodedLen, Clone, Copy, Debug, PartialEq, Eq, TypeInfo)] -pub enum OldDAppState { - /// dApp is registered and active. - Registered, - /// dApp has been unregistered in the contained era. - Unregistered(#[codec(compact)] EraNumber), -} - -/// General information about a dApp. -#[derive(Encode, Decode, MaxEncodedLen, Clone, Copy, Debug, PartialEq, Eq, TypeInfo)] -pub struct OldDAppInfo { - /// Owner of the dApp, default reward beneficiary. - pub owner: AccountId, - /// dApp's unique identifier in dApp staking. - #[codec(compact)] - pub id: DAppId, - /// Current state of the dApp. - pub state: OldDAppState, - // If `None`, rewards goes to the developer account, otherwise to the account Id in `Some`. - pub reward_beneficiary: Option, -} - -/// To be only used for Shibuya, can be removed later. -pub struct DAppStakingV3IntegratedDAppsMigration(PhantomData); -impl OnRuntimeUpgrade for DAppStakingV3IntegratedDAppsMigration { - fn on_runtime_upgrade() -> Weight { - let mut translated = 0_u64; - IntegratedDApps::::translate::, _>(|_key, old_value| { - translated.saturating_inc(); - - match old_value.state { - OldDAppState::Registered => Some(DAppInfo { - owner: old_value.owner, - id: old_value.id, - reward_beneficiary: old_value.reward_beneficiary, - }), - OldDAppState::Unregistered(_) => None, - } - }); - - T::DbWeight::get().reads_writes(translated, translated + 1 /* counted map */) - } -} diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index f60fade549..6fe4f069c0 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -1339,8 +1339,7 @@ pub type Executive = frame_executive::Executive< /// All migrations that will run on the next runtime upgrade. /// /// Once done, migrations should be removed from the tuple. -pub type Migrations = - (pallet_dapp_staking_v3::migrations::DAppStakingV3IntegratedDAppsMigration,); +pub type Migrations =(); type EventRecord = frame_system::EventRecord< ::RuntimeEvent, diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index ebfb20ac07..c83d3c39a1 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -1030,6 +1030,8 @@ construct_runtime!( NodeBlock = generic::Block, UncheckedExtrinsic = UncheckedExtrinsic { + Inflation: pallet_inflation = 5, + System: frame_system = 10, Utility: pallet_utility = 11, Identity: pallet_identity = 12, @@ -1044,7 +1046,6 @@ construct_runtime!( Balances: pallet_balances = 31, Vesting: pallet_vesting = 32, DappStaking: pallet_dapp_staking_v3 = 34, - Inflation: pallet_inflation = 35, Assets: pallet_assets = 36, Authorship: pallet_authorship = 40, @@ -1119,16 +1120,20 @@ parameter_types! { /// /// Once done, migrations should be removed from the tuple. pub type Migrations = ( + pallet_static_price_provider::InitActivePrice, pallet_inflation::PalletInflationInitConfig, - pallet_dapp_staking_v3::migrations::DAppStakingV3InitConfig, - frame_support::migrations::RemovePallet< - BlockRewardName, - ::DbWeight, + pallet_dapp_staking_v3::migrations::DAppStakingV3InitConfig< + Runtime, + InitDappStakingV3Params, + InitActivePriceGet, >, // This will handle new pallet storage version setting & it will put the new pallet into maintenance mode. // But it's most important for testing with try-runtime. pallet_dapp_staking_migration::DappStakingMigrationHandler, - pallet_static_price_provider::InitActivePrice, + frame_support::migrations::RemovePallet< + BlockRewardName, + ::DbWeight, + >, ); use sp_arithmetic::fixed_point::FixedU64; @@ -1194,7 +1199,6 @@ impl ]) .unwrap_or_default(); - // TODO: check if this is automatically adjusted post-upgrade! // Tier thresholds adjusted according to numbers observed on Shibuya let tier_thresholds = BoundedVec::try_from(vec![ TierThreshold::DynamicTvlAmount { From 1687144e680b9530f831d3857455d920ec0ed53e Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Mon, 5 Feb 2024 14:24:12 +0100 Subject: [PATCH 11/14] Fmt fix --- runtime/shibuya/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 6fe4f069c0..e3be75507c 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -1339,7 +1339,7 @@ pub type Executive = frame_executive::Executive< /// All migrations that will run on the next runtime upgrade. /// /// Once done, migrations should be removed from the tuple. -pub type Migrations =(); +pub type Migrations = (); type EventRecord = frame_system::EventRecord< ::RuntimeEvent, From 3196b3b88ef16d687be3ceab2419fc6babfb5d93 Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Mon, 5 Feb 2024 15:06:59 +0100 Subject: [PATCH 12/14] Bump versions --- Cargo.lock | 10 +++++----- bin/collator/Cargo.toml | 2 +- runtime/astar/Cargo.toml | 2 +- runtime/local/Cargo.toml | 2 +- runtime/shibuya/Cargo.toml | 2 +- runtime/shibuya/src/lib.rs | 2 +- runtime/shiden/Cargo.toml | 2 +- runtime/shiden/src/lib.rs | 7 +++---- 8 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 717e1ccedb..1e970c86d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -412,7 +412,7 @@ dependencies = [ [[package]] name = "astar-collator" -version = "5.30.0" +version = "5.31.0" dependencies = [ "astar-primitives", "astar-runtime", @@ -543,7 +543,7 @@ dependencies = [ [[package]] name = "astar-runtime" -version = "5.30.0" +version = "5.31.0" dependencies = [ "array-bytes 6.1.0", "astar-primitives", @@ -6032,7 +6032,7 @@ checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" [[package]] name = "local-runtime" -version = "5.30.0" +version = "5.31.0" dependencies = [ "array-bytes 6.1.0", "astar-primitives", @@ -13188,7 +13188,7 @@ dependencies = [ [[package]] name = "shibuya-runtime" -version = "5.30.0" +version = "5.31.0" dependencies = [ "array-bytes 6.1.0", "astar-primitives", @@ -13302,7 +13302,7 @@ dependencies = [ [[package]] name = "shiden-runtime" -version = "5.30.0" +version = "5.31.0" dependencies = [ "array-bytes 6.1.0", "astar-primitives", diff --git a/bin/collator/Cargo.toml b/bin/collator/Cargo.toml index 73d672c49c..1348e309ce 100644 --- a/bin/collator/Cargo.toml +++ b/bin/collator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "astar-collator" -version = "5.30.0" +version = "5.31.0" description = "Astar collator implementation in Rust." build = "build.rs" default-run = "astar-collator" diff --git a/runtime/astar/Cargo.toml b/runtime/astar/Cargo.toml index 71fffb5fe0..8ee6f6f5dd 100644 --- a/runtime/astar/Cargo.toml +++ b/runtime/astar/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "astar-runtime" -version = "5.30.0" +version = "5.31.0" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/local/Cargo.toml b/runtime/local/Cargo.toml index c414176c8f..c3e4cd8168 100644 --- a/runtime/local/Cargo.toml +++ b/runtime/local/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "local-runtime" -version = "5.30.0" +version = "5.31.0" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index 64381c651d..7a1b943d46 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shibuya-runtime" -version = "5.30.0" +version = "5.31.0" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index e3be75507c..cf259dae79 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -170,7 +170,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("shibuya"), impl_name: create_runtime_str!("shibuya"), authoring_version: 1, - spec_version: 120, + spec_version: 121, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, diff --git a/runtime/shiden/Cargo.toml b/runtime/shiden/Cargo.toml index 964588cdce..9a2a4d850e 100644 --- a/runtime/shiden/Cargo.toml +++ b/runtime/shiden/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shiden-runtime" -version = "5.30.0" +version = "5.31.0" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index c83d3c39a1..538a27e333 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -147,7 +147,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("shiden"), impl_name: create_runtime_str!("shiden"), authoring_version: 1, - spec_version: 117, + spec_version: 118, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -1140,9 +1140,8 @@ use sp_arithmetic::fixed_point::FixedU64; pub struct InitActivePriceGet; impl Get for InitActivePriceGet { fn get() -> FixedU64 { - // SDN is now around 0.4 USD, but to provide meaningful rewards with the current implementation, we hardcode it to 0.01 USD. - // This means there will be less available slots, but the rewards will be higher, compensating for low SDN value compared to its total issuance. - FixedU64::from_rational(1, 100) + // Roughly the average price, taken from CoinMarketCap data. + FixedU64::from_rational(32, 100) } } From 4727b60cef2582270f05b9044b60f0572635d737 Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Mon, 5 Feb 2024 15:55:39 +0100 Subject: [PATCH 13/14] Comment --- runtime/shiden/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 538a27e333..97e119e68d 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -1030,6 +1030,7 @@ construct_runtime!( NodeBlock = generic::Block, UncheckedExtrinsic = UncheckedExtrinsic { + // Inflation needs to execute `on_initialize` as soon as possible, and `on_finalize` as late as possible. Inflation: pallet_inflation = 5, System: frame_system = 10, From 9865dcbe692e74159248204bd48e05df471dbc7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Pa=C4=8Dandi?= <3002868+Dinonard@users.noreply.github.com> Date: Tue, 6 Feb 2024 13:53:06 +0100 Subject: [PATCH 14/14] dapp staking v3 - Freeze Improvements (#1164) * Init commit * Collator selection change * Collator selection update * Integration tests * Update astar spec due to changes * Weight updates --- Cargo.lock | 3 +- pallets/collator-selection/Cargo.toml | 1 + pallets/collator-selection/src/lib.rs | 20 + pallets/collator-selection/src/mock.rs | 10 + pallets/collator-selection/src/tests.rs | 10 + pallets/collator-selection/src/weights.rs | 341 ++++++++------- pallets/dapp-staking-migration/src/lib.rs | 19 +- pallets/dapp-staking-migration/src/mock.rs | 1 + pallets/dapp-staking-v3/Cargo.toml | 2 +- .../dapp-staking-v3/src/benchmarking/mod.rs | 37 +- pallets/dapp-staking-v3/src/lib.rs | 41 +- pallets/dapp-staking-v3/src/test/mock.rs | 9 + .../dapp-staking-v3/src/test/testing_utils.rs | 6 +- pallets/dapp-staking-v3/src/test/tests.rs | 40 +- pallets/dapp-staking-v3/src/weights.rs | 413 ++++++++++-------- precompiles/dapp-staking-v3/src/test/mock.rs | 1 + primitives/src/dapp_staking.rs | 12 + runtime/astar/src/lib.rs | 11 +- runtime/local/src/lib.rs | 1 + runtime/shibuya/src/lib.rs | 25 +- .../src/weights/pallet_dapp_staking_v3.rs | 203 +++++---- runtime/shiden/src/lib.rs | 29 +- .../src/weights/pallet_dapp_staking_v3.rs | 135 +++--- tests/integration/Cargo.toml | 7 +- tests/integration/src/dapp_staking_v3.rs | 47 ++ tests/integration/src/setup.rs | 2 + 26 files changed, 898 insertions(+), 528 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e970c86d9..295a1cd6de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4989,6 +4989,7 @@ dependencies = [ "libsecp256k1", "pallet-assets", "pallet-balances", + "pallet-collator-selection", "pallet-contracts", "pallet-contracts-primitives", "pallet-dapp-staking-v3", @@ -7711,7 +7712,7 @@ dependencies = [ [[package]] name = "pallet-dapp-staking-v3" -version = "0.0.1-alpha" +version = "0.1.0" dependencies = [ "assert_matches", "astar-primitives", diff --git a/pallets/collator-selection/Cargo.toml b/pallets/collator-selection/Cargo.toml index 4374e602f4..0a217da070 100644 --- a/pallets/collator-selection/Cargo.toml +++ b/pallets/collator-selection/Cargo.toml @@ -59,6 +59,7 @@ std = [ "pallet-authorship/std", "pallet-session/std", "pallet-aura/std", + "pallet-balances/std", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/collator-selection/src/lib.rs b/pallets/collator-selection/src/lib.rs index 58c49e8866..59754c0d2a 100644 --- a/pallets/collator-selection/src/lib.rs +++ b/pallets/collator-selection/src/lib.rs @@ -109,6 +109,12 @@ pub mod pallet { } } + /// Used to check whether an account is allowed to be a candidate. + pub trait AccountCheck { + /// `true` if the account is allowed to be a candidate, `false` otherwise. + fn allowed_candidacy(account: &AccountId) -> bool; + } + /// Configure the pallet by specifying the parameters and types on which it depends. #[pallet::config] pub trait Config: frame_system::Config { @@ -157,6 +163,9 @@ pub mod pallet { /// How many in perc kicked collators should be slashed (set 0 to disable) type SlashRatio: Get; + /// Used to check whether an account is allowed to be a candidate. + type AccountCheck: AccountCheck; + /// The weight information of this pallet. type WeightInfo: WeightInfo; } @@ -287,6 +296,8 @@ pub mod pallet { NoAssociatedValidatorId, /// Validator ID is not yet registered ValidatorNotRegistered, + /// Account is now allowed to be a candidate due to an external reason (e.g. it might be participating in dApp staking) + NotAllowedCandidate, } #[pallet::hooks] @@ -375,6 +386,10 @@ pub mod pallet { !Self::invulnerables().contains(&who), Error::::AlreadyInvulnerable ); + ensure!( + T::AccountCheck::allowed_candidacy(&who), + Error::::NotAllowedCandidate + ); let validator_key = T::ValidatorIdOf::convert(who.clone()) .ok_or(Error::::NoAssociatedValidatorId)?; @@ -502,6 +517,11 @@ pub mod pallet { }) .collect::>() } + + /// Check whether an account is a candidate. + pub fn is_account_candidate(account: &T::AccountId) -> bool { + Self::candidates().iter().any(|c| &c.who == account) + } } /// Keep track of number of authored blocks per authority, uncles are counted as well since diff --git a/pallets/collator-selection/src/mock.rs b/pallets/collator-selection/src/mock.rs index 3ba37fac6f..27f4efc171 100644 --- a/pallets/collator-selection/src/mock.rs +++ b/pallets/collator-selection/src/mock.rs @@ -212,6 +212,15 @@ impl ValidatorRegistration for IsRegistered { } } +pub(crate) const BLACKLISTED_ACCOUNT: u64 = 987654321; + +pub struct DummyAccountCheck; +impl AccountCheck for DummyAccountCheck { + fn allowed_candidacy(account: &u64) -> bool { + *account != BLACKLISTED_ACCOUNT + } +} + impl Config for Test { type RuntimeEvent = RuntimeEvent; type Currency = Balances; @@ -225,6 +234,7 @@ impl Config for Test { type ValidatorIdOf = IdentityCollator; type ValidatorRegistration = IsRegistered; type SlashRatio = SlashRatio; + type AccountCheck = DummyAccountCheck; type WeightInfo = (); } diff --git a/pallets/collator-selection/src/tests.rs b/pallets/collator-selection/src/tests.rs index dd60803912..a6e51f93d5 100644 --- a/pallets/collator-selection/src/tests.rs +++ b/pallets/collator-selection/src/tests.rs @@ -214,6 +214,16 @@ fn cannot_register_as_candidate_if_poor() { }); } +#[test] +fn cannot_register_candidate_if_externally_blacklisted() { + new_test_ext().execute_with(|| { + assert_noop!( + CollatorSelection::register_as_candidate(RuntimeOrigin::signed(BLACKLISTED_ACCOUNT)), + Error::::NotAllowedCandidate, + ); + }) +} + #[test] fn register_as_candidate_works() { new_test_ext().execute_with(|| { diff --git a/pallets/collator-selection/src/weights.rs b/pallets/collator-selection/src/weights.rs index 1a89e8d052..95ae3a2835 100644 --- a/pallets/collator-selection/src/weights.rs +++ b/pallets/collator-selection/src/weights.rs @@ -1,3 +1,4 @@ + // This file is part of Astar. // Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. @@ -15,19 +16,19 @@ // See the License for the specific language governing permissions and // limitations under the License. - //! Autogenerated weights for pallet_collator_selection //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-04-04, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shibuya-dev"), DB CACHE: 1024 +//! DATE: 2024-02-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `gh-runner-01-ovh`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shiden-dev"), DB CACHE: 1024 // Executed Command: // ./target/release/astar-collator // benchmark // pallet -// --chain=shibuya-dev +// --chain=shiden-dev // --steps=50 // --repeat=20 // --pallet=pallet_collator_selection @@ -35,7 +36,7 @@ // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./benchmark-results/collator_selection_weights.rs +// --output=./benchmark-results/shiden-dev/collator_selection_weights.rs // --template=./scripts/templates/weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -43,7 +44,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions needed for pallet_collator_selection. pub trait WeightInfo { @@ -59,216 +60,248 @@ pub trait WeightInfo { /// Weights for pallet_collator_selection using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Session NextKeys (r:48 w:0) - // Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) - // Storage: CollatorSelection Invulnerables (r:0 w:1) - // Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Session NextKeys (r:48 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// Storage: CollatorSelection Invulnerables (r:0 w:1) + /// Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `b` is `[1, 48]`. fn set_invulnerables(b: u32, ) -> Weight { - // Minimum execution time: 14_956 nanoseconds. - Weight::from_parts(15_730_242, 0) - .saturating_add(Weight::from_parts(0, 408)) - // Standard Error: 4_959 - .saturating_add(Weight::from_parts(2_577_606, 0).saturating_mul(b.into())) + // Proof Size summary in bytes: + // Measured: `204 + b * (79 ±0)` + // Estimated: `1194 + b * (2554 ±0)` + // Minimum execution time: 13_733_000 picoseconds. + Weight::from_parts(14_576_858, 1194) + // Standard Error: 4_742 + .saturating_add(Weight::from_parts(2_507_115, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) - .saturating_add(Weight::from_parts(0, 2633).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(0, 2554).saturating_mul(b.into())) } - // Storage: CollatorSelection DesiredCandidates (r:0 w:1) - // Proof Skipped: CollatorSelection DesiredCandidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection DesiredCandidates (r:0 w:1) + /// Proof Skipped: CollatorSelection DesiredCandidates (max_values: Some(1), max_size: None, mode: Measured) fn set_desired_candidates() -> Weight { - // Minimum execution time: 7_042 nanoseconds. - Weight::from_parts(7_159_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_143_000 picoseconds. + Weight::from_parts(7_357_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: CollatorSelection CandidacyBond (r:0 w:1) - // Proof Skipped: CollatorSelection CandidacyBond (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection CandidacyBond (r:0 w:1) + /// Proof Skipped: CollatorSelection CandidacyBond (max_values: Some(1), max_size: None, mode: Measured) fn set_candidacy_bond() -> Weight { - // Minimum execution time: 7_245 nanoseconds. - Weight::from_parts(7_395_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_292_000 picoseconds. + Weight::from_parts(7_433_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: CollatorSelection Candidates (r:1 w:1) - // Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) - // Storage: CollatorSelection DesiredCandidates (r:1 w:0) - // Proof Skipped: CollatorSelection DesiredCandidates (max_values: Some(1), max_size: None, mode: Measured) - // Storage: CollatorSelection Invulnerables (r:1 w:0) - // Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Session NextKeys (r:1 w:0) - // Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) - // Storage: CollatorSelection CandidacyBond (r:1 w:0) - // Proof Skipped: CollatorSelection CandidacyBond (max_values: Some(1), max_size: None, mode: Measured) - // Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) - // Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) + /// Storage: CollatorSelection Candidates (r:1 w:1) + /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection DesiredCandidates (r:1 w:0) + /// Proof Skipped: CollatorSelection DesiredCandidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection Invulnerables (r:1 w:0) + /// Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: DappStaking Ledger (r:1 w:0) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// Storage: CollatorSelection CandidacyBond (r:1 w:0) + /// Proof Skipped: CollatorSelection CandidacyBond (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) + /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) /// The range of component `c` is `[1, 148]`. fn register_as_candidate(c: u32, ) -> Weight { - // Minimum execution time: 39_356 nanoseconds. - Weight::from_parts(42_616_377, 0) - .saturating_add(Weight::from_parts(0, 9891)) - // Standard Error: 670 - .saturating_add(Weight::from_parts(39_880, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(5_u64)) + // Proof Size summary in bytes: + // Measured: `962 + c * (50 ±0)` + // Estimated: `4307 + c * (51 ±0)` + // Minimum execution time: 44_695_000 picoseconds. + Weight::from_parts(46_834_255, 4307) + // Standard Error: 586 + .saturating_add(Weight::from_parts(44_873, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 306).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(0, 51).saturating_mul(c.into())) } - // Storage: CollatorSelection Candidates (r:1 w:1) - // Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) - // Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) - // Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) + /// Storage: CollatorSelection Candidates (r:1 w:1) + /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) + /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) /// The range of component `c` is `[6, 148]`. fn leave_intent(c: u32, ) -> Weight { - // Minimum execution time: 28_341 nanoseconds. - Weight::from_parts(30_119_984, 0) - .saturating_add(Weight::from_parts(0, 1369)) - // Standard Error: 1_581 - .saturating_add(Weight::from_parts(42_495, 0).saturating_mul(c.into())) + // Proof Size summary in bytes: + // Measured: `342 + c * (49 ±0)` + // Estimated: `1845 + c * (49 ±0)` + // Minimum execution time: 30_579_000 picoseconds. + Weight::from_parts(34_125_189, 1845) + // Standard Error: 1_048 + .saturating_add(Weight::from_parts(45_625, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 98).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(0, 49).saturating_mul(c.into())) } - // Storage: System Account (r:2 w:2) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) - // Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) + /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) fn note_author() -> Weight { - // Minimum execution time: 31_536 nanoseconds. - Weight::from_parts(31_986_000, 0) - .saturating_add(Weight::from_parts(0, 5497)) + // Proof Size summary in bytes: + // Measured: `226` + // Estimated: `6196` + // Minimum execution time: 43_377_000 picoseconds. + Weight::from_parts(43_827_000, 6196) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: CollatorSelection Candidates (r:1 w:0) - // Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) - // Storage: CollatorSelection LastAuthoredBlock (r:148 w:0) - // Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) - // Storage: CollatorSelection Invulnerables (r:1 w:0) - // Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) - // Storage: System Account (r:143 w:143) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: CollatorSelection SlashDestination (r:1 w:0) - // Proof Skipped: CollatorSelection SlashDestination (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection Candidates (r:1 w:0) + /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection LastAuthoredBlock (r:148 w:0) + /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) + /// Storage: CollatorSelection Invulnerables (r:1 w:0) + /// Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: System Account (r:143 w:143) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: CollatorSelection SlashDestination (r:1 w:0) + /// Proof Skipped: CollatorSelection SlashDestination (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `r` is `[1, 148]`. /// The range of component `c` is `[1, 148]`. fn new_session(r: u32, c: u32, ) -> Weight { - // Minimum execution time: 16_816 nanoseconds. - Weight::from_parts(17_132_000, 0) - .saturating_add(Weight::from_parts(0, 4714)) - // Standard Error: 475_405 - .saturating_add(Weight::from_parts(15_758_567, 0).saturating_mul(c.into())) + // Proof Size summary in bytes: + // Measured: `3902 + c * (97 ±0) + r * (112 ±0)` + // Estimated: `3818 + c * (2632 ±2) + r * (2599 ±0)` + // Minimum execution time: 17_957_000 picoseconds. + Weight::from_parts(18_201_000, 3818) + // Standard Error: 564_328 + .saturating_add(Weight::from_parts(18_024_338, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) - .saturating_add(Weight::from_parts(0, 3131).saturating_mul(c.into())) - .saturating_add(Weight::from_parts(0, 2751).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2632).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(0, 2599).saturating_mul(r.into())) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Session NextKeys (r:48 w:0) - // Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) - // Storage: CollatorSelection Invulnerables (r:0 w:1) - // Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Session NextKeys (r:48 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// Storage: CollatorSelection Invulnerables (r:0 w:1) + /// Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `b` is `[1, 48]`. fn set_invulnerables(b: u32, ) -> Weight { - // Minimum execution time: 14_956 nanoseconds. - Weight::from_parts(15_730_242, 0) - .saturating_add(Weight::from_parts(0, 408)) - // Standard Error: 4_959 - .saturating_add(Weight::from_parts(2_577_606, 0).saturating_mul(b.into())) + // Proof Size summary in bytes: + // Measured: `204 + b * (79 ±0)` + // Estimated: `1194 + b * (2554 ±0)` + // Minimum execution time: 13_733_000 picoseconds. + Weight::from_parts(14_576_858, 1194) + // Standard Error: 4_742 + .saturating_add(Weight::from_parts(2_507_115, 0).saturating_mul(b.into())) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) - .saturating_add(Weight::from_parts(0, 2633).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(0, 2554).saturating_mul(b.into())) } - // Storage: CollatorSelection DesiredCandidates (r:0 w:1) - // Proof Skipped: CollatorSelection DesiredCandidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection DesiredCandidates (r:0 w:1) + /// Proof Skipped: CollatorSelection DesiredCandidates (max_values: Some(1), max_size: None, mode: Measured) fn set_desired_candidates() -> Weight { - // Minimum execution time: 7_042 nanoseconds. - Weight::from_parts(7_159_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_143_000 picoseconds. + Weight::from_parts(7_357_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: CollatorSelection CandidacyBond (r:0 w:1) - // Proof Skipped: CollatorSelection CandidacyBond (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection CandidacyBond (r:0 w:1) + /// Proof Skipped: CollatorSelection CandidacyBond (max_values: Some(1), max_size: None, mode: Measured) fn set_candidacy_bond() -> Weight { - // Minimum execution time: 7_245 nanoseconds. - Weight::from_parts(7_395_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_292_000 picoseconds. + Weight::from_parts(7_433_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: CollatorSelection Candidates (r:1 w:1) - // Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) - // Storage: CollatorSelection DesiredCandidates (r:1 w:0) - // Proof Skipped: CollatorSelection DesiredCandidates (max_values: Some(1), max_size: None, mode: Measured) - // Storage: CollatorSelection Invulnerables (r:1 w:0) - // Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Session NextKeys (r:1 w:0) - // Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) - // Storage: CollatorSelection CandidacyBond (r:1 w:0) - // Proof Skipped: CollatorSelection CandidacyBond (max_values: Some(1), max_size: None, mode: Measured) - // Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) - // Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) + /// Storage: CollatorSelection Candidates (r:1 w:1) + /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection DesiredCandidates (r:1 w:0) + /// Proof Skipped: CollatorSelection DesiredCandidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection Invulnerables (r:1 w:0) + /// Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: DappStaking Ledger (r:1 w:0) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// Storage: CollatorSelection CandidacyBond (r:1 w:0) + /// Proof Skipped: CollatorSelection CandidacyBond (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) + /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) /// The range of component `c` is `[1, 148]`. fn register_as_candidate(c: u32, ) -> Weight { - // Minimum execution time: 39_356 nanoseconds. - Weight::from_parts(42_616_377, 0) - .saturating_add(Weight::from_parts(0, 9891)) - // Standard Error: 670 - .saturating_add(Weight::from_parts(39_880, 0).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(5_u64)) + // Proof Size summary in bytes: + // Measured: `962 + c * (50 ±0)` + // Estimated: `4307 + c * (51 ±0)` + // Minimum execution time: 44_695_000 picoseconds. + Weight::from_parts(46_834_255, 4307) + // Standard Error: 586 + .saturating_add(Weight::from_parts(44_873, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 306).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(0, 51).saturating_mul(c.into())) } - // Storage: CollatorSelection Candidates (r:1 w:1) - // Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) - // Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) - // Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) + /// Storage: CollatorSelection Candidates (r:1 w:1) + /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) + /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) /// The range of component `c` is `[6, 148]`. fn leave_intent(c: u32, ) -> Weight { - // Minimum execution time: 28_341 nanoseconds. - Weight::from_parts(30_119_984, 0) - .saturating_add(Weight::from_parts(0, 1369)) - // Standard Error: 1_581 - .saturating_add(Weight::from_parts(42_495, 0).saturating_mul(c.into())) + // Proof Size summary in bytes: + // Measured: `342 + c * (49 ±0)` + // Estimated: `1845 + c * (49 ±0)` + // Minimum execution time: 30_579_000 picoseconds. + Weight::from_parts(34_125_189, 1845) + // Standard Error: 1_048 + .saturating_add(Weight::from_parts(45_625, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 98).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(0, 49).saturating_mul(c.into())) } - // Storage: System Account (r:2 w:2) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) - // Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) + /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) fn note_author() -> Weight { - // Minimum execution time: 31_536 nanoseconds. - Weight::from_parts(31_986_000, 0) - .saturating_add(Weight::from_parts(0, 5497)) + // Proof Size summary in bytes: + // Measured: `226` + // Estimated: `6196` + // Minimum execution time: 43_377_000 picoseconds. + Weight::from_parts(43_827_000, 6196) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: CollatorSelection Candidates (r:1 w:0) - // Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) - // Storage: CollatorSelection LastAuthoredBlock (r:148 w:0) - // Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) - // Storage: CollatorSelection Invulnerables (r:1 w:0) - // Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) - // Storage: System Account (r:143 w:143) - // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - // Storage: CollatorSelection SlashDestination (r:1 w:0) - // Proof Skipped: CollatorSelection SlashDestination (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection Candidates (r:1 w:0) + /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: CollatorSelection LastAuthoredBlock (r:148 w:0) + /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) + /// Storage: CollatorSelection Invulnerables (r:1 w:0) + /// Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: System Account (r:143 w:143) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: CollatorSelection SlashDestination (r:1 w:0) + /// Proof Skipped: CollatorSelection SlashDestination (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `r` is `[1, 148]`. /// The range of component `c` is `[1, 148]`. fn new_session(r: u32, c: u32, ) -> Weight { - // Minimum execution time: 16_816 nanoseconds. - Weight::from_parts(17_132_000, 0) - .saturating_add(Weight::from_parts(0, 4714)) - // Standard Error: 475_405 - .saturating_add(Weight::from_parts(15_758_567, 0).saturating_mul(c.into())) + // Proof Size summary in bytes: + // Measured: `3902 + c * (97 ±0) + r * (112 ±0)` + // Estimated: `3818 + c * (2632 ±2) + r * (2599 ±0)` + // Minimum execution time: 17_957_000 picoseconds. + Weight::from_parts(18_201_000, 3818) + // Standard Error: 564_328 + .saturating_add(Weight::from_parts(18_024_338, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(c.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(c.into()))) - .saturating_add(Weight::from_parts(0, 3131).saturating_mul(c.into())) - .saturating_add(Weight::from_parts(0, 2751).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2632).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(0, 2599).saturating_mul(r.into())) } -} \ No newline at end of file +} diff --git a/pallets/dapp-staking-migration/src/lib.rs b/pallets/dapp-staking-migration/src/lib.rs index a49ad9021c..68dc8c0230 100644 --- a/pallets/dapp-staking-migration/src/lib.rs +++ b/pallets/dapp-staking-migration/src/lib.rs @@ -168,7 +168,7 @@ pub mod pallet { impl Pallet { /// Execute migrations steps until the specified weight limit has been consumed. /// - /// Depending on the number of entries migrated and/or deleted, appropriate events are emited. + /// Depending on the number of entries migrated and/or deleted, appropriate events are emitted. /// /// In case at least some progress is made, `Ok(_)` is returned. /// If no progress is made, `Err(_)` is returned. @@ -295,7 +295,7 @@ pub mod pallet { /// Steps: /// 1. Attempt to `drain` a single DB entry from the old storage. If it's unregistered, move on. /// 2. Unreserve the old `RegisterDeposit` amount from the developer account. - /// 2. Re-decode old smart contract type into new one. Operation should be infalible in practice since the same underlying type is used. + /// 2. Re-decode old smart contract type into new one. Operation should be infallible in practice since the same underlying type is used. /// 3. `register` the old-new smart contract into dApp staking v3 pallet. /// /// Returns `Ok(_)` if an entry was migrated, `Err(_)` if there are no more entries to migrate. @@ -348,13 +348,6 @@ pub mod pallet { smart_contract, error, ); - - // This should never happen, but if it does, we want to know about it. - #[cfg(feature = "try-runtime")] - panic!( - "Failed to register smart contract: {:?} with error: {:?}.", - smart_contract, error - ); } } @@ -383,7 +376,7 @@ pub mod pallet { let locked = old_account_ledger.locked; // Old unbonding amount can just be released, to keep things simple. - // Alternative is to re-calculat this into unlocking chunks. + // Alternative is to re-calculate this into unlocking chunks. let _total_unbonding = old_account_ledger.unbonding_info.sum(); ::Currency::remove_lock( @@ -430,7 +423,7 @@ pub mod pallet { /// Used to remove one entry from the old _dapps_staking_v2_ storage. /// /// If there are no more entries to remove, returns `Err(_)` with consumed weight and number of deleted entries. - /// Otherwise returns `Ok(_)` with consumed weight and number of consumed enries. + /// Otherwise returns `Ok(_)` with consumed weight and number of consumed entries. pub(crate) fn cleanup_old_storage(limit: u32) -> Result<(Weight, u32), (Weight, u32)> { let hashed_prefix = twox_128(pallet_dapps_staking::Pallet::::name().as_bytes()); @@ -474,8 +467,8 @@ pub mod pallet { /// Min allowed weight that migration should be allowed to consume. /// - /// This serves as a safety marging, to prevent accidental overspending, due to - /// inprecision in implementation or benchmarks, when small weight limit is specified. + /// This serves as a safety margin, to prevent accidental overspending, due to + /// imprecision in implementation or benchmarks, when small weight limit is specified. pub(crate) fn min_call_weight() -> Weight { // 5% of block should be fine T::BlockWeights::get().max_block / 10 diff --git a/pallets/dapp-staking-migration/src/mock.rs b/pallets/dapp-staking-migration/src/mock.rs index a3de9ef81f..262c0ce340 100644 --- a/pallets/dapp-staking-migration/src/mock.rs +++ b/pallets/dapp-staking-migration/src/mock.rs @@ -182,6 +182,7 @@ impl pallet_dapp_staking_v3::Config for Test { type StakingRewardHandler = DummyStakingRewardHandler; type CycleConfiguration = DummyCycleConfiguration; type Observers = (); + type AccountCheck = (); type EraRewardSpanLength = ConstU32<8>; type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<10>; diff --git a/pallets/dapp-staking-v3/Cargo.toml b/pallets/dapp-staking-v3/Cargo.toml index c79755828d..2f06a1a054 100644 --- a/pallets/dapp-staking-v3/Cargo.toml +++ b/pallets/dapp-staking-v3/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-dapp-staking-v3" -version = "0.0.1-alpha" +version = "0.1.0" description = "Pallet for dApp staking v3 protocol" authors.workspace = true edition.workspace = true diff --git a/pallets/dapp-staking-v3/src/benchmarking/mod.rs b/pallets/dapp-staking-v3/src/benchmarking/mod.rs index fbe1a97b9a..af1cf1034a 100644 --- a/pallets/dapp-staking-v3/src/benchmarking/mod.rs +++ b/pallets/dapp-staking-v3/src/benchmarking/mod.rs @@ -151,7 +151,7 @@ mod benchmarks { } #[benchmark] - fn lock() { + fn lock_new_account() { initial_config::(); let staker: T::AccountId = whitelisted_caller(); @@ -167,7 +167,7 @@ mod benchmarks { T::BenchmarkHelper::set_balance(&staker, amount); #[extrinsic_call] - _(RawOrigin::Signed(staker.clone()), amount); + lock(RawOrigin::Signed(staker.clone()), amount); assert_last_event::( Event::::Locked { @@ -178,6 +178,39 @@ mod benchmarks { ); } + #[benchmark] + fn lock_existing_account() { + initial_config::(); + + let staker: T::AccountId = whitelisted_caller(); + let owner: T::AccountId = account("dapp_owner", 0, SEED); + let smart_contract = T::BenchmarkHelper::get_smart_contract(1); + assert_ok!(DappStaking::::register( + RawOrigin::Root.into(), + owner.clone().into(), + smart_contract.clone(), + )); + + let amount_1 = T::MinimumLockedAmount::get(); + let amount_2 = 19; + T::BenchmarkHelper::set_balance(&staker, amount_1 + amount_2); + assert_ok!(DappStaking::::lock( + RawOrigin::Signed(staker.clone()).into(), + amount_1, + )); + + #[extrinsic_call] + lock(RawOrigin::Signed(staker.clone()), amount_2); + + assert_last_event::( + Event::::Locked { + account: staker, + amount: amount_2, + } + .into(), + ); + } + #[benchmark] fn unlock() { initial_config::(); diff --git a/pallets/dapp-staking-v3/src/lib.rs b/pallets/dapp-staking-v3/src/lib.rs index 8bf1e0d36e..ff243de881 100644 --- a/pallets/dapp-staking-v3/src/lib.rs +++ b/pallets/dapp-staking-v3/src/lib.rs @@ -52,8 +52,8 @@ pub use sp_std::vec::Vec; use astar_primitives::{ dapp_staking::{ - CycleConfiguration, DAppId, EraNumber, Observer as DAppStakingObserver, PeriodNumber, - SmartContractHandle, StakingRewardHandler, TierId, + AccountCheck, CycleConfiguration, DAppId, EraNumber, Observer as DAppStakingObserver, + PeriodNumber, SmartContractHandle, StakingRewardHandler, TierId, }, oracle::PriceProvider, Balance, BlockNumber, @@ -144,6 +144,9 @@ pub mod pallet { /// dApp staking event observers, notified when certain events occur. type Observers: DAppStakingObserver; + /// Used to check whether an account is allowed to participate in dApp staking. + type AccountCheck: AccountCheck; + /// Maximum length of a single era reward span length entry. #[pallet::constant] type EraRewardSpanLength: Get; @@ -307,6 +310,8 @@ pub mod pallet { ZeroAmount, /// Total locked amount for staker is below minimum threshold. LockedAmountBelowThreshold, + /// Account is not allowed to participate in dApp staking due to some external reason (e.g. account is already a collator). + AccountNotAvailableForDappStaking, /// Cannot add additional unlocking chunks due to capacity limit. TooManyUnlockingChunks, /// Remaining stake prevents entire balance of starting the unlocking process. @@ -765,16 +770,30 @@ pub mod pallet { /// /// Locked amount can immediately be used for staking. #[pallet::call_index(7)] - #[pallet::weight(T::WeightInfo::lock())] - pub fn lock(origin: OriginFor, #[pallet::compact] amount: Balance) -> DispatchResult { + #[pallet::weight(T::WeightInfo::lock_new_account().max(T::WeightInfo::lock_existing_account()))] + pub fn lock( + origin: OriginFor, + #[pallet::compact] amount: Balance, + ) -> DispatchResultWithPostInfo { Self::ensure_pallet_enabled()?; let account = ensure_signed(origin)?; let mut ledger = Ledger::::get(&account); + // Only do the check for new accounts. + // External logic should ensure that accounts which are already participating in dApp staking aren't + // allowed to participate elsewhere where they shouldn't. + let is_new_account = ledger.is_empty(); + if is_new_account { + ensure!( + T::AccountCheck::allowed_to_stake(&account), + Error::::AccountNotAvailableForDappStaking + ); + } + // Calculate & check amount available for locking let available_balance = - T::Currency::balance(&account).saturating_sub(ledger.active_locked_amount()); + T::Currency::total_balance(&account).saturating_sub(ledger.active_locked_amount()); let amount_to_lock = available_balance.min(amount); ensure!(!amount_to_lock.is_zero(), Error::::ZeroAmount); @@ -795,7 +814,12 @@ pub mod pallet { amount: amount_to_lock, }); - Ok(()) + Ok(Some(if is_new_account { + T::WeightInfo::lock_new_account() + } else { + T::WeightInfo::lock_existing_account() + }) + .into()) } /// Attempts to start the unlocking process for the specified amount. @@ -1557,6 +1581,11 @@ pub mod pallet { } impl Pallet { + /// `true` if the account is a staker, `false` otherwise. + pub fn is_staker(account: &T::AccountId) -> bool { + Ledger::::contains_key(account) + } + /// `Err` if pallet disabled for maintenance, `Ok` otherwise. pub(crate) fn ensure_pallet_enabled() -> Result<(), Error> { if ActiveProtocolState::::get().maintenance { diff --git a/pallets/dapp-staking-v3/src/test/mock.rs b/pallets/dapp-staking-v3/src/test/mock.rs index 1be4b46eab..ae7e1c5046 100644 --- a/pallets/dapp-staking-v3/src/test/mock.rs +++ b/pallets/dapp-staking-v3/src/test/mock.rs @@ -193,6 +193,14 @@ impl DappStakingObserver for DummyDappStakingObserver { } } +pub(crate) const BLACKLISTED_ACCOUNT: AccountId = 789456123; +pub struct DummyAccountCheck; +impl AccountCheck for DummyAccountCheck { + fn allowed_to_stake(account: &AccountId) -> bool { + *account != BLACKLISTED_ACCOUNT + } +} + impl pallet_dapp_staking::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = RuntimeFreezeReason; @@ -203,6 +211,7 @@ impl pallet_dapp_staking::Config for Test { type StakingRewardHandler = DummyStakingRewardHandler; type CycleConfiguration = DummyCycleConfiguration; type Observers = DummyDappStakingObserver; + type AccountCheck = DummyAccountCheck; type EraRewardSpanLength = ConstU32<8>; type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<10>; diff --git a/pallets/dapp-staking-v3/src/test/testing_utils.rs b/pallets/dapp-staking-v3/src/test/testing_utils.rs index 6c4cf6f9d9..5ddb48bf4f 100644 --- a/pallets/dapp-staking-v3/src/test/testing_utils.rs +++ b/pallets/dapp-staking-v3/src/test/testing_utils.rs @@ -26,7 +26,7 @@ use crate::{ use frame_support::{ assert_ok, - traits::{fungible::InspectFreeze, Get, OnIdle}, + traits::{fungible::InspectFreeze, Currency, Get, OnIdle}, weights::Weight, }; use sp_runtime::{traits::Zero, Perbill}; @@ -208,11 +208,11 @@ pub(crate) fn assert_unregister(smart_contract: &MockSmartContract) { pub(crate) fn assert_lock(account: AccountId, amount: Balance) { let pre_snapshot = MemorySnapshot::new(); - let free_balance = Balances::free_balance(&account); + let total_balance = Balances::total_balance(&account); let locked_balance = pre_snapshot.locked_balance(&account); let init_frozen_balance = Balances::balance_frozen(&FreezeReason::DAppStaking.into(), &account); - let available_balance = free_balance + let available_balance = total_balance .checked_sub(locked_balance) .expect("Locked amount cannot be greater than available free balance"); let expected_lock_amount = available_balance.min(amount); diff --git a/pallets/dapp-staking-v3/src/test/tests.rs b/pallets/dapp-staking-v3/src/test/tests.rs index dc00bddd63..5f83eb7b52 100644 --- a/pallets/dapp-staking-v3/src/test/tests.rs +++ b/pallets/dapp-staking-v3/src/test/tests.rs @@ -25,7 +25,10 @@ use crate::{ use frame_support::{ assert_noop, assert_ok, assert_storage_noop, error::BadOrigin, - traits::{fungible::Unbalanced as FunUnbalanced, Currency, Get, OnFinalize, OnInitialize}, + traits::{ + fungible::Unbalanced as FunUnbalanced, Currency, Get, OnFinalize, OnInitialize, + ReservableCurrency, + }, }; use sp_runtime::traits::Zero; @@ -473,7 +476,7 @@ fn lock_is_ok() { ExtBuilder::build().execute_with(|| { // Lock some amount let locker = 2; - let free_balance = Balances::free_balance(&locker); + let free_balance = Balances::total_balance(&locker); assert!(free_balance > 500, "Sanity check"); assert_lock(locker, 100); assert_lock(locker, 200); @@ -487,6 +490,25 @@ fn lock_is_ok() { }) } +#[test] +fn lock_with_reserve_is_ok() { + ExtBuilder::build().execute_with(|| { + // Prepare locker account + let locker = 30; + let minimum_locked_amount: Balance = ::MinimumLockedAmount::get(); + Balances::make_free_balance_be(&locker, minimum_locked_amount); + assert_ok!(Balances::reserve(&locker, 1)); + assert_eq!( + Balances::free_balance(&locker), + minimum_locked_amount - 1, + "Sanity check post-reserve." + ); + + // Lock must still work since account is not blacklisted and has enough total balance to cover the lock requirement + assert_lock(locker, minimum_locked_amount); + }) +} + #[test] fn lock_with_incorrect_amount_fails() { ExtBuilder::build().execute_with(|| { @@ -499,7 +521,7 @@ fn lock_with_incorrect_amount_fails() { // Attempting to lock something after everything has been locked is same // as attempting to lock with "nothing" let locker = 1; - assert_lock(locker, Balances::free_balance(&locker)); + assert_lock(locker, Balances::total_balance(&locker)); assert_noop!( DappStaking::lock(RuntimeOrigin::signed(locker), 1), Error::::ZeroAmount, @@ -515,6 +537,18 @@ fn lock_with_incorrect_amount_fails() { }) } +#[test] +fn lock_with_blacklisted_account_fails() { + ExtBuilder::build().execute_with(|| { + Balances::make_free_balance_be(&BLACKLISTED_ACCOUNT, 100000); + + assert_noop!( + DappStaking::lock(RuntimeOrigin::signed(BLACKLISTED_ACCOUNT), 1000), + Error::::AccountNotAvailableForDappStaking, + ); + }) +} + #[test] fn unbond_and_unstake_is_ok() { ExtBuilder::build().execute_with(|| { diff --git a/pallets/dapp-staking-v3/src/weights.rs b/pallets/dapp-staking-v3/src/weights.rs index 624f90020c..e1013f4c2f 100644 --- a/pallets/dapp-staking-v3/src/weights.rs +++ b/pallets/dapp-staking-v3/src/weights.rs @@ -20,16 +20,16 @@ //! Autogenerated weights for pallet_dapp_staking_v3 //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-01-17, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-02-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `gh-runner-01-ovh`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shibuya-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shiden-dev"), DB CACHE: 1024 // Executed Command: // ./target/release/astar-collator // benchmark // pallet -// --chain=shibuya-dev +// --chain=shiden-dev // --steps=50 // --repeat=20 // --pallet=pallet_dapp_staking_v3 @@ -37,7 +37,7 @@ // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./benchmark-results/shibuya-dev/dapp_staking_v3_weights.rs +// --output=./benchmark-results/shiden-dev/dapp_staking_v3_weights.rs // --template=./scripts/templates/weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -54,7 +54,8 @@ pub trait WeightInfo { fn set_dapp_reward_beneficiary() -> Weight; fn set_dapp_owner() -> Weight; fn unregister() -> Weight; - fn lock() -> Weight; + fn lock_new_account() -> Weight; + fn lock_existing_account() -> Weight; fn unlock() -> Weight; fn claim_unlocked(x: u32, ) -> Weight; fn relock_unlocking() -> Weight; @@ -81,11 +82,11 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_765_000 picoseconds. - Weight::from_parts(9_104_000, 0) + // Minimum execution time: 8_967_000 picoseconds. + Weight::from_parts(9_242_000, 0) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking CounterForIntegratedDApps (r:1 w:1) /// Proof: DappStaking CounterForIntegratedDApps (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: DappStaking NextDAppId (r:1 w:1) @@ -93,46 +94,67 @@ impl WeightInfo for SubstrateWeight { fn register() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `3091` - // Minimum execution time: 17_156_000 picoseconds. - Weight::from_parts(17_426_000, 3091) + // Estimated: `3086` + // Minimum execution time: 17_044_000 picoseconds. + Weight::from_parts(17_328_000, 3086) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) fn set_dapp_reward_beneficiary() -> Weight { // Proof Size summary in bytes: - // Measured: `75` - // Estimated: `3091` - // Minimum execution time: 13_565_000 picoseconds. - Weight::from_parts(13_804_000, 3091) + // Measured: `74` + // Estimated: `3086` + // Minimum execution time: 13_369_000 picoseconds. + Weight::from_parts(13_617_000, 3086) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) fn set_dapp_owner() -> Weight { // Proof Size summary in bytes: - // Measured: `75` - // Estimated: `3091` - // Minimum execution time: 13_824_000 picoseconds. - Weight::from_parts(14_132_000, 3091) + // Measured: `74` + // Estimated: `3086` + // Minimum execution time: 13_421_000 picoseconds. + Weight::from_parts(13_692_000, 3086) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) + /// Storage: DappStaking CounterForIntegratedDApps (r:1 w:1) + /// Proof: DappStaking CounterForIntegratedDApps (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: DappStaking ContractStake (r:0 w:1) /// Proof: DappStaking ContractStake (max_values: Some(65535), max_size: Some(91), added: 2071, mode: MaxEncodedLen) fn unregister() -> Weight { // Proof Size summary in bytes: - // Measured: `75` - // Estimated: `3091` - // Minimum execution time: 17_255_000 picoseconds. - Weight::from_parts(17_659_000, 3091) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `74` + // Estimated: `3086` + // Minimum execution time: 18_458_000 picoseconds. + Weight::from_parts(18_864_000, 3086) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: CollatorSelection Candidates (r:1 w:0) + /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Balances Freezes (r:1 w:1) + /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:0) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: DappStaking CurrentEraInfo (r:1 w:1) + /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) + fn lock_new_account() -> Weight { + // Proof Size summary in bytes: + // Measured: `138` + // Estimated: `4764` + // Minimum execution time: 62_743_000 picoseconds. + Weight::from_parts(64_992_000, 4764) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) @@ -142,12 +164,12 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: DappStaking CurrentEraInfo (r:1 w:1) /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) - fn lock() -> Weight { + fn lock_existing_account() -> Weight { // Proof Size summary in bytes: - // Measured: `12` + // Measured: `158` // Estimated: `4764` - // Minimum execution time: 33_281_000 picoseconds. - Weight::from_parts(33_759_000, 4764) + // Minimum execution time: 38_250_000 picoseconds. + Weight::from_parts(38_835_000, 4764) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -161,10 +183,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) fn unlock() -> Weight { // Proof Size summary in bytes: - // Measured: `156` + // Measured: `158` // Estimated: `4764` - // Minimum execution time: 34_451_000 picoseconds. - Weight::from_parts(34_926_000, 4764) + // Minimum execution time: 34_582_000 picoseconds. + Weight::from_parts(35_126_000, 4764) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -176,15 +198,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: DappStaking CurrentEraInfo (r:1 w:1) /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) - /// The range of component `x` is `[0, 8]`. + /// The range of component `x` is `[0, 16]`. fn claim_unlocked(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `187` + // Measured: `191` // Estimated: `4764` - // Minimum execution time: 37_641_000 picoseconds. - Weight::from_parts(38_890_045, 4764) - // Standard Error: 7_639 - .saturating_add(Weight::from_parts(183_994, 0).saturating_mul(x.into())) + // Minimum execution time: 37_740_000 picoseconds. + Weight::from_parts(39_064_684, 4764) + // Standard Error: 2_750 + .saturating_add(Weight::from_parts(120_539, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -198,15 +220,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) fn relock_unlocking() -> Weight { // Proof Size summary in bytes: - // Measured: `182` + // Measured: `200` // Estimated: `4764` - // Minimum execution time: 33_528_000 picoseconds. - Weight::from_parts(33_929_000, 4764) + // Minimum execution time: 33_298_000 picoseconds. + Weight::from_parts(33_903_000, 4764) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) /// Storage: DappStaking StakerInfo (r:1 w:1) @@ -221,15 +243,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn stake() -> Weight { // Proof Size summary in bytes: - // Measured: `250` + // Measured: `251` // Estimated: `4764` - // Minimum execution time: 45_984_000 picoseconds. - Weight::from_parts(46_329_000, 4764) + // Minimum execution time: 44_905_000 picoseconds. + Weight::from_parts(45_261_000, 4764) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) /// Storage: DappStaking StakerInfo (r:1 w:1) @@ -244,10 +266,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn unstake() -> Weight { // Proof Size summary in bytes: - // Measured: `427` + // Measured: `432` // Estimated: `4764` - // Minimum execution time: 48_584_000 picoseconds. - Weight::from_parts(49_635_000, 4764) + // Minimum execution time: 48_594_000 picoseconds. + Weight::from_parts(49_441_000, 4764) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -264,12 +286,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_past_period(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `560` + // Measured: `541` // Estimated: `4764` - // Minimum execution time: 51_711_000 picoseconds. - Weight::from_parts(50_255_137, 4764) - // Standard Error: 5_418 - .saturating_add(Weight::from_parts(3_166_243, 0).saturating_mul(x.into())) + // Minimum execution time: 52_182_000 picoseconds. + Weight::from_parts(50_073_700, 4764) + // Standard Error: 4_907 + .saturating_add(Weight::from_parts(3_301_788, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -284,12 +306,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `501` + // Measured: `519` // Estimated: `4764` - // Minimum execution time: 48_656_000 picoseconds. - Weight::from_parts(46_590_994, 4764) - // Standard Error: 4_829 - .saturating_add(Weight::from_parts(3_197_956, 0).saturating_mul(x.into())) + // Minimum execution time: 49_637_000 picoseconds. + Weight::from_parts(47_809_537, 4764) + // Standard Error: 5_850 + .saturating_add(Weight::from_parts(3_304_857, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -301,28 +323,28 @@ impl WeightInfo for SubstrateWeight { /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) fn claim_bonus_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `267` + // Measured: `271` // Estimated: `3775` - // Minimum execution time: 41_921_000 picoseconds. - Weight::from_parts(42_440_000, 3775) + // Minimum execution time: 41_926_000 picoseconds. + Weight::from_parts(42_718_000, 3775) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking DAppTiers (r:1 w:1) /// Proof: DappStaking DAppTiers (max_values: None, max_size: Some(1583), added: 4058, mode: MaxEncodedLen) fn claim_dapp_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `2585` + // Measured: `2584` // Estimated: `5048` - // Minimum execution time: 58_409_000 picoseconds. - Weight::from_parts(60_103_000, 5048) + // Minimum execution time: 57_183_000 picoseconds. + Weight::from_parts(58_197_000, 5048) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking StakerInfo (r:1 w:1) /// Proof: DappStaking StakerInfo (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) @@ -335,14 +357,14 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn unstake_from_unregistered() -> Weight { // Proof Size summary in bytes: - // Measured: `389` + // Measured: `318` // Estimated: `4764` - // Minimum execution time: 43_579_000 picoseconds. - Weight::from_parts(44_128_000, 4764) + // Minimum execution time: 41_858_000 picoseconds. + Weight::from_parts(42_476_000, 4764) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } - /// Storage: DappStaking StakerInfo (r:9 w:8) + /// Storage: DappStaking StakerInfo (r:17 w:16) /// Proof: DappStaking StakerInfo (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) @@ -350,15 +372,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) /// Storage: Balances Locks (r:1 w:0) /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// The range of component `x` is `[1, 8]`. + /// The range of component `x` is `[1, 16]`. fn cleanup_expired_entries(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `255 + x * (69 ±0)` + // Measured: `256 + x * (69 ±0)` // Estimated: `4764 + x * (2613 ±0)` - // Minimum execution time: 43_019_000 picoseconds. - Weight::from_parts(39_628_074, 4764) - // Standard Error: 15_327 - .saturating_add(Weight::from_parts(4_990_892, 0).saturating_mul(x.into())) + // Minimum execution time: 43_103_000 picoseconds. + Weight::from_parts(39_876_215, 4764) + // Standard Error: 8_123 + .saturating_add(Weight::from_parts(5_014_232, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -369,8 +391,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_301_000 picoseconds. - Weight::from_parts(11_607_000, 0) + // Minimum execution time: 11_543_000 picoseconds. + Weight::from_parts(11_735_000, 0) } /// Storage: DappStaking CurrentEraInfo (r:1 w:1) /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) @@ -380,8 +402,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `16` // Estimated: `4254` - // Minimum execution time: 17_997_000 picoseconds. - Weight::from_parts(18_491_000, 4254) + // Minimum execution time: 17_687_000 picoseconds. + Weight::from_parts(18_283_000, 4254) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -401,10 +423,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: DappStaking DAppTiers (max_values: None, max_size: Some(1583), added: 4058, mode: MaxEncodedLen) fn on_initialize_build_and_earn_to_voting() -> Weight { // Proof Size summary in bytes: - // Measured: `627` + // Measured: `839` // Estimated: `4254` - // Minimum execution time: 45_396_000 picoseconds. - Weight::from_parts(46_230_000, 4254) + // Minimum execution time: 47_901_000 picoseconds. + Weight::from_parts(49_554_000, 4254) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -418,8 +440,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `68` // Estimated: `4254` - // Minimum execution time: 24_161_000 picoseconds. - Weight::from_parts(24_565_000, 4254) + // Minimum execution time: 23_705_000 picoseconds. + Weight::from_parts(24_313_000, 4254) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -432,10 +454,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `152 + x * (32 ±0)` // Estimated: `3061 + x * (2071 ±0)` - // Minimum execution time: 7_878_000 picoseconds. - Weight::from_parts(12_213_692, 3061) - // Standard Error: 3_051 - .saturating_add(Weight::from_parts(2_363_936, 0).saturating_mul(x.into())) + // Minimum execution time: 7_549_000 picoseconds. + Weight::from_parts(12_476_634, 3061) + // Standard Error: 3_594 + .saturating_add(Weight::from_parts(2_387_577, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) @@ -450,8 +472,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `293` // Estimated: `4254` - // Minimum execution time: 8_839_000 picoseconds. - Weight::from_parts(8_975_000, 4254) + // Minimum execution time: 8_529_000 picoseconds. + Weight::from_parts(8_772_000, 4254) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -463,11 +485,11 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_765_000 picoseconds. - Weight::from_parts(9_104_000, 0) + // Minimum execution time: 8_967_000 picoseconds. + Weight::from_parts(9_242_000, 0) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking CounterForIntegratedDApps (r:1 w:1) /// Proof: DappStaking CounterForIntegratedDApps (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: DappStaking NextDAppId (r:1 w:1) @@ -475,46 +497,67 @@ impl WeightInfo for () { fn register() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `3091` - // Minimum execution time: 17_156_000 picoseconds. - Weight::from_parts(17_426_000, 3091) + // Estimated: `3086` + // Minimum execution time: 17_044_000 picoseconds. + Weight::from_parts(17_328_000, 3086) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) fn set_dapp_reward_beneficiary() -> Weight { // Proof Size summary in bytes: - // Measured: `75` - // Estimated: `3091` - // Minimum execution time: 13_565_000 picoseconds. - Weight::from_parts(13_804_000, 3091) + // Measured: `74` + // Estimated: `3086` + // Minimum execution time: 13_369_000 picoseconds. + Weight::from_parts(13_617_000, 3086) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) fn set_dapp_owner() -> Weight { // Proof Size summary in bytes: - // Measured: `75` - // Estimated: `3091` - // Minimum execution time: 13_824_000 picoseconds. - Weight::from_parts(14_132_000, 3091) + // Measured: `74` + // Estimated: `3086` + // Minimum execution time: 13_421_000 picoseconds. + Weight::from_parts(13_692_000, 3086) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) + /// Storage: DappStaking CounterForIntegratedDApps (r:1 w:1) + /// Proof: DappStaking CounterForIntegratedDApps (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: DappStaking ContractStake (r:0 w:1) /// Proof: DappStaking ContractStake (max_values: Some(65535), max_size: Some(91), added: 2071, mode: MaxEncodedLen) fn unregister() -> Weight { // Proof Size summary in bytes: - // Measured: `75` - // Estimated: `3091` - // Minimum execution time: 17_255_000 picoseconds. - Weight::from_parts(17_659_000, 3091) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) + // Measured: `74` + // Estimated: `3086` + // Minimum execution time: 18_458_000 picoseconds. + Weight::from_parts(18_864_000, 3086) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: CollatorSelection Candidates (r:1 w:0) + /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Balances Freezes (r:1 w:1) + /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:0) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: DappStaking CurrentEraInfo (r:1 w:1) + /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) + fn lock_new_account() -> Weight { + // Proof Size summary in bytes: + // Measured: `138` + // Estimated: `4764` + // Minimum execution time: 62_743_000 picoseconds. + Weight::from_parts(64_992_000, 4764) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) @@ -524,12 +567,12 @@ impl WeightInfo for () { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: DappStaking CurrentEraInfo (r:1 w:1) /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) - fn lock() -> Weight { + fn lock_existing_account() -> Weight { // Proof Size summary in bytes: - // Measured: `12` + // Measured: `158` // Estimated: `4764` - // Minimum execution time: 33_281_000 picoseconds. - Weight::from_parts(33_759_000, 4764) + // Minimum execution time: 38_250_000 picoseconds. + Weight::from_parts(38_835_000, 4764) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -543,10 +586,10 @@ impl WeightInfo for () { /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) fn unlock() -> Weight { // Proof Size summary in bytes: - // Measured: `156` + // Measured: `158` // Estimated: `4764` - // Minimum execution time: 34_451_000 picoseconds. - Weight::from_parts(34_926_000, 4764) + // Minimum execution time: 34_582_000 picoseconds. + Weight::from_parts(35_126_000, 4764) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -558,15 +601,15 @@ impl WeightInfo for () { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: DappStaking CurrentEraInfo (r:1 w:1) /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) - /// The range of component `x` is `[0, 8]`. + /// The range of component `x` is `[0, 16]`. fn claim_unlocked(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `187` + // Measured: `191` // Estimated: `4764` - // Minimum execution time: 37_641_000 picoseconds. - Weight::from_parts(38_890_045, 4764) - // Standard Error: 7_639 - .saturating_add(Weight::from_parts(183_994, 0).saturating_mul(x.into())) + // Minimum execution time: 37_740_000 picoseconds. + Weight::from_parts(39_064_684, 4764) + // Standard Error: 2_750 + .saturating_add(Weight::from_parts(120_539, 0).saturating_mul(x.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -580,15 +623,15 @@ impl WeightInfo for () { /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) fn relock_unlocking() -> Weight { // Proof Size summary in bytes: - // Measured: `182` + // Measured: `200` // Estimated: `4764` - // Minimum execution time: 33_528_000 picoseconds. - Weight::from_parts(33_929_000, 4764) + // Minimum execution time: 33_298_000 picoseconds. + Weight::from_parts(33_903_000, 4764) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) /// Storage: DappStaking StakerInfo (r:1 w:1) @@ -603,15 +646,15 @@ impl WeightInfo for () { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn stake() -> Weight { // Proof Size summary in bytes: - // Measured: `250` + // Measured: `251` // Estimated: `4764` - // Minimum execution time: 45_984_000 picoseconds. - Weight::from_parts(46_329_000, 4764) + // Minimum execution time: 44_905_000 picoseconds. + Weight::from_parts(45_261_000, 4764) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) /// Storage: DappStaking StakerInfo (r:1 w:1) @@ -626,10 +669,10 @@ impl WeightInfo for () { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn unstake() -> Weight { // Proof Size summary in bytes: - // Measured: `427` + // Measured: `432` // Estimated: `4764` - // Minimum execution time: 48_584_000 picoseconds. - Weight::from_parts(49_635_000, 4764) + // Minimum execution time: 48_594_000 picoseconds. + Weight::from_parts(49_441_000, 4764) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -646,12 +689,12 @@ impl WeightInfo for () { /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_past_period(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `560` + // Measured: `541` // Estimated: `4764` - // Minimum execution time: 51_711_000 picoseconds. - Weight::from_parts(50_255_137, 4764) - // Standard Error: 5_418 - .saturating_add(Weight::from_parts(3_166_243, 0).saturating_mul(x.into())) + // Minimum execution time: 52_182_000 picoseconds. + Weight::from_parts(50_073_700, 4764) + // Standard Error: 4_907 + .saturating_add(Weight::from_parts(3_301_788, 0).saturating_mul(x.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -666,12 +709,12 @@ impl WeightInfo for () { /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `501` + // Measured: `519` // Estimated: `4764` - // Minimum execution time: 48_656_000 picoseconds. - Weight::from_parts(46_590_994, 4764) - // Standard Error: 4_829 - .saturating_add(Weight::from_parts(3_197_956, 0).saturating_mul(x.into())) + // Minimum execution time: 49_637_000 picoseconds. + Weight::from_parts(47_809_537, 4764) + // Standard Error: 5_850 + .saturating_add(Weight::from_parts(3_304_857, 0).saturating_mul(x.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -683,28 +726,28 @@ impl WeightInfo for () { /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) fn claim_bonus_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `267` + // Measured: `271` // Estimated: `3775` - // Minimum execution time: 41_921_000 picoseconds. - Weight::from_parts(42_440_000, 3775) + // Minimum execution time: 41_926_000 picoseconds. + Weight::from_parts(42_718_000, 3775) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking DAppTiers (r:1 w:1) /// Proof: DappStaking DAppTiers (max_values: None, max_size: Some(1583), added: 4058, mode: MaxEncodedLen) fn claim_dapp_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `2585` + // Measured: `2584` // Estimated: `5048` - // Minimum execution time: 58_409_000 picoseconds. - Weight::from_parts(60_103_000, 5048) + // Minimum execution time: 57_183_000 picoseconds. + Weight::from_parts(58_197_000, 5048) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking StakerInfo (r:1 w:1) /// Proof: DappStaking StakerInfo (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) @@ -717,14 +760,14 @@ impl WeightInfo for () { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn unstake_from_unregistered() -> Weight { // Proof Size summary in bytes: - // Measured: `389` + // Measured: `318` // Estimated: `4764` - // Minimum execution time: 43_579_000 picoseconds. - Weight::from_parts(44_128_000, 4764) + // Minimum execution time: 41_858_000 picoseconds. + Weight::from_parts(42_476_000, 4764) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } - /// Storage: DappStaking StakerInfo (r:9 w:8) + /// Storage: DappStaking StakerInfo (r:17 w:16) /// Proof: DappStaking StakerInfo (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) @@ -732,15 +775,15 @@ impl WeightInfo for () { /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) /// Storage: Balances Locks (r:1 w:0) /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// The range of component `x` is `[1, 8]`. + /// The range of component `x` is `[1, 16]`. fn cleanup_expired_entries(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `255 + x * (69 ±0)` + // Measured: `256 + x * (69 ±0)` // Estimated: `4764 + x * (2613 ±0)` - // Minimum execution time: 43_019_000 picoseconds. - Weight::from_parts(39_628_074, 4764) - // Standard Error: 15_327 - .saturating_add(Weight::from_parts(4_990_892, 0).saturating_mul(x.into())) + // Minimum execution time: 43_103_000 picoseconds. + Weight::from_parts(39_876_215, 4764) + // Standard Error: 8_123 + .saturating_add(Weight::from_parts(5_014_232, 0).saturating_mul(x.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) @@ -751,8 +794,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_301_000 picoseconds. - Weight::from_parts(11_607_000, 0) + // Minimum execution time: 11_543_000 picoseconds. + Weight::from_parts(11_735_000, 0) } /// Storage: DappStaking CurrentEraInfo (r:1 w:1) /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) @@ -762,8 +805,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `16` // Estimated: `4254` - // Minimum execution time: 17_997_000 picoseconds. - Weight::from_parts(18_491_000, 4254) + // Minimum execution time: 17_687_000 picoseconds. + Weight::from_parts(18_283_000, 4254) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -783,10 +826,10 @@ impl WeightInfo for () { /// Proof: DappStaking DAppTiers (max_values: None, max_size: Some(1583), added: 4058, mode: MaxEncodedLen) fn on_initialize_build_and_earn_to_voting() -> Weight { // Proof Size summary in bytes: - // Measured: `627` + // Measured: `839` // Estimated: `4254` - // Minimum execution time: 45_396_000 picoseconds. - Weight::from_parts(46_230_000, 4254) + // Minimum execution time: 47_901_000 picoseconds. + Weight::from_parts(49_554_000, 4254) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -800,8 +843,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `68` // Estimated: `4254` - // Minimum execution time: 24_161_000 picoseconds. - Weight::from_parts(24_565_000, 4254) + // Minimum execution time: 23_705_000 picoseconds. + Weight::from_parts(24_313_000, 4254) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -814,10 +857,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `152 + x * (32 ±0)` // Estimated: `3061 + x * (2071 ±0)` - // Minimum execution time: 7_878_000 picoseconds. - Weight::from_parts(12_213_692, 3061) - // Standard Error: 3_051 - .saturating_add(Weight::from_parts(2_363_936, 0).saturating_mul(x.into())) + // Minimum execution time: 7_549_000 picoseconds. + Weight::from_parts(12_476_634, 3061) + // Standard Error: 3_594 + .saturating_add(Weight::from_parts(2_387_577, 0).saturating_mul(x.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) @@ -832,8 +875,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `293` // Estimated: `4254` - // Minimum execution time: 8_839_000 picoseconds. - Weight::from_parts(8_975_000, 4254) + // Minimum execution time: 8_529_000 picoseconds. + Weight::from_parts(8_772_000, 4254) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } diff --git a/precompiles/dapp-staking-v3/src/test/mock.rs b/precompiles/dapp-staking-v3/src/test/mock.rs index 36359b9457..f3b1a53e93 100644 --- a/precompiles/dapp-staking-v3/src/test/mock.rs +++ b/precompiles/dapp-staking-v3/src/test/mock.rs @@ -252,6 +252,7 @@ impl pallet_dapp_staking_v3::Config for Test { type StakingRewardHandler = DummyStakingRewardHandler; type CycleConfiguration = DummyCycleConfiguration; type Observers = (); + type AccountCheck = (); type EraRewardSpanLength = ConstU32<8>; type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<10>; diff --git a/primitives/src/dapp_staking.rs b/primitives/src/dapp_staking.rs index ee6eeedfa5..23638089a7 100644 --- a/primitives/src/dapp_staking.rs +++ b/primitives/src/dapp_staking.rs @@ -160,3 +160,15 @@ impl SmartContractHandle for SmartContract { Self::Wasm(address) } } + +/// Used to check whether an account is allowed to participate in dApp staking or not. +pub trait AccountCheck { + /// `true` if the account is allowed to stake, `false` otherwise. + fn allowed_to_stake(account: &AccountId) -> bool; +} + +impl AccountCheck for () { + fn allowed_to_stake(_account: &AccountId) -> bool { + true + } +} diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index d381af295b..69c0a82561 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -138,7 +138,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("astar"), impl_name: create_runtime_str!("astar"), authoring_version: 1, - spec_version: 77, + spec_version: 78, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -427,6 +427,14 @@ parameter_types! { pub const KickThreshold: BlockNumber = 2 * HOURS; // 2 SessionPeriod } +pub struct CollatorSelectionAccountCheck; +impl pallet_collator_selection::AccountCheck for CollatorSelectionAccountCheck { + fn allowed_candidacy(_account: &AccountId) -> bool { + // TODO: update this when dApp staking v3 is integrated + true + } +} + impl pallet_collator_selection::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; @@ -441,6 +449,7 @@ impl pallet_collator_selection::Config for Runtime { type ValidatorIdOf = pallet_collator_selection::IdentityCollator; type ValidatorRegistration = Session; type SlashRatio = SlashRatio; + type AccountCheck = CollatorSelectionAccountCheck; type WeightInfo = pallet_collator_selection::weights::SubstrateWeight; } diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index 7455c99a88..7c5e0a6548 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -516,6 +516,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type StakingRewardHandler = Inflation; type CycleConfiguration = InflationCycleConfig; type Observers = Inflation; + type AccountCheck = (); type EraRewardSpanLength = ConstU32<8>; type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<100>; diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index cf259dae79..4eb2866d9c 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -67,7 +67,10 @@ use sp_runtime::{ use sp_std::{collections::btree_map::BTreeMap, prelude::*}; use astar_primitives::{ - dapp_staking::{CycleConfiguration, DAppId, EraNumber, PeriodNumber, SmartContract, TierId}, + dapp_staking::{ + AccountCheck as DappStakingAccountCheck, CycleConfiguration, DAppId, EraNumber, + PeriodNumber, SmartContract, TierId, + }, evm::{EvmRevertCodeHandler, HashedDefaultMappings}, xcm::AssetLocationIdConverter, Address, AssetId, BlockNumber, Hash, Header, Index, @@ -404,6 +407,13 @@ impl pallet_dapp_staking_v3::BenchmarkHelper, AccountId } } +pub struct AccountCheck; +impl DappStakingAccountCheck for AccountCheck { + fn allowed_to_stake(account: &AccountId) -> bool { + !CollatorSelection::is_account_candidate(account) + } +} + parameter_types! { pub const MinimumStakingAmount: Balance = 5 * SBY; } @@ -418,12 +428,13 @@ impl pallet_dapp_staking_v3::Config for Runtime { type StakingRewardHandler = Inflation; type CycleConfiguration = InflationCycleConfig; type Observers = Inflation; + type AccountCheck = AccountCheck; type EraRewardSpanLength = ConstU32<16>; - type RewardRetentionInPeriods = ConstU32<2>; // Low enough value so we can get some expired rewards during testing + type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<500>; type MaxUnlockingChunks = ConstU32<8>; type MinimumLockedAmount = MinimumStakingAmount; - type UnlockingPeriod = ConstU32<4>; // Keep it low so it's easier to test + type UnlockingPeriod = ConstU32<4>; type MaxNumberOfStakedContracts = ConstU32<8>; type MinimumStakeAmount = MinimumStakingAmount; type NumberOfTiers = ConstU32<4>; @@ -540,6 +551,13 @@ parameter_types! { pub const KickThreshold: BlockNumber = 2 * HOURS; // 2 SessionPeriod } +pub struct CollatorSelectionAccountCheck; +impl pallet_collator_selection::AccountCheck for CollatorSelectionAccountCheck { + fn allowed_candidacy(account: &AccountId) -> bool { + !DappStaking::is_staker(account) + } +} + impl pallet_collator_selection::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; @@ -554,6 +572,7 @@ impl pallet_collator_selection::Config for Runtime { type ValidatorIdOf = pallet_collator_selection::IdentityCollator; type ValidatorRegistration = Session; type SlashRatio = SlashRatio; + type AccountCheck = CollatorSelectionAccountCheck; type WeightInfo = pallet_collator_selection::weights::SubstrateWeight; } diff --git a/runtime/shibuya/src/weights/pallet_dapp_staking_v3.rs b/runtime/shibuya/src/weights/pallet_dapp_staking_v3.rs index 88fdf31674..884f3ed120 100644 --- a/runtime/shibuya/src/weights/pallet_dapp_staking_v3.rs +++ b/runtime/shibuya/src/weights/pallet_dapp_staking_v3.rs @@ -55,11 +55,11 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_765_000 picoseconds. - Weight::from_parts(9_104_000, 0) + // Minimum execution time: 8_967_000 picoseconds. + Weight::from_parts(9_242_000, 0) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking CounterForIntegratedDApps (r:1 w:1) /// Proof: DappStaking CounterForIntegratedDApps (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: DappStaking NextDAppId (r:1 w:1) @@ -67,46 +67,67 @@ impl WeightInfo for SubstrateWeight { fn register() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `3091` - // Minimum execution time: 17_156_000 picoseconds. - Weight::from_parts(17_426_000, 3091) + // Estimated: `3086` + // Minimum execution time: 17_044_000 picoseconds. + Weight::from_parts(17_328_000, 3086) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) fn set_dapp_reward_beneficiary() -> Weight { // Proof Size summary in bytes: - // Measured: `75` - // Estimated: `3091` - // Minimum execution time: 13_565_000 picoseconds. - Weight::from_parts(13_804_000, 3091) + // Measured: `74` + // Estimated: `3086` + // Minimum execution time: 13_369_000 picoseconds. + Weight::from_parts(13_617_000, 3086) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) fn set_dapp_owner() -> Weight { // Proof Size summary in bytes: - // Measured: `75` - // Estimated: `3091` - // Minimum execution time: 13_824_000 picoseconds. - Weight::from_parts(14_132_000, 3091) + // Measured: `74` + // Estimated: `3086` + // Minimum execution time: 13_421_000 picoseconds. + Weight::from_parts(13_692_000, 3086) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) + /// Storage: DappStaking CounterForIntegratedDApps (r:1 w:1) + /// Proof: DappStaking CounterForIntegratedDApps (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: DappStaking ContractStake (r:0 w:1) /// Proof: DappStaking ContractStake (max_values: Some(65535), max_size: Some(91), added: 2071, mode: MaxEncodedLen) fn unregister() -> Weight { // Proof Size summary in bytes: - // Measured: `75` - // Estimated: `3091` - // Minimum execution time: 17_255_000 picoseconds. - Weight::from_parts(17_659_000, 3091) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `74` + // Estimated: `3086` + // Minimum execution time: 18_458_000 picoseconds. + Weight::from_parts(18_864_000, 3086) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: CollatorSelection Candidates (r:1 w:0) + /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Balances Freezes (r:1 w:1) + /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:0) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: DappStaking CurrentEraInfo (r:1 w:1) + /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) + fn lock_new_account() -> Weight { + // Proof Size summary in bytes: + // Measured: `138` + // Estimated: `4764` + // Minimum execution time: 62_743_000 picoseconds. + Weight::from_parts(64_992_000, 4764) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) @@ -116,12 +137,12 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: DappStaking CurrentEraInfo (r:1 w:1) /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) - fn lock() -> Weight { + fn lock_existing_account() -> Weight { // Proof Size summary in bytes: - // Measured: `12` + // Measured: `158` // Estimated: `4764` - // Minimum execution time: 33_281_000 picoseconds. - Weight::from_parts(33_759_000, 4764) + // Minimum execution time: 38_250_000 picoseconds. + Weight::from_parts(38_835_000, 4764) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -135,10 +156,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) fn unlock() -> Weight { // Proof Size summary in bytes: - // Measured: `156` + // Measured: `158` // Estimated: `4764` - // Minimum execution time: 34_451_000 picoseconds. - Weight::from_parts(34_926_000, 4764) + // Minimum execution time: 34_582_000 picoseconds. + Weight::from_parts(35_126_000, 4764) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -150,15 +171,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: DappStaking CurrentEraInfo (r:1 w:1) /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) - /// The range of component `x` is `[0, 8]`. + /// The range of component `x` is `[0, 16]`. fn claim_unlocked(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `187` + // Measured: `191` // Estimated: `4764` - // Minimum execution time: 37_641_000 picoseconds. - Weight::from_parts(38_890_045, 4764) - // Standard Error: 7_639 - .saturating_add(Weight::from_parts(183_994, 0).saturating_mul(x.into())) + // Minimum execution time: 37_740_000 picoseconds. + Weight::from_parts(39_064_684, 4764) + // Standard Error: 2_750 + .saturating_add(Weight::from_parts(120_539, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -172,15 +193,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) fn relock_unlocking() -> Weight { // Proof Size summary in bytes: - // Measured: `182` + // Measured: `200` // Estimated: `4764` - // Minimum execution time: 33_528_000 picoseconds. - Weight::from_parts(33_929_000, 4764) + // Minimum execution time: 33_298_000 picoseconds. + Weight::from_parts(33_903_000, 4764) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) /// Storage: DappStaking StakerInfo (r:1 w:1) @@ -195,15 +216,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn stake() -> Weight { // Proof Size summary in bytes: - // Measured: `250` + // Measured: `251` // Estimated: `4764` - // Minimum execution time: 45_984_000 picoseconds. - Weight::from_parts(46_329_000, 4764) + // Minimum execution time: 44_905_000 picoseconds. + Weight::from_parts(45_261_000, 4764) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) /// Storage: DappStaking StakerInfo (r:1 w:1) @@ -218,10 +239,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn unstake() -> Weight { // Proof Size summary in bytes: - // Measured: `427` + // Measured: `432` // Estimated: `4764` - // Minimum execution time: 48_584_000 picoseconds. - Weight::from_parts(49_635_000, 4764) + // Minimum execution time: 48_594_000 picoseconds. + Weight::from_parts(49_441_000, 4764) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -238,12 +259,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_past_period(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `560` + // Measured: `541` // Estimated: `4764` - // Minimum execution time: 51_711_000 picoseconds. - Weight::from_parts(50_255_137, 4764) - // Standard Error: 5_418 - .saturating_add(Weight::from_parts(3_166_243, 0).saturating_mul(x.into())) + // Minimum execution time: 52_182_000 picoseconds. + Weight::from_parts(50_073_700, 4764) + // Standard Error: 4_907 + .saturating_add(Weight::from_parts(3_301_788, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -258,12 +279,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `501` + // Measured: `519` // Estimated: `4764` - // Minimum execution time: 48_656_000 picoseconds. - Weight::from_parts(46_590_994, 4764) - // Standard Error: 4_829 - .saturating_add(Weight::from_parts(3_197_956, 0).saturating_mul(x.into())) + // Minimum execution time: 49_637_000 picoseconds. + Weight::from_parts(47_809_537, 4764) + // Standard Error: 5_850 + .saturating_add(Weight::from_parts(3_304_857, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -275,28 +296,28 @@ impl WeightInfo for SubstrateWeight { /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) fn claim_bonus_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `267` + // Measured: `271` // Estimated: `3775` - // Minimum execution time: 41_921_000 picoseconds. - Weight::from_parts(42_440_000, 3775) + // Minimum execution time: 41_926_000 picoseconds. + Weight::from_parts(42_718_000, 3775) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking DAppTiers (r:1 w:1) /// Proof: DappStaking DAppTiers (max_values: None, max_size: Some(1583), added: 4058, mode: MaxEncodedLen) fn claim_dapp_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `2585` + // Measured: `2584` // Estimated: `5048` - // Minimum execution time: 58_409_000 picoseconds. - Weight::from_parts(60_103_000, 5048) + // Minimum execution time: 57_183_000 picoseconds. + Weight::from_parts(58_197_000, 5048) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: DappStaking IntegratedDApps (r:1 w:0) - /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(121), added: 2101, mode: MaxEncodedLen) + /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) /// Storage: DappStaking StakerInfo (r:1 w:1) /// Proof: DappStaking StakerInfo (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) @@ -309,14 +330,14 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn unstake_from_unregistered() -> Weight { // Proof Size summary in bytes: - // Measured: `389` + // Measured: `318` // Estimated: `4764` - // Minimum execution time: 43_579_000 picoseconds. - Weight::from_parts(44_128_000, 4764) + // Minimum execution time: 41_858_000 picoseconds. + Weight::from_parts(42_476_000, 4764) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } - /// Storage: DappStaking StakerInfo (r:9 w:8) + /// Storage: DappStaking StakerInfo (r:17 w:16) /// Proof: DappStaking StakerInfo (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) @@ -324,15 +345,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) /// Storage: Balances Locks (r:1 w:0) /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// The range of component `x` is `[1, 8]`. + /// The range of component `x` is `[1, 16]`. fn cleanup_expired_entries(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `255 + x * (69 ±0)` + // Measured: `256 + x * (69 ±0)` // Estimated: `4764 + x * (2613 ±0)` - // Minimum execution time: 43_019_000 picoseconds. - Weight::from_parts(39_628_074, 4764) - // Standard Error: 15_327 - .saturating_add(Weight::from_parts(4_990_892, 0).saturating_mul(x.into())) + // Minimum execution time: 43_103_000 picoseconds. + Weight::from_parts(39_876_215, 4764) + // Standard Error: 8_123 + .saturating_add(Weight::from_parts(5_014_232, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -343,8 +364,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_301_000 picoseconds. - Weight::from_parts(11_607_000, 0) + // Minimum execution time: 11_543_000 picoseconds. + Weight::from_parts(11_735_000, 0) } /// Storage: DappStaking CurrentEraInfo (r:1 w:1) /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) @@ -354,8 +375,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `16` // Estimated: `4254` - // Minimum execution time: 17_997_000 picoseconds. - Weight::from_parts(18_491_000, 4254) + // Minimum execution time: 17_687_000 picoseconds. + Weight::from_parts(18_283_000, 4254) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -375,10 +396,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: DappStaking DAppTiers (max_values: None, max_size: Some(1583), added: 4058, mode: MaxEncodedLen) fn on_initialize_build_and_earn_to_voting() -> Weight { // Proof Size summary in bytes: - // Measured: `627` + // Measured: `839` // Estimated: `4254` - // Minimum execution time: 45_396_000 picoseconds. - Weight::from_parts(46_230_000, 4254) + // Minimum execution time: 47_901_000 picoseconds. + Weight::from_parts(49_554_000, 4254) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -392,8 +413,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `68` // Estimated: `4254` - // Minimum execution time: 24_161_000 picoseconds. - Weight::from_parts(24_565_000, 4254) + // Minimum execution time: 23_705_000 picoseconds. + Weight::from_parts(24_313_000, 4254) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -406,10 +427,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `152 + x * (32 ±0)` // Estimated: `3061 + x * (2071 ±0)` - // Minimum execution time: 7_878_000 picoseconds. - Weight::from_parts(12_213_692, 3061) - // Standard Error: 3_051 - .saturating_add(Weight::from_parts(2_363_936, 0).saturating_mul(x.into())) + // Minimum execution time: 7_549_000 picoseconds. + Weight::from_parts(12_476_634, 3061) + // Standard Error: 3_594 + .saturating_add(Weight::from_parts(2_387_577, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) @@ -424,9 +445,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `293` // Estimated: `4254` - // Minimum execution time: 8_839_000 picoseconds. - Weight::from_parts(8_975_000, 4254) + // Minimum execution time: 8_529_000 picoseconds. + Weight::from_parts(8_772_000, 4254) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } -} \ No newline at end of file +} diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 97e119e68d..ed4f714f26 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -66,7 +66,10 @@ use sp_runtime::{ use sp_std::{collections::btree_map::BTreeMap, prelude::*}; use astar_primitives::{ - dapp_staking::{CycleConfiguration, DAppId, EraNumber, PeriodNumber, SmartContract, TierId}, + dapp_staking::{ + AccountCheck as DappStakingAccountCheck, CycleConfiguration, DAppId, EraNumber, + PeriodNumber, SmartContract, TierId, + }, evm::EvmRevertCodeHandler, xcm::AssetLocationIdConverter, Address, AssetId, BlockNumber, Hash, Header, Index, @@ -380,6 +383,13 @@ impl pallet_dapp_staking_v3::BenchmarkHelper, AccountId } } +pub struct AccountCheck; +impl DappStakingAccountCheck for AccountCheck { + fn allowed_to_stake(account: &AccountId) -> bool { + !CollatorSelection::is_account_candidate(account) + } +} + impl pallet_dapp_staking_v3::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = RuntimeFreezeReason; @@ -390,6 +400,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type StakingRewardHandler = Inflation; type CycleConfiguration = InflationCycleConfig; type Observers = Inflation; + type AccountCheck = AccountCheck; type EraRewardSpanLength = ConstU32<16>; type RewardRetentionInPeriods = ConstU32<3>; type MaxNumberOfContracts = ConstU32<500>; @@ -516,6 +527,13 @@ parameter_types! { pub const KickThreshold: BlockNumber = 2 * HOURS; // 2 SessionPeriod } +pub struct CollatorSelectionAccountCheck; +impl pallet_collator_selection::AccountCheck for CollatorSelectionAccountCheck { + fn allowed_candidacy(account: &AccountId) -> bool { + !DappStaking::is_staker(account) + } +} + impl pallet_collator_selection::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; @@ -530,6 +548,7 @@ impl pallet_collator_selection::Config for Runtime { type ValidatorIdOf = pallet_collator_selection::IdentityCollator; type ValidatorRegistration = Session; type SlashRatio = SlashRatio; + type AccountCheck = CollatorSelectionAccountCheck; type WeightInfo = pallet_collator_selection::weights::SubstrateWeight; } @@ -1030,9 +1049,6 @@ construct_runtime!( NodeBlock = generic::Block, UncheckedExtrinsic = UncheckedExtrinsic { - // Inflation needs to execute `on_initialize` as soon as possible, and `on_finalize` as late as possible. - Inflation: pallet_inflation = 5, - System: frame_system = 10, Utility: pallet_utility = 11, Identity: pallet_identity = 12, @@ -1046,6 +1062,11 @@ construct_runtime!( TransactionPayment: pallet_transaction_payment = 30, Balances: pallet_balances = 31, Vesting: pallet_vesting = 32, + // Inflation needs to execute `on_initialize` as soon as possible, and `on_finalize` as late as possible. + // However, we need to execute Balance genesis before Inflation genesis, otherwise we'll have zero issuance when Inflation + // logic is executed. + // TODO: Address this later. It would be best if Inflation was first pallet. + Inflation: pallet_inflation = 33, DappStaking: pallet_dapp_staking_v3 = 34, Assets: pallet_assets = 36, diff --git a/runtime/shiden/src/weights/pallet_dapp_staking_v3.rs b/runtime/shiden/src/weights/pallet_dapp_staking_v3.rs index e6bbef634d..a7067267f8 100644 --- a/runtime/shiden/src/weights/pallet_dapp_staking_v3.rs +++ b/runtime/shiden/src/weights/pallet_dapp_staking_v3.rs @@ -55,8 +55,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_090_000 picoseconds. - Weight::from_parts(9_358_000, 0) + // Minimum execution time: 8_967_000 picoseconds. + Weight::from_parts(9_242_000, 0) } /// Storage: DappStaking IntegratedDApps (r:1 w:1) /// Proof: DappStaking IntegratedDApps (max_values: Some(65535), max_size: Some(116), added: 2096, mode: MaxEncodedLen) @@ -68,8 +68,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3086` - // Minimum execution time: 17_212_000 picoseconds. - Weight::from_parts(17_529_000, 3086) + // Minimum execution time: 17_044_000 picoseconds. + Weight::from_parts(17_328_000, 3086) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -79,8 +79,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `74` // Estimated: `3086` - // Minimum execution time: 13_417_000 picoseconds. - Weight::from_parts(13_573_000, 3086) + // Minimum execution time: 13_369_000 picoseconds. + Weight::from_parts(13_617_000, 3086) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -90,8 +90,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `74` // Estimated: `3086` - // Minimum execution time: 13_737_000 picoseconds. - Weight::from_parts(13_916_000, 3086) + // Minimum execution time: 13_421_000 picoseconds. + Weight::from_parts(13_692_000, 3086) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -105,25 +105,44 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `74` // Estimated: `3086` - // Minimum execution time: 18_180_000 picoseconds. - Weight::from_parts(18_463_000, 3086) + // Minimum execution time: 18_458_000 picoseconds. + Weight::from_parts(18_864_000, 3086) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: DappStaking Ledger (r:1 w:1) /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: CollatorSelection Candidates (r:1 w:0) + /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) /// Storage: Balances Freezes (r:1 w:1) /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) /// Storage: Balances Locks (r:1 w:0) /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// Storage: DappStaking CurrentEraInfo (r:1 w:1) /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) - fn lock() -> Weight { + fn lock_new_account() -> Weight { // Proof Size summary in bytes: - // Measured: `12` + // Measured: `138` // Estimated: `4764` - // Minimum execution time: 32_874_000 picoseconds. - Weight::from_parts(33_274_000, 4764) + // Minimum execution time: 62_743_000 picoseconds. + Weight::from_parts(64_992_000, 4764) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: DappStaking Ledger (r:1 w:1) + /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) + /// Storage: Balances Freezes (r:1 w:1) + /// Proof: Balances Freezes (max_values: None, max_size: Some(67), added: 2542, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:0) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: DappStaking CurrentEraInfo (r:1 w:1) + /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) + fn lock_existing_account() -> Weight { + // Proof Size summary in bytes: + // Measured: `158` + // Estimated: `4764` + // Minimum execution time: 38_250_000 picoseconds. + Weight::from_parts(38_835_000, 4764) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -139,8 +158,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `158` // Estimated: `4764` - // Minimum execution time: 34_421_000 picoseconds. - Weight::from_parts(35_413_000, 4764) + // Minimum execution time: 34_582_000 picoseconds. + Weight::from_parts(35_126_000, 4764) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -157,10 +176,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `191` // Estimated: `4764` - // Minimum execution time: 37_435_000 picoseconds. - Weight::from_parts(39_113_839, 4764) - // Standard Error: 3_446 - .saturating_add(Weight::from_parts(118_027, 0).saturating_mul(x.into())) + // Minimum execution time: 37_740_000 picoseconds. + Weight::from_parts(39_064_684, 4764) + // Standard Error: 2_750 + .saturating_add(Weight::from_parts(120_539, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -176,8 +195,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `200` // Estimated: `4764` - // Minimum execution time: 33_192_000 picoseconds. - Weight::from_parts(33_631_000, 4764) + // Minimum execution time: 33_298_000 picoseconds. + Weight::from_parts(33_903_000, 4764) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -199,8 +218,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `251` // Estimated: `4764` - // Minimum execution time: 45_619_000 picoseconds. - Weight::from_parts(45_985_000, 4764) + // Minimum execution time: 44_905_000 picoseconds. + Weight::from_parts(45_261_000, 4764) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -222,8 +241,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `432` // Estimated: `4764` - // Minimum execution time: 48_932_000 picoseconds. - Weight::from_parts(49_757_000, 4764) + // Minimum execution time: 48_594_000 picoseconds. + Weight::from_parts(49_441_000, 4764) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -242,10 +261,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `541` // Estimated: `4764` - // Minimum execution time: 51_777_000 picoseconds. - Weight::from_parts(49_689_608, 4764) - // Standard Error: 6_426 - .saturating_add(Weight::from_parts(3_298_280, 0).saturating_mul(x.into())) + // Minimum execution time: 52_182_000 picoseconds. + Weight::from_parts(50_073_700, 4764) + // Standard Error: 4_907 + .saturating_add(Weight::from_parts(3_301_788, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -262,10 +281,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `519` // Estimated: `4764` - // Minimum execution time: 49_515_000 picoseconds. - Weight::from_parts(47_526_163, 4764) - // Standard Error: 5_683 - .saturating_add(Weight::from_parts(3_267_803, 0).saturating_mul(x.into())) + // Minimum execution time: 49_637_000 picoseconds. + Weight::from_parts(47_809_537, 4764) + // Standard Error: 5_850 + .saturating_add(Weight::from_parts(3_304_857, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -279,8 +298,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `271` // Estimated: `3775` - // Minimum execution time: 42_226_000 picoseconds. - Weight::from_parts(42_414_000, 3775) + // Minimum execution time: 41_926_000 picoseconds. + Weight::from_parts(42_718_000, 3775) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -292,8 +311,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2584` // Estimated: `5048` - // Minimum execution time: 57_523_000 picoseconds. - Weight::from_parts(59_818_000, 5048) + // Minimum execution time: 57_183_000 picoseconds. + Weight::from_parts(58_197_000, 5048) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -313,8 +332,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `318` // Estimated: `4764` - // Minimum execution time: 41_488_000 picoseconds. - Weight::from_parts(42_872_000, 4764) + // Minimum execution time: 41_858_000 picoseconds. + Weight::from_parts(42_476_000, 4764) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -331,10 +350,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `256 + x * (69 ±0)` // Estimated: `4764 + x * (2613 ±0)` - // Minimum execution time: 42_933_000 picoseconds. - Weight::from_parts(39_506_127, 4764) - // Standard Error: 7_450 - .saturating_add(Weight::from_parts(5_115_797, 0).saturating_mul(x.into())) + // Minimum execution time: 43_103_000 picoseconds. + Weight::from_parts(39_876_215, 4764) + // Standard Error: 8_123 + .saturating_add(Weight::from_parts(5_014_232, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -345,8 +364,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_323_000 picoseconds. - Weight::from_parts(11_592_000, 0) + // Minimum execution time: 11_543_000 picoseconds. + Weight::from_parts(11_735_000, 0) } /// Storage: DappStaking CurrentEraInfo (r:1 w:1) /// Proof: DappStaking CurrentEraInfo (max_values: Some(1), max_size: Some(112), added: 607, mode: MaxEncodedLen) @@ -356,8 +375,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `16` // Estimated: `4254` - // Minimum execution time: 17_474_000 picoseconds. - Weight::from_parts(17_913_000, 4254) + // Minimum execution time: 17_687_000 picoseconds. + Weight::from_parts(18_283_000, 4254) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -379,8 +398,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `839` // Estimated: `4254` - // Minimum execution time: 47_997_000 picoseconds. - Weight::from_parts(49_198_000, 4254) + // Minimum execution time: 47_901_000 picoseconds. + Weight::from_parts(49_554_000, 4254) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -394,8 +413,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `68` // Estimated: `4254` - // Minimum execution time: 23_840_000 picoseconds. - Weight::from_parts(24_333_000, 4254) + // Minimum execution time: 23_705_000 picoseconds. + Weight::from_parts(24_313_000, 4254) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -408,10 +427,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `152 + x * (32 ±0)` // Estimated: `3061 + x * (2071 ±0)` - // Minimum execution time: 7_372_000 picoseconds. - Weight::from_parts(12_387_768, 3061) - // Standard Error: 3_378 - .saturating_add(Weight::from_parts(2_365_111, 0).saturating_mul(x.into())) + // Minimum execution time: 7_549_000 picoseconds. + Weight::from_parts(12_476_634, 3061) + // Standard Error: 3_594 + .saturating_add(Weight::from_parts(2_387_577, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) @@ -426,8 +445,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `293` // Estimated: `4254` - // Minimum execution time: 8_292_000 picoseconds. - Weight::from_parts(8_593_000, 4254) + // Minimum execution time: 8_529_000 picoseconds. + Weight::from_parts(8_772_000, 4254) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } diff --git a/tests/integration/Cargo.toml b/tests/integration/Cargo.toml index 1d1696f550..595ee1afb2 100644 --- a/tests/integration/Cargo.toml +++ b/tests/integration/Cargo.toml @@ -25,9 +25,6 @@ pallet-assets = { workspace = true } pallet-balances = { workspace = true } pallet-contracts = { workspace = true } pallet-contracts-primitives = { workspace = true } -pallet-dapp-staking-v3 = { workspace = true } -pallet-dapps-staking = { workspace = true } -pallet-inflation = { workspace = true } pallet-proxy = { workspace = true } pallet-utility = { workspace = true } sp-core = { workspace = true } @@ -36,9 +33,13 @@ sp-runtime = { workspace = true } # astar dependencies assets-chain-extension-types = { workspace = true } +pallet-collator-selection = { workspace = true } +pallet-dapp-staking-v3 = { workspace = true } +pallet-dapps-staking = { workspace = true } pallet-ethereum-checked = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } pallet-evm-precompile-dispatch = { workspace = true } +pallet-inflation = { workspace = true } pallet-unified-accounts = { workspace = true } precompile-utils = { workspace = true } unified-accounts-chain-extension-types = { workspace = true } diff --git a/tests/integration/src/dapp_staking_v3.rs b/tests/integration/src/dapp_staking_v3.rs index 1a79c9ccbc..5fa769ea1f 100644 --- a/tests/integration/src/dapp_staking_v3.rs +++ b/tests/integration/src/dapp_staking_v3.rs @@ -20,6 +20,7 @@ use crate::setup::*; +use pallet_collator_selection::{CandidateInfo, Candidates}; use pallet_dapp_staking_v3::*; #[test] @@ -78,3 +79,49 @@ fn dapp_staking_triggers_inflation_recalculation() { ); }); } + +#[test] +fn lock_not_possible_for_collator_candidate_account() { + new_test_ext().execute_with(|| { + // Hacky approach but it works + let candidate_info = CandidateInfo { + who: ALICE.clone(), + deposit: CollatorSelection::candidacy_bond(), + }; + Candidates::::mutate(|candidates| { + candidates.push(candidate_info); + }); + + // Now try to participate in dApp staking with Alice and expect an error + let minimum_lock_amount = + ::MinimumLockedAmount::get(); + assert_noop!( + DappStaking::lock(RuntimeOrigin::signed(ALICE.clone()), minimum_lock_amount,), + pallet_dapp_staking_v3::Error::::AccountNotAvailableForDappStaking + ); + }); +} + +// Not the ideal place for such test, can be moved later. +#[test] +fn collator_selection_candidacy_not_possible_for_dapp_staking_participant() { + new_test_ext().execute_with(|| { + // Lock some amount with Alice + let minimum_lock_amount = + ::MinimumLockedAmount::get(); + assert_ok!(DappStaking::lock( + RuntimeOrigin::signed(ALICE.clone()), + minimum_lock_amount, + )); + + // Ensure it's not possible to become a candidate for collator selection while having locked funds in dApp staking + assert_ok!(CollatorSelection::set_desired_candidates( + RuntimeOrigin::root(), + 1_000_000, + )); + assert_noop!( + CollatorSelection::register_as_candidate(RuntimeOrigin::signed(ALICE.clone())), + pallet_collator_selection::Error::::NotAllowedCandidate + ); + }); +} diff --git a/tests/integration/src/setup.rs b/tests/integration/src/setup.rs index 083a560ceb..2bca834b28 100644 --- a/tests/integration/src/setup.rs +++ b/tests/integration/src/setup.rs @@ -231,6 +231,7 @@ pub fn run_to_block(n: BlockNumber) { AuraExt::on_finalize(block_number); PolkadotXcm::on_finalize(block_number); Ethereum::on_finalize(block_number); + CollatorSelection::on_finalize(block_number); DynamicEvmBaseFee::on_finalize(block_number); #[cfg(any(feature = "shibuya", feature = "shiden"))] Inflation::on_finalize(block_number); @@ -249,6 +250,7 @@ pub fn run_to_block(n: BlockNumber) { Authorship::on_initialize(block_number); Aura::on_initialize(block_number); AuraExt::on_initialize(block_number); + CollatorSelection::on_initialize(block_number); Ethereum::on_initialize(block_number); DynamicEvmBaseFee::on_initialize(block_number); #[cfg(any(feature = "shibuya", feature = "shiden"))]