Skip to content

Conversation

@khancode
Copy link
Contributor

@khancode khancode commented May 9, 2025

High Level Overview of Change

Adds support for Account Permission Delegation (XLS-74d, XLS-75d)

Context of Change

rippled PR: XRPLF/rippled#5354.

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)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Release

Did you update HISTORY.md?

  • Yes
  • No, this change does not impact library users

Test Plan

Adds unit/integ tests.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 9, 2025

Walkthrough

This change introduces support for account permissions and permission delegation in accordance with XLS-74d and XLS-75d standards. It adds new transaction and ledger entry types, validation logic, configuration flags, and comprehensive tests to enable and verify delegated permissions on the XRPL.

Changes

Files/Group Change Summary
.ci-config/rippled.cfg Added PermissionDelegation feature flag to enabled amendments.
packages/ripple-binary-codec/src/enums/definitions.json Added new field, ledger entry, and transaction types for permissions and delegation.
packages/ripple-binary-codec/src/enums/constants.ts Introduced DELEGATABLE_PERMISSIONS_WIDTH constant.
packages/ripple-binary-codec/src/enums/xrpl-definitions-base.ts Added granularPermissions and delegatablePermissions properties and updated type associations.
packages/ripple-binary-codec/HISTORY.md
packages/xrpl/HISTORY.md
Updated changelogs to document added support for account permissions and delegation.
packages/ripple-binary-codec/test/fixtures/codec-fixtures.json Added a new fixture for the DelegateSet transaction.
packages/xrpl/src/models/ledger/Delegate.ts Introduced Delegate ledger entry interface.
packages/xrpl/src/models/ledger/LedgerEntry.ts Added Delegate to ledger entry and filter union types.
packages/xrpl/src/models/ledger/index.ts Exported Delegate from the ledger model index.
packages/xrpl/src/models/methods/ledgerEntry.ts Added optional delegate property to LedgerEntryRequest.
packages/xrpl/src/models/transactions/common.ts Added optional Delegate field and validation to BaseTransaction.
packages/xrpl/src/models/transactions/delegateSet.ts Added DelegateSet transaction model, Permission type, and validation logic.
packages/xrpl/src/models/transactions/transaction.ts Included DelegateSet in submittable transactions and validation switch.
packages/xrpl/src/models/transactions/index.ts Exported DelegateSet and Permission from transaction models index.
packages/xrpl/test/integration/transactions/delegateSet.test.ts Added integration tests for DelegateSet transaction and delegation enforcement.
packages/xrpl/test/models/baseTransaction.test.ts Added tests for invalid or conflicting Delegate field values.
packages/xrpl/test/models/delegateSet.test.ts Introduced tests for DelegateSet transaction validation logic.
packages/xrpl/test/integration/utils.ts Extended testTransaction to optionally assert expected error codes.

Suggested reviewers

  • achowdhry-ripple
  • ckeshava

Poem

🐇
A hop, a skip, permissions bloom,
Delegates dance in ledger’s room.
With tests and types, the rules are set,
No duplicate, no self-delegate bet!
Onward we bound, with features new—
The XRPL grows, as rabbits do!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm warn config production Use --omit=dev instead.
npm warn EBADENGINE Unsupported engine {
npm warn EBADENGINE package: '@es-joy/[email protected]',
npm warn EBADENGINE required: { node: '^14 || ^16 || ^17 || ^18 || ^19' },
npm warn EBADENGINE current: { node: 'v24.0.2', npm: '11.3.0' }
npm warn EBADENGINE }
npm warn EBADENGINE Unsupported engine {
npm warn EBADENGINE package: '[email protected]',
npm warn EBADENGINE required: { node: '^14 || ^16 || ^17 || ^18 || ^19' },
npm warn EBADENGINE current: { node: 'v24.0.2', npm: '11.3.0' }
npm warn EBADENGINE }
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-05-20T21_21_04_340Z-debug-0.log

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between e85825b and 1d80561.

