Skip to content

fix: make submitAndWait fail faster with tem errors #2948

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

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

Conversation

mvadari
Copy link
Collaborator

@mvadari mvadari commented Mar 26, 2025

High Level Overview of Change

Title says it all. tem errors will never be validated on the XRPL, so no need to wait to see if they will. This will save a lot of waiting time on any tem errors.

Context of Change

Takes inspiration from XRPLF/xrpl-py#379 and XRPLF/xrpl-py#590 (which was for some reason not implemented in JS at the time)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Did you update HISTORY.md?

  • Yes

Test Plan

Added a test. CI passes.

@mvadari mvadari requested review from Copilot and khancode March 26, 2025 20:35
Copy link

coderabbitai bot commented Mar 26, 2025

Walkthrough

The PR updates several key components in the XRPL package. In the HISTORY file, an entry now documents that the submitAndWait function fails faster on tem errors. The Client class in the main source now includes a single simulate method and improved error handling in submitAndWait. Additionally, a dedicated test suite and fixture updates (including a new JSON response file) have been added to simulate and verify the behavior of tem errors during transaction submissions.

Changes

Files Change Summary
packages/xrpl/HISTORY.md Updated changelog entry to "Improve faucet support" and added note that submitAndWait now fails faster on tem errors.
packages/xrpl/src/client/index.ts Removed duplicate simulate method, retained single async simulate method; enhanced submitAndWait with error handling that throws XrplError on tem errors; updated method docs.
packages/xrpl/test/client/submitAndWait.test.ts Added new test suite verifying submitAndWait early exit behavior on transactions resulting in tem errors.
packages/xrpl/test/fixtures/rippled/index.ts, packages/xrpl/test/fixtures/rippled/submitTemError.json Added new temError property to fixtures referencing new submitTemError.json file simulating a malformed transaction submission error.

Possibly related PRs

  • feat: add support for the simulate RPC (XLS-69d) #2867: The changes in the main PR enhance the error handling of the submitAndWait function, while the retrieved PR introduces a new simulate method in the Client class, which also modifies the submitAndWait method's error handling; thus, they are related at the code level.

Suggested reviewers

  • khancode
  • ckeshava

Poem

I'm a little rabbit, hopping through code,
Finding bugs and errors wherever they showed.
Now submitAndWait is quick to paw,
With simulate in play, we marvel in awe.
Happy hops and ASCII cheers, note this fun mode!
🐰💻

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 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.1.0', 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.1.0', 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-06-08T10_00_16_305Z-debug-0.log


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6df1448 and d5e630c.

📒 Files selected for processing (2)
  • packages/xrpl/HISTORY.md (1 hunks)
  • packages/xrpl/src/client/index.ts (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/xrpl/HISTORY.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/xrpl/src/client/index.ts
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: unit (22.x)
  • GitHub Check: browser (22.x)
  • GitHub Check: unit (20.x)
  • GitHub Check: integration (22.x)
  • GitHub Check: integration (20.x)
  • GitHub Check: build-and-lint (22.x)
  • GitHub Check: Analyze (javascript)
✨ 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.

@mvadari mvadari requested a review from ckeshava March 26, 2025 20:35
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that transactions resulting in tem errors fail fast in submitAndWait, reducing unnecessary wait times.

  • Introduces an early error check in submitAndWait for tem errors.
  • Adds a new test case using a tem error fixture to verify the fast failure behavior.
  • Updates HISTORY.md to document the change.

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

File Description
packages/xrpl/test/fixtures/rippled/index.ts Added tem error fixture to support the tem error test.
packages/xrpl/test/client/submitAndWait.test.ts Added test case to assert that submitAndWait fails fast with tem errors.
packages/xrpl/src/client/index.ts Introduced simulate() method and updated submitAndWait to throw on tem errors.
packages/xrpl/HISTORY.md Updated changelog with a note on failing faster for tem errors.
Files not reviewed (1)
  • packages/xrpl/test/fixtures/rippled/submitTemError.json: Language not supported
Comments suppressed due to low confidence (2)

packages/xrpl/src/client/index.ts:847

  • [nitpick] The function is named submitAndWait, so the comment might be clearer if it referenced submitAndWait rather than submit.
* This is similar to submit, which does all of the above, but also waits to see if the transaction has been validated.

packages/xrpl/src/client/index.ts:740

  • The new simulate() method does not have any test coverage. Consider adding tests to ensure its behavior is correct.
public async simulate<Binary extends boolean = false>(

@@ -720,6 +720,41 @@ class Client extends EventEmitter<EventTypes> {
return Promise.all(promises).then(() => tx)
}

/**
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is just moved, no code change

@@ -0,0 +1,44 @@
import { XrplError } from '../../src'
Copy link
Collaborator

Choose a reason for hiding this comment

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

This file (packages/xrpl/test/integration/submitAndWait.test.ts) is also relevant for adding this test case. Why did you create a new file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's easier to test this sort of thing with a unit test where I can control the fixture as opposed to with an integration test.

@mvadari mvadari requested a review from ckeshava May 27, 2025 15:49
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.

3 participants