From be30e7ecec13cba1f47c7f426dba35b2d04f83b0 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 28 Aug 2023 18:22:52 +0200 Subject: [PATCH 1/8] remove deprecated dispatchables --- substrate/frame/balances/src/lib.rs | 63 ----------------------------- 1 file changed, 63 deletions(-) diff --git a/substrate/frame/balances/src/lib.rs b/substrate/frame/balances/src/lib.rs index f94b3230b917..5da6600d8796 100644 --- a/substrate/frame/balances/src/lib.rs +++ b/substrate/frame/balances/src/lib.rs @@ -563,53 +563,6 @@ pub mod pallet { Ok(()) } - /// Set the regular balance of a given account; it also takes a reserved balance but this - /// must be the same as the account's current reserved balance. - /// - /// The dispatch origin for this call is `root`. - /// - /// WARNING: This call is DEPRECATED! Use `force_set_balance` instead. - #[pallet::call_index(1)] - #[pallet::weight( - T::WeightInfo::force_set_balance_creating() // Creates a new account. - .max(T::WeightInfo::force_set_balance_killing()) // Kills an existing account. - )] - pub fn set_balance_deprecated( - origin: OriginFor, - who: AccountIdLookupOf, - #[pallet::compact] new_free: T::Balance, - #[pallet::compact] old_reserved: T::Balance, - ) -> DispatchResult { - ensure_root(origin)?; - let who = T::Lookup::lookup(who)?; - let existential_deposit = Self::ed(); - - let wipeout = new_free < existential_deposit; - let new_free = if wipeout { Zero::zero() } else { new_free }; - - // First we try to modify the account's balance to the forced balance. - let old_free = Self::try_mutate_account_handling_dust( - &who, - |account, _is_new| -> Result { - let old_free = account.free; - ensure!(account.reserved == old_reserved, TokenError::Unsupported); - account.free = new_free; - Ok(old_free) - }, - )?; - - // This will adjust the total issuance, which was not done by the `mutate_account` - // above. - if new_free > old_free { - mem::drop(PositiveImbalance::::new(new_free - old_free)); - } else if new_free < old_free { - mem::drop(NegativeImbalance::::new(old_free - new_free)); - } - - Self::deposit_event(Event::BalanceSet { who, free: new_free }); - Ok(()) - } - /// Exactly as `transfer_allow_death`, except the origin must be root and the source account /// may be specified. #[pallet::call_index(2)] @@ -730,22 +683,6 @@ pub mod pallet { } } - /// Alias for `transfer_allow_death`, provided only for name-wise compatibility. - /// - /// WARNING: DEPRECATED! Will be released in approximately 3 months. - #[pallet::call_index(7)] - #[pallet::weight(T::WeightInfo::transfer_allow_death())] - pub fn transfer( - origin: OriginFor, - dest: AccountIdLookupOf, - #[pallet::compact] value: T::Balance, - ) -> DispatchResult { - let source = ensure_signed(origin)?; - let dest = T::Lookup::lookup(dest)?; - >::transfer(&source, &dest, value, Expendable)?; - Ok(()) - } - /// Set the regular balance of a given account. /// /// The dispatch origin for this call is `root`. From f085aabe5d2749bc167ccf58430f226ae510d7c2 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 29 Aug 2023 09:39:13 +0200 Subject: [PATCH 2/8] update test --- substrate/frame/asset-conversion/src/tests.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/substrate/frame/asset-conversion/src/tests.rs b/substrate/frame/asset-conversion/src/tests.rs index 450a074ec367..4215dc7ab5a2 100644 --- a/substrate/frame/asset-conversion/src/tests.rs +++ b/substrate/frame/asset-conversion/src/tests.rs @@ -1389,7 +1389,11 @@ fn cannot_block_pool_creation() { let pool_account = AssetConversion::get_pool_account(&AssetConversion::get_pool_id(token_2, token_1)); // And transfers the ED to that pool account - assert_ok!(Balances::transfer(RuntimeOrigin::signed(attacker), pool_account, ed)); + assert_ok!(Balances::transfer_allow_death( + RuntimeOrigin::signed(attacker), + pool_account, + ed + )); // Then, the attacker creates 14 tokens and sends one of each to the pool account for i in 10..25 { create_tokens(attacker, vec![NativeOrAssetId::Asset(i)]); From 33ea65aaf380fbe8495241bf2d9a0b92462853ec Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 29 Aug 2023 09:42:32 +0200 Subject: [PATCH 3/8] update tests --- substrate/frame/safe-mode/src/mock.rs | 5 ++++- substrate/frame/safe-mode/src/tests.rs | 2 +- substrate/frame/tx-pause/src/mock.rs | 5 ++++- substrate/frame/tx-pause/src/tests.rs | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/substrate/frame/safe-mode/src/mock.rs b/substrate/frame/safe-mode/src/mock.rs index 337b6076f84b..635ee0cfedc0 100644 --- a/substrate/frame/safe-mode/src/mock.rs +++ b/substrate/frame/safe-mode/src/mock.rs @@ -122,7 +122,10 @@ impl InstanceFilter for ProxyType { match self { ProxyType::Any => true, ProxyType::JustTransfer => { - matches!(c, RuntimeCall::Balances(pallet_balances::Call::transfer { .. })) + matches!( + c, + RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. }) + ) }, ProxyType::JustUtility => matches!(c, RuntimeCall::Utility { .. }), } diff --git a/substrate/frame/safe-mode/src/tests.rs b/substrate/frame/safe-mode/src/tests.rs index 4ce9922d3b65..7fb65cb5cc03 100644 --- a/substrate/frame/safe-mode/src/tests.rs +++ b/substrate/frame/safe-mode/src/tests.rs @@ -605,7 +605,7 @@ fn fails_when_explicit_origin_required() { } fn call_transfer() -> RuntimeCall { - RuntimeCall::Balances(pallet_balances::Call::transfer { dest: 1, value: 1 }) + RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { dest: 1, value: 1 }) } fn signed(who: u64) -> RuntimeOrigin { diff --git a/substrate/frame/tx-pause/src/mock.rs b/substrate/frame/tx-pause/src/mock.rs index 70c888f3c38d..a64122d7b0fc 100644 --- a/substrate/frame/tx-pause/src/mock.rs +++ b/substrate/frame/tx-pause/src/mock.rs @@ -120,7 +120,10 @@ impl InstanceFilter for ProxyType { match self { ProxyType::Any => true, ProxyType::JustTransfer => { - matches!(c, RuntimeCall::Balances(pallet_balances::Call::transfer { .. })) + matches!( + c, + RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. }) + ) }, ProxyType::JustUtility => matches!(c, RuntimeCall::Utility { .. }), } diff --git a/substrate/frame/tx-pause/src/tests.rs b/substrate/frame/tx-pause/src/tests.rs index ca259315726b..83ecbb3b067a 100644 --- a/substrate/frame/tx-pause/src/tests.rs +++ b/substrate/frame/tx-pause/src/tests.rs @@ -207,7 +207,7 @@ fn fails_to_unpause_not_paused_pallet() { } pub fn call_transfer(dest: u64, value: u64) -> RuntimeCall { - RuntimeCall::Balances(pallet_balances::Call::transfer { dest, value }) + RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { dest, value }) } pub fn call_transfer_keep_alive(dest: u64, value: u64) -> RuntimeCall { From e09564fd369d485c4601dd8c120f2e563ff3de2d Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 29 Aug 2023 16:29:44 +0200 Subject: [PATCH 4/8] update tests --- substrate/frame/tx-pause/src/tests.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/substrate/frame/tx-pause/src/tests.rs b/substrate/frame/tx-pause/src/tests.rs index 83ecbb3b067a..0181510f0069 100644 --- a/substrate/frame/tx-pause/src/tests.rs +++ b/substrate/frame/tx-pause/src/tests.rs @@ -31,7 +31,7 @@ fn can_pause_specific_call() { assert_ok!(TxPause::pause( RuntimeOrigin::signed(mock::PauseOrigin::get()), - full_name::(b"Balances", b"transfer") + full_name::(b"Balances", b"transfer_allow_death") )); assert_err!( @@ -68,7 +68,7 @@ fn can_unpause_specific_call() { new_test_ext().execute_with(|| { assert_ok!(TxPause::pause( RuntimeOrigin::signed(mock::PauseOrigin::get()), - full_name::(b"Balances", b"transfer"), + full_name::(b"Balances", b"transfer_allow_death"), )); assert_err!( call_transfer(2, 1).dispatch(RuntimeOrigin::signed(2)), @@ -77,7 +77,7 @@ fn can_unpause_specific_call() { assert_ok!(TxPause::unpause( RuntimeOrigin::signed(mock::UnpauseOrigin::get()), - full_name::(b"Balances", b"transfer"), + full_name::(b"Balances", b"transfer_allow_death"), )); assert_ok!(call_transfer(4, 1).dispatch(RuntimeOrigin::signed(0))); }); @@ -91,7 +91,7 @@ fn can_filter_balance_in_batch_when_paused() { assert_ok!(TxPause::pause( RuntimeOrigin::signed(mock::PauseOrigin::get()), - full_name::(b"Balances", b"transfer"), + full_name::(b"Balances", b"transfer_allow_death"), )); assert_ok!(batch_call.clone().dispatch(RuntimeOrigin::signed(0))); @@ -110,7 +110,7 @@ fn can_filter_balance_in_proxy_when_paused() { new_test_ext().execute_with(|| { assert_ok!(TxPause::pause( RuntimeOrigin::signed(mock::PauseOrigin::get()), - full_name::(b"Balances", b"transfer"), + full_name::(b"Balances", b"transfer_allow_death"), )); assert_ok!(Proxy::add_proxy(RuntimeOrigin::signed(1), 2, ProxyType::JustTransfer, 0)); @@ -151,7 +151,7 @@ fn fails_to_pause_unpausable_call_when_other_call_is_paused() { assert_ok!(TxPause::pause( RuntimeOrigin::signed(mock::PauseOrigin::get()), - full_name::(b"Balances", b"transfer"), + full_name::(b"Balances", b"transfer_allow_death"), )); assert_ok!(call_transfer_keep_alive(3, 1).dispatch(RuntimeOrigin::signed(3))); @@ -180,13 +180,13 @@ fn fails_to_pause_already_paused_pallet() { new_test_ext().execute_with(|| { assert_ok!(TxPause::pause( RuntimeOrigin::signed(mock::PauseOrigin::get()), - full_name::(b"Balances", b"transfer"), + full_name::(b"Balances", b"transfer_allow_death"), )); assert_noop!( TxPause::pause( RuntimeOrigin::signed(mock::PauseOrigin::get()), - full_name::(b"Balances", b"transfer"), + full_name::(b"Balances", b"transfer_allow_death"), ), Error::::IsPaused ); From b46095ca8d670fcbff1371b1cd674aaf9908f84e Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 1 Sep 2023 15:29:11 +0200 Subject: [PATCH 5/8] add prdocs --- docs/prdoc/pr_1226.prdoc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 docs/prdoc/pr_1226.prdoc diff --git a/docs/prdoc/pr_1226.prdoc b/docs/prdoc/pr_1226.prdoc new file mode 100644 index 000000000000..5159deabbee5 --- /dev/null +++ b/docs/prdoc/pr_1226.prdoc @@ -0,0 +1,19 @@ +title: Removed deprecated `Balances::transfer` and `Balances::set_balance_deprecated` functions. + +doc: + # Ideally the audience should be `DApp Builders`, but that is not currently supported + - audience: Exchange + description: The Balances pallet's dispatchables `set_balance_deprecated` and `transfer` were deprecated in [paritytech/substrate#12951](https://github.com/paritytech/substrate/pull/12951) and have now been removed. + # Ideally these notes would go into a `api_changes` section, but that is not currently supported + notes: + - Instead `force_set_balance` and `transfer_allow_death` should be used respectively. +# Ideally, this section should be removed, but that is not currently supported +migrations: + runtime: + - pallet: pallet-balances + description: No migrations are required for this change. + +crates: + - name: pallet-balances + +host_functions: [] \ No newline at end of file From 3a8fae6b5d457d1d02148daaaed655e4f1dc0147 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 4 Sep 2023 18:19:12 +0200 Subject: [PATCH 6/8] add prdoc --- docs/prdoc/pr_1226.prdoc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/docs/prdoc/pr_1226.prdoc b/docs/prdoc/pr_1226.prdoc index 5159deabbee5..e838b3d63cdc 100644 --- a/docs/prdoc/pr_1226.prdoc +++ b/docs/prdoc/pr_1226.prdoc @@ -1,17 +1,15 @@ title: Removed deprecated `Balances::transfer` and `Balances::set_balance_deprecated` functions. doc: - # Ideally the audience should be `DApp Builders`, but that is not currently supported - - audience: Exchange + - audience: Builder description: The Balances pallet's dispatchables `set_balance_deprecated` and `transfer` were deprecated in [paritytech/substrate#12951](https://github.com/paritytech/substrate/pull/12951) and have now been removed. - # Ideally these notes would go into a `api_changes` section, but that is not currently supported - notes: - - Instead `force_set_balance` and `transfer_allow_death` should be used respectively. -# Ideally, this section should be removed, but that is not currently supported + notes: + - Use `set_balance_deprecated` instead `force_set_balance` and `transfer_allow_death` instead of `transfer`. + migrations: - runtime: - - pallet: pallet-balances - description: No migrations are required for this change. + db: [] + + runtime: [] crates: - name: pallet-balances From 498d08684915d9feddf5c5688ea2e2a94d994192 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 5 Sep 2023 18:45:00 -0400 Subject: [PATCH 7/8] Update docs/prdoc/pr_1226.prdoc Co-authored-by: Chevdor --- docs/prdoc/pr_1226.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/prdoc/pr_1226.prdoc b/docs/prdoc/pr_1226.prdoc index e838b3d63cdc..df7a425b5384 100644 --- a/docs/prdoc/pr_1226.prdoc +++ b/docs/prdoc/pr_1226.prdoc @@ -14,4 +14,4 @@ migrations: crates: - name: pallet-balances -host_functions: [] \ No newline at end of file +host_functions: [] From 72b3a0e5d3a6595d67df5c6ca45d97d7488357f8 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 6 Sep 2023 14:17:51 +0200 Subject: [PATCH 8/8] move prdoc file --- {docs/prdoc => prdoc}/pr_1226.prdoc | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {docs/prdoc => prdoc}/pr_1226.prdoc (100%) diff --git a/docs/prdoc/pr_1226.prdoc b/prdoc/pr_1226.prdoc similarity index 100% rename from docs/prdoc/pr_1226.prdoc rename to prdoc/pr_1226.prdoc