Multiple Accounts for ModuleAccount #9131
Replies: 20 comments 4 replies
-
@alexanderbez @fedekunze @alessio What do you guys think I should do to get around this? |
Beta Was this translation helpful? Give feedback.
-
Thanks for raising these concerns @colin-axner as they're definitely valid. We should certainly go forward with an ideal solution and not a short-term temporary one just to wrap up coinswap. That being said, I think it's OK if the proposed solution involves further restructuring and design/implementation. I like the idea of sub-module-accounts -- it seems to lend itself nicely to the existing implementation and use of permissions. Also, we can even hook in a governance proposal handler to provide the ability to permission/add new sub-accounts (fungible pairs)! Although wrt to your centralized exchange example, I don't see why we'd need to use a module account with sub-accounts for each user -- seems overkill. For something like Coinswap, it certainly makes sense to have a single parent/master module account with sub-accounts for each liquid fungible pair.
|
Beta Was this translation helpful? Give feedback.
-
Proposal
ModuleMultiAccount maintains an array of SubAccounts
SubAccount
Other Changes
|
Beta Was this translation helpful? Give feedback.
-
Alternatively these can go in |
Beta Was this translation helpful? Give feedback.
-
So my understanding is that each SubAccount has permissions: Also, if this gets implemented in |
Beta Was this translation helpful? Give feedback.
-
Are sub-account permission somehow restricted by the parent account's permissions set? |
Beta Was this translation helpful? Give feedback.
-
I think sub-account and parent permissions should not inherit permissions in either direction, i.e. parent and sub-account permissions should be explicitly set for both, they may overlap but I don't think there should be an enforced restriction such as sub-account inheriting parent permissions or parents having all sub-account permissions. I agree @alessio, this is definitely a discussion that should be well thought out |
Beta Was this translation helpful? Give feedback.
-
Questions (this will have to be spec'ed out before implementation):
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Maybe it makes more sense to just give MultiAcc full permissions, since it would be the account that creates the subaccs? Then the subacc perms just need to be a subset of parent permissions. Will try to open ADR/Spec for this soon, so comments can be moved to a draft pr. |
Beta Was this translation helpful? Give feedback.
-
@colin-axner I think a big point of confusion will come from implementation of what is outlined in this issue and that of the subkey implement bharvest and regen are working on. Would you mind updating the spec/details here please? Namely, I'd want to be assured that |
Beta Was this translation helpful? Give feedback.
-
@alexanderbez sorry for the confusion. Updated this issue and #4732 . Proposed changes should not touch |
Beta Was this translation helpful? Give feedback.
-
Perfect! I reviewed it; exactly what I had in mind 🌮 |
Beta Was this translation helpful? Give feedback.
-
This proposal would be perfect for a use case I have that is currently solved with a custom account type handled by a module. That approach isn’t as nice as these sub account though with respect to permissions, iterators/grouping, etc. Hopefully this approach can also allow the subaccounts to be selectively blacklisted (see #5371). |
Beta Was this translation helpful? Give feedback.
-
We can slate this for 0.41 |
Beta Was this translation helpful? Give feedback.
-
Module sub-account addresses are being addressed in ADR 028 and their usage in ADR 033. Some of this will be tackled as part of the larger refactor outlined in #7091 and #7093 . |
Beta Was this translation helpful? Give feedback.
-
Once this feature is completed, IBC transfer module will likely need to integrate these changes. It will help us fully solve #7737 |
Beta Was this translation helpful? Give feedback.
-
How soon is this needed @colin-axner ? For now can you just generate addresses based on ADR 028? I have a proof of concept of #7459 but it will take a bit of time to get it fully ready. |
Beta Was this translation helpful? Give feedback.
-
@aaronc Sorry, didn't mean to imply we needed this immediately. Just once this feature is included, we will want to migrate to it. Just read ADR 028, that will definitely work for now, thanks! |
Beta Was this translation helpful? Give feedback.
-
This has been implemented in ADR-28. |
Beta Was this translation helpful? Give feedback.
-
Summary
Creation of a
ModuleAccount
allows for no distinction between fungible coins. Some mechanism for separating balances could be very useful.Problem Definition
I will outline this issue specifically in relation to the coinswap #4644 implementation.
The coinswap module needs to use a
ModuleAccount
to hold liquidity for the exchange. However each trading pair's liquidity needs to be differentiated from the other trading pairs.ModuleAccount
does not separate fungible coins so an external mapping using store would need to be added to track the balance of each trading pair. This is the less ideal fix since it causes extra implementation on the application developers side that could increase the likely hood of supply tracking bugs.Proposal
One solution is to add subaccounts. This would allow for an address to maintain multiple accounts in order to isolate balances. For example, a centralized exchange could have one address and subaccounts for each user. I think this is a very interesting solution and would allow for a lot more features when paired with permissions. The downside is it may take a while to implement and would probably restructure the code a bit.
Another solution is to allow for dynamic creation of module accounts rather than just at the initialization of the supply keeper. I think this is a far less ideal solution and probably undermines the original intent of the supply module.
Thoughts? Would love feedback on this. Please let me know if I should move forward with adding an extra mapping to track balances if no other solution is suitable
For Admin Use
Beta Was this translation helpful? Give feedback.
All reactions