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

Deep Freeze XLS-77d #2873

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Deep Freeze XLS-77d #2873

wants to merge 8 commits into from

Conversation

ckeshava
Copy link
Collaborator

@ckeshava ckeshava commented Jan 7, 2025

High Level Overview of Change

This PR implements the Deep-Freeze spec: XRPLF/XRPL-Standards#220

CPP implementation: https://github.com/XRPLF/rippled/pull/5187/files#

Note: Please do not merge this PR until the CPP implementation is merged into the develop branch of rippled.

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

New integration tests have been added to validate the Deep-Freeze behavior. Unit tests have been modified to incorporate deep-frozen trust lines.

Future Tasks

Once the behavior of Checks is better understood with the deep-frozen trust lines, additional integration tests can be added. However, they introduce non-trivial complexity in the code. Furthermore, such tests are already covered by the cpp implementaion.

…t transaction

integration test for OfferCreate txn (negative case)

update to the unit test of TrustSet transaction
Copy link

coderabbitai bot commented Jan 7, 2025

Warning

Rate limit exceeded

@ckeshava has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 25 minutes and 33 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between bb1463b and 369df85.

📒 Files selected for processing (3)
  • packages/xrpl/HISTORY.md (1 hunks)
  • packages/xrpl/src/models/transactions/trustSet.ts (2 hunks)
  • packages/xrpl/test/integration/transactions/trustSet.test.ts (2 hunks)

Walkthrough

This pull request introduces support for the XLS-77d Deep-Freeze amendment in the XRPL ecosystem. The changes span multiple files across the xrpl.js library, adding new flags and configurations related to deep-freezing trust lines. Modifications include updating the configuration file, extending enum definitions with new flags, and adding test cases to verify the new deep-freeze functionality. The implementation allows for setting and clearing deep-freeze states on trust lines, which restricts sending and receiving of specified issued currencies.

Changes

File Change Summary
.ci-config/rippled.cfg Added DeepFreeze amendment to [features] section; commented out some port and SSL configurations.
packages/xrpl/HISTORY.md Added "Support for XLS-77d Deep-Freeze amendment" under Unreleased Changes.
packages/xrpl/src/models/ledger/RippleState.ts Added lsfLowDeepFreeze and lsfHighDeepFreeze flags to RippleStateFlags enum.
packages/xrpl/src/models/transactions/trustSet.ts Added tfSetDeepFreeze and tfClearDeepFreeze flags to TrustSetFlags enum; added optional properties to TrustSetFlagsInterface.
packages/xrpl/test/... Added integration tests for deep-freeze functionality in offerCreate.test.ts and trustSet.test.ts; updated trustSet.test.ts to include new flags in the trustSet object.

Possibly Related PRs

Suggested Reviewers

  • mvadari

Poem

🐰 A Rabbit's Deep-Freeze Delight
In the realm of trust and token's might,
Deep-freeze flags now take their flight,
Transactions locked, no currency's sway,
A rabbit's magic keeps risks at bay!
🧊✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

Copy link

@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: 3

🧹 Nitpick comments (5)
packages/xrpl/src/models/ledger/RippleState.ts (1)

80-83: Add documentation comments for the new deep freeze flags.

The new flags would benefit from detailed documentation comments explaining their purpose and behavior, similar to other flags in the enum.

  // True, trust line to AMM. Used by client apps to identify payments via AMM.
  lsfAMMNode = 0x01000000,
-  // True, low side has set deep freeze flag
+  /**
+   * True if the low side has set the deep freeze flag.
+   * When set, this flag permanently freezes the trust line until explicitly cleared.
+   */
  lsfLowDeepFreeze = 0x02000000,
-  // True, high side has set deep freeze flag
+  /**
+   * True if the high side has set the deep freeze flag.
+   * When set, this flag permanently freezes the trust line until explicitly cleared.
+   */
  lsfHighDeepFreeze = 0x04000000,
packages/xrpl/test/models/trustSet.test.ts (1)

25-29: Enhance test coverage for deep freeze flags.

The test suite would benefit from additional test cases:

  1. Testing the tfClearDeepFreeze flag
  2. Negative test cases for invalid flag combinations
  3. Validation of flag values
// Example additional test cases:
it('throws when setting both tfSetDeepFreeze and tfClearDeepFreeze', function () {
  trustSet.Flags = {
    tfSetDeepFreeze: true,
    tfClearDeepFreeze: true,
  }
  assert.throws(
    () => validateTrustSet(trustSet),
    ValidationError,
    'TrustSet: cannot set and clear deep freeze simultaneously',
  )
})

