Sponsored Content
Skip to content

Stop tx processing if failed to delete expired credentials - #6715

Merged
oleks-rip merged 8 commits into
XRPLF:ripple/staging-313from
oleks-rip:del_cred2
Apr 18, 2026
Merged

Stop tx processing if failed to delete expired credentials#6715
oleks-rip merged 8 commits into
XRPLF:ripple/staging-313from
oleks-rip:del_cred2

Conversation

@oleks-rip

@oleks-rip oleks-rip commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

High Level Overview of Change

Return error code if deleting expired credentials failed
Port to develop PR #6962

@codecov

codecov Bot commented Apr 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.5%. Comparing base (eefa1d0) to head (bdbb60b).
⚠️ Report is 2 commits behind head on ripple/staging-313.

Files with missing lines Patch % Lines
src/xrpld/app/tx/detail/Transactor.cpp 40.0% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                  @@
##           ripple/staging-313   #6715     +/-   ##
====================================================
- Coverage                79.5%   79.5%   -0.0%     
====================================================
  Files                     840     840             
  Lines                   71890   71902     +12     
  Branches                 8200    8205      +5     
====================================================
+ Hits                    57128   57135      +7     
- Misses                  14762   14767      +5     
Files with missing lines Coverage Δ
src/libxrpl/ledger/CredentialHelpers.cpp 98.4% <100.0%> (+0.6%) ⬆️
src/xrpld/app/misc/PermissionedDEXHelpers.cpp 92.6% <100.0%> (ø)
src/xrpld/app/tx/detail/Credentials.cpp 100.0% <100.0%> (ø)
src/xrpld/rpc/handlers/DepositAuthorized.cpp 100.0% <100.0%> (ø)
src/xrpld/app/tx/detail/Transactor.cpp 92.3% <40.0%> (-0.5%) ⬇️

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

@ximinez
ximinez force-pushed the ripple/staging-313 branch from 628230a to f85b917 Compare April 6, 2026 16:55

@mvadari mvadari 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.

Some extra stuff included in this diff in the workflows - can we remove those?

Comment thread src/libxrpl/ledger/CredentialHelpers.cpp
Comment thread .github/workflows/on-pr.yml
Comment thread src/libxrpl/ledger/CredentialHelpers.cpp
Comment thread src/test/app/Credentials_test.cpp
Comment thread src/test/app/Credentials_test.cpp Outdated
@oleks-rip
oleks-rip requested a review from ximinez April 8, 2026 18:09
Comment thread src/libxrpl/ledger/CredentialHelpers.cpp Outdated
Comment thread src/test/app/Credentials_test.cpp Outdated
Comment thread src/xrpld/app/tx/detail/Transactor.cpp Outdated
@oleks-rip
oleks-rip requested a review from ximinez April 16, 2026 21:12
@oleks-rip

oleks-rip commented Apr 16, 2026

Copy link
Copy Markdown
Contributor Author

Develop PR

Comment thread src/libxrpl/ledger/CredentialHelpers.cpp Outdated

@ximinez ximinez 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.

One small thing, then I think it's done!

Comment thread src/xrpld/app/tx/detail/Credentials.cpp

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 ports the develop-branch fix to ensure that failures while deleting expired credentials can be surfaced as transaction errors (instead of silently continuing), and updates the credential-expiration helper API accordingly.

Changes:

  • Refactors credentials::checkExpired to take SLE const& and updates call sites to dereference SLE pointers before checking expiration.
  • Updates expired-credential cleanup in CredentialHelpers.cpp to propagate deleteSLE failures (behind fixSecurity3_1_3) via an Expected<bool, TER> result.
  • Adds a unit test that simulates ledger corruption and verifies behavior before/after fixSecurity3_1_3.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/xrpld/rpc/handlers/DepositAuthorized.cpp Adjusts expiration checks to match the new checkExpired(SLE const&) signature.
src/xrpld/app/tx/detail/Transactor.cpp Adds logging when reapply-time credential deletion fails (but currently doesn’t propagate failure).
src/xrpld/app/tx/detail/Credentials.cpp Updates expiration checks to dereference SLE and adds a defensive null check in doApply().
src/xrpld/app/misc/PermissionedDEXHelpers.cpp Updates expiration checks to match the new checkExpired signature.
src/test/app/Credentials_test.cpp Adds regression coverage for delete-failure handling under simulated corruption and fixSecurity3_1_3.
src/libxrpl/ledger/CredentialHelpers.cpp Implements error propagation from expired-credential deletion when fixSecurity3_1_3 is enabled.
include/xrpl/ledger/CredentialHelpers.h Updates public helper signatures (checkExpired) and marks deleteSLE as [[nodiscard]].

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

Comment on lines +1202 to +1203
STVector256 credHashes;
credHashes.push_back(credKeylet.key);

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

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

STVector256 credHashes is created and populated but never used, which will trigger -Wunused-variable/-Wunused-but-set-variable warnings in many builds (and may fail under -Werror). Remove it or use it in the subsequent calls.

Suggested change
STVector256 credHashes;
credHashes.push_back(credKeylet.key);

Copilot uses AI. Check for mistakes.
Comment on lines 39 to 46

// Check if credential sfExpiration field has passed ledger's parentCloseTime
bool
checkExpired(
std::shared_ptr<SLE const> const& sleCredential,
NetClock::time_point const& closed);

// Return true if any expired credential was found in arr (and deleted)
bool
removeExpired(ApplyView& view, STVector256 const& arr, beast::Journal const j);
checkExpired(SLE const& sleCredential, NetClock::time_point const& closed);

// Actually remove a credentials object from the ledger
TER
[[nodiscard]] TER
deleteSLE(

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

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

This change removes credentials::removeExpired from a public header and changes checkExpired's parameter from shared_ptr<SLE const> to SLE const&. Both are API/ABI breaking for any external consumers of the installed include/xrpl/* headers; if downstream compatibility matters, consider keeping a deprecated overload/wrapper (or leaving removeExpired declared and forwarding internally) rather than removing/changing the public signatures outright.

Copilot uses AI. Check for mistakes.
Comment on lines +1094 to +1101
{
if (auto const ter = credentials::deleteSLE(view, sle, viewJ);
!isTesSuccess(ter))
{
JLOG(viewJ.error()) << "removeExpiredCredentials: failed to "
"delete expired credential. Err: "
<< transToken(ter);
}

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

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

removeExpiredCredentials logs when credentials::deleteSLE fails but then continues, so the transaction can still complete with tecEXPIRED while leaving the expired credential undeleted. Since deleteSLE failures indicate ledger corruption (e.g. missing owner account / dirRemove failure), this should be treated as a hard failure: propagate the TER back to Transactor::operator() (and discard/stop processing) instead of only logging (optionally gated behind fixSecurity3_1_3).

Copilot uses AI. Check for mistakes.
@oleks-rip
oleks-rip added this pull request to the merge queue Apr 17, 2026
Merged via the queue into XRPLF:ripple/staging-313 with commit 673af42 Apr 18, 2026
3 checks passed
@oleks-rip
oleks-rip deleted the del_cred2 branch April 18, 2026 00:26
ximinez added a commit that referenced this pull request Apr 22, 2026
godexsoft pushed a commit to godexsoft/rippled that referenced this pull request May 7, 2026
…F#6715) (XRPLF#6962)

Co-authored-by: Ed Hennis <ed@ripple.com>
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
beartec-jpg pushed a commit to beartec-jpg/FalconLedger that referenced this pull request Jun 1, 2026
…F#6715) (XRPLF#6962)

Co-authored-by: Ed Hennis <ed@ripple.com>
Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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