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

XLS-80d Permissioned Domains #773

Merged
merged 100 commits into from
Feb 12, 2025
Merged

XLS-80d Permissioned Domains #773

merged 100 commits into from
Feb 12, 2025

Conversation

ckeshava
Copy link
Collaborator

@ckeshava ckeshava commented Nov 15, 2024

High Level Overview of Change

This PR implements the PermissionedDomains amendment in the xrpl-py library.

Specification: XRPLF/XRPL-Standards#228
C++ Implementation: XRPLF/rippled#5161

#759 is a prerequisite for this PR.

For the readers who are only interested in the PermissionedDomain changes only, (but not the VerifiableCredentials changes) please read from this commit onwards: 8abf7b7

Context of Change

This PR implements the client library changes for two new transactions: PermissionedDomainSet and PermissionedDomainDelete

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 CHANGELOG.md?

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

Test Plan

I've included Unit and integration tests for the newly added transactions. No new unit tests have been attributed to the PermissionedDomainDelete transaction. The domain_id field must be retrieved from one of the rippled RPCs which conforms to the HASH256 internal type.

ckeshava and others added 30 commits October 15, 2024 12:38
… at commit ea8e77ffec065cf1a8d1cd4517f9cebdab27cc17

Explicity specify featureCredentials inside the conf file. This enables the features inside the genesis ledger
Refactor common elements within Credential-related transactions
…ommit

Deposit_preauth: array length checks on the authcreds and unauthcreds fields
… successfully deleted

Updates to Payment transaction model

Update AccountDelete transaction model with Credential ID array

Update EscrowFinish txn model with CredentialIDs

Updates to the PaymentChannelClaim txn model -- Include new unit test file
Co-authored-by: Mayukha Vadari <[email protected]>
…ion model; Revert this file to an older version
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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 (1)
tests/unit/models/transactions/test_permissioned_domain_set.py (1)

1-25: Add test cases for domain_id validation.

While the basic test case is good, consider adding test cases for domain_id validation:

  • Invalid hex string format
  • Incorrect length
  • Missing domain_id when required for modification
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c3a15b9 and 39ec51e.

📒 Files selected for processing (3)
  • tests/integration/transactions/test_permissioned_domain.py (1 hunks)
  • tests/unit/models/transactions/test_permissioned_domain_set.py (1 hunks)
  • xrpl/models/transactions/permissioned_domain_set.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/integration/transactions/test_permissioned_domain.py
🧰 Additional context used
📓 Learnings (1)
xrpl/models/transactions/permissioned_domain_set.py (1)
Learnt from: mvadari
PR: XRPLF/xrpl-py#773
File: xrpl/models/transactions/permissioned_domain_set.py:22-22
Timestamp: 2024-11-20T21:16:43.491Z
Learning: In the `xrpl.models.transactions.PermissionedDomainSet` class, the `domain_id` field is optional in the `PermissionedDomainSet` transaction.
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: Integration test (3.13)
  • GitHub Check: Snippet test (3.13)
  • GitHub Check: Integration test (3.12)
  • GitHub Check: Snippet test (3.12)
  • GitHub Check: Integration test (3.11)
  • GitHub Check: Snippet test (3.11)
  • GitHub Check: Integration test (3.10)
  • GitHub Check: Snippet test (3.10)
  • GitHub Check: Integration test (3.9)
  • GitHub Check: Snippet test (3.9)
  • GitHub Check: Snippet test (3.8)
  • GitHub Check: Integration test (3.8)
🔇 Additional comments (7)
xrpl/models/transactions/permissioned_domain_set.py (4)

1-15: LGTM!

The imports are well-organized and the constant is properly defined with a clear naming convention.


17-20: LGTM!

The class is well-defined with appropriate decorators enforcing immutability and keyword-only arguments.


22-34: LGTM!

The fields are well-documented and properly typed. The domain_id is correctly marked as optional, and the transaction_type is appropriately set as non-initializable.


36-53: LGTM!

The error handling is comprehensive, covering all necessary validations for the accepted_credentials list with clear error messages.

tests/unit/models/transactions/test_permissioned_domain_set.py (3)

26-44: LGTM!

The test effectively validates the maximum length constraint for accepted_credentials.


46-56: LGTM!

The test effectively validates that empty accepted_credentials lists are rejected.


58-76: LGTM!

The test effectively validates that duplicate credentials are rejected.

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: 1

🧹 Nitpick comments (2)
xrpl/models/transactions/permissioned_domain_delete.py (1)

19-20: Enhance the docstring.

The docstring should include more details about the transaction and its fields based on the specification.

Apply this diff to enhance the docstring:

-    """This transaction deletes a PermissionedDomain object."""
+    """
+    This transaction deletes a PermissionedDomain object from the ledger.
+    
+    Attributes:
+        domain_id: A 64-character hexadecimal string that uniquely identifies
+                  the PermissionedDomain object to be deleted.
+    """
tests/unit/models/transactions/test_permissioned_domain_delete.py (1)

9-9: Add test cases for edge cases.

Consider adding test cases for:

  • Empty domain_id
  • None domain_id

Apply this diff to add the test cases:

+    def test_domain_id_empty(self):
+        with self.assertRaises(XRPLModelException) as err:
+            PermissionedDomainDelete(
+                account=_ACCOUNT_1,
+                domain_id="",
+            )
+
+        self.assertEqual(
+            err.exception.args[0],
+            "{'PermissionedDomainDelete': 'domain_id must be 64 characters long.'}",
+        )
+
+    def test_domain_id_none(self):
+        with self.assertRaises(XRPLModelException) as err:
+            PermissionedDomainDelete(
+                account=_ACCOUNT_1,
+                domain_id=None,
+            )
+
+        self.assertEqual(
+            err.exception.args[0],
+            "{'PermissionedDomainDelete': 'domain_id must be 64 characters long.'}",
+        )
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39ec51e and 084d876.