it('verifies clearing of deep freeze', function () {
  trustSet.Flags = {
    tfClearDeepFreeze: true,
  }
  assert.doesNotThrow(() => validateTrustSet(trustSet))
})
packages/xrpl/test/integration/transactions/offerCreate.test.ts (1)

62-108: Enhance test coverage for deep-frozen trust line scenarios.

While the test verifies basic blocking behavior, consider adding test cases for:

  1. Attempting to modify an existing offer after deep-freezing
  2. Testing with different combinations of freeze flags (regular freeze vs deep freeze)
  3. Testing behavior when only one side of the trust line is deep-frozen

Also, consider extracting the trust line setup into a helper function to improve test readability and reusability:

async function setupDeepFrozenTrustLine(
  testContext: XrplIntegrationTestContext,
  counterparty: Wallet,
  currency: string = 'USD',
  value: string = '10',
): Promise<void> {
  const trust_set_tx: TrustSet = {
    TransactionType: 'TrustSet',
    Account: testContext.wallet.classicAddress,
    LimitAmount: {
      currency,
      issuer: counterparty.classicAddress,
      value,
    },
    Flags: {
      tfSetFreeze: true,
      tfSetDeepFreeze: true,
    },
  }
  await testTransaction(testContext.client, trust_set_tx, testContext.wallet)
}
packages/xrpl/src/models/transactions/trustSet.ts (2)

33-34: Fix typo in documentation comment

There's a typo in the comment: "recieving" should be "receiving".

-  /** Deep-Freeze the trust line -- disallow sending and recieving the said IssuedCurrency */
+  /** Deep-Freeze the trust line -- disallow sending and receiving the said IssuedCurrency */

96-99: Document interaction with regular freeze flags

The documentation should clarify how deep-freeze flags interact with regular freeze flags (tfSetFreeze/tfClearFreeze). This helps developers understand the precedence and combined effects.

Add a note in the documentation:

   /** Deep-Freeze the trust line -- disallow sending and receiving the said IssuedCurrency */
   tfSetDeepFreeze?: boolean
   /** Clear a Deep-Frozen trust line */
   tfClearDeepFreeze?: boolean
+  /**
+   * Note: Deep-freeze takes precedence over regular freeze. When a trust line is
+   * deep-frozen, the regular freeze state has no effect until the deep-freeze is cleared.
+   */
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 84943ae and 1d897a4.

📒 Files selected for processing (7)
  • .ci-config/rippled.cfg (1 hunks)
  • packages/xrpl/HISTORY.md (1 hunks)
  • packages/xrpl/src/models/ledger/RippleState.ts (1 hunks)
  • packages/xrpl/src/models/transactions/trustSet.ts (2 hunks)
  • packages/xrpl/test/integration/transactions/offerCreate.test.ts (2 hunks)
  • packages/xrpl/test/integration/transactions/trustSet.test.ts (1 hunks)
  • packages/xrpl/test/models/trustSet.test.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/xrpl/HISTORY.md
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: integration (22.x)
  • GitHub Check: snippets (22.x)
  • GitHub Check: unit (18.x)
  • GitHub Check: integration (20.x)
  • GitHub Check: snippets (20.x)
  • GitHub Check: integration (18.x)
  • GitHub Check: browser (18.x)
  • GitHub Check: snippets (18.x)
🔇 Additional comments (2)
.ci-config/rippled.cfg (1)

191-191: Verify amendment dependency with C++ implementation

The PR objectives state that this PR should not be merged until the C++ implementation is integrated into the rippled project. We should ensure that enabling the DeepFreeze amendment here is safe and won't cause issues if the C++ implementation isn't ready.

Run this script to check the amendment status in rippled:

packages/xrpl/src/models/transactions/trustSet.ts (1)

33-36: Verify bit flag values with rippled implementation

The bit flag values (0x00400000 and 0x00800000) for deep-freeze must match the C++ implementation in rippled.

Run this script to verify the flag values:

Also applies to: 96-99

✅ Verification successful

Deep-freeze flag values are correctly implemented

The values 0x00400000 (tfSetDeepFreeze) and 0x00800000 (tfClearDeepFreeze) are correctly implemented as part of the XLS-77d Deep-Freeze amendment. These values are consistently used across the codebase and validated through integration tests. While these bit positions are reused in other transaction and ledger entry types, this is a common practice in XRPL as each type maintains its own separate flag namespace.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify deep-freeze flag values match rippled implementation

# Check flag definitions in rippled
gh api repos/ripple/rippled/contents/src/ripple/protocol/TxFlags.h -q '.content' | base64 -d | grep -A 5 "tfSetDeepFreeze"

Length of output: 217


Script:

#!/bin/bash
# Try multiple approaches to verify the flag values

# 1. Fetch rippled implementation using curl
curl -s https://raw.githubusercontent.com/ripple/rippled/develop/src/ripple/protocol/TxFlags.h | grep -A 5 "tfSetDeepFreeze"

# 2. Search for tests or documentation about these flags
rg -i "deep.*freeze" -A 5 -B 5

# 3. Look for any validation of these specific hex values
rg "0x00400000|0x00800000" -A 2 -B 2

Length of output: 12337


Script:

#!/bin/bash
# Look for XLS-77d documentation and specs
rg -i "XLS-77d|deep.?freeze" --type md

# Check if there are any conflicting uses of these specific values
rg "0x00400000|0x00800000" --type ts --context 3

Length of output: 3790

Comment on lines 89 to 128
it(
'Create a Deep-Frozen trust line',
async () => {
assert(wallet2 != null)
// preemptively deep-freeze a trust line with the specified counter-party/currency-code
const tx: TrustSet = {
TransactionType: 'TrustSet',
Account: testContext.wallet.classicAddress,
LimitAmount: {
currency: 'USD',
issuer: wallet2.classicAddress,
value: '10',
},
Flags: {
tfSetFreeze: true,
tfSetDeepFreeze: true,
},
}

const response = await testTransaction(
testContext.client,
tx,
testContext.wallet,
)
assert.equal(response.result.engine_result, 'tesSUCCESS')

// assert that the trust line is deep-frozen
const trustLine = await testContext.client.request({
command: 'account_lines',
account: testContext.wallet.classicAddress,
})

// assert that the TrustLine is deep-frozen
assert.equal(trustLine.result.lines[0].freeze, true)

// Keshava: ensure that account_lines RPC response contains a deep_freeze flag
// assert.equal(trustLine.result.lines[0].deep_freeze, true)
},
TIMEOUT,
)
Copy link

@coderabbitai coderabbitai bot Jan 7, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add test cases for high/low side deep freeze behavior.

The test suite should verify:

  1. Deep freeze behavior from both high and low sides of the trust line
  2. Interaction between regular freeze and deep freeze
  3. Clearing of deep freeze flags
it('Deep freeze from high side', async () => {
  // Similar test but with wallet2 setting the deep freeze
})

it('Clear deep freeze', async () => {
  // Test clearing the deep freeze flag
})

it('Interaction between regular and deep freeze', async () => {
  // Test combinations of regular and deep freeze flags
})

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

these cases are covered by the cpp tests. they are not required in this repository

Copy link

Choose a reason for hiding this comment

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

@ckeshava Understood, thanks for clarifying that these test cases are already covered in the C++ implementation.


✏️ Learnings added
Learnt from: ckeshava
PR: XRPLF/xrpl.js#2873
File: packages/xrpl/test/integration/transactions/trustSet.test.ts:0-0
Timestamp: 2025-01-31T17:46:25.234Z
Learning: For the XRPL implementation, extensive test cases for deep freeze behavior (high/low side interactions, clearing flags, etc.) are maintained in the C++ implementation and don't need to be duplicated in the JavaScript implementation.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Comment on lines 124 to 125
// Keshava: ensure that account_lines RPC response contains a deep_freeze flag
// assert.equal(trustLine.result.lines[0].deep_freeze, true)
Copy link

@coderabbitai coderabbitai bot Jan 7, 2025

Choose a reason for hiding this comment

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

💡 Codebase verification

Remove the commented deep_freeze assertion

The deep_freeze flag is not part of the XRPL account_lines API. The trust line freeze functionality is handled by the documented freeze and freeze_peer flags. This commented assertion should be removed as it references a non-existent feature.

🔗 Analysis chain

Clarify the status of the commented assertion.

The commented assertion suggests that the deep_freeze flag in the account_lines RPC response might be pending implementation. This should be either:

  1. Implemented and uncommented if the feature is ready
  2. Removed if the feature is not planned
  3. Converted to a TODO comment with a clear explanation if it's pending
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if deep_freeze flag is implemented in account_lines RPC
rg -A 5 "deep_freeze.*account_lines"

Length of output: 38


Script:

#!/bin/bash
# Search for deep_freeze usage in the codebase
rg "deep_freeze" -B 2 -A 2

