diff --git a/node/cli/src/chain_spec.rs b/node/cli/src/chain_spec.rs index 1cad42e4..c68d276e 100644 --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -288,6 +288,12 @@ pub fn testnet_genesis( current_payout: 95 * DOLLARS, minting_interval: One::one(), }, + nomination_pools: edgeware_runtime::NominationPoolsConfig { + max_pools: Some(84), + min_join_bond: EDG, + min_create_bond: 100 * EDG, + ..Default::default() + }, } } diff --git a/node/runtime/Cargo.toml b/node/runtime/Cargo.toml index 228dab14..30379dde 100644 --- a/node/runtime/Cargo.toml +++ b/node/runtime/Cargo.toml @@ -71,6 +71,7 @@ pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", b frame-executive = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19", default-features = false } pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19", default-features = false } pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19", default-features = false } +pallet-nomination-pools = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.20" } pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19", default-features = false } pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19", default-features = false } pallet-multisig = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19", default-features = false } @@ -127,6 +128,7 @@ getrandom = { version = "0.2", features = ["js"] } # used for runtime benchmarking frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19", default-features = false, optional = true } frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.19", default-features = false, optional = true } +pallet-nomination-pools-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.20" } hex-literal = "0.3.4" [build-dependencies] @@ -161,6 +163,7 @@ std = [ "frame-executive/std", "pallet-grandpa/std", "pallet-identity/std", + "pallet-nomination-pools/std", "pallet-im-online/std", "pallet-indices/std", "pallet-multisig/std", @@ -235,4 +238,5 @@ runtime-benchmarks = [ "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "frame-system-benchmarking", + "pallet-nomination-pools-benchmarking", ] diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index b96af98c..355d32bc 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -141,8 +141,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to equal spec_version. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 53, - impl_version: 53, + spec_version: 54, + impl_version: 54, apis: RUNTIME_API_VERSIONS, transaction_version: 2, state_version: 53, @@ -320,6 +320,7 @@ impl InstanceFilter for ProxyType { Call::Balances(..) | Call::Vesting(pallet_vesting::Call::vested_transfer { .. }) | Call::Indices(pallet_indices::Call::transfer { .. }) + | Call::NominationPools(..) ), ProxyType::Governance => matches!( c, @@ -585,6 +586,7 @@ impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig { impl pallet_staking::Config for Runtime { type MaxNominations = MaxNominations; type Currency = Balances; + type CurrencyBalance = Balance; type UnixTime = Timestamp; type CurrencyToVote = U128CurrencyToVote; type RewardRemainder = Treasury; @@ -608,6 +610,7 @@ impl pallet_staking::Config for Runtime { type GenesisElectionProvider = onchain::UnboundedExecution; type VoterList = BagsList; type MaxUnlockingChunks = ConstU32<32>; + type OnStakerSlash = (); type WeightInfo = pallet_staking::weights::SubstrateWeight; type BenchmarkingConfig = StakingBenchmarkingConfig; } @@ -1469,6 +1472,37 @@ impl treasury_reward::Config for Runtime { type Event = Event; } +pub struct BalanceToU256; +impl sp_runtime::traits::Convert for BalanceToU256 { + fn convert(n: Balance) -> sp_core::U256 { + n.into() + } +} +pub struct U256ToBalance; +impl sp_runtime::traits::Convert for U256ToBalance { + fn convert(n: sp_core::U256) -> Balance { + n.try_into().unwrap_or(Balance::MAX) + } +} + +parameter_types! { + pub const PoolsPalletId: PalletId = PalletId(*b"py/nopls"); +} + +impl pallet_nomination_pools::Config for Runtime { + type Event = Event; + type WeightInfo = weights::pallet_nomination_pools::WeightInfo; + type Currency = Balances; + type BalanceToU256 = BalanceToU256; + type U256ToBalance = U256ToBalance; + type StakingInterface = Staking; + type PostUnbondingPoolsWindow = ConstU32<4>; + type MaxMetadataLen = ConstU32<256>; + // we use the same number of allowed unlocking chunks as with staking. + type MaxUnbonding = ::MaxUnlockingChunks; + type PalletId = PoolsPalletId; +} + construct_runtime!( pub enum Runtime where Block = Block, @@ -1516,6 +1550,7 @@ construct_runtime!( BaseFee: pallet_base_fee = 41, BagsList: pallet_bags_list = 42, Preimage: pallet_preimage = 43, + NominationPools: pallet_nomination_pools::{Pallet, Call, Storage, Event, Config} = 44, // Referenda: pallet_referenda, // ConvictionVoting: pallet_conviction_voting, } @@ -2066,6 +2101,7 @@ impl_runtime_apis! { use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; + use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench; let mut list = Vec::::new(); @@ -2083,7 +2119,9 @@ impl_runtime_apis! { use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; use frame_system_benchmarking::Pallet as SystemBench; + use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench; impl frame_system_benchmarking::Config for Runtime {} + impl pallet_nomination_pools_benchmarking::Config for Runtime {} let whitelist: Vec = vec![ // Block Number