mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-31 19:10:25 +00:00
fix(AMM): prevent orphaned objects, inconsistent ledger state: (#4626)
When an AMM account is deleted, the owner directory entries must be
deleted in order to ensure consistent ledger state.
* When deleting AMM account:
* Clean up AMM owner dir, linking AMM account and AMM object
* Delete trust lines to AMM
* Disallow `CheckCreate` to AMM accounts
* AMM cannot cash a check
* Constrain entries in AuthAccounts array to be accounts
* AuthAccounts is an array of objects for the AMMBid transaction
* SetTrust (TrustSet): Allow on AMM only for LP tokens
* If the destination is an AMM account and the trust line doesn't
exist, then:
* If the asset is not the AMM LP token, then fail the tx with
`tecNO_PERMISSION`
* If the AMM is in empty state, then fail the tx with `tecAMM_EMPTY`
* This disallows trustlines to AMM in empty state
* Add AMMID to AMM root account
* Remove lsfAMM flag and use sfAMMID instead
* Remove owner dir entry for ltAMM
* Add `AMMDelete` transaction type to handle amortized deletion
* Limit number of trust lines to delete on final withdraw + AMMDelete
* Put AMM in empty state when LPTokens is 0 upon final withdraw
* Add `tfTwoAssetIfEmpty` deposit option in AMM empty state
* Fail all AMM transactions in AMM empty state except special deposit
* Add `tecINCOMPLETE` to indicate that not all AMM trust lines are
deleted (i.e. partial deletion)
* This is handled in Transactor similar to deleted offers
* Fail AMMDelete with `tecINTERNAL` if AMM root account is nullptr
* Don't validate for invalid asset pair in AMMDelete
* AMMWithdraw deletes AMM trust lines and AMM account/object only if the
number of trust lines is less than max
* Current `maxDeletableAMMTrustLines` = 512
* Check no directory left after AMM trust lines are deleted
* Enable partial trustline deletion in AMMWithdraw
* Add `tecAMM_NOT_EMPTY` to fail any transaction that expects an AMM in
empty state
* Clawback considerations
* Disallow clawback out of AMM account
* Disallow AMM create if issuer can claw back
This patch applies to the AMM implementation in #4294.
Acknowledgements:
Richard Holland and Nik Bougalis for responsibly disclosing this issue.
Bug Bounties and Responsible Disclosures:
We welcome reviews of the project code and urge researchers to
responsibly disclose any issues they may find.
To report a bug, please send a detailed report to:
bugs@xrpl.org
Signed-off-by: Manoj Doshi <mdoshi@ripple.com>
This commit is contained in:
committed by
Manoj Doshi
parent
5530a0b665
commit
58f7aecb0b
@@ -45,6 +45,9 @@ transResults()
|
||||
MAKE_ERROR(tecAMM_BALANCE, "AMM has invalid balance."),
|
||||
MAKE_ERROR(tecAMM_INVALID_TOKENS, "AMM invalid LP tokens."),
|
||||
MAKE_ERROR(tecAMM_FAILED, "AMM transaction failed."),
|
||||
MAKE_ERROR(tecAMM_EMPTY, "AMM is in empty state."),
|
||||
MAKE_ERROR(tecAMM_NOT_EMPTY, "AMM is not in empty state."),
|
||||
MAKE_ERROR(tecAMM_ACCOUNT, "This operation is not allowed on an AMM Account."),
|
||||
MAKE_ERROR(tecCLAIM, "Fee claimed. Sequence used. No action."),
|
||||
MAKE_ERROR(tecDIR_FULL, "Can not add entry to full directory."),
|
||||
MAKE_ERROR(tecFAILED_PROCESSING, "Failed to correctly process transaction."),
|
||||
@@ -92,6 +95,7 @@ transResults()
|
||||
MAKE_ERROR(tecINSUFFICIENT_FUNDS, "Not enough funds available to complete requested transaction."),
|
||||
MAKE_ERROR(tecOBJECT_NOT_FOUND, "A requested object could not be located."),
|
||||
MAKE_ERROR(tecINSUFFICIENT_PAYMENT, "The payment is not sufficient."),
|
||||
MAKE_ERROR(tecINCOMPLETE, "Some work was completed, but more submissions required to finish."),
|
||||
|
||||
MAKE_ERROR(tefALREADY, "The exact transaction was already in this ledger."),
|
||||
MAKE_ERROR(tefBAD_ADD_AUTH, "Not authorized to add account."),
|
||||
|
||||
Reference in New Issue
Block a user