Sponsored Content
Skip to content

Support PermissionDelegation Amendment XLS-74d XLS-75d - #5354

Merged
bthomee merged 26 commits into
XRPLF:developfrom
yinyiqian1:account_permission_new
May 8, 2025
Merged

Support PermissionDelegation Amendment XLS-74d XLS-75d#5354
bthomee merged 26 commits into
XRPLF:developfrom
yinyiqian1:account_permission_new

Conversation

@yinyiqian1

@yinyiqian1 yinyiqian1 commented Mar 19, 2025

Copy link
Copy Markdown
Contributor

spec:
https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0074d-account-permissions
https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0075d-permission-delegation

This amendment is called PermissionDelegation

  1. DelegateSet transaction is added so that a delegating account can give permission to delegated account to send transaction on his behalf.
{
    TransactionType: "DelegateSet",
    Account: "rDelegating......",
    Authorize: "rDelegated......",
    Permissions: [{Permission: {PermissionValue: "Payment"}}],
}
  1. Ledger object Delegate is created, its keylet is hashed from delegating and delegated account.

  2. optional common field Delegate is added, to indicate that a transaction is a delegating transaction.
    The following transaction is a delegating transaction, Delegate account is the sender of the transaction and will sign this transaction, Account is the delegating account,

{
    Transaction: "Payment",
    Account: "rDelegating......",
    Amount: "1000000000",
    Destination: "r......",
    Delegate: "rDelegated......"
}
  1. Added a checkPermission function to check if the delegated account is authorized to send the transaction. And it can be extended in each sub-transactor to check the granular permissions.

  2. the delegated account pays the fee

  3. can query account_objects of the delegating account to see the permissions he owns.

  4. A delegate transaction can be multi-signed by the delegated account's signer list

High Level Overview of Change

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)

@yinyiqian1
yinyiqian1 force-pushed the account_permission_new branch 2 times, most recently from 70a6362 to 5b262d1 Compare March 19, 2025 06:37
@yinyiqian1 yinyiqian1 changed the title Support AccountPermission Support AccountPermission XLS-74d XLS-75d Mar 19, 2025
@yinyiqian1
yinyiqian1 force-pushed the account_permission_new branch 5 times, most recently from c8bc5f6 to e8e74f1 Compare March 19, 2025 15:57

@ximinez ximinez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Preliminary partial review. I know you're still working on this, but a few things jumped out at me, and I wanted to bring them to your attention before you go down a problematic path.

Comment thread src/xrpld/app/tx/detail/Transactor.cpp Outdated
Comment thread src/libxrpl/protocol/STParsedJSON.cpp Outdated
Comment thread src/libxrpl/protocol/STParsedJSON.cpp Outdated
Comment thread src/libxrpl/protocol/Permissions.cpp Outdated
Comment thread src/libxrpl/protocol/STParsedJSON.cpp Outdated
Comment thread src/libxrpl/protocol/Permissions.cpp Outdated
Comment thread include/xrpl/protocol/Permissions.h Outdated
Comment thread include/xrpl/protocol/Permissions.h Outdated
Comment thread src/libxrpl/protocol/Permissions.cpp Outdated
Comment thread src/xrpld/rpc/handlers/LedgerEntry.cpp Outdated
@codecov

codecov Bot commented Mar 19, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 99.55157% with 2 lines in your changes missing coverage. Please review.

Project coverage is 78.3%. Comparing base (9ec2d7f) to head (3839f1f).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
src/libxrpl/protocol/Permissions.cpp 97.7% 1 Missing ⚠️
src/xrpld/app/tx/detail/SetAccount.cpp 97.1% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #5354     +/-   ##
=========================================
+ Coverage     78.1%   78.3%   +0.1%     
=========================================
  Files          795     800      +5     
  Lines        68653   69025    +372     
  Branches      8276    8275      -1     
=========================================
+ Hits         53644   54022    +378     
+ Misses       15009   15003      -6     
Files with missing lines Coverage Δ
include/xrpl/protocol/ErrorCodes.h 100.0% <ø> (ø)
include/xrpl/protocol/Indexes.h 100.0% <ø> (ø)
include/xrpl/protocol/detail/ledger_entries.macro 100.0% <100.0%> (ø)
include/xrpl/protocol/detail/permissions.macro 100.0% <100.0%> (ø)
include/xrpl/protocol/detail/transactions.macro 100.0% <100.0%> (ø)
src/libxrpl/protocol/ErrorCodes.cpp 85.7% <ø> (ø)
src/libxrpl/protocol/Indexes.cpp 98.1% <100.0%> (+<0.1%) ⬆️
src/libxrpl/protocol/InnerObjectFormats.cpp 100.0% <100.0%> (ø)
src/libxrpl/protocol/STInteger.cpp 86.4% <100.0%> (+1.9%) ⬆️
src/libxrpl/protocol/STParsedJSON.cpp 70.0% <100.0%> (+0.8%) ⬆️
... and 20 more

... and 3 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.

