-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Refactor Account Storage into Accounts Pallet #8254
Conversation
This is ready for a review on direction and design |
Some feedback when fixing errors. Since Balances pallet uses reference counters, and most pallets use Currency, I had to add the In most of these pallets, the use of reference counting was never relevant or part of the tests. I wanted to implement some dummy struct like I am also thinking to split up the reference counters into smaller traits since most pallets only use one kind of reference counters for their needs. What do you all think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the meat of this PR is all in the first 4 commits, so that's where I focused most of my energy. The rest appears to be mostly fixups to propagate the changes through the rest of the system.
I think that overall NoReferenceCounters
is a good idea to reduce the amount of dev-dependencies propagated. Let's only pay for what we're using; if we're not using the reference counting, then let's structure things such that they aren't required.
Smaller reference counter traits also seem like a good idea to me, because it's not obvious as a newcomer to the topic what the distinctions between them are.
The major reason I'm not currently approving this is that, if you do take those suggestions within this PR, then substantial work is incoming and an approval is premature. If you'd prefer to put those into new issues/PRs, then I'd be prepared to approve this once CI is happy.
@@ -238,7 +243,8 @@ impl pallet_balances::Config for Runtime { | |||
type Event = Event; | |||
type DustRemoval = (); | |||
type ExistentialDeposit = ExistentialDeposit; | |||
type AccountStore = System; | |||
type AccountStore = Accounts; | |||
type ReferencedAccount = Accounts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name suggestion: AccountReferences
?
The account abstraction in FRAME System has become increasingly complex, and does not easily allow for customizable Account storage patterns.
Here, we extract the Account Storage from FRAME System and place those items in a new pallet with a simple API.
This allows developers to crate their own account abstraction while still using FRAME System with all of the macros.
FRAME System now only requires the
BasicAccount
API to be satisfied:FRAME System provides an implementation for a basic account, where the only data about a user is their nonce.
Other pallets may need to apply and use reference counters on accounts to prevent their account deletion. This is now exposed through an extended
ReferencedAccount
API:The requirement to use
ReferencedAccount
will come from specific pallets that require this functionality, but will no longer be an assumption about all accounts in FRAME.