In the trait config for LockableCurrency there's a type MaxLocks. I am writing a pallet that uses set_lock and remove_lock from this trait. Should I implement checks to see if I am not exceeding MaxLocks before calling set_lock? If yes, how should I check how many locks an account already has?

1 Answer 1


The current solution is to require the runtime-author to set MaxLocks to the number of unique LockIdentifier values in the runtime. This alleviates any need to check the number of locks since there can only ever be as many locks as identifiers as each identifier can result in at most one lock per account.

If MaxLocks is underestimated then it's likely not the end of the world; it means that the weights and PoV footprint estimations will be a little lower than they should be, but there's enough headroom in both of these that a small error shouldn't cause anything catastrophic to happen.

(This does place some effort on the part of the runtime-author and a mistake might be made. This will likely be abstracted away in the future by requiring the LockIdentifier type to be an amalgamation type similar to Origin, Event and Error but whose values are enumerable.)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.