📒 Files selected for processing (1)
  • packages/xrpl/test/integration/transactions/delegateSet.test.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/xrpl/test/integration/transactions/delegateSet.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: browser (18.x)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment on lines 49 to 57
try {
await testTransaction(testContext.client, tx, bob)
} catch (err: unknown) {
const assertErr = err as AssertionError
assert.equal(
assertErr.message,
"No permission to perform requested operation.: expected 'tecNO_PERMISSION' to equal 'tesSUCCESS'",
)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can the framework be adjusted to take other optional error codes instead of needing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean adding an optional param like this: await testTransaction(testContext.client, tx, bob, errCode)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mvadari I did the refactor in 760ac8b but now only the browser test fails 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nevermind, got it working in 2f1f6a2

Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't that be used here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, missed the update here. Done in a192433

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh actually, since tecNO_PERMISSION is already being tested in base flow, I removed it from here.

@khancode khancode requested review from Patel-Raj11 and mvadari May 15, 2025 01:03
Copy link
Collaborator

@Patel-Raj11 Patel-Raj11 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/xrpl/test/integration/transactions/delegateSet.test.ts (2)

49-57: Consider using the new errCode parameter for consistency.

The test catches an AssertionError to verify the tecNO_PERMISSION error, but it would be more consistent to use the new errCode parameter that was added specifically for this purpose.

-      try {
-        await testTransaction(testContext.client, tx, bob)
-      } catch (err: unknown) {
-        const assertErr = err as AssertionError
-        assert.equal(
-          assertErr.message,
-          "No permission to perform requested operation.: expected 'tecNO_PERMISSION' to equal 'tesSUCCESS'",
-        )
-      }
+      await testTransaction(testContext.client, tx, bob, undefined, 'tecNO_PERMISSION')

40-41: Consider a more descriptive test name.

The current test name "no permission" could be more descriptive to clearly communicate what's being tested.

-    'no permission',
+    'rejects delegated transaction without prior authorization',
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 5cc9427 and 760ac8b.

📒 Files selected for processing (2)
  • packages/xrpl/test/integration/transactions/delegateSet.test.ts (1 hunks)
  • packages/xrpl/test/integration/utils.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: snippets (22.x)
  • GitHub Check: snippets (20.x)
  • GitHub Check: snippets (18.x)
  • GitHub Check: integration (22.x)
  • GitHub Check: browser (18.x)
  • GitHub Check: integration (20.x)
  • GitHub Check: integration (18.x)
  • GitHub Check: unit (18.x)
🔇 Additional comments (5)
packages/xrpl/test/integration/utils.ts (1)

235-236: Appropriate enhancement for handling expected failures.

The addition of the errCode parameter enables more efficient testing of cases where transactions are expected to fail with specific error codes. This is particularly valuable for testing permission-related features like the new account delegation functionality.

Also applies to: 248-248, 263-266

packages/xrpl/test/integration/transactions/delegateSet.test.ts (4)

33-35: Good use of test context wallet to reduce funding time.

Using testContext.wallet for Alice instead of generating a new wallet is an efficient approach that reduces test initialization time.


78-91: Well-structured verification of Delegate ledger entry.

The test properly verifies the creation of the Delegate ledger entry with all the expected fields, ensuring the delegation was properly recorded.


93-106: Thorough validation of delegated payment transaction.

The test comprehensively verifies that Bob can successfully execute a payment on behalf of Alice, checking that the transaction includes the correct Account (Alice), Delegate (Bob), and is properly signed with Bob's key.


108-123: Good negative test case for insufficient permissions.

The test correctly verifies that Bob cannot perform an AccountSet operation for which he hasn't been authorized, using the new errCode parameter to check for the expected tecNO_PERMISSION error.

@khancode khancode requested a review from mvadari May 20, 2025 03:28
@khancode khancode merged commit eeb74f7 into main May 20, 2025
24 of 27 checks passed
@khancode khancode deleted the permission-delegation branch May 20, 2025 21:28
@mvadari
Copy link
Collaborator

mvadari commented May 20, 2025

Nice job

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.

4 participants