Skip to content

adds sfMemoData field to VaultDelete transaction#6356

Merged
Tapanito merged 14 commits intotapanito/lending-fix-amendmentfrom
tapanito/vault-delete-data
Feb 26, 2026
Merged

adds sfMemoData field to VaultDelete transaction#6356
Tapanito merged 14 commits intotapanito/lending-fix-amendmentfrom
tapanito/vault-delete-data

Conversation

@Tapanito
Copy link
Collaborator

@Tapanito Tapanito commented Feb 12, 2026

This PR adds an optional Data field to the VaultDelete transaction to register the reason for deletion.

Specification: XRPLF/XRPL-Standards#470

High Level Overview of Change

Context of Change

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)

@Tapanito Tapanito force-pushed the tapanito/vault-delete-data branch from df4e319 to f8b555d Compare February 12, 2026 10:47
@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.8%. Comparing base (3477308) to head (5805372).
⚠️ Report is 1 commits behind head on tapanito/lending-fix-amendment.

Additional details and impacted files

Impacted file tree graph

@@                      Coverage Diff                       @@
##           tapanito/lending-fix-amendment   #6356   +/-   ##
==============================================================
  Coverage                            79.8%   79.8%           
==============================================================
  Files                                 848     848           
  Lines                               67763   67767    +4     
  Branches                             7561    7558    -3     
==============================================================
+ Hits                                54064   54072    +8     
+ Misses                              13699   13695    -4     
Files with missing lines Coverage Δ
include/xrpl/protocol/detail/transactions.macro 100.0% <ø> (ø)
src/libxrpl/tx/transactors/Vault/VaultDelete.cpp 91.9% <100.0%> (+0.6%) ⬆️

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

// The sfData field is an optional field used to record the deletion reason.
if (auto const data = ctx.tx[~sfData]; data && !validDataLength(data, maxDataPayloadLength))
return temMALFORMED;

Copy link
Collaborator

Choose a reason for hiding this comment

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

How is this not redundant with sfMemos/sfMemo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I haven't considered sfMemos / sfMemo. Looking at it, I have reservations with the field, simply based on how big / complex the field is.

I don't have a strong opinion either way. The benefit I see, in sfData is that it does not prescribe a particular structure. Other than that, either option works. That said, I think we only use sfMemos field, never sfMemo.

Copy link
Collaborator

@ximinez ximinez Feb 23, 2026

Choose a reason for hiding this comment

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

I don't have a strong opinion either way. The benefit I see, in sfData is that it does not prescribe a particular structure. Other than that, either option works. That said, I think we only use sfMemos field, never sfMemo.

Yes, the structure of sfMemos is probably overcomplicated. The JSON for even a simple one can look like

"Memos" : [
  {
     "Memo" : {
        "MemoData" : "7274312E312E302D31",
     }
  }
],

Note that sfMemo is used as the first level inner object.

Whereas sfData would just be

"Data" : "7274312E312E302D31",

Despite the complication, sfMemos is fit to purpose for what you're using sfData for in this PR. I think it would be confusing to have sfData used in some transactions to be written to a ledger object, and used in others as "information only" that will not be written.

But I have a proposal: We have memo fields to represent text available already, and not used for any other purpose.

TYPED_SFIELD(sfMemoType,                 VL,        12)
TYPED_SFIELD(sfMemoData,                 VL,        13)
TYPED_SFIELD(sfMemoFormat,               VL,        14)
TYPED_SFIELD(sfData,                     VL,        27)

If you search for any of them, you'll see that they're only used in tests and STTx.cpp where the formatting is checked.

Option 1 (easier): Instead of adding sfData to ttVAULT_DELETE, add sfMemoData. Do all the same checks in VaultDelete, but using sfMemoData instead.

Option 2 (more involved, but so much cooler): Add sfMemoData to the commonFields in TxFormats.cpp. Move the checks in VaultDelete to the corresponding location in the base Transactor class (most likely preflight0, since that's called by every transactor). Realistically, this might need a separate amendment (e.g. SimpleMemo), though that could easily be written to be backward compatible with Option 1.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for the detailed response Ed. I understand, and agree with your reasoning.

The proposal is great, I think what we need to do is apply both options.

Option 1, in this PR, gated with the lending protocol fix amendment.

Option 2, as a separate PR against develop branch, as it would introduce a separate amendment, and I don't think it's a great idea to introduce two separate amendments in this PR. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added option 1, let me know your thoughts about Option 2! 🙇

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for the detailed response Ed. I understand, and agree with your reasoning.

👍

The proposal is great, I think what we need to do is apply both options.

Option 1, in this PR, gated with the lending protocol fix amendment.

Woot!

Option 2, as a separate PR against develop branch, as it would introduce a separate amendment, and I don't think it's a great idea to introduce two separate amendments in this PR. What do you think?

Yes, agreed! Sounds good.

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.

I left one small suggestion that is not enough to hang this PR up if you don't want to do it.

{
testcase("VaultDelete data fixLendingProtocolV1_1 disabled");
env.disableFeature(fixLendingProtocolV1_1);
auto tx = vault.del({.owner = owner, .id = keylet.key});
Copy link
Collaborator

Choose a reason for hiding this comment

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

This restructuring is great. The only feedback I have is minor. You can build the vault.del(...) transaction once at the outer scope and reuse it in each test case, setting a different sfMemoData every time. Call it delTx to distinguish it from the creation tx in the last test case.

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 a nice clean up! I removed the duplicate constructions of the transaction.

@ximinez ximinez changed the title adds sfData field to VaultDelete transaction adds sfMemoData field to VaultDelete transaction Feb 25, 2026
@Tapanito Tapanito merged commit ba53026 into tapanito/lending-fix-amendment Feb 26, 2026
28 of 29 checks passed
@Tapanito Tapanito deleted the tapanito/vault-delete-data branch February 26, 2026 13:13
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