mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'ximinez/lending-XLS-66-2' into tapanito/lending-fix-overpayment
This commit is contained in:
@@ -40,7 +40,10 @@ findPreviousPage(ApplyView& view, Keylet const& directory, SLE::ref start)
|
|||||||
{
|
{
|
||||||
node = view.peek(keylet::page(directory, page));
|
node = view.peek(keylet::page(directory, page));
|
||||||
if (!node)
|
if (!node)
|
||||||
|
{ // LCOV_EXCL_START
|
||||||
LogicError("Directory chain: root back-pointer broken.");
|
LogicError("Directory chain: root back-pointer broken.");
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto indexes = node->getFieldV256(sfIndexes);
|
auto indexes = node->getFieldV256(sfIndexes);
|
||||||
@@ -59,7 +62,7 @@ insertKey(
|
|||||||
if (preserveOrder)
|
if (preserveOrder)
|
||||||
{
|
{
|
||||||
if (std::find(indexes.begin(), indexes.end(), key) != indexes.end())
|
if (std::find(indexes.begin(), indexes.end(), key) != indexes.end())
|
||||||
LogicError("dirInsert: double insertion");
|
LogicError("dirInsert: double insertion"); // LCOV_EXCL_LINE
|
||||||
|
|
||||||
indexes.push_back(key);
|
indexes.push_back(key);
|
||||||
}
|
}
|
||||||
@@ -73,7 +76,7 @@ insertKey(
|
|||||||
auto pos = std::lower_bound(indexes.begin(), indexes.end(), key);
|
auto pos = std::lower_bound(indexes.begin(), indexes.end(), key);
|
||||||
|
|
||||||
if (pos != indexes.end() && key == *pos)
|
if (pos != indexes.end() && key == *pos)
|
||||||
LogicError("dirInsert: double insertion");
|
LogicError("dirInsert: double insertion"); // LCOV_EXCL_LINE
|
||||||
|
|
||||||
indexes.insert(pos, key);
|
indexes.insert(pos, key);
|
||||||
}
|
}
|
||||||
@@ -131,8 +134,15 @@ insertPage(
|
|||||||
// it's the default.
|
// it's the default.
|
||||||
if (page != 1)
|
if (page != 1)
|
||||||
node->setFieldU64(sfIndexPrevious, page - 1);
|
node->setFieldU64(sfIndexPrevious, page - 1);
|
||||||
|
XRPL_ASSERT_PARTS(
|
||||||
|
!nextPage,
|
||||||
|
"ripple::directory::insertPage",
|
||||||
|
"nextPage has default value");
|
||||||
|
/* Reserved for future use when directory pages may be inserted in
|
||||||
|
* between two other pages instead of only at the end of the chain.
|
||||||
if (nextPage)
|
if (nextPage)
|
||||||
node->setFieldU64(sfIndexNext, nextPage);
|
node->setFieldU64(sfIndexNext, nextPage);
|
||||||
|
*/
|
||||||
describe(node);
|
describe(node);
|
||||||
view.insert(node);
|
view.insert(node);
|
||||||
|
|
||||||
@@ -197,10 +207,10 @@ ApplyView::emptyDirDelete(Keylet const& directory)
|
|||||||
auto nextPage = node->getFieldU64(sfIndexNext);
|
auto nextPage = node->getFieldU64(sfIndexNext);
|
||||||
|
|
||||||
if (nextPage == rootPage && prevPage != rootPage)
|
if (nextPage == rootPage && prevPage != rootPage)
|
||||||
LogicError("Directory chain: fwd link broken");
|
LogicError("Directory chain: fwd link broken"); // LCOV_EXCL_LINE
|
||||||
|
|
||||||
if (prevPage == rootPage && nextPage != rootPage)
|
if (prevPage == rootPage && nextPage != rootPage)
|
||||||
LogicError("Directory chain: rev link broken");
|
LogicError("Directory chain: rev link broken"); // LCOV_EXCL_LINE
|
||||||
|
|
||||||
// Older versions of the code would, in some cases, allow the last
|
// Older versions of the code would, in some cases, allow the last
|
||||||
// page to be empty. Remove such pages:
|
// page to be empty. Remove such pages:
|
||||||
@@ -209,7 +219,10 @@ ApplyView::emptyDirDelete(Keylet const& directory)
|
|||||||
auto last = peek(keylet::page(directory, nextPage));
|
auto last = peek(keylet::page(directory, nextPage));
|
||||||
|
|
||||||
if (!last)
|
if (!last)
|
||||||
|
{ // LCOV_EXCL_START
|
||||||
LogicError("Directory chain: fwd link broken.");
|
LogicError("Directory chain: fwd link broken.");
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
}
|
||||||
|
|
||||||
if (!last->getFieldV256(sfIndexes).empty())
|
if (!last->getFieldV256(sfIndexes).empty())
|
||||||
return false;
|
return false;
|
||||||
@@ -281,10 +294,16 @@ ApplyView::dirRemove(
|
|||||||
if (page == rootPage)
|
if (page == rootPage)
|
||||||
{
|
{
|
||||||
if (nextPage == page && prevPage != page)
|
if (nextPage == page && prevPage != page)
|
||||||
|
{ // LCOV_EXCL_START
|
||||||
LogicError("Directory chain: fwd link broken");
|
LogicError("Directory chain: fwd link broken");
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
}
|
||||||
|
|
||||||
if (prevPage == page && nextPage != page)
|
if (prevPage == page && nextPage != page)
|
||||||
|
{ // LCOV_EXCL_START
|
||||||
LogicError("Directory chain: rev link broken");
|
LogicError("Directory chain: rev link broken");
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
}
|
||||||
|
|
||||||
// Older versions of the code would, in some cases,
|
// Older versions of the code would, in some cases,
|
||||||
// allow the last page to be empty. Remove such
|
// allow the last page to be empty. Remove such
|
||||||
@@ -293,7 +312,10 @@ ApplyView::dirRemove(
|
|||||||
{
|
{
|
||||||
auto last = peek(keylet::page(directory, nextPage));
|
auto last = peek(keylet::page(directory, nextPage));
|
||||||
if (!last)
|
if (!last)
|
||||||
|
{ // LCOV_EXCL_START
|
||||||
LogicError("Directory chain: fwd link broken.");
|
LogicError("Directory chain: fwd link broken.");
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
}
|
||||||
|
|
||||||
if (last->getFieldV256(sfIndexes).empty())
|
if (last->getFieldV256(sfIndexes).empty())
|
||||||
{
|
{
|
||||||
@@ -325,10 +347,10 @@ ApplyView::dirRemove(
|
|||||||
|
|
||||||
// This can never happen for nodes other than the root:
|
// This can never happen for nodes other than the root:
|
||||||
if (nextPage == page)
|
if (nextPage == page)
|
||||||
LogicError("Directory chain: fwd link broken");
|
LogicError("Directory chain: fwd link broken"); // LCOV_EXCL_LINE
|
||||||
|
|
||||||
if (prevPage == page)
|
if (prevPage == page)
|
||||||
LogicError("Directory chain: rev link broken");
|
LogicError("Directory chain: rev link broken"); // LCOV_EXCL_LINE
|
||||||
|
|
||||||
// This node isn't the root, so it can either be in the
|
// This node isn't the root, so it can either be in the
|
||||||
// middle of the list, or at the end. Unlink it first
|
// middle of the list, or at the end. Unlink it first
|
||||||
@@ -336,14 +358,14 @@ ApplyView::dirRemove(
|
|||||||
// root:
|
// root:
|
||||||
auto prev = peek(keylet::page(directory, prevPage));
|
auto prev = peek(keylet::page(directory, prevPage));
|
||||||
if (!prev)
|
if (!prev)
|
||||||
LogicError("Directory chain: fwd link broken.");
|
LogicError("Directory chain: fwd link broken."); // LCOV_EXCL_LINE
|
||||||
// Fix previous to point to its new next.
|
// Fix previous to point to its new next.
|
||||||
prev->setFieldU64(sfIndexNext, nextPage);
|
prev->setFieldU64(sfIndexNext, nextPage);
|
||||||
update(prev);
|
update(prev);
|
||||||
|
|
||||||
auto next = peek(keylet::page(directory, nextPage));
|
auto next = peek(keylet::page(directory, nextPage));
|
||||||
if (!next)
|
if (!next)
|
||||||
LogicError("Directory chain: rev link broken.");
|
LogicError("Directory chain: rev link broken."); // LCOV_EXCL_LINE
|
||||||
// Fix next to point to its new previous.
|
// Fix next to point to its new previous.
|
||||||
next->setFieldU64(sfIndexPrevious, prevPage);
|
next->setFieldU64(sfIndexPrevious, prevPage);
|
||||||
update(next);
|
update(next);
|
||||||
@@ -367,7 +389,10 @@ ApplyView::dirRemove(
|
|||||||
// And the root points to the last page:
|
// And the root points to the last page:
|
||||||
auto root = peek(keylet::page(directory, rootPage));
|
auto root = peek(keylet::page(directory, rootPage));
|
||||||
if (!root)
|
if (!root)
|
||||||
|
{ // LCOV_EXCL_START
|
||||||
LogicError("Directory chain: root link broken.");
|
LogicError("Directory chain: root link broken.");
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
|
}
|
||||||
root->setFieldU64(sfIndexPrevious, prevPage);
|
root->setFieldU64(sfIndexPrevious, prevPage);
|
||||||
update(root);
|
update(root);
|
||||||
|
|
||||||
|
|||||||
@@ -1271,7 +1271,8 @@ protected:
|
|||||||
verifyLoanStatus,
|
verifyLoanStatus,
|
||||||
issuer,
|
issuer,
|
||||||
lender,
|
lender,
|
||||||
borrower);
|
borrower,
|
||||||
|
PaymentParameters{.showStepBalances = true});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Runs through the complete lifecycle of a loan
|
/** Runs through the complete lifecycle of a loan
|
||||||
@@ -7194,15 +7195,15 @@ class LoanArbitrary_test : public LoanBatch_test
|
|||||||
.vaultDeposit = 10000,
|
.vaultDeposit = 10000,
|
||||||
.debtMax = 0,
|
.debtMax = 0,
|
||||||
.coverRateMin = TenthBips32{0},
|
.coverRateMin = TenthBips32{0},
|
||||||
// .managementFeeRate = TenthBips16{5919},
|
.managementFeeRate = TenthBips16{0},
|
||||||
.coverRateLiquidation = TenthBips32{0}};
|
.coverRateLiquidation = TenthBips32{0}};
|
||||||
LoanParameters const loanParams{
|
LoanParameters const loanParams{
|
||||||
.account = Account("lender"),
|
.account = Account("lender"),
|
||||||
.counter = Account("borrower"),
|
.counter = Account("borrower"),
|
||||||
.principalRequest = Number{10000, 0},
|
.principalRequest = Number{200000, -6},
|
||||||
// .interest = TenthBips32{0},
|
.interest = TenthBips32{50000},
|
||||||
// .payTotal = 5816,
|
.payTotal = 2,
|
||||||
.payInterval = 150};
|
.payInterval = 200};
|
||||||
|
|
||||||
runLoan(AssetType::XRP, brokerParams, loanParams);
|
runLoan(AssetType::XRP, brokerParams, loanParams);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,17 +205,23 @@ Transactor::preflight2(PreflightContext const& ctx)
|
|||||||
return *ret;
|
return *ret;
|
||||||
|
|
||||||
// Skip signature check on batch inner transactions
|
// Skip signature check on batch inner transactions
|
||||||
if (!ctx.tx.isFlag(tfInnerBatchTxn) || !ctx.rules.enabled(featureBatch))
|
if (ctx.tx.isFlag(tfInnerBatchTxn) && !ctx.rules.enabled(featureBatch))
|
||||||
{
|
return tesSUCCESS;
|
||||||
auto const sigValid = checkValidity(
|
// Do not add any checks after this point that are relevant for
|
||||||
ctx.app.getHashRouter(), ctx.tx, ctx.rules, ctx.app.config());
|
// batch inner transactions. They will be skipped.
|
||||||
if (sigValid.first == Validity::SigBad)
|
|
||||||
{ // LCOV_EXCL_START
|
auto const sigValid = checkValidity(
|
||||||
JLOG(ctx.j.debug())
|
ctx.app.getHashRouter(), ctx.tx, ctx.rules, ctx.app.config());
|
||||||
<< "preflight2: bad signature. " << sigValid.second;
|
if (sigValid.first == Validity::SigBad)
|
||||||
return temINVALID;
|
{ // LCOV_EXCL_START
|
||||||
} // LCOV_EXCL_STOP
|
JLOG(ctx.j.debug()) << "preflight2: bad signature. " << sigValid.second;
|
||||||
|
return temINVALID;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do not add any checks after this point that are relevant for
|
||||||
|
// batch inner transactions. They will be skipped.
|
||||||
|
|
||||||
return tesSUCCESS;
|
return tesSUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user