Skip to content
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

Permissioned Domains (XLS-80d) #5149

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

Conversation

mtrippled
Copy link
Collaborator

Spec: XRPLF/XRPL-Standards#228

High Level Overview of Change

Implements the object, transactions, and tests required by the spec:
XRPLF/XRPL-Standards#228

Context of Change

New feature. Follows existing patterns for adding a new ledger object and related transactions.

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

Requires an amendment.

  • 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

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 95.03546% with 7 lines in your changes missing coverage. Please review.

Project coverage is 76.2%. Comparing base (1fbf8da) to head (bb5d603).
Report is 8 commits behind head on develop.

Files with missing lines Patch % Lines
...c/xrpld/app/tx/detail/PermissionedDomainDelete.cpp 87.1% 4 Missing ⚠️
src/xrpld/app/tx/detail/PermissionedDomainSet.cpp 96.3% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #5149    +/-   ##
========================================
  Coverage     76.2%   76.2%            
========================================
  Files          760     764     +4     
  Lines        61568   61709   +141     
  Branches      8126    8126            
========================================
+ Hits         46909   47033   +124     
- Misses       14659   14676    +17     
Files with missing lines Coverage Δ
include/xrpl/protocol/Feature.h 100.0% <ø> (ø)
include/xrpl/protocol/Indexes.h 100.0% <ø> (ø)
include/xrpl/protocol/SField.h 100.0% <ø> (ø)
src/libxrpl/protocol/Feature.cpp 94.6% <ø> (ø)
src/libxrpl/protocol/Indexes.cpp 97.7% <100.0%> (+0.1%) ⬆️
src/libxrpl/protocol/LedgerFormats.cpp 100.0% <100.0%> (ø)
src/libxrpl/protocol/SField.cpp 77.5% <ø> (ø)
src/libxrpl/protocol/TxFormats.cpp 100.0% <100.0%> (ø)
src/xrpld/app/tx/detail/InvariantCheck.cpp 91.5% <100.0%> (+0.4%) ⬆️
src/xrpld/app/tx/detail/InvariantCheck.h 100.0% <ø> (ø)
... and 7 more

... and 7 files with indirect coverage changes

Impacted file tree graph

@Bronek Bronek changed the title Permissioned Domains Permissioned Domains (XLS-80d) Sep 27, 2024
Copy link
Collaborator

@oleks-rip oleks-rip left a comment

Choose a reason for hiding this comment

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

InnerObjectFormats.cpp should be updated with

add(sfCredential.jsonName.c_str(),
sfCredential.getCode(),
{
    {sfIssuer, soeREQUIRED},
    {sfCredentialType, soeREQUIRED},
});

to check sfAcceptedCredentials array during RPC parsing. This inner object already present in credentials PR(#5103) so I will not treat this as an issue

src/test/app/PermissionedDomains_test.cpp Outdated Show resolved Hide resolved
src/test/app/PermissionedDomains_test.cpp Outdated Show resolved Hide resolved
src/test/app/PermissionedDomains_test.cpp Outdated Show resolved Hide resolved
src/test/app/PermissionedDomains_test.cpp Outdated Show resolved Hide resolved
src/test/app/PermissionedDomains_test.cpp Outdated Show resolved Hide resolved
src/test/app/PermissionedDomains_test.cpp Outdated Show resolved Hide resolved
src/xrpld/app/tx/detail/InvariantCheck.cpp Outdated Show resolved Hide resolved
src/xrpld/app/tx/detail/PermissionedDomainSet.cpp Outdated Show resolved Hide resolved
@mtrippled
Copy link
Collaborator Author

InnerObjectFormats.cpp should be updated with

add(sfCredential.jsonName.c_str(),
sfCredential.getCode(),
{
    {sfIssuer, soeREQUIRED},
    {sfCredentialType, soeREQUIRED},
});

to check sfAcceptedCredentials array during RPC parsing. This inner object already present in credentials PR(#5103) so I will not treat this as an issue

Credentials should be merged before this one. There likely will be merge conflicts from some of the new field names having different values, but they should be simple to resolve.

failing the transaction. Conforms to Credentials spec.
Copy link
Collaborator

@dangell7 dangell7 left a comment

Choose a reason for hiding this comment

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

Partial Review

src/xrpld/app/tx/detail/PermissionedDomainSet.cpp Outdated Show resolved Hide resolved
src/xrpld/app/tx/detail/PermissionedDomainSet.cpp Outdated Show resolved Hide resolved
src/xrpld/app/tx/detail/PermissionedDomainSet.cpp Outdated Show resolved Hide resolved
@@ -222,7 +222,8 @@ doAccountObjects(RPC::JsonContext& context)
{jss::xchain_owned_claim_id, ltXCHAIN_OWNED_CLAIM_ID},
{jss::xchain_owned_create_account_claim_id,
ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID},
{jss::bridge, ltBRIDGE}};
{jss::bridge, ltBRIDGE},
{jss::permissioned_domain, ltPERMISSIONED_DOMAIN}};
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are other rpc functions that need to be added for account_objects I believe. LedgerEntry. Also you should write some tests to confirm the behavior.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You should also be able to query the ledger entry from the account/seq so add that as well. And then add tests.

Copy link
Collaborator Author

@mtrippled mtrippled Oct 15, 2024

Choose a reason for hiding this comment

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

I added a flag for account_objects to return type=permissioned_domain, and tested it. Also the ledger_entry call is already tested ok. Please specify what other RPC's you think are necessary. But i think what's there already is sufficient for people to find their PermissionedDomain objects.

Copy link
Collaborator

@dangell7 dangell7 Oct 15, 2024

Choose a reason for hiding this comment

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

There are 2 ledger entry calls. The index and { permissioned_domain: { account: account, seq: seq }} the other should be added and tested unless I'm just missing it.

You tested that the objects are empty, you then lower in the test would create the permissioned_domain and validate it. I'm not the main reviewer so if someone else is fine with you testing account_objects differently than the other objects then thats ok. (All the objects are not even tested there anyways so its prob not a big deal)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've checked documentation, it seems we also need to extend the RPCs:

  • ledger_data- relies on chooseLedgerEntryType which is already modified, so we only need to add it to unit tests
  • ledger_entry - needs a custom section of code inside doLedgerEntry (and a unit test)

Copy link
Collaborator

@mDuo13 mDuo13 Oct 15, 2024

Choose a reason for hiding this comment

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

Whenever you add a new type of ledger entry, the following methods need to be extended:

  • account_objects - type field
  • ledger_data - type field
  • ledger_entry - new field for looking up the new entry type (typically this can accept either a string ledger entry ID or an object with nested sub-fields as appropriate for the type of entry)

I think the ledger_data and account_objects type filters use shared code as mentioned above.

I don't think there's anything else that always needs to be added/updated, but of course depending on what the amendment does there may always be more. In the case of Permissioned Domains I'm guessing nothing.

Also, I don't think adding a new type of transaction requires any similar work since AFAIK we don't have anything that filters on transaction type or retrieves specific types of transactions specifically.

include/xrpl/protocol/Indexes.h Show resolved Hide resolved
src/libxrpl/protocol/LedgerFormats.cpp Show resolved Hide resolved
// Get newly created domain from transaction metadata.
uint256
getNewDomain(std::shared_ptr<STObject const> const& meta);

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Can you check to make sure you're not duplicating any helper functions here? toBlob I have seen before and objectExists seems more agnostic than just for domains. Maybe we could move that and also pass in the ledger entry type? Owner Info is also very agnostic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I put those things in their own namespace, for this particular project, for this particular set of methods & ledger object. If somebody else wants to use them for something else, they can modify, C&P, put somewhere else, etc.

src/test/jtx/impl/PermissionedDomains.cpp Show resolved Hide resolved
src/test/jtx/impl/PermissionedDomains.cpp Show resolved Hide resolved
auto const reserve =
ctx_.view().fees().accountReserve((*ownerSle)[sfOwnerCount] + 1);
if (balance < reserve)
return tecINSUFFICIENT_RESERVE;
Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks for putting this check here 👍

BEAST_EXPECT(pd::ownerInfo(alice, env)["OwnerCount"].asUInt() == 1);

/*
env(did::setValid(alice), ter(tecINSUFFICIENT_RESERVE));
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there any purpose to having this commented-out section here ?

env.close();

// Pay alice almost enough to make the reserve.
env(pay(env.master, alice, incReserve + drops(19)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please avoid using fee 10 directly, this will break with any fee other than 10.

In this case, this could be written as

auto const baseFee = env.current()->fees().base.drops();
...
env(pay(env.master, alice, incReserve + 2 * baseFee - 1));


// Pay alice almost enough to make the reserve.
env(pay(env.master, alice, incReserve + drops(19)));
BEAST_EXPECT(env.balance(alice) == acctReserve + incReserve + drops(9));
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

BEAST_EXPECT(pd::ownerInfo(alice, env)["OwnerCount"].asUInt() == 0);

// Pay alice enough to make the reserve.
env(pay(env.master, alice, drops(11)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

Copy link
Collaborator

Choose a reason for hiding this comment

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

please also fix for commented section if it's not going to be removed.

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.

7 participants