Skip to content

VaultWithdraw destination account bugfix #5572

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

Merged
merged 15 commits into from
Jul 25, 2025

Conversation

Bronek
Copy link
Collaborator

@Bronek Bronek commented Jul 16, 2025

High Level Overview of Change

Remove automatic creation of trust line to Destination account in VaultWithdraw.

Context of Change

#5224 added (among other things) a VaultWithdraw transaction which allows setting the recipient of the withdrawn funds in the Destination transaction field. This technically turns this transaction into a payment, and in some respect the implementation does follow payment rules e.g. enforcement of lsfRequireDestTag or lsfDepositAuth or that MPT transfer has destination MPToken. However for IOU, it missed verification that the destination account has trust line to the asset issuer. Since the default behaviour of accountSendIOU is to create this trust line (if missing), this is what VaultWithdraw currently does. This is incorrect, since the Destination might not be interested in holding the asset in question; this basically enables spammy transfers.

Thanks to @ximinez who found the issue and implemented the fix.

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

Bronek and others added 2 commits July 16, 2025 18:20
- Unfortunately, to not change behavior, a new "Legacy" authorization
  type was created. It acts like "StrongAuth" for MPTs and "WeakAuth"
  for IOUs.
@Bronek Bronek force-pushed the Bronek/vault_destination_bugfix branch from 932dd8b to dec0bf7 Compare July 17, 2025 09:13
@Bronek Bronek force-pushed the Bronek/vault_destination_bugfix branch from 250cea2 to 14cb2e1 Compare July 17, 2025 09:48
@Bronek Bronek requested review from mvadari, gregtatcam and ximinez and removed request for gregtatcam and mvadari July 17, 2025 11:31
@Bronek Bronek marked this pull request as ready for review July 17, 2025 13:13
@Bronek Bronek requested review from gregtatcam and shawnxie999 July 17, 2025 13:34
Copy link

codecov bot commented Jul 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.8%. Comparing base (5c2a3a2) to head (f4c3c2e).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #5572     +/-   ##
=========================================
- Coverage     78.8%   78.8%   -0.0%     
=========================================
  Files          814     814             
  Lines        71205   71222     +17     
  Branches      8330    8362     +32     
=========================================
- Hits         56111   56089     -22     
- Misses       15094   15133     +39     
Files with missing lines Coverage Δ
include/xrpl/protocol/detail/transactions.macro 100.0% <ø> (ø)
src/xrpld/app/tx/detail/Escrow.cpp 93.6% <100.0%> (ø)
src/xrpld/app/tx/detail/VaultWithdraw.cpp 94.0% <100.0%> (+0.4%) ⬆️
src/xrpld/ledger/View.h 100.0% <100.0%> (ø)
src/xrpld/ledger/detail/View.cpp 90.7% <100.0%> (-0.3%) ⬇️

... and 10 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Bronek Bronek requested a review from a team as a code owner July 18, 2025 14:40
@Bronek Bronek force-pushed the Bronek/vault_destination_bugfix branch from cb4a73c to 88d712e Compare July 18, 2025 15:04
@Bronek Bronek added the Bug label Jul 18, 2025
Copy link
Collaborator

@ximinez ximinez left a comment

Choose a reason for hiding this comment

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

Tiny comment change

Copy link
Collaborator

@shawnxie999 shawnxie999 left a comment

Choose a reason for hiding this comment

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

LGTM

Bronek and others added 2 commits July 21, 2025 13:44
auto const trustLine =
view.read(keylet::line(account, issue.account, issue.currency));
// If account has no line, and this is a strong check, fail
if (!trustLine && authType == AuthType::StrongAuth)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be gated by an amendment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, because before this change there was no way to pass AuthType::StrongAuth to this function (i.e. the old behaviour was always as-if AuthType::WeakAuth was used). So the new behaviour will only be enabled in the code changed in this PR, where we change the parameters passed to requireAuth.

Copy link
Collaborator

@gregtatcam gregtatcam left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@Bronek Bronek requested a review from ximinez July 22, 2025 14:14
Copy link
Collaborator

@ximinez ximinez left a comment

Choose a reason for hiding this comment

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

Not a super-thorough review, but since there are two others, I figure that's ok. I confirmed that my earlier requested changes have been addressed, and gave the rest of the changes a quick read-through.

@Bronek Bronek 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 Jul 25, 2025
@Bronek
Copy link
Collaborator Author

Bronek commented Jul 25, 2025

Not a super-thorough review, but since there are two others, I figure that's ok. I confirmed that my earlier requested changes have been addressed, and gave the rest of the changes a quick read-through.

thanks @ximinez !

@Bronek Bronek removed the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Jul 25, 2025
@bthomee bthomee enabled auto-merge (squash) July 25, 2025 12:28
@bthomee bthomee merged commit e7a7bb8 into develop Jul 25, 2025
27 checks passed
@bthomee bthomee deleted the Bronek/vault_destination_bugfix branch July 25, 2025 13:53
@@ -315,14 +315,14 @@ escrowCreatePreclaimHelper<MPTIssue>(
// authorized
auto const& mptIssue = amount.get<MPTIssue>();
if (auto const ter =
requireAuth(ctx.view, mptIssue, account, MPTAuthType::WeakAuth);
requireAuth(ctx.view, mptIssue, account, AuthType::WeakAuth);
Copy link

Choose a reason for hiding this comment

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

Require proof of work to withdrawl

ter != tesSUCCESS)
return ter;

// If the issuer has requireAuth set, check if the destination is
// authorized
if (auto const ter =
requireAuth(ctx.view, mptIssue, dest, MPTAuthType::WeakAuth);
requireAuth(ctx.view, mptIssue, dest, AuthType::WeakAuth);
Copy link

Choose a reason for hiding this comment

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

no auth

ximinez added a commit that referenced this pull request Jul 29, 2025
…to ximinez/lending-XLS-66

* XRPLF/ximinez/lending-refactoring-4:
  Build options cleanup (#5581)
  Updates Conan dependencies: Boost 1.86 (#5264)
  VaultWithdraw destination account bugfix (#5572)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants