@@ -200,6 +200,10 @@ pub trait Subtrait<I: Instance = DefaultInstance>: frame_system::Trait {
200200
201201 /// Weight information for the extrinsics in this pallet.
202202 type WeightInfo : WeightInfo ;
203+
204+ /// The maximum number of locks that should exist on an account.
205+ /// Not strictly enforced, but used for weight estimation.
206+ type MaxLocks : Get < u32 > ;
203207}
204208
205209pub trait Trait < I : Instance = DefaultInstance > : frame_system:: Trait {
@@ -221,13 +225,18 @@ pub trait Trait<I: Instance = DefaultInstance>: frame_system::Trait {
221225
222226 /// Weight information for extrinsics in this pallet.
223227 type WeightInfo : WeightInfo ;
228+
229+ /// The maximum number of locks that should exist on an account.
230+ /// Not strictly enforced, but used for weight estimation.
231+ type MaxLocks : Get < u32 > ;
224232}
225233
226234impl < T : Trait < I > , I : Instance > Subtrait < I > for T {
227235 type Balance = T :: Balance ;
228236 type ExistentialDeposit = T :: ExistentialDeposit ;
229237 type AccountStore = T :: AccountStore ;
230238 type WeightInfo = <T as Trait < I > >:: WeightInfo ;
239+ type MaxLocks = T :: MaxLocks ;
231240}
232241
233242decl_event ! (
@@ -663,6 +672,12 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
663672
664673 /// Update the account entry for `who`, given the locks.
665674 fn update_locks ( who : & T :: AccountId , locks : & [ BalanceLock < T :: Balance > ] ) {
675+ if locks. len ( ) as u32 > T :: MaxLocks :: get ( ) {
676+ frame_support:: debug:: warn!(
677+ "Warning: A user has more currency locks than expected. \
678+ A runtime configuration adjustment may be needed."
679+ ) ;
680+ }
666681 Self :: mutate_account ( who, |b| {
667682 b. misc_frozen = Zero :: zero ( ) ;
668683 b. fee_frozen = Zero :: zero ( ) ;
@@ -900,6 +915,7 @@ impl<T: Subtrait<I>, I: Instance> Trait<I> for ElevatedTrait<T, I> {
900915 type ExistentialDeposit = T :: ExistentialDeposit ;
901916 type AccountStore = T :: AccountStore ;
902917 type WeightInfo = <T as Subtrait < I > >:: WeightInfo ;
918+ type MaxLocks = T :: MaxLocks ;
903919}
904920
905921impl < T : Trait < I > , I : Instance > Currency < T :: AccountId > for Module < T , I > where
@@ -1285,6 +1301,8 @@ where
12851301{
12861302 type Moment = T :: BlockNumber ;
12871303
1304+ type MaxLocks = T :: MaxLocks ;
1305+
12881306 // Set a lock on the balance of `who`.
12891307 // Is a no-op if lock amount is zero or `reasons` `is_none()`.
12901308 fn set_lock (
0 commit comments