Skip to content
Open
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
21 changes: 21 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ members = [
"substrate/frame/contracts/uapi",
"substrate/frame/conviction-voting",
"substrate/frame/core-fellowship",
"substrate/frame/dap",
"substrate/frame/delegated-staking",
"substrate/frame/democracy",
"substrate/frame/derivatives",
Expand Down Expand Up @@ -985,6 +986,7 @@ pallet-contracts-proc-macro = { path = "substrate/frame/contracts/proc-macro", d
pallet-contracts-uapi = { path = "substrate/frame/contracts/uapi", default-features = false }
pallet-conviction-voting = { path = "substrate/frame/conviction-voting", default-features = false }
pallet-core-fellowship = { path = "substrate/frame/core-fellowship", default-features = false }
pallet-dap = { path = "substrate/frame/dap", default-features = false }
pallet-default-config-example = { path = "substrate/frame/examples/default-config", default-features = false }
pallet-delegated-staking = { path = "substrate/frame/delegated-staking", default-features = false }
pallet-democracy = { path = "substrate/frame/democracy", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ cumulus-primitives-aura = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-utility = { workspace = true }
pallet-collator-selection = { workspace = true }
pallet-dap = { workspace = true }
pallet-message-queue = { workspace = true }
parachain-info = { workspace = true }
parachains-common = { workspace = true }
Expand Down Expand Up @@ -174,6 +175,7 @@ runtime-benchmarks = [
"pallet-balances/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
"pallet-conviction-voting/runtime-benchmarks",
"pallet-dap/runtime-benchmarks",
"pallet-delegated-staking/runtime-benchmarks",
"pallet-election-provider-multi-block/runtime-benchmarks",
"pallet-fast-unstake/runtime-benchmarks",
Expand Down Expand Up @@ -248,6 +250,7 @@ try-runtime = [
"pallet-balances/try-runtime",
"pallet-collator-selection/try-runtime",
"pallet-conviction-voting/try-runtime",
"pallet-dap/try-runtime",
"pallet-delegated-staking/try-runtime",
"pallet-election-provider-multi-block/try-runtime",
"pallet-fast-unstake/try-runtime",
Expand Down Expand Up @@ -329,6 +332,7 @@ std = [
"pallet-balances/std",
"pallet-collator-selection/std",
"pallet-conviction-voting/std",
"pallet-dap/std",
"pallet-delegated-staking/std",
"pallet-election-provider-multi-block/std",
"pallet-fast-unstake/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ impl pallet_referenda::Config for Runtime {

parameter_types! {
pub const SpendPeriod: BlockNumber = 6 * DAYS;
pub const Burn: Permill = Permill::from_perthousand(2);
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;

Expand Down Expand Up @@ -139,7 +138,7 @@ impl pallet_treasury::Config for Runtime {
type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type RuntimeEvent = RuntimeEvent;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type Burn = ();
type BurnDestination = ();
type MaxApprovals = MaxApprovals;
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,9 @@ construct_runtime!(
AssetRate: pallet_asset_rate = 95,
MultiAssetBounties: pallet_multi_asset_bounties = 96,

// Dynamic Allocation Pool / Issuance Buffer
Dap: pallet_dap = 100,

// TODO: the pallet instance should be removed once all pools have migrated
// to the new account IDs.
AssetConversionMigration: pallet_asset_conversion_ops = 200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl pallet_staking_async::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type CurrencyToVote = sp_staking::currency_to_vote::SaturatingCurrencyToVote;
type RewardRemainder = ();
type Slash = ();
type Slash = pallet_dap::SlashToDap<Runtime>;
type Reward = ();
type SessionsPerEra = SessionsPerEra;
type BondingDuration = BondingDuration;
Expand Down Expand Up @@ -311,6 +311,15 @@ impl pallet_staking_async_rc_client::Config for Runtime {
type ValidatorSetExportSession = ConstU32<4>;
}

parameter_types! {
pub const DapPalletId: frame_support::PalletId = frame_support::PalletId(*b"dap/buff");
}

impl pallet_dap::Config for Runtime {
type Currency = Balances;
type PalletId = DapPalletId;
}

#[derive(Encode, Decode)]
// Call indices taken from westend-next runtime.
pub enum RelayChainRuntimePallets {
Expand Down
5 changes: 2 additions & 3 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ use sp_runtime::{
Keccak256, OpaqueKeys, SaturatedConversion, Verify,
},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedU128, KeyTypeId, MultiSignature, MultiSigner, Percent, Permill,
ApplyExtrinsicResult, FixedU128, KeyTypeId, MultiSignature, MultiSigner, Percent,
};
use sp_staking::{EraIndex, SessionIndex};
#[cfg(any(feature = "std", test))]
Expand Down Expand Up @@ -923,7 +923,6 @@ impl pallet_fast_unstake::Config for Runtime {

parameter_types! {
pub const SpendPeriod: BlockNumber = 6 * DAYS;
pub const Burn: Permill = Permill::from_perthousand(2);
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;
// The asset's interior location for the paying account. This is the Treasury
Expand All @@ -947,7 +946,7 @@ impl pallet_treasury::Config for Runtime {
type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type RuntimeEvent = RuntimeEvent;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type Burn = ();
type BurnDestination = ();
type MaxApprovals = MaxApprovals;
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
Expand Down
41 changes: 41 additions & 0 deletions prdoc/pr_10576.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
title: 'Introduce FundingSink trait and pallet-dap for AssetHub'
doc:
- audience: Runtime Dev
description: |-
This PR introduces the foundation for the Dynamic Allocation Pool (DAP) system:

1. **FundingSink trait** (frame-support): A new trait for returning funds to an issuance system.
Implementations can either burn directly (`DirectBurn`) or return to a buffer for reuse.

2. **pallet-dap**: A new pallet that implements `FundingSink` by collecting funds into a buffer
account instead of burning them. The buffer account is created via `inc_providers` at genesis
or on runtime upgrade, ensuring it can receive any amount including those below ED.

3. **AssetHub Westend integration**: The runtime now uses pallet-dap to redirect staking slashes
to the DAP buffer (via `SlashToDap`).

**Treasury burns are now disabled** so no need to integrate with DAP: treasury `Burn` parameter is set
to zero in Westend RC, AssetHub and collective runtimes. This means no treasury funds are burned at
the end of spend periods, preserving total issuance.

User and pallet initiated burns do NOT go through DAP currently but they burn directly instead, reducing
total issuance immediately. It will be addressed in a follow-up change.
crates:
- name: frame-support
bump: minor
- name: pallet-balances
bump: major
- name: pallet-dap
bump: patch
- name: polkadot-sdk
bump: minor
- name: asset-hub-westend-runtime
bump: major
- name: westend-runtime
bump: major
- name: pallet-staking-async
bump: patch
- name: pallet-staking-async-parachain-runtime
bump: major
- name: pallet-staking-async-rc-runtime
bump: major
18 changes: 11 additions & 7 deletions substrate/frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ use frame_support::{
pallet_prelude::DispatchResult,
traits::{
tokens::{
fungible, BalanceStatus as Status, DepositConsequence,
Fortitude::{self, Force, Polite},
fungible, BalanceStatus as Status, DepositConsequence, Fortitude,
Fortitude::{Force, Polite},
IdAmount,
Preservation::{Expendable, Preserve, Protect},
WithdrawConsequence,
Expand Down Expand Up @@ -206,7 +206,11 @@ pub mod pallet {
use codec::HasCompact;
use frame_support::{
pallet_prelude::*,
traits::{fungible::Credit, tokens::Precision, VariantCount, VariantCountOf},
traits::{
fungible::Credit,
tokens::{Precision, Preservation},
VariantCount, VariantCountOf,
},
};
use frame_system::pallet_prelude::*;

Expand Down Expand Up @@ -852,8 +856,7 @@ pub mod pallet {
/// If the origin's account ends up below the existential deposit as a result
/// of the burn and `keep_alive` is false, the account will be reaped.
///
/// Unlike sending funds to a _burn_ address, which merely makes the funds inaccessible,
/// this `burn` operation will reduce total issuance by the amount _burned_.
/// Currently burns directly, reducing total issuance.
#[pallet::call_index(10)]
#[pallet::weight(if *keep_alive {T::WeightInfo::burn_allow_death() } else {T::WeightInfo::burn_keep_alive()})]
pub fn burn(
Expand All @@ -862,13 +865,14 @@ pub mod pallet {
keep_alive: bool,
) -> DispatchResult {
let source = ensure_signed(origin)?;
let preservation = if keep_alive { Preserve } else { Expendable };
let preservation =
if keep_alive { Preservation::Preserve } else { Preservation::Expendable };
<Self as fungible::Mutate<_>>::burn_from(
&source,
value,
preservation,
Precision::Exact,
Polite,
Fortitude::Polite,
)?;
Ok(())
}
Expand Down
57 changes: 57 additions & 0 deletions substrate/frame/dap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[package]
name = "pallet-dap"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME pallet for Dynamic Allocation Pool (DAP)"

[lints]
workspace = true

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { features = ["derive", "max-encoded-len"], workspace = true }
frame-benchmarking = { optional = true, workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
sp-runtime = { workspace = true }

[dev-dependencies]
pallet-balances = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }

[features]
default = ["std"]
std = [
"codec/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-balances/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-balances/try-runtime",
"sp-runtime/try-runtime",
]
Loading
Loading