Comment thread src/xrpld/app/tx/detail/MPTokenIssuanceSet.cpp Outdated
Comment thread src/xrpld/app/tx/detail/SetTrust.cpp Outdated
Comment thread include/xrpl/protocol/detail/permissions.macro Outdated
Comment thread src/xrpld/rpc/handlers/LedgerEntry.cpp Outdated
Comment thread src/xrpld/rpc/handlers/LedgerEntry.cpp Outdated
@yinyiqian1
yinyiqian1 force-pushed the account_permission_new branch from b1f0387 to 4495956 Compare March 20, 2025 15:41
@yinyiqian1
yinyiqian1 force-pushed the account_permission_new branch from 4495956 to 49ca2b8 Compare March 20, 2025 16:38
@yinyiqian1 yinyiqian1 changed the title Support AccountPermission XLS-74d XLS-75d Support DelegateSet Amendment XLS-74d XLS-75d Mar 20, 2025
@yinyiqian1
yinyiqian1 marked this pull request as ready for review March 20, 2025 16:50
Comment thread src/xrpld/rpc/handlers/LedgerEntry.cpp Outdated
@shawnxie999

Copy link
Copy Markdown
Contributor

Also, I propose that we shouldn't need to squash commits. Commits makes it easier for the reviewers to keep track of the changes, and they will all be squashed in the end anyways. Also, the audit relies on a particular commit hash, so it's best to keep the commit history as authentic as possible.

Comment thread include/xrpl/protocol/Protocol.h Outdated
Comment thread include/xrpl/protocol/detail/sfields.macro Outdated
Comment thread include/xrpl/protocol/detail/permissions.macro Outdated
Comment thread src/xrpld/app/tx/detail/DelegateSet.cpp Outdated
@yinyiqian1
yinyiqian1 requested a review from gregtatcam March 20, 2025 18:20
Comment thread src/xrpld/app/tx/detail/SetAccount.cpp Outdated
Comment thread src/libxrpl/protocol/Permissions.cpp Outdated
Comment thread src/xrpld/app/tx/detail/SetTrust.cpp Outdated

@gregtatcam gregtatcam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 LGTM

I have a few minor comments for your consideration,

Comment thread include/xrpl/protocol/jss.h Outdated
Comment thread include/xrpl/protocol/Permissions.h Outdated
Comment thread src/xrpld/app/tx/detail/MPTokenIssuanceSet.cpp
Comment thread src/xrpld/app/misc/DelegateUtils.h

@ximinez ximinez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like all my concerns have been addressed. I have not reviewed the whole PR, so I can not "approve", but I will dismiss my stale change request review.

@ximinez
ximinez dismissed their stale review May 7, 2025 18:51

As noted above, dismissing this change request.

@kennyzlei kennyzlei added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label May 7, 2025
Comment on lines +224 to +226
if (tx.isFieldPresent(sfWalletLocator) ||
tx.isFieldPresent(sfNFTokenMinter))
return tecNO_PERMISSION;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't it necessary to check the WalletSize field?

@yinyiqian1 yinyiqian1 May 20, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The WalletSize field does nothing according to https://xrpl.org/docs/references/protocol/transactions/types/accountset
Although WalletSize is defined, there's no code in AccountSet setting WalletSize, which approves that the field is not used.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, WalletSize does not change AccountRoot, but it is a field that can be specified in AccountSet transactions.
It seems strange that a transaction would succeed when only sfWaletSize is specified by an account with permissions only for AccountEmailHashSet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, if we have some specific permission for AccountSet, are AccountSet transactions (empty execution) that don't change AccountRoot allowed?

Comment on lines +217 to +218
if (uSetFlag != 0 || uClearFlag != 0 || uTxFlags != tfFullyCanonicalSig)
return tecNO_PERMISSION;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dangell7

The tfInnerBatchTxn flag should be enabled here in Batch.
#5060

possibly uTxFlags & tfUniversalMask

@yinyiqian1 yinyiqian1 May 20, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The check now already blocks batch transaction and returns tecNO_PERMISSION. If the tx flag is not equal to the auto filled tfFullyCanonicalSig, it will return tecNO_PERMISSION. I think we don't need to modify for Batch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good Catch! @tequdev! You are right, as the current code stands Batch Inner AccountSet for Domain is rejected with NO_PERMISSION. tfUniversalMask should have been used here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok. Got it. So we are supporting delegation within the Batch transactions, even though Batch itself could not be delegated. Please ignore my previous comment. @dangell7 Thank you for updating.

pdp2121 added a commit to ripple/explorer that referenced this pull request May 23, 2025
## High Level Overview of Change

<!--
Please include a summary/list of the changes.
If too broad, please consider splitting into multiple PRs.
-->
Adds support for Account Permission Delegation ([XLS-74d,
XLS-75d](https://github.com/XRPLF/XRPL-Standards/pull/257/files))

Changes will include:
- Adding a new transaction `DelegateSet`
- Adding a common optional field `Delegate` to `SimpleTab`

### Context of Change

<!--
Please include the context of a change.
If a bug fix, when was the bug introduced? What was the behavior?
If a new feature, why was this architecture chosen? What were the
alternatives?
If a refactor, how is this better than the previous implementation?

If there is a design document for this feature, please link it here.
-->
rippled PR: XRPLF/rippled#5354.

### Type of Change

<!--
Please check relevant options, delete irrelevant ones.
-->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] 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)
- [ ] Tests (You added tests for code that already exists, or your new
feature included in this PR)
- [ ] Documentation Updates
- [ ] Translation Updates
- [ ] Release

