Skip to content

fix: Add zero domainID check for permissionedDomain#7362

Merged
bthomee merged 5 commits into
XRPLF:developfrom
yinyiqian1:fix-zero-domain
May 30, 2026
Merged

fix: Add zero domainID check for permissionedDomain#7362
bthomee merged 5 commits into
XRPLF:developfrom
yinyiqian1:fix-zero-domain

Conversation

@yinyiqian1
Copy link
Copy Markdown
Collaborator

@yinyiqian1 yinyiqian1 commented May 29, 2026

Because Ledger::read() asserts on zero keys, view.read(keylet::permissionedDomain(domainID)) must only be called with a non-zero domainID. This PR adds guarded validation for zero DomainID in OfferCreate and Payment, plus a defensive check in permissioned_dex::accountInDomain().
Although the asserts are only triggered in debug build, it is still worth adding the defensive check.

  • Add preflight checks for OfferCreate and Payment so a zero DomainID returns temMALFORMED.
  • Add check in permissioned_dex::accountInDomain() to avoid constructing a zero-key PermissionedDomain keylet.
  • The changes are guarded by fixCleanup3_2_0

High Level Overview of Change

Context of Change

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)

Comment thread src/libxrpl/ledger/helpers/PermissionedDEXHelpers.cpp
Comment thread src/libxrpl/ledger/helpers/PermissionedDEXHelpers.cpp
Copy link
Copy Markdown
Contributor

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 hardens Permissioned DEX DomainID handling to prevent Ledger::read() from being called with a zero key (which triggers UNREACHABLE in assert-enabled builds). It adds preflight validation to reject a zero sfDomainID on OfferCreate and Payment, and adds a defensive guard in permissioned_dex::accountInDomain(), all gated by fixCleanup3_2_0.

Changes:

  • Add temMALFORMED preflight rejection when sfDomainID == 0 for OfferCreate and Payment (when fixCleanup3_2_0 is enabled).
  • Add a defensive early-return in permissioned_dex::accountInDomain() to avoid constructing a zero-key PermissionedDomain keylet.
  • Extend PermissionedDEX_test coverage to assert temMALFORMED for zero DomainID, and run relevant tests both with and without fixCleanup3_2_0.

Reviewed changes

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

File Description
src/test/app/PermissionedDEX_test.cpp Adds regression tests for zero DomainID preflight behavior and runs OfferCreate/Payment tests with/without fixCleanup3_2_0.
src/libxrpl/tx/transactors/payment/Payment.cpp Rejects sfDomainID == 0 as temMALFORMED in preflight (gated by fixCleanup3_2_0).
src/libxrpl/tx/transactors/dex/OfferCreate.cpp Rejects sfDomainID == 0 as temMALFORMED in preflight (gated by fixCleanup3_2_0).
src/libxrpl/ledger/helpers/PermissionedDEXHelpers.cpp Adds a defensive check to avoid view.read(keylet::permissionedDomain(0)) (gated by fixCleanup3_2_0).

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

@kennyzlei kennyzlei requested a review from Kassaking7 May 29, 2026 18:59
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.4%. Comparing base (2f3558c) to head (fd8b3a5).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #7362     +/-   ##
=========================================
- Coverage     82.4%   82.4%   -0.0%     
=========================================
  Files         1011    1011             
  Lines        76477   76484      +7     
  Branches      7322    7316      -6     
=========================================
- Hits         63005   63004      -1     
- Misses       13472   13480      +8     
Files with missing lines Coverage Δ
.../libxrpl/ledger/helpers/PermissionedDEXHelpers.cpp 96.7% <100.0%> (+0.1%) ⬆️
src/libxrpl/tx/transactors/dex/OfferCreate.cpp 93.4% <100.0%> (+<0.1%) ⬆️
src/libxrpl/tx/transactors/payment/Payment.cpp 93.8% <100.0%> (+0.1%) ⬆️

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

Comment thread src/libxrpl/ledger/helpers/PermissionedDEXHelpers.cpp
Copy link
Copy Markdown
Collaborator

@PeterChen13579 PeterChen13579 left a comment

Choose a reason for hiding this comment

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

Looks good to me

Copy link
Copy Markdown
Collaborator

@Kassaking7 Kassaking7 left a comment

Choose a reason for hiding this comment

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

LGTM :D

@bthomee bthomee added this to the 3.2.0 milestone May 29, 2026
@bthomee
Copy link
Copy Markdown
Collaborator

bthomee commented May 30, 2026

@yinyiqian1 is this ready to merge?

@yinyiqian1 yinyiqian1 added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label May 30, 2026
@yinyiqian1
Copy link
Copy Markdown
Collaborator Author

@yinyiqian1 is this ready to merge?

Yes. Thanks for reminding. Just added the label

@bthomee bthomee added this pull request to the merge queue May 30, 2026
Merged via the queue into XRPLF:develop with commit 763dd50 May 30, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants