Open jonjove opened 2 years ago
Asset issuance always occurs in TrustLineWrapper::IssuerImpl, so this class must be modified to properly maintain AmountIssuedEntry.
Besides asset issuance, asset clawback operation also changes the outstanding amount, and it is a NonIssuerImpl
op?
Asset issuance always occurs in TrustLineWrapper::IssuerImpl, so this class must be modified to properly maintain AmountIssuedEntry.
Besides asset issuance, asset clawback operation also changes the outstanding amount, and it is a
NonIssuerImpl
op?
Jay and I went over this during our 1 on 1 and cleared things up. Clawback currently doesn't load the TrustLineWrapper for the account initiating the clawback (the issuer).
To lay out the scope of work for this issue.
Add a new internal ledger entry field AssetAmountIssuedEntry
:
enum class InternalLedgerEntryType
{
ASSET_AMOUNT_ISSUED,
};
struct AssetAmountIssuedKey
{
Asset asset;
};
struct AssetAmountIssuedEntry
{
Asset asset;
uint128_t amount;
};
and adapt the new type into LedgerTxn and SQL.
The uint128_t amount
is large enough to hold the maximum quantity of the asset being ever issued, and unsigned is good enough since this is for internal tracking.
Workflows that affect amount of asset issued:
PathPaymentStrictSend
and PathPaymentStrictReceive
)Clawback and Clawback Claimable Balance currently doesn't load the TrustLineWrapper for the issuer (as Siddharth pointed out). We'll need to first add that part. Then all the AssetAmountIssued
altering logic can be consolidated in the TrustLineWrapper::IssuerImpl
.
Handle the corner case where authorization is revoked for an trustline contributing to a liquidity pool (as Siddharth pointed out below).
Initialize the AssetAmountIssued
for all assets during catch up work. Right after applying buckets completes, we calculate the total amount issued by aggregating over all trustlines of a particular asset, and persist it.
Add/update test cases in operations mentioned above.
Depending on Speedex design, liabilities may affect the amount issued. For now we assume they don't, but need to verify. (Speedex offers are different from the DEX orders and won't affect the liabilities)
This plan looks good to me and I think you're ready to start. Just a few points -
Thanks @sisuresh , I have updated the summary based on your points.
Right now, the total issued amount of non-native assets are not tracked. This is an impediment to implementing new invariants (such as #1496) and new protocol features (such as SPEEDEX).
Asset issuance can be tracked by adding a new type of
InternalLedgerEntry
(which I will refer to asAmountIssuedEntry
but I'm open to other names).AmountIssuedEntry
contains an asset and an amount. Asset issuance always occurs inTrustLineWrapper::IssuerImpl
, so this class must be modified to properly maintainAmountIssuedEntry
.Unlike other types of
InternalLedgerEntry
,AmountIssuedEntry
cannot be ephemeral so it must be recorded in the database.