Skip to content

Single Asset Vault #5224

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

Open
wants to merge 182 commits into
base: develop
Choose a base branch
from
Open

Single Asset Vault #5224

wants to merge 182 commits into from

Conversation

Bronek
Copy link
Collaborator

@Bronek Bronek commented Dec 17, 2024

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

Copy link
Collaborator

@gregtatcam gregtatcam left a 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

Copy link
Collaborator

@gregtatcam gregtatcam left a 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.

@Bronek
Copy link
Collaborator Author

Bronek commented Dec 18, 2024

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 VaultDelete still needs to be fixed, but for the time being I've commented the failing test out. Compilation errors in clang 16 fixed, also simplified json_value.h a little.

@Bronek Bronek force-pushed the vault branch 3 times, most recently from 2bcc6ad to 17af6e7 Compare December 18, 2024 17:23
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 89.46037% with 125 lines in your changes missing coverage. Please review.

Project coverage is 78.3%. Comparing base (3502df2) to head (01cc089).

Files with missing lines Patch % Lines
src/xrpld/ledger/detail/View.cpp 89.3% 25 Missing ⚠️
src/xrpld/app/tx/detail/VaultDeposit.cpp 85.3% 17 Missing ⚠️
src/xrpld/app/tx/detail/VaultClawback.cpp 84.6% 16 Missing ⚠️
src/xrpld/app/tx/detail/VaultWithdraw.cpp 84.8% 16 Missing ⚠️
src/xrpld/app/tx/detail/VaultSet.cpp 85.9% 10 Missing ⚠️
src/xrpld/app/tx/detail/VaultCreate.cpp 92.0% 9 Missing ⚠️
src/xrpld/app/misc/CredentialHelpers.cpp 87.0% 7 Missing ⚠️
src/xrpld/app/tx/detail/VaultDelete.cpp 88.5% 7 Missing ⚠️
src/xrpld/rpc/handlers/VaultInfo.cpp 92.0% 4 Missing ⚠️
src/libxrpl/protocol/STParsedJSON.cpp 50.0% 3 Missing ⚠️
... and 7 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #5224     +/-   ##
=========================================
+ Coverage     78.1%   78.3%   +0.2%     
=========================================
  Files          795     808     +13     
  Lines        68582   69629   +1047     
  Branches      8278    8293     +15     
=========================================
+ Hits         53574   54521    +947     
- Misses       15008   15108    +100     
Files with missing lines Coverage Δ
include/xrpl/json/json_value.h 98.5% <ø> (ø)
include/xrpl/protocol/AMMCore.h 100.0% <ø> (ø)
include/xrpl/protocol/Asset.h 95.5% <100.0%> (+0.7%) ⬆️
include/xrpl/protocol/IOUAmount.h 100.0% <ø> (ø)
include/xrpl/protocol/Indexes.h 100.0% <100.0%> (ø)
include/xrpl/protocol/MPTAmount.h 100.0% <ø> (ø)
include/xrpl/protocol/MPTIssue.h 100.0% <100.0%> (ø)
include/xrpl/protocol/SField.h 100.0% <ø> (ø)
include/xrpl/protocol/STAmount.h 95.5% <100.0%> (+0.3%) ⬆️
include/xrpl/protocol/STBase.h 94.7% <100.0%> (+0.6%) ⬆️
... and 60 more

... and 6 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -80,17 +85,23 @@ VaultDeposit::preclaim(PreclaimContext const& ctx)

if ((vault->getFlags() & tfVaultPrivate) && account != vault->at(sfOwner))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STObject::isFlag() is a nice helper function that abstracts the getFlags() & tfWhatever check. It's not the best name. Probably should have been called isFlagSet. But I like it because it's more concise and precise. Consider switching to it.

Suggested change
if ((vault->getFlags() & tfVaultPrivate) && account != vault->at(sfOwner))
if ((vault->isFlag(tfVaultPrivate)) && account != vault->at(sfOwner))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

.mptIssuanceID = mptIssuanceID->value(),
.accountID = account_});
!isTesSuccess(err))
return err;
}

// If the vault is private, set the authorized flag for the vault owner
if (vault->getFlags() & tfVaultPrivate)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also use isFlag()


return tesSUCCESS;
XRPL_ASSERT(
sleIssuance->getFieldU32(sfFlags) & lsfMPTRequireAuth,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also use isFlag()

Comment on lines 2315 to 2316
if (sleIssuance->getFieldU32(sfFlags) & lsfMPTRequireAuth &&
!(sleToken->getFlags() & lsfMPTAuthorized))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these checks could also use isFlag

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done (in requireAuth)

{
if (!uNodeIndex.parseHex(params[jss::vault_id].asString()))
{
jvResult[jss::error] = "malformedRequest";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good (in this file) where any checks that is checking for wrong type, rpcINVALID_PARAMS is used instead of malformedRequest to maintain consistency across other handlers

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.