Skip to content
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

Track escrow in recipient's owner directory (RIPD-1523): #2212

Closed
wants to merge 1 commit into from
Closed

Track escrow in recipient's owner directory (RIPD-1523): #2212

wants to merge 1 commit into from

Conversation

nbougalis
Copy link
Contributor

Introduce "fix1523" which corrects a minor technical flaw with
the original implementation of the escrow feature.

When creating an escrow, the entry would only be tracked in the
owner directory of the sender; as a result, an escrow recipient
would not be able to detect incoming escrows without monitoring
the ledger in real-time for transactions of interest or without
the sender communicating this information out of band.

With the fix in place, escrows where the recipient differs from
the sender will be listed in the recipient's owner directory as
well.

Copy link
Collaborator

@bachase bachase 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 with some minor caveats.

@@ -57,7 +57,8 @@ supportedAmendments ()
{ "DC9CA96AEA1DCF83E527D1AFC916EFAF5D27388ECA4060A88817C1238CAEE0BF EnforceInvariants" },
{ "3012E8230864E95A58C60FD61430D7E1B4D3353195F2981DC12B0C7C0950FFAC FlowCross" },
{ "CC5ABAE4F3EC92E94A59B1908C2BE82D2228B6485C00AFF8F22DF930D89C194E SortedDirectories" },
{ "B4D44CC3111ADD964E846FC57760C8B50FFCD5A82C86A72756F6B058DDDF96AD fix1201" }
{ "B4D44CC3111ADD964E846FC57760C8B50FFCD5A82C86A72756F6B058DDDF96AD fix1201" },
{ "6E3FF89E20D93A6C51FAE78409EB68B74DCEA0FA8AA50A2A364630241DC18976 fix1523" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

B9E739B8296B4A1BB29BE990B17D66E21B62A300A909F25AC55C22D6C72E1F9D for fix1523?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. Last minute rename!

{
testcase ("Metadata (with fix1523, to self)");

Env env(*this, with_features(featureEscrow));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be with_features(featureEscrow, fix1523) to match the message on L710?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

// Verify that Carol's owner directory tracks the escrow entry too.
ripple::Dir cod (*env.current(), keylet::ownerDir(carol.id()));
BEAST_EXPECT(std::distance(cod.begin(), cod.end()) == 1);
BEAST_EXPECT(std::find(cod.begin(), cod.end(), escrow) != cod.end());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it worth adding a test to confirm EscrowFinish and EscrowCancel properly delete the entries in both directories?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

{
TER const ter = dirDelete(ctx_.view(), true,
(*slep)[sfAltOwnerNode], keylet::ownerDir((*slep)[sfDestination]),
k.key, false, false, ctx_.app.journal ("View"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

The owner deletion checks page==0 for the bSoft argument (second to last) of dirDelete. Is that important to mirror here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No: that's legacy code (that should have never been there for things like escrow).

Copy link
Collaborator

@scottschurr scottschurr left a comment

Choose a reason for hiding this comment

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

I only have one suggestion beyond the comments that Brad already made...

@@ -387,6 +387,7 @@ extern SF_U64 const sfBaseFee;
extern SF_U64 const sfExchangeRate;
extern SF_U64 const sfLowNode;
extern SF_U64 const sfHighNode;
extern SF_U64 const sfAltOwnerNode;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider sfDestinationNode, as suggested in the Checks proposal: https://ripplelabs.atlassian.net/wiki/spaces/RIPD/pages/111566093/Checks. I think sfDestinationNode is descriptive of the intent for both Checks and Escrow. It would probably work well for Payment Channels as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 done!


{
testcase ("Metadata & Ownership (without fix1523)");
Env env(*this, with_features(featureEscrow));
Copy link
Contributor

@mellery451 mellery451 Aug 25, 2017

Choose a reason for hiding this comment

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

I'd lean toward all_features_except() in this case and then just the default Env (with all features) for the remaining tests, but I realize there is some refactoring by @scottschurr that might impact some of this too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I squinted at the features handling in these unit tests. I figured I'd make a tidying pass on this test after my other changes are merged. Which is not to say I disagree with @mellery451's suggestions. They are good ones...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to be clear, are you suggesting that this be: Env env(*this, all_features_except(fix1523))?

Copy link
Contributor

Choose a reason for hiding this comment

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

@nbougalis yes, that's what I was thinking

@scottschurr
Copy link
Collaborator

Looks like one of the unit tests is failing. But the unit test output is a bit too quiet, so I can't tell which of the tests is failing...

@mellery451
Copy link
Contributor

pretty sure that the failure is #65 failed: AmendmentTable_test.cpp(744)....which I think is failing because the sha512_half hash is wrong in the supportedAmendments (as @bachase pointed out)

@codecov-io
Copy link

Codecov Report

Merging #2212 into develop will increase coverage by 0.01%.
The diff coverage is 90.62%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2212      +/-   ##
===========================================
+ Coverage    70.05%   70.07%   +0.01%     
===========================================
  Files          689      689              
  Lines        50724    50729       +5     
===========================================
+ Hits         35533    35546      +13     
+ Misses       15191    15183       -8
Impacted Files Coverage Δ
src/ripple/ledger/Directory.h 100% <ø> (ø) ⬆️
src/ripple/app/main/Amendments.cpp 100% <ø> (ø) ⬆️
src/ripple/protocol/Feature.h 100% <ø> (ø) ⬆️
src/ripple/protocol/SField.h 100% <ø> (ø) ⬆️
src/ripple/ledger/impl/Directory.cpp 85.71% <ø> (+23.02%) ⬆️
src/ripple/protocol/impl/SField.cpp 91.78% <100%> (+0.03%) ⬆️
src/ripple/protocol/impl/LedgerFormats.cpp 100% <100%> (ø) ⬆️
src/ripple/protocol/impl/Feature.cpp 94.54% <100%> (+0.1%) ⬆️
src/ripple/app/tx/impl/Escrow.cpp 90.65% <85%> (-0.59%) ⬇️
src/ripple/basics/DecayingSample.h 77.77% <0%> (-8.34%) ⬇️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 589570d...b05f16c. Read the comment docs.

Copy link
Contributor

@HowardHinnant HowardHinnant 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 with all the suggested changes. Tests out fine on macOS.

Copy link
Collaborator

@bachase bachase left a comment

Choose a reason for hiding this comment

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

Added tests look great.

@nbougalis
Copy link
Contributor Author

Rebased and squashed. For inclusion into 0.80.0.

Introduce "fix1523" which corrects a minor technical flaw with
the original implementation of the escrow feature.

When creating an escrow, the entry would only be tracked in the
owner directory of the sender; as a result, an escrow recipient
would not be able to detect incoming escrows without monitoring
the ledger in real-time for transactions of interest or without
the sender communicating this information out of band.

With the fix in place, escrows where the recipient differs from
the sender will be listed in the recipient's owner directory as
well.
@nbougalis nbougalis mentioned this pull request Sep 23, 2017
@nbougalis
Copy link
Contributor Author

Merged as c7c1b3c

@nbougalis nbougalis closed this Sep 25, 2017
@nbougalis nbougalis deleted the fix1523 branch March 22, 2018 03:29
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.

6 participants