## Before / After

<!--
If just refactoring / back-end changes, this can be just an in-English
description of the change at a technical level.
If a UI change, screenshots should be included.
-->

### DelegateSet Simple Tab

<img width="1008" alt="Screenshot 2025-05-21 at 3 17 53 PM"
src="https://github.com/user-attachments/assets/f1058289-25c8-4f3d-8f7c-513354d58406"
/>

### DelegateSet Table Detail

<img width="1210" alt="Screenshot 2025-05-21 at 3 21 02 PM"
src="https://github.com/user-attachments/assets/7ab86e54-379e-44f9-b6eb-f3269feac072"
/>

### DelegateSet Description

<img width="898" alt="Screenshot 2025-05-21 at 3 22 00 PM"
src="https://github.com/user-attachments/assets/3542f6e3-7d1f-48c7-946a-87e8a7ba8fd3"
/>

### An authorized Payment transaction Simple Tab

<img width="1027" alt="Screenshot 2025-05-21 at 3 23 08 PM"
src="https://github.com/user-attachments/assets/87deee32-fd75-4a06-ab55-56c341495eb0"
/>

### An authorized Payment transaction Description

<img width="719" alt="Screenshot 2025-05-21 at 3 23 29 PM"
src="https://github.com/user-attachments/assets/f1d69437-cd4b-404a-b679-ccc14dfa3754"
/>
@Bronek Bronek mentioned this pull request Jun 24, 2025
@yinyiqian1
yinyiqian1 deleted the account_permission_new branch July 25, 2025 14:47
heap-coder added a commit to heap-coder/explorer that referenced this pull request Sep 27, 2025
## High Level Overview of Change

<!--
Please include a summary/list of the changes.
If too broad, please consider splitting into multiple PRs.
-->
Adds support for Account Permission Delegation ([XLS-74d,
XLS-75d](https://github.com/XRPLF/XRPL-Standards/pull/257/files))

Changes will include:
- Adding a new transaction `DelegateSet`
- Adding a common optional field `Delegate` to `SimpleTab`

### Context of Change

<!--
Please include the context of a change.
If a bug fix, when was the bug introduced? What was the behavior?
If a new feature, why was this architecture chosen? What were the
alternatives?
If a refactor, how is this better than the previous implementation?

If there is a design document for this feature, please link it here.
-->
rippled PR: XRPLF/rippled#5354.

### Type of Change

<!--
Please check relevant options, delete irrelevant ones.
-->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] 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)
- [ ] Tests (You added tests for code that already exists, or your new
feature included in this PR)
- [ ] Documentation Updates
- [ ] Translation Updates
- [ ] Release

## Before / After

<!--
If just refactoring / back-end changes, this can be just an in-English
description of the change at a technical level.
If a UI change, screenshots should be included.
-->

### DelegateSet Simple Tab

<img width="1008" alt="Screenshot 2025-05-21 at 3 17 53 PM"
src="https://github.com/user-attachments/assets/f1058289-25c8-4f3d-8f7c-513354d58406"
/>

### DelegateSet Table Detail

<img width="1210" alt="Screenshot 2025-05-21 at 3 21 02 PM"
src="https://github.com/user-attachments/assets/7ab86e54-379e-44f9-b6eb-f3269feac072"
/>

### DelegateSet Description

<img width="898" alt="Screenshot 2025-05-21 at 3 22 00 PM"
src="https://github.com/user-attachments/assets/3542f6e3-7d1f-48c7-946a-87e8a7ba8fd3"
/>

### An authorized Payment transaction Simple Tab

<img width="1027" alt="Screenshot 2025-05-21 at 3 23 08 PM"
src="https://github.com/user-attachments/assets/87deee32-fd75-4a06-ab55-56c341495eb0"
/>

### An authorized Payment transaction Description

<img width="719" alt="Screenshot 2025-05-21 at 3 23 29 PM"
src="https://github.com/user-attachments/assets/f1d69437-cd4b-404a-b679-ccc14dfa3754"
/>
beartec-jpg pushed a commit to beartec-jpg/FalconLedger that referenced this pull request Jun 1, 2026
This change implements the account permission delegation described in XLS-75d, see XRPLF/XRPL-Standards#257.

* Introduces transaction-level and granular permissions that can be delegated to other accounts.
* Adds `DelegateSet` transaction to grant specified permissions to another account.
* Adds `ltDelegate` ledger object to maintain the permission list for delegating/delegated account pair.
* Adds an optional `Delegate` field in common fields, allowing a delegated account to send transactions on behalf of the delegating account within the granted permission scope. The `Account` field remains the delegating account; the `Delegate` field specifies the delegated account. The transaction is signed by the delegated account.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Amendment API Change Clio Reviewed Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants