mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-10 06:05:49 +00:00
Compare commits
2 Commits
ripple/wam
...
vlntb/mall
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac5554e9f5 | ||
|
|
673fb06c75 |
@@ -4,6 +4,10 @@
|
||||
#include <xrpl/basics/IntrusivePointer.ipp>
|
||||
#include <xrpl/basics/TaggedCache.h>
|
||||
|
||||
#ifdef __GLIBC__
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
namespace ripple {
|
||||
|
||||
template <
|
||||
@@ -326,6 +330,10 @@ TaggedCache<
|
||||
std::chrono::steady_clock::now() - start)
|
||||
.count()
|
||||
<< "ms";
|
||||
|
||||
#ifdef __GLIBC__
|
||||
(void)malloc_trim(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <
|
||||
|
||||
@@ -62,7 +62,6 @@ XRPL_FIX (UniversalNumber, Supported::yes, VoteBehavior::DefaultNo
|
||||
XRPL_FEATURE(XRPFees, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DisallowIncoming, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FIX (TrustLinesToSelf, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(ExpandedSignerList, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(CheckCashMakesTrustLine, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(FlowSortStrands, Supported::yes, VoteBehavior::DefaultYes)
|
||||
@@ -119,6 +118,7 @@ XRPL_RETIRE(fixReducedOffersV1)
|
||||
XRPL_RETIRE(fixRmSmallIncreasedQOffers)
|
||||
XRPL_RETIRE(fixSTAmountCanonicalize)
|
||||
XRPL_RETIRE(fixTakerDryOfferRemoval)
|
||||
XRPL_RETIRE(fixTrustLinesToSelf)
|
||||
XRPL_RETIRE(CryptoConditions)
|
||||
XRPL_RETIRE(Escrow)
|
||||
XRPL_RETIRE(EnforceInvariants)
|
||||
|
||||
@@ -121,7 +121,8 @@ class Feature_test : public beast::unit_test::suite
|
||||
// Test a random sampling of the variables. If any of these get retired
|
||||
// or removed, swap out for any other feature.
|
||||
BEAST_EXPECT(
|
||||
featureToName(fixTrustLinesToSelf) == "fixTrustLinesToSelf");
|
||||
featureToName(fixRemoveNFTokenAutoTrustLine) ==
|
||||
"fixRemoveNFTokenAutoTrustLine");
|
||||
BEAST_EXPECT(featureToName(featureFlow) == "Flow");
|
||||
BEAST_EXPECT(featureToName(featureNegativeUNL) == "NegativeUNL");
|
||||
BEAST_EXPECT(
|
||||
|
||||
@@ -147,88 +147,6 @@ Change::preCompute()
|
||||
account_ == beast::zero, "ripple::Change::preCompute : zero account");
|
||||
}
|
||||
|
||||
void
|
||||
Change::activateTrustLinesToSelfFix()
|
||||
{
|
||||
JLOG(j_.warn()) << "fixTrustLinesToSelf amendment activation code starting";
|
||||
|
||||
auto removeTrustLineToSelf = [this](Sandbox& sb, uint256 id) {
|
||||
auto tl = sb.peek(keylet::child(id));
|
||||
|
||||
if (tl == nullptr)
|
||||
{
|
||||
JLOG(j_.warn()) << id << ": Unable to locate trustline";
|
||||
return true;
|
||||
}
|
||||
|
||||
if (tl->getType() != ltRIPPLE_STATE)
|
||||
{
|
||||
JLOG(j_.warn()) << id << ": Unexpected type "
|
||||
<< static_cast<std::uint16_t>(tl->getType());
|
||||
return true;
|
||||
}
|
||||
|
||||
auto const& lo = tl->getFieldAmount(sfLowLimit);
|
||||
auto const& hi = tl->getFieldAmount(sfHighLimit);
|
||||
|
||||
if (lo != hi)
|
||||
{
|
||||
JLOG(j_.warn()) << id << ": Trustline doesn't meet requirements";
|
||||
return true;
|
||||
}
|
||||
|
||||
if (auto const page = tl->getFieldU64(sfLowNode); !sb.dirRemove(
|
||||
keylet::ownerDir(lo.getIssuer()), page, tl->key(), false))
|
||||
{
|
||||
JLOG(j_.error()) << id << ": failed to remove low entry from "
|
||||
<< toBase58(lo.getIssuer()) << ":" << page
|
||||
<< " owner directory";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto const page = tl->getFieldU64(sfHighNode); !sb.dirRemove(
|
||||
keylet::ownerDir(hi.getIssuer()), page, tl->key(), false))
|
||||
{
|
||||
JLOG(j_.error()) << id << ": failed to remove high entry from "
|
||||
<< toBase58(hi.getIssuer()) << ":" << page
|
||||
<< " owner directory";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tl->getFlags() & lsfLowReserve)
|
||||
adjustOwnerCount(
|
||||
sb, sb.peek(keylet::account(lo.getIssuer())), -1, j_);
|
||||
|
||||
if (tl->getFlags() & lsfHighReserve)
|
||||
adjustOwnerCount(
|
||||
sb, sb.peek(keylet::account(hi.getIssuer())), -1, j_);
|
||||
|
||||
sb.erase(tl);
|
||||
|
||||
JLOG(j_.warn()) << "Successfully deleted trustline " << id;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
Sandbox sb(&view());
|
||||
|
||||
if (removeTrustLineToSelf(
|
||||
sb,
|
||||
uint256{
|
||||
"2F8F21EFCAFD7ACFB07D5BB04F0D2E18587820C7611305BB674A64EAB0FA71E1"sv}) &&
|
||||
removeTrustLineToSelf(
|
||||
sb,
|
||||
uint256{
|
||||
"326035D5C0560A9DA8636545DD5A1B0DFCFF63E68D491B5522B767BB00564B1A"sv}))
|
||||
{
|
||||
JLOG(j_.warn()) << "fixTrustLinesToSelf amendment activation code "
|
||||
"executed successfully";
|
||||
sb.apply(ctx_.rawView());
|
||||
}
|
||||
}
|
||||
|
||||
TER
|
||||
Change::applyAmendment()
|
||||
{
|
||||
@@ -305,9 +223,6 @@ Change::applyAmendment()
|
||||
amendments.push_back(amendment);
|
||||
amendmentObject->setFieldV256(sfAmendments, amendments);
|
||||
|
||||
if (amendment == fixTrustLinesToSelf)
|
||||
activateTrustLinesToSelfFix();
|
||||
|
||||
ctx_.app.getAmendmentTable().enable(amendment);
|
||||
|
||||
if (!ctx_.app.getAmendmentTable().isSupported(amendment))
|
||||
|
||||
@@ -29,9 +29,6 @@ public:
|
||||
preclaim(PreclaimContext const& ctx);
|
||||
|
||||
private:
|
||||
void
|
||||
activateTrustLinesToSelfFix();
|
||||
|
||||
TER
|
||||
applyAmendment();
|
||||
|
||||
|
||||
@@ -195,29 +195,8 @@ SetTrust::preclaim(PreclaimContext const& ctx)
|
||||
auto const currency = saLimitAmount.getCurrency();
|
||||
auto const uDstAccountID = saLimitAmount.getIssuer();
|
||||
|
||||
if (ctx.view.rules().enabled(fixTrustLinesToSelf))
|
||||
{
|
||||
if (id == uDstAccountID)
|
||||
return temDST_IS_SRC;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (id == uDstAccountID)
|
||||
{
|
||||
// Prevent trustline to self from being created,
|
||||
// unless one has somehow already been created
|
||||
// (in which case doApply will clean it up).
|
||||
auto const sleDelete =
|
||||
ctx.view.read(keylet::line(id, uDstAccountID, currency));
|
||||
|
||||
if (!sleDelete)
|
||||
{
|
||||
JLOG(ctx.j.trace())
|
||||
<< "Malformed transaction: Can not extend credit to self.";
|
||||
return temDST_IS_SRC;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (id == uDstAccountID)
|
||||
return temDST_IS_SRC;
|
||||
|
||||
// This might be nullptr
|
||||
auto const sleDst = ctx.view.read(keylet::account(uDstAccountID));
|
||||
@@ -403,21 +382,6 @@ SetTrust::doApply()
|
||||
|
||||
auto viewJ = ctx_.app.journal("View");
|
||||
|
||||
// Trust lines to self are impossible but because of the old bug there
|
||||
// are two on 19-02-2022. This code was here to allow those trust lines
|
||||
// to be deleted. The fixTrustLinesToSelf fix amendment will remove them
|
||||
// when it enables so this code will no longer be needed.
|
||||
if (!view().rules().enabled(fixTrustLinesToSelf) &&
|
||||
account_ == uDstAccountID)
|
||||
{
|
||||
return trustDelete(
|
||||
view(),
|
||||
view().peek(keylet::line(account_, uDstAccountID, currency)),
|
||||
account_,
|
||||
uDstAccountID,
|
||||
viewJ);
|
||||
}
|
||||
|
||||
SLE::pointer sleDst = view().peek(keylet::account(uDstAccountID));
|
||||
|
||||
if (!sleDst)
|
||||
|
||||
Reference in New Issue
Block a user