Skip to content

fix: Expand the pathing tables and lower weight on sabbxd, also return up to 6 paths - #6507

Closed
shortthefomo wants to merge 32 commits into
XRPLF:developfrom
shortthefomo:pathing-fix-nonXRP-to-XRP
Closed

fix: Expand the pathing tables and lower weight on sabbxd, also return up to 6 paths#6507
shortthefomo wants to merge 32 commits into
XRPLF:developfrom
shortthefomo:pathing-fix-nonXRP-to-XRP

Conversation

@shortthefomo

@shortthefomo shortthefomo commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Expanded the pt_nonXRP_to_XRP template set by adding 1 new route pattern:
sabbxd (cost 8)

Adjust sabbxd to a lower weight as it is needed for valid result set past X -> XRP
sabxd (cost 5)

High Level Overview of Change

This change updates Pathfinder::initPathTable() to expand nonXRP→XRP path exploration by adding three additional non-default template patterns in pt_nonXRP_to_XRP:

  • sabxd
  • sabbxd

These templates add deeper order-book traversal options for nonXRP→XRP pathfinding when shorter templates do not produce fillable routes.

PRE PATCH result
Screenshot 2026-03-09 at 1 19 58 PM

POST PATCH result
Screenshot 2026-03-11 at 19 33 00

As well max_paths_ ceiling was increased to 5 so that a maximum of 6 paths can be returned as that's the limit payments accept. There is little to no performance change for this.

Context of Change

We observed asymmetric route discovery between forward and inverse directions in some markets, where nonXRP→XRP requests could miss viable liquidity that existed behind deeper book chains.

The existing table-driven architecture in initPathTable() is cost-gated by search depth, so the least invasive fix was to add targeted path templates rather than changing core ranking or liquidity evaluation logic. This keeps behavior predictable while broadening candidate generation.

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)

Before / After

Before:

  • nonXRP→XRP path templates were limited to shorter and mid-depth forms (sxd, saxd, saaxd, sbxd, sabxd, sabaxd).
  • Some requests failed to surface fillable routes despite liquidity reachable through extra book hops.
  • Running pathing on a aggressiveness of 8 to return paths other than X -> XRP was incorrect.

After:

  • Moved sabxd to 5 from 8:
    • {5, "sabxd"}
  • Added deeper non-default nonXRP→XRP template:
    • {8, "sabbxd"}
  • Path discovery considers additional order-book-chain candidates at configured search depth.

@shortthefomo shortthefomo changed the title expand the pathing tables to look at different routes, also return up to 6 paths fix: expand the pathing tables to look at different routes, also return up to 6 paths Mar 9, 2026
@codecov

codecov Bot commented Mar 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.9%. Comparing base (1ee0567) to head (ebe963f).
⚠️ Report is 25 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #6507   +/-   ##
=======================================
  Coverage     79.8%   79.9%           
=======================================
  Files          861     878   +17     
  Lines        67857   67889   +32     
  Branches      7553    7537   -16     
=======================================
+ Hits         54169   54223   +54     
+ Misses       13688   13666   -22     
Files with missing lines Coverage Δ
src/xrpld/app/paths/Pathfinder.cpp 90.7% <ø> (+1.5%) ⬆️

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

@shortthefomo shortthefomo changed the title fix: expand the pathing tables to look at different routes, also return up to 6 paths fix: Expand the pathing tables to look at different routes, also return up to 6 paths Mar 10, 2026

Copilot AI 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.

Pull request overview

This PR aims to improve pathfinding results by (1) expanding the nonXRP→XRP path template table used by Pathfinder::initPathTable() and (2) increasing the maximum number of paths returned in ripple_path_find responses (aligned with Payment’s accepted path limit).

Changes:

  • Extends pt_nonXRP_to_XRP templates to explore deeper book-chains.
  • Increases PathRequest’s path cap used for ranking/selection to allow up to 6 paths in responses when the optional fullLiquidityPath is appended.

Reviewed changes

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

File Description
src/xrpld/app/paths/Pathfinder.cpp Modifies the nonXRP→XRP path template list and associated search-level costs.
src/xrpld/app/paths/PathRequest.h Adjusts the internal max-paths cap used to compute/select paths for pathfind responses.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/xrpld/rpc/detail/Pathfinder.cpp
Comment thread src/xrpld/app/paths/PathRequest.h Outdated
Comment thread src/xrpld/app/paths/PathRequest.h Outdated
Comment thread src/xrpld/rpc/detail/Pathfinder.cpp
@shortthefomo shortthefomo changed the title fix: Expand the pathing tables to look at different routes, also return up to 6 paths fix: Expand the pathing tables and lower weight on sabbxd, also return up to 6 paths Mar 11, 2026
Comment thread src/test/app/Path_test.cpp Outdated
Comment thread src/test/app/Path_test.cpp
@mvadari

mvadari commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

/ai-review

@github-actions

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

@github-actions

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@shortthefomo
shortthefomo force-pushed the pathing-fix-nonXRP-to-XRP branch from c76994e to 630fa6b Compare April 3, 2026 19:06
@shortthefomo
shortthefomo force-pushed the pathing-fix-nonXRP-to-XRP branch from 4ee8bca to 936a694 Compare April 14, 2026 02:46
@github-actions

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

@godexsoft

Copy link
Copy Markdown
Contributor

We recently merged a refactor to develop that enables clang-tidy's readability-identifier-naming. Your branch now has heavy conflicts that are largely mechanical. Below is a workflow that aligns your branch's naming with develop before merging, which should minimize the merge conflicts.

One-time setup

If you don't already have clang-tidy working in your env, on macOS:

brew install llvm@21
# Follow brew's hint to put $(brew --prefix llvm@21)/bin on PATH so run-clang-tidy is found.

Workflow on your branch (before merging develop)

1. Grab the new .clang-tidy from develop without pulling anything else. Sync your fork on GitHub first, then:

git remote -v   # should show 'upstream' among others; if not:
# git remote set-url upstream git@github.com:XRPLF/rippled.git
git fetch upstream
git checkout upstream/develop -- .clang-tidy

2. Reconfigure conan/cmake so compile_commands.json is fresh.

3. Apply renames for the files modified in your PR:

git diff --name-only $(git merge-base HEAD upstream/develop) HEAD \
  | grep -E '\.(cpp|h|hpp|ipp)$' \
  | xargs run-clang-tidy -p build -fix -allow-no-checks
# or -p .build, or whatever your build dir is called

4. Build + test, then commit as a single dedicated commit:

cmake --build build -j8
git commit -am "refactor: Align identifier naming with develop"

5. Now merge develop:

git merge upstream/develop

Extra

Run clang-tidy once more after the merge to catch any stragglers introduced from develop's side:

run-clang-tidy -p build -fix -allow-no-checks src tests
# or -p .build, or whatever your build dir is called

@github-actions

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@github-actions

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

@github-actions

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@shortthefomo

Copy link
Copy Markdown
Contributor Author

no longer needed with #7392

@shortthefomo
shortthefomo deleted the pathing-fix-nonXRP-to-XRP branch June 11, 2026 14:54
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