-
Notifications
You must be signed in to change notification settings - Fork 1.6k
adds sfMemoData field to VaultDelete transaction #6356
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
Changes from 10 commits
f8b555d
60fce3c
3338ec3
6a34a66
a14541a
0bc67c8
667b559
edfc41f
d67c520
cb93f02
597c3e3
5cd9d18
3d4c11e
5805372
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1064,14 +1064,13 @@ class Vault_test : public beast::unit_test::suite | |
| { | ||
| using namespace test::jtx; | ||
|
|
||
| auto testCase = [this]( | ||
| std::function<void( | ||
| Env & env, | ||
| Account const& issuer, | ||
| Account const& owner, | ||
| Account const& depositor, | ||
| Asset const& asset, | ||
| Vault& vault)> test) { | ||
| auto testCase = [this](std::function<void( | ||
| Env & env, | ||
| Account const& issuer, | ||
| Account const& owner, | ||
| Account const& depositor, | ||
| Asset const& asset, | ||
| Vault& vault)> test) { | ||
| Env env{*this, testable_amendments() | featureSingleAssetVault}; | ||
| Account issuer{"issuer"}; | ||
| Account owner{"owner"}; | ||
|
|
@@ -1354,14 +1353,13 @@ class Vault_test : public beast::unit_test::suite | |
| { | ||
| using namespace test::jtx; | ||
|
|
||
| auto testCase = [this]( | ||
| std::function<void( | ||
| Env & env, | ||
| Account const& issuer, | ||
| Account const& owner, | ||
| Account const& depositor, | ||
| Asset const& asset, | ||
| Vault& vault)> test) { | ||
| auto testCase = [this](std::function<void( | ||
| Env & env, | ||
| Account const& issuer, | ||
| Account const& owner, | ||
| Account const& depositor, | ||
| Asset const& asset, | ||
| Vault& vault)> test) { | ||
| Env env{*this, testable_amendments() | featureSingleAssetVault}; | ||
| Account issuer{"issuer"}; | ||
| Account owner{"owner"}; | ||
|
|
@@ -5357,6 +5355,65 @@ class Vault_test : public beast::unit_test::suite | |
| } | ||
| } | ||
|
|
||
| void | ||
| testVaultDeleteData() | ||
| { | ||
| using namespace test::jtx; | ||
|
|
||
| Env env{*this}; | ||
|
|
||
| Account const owner{"owner"}; | ||
| env.fund(XRP(1'000'000), owner); | ||
| env.close(); | ||
|
|
||
| Vault vault{env}; | ||
|
|
||
| auto const keylet = keylet::vault(owner.id(), 1); | ||
|
|
||
| // Test VaultDelete with fixLendingProtocolV1_1 disabled | ||
| // Transaction fails if the data field is provided | ||
| { | ||
| testcase("VaultDelete data fixLendingProtocolV1_1 disabled"); | ||
| env.disableFeature(fixLendingProtocolV1_1); | ||
| auto tx = vault.del({.owner = owner, .id = keylet.key}); | ||
|
||
| tx[sfMemoData] = strHex(std::string(maxDataPayloadLength, 'A')); | ||
| env(tx, ter(temDISABLED), THISLINE); | ||
| env.close(); | ||
| env.enableFeature(fixLendingProtocolV1_1); | ||
| } | ||
|
|
||
| // Transaction fails if the data field is too large | ||
| { | ||
| testcase("VaultDelete data fixLendingProtocolV1_1 enabled data too large"); | ||
| auto tx = vault.del({.owner = owner, .id = keylet.key}); | ||
| tx[sfMemoData] = strHex(std::string(maxDataPayloadLength + 1, 'A')); | ||
| env(tx, ter(temMALFORMED), THISLINE); | ||
| env.close(); | ||
| } | ||
|
|
||
| // Transaction fails if the data field is set, but is empty | ||
| { | ||
| testcase("VaultDelete data fixLendingProtocolV1_1 enabled data empty"); | ||
| auto tx = vault.del({.owner = owner, .id = keylet.key}); | ||
| tx[sfMemoData] = strHex(std::string(0, 'A')); | ||
| env(tx, ter(temMALFORMED), THISLINE); | ||
| env.close(); | ||
| } | ||
|
|
||
| { | ||
| testcase("VaultDelete data fixLendingProtocolV1_1 enabled data valid"); | ||
| PrettyAsset const xrpAsset = xrpIssue(); | ||
| auto [tx, keylet] = vault.create({.owner = owner, .asset = xrpAsset}); | ||
| env(tx, ter(tesSUCCESS), THISLINE); | ||
| env.close(); | ||
|
|
||
| tx = vault.del({.owner = owner, .id = keylet.key}); | ||
| tx[sfMemoData] = strHex(std::string(maxDataPayloadLength, 'A')); | ||
| env(tx, ter(tesSUCCESS), THISLINE); | ||
| env.close(); | ||
| } | ||
| } | ||
|
|
||
| public: | ||
| void | ||
| run() override | ||
|
|
@@ -5378,6 +5435,7 @@ class Vault_test : public beast::unit_test::suite | |
| testVaultClawbackBurnShares(); | ||
| testVaultClawbackAssets(); | ||
| testAssetsMaximum(); | ||
| testVaultDeleteData(); | ||
| } | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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
sfDatais that it does not prescribe a particular structure. Other than that, either option works. That said, I think we only usesfMemosfield, neversfMemo.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the structure of
sfMemosis probably overcomplicated. The JSON for even a simple one can look likeNote that
sfMemois used as the first level inner object.Whereas
sfDatawould just beDespite the complication,
sfMemosis fit to purpose for what you're usingsfDatafor in this PR. I think it would be confusing to havesfDataused 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.
If you search for any of them, you'll see that they're only used in tests and
STTx.cppwhere the formatting is checked.Option 1 (easier): Instead of adding
sfDatatottVAULT_DELETE, addsfMemoData. Do all the same checks inVaultDelete, but usingsfMemoDatainstead.Option 2 (more involved, but so much cooler): Add
sfMemoDatato thecommonFieldsinTxFormats.cpp. Move the checks inVaultDeleteto the corresponding location in the baseTransactorclass (most likelypreflight0, 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.There was a problem hiding this comment.
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
developbranch, 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?There was a problem hiding this comment.
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! 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Woot!
Yes, agreed! Sounds good.