# Search for account_lines test assertions
rg "account_lines.*assert" -B 2 -A 2

# Check documentation or type definitions for account_lines
fd "account.*lines" --type f --exec cat {}

Length of output: 83376

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed in c9ecd33

Copy link

Choose a reason for hiding this comment

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

@ckeshava Thank you for fixing this! The changes look good, and I appreciate the addition of proper deep-freeze verification using the account_objects RPC.

🔗 Analysis chain
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Fetch the specific commit changes
git show c9ecd33eb88848d25d1dca2a24c5270ac356cb04

Length of output: 3745


If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!

Comment on lines 33 to 36
/** Deep-Freeze the trust line -- disallow sending and recieving the said IssuedCurrency */
tfSetDeepFreeze = 0x00400000,
/** Clear a Deep-Frozen trust line */
tfClearDeepFreeze = 0x00800000,
Copy link

@coderabbitai coderabbitai bot Jan 7, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adding validation for mutually exclusive flags

The deep-freeze flags (tfSetDeepFreeze and tfClearDeepFreeze) are mutually exclusive, similar to the existing freeze flags. Consider adding validation to prevent setting both flags simultaneously.

Here's a suggested implementation:

function validateTrustSet(tx: Record<string, unknown>): void {
  // ... existing validation ...
  
  if (typeof tx.Flags === 'object') {
    const flags = tx.Flags as TrustSetFlagsInterface
    if (flags.tfSetDeepFreeze && flags.tfClearDeepFreeze) {
      throw new ValidationError(
        'TrustSet: cannot set both tfSetDeepFreeze and tfClearDeepFreeze flags',
      )
    }
  }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

there are many validation rules associated with the flags of trust-set transaction. It is not informative if certain rules are cherry-picked for implementation

Copy link

Choose a reason for hiding this comment

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

@ckeshava Understood, I'll retract the suggestion. You make a valid point about the importance of comprehensive validation rather than selective implementation.


✏️ Learnings added
Learnt from: ckeshava
PR: XRPLF/xrpl.js#2873
File: packages/xrpl/src/models/transactions/trustSet.ts:33-36
Timestamp: 2025-01-08T13:08:52.450Z
Learning: For trust-set transactions in XRPL, validation rules for flags should be implemented comprehensively rather than cherry-picking specific rules, as there are many interdependent validation rules associated with these flags.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd actually agree with this one, seems like an important check we should add. We aren't responsible for core logic like determining if a trustline is frozen before deep freezing, but surface level checks should be handled here to best catch invalid transactions like this

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@achowdhry-ripple I'm not entirely convinced that this is a feasible suggestion. There are many combination of invalid flags. For instance: tfSetDeepFreeze | tfClearFreeze, tfSetFreeze | tfClearDeepFreeze ... 2 more such combinations.

We would need to enumerate all such possibilities (the above is not an exhaustive list). It also necessitates defining a mask of valid flags for easier validation.

This task goes out of scope of the current PR and would be a repetition of the cpp code.

@ckeshava
Copy link
Collaborator Author

ckeshava commented Jan 8, 2025

@shawnxie999 If you have any free time, please review this PR

@shawnxie999
Copy link
Collaborator

just a heads up I'll only be able to start reviewing this PR end of next week - if that's fine with you. doesn't want to be a blocker if this PR is urgent

@ckeshava
Copy link
Collaborator Author

ckeshava commented Jan 9, 2025

just a heads up I'll only be able to start reviewing this PR end of next week - if that's fine with you. doesn't want to be a blocker if this PR is urgent

no worries, that is fine

@ckeshava ckeshava requested review from khancode and mvadari January 13, 2025 17:32
Comment on lines +97 to +99
tfSetDeepFreeze?: boolean
/** Clear a Deep-Frozen trust line */
tfClearDeepFreeze?: boolean
Copy link
Collaborator

Choose a reason for hiding this comment

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

could also possibly add a validation check that tfSetDeepFreeze and tfClearDeepFreeze should not be set in the same transaction? And possibly add a unit test for this.

unrelated to this PR, but a similar validation can be added for tfSetFreeze and tfClearFreeze to make sure they aren't set at the same time (and a unit test).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, in the worst case, erring users will be greeted with a temINVALID_FLAG error here: https://github.com/XRPLF/rippled/blob/1b75dc8bcd536ff09a4d96064725c016e0df7293/src/xrpld/app/tx/detail/SetTrust.cpp#L42 (Users do not lose any transaction fees)

I have elaborated here as well: #2873 (comment)

We will need to replicate the tfTrustSetMask variable to do a complete validation. It feels a bit of an overkill.

packages/xrpl/test/models/trustSet.test.ts Outdated Show resolved Hide resolved
packages/xrpl/src/models/transactions/trustSet.ts Outdated Show resolved Hide resolved
Co-authored-by: Shawn Xie <35279399+shawnxie999@users.noreply.github.com>
Copy link

@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 (3)
packages/xrpl/test/integration/transactions/offerCreate.test.ts (3)

21-21: Consider renaming the wallet variable for clarity.

Based on the past review comments, consider renaming wallet_deep_freeze_trustline to be more specific about its purpose, e.g., deepFreezeTestWallet.

Also applies to: 25-30


26-26: Document the ESLint disable comment.

Please add a more detailed explanation for disabling the require-atomic-updates rule. While you mentioned that the race condition doesn't matter, it would be helpful to explain why it's safe to ignore in this context.


65-111: Enhance test coverage and documentation.

The test case is well-structured, but consider these improvements:

  1. Add JSDoc comments to document the test scenario and expected behavior
  2. Add assertions to verify the trust line state after setting the deep-freeze
  3. Consider adding cleanup code to reset the trust line state after the test

Here's an example of how to enhance the test:

+  /**
+   * Verifies that OfferCreate transactions fail when using a deep-frozen trust line.
+   * 
+   * Steps:
+   * 1. Set up a trust line with deep-freeze flags
+   * 2. Verify the trust line state
+   * 3. Attempt to create an offer using the frozen trust line
+   * 4. Verify the transaction fails with tecFROZEN
+   * 5. Clean up the trust line state
+   */
   it(
     'OfferCreate with Deep-Frozen trustline must fail',
     async () => {
       assert(wallet_deep_freeze_trustline != null)

       // deep-freeze the trust line
       const trust_set_tx: TrustSet = {
         // ... existing code ...
       }

       await testTransaction(
         testContext.client,
         trust_set_tx,
         testContext.wallet,
       )

+      // Verify trust line state
+      const accountLines = await testContext.client.request({
+        command: 'account_lines',
+        account: testContext.wallet.classicAddress,
+        peer: wallet_deep_freeze_trustline.classicAddress,
+      })
+      assert.isTrue(
+        accountLines.result.lines?.[0].freeze,
+        'Trust line should be frozen',
+      )
+      assert.isTrue(
+        accountLines.result.lines?.[0].deep_freeze,
+        'Trust line should be deep-frozen',
+      )

       const offer_create_tx: OfferCreate = {
         // ... existing code ...
       }

       const response = await submitTransaction({
         // ... existing code ...
       })

       assert.equal(response.result.engine_result, 'tecFROZEN')

+      // Clean up: Clear the deep-freeze state
+      await testTransaction(
+        testContext.client,
+        {
+          ...trust_set_tx,
+          Flags: {
+            tfClearFreeze: true,
+          },
+        },
+        testContext.wallet,
+      )
     },
     TIMEOUT,
   )
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1d897a4 and bb1463b.

📒 Files selected for processing (3)
  • packages/xrpl/test/integration/transactions/offerCreate.test.ts (2 hunks)
  • packages/xrpl/test/integration/transactions/trustSet.test.ts (1 hunks)
  • packages/xrpl/test/models/trustSet.test.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/xrpl/test/models/trustSet.test.ts
  • packages/xrpl/test/integration/transactions/trustSet.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: unit (22.x)
  • GitHub Check: integration (22.x)
  • GitHub Check: unit (20.x)
  • GitHub Check: snippets (22.x)
  • GitHub Check: integration (20.x)
  • GitHub Check: unit (18.x)
  • GitHub Check: snippets (20.x)
  • GitHub Check: integration (18.x)
  • GitHub Check: snippets (18.x)
  • GitHub Check: browser (18.x)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/xrpl/test/integration/transactions/offerCreate.test.ts (1)

3-3: LGTM! Import statements are well-organized.

The new imports are correctly structured and necessary for implementing the deep-freeze functionality.

Also applies to: 10-14

ckeshava and others added 5 commits January 31, 2025 09:43
Co-authored-by: Shawn Xie <35279399+shawnxie999@users.noreply.github.com>
Co-authored-by: Shawn Xie <35279399+shawnxie999@users.noreply.github.com>
Co-authored-by: Shawn Xie <35279399+shawnxie999@users.noreply.github.com>
@ckeshava ckeshava requested a review from shawnxie999 January 31, 2025 17:47
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