Skip to content

Commit

Permalink
Revert "Merge remote-tracking branch 'upstream/develop' into nft-rese…
Browse files Browse the repository at this point in the history
…rve"

This reverts commit 46c2d66.
  • Loading branch information
shawnxie999 committed Oct 31, 2023
1 parent 46c2d66 commit c037d7f
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 272 deletions.
2 changes: 1 addition & 1 deletion src/ripple/app/paths/Flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ flow(
bool defaultPaths,
bool partialPayment,
bool ownerPaysTransferFee,
OfferCrossing offerCrossing,
bool offerCrossing,
std::optional<Quality> const& limitQuality,
std::optional<STAmount> const& sendMax,
beast::Journal j,
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/app/paths/Flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct FlowDebugInfo;
@param partialPayment If the payment cannot deliver the entire
requested amount, deliver as much as possible, given the constraints
@param ownerPaysTransferFee If true then owner, not sender, pays fee
@param offerCrossing If Yes or Sell then flow is executing offer crossing, not
@param offerCrossing If true then flow is executing offer crossing, not
payments
@param limitQuality Do not use liquidity below this quality threshold
@param sendMax Do not spend more than this amount
Expand All @@ -62,7 +62,7 @@ flow(
bool defaultPaths,
bool partialPayment,
bool ownerPaysTransferFee,
OfferCrossing offerCrossing,
bool offerCrossing,
std::optional<Quality> const& limitQuality,
std::optional<STAmount> const& sendMax,
beast::Journal j,
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/paths/RippleCalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ RippleCalc::rippleCalculate(
defaultPaths,
partialPayment,
ownerPaysTransferFee,
OfferCrossing::no,
/* offerCrossing */ false,
limitQuality,
sendMax,
j,
Expand Down
6 changes: 3 additions & 3 deletions src/ripple/app/paths/impl/PaySteps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ toStrand(
std::optional<Issue> const& sendMaxIssue,
STPath const& path,
bool ownerPaysTransferFee,
OfferCrossing offerCrossing,
bool offerCrossing,
AMMContext& ammContext,
beast::Journal j)
{
Expand Down Expand Up @@ -475,7 +475,7 @@ toStrands(
STPathSet const& paths,
bool addDefaultPath,
bool ownerPaysTransferFee,
OfferCrossing offerCrossing,
bool offerCrossing,
AMMContext& ammContext,
beast::Journal j)
{
Expand Down Expand Up @@ -588,7 +588,7 @@ StrandContext::StrandContext(
std::optional<Quality> const& limitQuality_,
bool isLast_,
bool ownerPaysTransferFee_,
OfferCrossing offerCrossing_,
bool offerCrossing_,
bool isDefaultPath_,
std::array<boost::container::flat_set<Issue>, 2>& seenDirectIssues_,
boost::container::flat_set<Issue>& seenBookOuts_,
Expand Down
14 changes: 6 additions & 8 deletions src/ripple/app/paths/impl/Steps.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class AMMContext;
enum class DebtDirection { issues, redeems };
enum class QualityDirection { in, out };
enum class StrandDirection { forward, reverse };
enum OfferCrossing { no = 0, yes = 1, sell = 2 };

inline bool
redeems(DebtDirection dir)
Expand Down Expand Up @@ -399,7 +398,7 @@ toStrand(
std::optional<Issue> const& sendMaxIssue,
STPath const& path,
bool ownerPaysTransferFee,
OfferCrossing offerCrossing,
bool offerCrossing,
AMMContext& ammContext,
beast::Journal j);

Expand Down Expand Up @@ -439,7 +438,7 @@ toStrands(
STPathSet const& paths,
bool addDefaultPath,
bool ownerPaysTransferFee,
OfferCrossing offerCrossing,
bool offerCrossing,
AMMContext& ammContext,
beast::Journal j);

Expand Down Expand Up @@ -532,10 +531,9 @@ struct StrandContext
bool const isFirst; ///< true if Step is first in Strand
bool const isLast = false; ///< true if Step is last in Strand
bool const ownerPaysTransferFee; ///< true if owner, not sender, pays fee
OfferCrossing const
offerCrossing; ///< Yes/Sell if offer crossing, not payment
bool const isDefaultPath; ///< true if Strand is default path
size_t const strandSize; ///< Length of Strand
bool const offerCrossing; ///< true if offer crossing, not payment
bool const isDefaultPath; ///< true if Strand is default path
size_t const strandSize; ///< Length of Strand
/** The previous step in the strand. Needed to check the no ripple
constraint
*/
Expand Down Expand Up @@ -565,7 +563,7 @@ struct StrandContext
std::optional<Quality> const& limitQuality_,
bool isLast_,
bool ownerPaysTransferFee_,
OfferCrossing offerCrossing_,
bool offerCrossing_,
bool isDefaultPath_,
std::array<boost::container::flat_set<Issue>, 2>&
seenDirectIssues_, ///< For detecting currency loops
Expand Down
33 changes: 4 additions & 29 deletions src/ripple/app/paths/impl/StrandFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ flow(
std::vector<Strand> const& strands,
TOutAmt const& outReq,
bool partialPayment,
OfferCrossing offerCrossing,
bool offerCrossing,
std::optional<Quality> const& limitQuality,
std::optional<STAmount> const& sendMaxST,
beast::Journal j,
Expand Down Expand Up @@ -817,19 +817,6 @@ flow(
JLOG(j.trace()) << "Total flow: in: " << to_string(actualIn)
<< " out: " << to_string(actualOut);

/* flowCross doesn't handle offer crossing with tfFillOrKill flag correctly.
* 1. If tfFillOrKill is set then the owner must receive the full
* TakerPays. We reverse pays and gets because during crossing
* we are taking, therefore the owner must deliver the full TakerPays and
* the entire TakerGets doesn't have to be spent.
* Pre-fixFillOrKill amendment code fails if the entire TakerGets
* is not spent. fixFillOrKill addresses this issue.
* 2. If tfSell is also set then the owner must spend the entire TakerGets
* even if it means obtaining more than TakerPays. Since the pays and gets
* are reversed, the owner must send the entire TakerGets.
*/
bool const fillOrKillEnabled = baseView.rules().enabled(fixFillOrKill);

if (actualOut != outReq)
{
if (actualOut > outReq)
Expand All @@ -840,14 +827,8 @@ flow(
if (!partialPayment)
{
// If we're offerCrossing a !partialPayment, then we're
// handling tfFillOrKill.
// Pre-fixFillOrKill amendment:
// That case is handled below; not here.
// fixFillOrKill amendment:
// That case is handled here if tfSell is also not set; i.e,
// case 1.
if (!offerCrossing ||
(fillOrKillEnabled && offerCrossing != OfferCrossing::sell))
// handling tfFillOrKill. That case is handled below; not here.
if (!offerCrossing)
return {
tecPATH_PARTIAL,
actualIn,
Expand All @@ -859,17 +840,11 @@ flow(
return {tecPATH_DRY, std::move(ofrsToRmOnFail)};
}
}
if (offerCrossing &&
(!partialPayment &&
(!fillOrKillEnabled || offerCrossing == OfferCrossing::sell)))
if (offerCrossing && !partialPayment)
{
// If we're offer crossing and partialPayment is *not* true, then
// we're handling a FillOrKill offer. In this case remainingIn must
// be zero (all funds must be consumed) or else we kill the offer.
// Pre-fixFillOrKill amendment:
// Handles both cases 1. and 2.
// fixFillOrKill amendment:
// Handles 2. 1. is handled above and falls through for tfSell.
assert(remainingIn);
if (remainingIn && *remainingIn != beast::zero)
return {
Expand Down
4 changes: 4 additions & 0 deletions src/ripple/app/rdb/backend/impl/PostgresDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ loadLedgerInfos(
"total_coins, closing_time, prev_closing_time, close_time_res, "
"close_flags, ledger_seq FROM ledgers ";

uint32_t expNumResults = 1;

if (auto ledgerSeq = std::get_if<uint32_t>(&whichLedger))
{
sql << "WHERE ledger_seq = " + std::to_string(*ledgerSeq);
Expand All @@ -187,6 +189,8 @@ loadLedgerInfos(
auto minAndMax =
std::get_if<std::pair<uint32_t, uint32_t>>(&whichLedger))
{
expNumResults = minAndMax->second - minAndMax->first;

sql
<< ("WHERE ledger_seq >= " + std::to_string(minAndMax->first) +
" AND ledger_seq <= " + std::to_string(minAndMax->second));
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/tx/impl/CashCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ CashCheck::doApply()
true, // default path
static_cast<bool>(optDeliverMin), // partial payment
true, // owner pays transfer fee
OfferCrossing::no,
false, // offer crossing
std::nullopt,
sleCheck->getFieldAmount(sfSendMax),
viewJ);
Expand Down
4 changes: 1 addition & 3 deletions src/ripple/app/tx/impl/CreateOffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,8 @@ CreateOffer::flowCross(
}
// Special handling for the tfSell flag.
STAmount deliver = takerAmount.out;
OfferCrossing offerCrossing = OfferCrossing::yes;
if (txFlags & tfSell)
{
offerCrossing = OfferCrossing::sell;
// We are selling, so we will accept *more* than the offer
// specified. Since we don't know how much they might offer,
// we allow delivery of the largest possible amount.
Expand All @@ -766,7 +764,7 @@ CreateOffer::flowCross(
true, // default path
!(txFlags & tfFillOrKill), // partial payment
true, // owner pays transfer fee
offerCrossing,
true, // offer crossing
threshold,
sendMax,
j_);
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/tx/impl/XChainBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ transferHelper(
/*default path*/ true,
/*partial payment*/ false,
/*owner pays transfer fee*/ true,
/*offer crossing*/ OfferCrossing::no,
/*offer crossing*/ false,
/*limit quality*/ std::nullopt,
/*sendmax*/ std::nullopt,
j);
Expand Down
3 changes: 1 addition & 2 deletions src/ripple/protocol/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace detail {
// Feature.cpp. Because it's only used to reserve storage, and determine how
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
// the actual number of amendments. A LogicError on startup will verify this.
static constexpr std::size_t numFeatures = 66;
static constexpr std::size_t numFeatures = 65;

/** Amendments that this server supports and the default voting behavior.
Whether they are enabled depends on the Rules defined in the validated
Expand Down Expand Up @@ -351,7 +351,6 @@ extern uint256 const featureClawback;
extern uint256 const featureXChainBridge;
extern uint256 const fixDisallowIncomingV1;
extern uint256 const featureDID;
extern uint256 const fixFillOrKill;
extern uint256 const fixNFTokenReserve;

} // namespace ripple
Expand Down
1 change: 0 additions & 1 deletion src/ripple/protocol/impl/Feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ REGISTER_FEATURE(AMM, Supported::yes, VoteBehavior::De
REGISTER_FEATURE(XChainBridge, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FIX (fixDisallowIncomingV1, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FEATURE(DID, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FIX(fixFillOrKill, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FIX (fixNFTokenReserve, Supported::yes, VoteBehavior::DefaultNo);

// The following amendments are obsolete, but must remain supported
Expand Down
2 changes: 1 addition & 1 deletion src/test/app/AMMExtended_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2103,7 +2103,7 @@ struct AMMExtended_test : public jtx::AMMTest
false,
false,
true,
OfferCrossing::no,
false,
std::nullopt,
smax,
flowJournal);
Expand Down
2 changes: 1 addition & 1 deletion src/test/app/Flow_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ struct Flow_test : public beast::unit_test::suite
false,
false,
true,
OfferCrossing::no,
false,
std::nullopt,
smax,
flowJournal);
Expand Down
Loading

0 comments on commit c037d7f

Please sign in to comment.