-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Lending Protocol implementation XLS-66 #5270
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
Conversation
1240135 to
6f5d1ad
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #5270 +/- ##
=========================================
+ Coverage 78.6% 79.0% +0.5%
=========================================
Files 818 839 +21
Lines 68938 71377 +2439
Branches 8240 8339 +99
=========================================
+ Hits 54177 56422 +2245
- Misses 14761 14955 +194
🚀 New features to boost your workflow:
|
27e4c4f to
2d209c4
Compare
e8fbd22 to
a697138
Compare
72d979e to
441d5b5
Compare
b1e091c to
2a8861d
Compare
5223459 to
c7b296c
Compare
6bc30ca to
f8ee979
Compare
ximinez
left a comment
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.
Posting a bunch of pending comments?
| return { | ||
| Validity::SigBad, | ||
| "Malformed: Invalid inner batch transaction."}; | ||
|
|
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.
Does removing this check have to be amendment-gated?
Ugh. I really want to say no, but it's called from Transactor::preflight, so to be safe, I guess it needs to be.
I've restored the code on this branch, and made a separate PR with a fix amendment to skip over the block: #6069
| Valid values are between 0 and 10% inclusive. | ||
| */ | ||
| TenthBips16 constexpr maxManagementFeeRate( |
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.
Should it be moved to a namespace to avoid potential name collisions in the future?
I'm having a hard time imagining what would use the names that wasn't lending related, but a namespace doesn't hurt, so I'll do that.
| { | ||
| // Fixed fields can not be specified if we're modifying an existing | ||
| // LoanBroker Object | ||
| if (tx.isFieldPresent(sfManagementFeeRate) || |
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.
As
sfVaultIDis also not allowed to be modified, do we want to check if it presents?
The VaultID field is defined as required in the transaction, so it will be present. It just has to match.
| broker->at(sfVaultID) = vaultID; | ||
| broker->at(sfOwner) = account_; | ||
| broker->at(sfAccount) = pseudoId; | ||
| broker->at(sfLoanSequence) = 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.
Shouldn't it be the default value 0 as we don't have a Loan object at this moment?
No. In XRPL, sequence numbers are read then incremented, so we start with 1. 0 is an invalid sequence.
If you look at the pre-DeletableAccounts code, you'll see that new account roots were originally created with a sequence of 1. This just follows that same pattern.
| } | ||
|
|
||
| // These values are only going to decrease, and can't be less than 0, so | ||
| // there's no need for integer range enforcement. |
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.
Leaving a comment here since the github doesn't let adding it to unchanged code. There is this code in
doApply()just before the funds are transferred:auto const dstAcct = ctx_.tx[~sfDestination].value_or(account_); if (!vaultAsset.native() && // dstAcct != vaultAsset.getIssuer() && // dstAcct == account_) { if (auto const ter = addEmptyHolding( view(), account_, mPriorBalance, vaultAsset, j_); !isTesSuccess(ter) && ter != tecDUPLICATE) return ter; }There is no need to check for native() and non issuer account -
addEmptyHolding()has these checks.
These extra checks have since been removed in another PR.
src/xrpld/app/tx/detail/LoanSet.cpp
Outdated
| return valueFields; | ||
| } | ||
|
|
||
| std::uint32_t |
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.
It should be
staticfunction.
I assume you're talking about getStartDate, in which case, this is fixed in 1ceff3d
- Revert Payment transactor (Payment.*) back to what is in "develop". - Change LoanBrokerCoverWithdraw to do a direct transfer, whether it's too the account or the destination. Similar to VaultWithdraw, and as specified - #5270 (comment)
| [[maybe_unused]] bool const enforce = | ||
| view.rules().enabled(featureInvariantsV1_1) || | ||
| view.rules().enabled(featureSingleAssetVault); | ||
| view.rules().enabled(featureSingleAssetVault) || | ||
| view.rules().enabled(featureLendingProtocol); |
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.
If featureInvariantsV1_1 is enabled, but one node hasn’t upgraded to the rippled version that includes lending while another node has (and therefore runs the new invariant checks), wouldn’t they end up producing different transaction results? (I guess it would be okay since invaraints are meant to be defensive checks)
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.
If featureInvariantsV1_1 is enabled, but one node hasn’t upgraded to the rippled version that includes lending while another node has (and therefore runs the new invariant checks), wouldn’t they end up producing different transaction results? (I guess it would be okay since invaraints are meant to be defensive checks)
Nope. That's not a problem, since the checks are joined by "or". In your scenario, assuming both nodes are running a version that supports featureInvariantsV1_1 (it's not supported in any version at the moment), then they would both run the invariant check and get identical results. (If one of them did not support it, it would be amendment blocked.)
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.
To clarify, I'm taking about the scenario where:
featureInvariantsV1_1is enabled across the network andfeatureLendingProtocolis not enabled- Node A supports
featureInvariantsV1_1but does not supportfeatureLendingProtocol(didn't upgrade to latest rippled version) - Node B supports both
featureInvariantsV1_1andfeatureLendingProtocol(upgraded to latest rippled version)
Now with the invariant checks below introduced in lending, gated by enforce
If one of these new checks fails for a transaction, Node A would still succeed (since it runs on an older version and does not have these checks) but Node B would fail.
Anyways, since featureInvariantsV1_1 is not supported, this can be left for later discussion.
dangell7
left a comment
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.
non amendment guarded code review
shawnxie999
left a comment
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.
Approving the PR (non amendment gated portion) in its current state, given that we are keeping the lending feature unsupported for the time being.
gregtatcam
left a comment
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.
👍 LGTM
|
@dangell7 I've addressed your comments. Could you re-review ASAP, so I can resolve the issue with unsigned commits, and get this thing merged? |
dangell7
left a comment
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.
Approving ONLY non amendment gated code
- Spec: XLS-66 - Introduces amendment "featureLendingProtocol", but leaves it UNSUPPORTED to allow for future development work. - AccountInfo RPC will indicate the type of pseudo-account when appropriate. - Refactors and improves several existing classes and functional areas, including Number, STAmount, STObject, json_value, Asset, directory handling, View helper functions, and unit test helpers.
a5a2b38 to
3ca1593
Compare
|
Commit message: |
- Spec: XLS-66 - Introduces amendment "LendingProtocol", but leaves it UNSUPPORTED to allow for standalone testing, future development work, and potential bug fixes. - AccountInfo RPC will indicate the type of pseudo-account when appropriate. - Refactors and improves several existing classes and functional areas, including Number, STAmount, STObject, json_value, Asset, directory handling, View helper functions, and unit test helpers.
- Spec: XLS-66 - Introduces amendment "LendingProtocol", but leaves it UNSUPPORTED to allow for standalone testing, future development work, and potential bug fixes. - AccountInfo RPC will indicate the type of pseudo-account when appropriate. - Refactors and improves several existing classes and functional areas, including Number, STAmount, STObject, json_value, Asset, directory handling, View helper functions, and unit test helpers.
High Level Overview of Change
Implement the Lending Protocol as described in XLS-66
Context of Change
Type of Change
API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)