mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-21 14:20:56 +00:00
Put flowV2 on an amendment only
This commit is contained in:
@@ -76,7 +76,6 @@ RippleCalc::Output RippleCalc::rippleCalculate (
|
||||
view.rules ().enabled (featureCompareFlowV1V2, config.features);
|
||||
|
||||
bool const useFlowV1Output =
|
||||
!flowV2Switchover (view.info ().parentCloseTime) &&
|
||||
!view.rules ().enabled (featureFlowV2, config.features);
|
||||
bool const callFlowV1 = useFlowV1Output || compareFlowV1V2;
|
||||
bool const callFlowV2 = !useFlowV1Output || compareFlowV1V2;
|
||||
@@ -331,7 +330,7 @@ TER RippleCalc::rippleCalculate (detail::FlowDebugInfo* flowDebugInfo)
|
||||
boost::container::flat_set<uint256> unfundedOffersFromBestPaths;
|
||||
|
||||
int iPass = 0;
|
||||
auto const dcSwitch = dcSwitchover(view.info().parentCloseTime);
|
||||
auto const dcSwitch = amendmentRIPD1141(view.info().parentCloseTime);
|
||||
|
||||
while (resultCode == temUNCERTAIN)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace path {
|
||||
|
||||
TER PathCursor::advanceNode (STAmount const& amount, bool reverse, bool callerHasLiquidity) const
|
||||
{
|
||||
bool const multi = dcSwitchover (view ().info ().parentCloseTime)
|
||||
bool const multi = amendmentRIPD1141 (view ().info ().parentCloseTime)
|
||||
? (multiQuality_ || (!callerHasLiquidity && amount == zero))
|
||||
: (multiQuality_ || amount == zero);
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ TER PathCursor::deliverNodeReverseImpl (
|
||||
saInPassAct,
|
||||
saOutAct > zero);
|
||||
|
||||
if (dcSwitchover(view().info().parentCloseTime))
|
||||
if (amendmentRIPD1141(view().info().parentCloseTime))
|
||||
{
|
||||
// The recursive call is dry this time, but we have liquidity
|
||||
// from previous calls
|
||||
|
||||
@@ -913,7 +913,7 @@ struct Flow_test : public beast::unit_test::suite
|
||||
Account const bob ("bob");
|
||||
Account const carol ("carol");
|
||||
|
||||
auto const closeTime = dcSoTime() +
|
||||
auto const closeTime = amendmentRIPD1141SoTime() +
|
||||
100 * env.closed ()->info ().closeTimeResolution;
|
||||
env.close (closeTime);
|
||||
|
||||
@@ -977,30 +977,27 @@ struct Flow_test : public beast::unit_test::suite
|
||||
|
||||
auto const timeDelta = Env{*this}.closed ()->info ().closeTimeResolution;
|
||||
|
||||
for(auto const& t :{dcSoTime(), flowV2SoTime()}){
|
||||
for(auto const& d: {-timeDelta*100, +timeDelta*100}){
|
||||
auto const closeTime = t+d;
|
||||
Env env (*this);
|
||||
env.close (closeTime);
|
||||
for(auto const& d: {-timeDelta*100, +timeDelta*100}){
|
||||
auto const closeTime = amendmentRIPD1141SoTime () + d;
|
||||
Env env (*this);
|
||||
env.close (closeTime);
|
||||
|
||||
env.fund (XRP(10000), alice, bob, carol, gw);
|
||||
env.fund (XRP(10000), alice, bob, carol, gw);
|
||||
|
||||
env.trust (USD(100), alice, bob, carol);
|
||||
env (pay (gw, bob, USD (100)));
|
||||
env (offer (bob, XRP (50), USD (50)));
|
||||
env (offer (bob, XRP (100), USD (50)));
|
||||
env.trust (USD(100), alice, bob, carol);
|
||||
env (pay (gw, bob, USD (100)));
|
||||
env (offer (bob, XRP (50), USD (50)));
|
||||
env (offer (bob, XRP (100), USD (50)));
|
||||
|
||||
auto expectedResult =
|
||||
closeTime < dcSoTime () ? tecPATH_DRY : tesSUCCESS;
|
||||
env (pay (alice, carol, USD (100)), path (~USD), sendmax (XRP (100)),
|
||||
txflags (tfNoRippleDirect | tfPartialPayment | tfLimitQuality),
|
||||
ter (expectedResult));
|
||||
auto expectedResult =
|
||||
closeTime < amendmentRIPD1141SoTime () ? tecPATH_DRY : tesSUCCESS;
|
||||
env (pay (alice, carol, USD (100)), path (~USD), sendmax (XRP (100)),
|
||||
txflags (tfNoRippleDirect | tfPartialPayment | tfLimitQuality),
|
||||
ter (expectedResult));
|
||||
|
||||
if (expectedResult == tesSUCCESS)
|
||||
env.require (balance (carol, USD (50)));
|
||||
}
|
||||
if (expectedResult == tesSUCCESS)
|
||||
env.require (balance (carol, USD (50)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Helper function that returns the reserve on an account based on
|
||||
@@ -1045,7 +1042,7 @@ struct Flow_test : public beast::unit_test::suite
|
||||
Env env (*this, features (featureFlowV2));
|
||||
|
||||
auto const closeTime =
|
||||
flowV2SoTime () + 100 * env.closed ()->info ().closeTimeResolution;
|
||||
amendmentRIPD1141SoTime () + 100 * env.closed ()->info ().closeTimeResolution;
|
||||
env.close (closeTime);
|
||||
|
||||
env.fund (XRP (1000000), gw1, gw2);
|
||||
@@ -1119,7 +1116,7 @@ struct Flow_test : public beast::unit_test::suite
|
||||
Env env (*this, features (featureFlowV2));
|
||||
|
||||
auto const closeTime =
|
||||
flowV2SoTime () + 100 * env.closed ()->info ().closeTimeResolution;
|
||||
amendmentRIPD1141SoTime () + 100 * env.closed ()->info ().closeTimeResolution;
|
||||
env.close (closeTime);
|
||||
|
||||
env.fund (XRP (1000000), gw1, gw2);
|
||||
|
||||
@@ -340,11 +340,11 @@ transferXRP (ApplyView& view,
|
||||
STAmount const& amount,
|
||||
beast::Journal j);
|
||||
|
||||
NetClock::time_point const& flowV2SoTime ();
|
||||
bool flowV2Switchover (NetClock::time_point const closeTime);
|
||||
NetClock::time_point const& amendmentRIPD1141SoTime ();
|
||||
bool amendmentRIPD1141 (NetClock::time_point const closeTime);
|
||||
|
||||
NetClock::time_point const& dcSoTime ();
|
||||
bool dcSwitchover (NetClock::time_point const closeTime);
|
||||
NetClock::time_point const& amendmentRIPD1141SoTime ();
|
||||
bool amendmentRIPD1141 (NetClock::time_point const closeTime);
|
||||
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -179,7 +179,7 @@ PaymentSandbox::balanceHook (AccountID const& account,
|
||||
*/
|
||||
|
||||
auto const currency = amount.getCurrency ();
|
||||
auto const switchover = flowV2Switchover (info ().parentCloseTime);
|
||||
auto const switchover = amendmentRIPD1141 (info ().parentCloseTime);
|
||||
|
||||
auto adjustedAmt = amount;
|
||||
if (switchover)
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
NetClock::time_point const& flowV2SoTime ()
|
||||
NetClock::time_point const& amendmentRIPD1141SoTime ()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
// Wed May 26, 2016 07:00:00am PDT
|
||||
@@ -39,22 +39,9 @@ NetClock::time_point const& flowV2SoTime ()
|
||||
return soTime;
|
||||
}
|
||||
|
||||
bool flowV2Switchover (NetClock::time_point const closeTime)
|
||||
bool amendmentRIPD1141 (NetClock::time_point const closeTime)
|
||||
{
|
||||
return closeTime > flowV2SoTime();
|
||||
}
|
||||
|
||||
NetClock::time_point const& dcSoTime ()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
// Mon May 23, 2016 10:00:00am PDT
|
||||
static NetClock::time_point const soTime{517338000s};
|
||||
return soTime;
|
||||
}
|
||||
|
||||
bool dcSwitchover (NetClock::time_point const closeTime)
|
||||
{
|
||||
return closeTime > dcSoTime();
|
||||
return closeTime > amendmentRIPD1141SoTime();
|
||||
}
|
||||
|
||||
// VFALCO NOTE A copy of the other one for now
|
||||
@@ -134,7 +121,7 @@ accountHolds (ReadView const& view,
|
||||
if (isXRP(currency))
|
||||
{
|
||||
// XRP: return balance minus reserve
|
||||
if (dcSwitchover (view.info ().parentCloseTime))
|
||||
if (amendmentRIPD1141 (view.info ().parentCloseTime))
|
||||
{
|
||||
auto const sle = view.read(
|
||||
keylet::account(account));
|
||||
@@ -1429,7 +1416,7 @@ rippleSend (ApplyView& view,
|
||||
|
||||
// Calculate the amount to transfer accounting
|
||||
// for any transfer fees:
|
||||
if (!flowV2Switchover (view.info ().parentCloseTime))
|
||||
if (!amendmentRIPD1141 (view.info ().parentCloseTime))
|
||||
{
|
||||
STAmount const saTransitFee = rippleTransferFee (
|
||||
view, uSenderID, uReceiverID, issuer, saAmount, j);
|
||||
@@ -1485,7 +1472,7 @@ accountSend (ApplyView& view,
|
||||
return rippleSend (view, uSenderID, uReceiverID, saAmount, saActual, j);
|
||||
}
|
||||
|
||||
auto const fv2Switch = flowV2Switchover (view.info ().parentCloseTime);
|
||||
auto const fv2Switch = amendmentRIPD1141 (view.info ().parentCloseTime);
|
||||
if (!fv2Switch)
|
||||
{
|
||||
auto const dummyBalance = saAmount.zeroed();
|
||||
|
||||
@@ -280,12 +280,12 @@ class PaymentSandbox_test : public beast::unit_test::suite
|
||||
for (auto timeDelta : {-env.closed ()->info ().closeTimeResolution,
|
||||
env.closed ()->info ().closeTimeResolution})
|
||||
{
|
||||
auto const closeTime = flowV2SoTime () + timeDelta;
|
||||
auto const closeTime = amendmentRIPD1141SoTime () + timeDelta;
|
||||
env.close (closeTime);
|
||||
ApplyViewImpl av (&*env.current (), tapNONE);
|
||||
PaymentSandbox pv (&av);
|
||||
pv.creditHook (gw, alice, hugeAmt, -tinyAmt);
|
||||
if (closeTime > flowV2SoTime ())
|
||||
if (closeTime > amendmentRIPD1141SoTime ())
|
||||
expect (pv.balanceHook (alice, gw, hugeAmt) == tinyAmt);
|
||||
else
|
||||
expect (pv.balanceHook (alice, gw, hugeAmt) != tinyAmt);
|
||||
@@ -315,7 +315,7 @@ class PaymentSandbox_test : public beast::unit_test::suite
|
||||
Account const alice ("alice");
|
||||
env.fund (reserve(env, 1), alice);
|
||||
|
||||
auto const closeTime = dcSoTime () +
|
||||
auto const closeTime = amendmentRIPD1141SoTime () +
|
||||
100 * env.closed ()->info ().closeTimeResolution;
|
||||
env.close (closeTime);
|
||||
ApplyViewImpl av (&*env.current (), tapNONE);
|
||||
|
||||
Reference in New Issue
Block a user