Amendment Idea: Optimized Accounts and Trustlines #371
mvadari
started this conversation in
XLS Ideas (pre standard proposal)
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Originally posted by Nik Bougalis in #56 (comment) and Rome Reginelli in XRPLF/rippled#3866
Amendment Idea: Optimized Accounts and Trustlines
1. Overview
This alternative proposal makes several minor changes to the way accounts are structured and by which reserves are calculated.
Unlike XLS-23d, this proposal does not impose any limitations on an account, does not require a flag to signify that an account should be charged a reduced reserve and does not mandate complicated conversion procedures from 'lite' to 'full' accounts. Additionally, it makes it possible for accounts to to only be charged for the resources they use at any given time, which the existing proposal does not allow: once an account has been converted into a full account, it is always charged a full reserve.
These changes will require an amendment, tentatively named
EfficientObjects.1.1. Historical Background
The original intention behind the account reserve was to act as as a deterrent to the creation of new accounts with the intention of spamming the ledger, since at the time accounts could not be deleted and the entire reserve was, therefore, unrecoverable.
Accounts are now deletable, and users can retrieve most of their account reserve if they delete their account (0.8 out of 1 XRP).
As XLS-23d makes clear, several participants in the ecosystem have expressed concerns that the cost of creating an account represents a barrier to entry for new users and remains a major impediment to the expansion of the ecosystem. While this barrier has reduced now that reserves are only 1 XRP for an account, this is still a nontrivial amount in some parts of the world.
1.2. Background: Field Types
3 types of types: Required/Optional/Default
0value of the type) if it is not presentSTUInt32field with type "default", it is assumed to be0if it's not present. So using default fields can save a lot of space if the field often has the default value.1.3. The Current
AccountRootObjectAccounts on the XRP Ledger are stored inside
AccountRootledger object, which groups together the many fields that, together, comprise the state of an account on the XRP Ledger.Specifically, as of the time of this writing an
AccountRootconsists of the following fields:sfLedgerEntryTypeUInt16sfFlagsUInt32sfAccountAccountIDsfSequenceUInt32sfBalanceAmountsfOwnerCountUInt32sfPreviousTxnIDUInt256sfPreviousTxnLgrSeqUInt32sfAccountTxnIDUInt256sfAMMIDUInt256sfRegularKeyAccountIDsfEmailHashUInt128sfWalletLocatorUInt256sfWalletSizeUInt32sfMessageKeyBlobsfTransferRateUInt32sfDomainBlobsfTickSizeUInt8sfBurnedNFTokensUInt32sfFirstNFTokenSequenceUInt32sfMintedNFTokensUInt32sfNFTokenMinterAccountIDThus, an account with all the bells and whistles enabled may exceed 500 bytes, although most accounts will be much smaller - a minimal account is only 110 bytes.
2. On-Ledger Object:
AccountRootDefaulting Fields
This proposal recommends that modifying the definitions of the
FlagsandOwnerCountfields, changing them fromREQUIREDtoDEFAULT, which essentially makes the fieldsOPTIONALand avoids storing them if their value is0, marginally reducing the size of an account with no owner directory. Note that theFlagsfield is currently a common field; changing this could reduce the size of other object types as well, but many objects have at least one flag set.Net gains
Assuming an account with no optional fields, the size of the
AccountRootwill go down by 10 bytes, which represents a reduction of greater than 10% for a minimal account. This may not seem like a lot, but it is a measurable amount - and combined with further improvements on trust lines, this might result in significant savings.As of ledger
95079427(3/28/2025, 4:30:00 PM UTC), there were:Flagvalue of0.OwnerCountvalue of0.This change would result in 56.3 MB of savings, or about 0.8% of the total size of the ledger (which is about 6,600 MB), or about 512k accounts of minimal size.
Deprecating Fields
In the interest of reducing the possibility of account bloat and to eliminate legacy and fields which have no clear purpose, this proposals recommends that we disable support for the
WalletLocatorandWalletSizefields. Since existing accounts use these fields, they must remain part of the object, but it should not be possible to set these fields going forward and attempts to do so must fail.As of ledger
95079427(3/28/2025, 4:30:00 PM UTC), there were:WalletLocatorset.WalletSizeset.Given the small amount of objects with these fields set, no provision is made to allow them to be cleared.
3. On-Ledger Object:
RippleStateXRPLF/rippled#3866
3.1. Current State
sfLedgerEntryTypeUInt16sfFlagsUInt32sfBalanceAmountsfLowLimitAmountsfHighLimitAmountsfPreviousTxnIDUInt256sfPreviousTxnLgrSeqUInt32sfLowNodeUInt64sfHighNodeUInt64sfLowQualityInUInt32sfLowQualityOutUInt32sfHighQualityInUInt32sfHighQualityOutUInt323.1.1.
sfBalanceAlways has an issuer of
rrrrrrrrrrrrrrrrrrrrBZbvji- wasted space3.1.2.
HighLimitandLowLimitCurrency code is repeated from
Balance3.1.3.
HighNodeandLowNodeOften have values of
03.2. Proposal
sfLedgerEntryTypeUInt16sfFlagsUInt32sfBalanceAmountNumbersfCurrencyCurrencysfLowAccountAccountIDsfLowLimitAmountNumbersfHighAccountAccountIDsfHighLimitAmountNumbersfPreviousTxnIDUInt256sfPreviousTxnLgrSeqUInt32sfLowNodeUInt64sfHighNodeUInt64sfLowQualityInUInt32sfLowQualityOutUInt32sfHighQualityInUInt32sfHighQualityOutUInt323.2.1. Proposal in English
For all trustlines:
sfBalancewithsfCurrency/sfBalanceAmount, since theissueris not needed for the balancesfLowLimitwithsfLowAccount/sfLowLimitAmount, since theCurrencyis already stored abovesfHighLimitwithsfHighAccount/sfHighLimitAmount, since theCurrencyis already stored aboveFor some trustlines:
sfFlagsissoeDEFAULT, like withAccountRootsfBalanceAmountissoeDEFAULT, which saves some bytes for trustlines with 0 balancesfLowLimitAmount/sfHighLimitAmountissoeDEFAULT, which saves some bytes for unidirectional trustlines (the vast majority of themLowNodeandHighNodeare optional fields, to be omitted when their value is 0.3.3. Savings
3.3.1. Savings for All Trustlines
sfBalance->sfCurrency/sfBalanceAmount- 15 bytes savedsfLowLimit->sfLowAccount/sfLowLimitAmount-> 14 bytes savedsfHighLimit->sfHighAccount/sfHighLimitAmount-> 14 bytes savedA total of 43 bytes saved per trustline.
3.3.2. Savings for Some Trustlines
sfFlagsissoeDEFAULT- 5 bytes saved for trustlines with no flags (rare - you get this from the account savings)sfBalanceAmountissoeDEFAULT- 9 bytes saved for trustlines with 0 balancesfLowLimitAmount/sfHighLimitAmountissoeDEFAULT- 9 bytes saved for one-directional trustlines (the vast majority of them)sfLowNodeissoeDEFAULT- 9 bytes saved for most trustlinessfHighNodeissoeDEFAULT- 9 bytes saved for most trustlines3.3.3. Total Savings Based on Latest Data
As of ledger
95079166(3/28/2025, 4:13:01 PM UTC), there were:Flagsvalue of0HighNodevalue of"0"LowNodevalue of"0"0LowLimitnor theHighLimitis0)Resulting savings:
FlagsHighNodeLowNodeThe total savings would be 403 MB, or 6.1% of the whole ledger (which is about 6,600 MB). These savings would be equivalent to 3.7 million accounts of minimal size, or 3.3 million trustlines of minimal size.
Note: these savings may not translate directly to this number of accounts/trustlines, as there will likely be other side effects of having an additional 3-4 million accounts/trustlines, such as with the size of the SHAMap.
4. Transaction:
LedgerStateFixThe LedgerStateFix transaction is intended to be used for one-time fixes. It could be used for converting
AccountRoots andRippleStates from the old format to the new one, on top of lazily converting them whenever a transaction interacts with them.5. Out of Scope
This proposal avoids the topic of account sponsorship, which XLS-23 and XLS-68 discuss at length. While the topic is important, it does not need to be combined with this proposal; it should instead be discussed separately, especially since there is no way to enable "sponsorship" without actually increasing the size of the
AccountRootby at least 20 bytes (to track the sponsor).This proposal also avoids the topic of "better token standards", which XLS-33 discusses at length.
Beta Was this translation helpful? Give feedback.
All reactions