AI feedback

This commit is contained in:
Vito
2026-06-26 13:19:42 +02:00
parent c7ee3c2727
commit c3aae7b81d
4 changed files with 50 additions and 47 deletions

View File

@@ -132,32 +132,36 @@ checkDeepFrozen(ReadView const& view, AccountID const& account, MPTIssue const&
checkDeepFrozen(ReadView const& view, AccountID const& account, Asset const& asset);
/**
* Checks freeze compliance for withdrawing an asset from a pseudo-account
* (e.g. Vault, AMM, LoanBroker) to a destination account.
* Checks freeze compliance for withdrawing an asset from a pseudo-account (e.g. Vault, AMM,
* LoanBroker) to a destination account.
*
* Asserts that sourceAcct is a pseudo-account.
* Asserts that sourceAcct is a pseudo-account and that submitterAcct and dstAcct are not.
*
* Issuer exemption: returns tesSUCCESS immediately when dstAcct is the asset
* issuer — the issuer can always receive their own token, even when the pool
* is frozen. Callers that need to block withdrawals from a frozen pool even
* for the issuer (e.g. because the pool math cannot handle it) must check
* checkFrozen(sourceAcct, asset) separately before calling this function.
* Issuer exemption: returns tesSUCCESS immediately when dstAcct is the asset issuer — the issuer
* can always receive their own token, even when the pool is frozen. Callers that need to block
* withdrawals from a frozen pool even for the issuer (e.g. because the pool math cannot handle it)
* must check checkFrozen(sourceAcct, asset) separately before calling this function.
*
* Otherwise checks, in order:
* 1. checkFrozen(sourceAcct, asset) — the pseudo-account's trustline /
* global freeze must not block sending.
* 1a. For MPT assets: isVaultPseudoAccountFrozen(sourceAcct, asset) —
* the pseudo-account's vault share must not be transitively frozen
* via its underlying asset.
* 2. checkFrozen(submitterAcct, asset) — skipped when submitter == dst
* (self-withdrawal); a regular freeze should not prevent recovering
* one's own funds.
* 3. checkDeepFrozen(dstAcct, asset) — the destination must not be
* deep-frozen (cannot receive under any circumstance).
* 1. If the asset is globally frozen the remaining checks are redundant.
* 2. For MPT shares: The pseudo-account's vault share must not be transitively frozen via its
* underlying asset.
* 3. The pseudo-account's trustline / MPToken must not be frozen for sending.
* 4. Skipped when submitter == dst (self-withdrawal); a regular freeze should not prevent
* recovering one's own funds.
* 5. The destination must not be deep-frozen (cannot receive under any circumstance).
*
* For IOUs a regular individual freeze on the withdrawer does NOT block
* self-withdrawal; only deep freeze does. For MPTs "locked" is equivalent
* to deep-frozen, so locked MPT holders are always blocked.
* For IOUs a regular individual freeze on the withdrawer does NOT block self-withdrawal; only deep
* freeze does. For MPTs "locked" is equivalent to deep-frozen, so locked MPT holders are always
* blocked.
*
* @param view Ledger view to read freeze state from.
* @param srcAcct Pseudo-account the funds are withdrawn from (sender).
* @param submitterAcct Account that submitted the withdrawal transaction.
* @param dstAcct Account receiving the withdrawn funds.
* @param asset Asset being withdrawn.
* @return tesSUCCESS if the withdrawal is permitted, otherwise a freeze
* result (tecFROZEN for IOUs, tecLOCKED for MPTs).
*/
[[nodiscard]] TER
checkWithdrawFreeze(
@@ -168,21 +172,26 @@ checkWithdrawFreeze(
Asset const& asset);
/**
* Checks freeze compliance for depositing an asset into a pseudo-account
* (e.g. Vault, AMM, LoanBroker).
* Checks freeze compliance for depositing an asset into a pseudo-account (e.g. Vault, AMM,
* LoanBroker).
*
* Asserts that dstAcct is a pseudo-account.
*
* Checks, in order:
* 1. checkFrozen(srcAcct, asset) — the depositor must not be frozen
* (global or individual) for the asset.
* 1a. For MPT assets: isVaultPseudoAccountFrozen(dstAcct, asset) —
* the pseudo-account's vault share must not be transitively frozen
* via its underlying asset.
* 2. checkFrozen(dstAcct, asset) — the pseudo-account must not be
* frozen for the asset. Unlike regular accounts, pseudo-accounts
* cannot receive deposits under a regular freeze because the
* deposited funds could not later be withdrawn.
* 1. If the asset is globally frozen the remaining checks are redundant.
* 2. For MPT shares: the pseudo-account's vault share must not be transitively frozen via its
* underlying asset (returns tecLOCKED).
* 3. The depositor must not be individually frozen. Skipped when srcAcct is the asset issuer,
* since the issuer can always send its own asset.
* 4. The pseudo-account must not be individually frozen for the asset. Unlike regular accounts,
* pseudo-accounts cannot receive deposits under a regular freeze because the deposited funds
* could not later be withdrawn.
*
* @param view Ledger view to read freeze state from.
* @param srcAcct Depositor sending the funds.
* @param dstAcct Pseudo-account receiving the deposit.
* @param asset Asset being deposited.
* @return tesSUCCESS if the deposit is permitted, otherwise a freeze result
* (tecFROZEN for IOUs, tecLOCKED for MPTs).
*/
[[nodiscard]] TER
checkDepositFreeze(

View File

@@ -220,14 +220,10 @@ checkDepositFreeze(
!isPseudoAccount(view, srcAcct),
"xrpl::checkDepositFreeze : source is not a pseudo-account");
// An Issuer cannot deposit when:
// 1. Asset is globally frozen
// 2. The trustline/mptoken of the pseudo-account is frozen
if (auto const ret = checkGlobalFrozen(view, asset); !isTesSuccess(ret))
return ret;
// Special case for shares - check if the shares (and the transitive asset) is not frozen
// Special case for shares - check if the shares and the transitive asset is not frozen
if (asset.holds<MPTIssue>() &&
isVaultPseudoAccountFrozen(view, dstAcct, asset.get<MPTIssue>(), 0))
{

View File

@@ -96,6 +96,13 @@ testableAmendments()
return kIds;
}
/**
* Returns all 2^N permutations of a seed FeatureBitset with each subset of
* the given features excluded. The seed is included as the first element.
*
* Useful for running a test over every combination of optional amendments
* so that each case is exercised both with and without each feature.
*/
inline std::vector<FeatureBitset>
amendmentCombinations(std::initializer_list<uint256> features, FeatureBitset seed)
{

View File

@@ -54,13 +54,4 @@ fillSeq(json::Value& jv, ReadView const& view);
/** Given an xrpld unit test rpc command, return the corresponding JSON. */
json::Value
cmdToJSONRPC(std::vector<std::string> const& args, beast::Journal j, unsigned int apiVersion);
/**
* Returns all 2^N permutations of a seed FeatureBitset with each subset of
* the given features excluded. The seed is included as the first element.
*
* Useful for running a test over every combination of optional amendments
* so that each case is exercised both with and without each feature.
*/
} // namespace xrpl::test::jtx