From 9950554e802e508efe462b00fab3a23f074374de Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 1 Nov 2023 14:44:38 +0100 Subject: [PATCH 01/10] Add regression test Signed-off-by: Oliver Tale-Yazdi --- .../balances/src/tests/currency_tests.rs | 55 ++++++++++++++++--- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/substrate/frame/balances/src/tests/currency_tests.rs b/substrate/frame/balances/src/tests/currency_tests.rs index 200df9ae743c..fcadb5341138 100644 --- a/substrate/frame/balances/src/tests/currency_tests.rs +++ b/substrate/frame/balances/src/tests/currency_tests.rs @@ -18,14 +18,18 @@ //! Tests regarding the functionality of the `Currency` trait set implementations. use super::*; -use crate::NegativeImbalance; -use frame_support::traits::{ - BalanceStatus::{Free, Reserved}, - Currency, - ExistenceRequirement::{self, AllowDeath, KeepAlive}, - Hooks, LockIdentifier, LockableCurrency, NamedReservableCurrency, ReservableCurrency, - WithdrawReasons, +use crate::{Event, NegativeImbalance}; +use frame_support::{ + traits::{ + BalanceStatus::{Free, Reserved}, + Currency, + ExistenceRequirement::{self, AllowDeath, KeepAlive}, + Hooks, LockIdentifier, LockableCurrency, NamedReservableCurrency, ReservableCurrency, + WithdrawReasons, + }, + StorageNoopGuard, }; +use frame_system::Event as SysEvent; const ID_1: LockIdentifier = *b"1 "; const ID_2: LockIdentifier = *b"2 "; @@ -1363,3 +1367,40 @@ fn freezing_and_locking_should_work() { assert_eq!(System::consumers(&1), 0); }); } + +#[test] +fn account_removal_and_total_issuance_does_update_properly() { + ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { + ExistentialDeposit::set(100); + assert_eq!(Balances::total_issuance(), 0); + let _ = Balances::deposit_creating(&1, 100); + + // The account is set up properly: + assert_eq!( + events(), + [ + Event::Deposit { who: 1, amount: 100 }.into(), + SysEvent::NewAccount { account: 1 }.into(), + Event::Endowed { account: 1, free_balance: 100 }.into(), + ] + ); + assert_eq!(Balances::free_balance(1), 100); + assert_eq!(Balances::total_issuance(), 100); + + // Transfers to self are No-OPs: + let _g = StorageNoopGuard::new(); + for i in 0..200 { + let r = Balances::transfer_allow_death(Some(1).into(), 1, i); + + if i <= 100 { + assert_ok!(r); + } else { + assert!(r.is_err()); + } + + assert!(events().is_empty()); + assert_eq!(Balances::free_balance(1), 100, "Balance unchanged by self transfer"); + assert_eq!(Balances::total_issuance(), 100, "TI unchanged by self transfers"); + } + }); +} From 6813a3f1180a055da7eec6446857097d319e4009 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 1 Nov 2023 14:44:55 +0100 Subject: [PATCH 02/10] Short-circuit fungible(s) self transfer Signed-off-by: Oliver Tale-Yazdi --- substrate/frame/support/src/traits/tokens/fungible/regular.rs | 4 ++++ .../frame/support/src/traits/tokens/fungibles/regular.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/substrate/frame/support/src/traits/tokens/fungible/regular.rs b/substrate/frame/support/src/traits/tokens/fungible/regular.rs index fe2a1f2a14a6..174be855d88a 100644 --- a/substrate/frame/support/src/traits/tokens/fungible/regular.rs +++ b/substrate/frame/support/src/traits/tokens/fungible/regular.rs @@ -311,6 +311,10 @@ pub trait Mutate: Inspect + Unbalanced { ) -> Result { let _extra = Self::can_withdraw(source, amount).into_result(preservation != Expendable)?; Self::can_deposit(dest, amount, Extant).into_result()?; + if source == dest { + return Ok(amount) + } + Self::decrease_balance(source, amount, BestEffort, preservation, Polite)?; // This should never fail as we checked `can_deposit` earlier. But we do a best-effort // anyway. diff --git a/substrate/frame/support/src/traits/tokens/fungibles/regular.rs b/substrate/frame/support/src/traits/tokens/fungibles/regular.rs index 7c39acdf4241..53a1c09c3ee3 100644 --- a/substrate/frame/support/src/traits/tokens/fungibles/regular.rs +++ b/substrate/frame/support/src/traits/tokens/fungibles/regular.rs @@ -363,6 +363,10 @@ pub trait Mutate: Inspect + Unbalanced { let _extra = Self::can_withdraw(asset.clone(), source, amount) .into_result(preservation != Expendable)?; Self::can_deposit(asset.clone(), dest, amount, Extant).into_result()?; + if source == dest { + return Ok(amount) + } + Self::decrease_balance(asset.clone(), source, amount, BestEffort, preservation, Polite)?; // This should never fail as we checked `can_deposit` earlier. But we do a best-effort // anyway. From 096ce846c42fc4af1bf61c1d9bbfb14015754a41 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 1 Nov 2023 14:45:11 +0100 Subject: [PATCH 03/10] Bound AccountId to PartialEq Signed-off-by: Oliver Tale-Yazdi --- .../support/src/traits/tokens/fungible/item_of.rs | 4 ++-- .../support/src/traits/tokens/fungible/regular.rs | 5 ++++- .../support/src/traits/tokens/fungibles/regular.rs | 5 ++++- substrate/frame/support/src/traits/tokens/pay.rs | 12 +++++++++--- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/substrate/frame/support/src/traits/tokens/fungible/item_of.rs b/substrate/frame/support/src/traits/tokens/fungible/item_of.rs index a47998eb134e..0a6069761a42 100644 --- a/substrate/frame/support/src/traits/tokens/fungible/item_of.rs +++ b/substrate/frame/support/src/traits/tokens/fungible/item_of.rs @@ -219,7 +219,7 @@ impl< impl< F: fungibles::Mutate, A: Get<>::AssetId>, - AccountId, + AccountId: PartialEq, > Mutate for ItemOf { fn mint_into(who: &AccountId, amount: Self::Balance) -> Result { @@ -256,7 +256,7 @@ impl< impl< F: fungibles::MutateHold, A: Get<>::AssetId>, - AccountId, + AccountId: PartialEq, > MutateHold for ItemOf { fn hold(reason: &Self::Reason, who: &AccountId, amount: Self::Balance) -> DispatchResult { diff --git a/substrate/frame/support/src/traits/tokens/fungible/regular.rs b/substrate/frame/support/src/traits/tokens/fungible/regular.rs index 174be855d88a..7c42e1a830b4 100644 --- a/substrate/frame/support/src/traits/tokens/fungible/regular.rs +++ b/substrate/frame/support/src/traits/tokens/fungible/regular.rs @@ -235,7 +235,10 @@ pub trait Unbalanced: Inspect { } /// Trait for providing a basic fungible asset. -pub trait Mutate: Inspect + Unbalanced { +pub trait Mutate: Inspect + Unbalanced +where + AccountId: PartialEq, +{ /// Increase the balance of `who` by exactly `amount`, minting new tokens. If that isn't /// possible then an `Err` is returned and nothing is changed. fn mint_into(who: &AccountId, amount: Self::Balance) -> Result { diff --git a/substrate/frame/support/src/traits/tokens/fungibles/regular.rs b/substrate/frame/support/src/traits/tokens/fungibles/regular.rs index 53a1c09c3ee3..8217d30f780d 100644 --- a/substrate/frame/support/src/traits/tokens/fungibles/regular.rs +++ b/substrate/frame/support/src/traits/tokens/fungibles/regular.rs @@ -250,7 +250,10 @@ pub trait Unbalanced: Inspect { } /// Trait for providing a basic fungible asset. -pub trait Mutate: Inspect + Unbalanced { +pub trait Mutate: Inspect + Unbalanced +where + AccountId: PartialEq, +{ /// Increase the balance of `who` by exactly `amount`, minting new tokens. If that isn't /// possible then an `Err` is returned and nothing is changed. fn mint_into( diff --git a/substrate/frame/support/src/traits/tokens/pay.rs b/substrate/frame/support/src/traits/tokens/pay.rs index 18af7e5e5483..ddf388ae9fd1 100644 --- a/substrate/frame/support/src/traits/tokens/pay.rs +++ b/substrate/frame/support/src/traits/tokens/pay.rs @@ -82,8 +82,13 @@ pub enum PaymentStatus { } /// Simple implementation of `Pay` which makes a payment from a "pot" - i.e. a single account. -pub struct PayFromAccount(sp_std::marker::PhantomData<(F, A)>); -impl> Pay for PayFromAccount { +pub struct PayFromAccount(core::marker::PhantomData<(F, A)>); +impl Pay for PayFromAccount +where + A: TypedGet, + F: fungible::Mutate, + A::Type: PartialEq, +{ type Balance = F::Balance; type Beneficiary = A::Type; type AssetKind = (); @@ -110,11 +115,12 @@ impl> Pay for PayFromAccount { /// Simple implementation of `Pay` for assets which makes a payment from a "pot" - i.e. a single /// account. -pub struct PayAssetFromAccount(sp_std::marker::PhantomData<(F, A)>); +pub struct PayAssetFromAccount(core::marker::PhantomData<(F, A)>); impl frame_support::traits::tokens::Pay for PayAssetFromAccount where A: TypedGet, F: fungibles::Mutate + fungibles::Create, + A::Type: PartialEq, { type Balance = F::Balance; type Beneficiary = A::Type; From 5d1831cd46ff689dcf1df74461abf8c4d88ff05c Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 1 Nov 2023 14:53:04 +0100 Subject: [PATCH 04/10] Remove double setting ED Signed-off-by: Oliver Tale-Yazdi --- substrate/frame/balances/src/tests/currency_tests.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/substrate/frame/balances/src/tests/currency_tests.rs b/substrate/frame/balances/src/tests/currency_tests.rs index fcadb5341138..46a4c4caefc3 100644 --- a/substrate/frame/balances/src/tests/currency_tests.rs +++ b/substrate/frame/balances/src/tests/currency_tests.rs @@ -1369,9 +1369,8 @@ fn freezing_and_locking_should_work() { } #[test] -fn account_removal_and_total_issuance_does_update_properly() { +fn self_transfer_noop() { ExtBuilder::default().existential_deposit(100).build_and_execute_with(|| { - ExistentialDeposit::set(100); assert_eq!(Balances::total_issuance(), 0); let _ = Balances::deposit_creating(&1, 100); From 6a0886e92e1ad126ad1c40ad800c0434891b938d Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 1 Nov 2023 15:01:00 +0100 Subject: [PATCH 05/10] Add docs Signed-off-by: Oliver Tale-Yazdi --- substrate/frame/support/src/traits/tokens/fungible/regular.rs | 3 +++ substrate/frame/support/src/traits/tokens/fungibles/regular.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/substrate/frame/support/src/traits/tokens/fungible/regular.rs b/substrate/frame/support/src/traits/tokens/fungible/regular.rs index 7c42e1a830b4..0476b354c718 100644 --- a/substrate/frame/support/src/traits/tokens/fungible/regular.rs +++ b/substrate/frame/support/src/traits/tokens/fungible/regular.rs @@ -306,6 +306,9 @@ where } /// Transfer funds from one account into another. + /// + /// A transfer where the source and destination account are identical is treated as No-OP after + /// checking the preconditions. fn transfer( source: &AccountId, dest: &AccountId, diff --git a/substrate/frame/support/src/traits/tokens/fungibles/regular.rs b/substrate/frame/support/src/traits/tokens/fungibles/regular.rs index 8217d30f780d..30cac616cc0b 100644 --- a/substrate/frame/support/src/traits/tokens/fungibles/regular.rs +++ b/substrate/frame/support/src/traits/tokens/fungibles/regular.rs @@ -356,6 +356,9 @@ where } /// Transfer funds from one account into another. + /// + /// A transfer where the source and destination account are identical is treated as No-OP after + /// checking the preconditions. fn transfer( asset: Self::AssetId, source: &AccountId, From 2000a60c8fbc2f92f747f6ee3023de1bbe0ae580 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 1 Nov 2023 15:16:49 +0100 Subject: [PATCH 06/10] Add where bound everywhere Signed-off-by: Oliver Tale-Yazdi --- bridges/modules/relayers/src/stake_adapter.rs | 2 +- bridges/primitives/relayers/src/lib.rs | 4 ++-- cumulus/primitives/utility/src/lib.rs | 6 +++--- polkadot/xcm/xcm-builder/src/fungibles_adapter.rs | 12 ++++++++---- substrate/frame/nis/src/lib.rs | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/bridges/modules/relayers/src/stake_adapter.rs b/bridges/modules/relayers/src/stake_adapter.rs index 88af9b1877bf..ddbe4b921493 100644 --- a/bridges/modules/relayers/src/stake_adapter.rs +++ b/bridges/modules/relayers/src/stake_adapter.rs @@ -36,7 +36,7 @@ impl StakeAndSlash for StakeAndSlashNamed where - AccountId: Codec + Debug, + AccountId: Codec + Debug + PartialEq, Currency: NamedReservableCurrency, ReserveId: Get, Stake: Get, diff --git a/bridges/primitives/relayers/src/lib.rs b/bridges/primitives/relayers/src/lib.rs index c529eea536d7..d84e299ae701 100644 --- a/bridges/primitives/relayers/src/lib.rs +++ b/bridges/primitives/relayers/src/lib.rs @@ -104,7 +104,7 @@ pub struct PayRewardFromAccount(PhantomData<(T, Relayer)>); impl PayRewardFromAccount where - Relayer: Decode + Encode, + Relayer: Decode + Encode + PartialEq, { /// Return account that pays rewards based on the provided parameters. pub fn rewards_account(params: RewardsAccountParams) -> Relayer { @@ -115,7 +115,7 @@ where impl PaymentProcedure for PayRewardFromAccount where T: frame_support::traits::fungible::Mutate, - Relayer: Decode + Encode, + Relayer: Decode + Encode + PartialEq, { type Error = sp_runtime::DispatchError; diff --git a/cumulus/primitives/utility/src/lib.rs b/cumulus/primitives/utility/src/lib.rs index c4ce67194855..740a169249e4 100644 --- a/cumulus/primitives/utility/src/lib.rs +++ b/cumulus/primitives/utility/src/lib.rs @@ -102,7 +102,7 @@ struct AssetTraderRefunder { /// Important: Errors if the Trader is being called twice by 2 BuyExecution instructions /// Alternatively we could just return payment in the aforementioned case pub struct TakeFirstAssetTrader< - AccountId, + AccountId: PartialEq, FeeCharger: ChargeWeightInFungibles, Matcher: MatchesFungibles, ConcreteAssets: fungibles::Mutate + fungibles::Balanced, @@ -112,7 +112,7 @@ pub struct TakeFirstAssetTrader< PhantomData<(AccountId, FeeCharger, Matcher, ConcreteAssets, HandleRefund)>, ); impl< - AccountId, + AccountId: PartialEq, FeeCharger: ChargeWeightInFungibles, Matcher: MatchesFungibles, ConcreteAssets: fungibles::Mutate + fungibles::Balanced, @@ -241,7 +241,7 @@ impl< } impl< - AccountId, + AccountId: PartialEq, FeeCharger: ChargeWeightInFungibles, Matcher: MatchesFungibles, ConcreteAssets: fungibles::Mutate + fungibles::Balanced, diff --git a/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs b/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs index b2802c908092..605d33c96cb8 100644 --- a/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs @@ -34,7 +34,8 @@ impl< Assets: fungibles::Mutate, Matcher: MatchesFungibles, AccountIdConverter: ConvertLocation, - AccountId: Clone, // can't get away without it since Currency is generic over it. + AccountId: PartialEq + Clone, /* can't get away without it since Currency is generic + * over it. */ > TransactAsset for FungiblesTransferAdapter { fn internal_transfer_asset( @@ -150,7 +151,8 @@ impl< Assets: fungibles::Mutate, Matcher: MatchesFungibles, AccountIdConverter: ConvertLocation, - AccountId: Clone, // can't get away without it since Currency is generic over it. + AccountId: PartialEq + Clone, /* can't get away without it since Currency is generic + * over it. */ CheckAsset: AssetChecking, CheckingAccount: Get, > @@ -185,7 +187,8 @@ impl< Assets: fungibles::Mutate, Matcher: MatchesFungibles, AccountIdConverter: ConvertLocation, - AccountId: Clone, // can't get away without it since Currency is generic over it. + AccountId: PartialEq + Clone, /* can't get away without it since Currency is generic + * over it. */ CheckAsset: AssetChecking, CheckingAccount: Get, > TransactAsset @@ -325,7 +328,8 @@ impl< Assets: fungibles::Mutate, Matcher: MatchesFungibles, AccountIdConverter: ConvertLocation, - AccountId: Clone, // can't get away without it since Currency is generic over it. + AccountId: PartialEq + Clone, /* can't get away without it since Currency is generic + * over it. */ CheckAsset: AssetChecking, CheckingAccount: Get, > TransactAsset diff --git a/substrate/frame/nis/src/lib.rs b/substrate/frame/nis/src/lib.rs index decebbd56762..32b7f132ca60 100644 --- a/substrate/frame/nis/src/lib.rs +++ b/substrate/frame/nis/src/lib.rs @@ -148,7 +148,7 @@ impl fungible::Unbalanced for NoCounterpart { } fn set_total_issuance(_: Self::Balance) {} } -impl FunMutate for NoCounterpart {} +impl FunMutate for NoCounterpart {} impl Convert for NoCounterpart { fn convert(_: Perquintill) -> u32 { 0 From efb287565bede1a900c6171379a6595b90a958be Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 1 Nov 2023 15:34:42 +0100 Subject: [PATCH 07/10] One more bound Signed-off-by: Oliver Tale-Yazdi --- substrate/frame/broker/src/test_fungibles.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/broker/src/test_fungibles.rs b/substrate/frame/broker/src/test_fungibles.rs index f6ac5a49dedd..dd4d28d6f0b7 100644 --- a/substrate/frame/broker/src/test_fungibles.rs +++ b/substrate/frame/broker/src/test_fungibles.rs @@ -168,7 +168,7 @@ where impl< Instance: Get, - AccountId: Encode, + AccountId: Encode + PartialEq, AssetId: tokens::AssetId + Copy, MinimumBalance: TypedGet, HoldReason, From eec76bbe175cb0dacfdc352f7c88d21c05183be4 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 1 Nov 2023 16:01:47 +0100 Subject: [PATCH 08/10] Use Eq instead of PartialEq Signed-off-by: Oliver Tale-Yazdi --- bridges/primitives/relayers/src/lib.rs | 2 +- cumulus/primitives/utility/src/lib.rs | 6 +++--- polkadot/xcm/xcm-builder/src/fungibles_adapter.rs | 12 ++++-------- substrate/frame/broker/src/test_fungibles.rs | 2 +- substrate/frame/nis/src/lib.rs | 2 +- .../support/src/traits/tokens/fungible/item_of.rs | 2 +- .../support/src/traits/tokens/fungible/regular.rs | 2 +- .../support/src/traits/tokens/fungibles/regular.rs | 2 +- substrate/frame/support/src/traits/tokens/pay.rs | 4 ++-- 9 files changed, 15 insertions(+), 19 deletions(-) diff --git a/bridges/primitives/relayers/src/lib.rs b/bridges/primitives/relayers/src/lib.rs index d84e299ae701..e6d306729085 100644 --- a/bridges/primitives/relayers/src/lib.rs +++ b/bridges/primitives/relayers/src/lib.rs @@ -115,7 +115,7 @@ where impl PaymentProcedure for PayRewardFromAccount where T: frame_support::traits::fungible::Mutate, - Relayer: Decode + Encode + PartialEq, + Relayer: Decode + Encode + Eq, { type Error = sp_runtime::DispatchError; diff --git a/cumulus/primitives/utility/src/lib.rs b/cumulus/primitives/utility/src/lib.rs index 740a169249e4..03f827d7ee2f 100644 --- a/cumulus/primitives/utility/src/lib.rs +++ b/cumulus/primitives/utility/src/lib.rs @@ -102,7 +102,7 @@ struct AssetTraderRefunder { /// Important: Errors if the Trader is being called twice by 2 BuyExecution instructions /// Alternatively we could just return payment in the aforementioned case pub struct TakeFirstAssetTrader< - AccountId: PartialEq, + AccountId: Eq, FeeCharger: ChargeWeightInFungibles, Matcher: MatchesFungibles, ConcreteAssets: fungibles::Mutate + fungibles::Balanced, @@ -112,7 +112,7 @@ pub struct TakeFirstAssetTrader< PhantomData<(AccountId, FeeCharger, Matcher, ConcreteAssets, HandleRefund)>, ); impl< - AccountId: PartialEq, + AccountId: Eq, FeeCharger: ChargeWeightInFungibles, Matcher: MatchesFungibles, ConcreteAssets: fungibles::Mutate + fungibles::Balanced, @@ -241,7 +241,7 @@ impl< } impl< - AccountId: PartialEq, + AccountId: Eq, FeeCharger: ChargeWeightInFungibles, Matcher: MatchesFungibles, ConcreteAssets: fungibles::Mutate + fungibles::Balanced, diff --git a/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs b/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs index 605d33c96cb8..63ce608824eb 100644 --- a/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs @@ -34,8 +34,7 @@ impl< Assets: fungibles::Mutate, Matcher: MatchesFungibles, AccountIdConverter: ConvertLocation, - AccountId: PartialEq + Clone, /* can't get away without it since Currency is generic - * over it. */ + AccountId: Eq + Clone, /* can't get away without it since Currency is generic over it. */ > TransactAsset for FungiblesTransferAdapter { fn internal_transfer_asset( @@ -151,8 +150,7 @@ impl< Assets: fungibles::Mutate, Matcher: MatchesFungibles, AccountIdConverter: ConvertLocation, - AccountId: PartialEq + Clone, /* can't get away without it since Currency is generic - * over it. */ + AccountId: Eq + Clone, /* can't get away without it since Currency is generic over it. */ CheckAsset: AssetChecking, CheckingAccount: Get, > @@ -187,8 +185,7 @@ impl< Assets: fungibles::Mutate, Matcher: MatchesFungibles, AccountIdConverter: ConvertLocation, - AccountId: PartialEq + Clone, /* can't get away without it since Currency is generic - * over it. */ + AccountId: Eq + Clone, /* can't get away without it since Currency is generic over it. */ CheckAsset: AssetChecking, CheckingAccount: Get, > TransactAsset @@ -328,8 +325,7 @@ impl< Assets: fungibles::Mutate, Matcher: MatchesFungibles, AccountIdConverter: ConvertLocation, - AccountId: PartialEq + Clone, /* can't get away without it since Currency is generic - * over it. */ + AccountId: Eq + Clone, /* can't get away without it since Currency is generic over it. */ CheckAsset: AssetChecking, CheckingAccount: Get, > TransactAsset diff --git a/substrate/frame/broker/src/test_fungibles.rs b/substrate/frame/broker/src/test_fungibles.rs index dd4d28d6f0b7..d18bff149533 100644 --- a/substrate/frame/broker/src/test_fungibles.rs +++ b/substrate/frame/broker/src/test_fungibles.rs @@ -168,7 +168,7 @@ where impl< Instance: Get, - AccountId: Encode + PartialEq, + AccountId: Encode + Eq, AssetId: tokens::AssetId + Copy, MinimumBalance: TypedGet, HoldReason, diff --git a/substrate/frame/nis/src/lib.rs b/substrate/frame/nis/src/lib.rs index 32b7f132ca60..5e547b63e547 100644 --- a/substrate/frame/nis/src/lib.rs +++ b/substrate/frame/nis/src/lib.rs @@ -148,7 +148,7 @@ impl fungible::Unbalanced for NoCounterpart { } fn set_total_issuance(_: Self::Balance) {} } -impl FunMutate for NoCounterpart {} +impl FunMutate for NoCounterpart {} impl Convert for NoCounterpart { fn convert(_: Perquintill) -> u32 { 0 diff --git a/substrate/frame/support/src/traits/tokens/fungible/item_of.rs b/substrate/frame/support/src/traits/tokens/fungible/item_of.rs index 0a6069761a42..4933acc7e10e 100644 --- a/substrate/frame/support/src/traits/tokens/fungible/item_of.rs +++ b/substrate/frame/support/src/traits/tokens/fungible/item_of.rs @@ -219,7 +219,7 @@ impl< impl< F: fungibles::Mutate, A: Get<>::AssetId>, - AccountId: PartialEq, + AccountId: Eq, > Mutate for ItemOf { fn mint_into(who: &AccountId, amount: Self::Balance) -> Result { diff --git a/substrate/frame/support/src/traits/tokens/fungible/regular.rs b/substrate/frame/support/src/traits/tokens/fungible/regular.rs index 0476b354c718..f2fb5c5f7c24 100644 --- a/substrate/frame/support/src/traits/tokens/fungible/regular.rs +++ b/substrate/frame/support/src/traits/tokens/fungible/regular.rs @@ -237,7 +237,7 @@ pub trait Unbalanced: Inspect { /// Trait for providing a basic fungible asset. pub trait Mutate: Inspect + Unbalanced where - AccountId: PartialEq, + AccountId: Eq, { /// Increase the balance of `who` by exactly `amount`, minting new tokens. If that isn't /// possible then an `Err` is returned and nothing is changed. diff --git a/substrate/frame/support/src/traits/tokens/fungibles/regular.rs b/substrate/frame/support/src/traits/tokens/fungibles/regular.rs index 30cac616cc0b..a2fc4e550952 100644 --- a/substrate/frame/support/src/traits/tokens/fungibles/regular.rs +++ b/substrate/frame/support/src/traits/tokens/fungibles/regular.rs @@ -252,7 +252,7 @@ pub trait Unbalanced: Inspect { /// Trait for providing a basic fungible asset. pub trait Mutate: Inspect + Unbalanced where - AccountId: PartialEq, + AccountId: Eq, { /// Increase the balance of `who` by exactly `amount`, minting new tokens. If that isn't /// possible then an `Err` is returned and nothing is changed. diff --git a/substrate/frame/support/src/traits/tokens/pay.rs b/substrate/frame/support/src/traits/tokens/pay.rs index ddf388ae9fd1..4d1d80b5b507 100644 --- a/substrate/frame/support/src/traits/tokens/pay.rs +++ b/substrate/frame/support/src/traits/tokens/pay.rs @@ -87,7 +87,7 @@ impl Pay for PayFromAccount where A: TypedGet, F: fungible::Mutate, - A::Type: PartialEq, + A::Type: Eq, { type Balance = F::Balance; type Beneficiary = A::Type; @@ -120,7 +120,7 @@ impl frame_support::traits::tokens::Pay for PayAssetFromAccount where A: TypedGet, F: fungibles::Mutate + fungibles::Create, - A::Type: PartialEq, + A::Type: Eq, { type Balance = F::Balance; type Beneficiary = A::Type; From c5f9fc471aa03359dbba681ca3e6788b221b49df Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 1 Nov 2023 19:06:11 +0100 Subject: [PATCH 09/10] Remove unneeded bounds Signed-off-by: Oliver Tale-Yazdi --- bridges/modules/relayers/src/stake_adapter.rs | 2 +- bridges/primitives/relayers/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bridges/modules/relayers/src/stake_adapter.rs b/bridges/modules/relayers/src/stake_adapter.rs index ddbe4b921493..88af9b1877bf 100644 --- a/bridges/modules/relayers/src/stake_adapter.rs +++ b/bridges/modules/relayers/src/stake_adapter.rs @@ -36,7 +36,7 @@ impl StakeAndSlash for StakeAndSlashNamed where - AccountId: Codec + Debug + PartialEq, + AccountId: Codec + Debug, Currency: NamedReservableCurrency, ReserveId: Get, Stake: Get, diff --git a/bridges/primitives/relayers/src/lib.rs b/bridges/primitives/relayers/src/lib.rs index e6d306729085..c808c437b54c 100644 --- a/bridges/primitives/relayers/src/lib.rs +++ b/bridges/primitives/relayers/src/lib.rs @@ -104,7 +104,7 @@ pub struct PayRewardFromAccount(PhantomData<(T, Relayer)>); impl PayRewardFromAccount where - Relayer: Decode + Encode + PartialEq, + Relayer: Decode + Encode, { /// Return account that pays rewards based on the provided parameters. pub fn rewards_account(params: RewardsAccountParams) -> Relayer { From 3030e1872524ad9c18685d288a918bcd2189b046 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 1 Nov 2023 19:14:20 +0100 Subject: [PATCH 10/10] Remove one more Signed-off-by: Oliver Tale-Yazdi --- substrate/frame/support/src/traits/tokens/fungible/item_of.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/support/src/traits/tokens/fungible/item_of.rs b/substrate/frame/support/src/traits/tokens/fungible/item_of.rs index 4933acc7e10e..636866ab93c9 100644 --- a/substrate/frame/support/src/traits/tokens/fungible/item_of.rs +++ b/substrate/frame/support/src/traits/tokens/fungible/item_of.rs @@ -256,7 +256,7 @@ impl< impl< F: fungibles::MutateHold, A: Get<>::AssetId>, - AccountId: PartialEq, + AccountId, > MutateHold for ItemOf { fn hold(reason: &Self::Reason, who: &AccountId, amount: Self::Balance) -> DispatchResult {