Skip to content

Commit 061d27f

Browse files
author
DavidK
committed
Deprecate Gov_v1 flow components inside treasury pallet
1 parent 21b3a46 commit 061d27f

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

prdoc/pr_6169.prdoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
title: Deprecate Gov_v1 treasury spend flow in `treasury` pallet
2+
3+
doc:
4+
- audience: Runtime Dev
5+
description: |
6+
Deprecates items from treasury pallet used in Gov_v1 flow.
7+
Items deprecated: `spend_local`, `remove_approval`, `proposal_count`, `proposals`, `approvals`, `MaxApprovals`, `ProposalCount`, `Proposals`, `Approvals`.
8+
To replace `spend_local` functionality configure `Paymaster` pallet configuration to be `PayFromAccount` and configure `AssetKind` to be `()`.
9+
10+
crates:
11+
- name: pallet-treasury
12+
bump: major

substrate/frame/treasury/src/lib.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
7373
#![cfg_attr(not(feature = "std"), no_std)]
7474

75+
// not all specific usages can be marked as deprecated
76+
#![allow(deprecated)]
77+
7578
mod benchmarking;
7679
pub mod migration;
7780
#[cfg(test)]
@@ -240,6 +243,9 @@ pub mod pallet {
240243
///
241244
/// NOTE: This parameter is also used within the Bounties Pallet extension if enabled.
242245
#[pallet::constant]
246+
#[deprecated(
247+
note = "Gov v1 type used for spend_local, configure pallet to use PayFromAccount for Paymaster type instead"
248+
)]
243249
type MaxApprovals: Get<u32>;
244250

245251
/// The origin required for approving spends from the treasury outside of the proposal
@@ -279,10 +285,17 @@ pub mod pallet {
279285

280286
/// Number of proposals that have been made.
281287
#[pallet::storage]
288+
#[deprecated(
289+
note = "Gov v1 type used for spend_local, configure pallet to use PayFromAccount for Paymaster type instead"
290+
)]
282291
pub type ProposalCount<T, I = ()> = StorageValue<_, ProposalIndex, ValueQuery>;
283292

284293
/// Proposals that have been made.
285294
#[pallet::storage]
295+
#[deprecated(
296+
note = "Gov v1 type used for spend_local, configure pallet to use PayFromAccount for Paymaster type instead"
297+
)]
298+
#[allow(deprecated)]
286299
pub type Proposals<T: Config<I>, I: 'static = ()> = StorageMap<
287300
_,
288301
Twox64Concat,
@@ -298,6 +311,10 @@ pub mod pallet {
298311

299312
/// Proposal indices that have been approved but not yet awarded.
300313
#[pallet::storage]
314+
#[deprecated(
315+
note = "Gov v1 type used for spend_local, configure pallet to use PayFromAccount for Paymaster type instead"
316+
)]
317+
#[allow(deprecated)]
301318
pub type Approvals<T: Config<I>, I: 'static = ()> =
302319
StorageValue<_, BoundedVec<ProposalIndex, T::MaxApprovals>, ValueQuery>;
303320

