diff --git a/Cargo.lock b/Cargo.lock index e554d5f..886accc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2560,6 +2560,7 @@ dependencies = [ "pallet-transaction-payment-rpc-runtime-api", "pallet-treasury", "pallet-utility", + "pallet-vesting", "pallet-xcm", "parity-scale-codec", "polkadot-parachain-primitives", @@ -5369,6 +5370,7 @@ dependencies = [ "pallet-transaction-payment-rpc-runtime-api", "pallet-treasury", "pallet-utility", + "pallet-vesting", "pallet-xcm", "parity-scale-codec", "polkadot-parachain-primitives", diff --git a/Cargo.toml b/Cargo.toml index 3ffec3f..c1933dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,6 +63,7 @@ pallet-transaction-payment-rpc = { version = "26.0.0" } pallet-transaction-payment-rpc-runtime-api = { version = "24.0.0", default-features = false } pallet-treasury = { version = "23.0.0", default-features = false} pallet-utility = { version = "24.0.0", default-features = false } +pallet-vesting = { version = "24.0.0", default-features = false } sc-basic-authorship = { version = "0.30.0" } sc-chain-spec = { version = "23.0.0" } sc-cli = { version = "0.32.0" } diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 15aecfc..227c1f5 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -265,6 +265,7 @@ pub mod devnet { }, transaction_payment: Default::default(), treasury: Default::default(), + vesting: Default::default(), } } } @@ -463,6 +464,7 @@ pub mod mainnet { }, transaction_payment: Default::default(), treasury: Default::default(), + vesting: Default::default(), } } } diff --git a/runtime/devnet/Cargo.toml b/runtime/devnet/Cargo.toml index e2b5020..933d7ce 100644 --- a/runtime/devnet/Cargo.toml +++ b/runtime/devnet/Cargo.toml @@ -54,6 +54,7 @@ pallet-transaction-payment = { workspace = true, default-features = false } pallet-transaction-payment-rpc-runtime-api = { workspace = true, default-features = false } pallet-treasury = { workspace = true, default-features = false } pallet-utility = { workspace = true, default-features = false } +pallet-vesting = { workspace = true, default-features = false } sp-api = { workspace = true, default-features = false } sp-block-builder = { workspace = true, default-features = false } sp-consensus-aura = { workspace = true, default-features = false } @@ -126,6 +127,7 @@ std = [ "pallet-transaction-payment/std", "pallet-treasury/std", "pallet-utility/std", + "pallet-vesting/std", "pallet-xcm/std", "parachain-info/std", "parity-scale-codec/std", @@ -171,6 +173,7 @@ runtime-benchmarks = [ "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", "pallet-utility/runtime-benchmarks", + "pallet-vesting/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", @@ -203,6 +206,7 @@ try-runtime = [ "pallet-transaction-payment/try-runtime", "pallet-treasury/try-runtime", "pallet-utility/try-runtime", + "pallet-vesting/try-runtime", "pallet-xcm/try-runtime", "parachain-info/try-runtime", ] diff --git a/runtime/devnet/src/lib.rs b/runtime/devnet/src/lib.rs index c6c5cef..cabec60 100644 --- a/runtime/devnet/src/lib.rs +++ b/runtime/devnet/src/lib.rs @@ -32,7 +32,7 @@ use frame_support::{ parameter_types, traits::{ fungible::HoldConsideration, AsEnsureOriginWithArg, ConstU128, ConstU32, ConstU64, ConstU8, - EitherOfDiverse, Everything, LinearStoragePrice, + EitherOfDiverse, Everything, LinearStoragePrice, WithdrawReasons, }, weights::{ConstantMultiplier, Weight}, BoundedVec, PalletId, @@ -48,7 +48,7 @@ pub use runtime_common::{ NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; -pub use sp_runtime::{MultiAddress, Perbill, Percent, Permill}; +pub use sp_runtime::{traits::ConvertInto, MultiAddress, Perbill, Percent, Permill}; use xcm_config::{RelayLocation, XcmConfig, XcmOriginToTransactDispatchOrigin}; #[cfg(any(feature = "std", test))] @@ -739,6 +739,23 @@ impl pallet_treasury::Config for Runtime { type SpendOrigin = EnsureWithSuccess, AccountId, MaxBalance>; } +parameter_types! { + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); +} + +impl pallet_vesting::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type BlockNumberToBalance = ConvertInto; + type MinVestedTransfer = ConstU128<{ 1 * MQTY }>; + type WeightInfo = pallet_vesting::weights::SubstrateWeight; + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; + // `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the + // highest number of schedules that encodes less than 2^10. + const MAX_VESTING_SCHEDULES: u32 = 28; +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub struct Runtime { @@ -759,6 +776,7 @@ construct_runtime!( TransactionPayment: pallet_transaction_payment = 11, Assets: pallet_assets = 12, Treasury: pallet_treasury = 13, + Vesting: pallet_vesting = 14, // Governance Sudo: pallet_sudo = 15, @@ -801,6 +819,7 @@ mod benches { [pallet_utility, Utility] [pallet_nfts, Nfts] [pallet_nft_fractionalization, NftFractionalization] + [pallet_vesting, Vesting] [cumulus_pallet_xcmp_queue, XcmpQueue] // SBP-M1 review: add missing pallets: benchmarks should be re-run on reference hardware based on how they are configured/used by your runtime // TODO (@khssnv): consider reference hardware and re-run benchmarks diff --git a/runtime/mainnet/Cargo.toml b/runtime/mainnet/Cargo.toml index 3a4e949..7b3282a 100644 --- a/runtime/mainnet/Cargo.toml +++ b/runtime/mainnet/Cargo.toml @@ -54,6 +54,7 @@ pallet-transaction-payment = { workspace = true, default-features = false } pallet-transaction-payment-rpc-runtime-api = { workspace = true, default-features = false } pallet-treasury = { workspace = true, default-features = false } pallet-utility = { workspace = true, default-features = false } +pallet-vesting = { workspace = true, default-features = false } sp-api = { workspace = true, default-features = false } sp-block-builder = { workspace = true, default-features = false } sp-consensus-aura = { workspace = true, default-features = false } @@ -126,6 +127,7 @@ std = [ "pallet-transaction-payment/std", "pallet-treasury/std", "pallet-utility/std", + "pallet-vesting/std", "pallet-xcm/std", "parachain-info/std", "parity-scale-codec/std", @@ -171,6 +173,7 @@ runtime-benchmarks = [ "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", "pallet-utility/runtime-benchmarks", + "pallet-vesting/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", @@ -203,6 +206,7 @@ try-runtime = [ "pallet-transaction-payment/try-runtime", "pallet-treasury/try-runtime", "pallet-utility/try-runtime", + "pallet-vesting/try-runtime", "pallet-xcm/try-runtime", "parachain-info/try-runtime", ] diff --git a/runtime/mainnet/src/lib.rs b/runtime/mainnet/src/lib.rs index 31ff6be..68571e3 100644 --- a/runtime/mainnet/src/lib.rs +++ b/runtime/mainnet/src/lib.rs @@ -32,7 +32,7 @@ use frame_support::{ parameter_types, traits::{ fungible::HoldConsideration, AsEnsureOriginWithArg, ConstU128, ConstU32, ConstU64, ConstU8, - EitherOfDiverse, Everything, LinearStoragePrice, + EitherOfDiverse, Everything, LinearStoragePrice, WithdrawReasons, }, weights::{ConstantMultiplier, Weight}, BoundedVec, PalletId, @@ -48,7 +48,7 @@ pub use runtime_common::{ NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; -pub use sp_runtime::{MultiAddress, Perbill, Percent, Permill}; +pub use sp_runtime::{traits::ConvertInto, MultiAddress, Perbill, Percent, Permill}; use xcm_config::{RelayLocation, XcmConfig, XcmOriginToTransactDispatchOrigin}; #[cfg(any(feature = "std", test))] @@ -739,7 +739,25 @@ impl pallet_treasury::Config for Runtime { type SpendOrigin = EnsureWithSuccess, AccountId, MaxBalance>; } +parameter_types! { + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); +} + +impl pallet_vesting::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type BlockNumberToBalance = ConvertInto; + type MinVestedTransfer = ConstU128<{ 1 * MQTY }>; + type WeightInfo = pallet_vesting::weights::SubstrateWeight; + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; + // `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the + // highest number of schedules that encodes less than 2^10. + const MAX_VESTING_SCHEDULES: u32 = 28; +} + // Create the runtime by composing the FRAME pallets that were previously configured. +// add pallet vesting construct_runtime!( pub struct Runtime { // System support stuff. @@ -759,6 +777,7 @@ construct_runtime!( TransactionPayment: pallet_transaction_payment = 11, Assets: pallet_assets = 12, Treasury: pallet_treasury = 13, + Vesting: pallet_vesting = 14, // Governance Sudo: pallet_sudo = 15, @@ -802,6 +821,7 @@ mod benches { [pallet_utility, Utility] [pallet_nfts, Nfts] [pallet_nft_fractionalization, NftFractionalization] + [pallet_vesting, Vesting] [cumulus_pallet_xcmp_queue, XcmpQueue] // SBP-M1 review: add missing pallets: benchmarks should be re-run on reference hardware based on how they are configured/used by your runtime // TODO (@khssnv): consider reference hardware and re-run benchmarks