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
Original file line number Diff line number Diff line change
Expand Up @@ -47,34 +47,6 @@ use core::marker::PhantomData;
/// Weight functions for `pallet_treasury`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
/// Storage: Treasury ProposalCount (r:1 w:1)
/// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: Treasury Approvals (r:1 w:1)
/// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:0 w:1)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
fn spend_local() -> Weight {
// Proof Size summary in bytes:
// Measured: `42`
// Estimated: `1887`
// Minimum execution time: 177_000_000 picoseconds.
Weight::from_parts(191_000_000, 0)
.saturating_add(Weight::from_parts(0, 1887))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// 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 {
// Proof Size summary in bytes:
// Measured: `127`
// Estimated: `1887`
// Minimum execution time: 80_000_000 picoseconds.
Weight::from_parts(82_000_000, 0)
.saturating_add(Weight::from_parts(0, 1887))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Treasury Deactivated (r:1 w:1)
/// Proof: Treasury Deactivated (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
/// Storage: Balances InactiveIssuance (r:1 w:1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,6 @@ use core::marker::PhantomData;
/// Weight functions for `pallet_treasury`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
/// Storage: `FellowshipTreasury::ProposalCount` (r:1 w:1)
/// Proof: `FellowshipTreasury::ProposalCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `FellowshipTreasury::Approvals` (r:1 w:1)
/// Proof: `FellowshipTreasury::Approvals` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`)
/// Storage: `FellowshipTreasury::Proposals` (r:0 w:1)
/// Proof: `FellowshipTreasury::Proposals` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`)
fn spend_local() -> Weight {
// Proof Size summary in bytes:
// Measured: `76`
// Estimated: `1887`
// Minimum execution time: 12_879_000 picoseconds.
Weight::from_parts(13_346_000, 0)
.saturating_add(Weight::from_parts(0, 1887))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// 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 {
// Proof Size summary in bytes:
// Measured: `161`
// Estimated: `1887`
// Minimum execution time: 6_978_000 picoseconds.
Weight::from_parts(7_278_000, 0)
.saturating_add(Weight::from_parts(0, 1887))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `System::Account` (r:1 w:0)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `FellowshipTreasury::Deactivated` (r:1 w:1)
Expand Down
28 changes: 0 additions & 28 deletions polkadot/runtime/rococo/src/weights/pallet_treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,6 @@ use core::marker::PhantomData;
/// Weight functions for `pallet_treasury`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
/// Storage: `Treasury::ProposalCount` (r:1 w:1)
/// Proof: `Treasury::ProposalCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Treasury::Approvals` (r:1 w:1)
/// Proof: `Treasury::Approvals` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`)
/// Storage: `Treasury::Proposals` (r:0 w:1)
/// Proof: `Treasury::Proposals` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`)
fn spend_local() -> Weight {
// Proof Size summary in bytes:
// Measured: `142`
// Estimated: `1887`
// Minimum execution time: 12_748_000 picoseconds.
Weight::from_parts(13_519_000, 0)
.saturating_add(Weight::from_parts(0, 1887))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// 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 {
// Proof Size summary in bytes:
// Measured: `227`
// Estimated: `1887`
// Minimum execution time: 7_025_000 picoseconds.
Weight::from_parts(7_385_000, 0)
.saturating_add(Weight::from_parts(0, 1887))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Treasury::Deactivated` (r:1 w:1)
/// Proof: `Treasury::Deactivated` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `Treasury::LastSpendPeriod` (r:1 w:1)
Expand Down
23 changes: 23 additions & 0 deletions prdoc/pr_12683.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
title: Remove deprecated treasury spend_local and remove_approval
doc:
- audience: Runtime Dev
description: |-
## Summary
- Removed `spend_local` and `remove_approval` (deprecated by May 2025), plus the related public getters.
- Keeped `MaxApprovals` and `ProposalCount` / `Proposals` / `Approvals` so leftover approvals still pay out via `spend_funds`, and so bounties can keep using `MaxApprovals`.
- Updated tests/benchmarks to seed legacy proposal storage directly; drop weight methods from runtime weight files.
crates:
- name: asset-hub-westend-runtime
bump: major
- name: collectives-westend-runtime
bump: major
- name: rococo-runtime
bump: major
- name: pallet-bounties
bump: major
- name: pallet-child-bounties
bump: major
- name: pallet-tips
bump: major
- name: pallet-treasury
bump: major
39 changes: 25 additions & 14 deletions substrate/frame/bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@ fn go_to_block(n: u64) {
<Treasury as OnInitialize<u64>>::on_initialize(n);
}

// Directly insert a proposal into the legacy treasury `ProposalCount`/`Proposals`/`Approvals`
// storage, bypassing the now-removed `spend_local` call. Returns the proposal index. Kept around
// so that spend-period tests exercising the legacy approvals queue still work.
fn add_treasury_proposal(value: u64, beneficiary: u128) -> pallet_treasury::ProposalIndex {
let proposal_index = pallet_treasury::ProposalCount::<Test>::get();
pallet_treasury::Approvals::<Test>::try_append(proposal_index).expect("too many approvals");
let proposal = pallet_treasury::Proposal {
proposer: beneficiary,
value,
beneficiary,
bond: Default::default(),
};
pallet_treasury::Proposals::<Test>::insert(proposal_index, proposal);
pallet_treasury::ProposalCount::<Test>::put(proposal_index + 1);
proposal_index
}

frame_support::construct_runtime!(
pub enum Test
{
Expand Down Expand Up @@ -274,11 +291,10 @@ fn expect_events(e: Vec<BountiesEvent<Test>>) {
}

#[test]
#[allow(deprecated)]
fn genesis_config_works() {
ExtBuilder::default().build_and_execute(|| {
assert_eq!(Treasury::pot(), 0);
assert_eq!(Treasury::proposal_count(), 0);
assert_eq!(pallet_treasury::ProposalCount::<Test>::get(), 0);
});
}

Expand All @@ -292,12 +308,11 @@ fn minting_works() {
}

#[test]
#[allow(deprecated)]
fn accepted_spend_proposal_ignored_outside_spend_period() {
ExtBuilder::default().build_and_execute(|| {
Balances::make_free_balance_be(&Treasury::account_id(), 101);

assert_ok!({ Treasury::spend_local(RuntimeOrigin::root(), 100, 3) });
add_treasury_proposal(100, 3);

go_to_block(1);
assert_eq!(Balances::free_balance(3), 0);
Expand All @@ -319,13 +334,12 @@ fn unused_pot_should_diminish() {
}

#[test]
#[allow(deprecated)]
fn accepted_spend_proposal_enacted_on_spend_period() {
ExtBuilder::default().build_and_execute(|| {
Balances::make_free_balance_be(&Treasury::account_id(), 101);
assert_eq!(Treasury::pot(), 100);

assert_ok!({ Treasury::spend_local(RuntimeOrigin::root(), 100, 3) });
add_treasury_proposal(100, 3);

go_to_block(2);
assert_eq!(Balances::free_balance(3), 100);
Expand All @@ -334,13 +348,12 @@ fn accepted_spend_proposal_enacted_on_spend_period() {
}

#[test]
#[allow(deprecated)]
fn pot_underflow_should_not_diminish() {
ExtBuilder::default().build_and_execute(|| {
Balances::make_free_balance_be(&Treasury::account_id(), 101);
assert_eq!(Treasury::pot(), 100);

assert_ok!({ Treasury::spend_local(RuntimeOrigin::root(), 150, 3) });
add_treasury_proposal(150, 3);

go_to_block(2);
assert_eq!(Treasury::pot(), 100); // Pot hasn't changed
Expand All @@ -355,19 +368,18 @@ fn pot_underflow_should_not_diminish() {
// Treasury account doesn't get deleted if amount approved to spend is all its free balance.
// i.e. pot should not include existential deposit needed for account survival.
#[test]
#[allow(deprecated)]
fn treasury_account_doesnt_get_deleted() {
ExtBuilder::default().build_and_execute(|| {
Balances::make_free_balance_be(&Treasury::account_id(), 101);
assert_eq!(Treasury::pot(), 100);
let treasury_balance = Balances::free_balance(&Treasury::account_id());

assert_ok!({ Treasury::spend_local(RuntimeOrigin::root(), treasury_balance, 3) });
add_treasury_proposal(treasury_balance, 3);

go_to_block(2);
assert_eq!(Treasury::pot(), 100); // Pot hasn't changed

assert_ok!({ Treasury::spend_local(RuntimeOrigin::root(), Treasury::pot(), 3) });
add_treasury_proposal(Treasury::pot(), 3);

go_to_block(4);
assert_eq!(Treasury::pot(), 0); // Pot is emptied
Expand All @@ -378,7 +390,6 @@ fn treasury_account_doesnt_get_deleted() {
// In case treasury account is not existing then it works fine.
// This is useful for chain that will just update runtime.
#[test]
#[allow(deprecated)]
fn inexistent_account_works() {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pallet_balances::GenesisConfig::<Test> {
Expand All @@ -394,8 +405,8 @@ fn inexistent_account_works() {
assert_eq!(Balances::free_balance(Treasury::account_id()), 0); // Account does not exist
assert_eq!(Treasury::pot(), 0); // Pot is empty

assert_ok!({ Treasury::spend_local(RuntimeOrigin::root(), 99, 3) });
assert_ok!({ Treasury::spend_local(RuntimeOrigin::root(), 1, 3) });
add_treasury_proposal(99, 3);
add_treasury_proposal(1, 3);
go_to_block(2);

assert_eq!(Treasury::pot(), 0); // Pot hasn't changed
Expand Down
3 changes: 1 addition & 2 deletions substrate/frame/child-bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,10 @@ fn last_event() -> ChildBountiesEvent<Test> {
}

#[test]
#[allow(deprecated)]
fn genesis_config_works() {
new_test_ext().execute_with(|| {
assert_eq!(Treasury::pot(), 0);
assert_eq!(Treasury::proposal_count(), 0);
assert_eq!(pallet_treasury::ProposalCount::<Test>::get(), 0);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,34 +47,6 @@ use core::marker::PhantomData;
/// Weight functions for `pallet_treasury`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
/// Storage: Treasury ProposalCount (r:1 w:1)
/// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen)
/// Storage: Treasury Approvals (r:1 w:1)
/// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen)
/// Storage: Treasury Proposals (r:0 w:1)
/// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen)
fn spend_local() -> Weight {
// Proof Size summary in bytes:
// Measured: `42`
// Estimated: `1887`
// Minimum execution time: 177_000_000 picoseconds.
Weight::from_parts(191_000_000, 0)
.saturating_add(Weight::from_parts(0, 1887))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// 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 {
// Proof Size summary in bytes:
// Measured: `127`
// Estimated: `1887`
// Minimum execution time: 80_000_000 picoseconds.
Weight::from_parts(82_000_000, 0)
.saturating_add(Weight::from_parts(0, 1887))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Treasury Deactivated (r:1 w:1)
/// Proof: Treasury Deactivated (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
/// Storage: Balances InactiveIssuance (r:1 w:1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,6 @@ use core::marker::PhantomData;
/// Weight functions for `pallet_treasury`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
/// Storage: `Treasury::ProposalCount` (r:1 w:1)
/// Proof: `Treasury::ProposalCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Treasury::Approvals` (r:1 w:1)
/// Proof: `Treasury::Approvals` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`)
/// Storage: `Treasury::Proposals` (r:0 w:1)
/// Proof: `Treasury::Proposals` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`)
fn spend_local() -> Weight {
// Proof Size summary in bytes:
// Measured: `142`
// Estimated: `1887`
// Minimum execution time: 13_064_000 picoseconds.
Weight::from_parts(13_610_000, 0)
.saturating_add(Weight::from_parts(0, 1887))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// 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 {
// Proof Size summary in bytes:
// Measured: `227`
// Estimated: `1887`
// Minimum execution time: 7_097_000 picoseconds.
Weight::from_parts(7_538_000, 0)
.saturating_add(Weight::from_parts(0, 1887))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `System::Account` (r:1 w:0)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Treasury::Deactivated` (r:1 w:1)
Expand Down
3 changes: 1 addition & 2 deletions substrate/frame/tips/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,10 @@ fn last_event() -> TipEvent<Test> {
}

#[test]
#[allow(deprecated)]
fn genesis_config_works() {
build_and_execute(|| {
assert_eq!(Treasury::pot(), 0);
assert_eq!(Treasury::proposal_count(), 0);
assert_eq!(pallet_treasury::ProposalCount::<Test>::get(), 0);
});
}

Expand Down
Loading
Loading