Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Vesting to Asset Hubs #269

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog for the runtimes governed by the Polkadot Fellowship.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

- Add `pallet-vesting` to Asset Hubs ([polkadot-fellows/runtimes#269](https://github.com/polkadot-fellows/runtimes/pull/269))

## [1.2.1] 09.04.2024

### Changed
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pallet-transaction-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
pallet-uniques = { workspace = true }
pallet-utility = { workspace = true }
pallet-vesting = { workspace = true }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-consensus-aura = { workspace = true }
Expand Down Expand Up @@ -138,6 +139,7 @@ runtime-benchmarks = [
"pallet-timestamp/runtime-benchmarks",
"pallet-uniques/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-vesting/runtime-benchmarks",
"pallet-xcm-benchmarks/runtime-benchmarks",
"pallet-xcm-bridge-hub-router/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
Expand Down Expand Up @@ -178,6 +180,7 @@ try-runtime = [
"pallet-transaction-payment/try-runtime",
"pallet-uniques/try-runtime",
"pallet-utility/try-runtime",
"pallet-vesting/try-runtime",
"pallet-xcm-bridge-hub-router/try-runtime",
"pallet-xcm/try-runtime",
"parachain-info/try-runtime",
Expand Down Expand Up @@ -229,6 +232,7 @@ std = [
"pallet-transaction-payment/std",
"pallet-uniques/std",
"pallet-utility/std",
"pallet-vesting/std",
"pallet-xcm-benchmarks?/std",
"pallet-xcm-bridge-hub-router/std",
"pallet-xcm/std",
Expand Down
33 changes: 30 additions & 3 deletions system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Verify},
traits::{
AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, Verify,
},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, Perbill, Permill,
};
Expand All @@ -58,7 +60,7 @@ use frame_support::{
traits::{
fungible, fungibles, tokens::imbalance::ResolveAssetTo, AsEnsureOriginWithArg, ConstBool,
ConstU128, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Equals, InstanceFilter,
TransformOrigin,
TransformOrigin, WithdrawReasons,
},
weights::{ConstantMultiplier, Weight},
BoundedVec, PalletId,
Expand Down Expand Up @@ -229,6 +231,26 @@ impl pallet_balances::Config for Runtime {
type MaxFreezes = ConstU32<0>;
}

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 = ExistentialDeposit;
type WeightInfo = weights::pallet_vesting::WeightInfo<Runtime>;
type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
/// Note for wallets and implementers: This means that vesting schedules are evaluated with the
/// block number of the Relay Chain, not the parachain. This is because with Coretime and Async
/// Backing, parachain block numbers may not be a good proxy for time. Vesting schedules should
/// be set accordingly.
type BlockNumberProvider = cumulus_pallet_parachain_system::RelaychainDataProvider<Runtime>;
const MAX_VESTING_SCHEDULES: u32 = 28;
}

parameter_types! {
/// Relay Chain `TransactionByteFee` / 10
pub const TransactionByteFee: Balance = system_parachains_constants::kusama::fee::TRANSACTION_BYTE_FEE;
Expand Down Expand Up @@ -507,7 +529,10 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Assets { .. } |
RuntimeCall::NftFractionalization { .. } |
RuntimeCall::Nfts { .. } |
RuntimeCall::Uniques { .. }
RuntimeCall::Uniques { .. } |
// We allow calling `vest` and merging vesting schedules, but obviously not
// vested transfers.
RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. })
),
ProxyType::CancelProxy => matches!(
c,
Expand Down Expand Up @@ -934,6 +959,7 @@ construct_runtime!(
Balances: pallet_balances = 10,
TransactionPayment: pallet_transaction_payment = 11,
AssetTxPayment: pallet_asset_conversion_tx_payment = 13,
Vesting: pallet_vesting = 14,

// Collator support. the order of these 5 are important and shall not change.
Authorship: pallet_authorship = 20,
Expand Down Expand Up @@ -1029,6 +1055,7 @@ mod benches {
[pallet_session, SessionBench::<Runtime>]
[pallet_uniques, Uniques]
[pallet_utility, Utility]
[pallet_vesting, Vesting]
[pallet_timestamp, Timestamp]
[pallet_collator_selection, CollatorSelection]
[cumulus_pallet_parachain_system, ParachainSystem]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading