mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
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>
106 lines
3.1 KiB
C++
106 lines
3.1 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of rippled: https://github.com/ripple/rippled
|
|
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
//==============================================================================
|
|
|
|
#include <ripple/protocol/InnerObjectFormats.h>
|
|
|
|
namespace ripple {
|
|
|
|
InnerObjectFormats::InnerObjectFormats()
|
|
{
|
|
add(sfSignerEntry.jsonName.c_str(),
|
|
sfSignerEntry.getCode(),
|
|
{
|
|
{sfAccount, soeREQUIRED},
|
|
{sfSignerWeight, soeREQUIRED},
|
|
{sfWalletLocator, soeOPTIONAL},
|
|
});
|
|
|
|
add(sfSigner.jsonName.c_str(),
|
|
sfSigner.getCode(),
|
|
{
|
|
{sfAccount, soeREQUIRED},
|
|
{sfSigningPubKey, soeREQUIRED},
|
|
{sfTxnSignature, soeREQUIRED},
|
|
});
|
|
|
|
add(sfMajority.jsonName.c_str(),
|
|
sfMajority.getCode(),
|
|
{
|
|
{sfAmendment, soeREQUIRED},
|
|
{sfCloseTime, soeREQUIRED},
|
|
});
|
|
|
|
add(sfDisabledValidator.jsonName.c_str(),
|
|
sfDisabledValidator.getCode(),
|
|
{
|
|
{sfPublicKey, soeREQUIRED},
|
|
{sfFirstLedgerSequence, soeREQUIRED},
|
|
});
|
|
|
|
add(sfNFToken.jsonName.c_str(),
|
|
sfNFToken.getCode(),
|
|
{
|
|
{sfNFTokenID, soeREQUIRED},
|
|
{sfURI, soeOPTIONAL},
|
|
});
|
|
|
|
add(sfVoteEntry.jsonName.c_str(),
|
|
sfVoteEntry.getCode(),
|
|
{
|
|
{sfAccount, soeREQUIRED},
|
|
{sfTradingFee, soeDEFAULT},
|
|
{sfVoteWeight, soeREQUIRED},
|
|
});
|
|
|
|
add(sfAuctionSlot.jsonName.c_str(),
|
|
sfAuctionSlot.getCode(),
|
|
{
|
|
{sfAccount, soeREQUIRED},
|
|
{sfExpiration, soeREQUIRED},
|
|
{sfDiscountedFee, soeDEFAULT},
|
|
{sfPrice, soeREQUIRED},
|
|
{sfAuthAccounts, soeOPTIONAL},
|
|
});
|
|
|
|
add(sfAuthAccount.jsonName.c_str(),
|
|
sfAuthAccount.getCode(),
|
|
{
|
|
{sfAccount, soeREQUIRED},
|
|
});
|
|
}
|
|
|
|
InnerObjectFormats const&
|
|
InnerObjectFormats::getInstance()
|
|
{
|
|
static InnerObjectFormats instance;
|
|
return instance;
|
|
}
|
|
|
|
SOTemplate const*
|
|
InnerObjectFormats::findSOTemplateBySField(SField const& sField) const
|
|
{
|
|
auto itemPtr = findByType(sField.getCode());
|
|
if (itemPtr)
|
|
return &(itemPtr->getSOTemplate());
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
} // namespace ripple
|