-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single Asset Vault #5224
base: develop
Are you sure you want to change the base?
Single Asset Vault #5224
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got compile error on MAC M1 Sequoia 15.1.1, apple clang 16.0.0
xrpl/json/json_value.h:705:5: error: constexpr function's return type 'Value' is not a literal type
705 | operator()(T&& t) const
xrpl/json/json_value.h:148:7: note: 'Value' is not literal because it is not an aggregate and has no constexpr constructors other than copy or move constructors
148 | class Value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few warnings, of which the most common is:
xrpl/protocol/STIssue.h:49:5: warning: definition of implicit copy constructor for 'STIssue' is deprecated because it has a user-declared copy assignment operator [-Wdeprecated-copy]
49 | operator=(STIssue const& rhs) = default;
And once the compile error is fixed (remove constexpr
in to_json_fn::operator()
return value), there are VaultDelete
unit-tests failures.
This is fixed now. The |
2bcc6ad
to
17af6e7
Compare
Also remove potential ODR violation from json_value.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a first pass at the review. It looks overall pretty good.
I still need to review the Vault unit-tests.
{sfAccount, soeREQUIRED}, | ||
{sfData, soeDEFAULT}, | ||
{sfAsset, soeREQUIRED}, | ||
{sfAssetTotal, soeDEFAULT}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AssetTotal
, AssetAvailable
, LossUnrealized
are marked as required in the specifications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, AssetTotal
, AssetMaximum
, and AssetAvailable
are plural in the specifications - AssetsTotal
, AssetsMaximum
, and AssetsAvailable
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NVM the first comment. These fields have a default value.
{sfAssetAvailable, soeDEFAULT}, | ||
{sfAssetMaximum, soeDEFAULT}, | ||
{sfLossUnrealized, soeDEFAULT}, | ||
{sfMPTokenIssuanceID, soeREQUIRED}, // sfShare |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these three fields slated for SAV v1 and just not implemented yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ShareTotal
is not going to be implemented. We decided to just use the bookkeeping inmptIssuance(vault.sfMPTIssuanceID).sfOutstandingAmount
. However, the RPC forledger_object
(or whatever it's called) needs to join that field in the result.- Right now, there is only one
WithdrawalPolicy
. IMO, it can be added (and tested) once a second is introduced. PermissionedDomainID
is planned for v1, but isn't yet available indevelop
. Its PR (Permissioned Domains (XLS-80d) #5161) needs to be merged with this branch.
if ((issuance->getFlags() & lsfMPTCanTransfer) == 0) | ||
return tecLOCKED; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the specs there should be a check added for a frozen trustline.
vault->at(sfAssetAvailable) -= assets; | ||
view().update(vault); | ||
|
||
// auto const& vaultAccount = vault->at(sfAccount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this block of code commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was in the middle of tracking down a bug in this transaction.
} | ||
auto& account = *maybeAccount; | ||
auto const accountId = (*account)[sfAccount]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider renaming to ammAccountId
to emphasize that this AMM's pseudo account.
@@ -327,7 +327,8 @@ AccountRootsNotDeleted::finalize( | |||
// A successful AccountDelete or AMMDelete MUST delete exactly | |||
// one account root. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add comments for the Vault.
auto const sleMpt = view.peek(mptokenKey); | ||
if (!sleMpt || (*sleMpt)[sfMPTAmount] != 0) | ||
return tecINTERNAL; | ||
if (!sleMpt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do decide to go ahead with these changes (here and in MPTokenIssuance[Create,Destroy] then any return code changes have to be amendment gated. It makes sense for @shawnxie999 to review.
@@ -108,4 +110,101 @@ operator<<(std::ostream& out, STNumber const& rhs) | |||
return out << rhs.getText(); | |||
} | |||
|
|||
NumberParts | |||
partsFromString(std::string const& number) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is copied from the original implementation of amountFromString()
but this check is missing:
if ((match[2].length() + match[4].length()) > 32)
Throw<std::runtime_error>("Number '" + amount + "' is overlong");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have access to the Slack any more, but I had asked about this there and explained why I left it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @thejohnfreeman , I found it
separately, that function has a CHECKME about its length check. it checks that the non-fractional and fractional strings do not concatenate longer than 32 characters. the CHECKME asks if that should be 16 characters. I'm guessing this check is to make sure the base-10 digit string can be parsed into an unsigned integer 64 bits long, but both of those lengths are wrong. 2^64 - 1 has a decimal representation that is 20 digits long. of course you can't put just any digits in those 20 places, but this length check seems misguided anyway, because the parsing is handled by beast::lexicalCastThrow, which will throw if the string overflows 64 bits unsigned. am I reading this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the following unit-tests are missing:
- Vault feature disabled for all transactors
- Invalid flags for all transactors (except for set:tfVaultPrivate)
- Insufficient fee (except for create)
- Vault is not found (except for delete)
- Set:
- Data too large
- Deposit:
- Deposit into private vault
- Amount to deposit is not the vault's asset
- Checking for the reserve if the depositor doesn't have MPToken for the Vault shares
- Withdraw
- Amount to withdraw is not the vault's asset
- Vault is private
- Clawback:
- Amount to clawback is not the vault's asset
- Insufficient funds to withdraw
296cdec
to
201a310
Compare
High Level Overview of Change
This is implementation of XLS-65 Single Asset Vault. First draft was implemented by @thejohnfreeman in #5147
Context of Change
Type of Change
.gitignore
, formatting, dropping support for older tooling)API Impact
libxrpl
change (any change that may affectlibxrpl
or dependents oflibxrpl
)