Skip to content

Commit

Permalink
Remove deprecated treasury pallet calls (paritytech#3820)
Browse files Browse the repository at this point in the history
# ISSUE
- Link to the issue:
paritytech#3800
# Deliverables
- [x] remove deprecated calls;
(paritytech@d579b67)
- [x] set explicit coded indexes for Error and Event enums, remove
unused variants and keep the same indexes for the rest;
(paritytech@d579b67)
- [x] remove unused Config's type parameters;
(paritytech@d579b67)
- [x] remove irrelevant tests and adopt relevant using old api;
(paritytech@d579b67)
- [x] remove benchmarks for removed calls;
(paritytech@1a3d5f1)
- [x] prdoc
(paritytech@d579b67)
- [x] remove deprecated methods from the `treasury/README.md` and add
up-to-date dispatchable functions documentation
(paritytech@d579b67)
- [x] remove deprecated weight functions
(paritytech@8f74134)
> ### Separated to other issues
> - [ ] remove storage items like Proposals and ProposalCount, that are
not used anymore

Adjust all treasury pallet instances within polkadot-sdk
- [x] `pallet_bounty`, `tip`, `child_bounties`:
openguild-labs#3
- [x] Remove deprecated treasury weight functions used in Westend and
Rococo runtime `collective-westend`, `collective-rococo`

Add migration for westend and rococo to clean the data from removed
storage items
- [ ] paritytech#3828
# Test Outcomes
Successful tests by running `cargo test --features runtime-benchmarks`
```
running 38 tests
test tests::__construct_runtime_integrity_test::runtime_integrity_tests ... ok
test benchmarking::benchmarks::bench_check_status ... ok
test benchmarking::benchmarks::bench_payout ... ok
test benchmarking::benchmarks::bench_spend_local ... ok
test tests::accepted_spend_proposal_enacted_on_spend_period ... ok
test benchmarking::benchmarks::bench_spend ... ok
test tests::accepted_spend_proposal_ignored_outside_spend_period ... ok
test benchmarking::benchmarks::bench_void_spend ... ok
test benchmarking::benchmarks::bench_remove_approval ... ok
test tests::genesis_funding_works ... ok
test tests::genesis_config_works ... ok
test tests::inexistent_account_works ... ok
test tests::minting_works ... ok
test tests::check_status_works ... ok
test tests::payout_retry_works ... ok
test tests::pot_underflow_should_not_diminish ... ok
test tests::remove_already_removed_approval_fails ... ok
test tests::spend_local_origin_permissioning_works ... ok
test tests::spend_valid_from_works ... ok
test tests::spend_expires ... ok
test tests::spend_works ... ok
test tests::test_genesis_config_builds ... ok
test tests::spend_payout_works ... ok
test tests::spend_local_origin_works ... ok
test tests::spend_origin_works ... ok
test tests::spending_local_in_batch_respects_max_total ... ok
test tests::spending_in_batch_respects_max_total ... ok
test tests::try_state_proposals_invariant_2_works ... ok
test tests::try_state_proposals_invariant_1_works ... ok
test tests::try_state_spends_invariant_2_works ... ok
test tests::try_state_spends_invariant_1_works ... ok
test tests::treasury_account_doesnt_get_deleted ... ok
test tests::try_state_spends_invariant_3_works ... ok
test tests::unused_pot_should_diminish ... ok
test tests::void_spend_works ... ok
test tests::try_state_proposals_invariant_3_works ... ok
test tests::max_approvals_limited ... ok
test benchmarking::benchmarks::bench_on_initialize_proposals ... ok

test result: ok. 38 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.08s

   Doc-tests pallet_treasury

running 2 tests
test substrate/frame/treasury/src/lib.rs - (line 52) ... ignored
test substrate/frame/treasury/src/lib.rs - (line 79) ... ignored

test result: ok. 0 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out; finished in 0.00s
```

polkadot address: 19nSqFQorfF2HxD3oBzWM3oCh4SaCRKWt1yvmgaPYGCo71J
  • Loading branch information
chungquantin authored and TarekkMA committed Aug 2, 2024
1 parent 7278d20 commit 579ee3c
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 918 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ use xcm_builder::{AliasesIntoAccountId32, PayOverXcm};

#[cfg(feature = "runtime-benchmarks")]
use crate::impls::benchmarks::{OpenHrmpChannel, PayWithEnsure};
#[cfg(feature = "runtime-benchmarks")]
use testnet_parachains_constants::westend::currency::DOLLARS;

/// The Fellowship members' ranks.
pub mod ranks {
Expand Down Expand Up @@ -270,16 +268,6 @@ parameter_types! {
pub SelfParaId: ParaId = ParachainInfo::parachain_id();
}

#[cfg(feature = "runtime-benchmarks")]
parameter_types! {
// Benchmark bond. Needed to make `propose_spend` work.
pub const TenPercent: Permill = Permill::from_percent(10);
// Benchmark minimum. Needed to make `propose_spend` work.
pub const BenchmarkProposalBondMinimum: Balance = 1 * DOLLARS;
// Benchmark maximum. Needed to make `propose_spend` work.
pub const BenchmarkProposalBondMaximum: Balance = 10 * DOLLARS;
}

/// [`PayOverXcm`] setup to pay the Fellowship Treasury.
pub type FellowshipTreasuryPaymaster = PayOverXcm<
FellowshipTreasuryInteriorLocation,
Expand All @@ -302,20 +290,6 @@ impl pallet_treasury::Config<FellowshipTreasuryInstance> for Runtime {
// TODO: replace with `NeverEnsure` once polkadot-sdk 1.5 is released.
type ApproveOrigin = NeverEnsureOrigin<()>;
type OnSlash = ();
#[cfg(not(feature = "runtime-benchmarks"))]
type ProposalBond = HundredPercent;
#[cfg(not(feature = "runtime-benchmarks"))]
type ProposalBondMinimum = MaxBalance;
#[cfg(not(feature = "runtime-benchmarks"))]
type ProposalBondMaximum = MaxBalance;

#[cfg(feature = "runtime-benchmarks")]
type ProposalBond = TenPercent;
#[cfg(feature = "runtime-benchmarks")]
type ProposalBondMinimum = BenchmarkProposalBondMinimum;
#[cfg(feature = "runtime-benchmarks")]
type ProposalBondMaximum = BenchmarkProposalBondMaximum;
// end.

type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
type PalletId = FellowshipTreasuryPalletId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,43 +62,6 @@ impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `FellowshipTreasury::ProposalCount` (r:1 w:1)
/// Proof: `FellowshipTreasury::ProposalCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `FellowshipTreasury::Proposals` (r:0 w:1)
/// Proof: `FellowshipTreasury::Proposals` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`)
fn propose_spend() -> Weight {
// Proof Size summary in bytes:
// Measured: `143`
// Estimated: `1489`
// Minimum execution time: 264_000_000 picoseconds.
Weight::from_parts(277_000_000, 0)
.saturating_add(Weight::from_parts(0, 1489))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `FellowshipTreasury::Proposals` (r:1 w:1)
/// Proof: `FellowshipTreasury::Proposals` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn reject_proposal() -> Weight {
// Proof Size summary in bytes:
// Measured: `301`
// Estimated: `3593`
// Minimum execution time: 289_000_000 picoseconds.
Weight::from_parts(312_000_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// The range of component `p` is `[0, 99]`.
fn approve_proposal(_p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 0_000 picoseconds.
Weight::from_parts(0, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `FellowshipTreasury::Approvals` (r:1 w:1)
/// Proof: `FellowshipTreasury::Approvals` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`)
fn remove_approval() -> Weight {
Expand Down
3 changes: 0 additions & 3 deletions polkadot/runtime/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,6 @@ mod tests {
type RejectOrigin = frame_system::EnsureRoot<AccountId>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = ();
type ProposalBond = ();
type ProposalBondMinimum = ();
type ProposalBondMaximum = ();
type SpendPeriod = ();
type Burn = ();
type BurnDestination = ();
Expand Down
6 changes: 0 additions & 6 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,6 @@ parameter_types! {
}

parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: Balance = 2000 * CENTS;
pub const ProposalBondMaximum: Balance = 1 * GRAND;
pub const SpendPeriod: BlockNumber = 6 * DAYS;
pub const Burn: Permill = Permill::from_perthousand(2);
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
Expand All @@ -505,9 +502,6 @@ impl pallet_treasury::Config for Runtime {
type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = Treasury;
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ProposalBondMaximum;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BurnDestination = Society;
Expand Down
45 changes: 0 additions & 45 deletions polkadot/runtime/rococo/src/weights/pallet_treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,51 +63,6 @@ impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: Treasury ProposalCount (r:1 w:1)
/// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:0 w:1)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
fn propose_spend() -> Weight {
// Proof Size summary in bytes:
// Measured: `143`
// Estimated: `1489`
// Minimum execution time: 354_000_000 picoseconds.
Weight::from_parts(376_000_000, 0)
.saturating_add(Weight::from_parts(0, 1489))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: Treasury Proposals (r:1 w:1)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn reject_proposal() -> Weight {
// Proof Size summary in bytes:
// Measured: `301`
// Estimated: `3593`
// Minimum execution time: 547_000_000 picoseconds.
Weight::from_parts(550_000_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: Treasury Proposals (r:1 w:0)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
/// Storage: Treasury Approvals (r:1 w:1)
/// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// The range of component `p` is `[0, 99]`.
fn approve_proposal(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `470 + p * (8 ±0)`
// Estimated: `3573`
// Minimum execution time: 104_000_000 picoseconds.
Weight::from_parts(121_184_402, 0)
.saturating_add(Weight::from_parts(0, 3573))
// Standard Error: 42_854
.saturating_add(Weight::from_parts(153_112, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Treasury Approvals (r:1 w:1)
/// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
fn remove_approval() -> Weight {
Expand Down
6 changes: 0 additions & 6 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,6 @@ impl pallet_fast_unstake::Config for Runtime {
}

parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: Balance = 2000 * CENTS;
pub const ProposalBondMaximum: Balance = 1 * GRAND;
pub const SpendPeriod: BlockNumber = 6 * DAYS;
pub const Burn: Permill = Permill::from_perthousand(2);
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
Expand All @@ -690,9 +687,6 @@ impl pallet_treasury::Config for Runtime {
type RejectOrigin = EitherOfDiverse<EnsureRoot<AccountId>, Treasurer>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = Treasury;
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ProposalBondMaximum;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BurnDestination = ();
Expand Down
45 changes: 0 additions & 45 deletions polkadot/runtime/westend/src/weights/pallet_treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,51 +63,6 @@ impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: Treasury ProposalCount (r:1 w:1)
/// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:0 w:1)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
fn propose_spend() -> Weight {
// Proof Size summary in bytes:
// Measured: `143`
// Estimated: `1489`
// Minimum execution time: 354_000_000 picoseconds.
Weight::from_parts(376_000_000, 0)
.saturating_add(Weight::from_parts(0, 1489))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: Treasury Proposals (r:1 w:1)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn reject_proposal() -> Weight {
// Proof Size summary in bytes:
// Measured: `301`
// Estimated: `3593`
// Minimum execution time: 547_000_000 picoseconds.
Weight::from_parts(550_000_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: Treasury Proposals (r:1 w:0)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
/// Storage: Treasury Approvals (r:1 w:1)
/// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// The range of component `p` is `[0, 99]`.
fn approve_proposal(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `470 + p * (8 ±0)`
// Estimated: `3573`
// Minimum execution time: 104_000_000 picoseconds.
Weight::from_parts(121_184_402, 0)
.saturating_add(Weight::from_parts(0, 3573))
// Standard Error: 42_854
.saturating_add(Weight::from_parts(153_112, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Treasury Approvals (r:1 w:1)
/// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
fn remove_approval() -> Weight {
Expand Down
32 changes: 32 additions & 0 deletions prdoc/pr_3820.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Remove deprecated calls from treasury pallet

doc:
- audience: Runtime User
description: |
This PR remove deprecated calls, relevant tests from `pallet-treasury`.
- Remove deprecated calls `propose_spend`, `reject_proposal`, `approve_proposal`.
- Replace the code flow of `propose_spend` then `approve_proposal` with `spend_local`
- Remove deprecated calls' related weight functions and test cases.
- Remove deprecated parameter types: ProposalBond, ProposalBondMaximum, ProposalBondMinimum
- Remove pallet treasury's relevant deprecated code in pallet-tips, pallet-bounties and pallet-child-bounties

crates:
- name: pallet-treasury
bump: major
- name: pallet-tips
bump: patch
- name: pallet-child-bounties
bump: patch
- name: pallet-bounties
bump: patch
- name: polkadot-runtime-common
bump: patch
- name: rococo-runtime
bump: patch
- name: westend-runtime
bump: patch
- name: collectives-westend-runtime
bump: patch
5 changes: 0 additions & 5 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,8 +1212,6 @@ impl pallet_membership::Config<pallet_membership::Instance1> for Runtime {
}

parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: Balance = 1 * DOLLARS;
pub const SpendPeriod: BlockNumber = 1 * DAYS;
pub const Burn: Permill = Permill::from_percent(50);
pub const TipCountdown: BlockNumber = 1 * DAYS;
Expand All @@ -1240,9 +1238,6 @@ impl pallet_treasury::Config for Runtime {
>;
type RuntimeEvent = RuntimeEvent;
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ();
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BurnDestination = ();
Expand Down
Loading

0 comments on commit 579ee3c

Please sign in to comment.