📒 Files selected for processing (8)
  • CHANGELOG.md (2 hunks)
  • tests/integration/transactions/test_permissioned_domain.py (1 hunks)
  • tests/unit/models/transactions/test_permissioned_domain_delete.py (1 hunks)
  • tests/unit/models/transactions/test_permissioned_domain_set.py (1 hunks)
  • xrpl/core/binarycodec/definitions/definitions.json (5 hunks)
  • xrpl/models/transactions/__init__.py (2 hunks)
  • xrpl/models/transactions/permissioned_domain_delete.py (1 hunks)
  • xrpl/models/transactions/types/transaction_type.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • xrpl/models/transactions/init.py
  • xrpl/models/transactions/types/transaction_type.py
  • CHANGELOG.md
  • tests/unit/models/transactions/test_permissioned_domain_set.py
  • tests/integration/transactions/test_permissioned_domain.py
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: Integration test (3.13)
  • GitHub Check: Snippet test (3.13)
  • GitHub Check: Snippet test (3.12)
  • GitHub Check: Integration test (3.12)
  • GitHub Check: Snippet test (3.11)
  • GitHub Check: Integration test (3.11)
  • GitHub Check: Snippet test (3.10)
  • GitHub Check: Integration test (3.10)
  • GitHub Check: Snippet test (3.9)
  • GitHub Check: Integration test (3.9)
  • GitHub Check: Integration test (3.8)
  • GitHub Check: Snippet test (3.8)
🔇 Additional comments (3)
xrpl/models/transactions/permissioned_domain_delete.py (1)

1-14: LGTM!

The imports are appropriate and the regex pattern is correctly defined as a Final constant to match a 64-character hexadecimal string.

tests/unit/models/transactions/test_permissioned_domain_delete.py (1)

10-16: LGTM!

The test cases cover the basic validation scenarios with appropriate assertions.

xrpl/core/binarycodec/definitions/definitions.json (1)

1253-1262: LGTM!

The additions to the definitions file are well-structured and follow the existing patterns:

  • New fields DomainID and AcceptedCredentials are correctly defined with appropriate types and properties
  • New ledger entry type PermissionedDomain uses a valid unique number
  • New transaction types PermissionedDomainSet and PermissionedDomainDelete use valid unique numbers

Also applies to: 2543-2551, 2885-2885, 3118-3119

xrpl/models/transactions/permissioned_domain_delete.py Outdated Show resolved Hide resolved
ckeshava and others added 3 commits February 11, 2025 15:11
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
default=TransactionType.PERMISSIONED_DOMAIN_DELETE,
init=False,
)
"""The transaction type (PermissionedDomainDelete)."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we've done this in other transactions but makes sense to add it for transaction_type and not exclude it from all other class variables.

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 don't understand. What do you propose to add/remove/change in this snippet?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with this change. I was just noting that we haven't added docstrings to transaction_type variables before but I do think we may as well such that all class variables have docstrings.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes okay 👍
I felt we could add one for the sake of consistency

def _get_errors(self: Self) -> Dict[str, str]:
errors = super()._get_errors()

if len(self.domain_id) != 64:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should use a variable for this.

Suggested change
if len(self.domain_id) != 64:
if len(self.domain_id) != DOMAIN_ID_LENGTH:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

errors = super()._get_errors()

if len(self.domain_id) != 64:
errors["PermissionedDomainDelete"] = "domain_id must be 64 characters long."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
errors["PermissionedDomainDelete"] = "domain_id must be 64 characters long."
errors["PermissionedDomainDelete"] = "domain_id must be " + DOMAIN_ID_LENGTH + " characters long."

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would recommend this:

Suggested change
errors["PermissionedDomainDelete"] = "domain_id must be 64 characters long."
errors["PermissionedDomainDelete"] = f"domain_id must be {DOMAIN_ID_LENGTH} characters long."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that violates the maximum length rule, I'll update it in a slightly different way

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yes, I agree :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ckeshava ckeshava requested review from khancode and mvadari February 12, 2025 18:42
Comment on lines 30 to 32
"{'PermissionedDomainDelete': 'domain_id must be "
+ str(DOMAIN_ID_LENGTH)
+ " characters long.'}",
Copy link
Collaborator

@khancode khancode Feb 12, 2025

Choose a reason for hiding this comment

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

You can still use what @mvadari recommended:

Suggested change
"{'PermissionedDomainDelete': 'domain_id must be "
+ str(DOMAIN_ID_LENGTH)
+ " characters long.'}",
"{'PermissionedDomainDelete': 'domain_id must be "
f"{DOMAIN_ID_LENGTH} characters long.'}}",

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

how is this better than what I already have in the code?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't think it's cleaner? f-strings are generally considered the best practice for string interpolation. It's why we also use them in the codebase too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok
8206d73

Comment on lines 45 to 47
"{'PermissionedDomainDelete': 'domain_id must be "
+ str(DOMAIN_ID_LENGTH)
+ " characters long.'}",
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

how is this better than what I already have in the code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ckeshava ckeshava requested a review from khancode February 12, 2025 21:33
@ckeshava
Copy link
Collaborator Author

thank you for all the reviews.

@ckeshava ckeshava merged commit 7af0ca8 into XRPLF:main Feb 12, 2025
22 checks passed
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.

5 participants