@@ -470,6 +487,8 @@ pub mod pallet {
470487
/// Emits [`Event::SpendApproved`] if successful.
471488
#[pallet::call_index(3)]
472489
#[pallet::weight(T::WeightInfo::spend_local())]
490+
#[deprecated(note = "This call will be removed by May 2025. Configure pallet to use PayFromAccount for Paymaster type instead")]
491+
#[allow(deprecated)]
473492
pub fn spend_local(
474493
origin: OriginFor<T>,
475494
#[pallet::compact] amount: BalanceOf<T, I>,
@@ -499,7 +518,9 @@ pub mod pallet {
499518
.unwrap_or(Ok(()))?;
500519

501520
let beneficiary = T::Lookup::lookup(beneficiary)?;
521+
#[allow(deprecated)]
502522
let proposal_index = ProposalCount::<T, I>::get();
523+
#[allow(deprecated)]
503524
Approvals::<T, I>::try_append(proposal_index)
504525
.map_err(|_| Error::<T, I>::TooManyApprovals)?;
505526
let proposal = Proposal {
@@ -508,7 +529,9 @@ pub mod pallet {
508529
beneficiary: beneficiary.clone(),
509530
bond: Default::default(),
510531
};
532+
#[allow(deprecated)]
511533
Proposals::<T, I>::insert(proposal_index, proposal);
534+
#[allow(deprecated)]
512535
ProposalCount::<T, I>::put(proposal_index + 1);
513536

514537
Self::deposit_event(Event::SpendApproved { proposal_index, amount, beneficiary });
@@ -538,12 +561,17 @@ pub mod pallet {
538561
/// in the first place.
539562
#[pallet::call_index(4)]
540563
#[pallet::weight((T::WeightInfo::remove_approval(), DispatchClass::Operational))]
564+
#[deprecated(
565+
note = "This call will be removed by May 2025. Configure pallet to use PayFromAccount for Paymaster type instead"
566+
)]
567+
#[allow(deprecated)]
541568
pub fn remove_approval(
542569
origin: OriginFor<T>,
543570
#[pallet::compact] proposal_id: ProposalIndex,
544571
) -> DispatchResult {
545572
T::RejectOrigin::ensure_origin(origin)?;
546573

574+
#[allow(deprecated)]
547575
Approvals::<T, I>::try_mutate(|v| -> DispatchResult {
548576
if let Some(index) = v.iter().position(|x| x == &proposal_id) {
549577
v.remove(index);
@@ -793,16 +821,28 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
793821
}
794822

795823
/// Public function to proposal_count storage.
824+
#[deprecated(
825+
note = "This function will be removed by May 2025. Configure pallet to use PayFromAccount for Paymaster type instead"
826+
)]
796827
pub fn proposal_count() -> ProposalIndex {
828+
#[allow(deprecated)]
797829
ProposalCount::<T, I>::get()
798830
}
799831

800832
/// Public function to proposals storage.
833+
#[deprecated(
834+
note = "This function will be removed by May 2025. Configure pallet to use PayFromAccount for Paymaster type instead"
835+
)]
801836
pub fn proposals(index: ProposalIndex) -> Option<Proposal<T::AccountId, BalanceOf<T, I>>> {
837+
#[allow(deprecated)]
802838
Proposals::<T, I>::get(index)
803839
}
804840

805841
/// Public function to approvals storage.
842+
#[deprecated(
843+
note = "This function will be removed by May 2025. Configure pallet to use PayFromAccount for Paymaster type instead"
844+
)]
845+
#[allow(deprecated)]
806846
pub fn approvals() -> BoundedVec<ProposalIndex, T::MaxApprovals> {
807847
Approvals::<T, I>::get()
808848
}
@@ -817,6 +857,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
817857

818858
let mut missed_any = false;
819859
let mut imbalance = PositiveImbalanceOf::<T, I>::zero();
860+
#[allow(deprecated)]
820861
let proposals_len = Approvals::<T, I>::mutate(|v| {
821862
let proposals_approvals_len = v.len() as u32;
822863
v.retain(|&index| {

substrate/frame/treasury/src/migration.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ pub mod cleanup_proposals {
4343
{
4444
fn on_runtime_upgrade() -> frame_support::weights::Weight {
4545
let mut approval_index = BTreeSet::new();
46+
#[allow(deprecated)]
4647
for approval in Approvals::<T, I>::get().iter() {
4748
approval_index.insert(*approval);
4849
}
4950

5051
let mut proposals_processed = 0;
52+
#[allow(deprecated)]
5153
for (proposal_index, p) in Proposals::<T, I>::iter() {
5254
if !approval_index.contains(&proposal_index) {
5355
let err_amount = T::Currency::unreserve(&p.proposer, p.bond);

0 commit comments

Comments
 (0)