Remove already-triggered ledger switches

This commit is contained in:
Nik Bougalis
2015-11-24 03:29:47 -08:00
parent 298ef4ac4d
commit 0633ef1ba1
6 changed files with 40 additions and 125 deletions

View File

@@ -1873,10 +1873,6 @@ void applyTransactions (
ApplyFlags flags)
{
// Switch to new transaction ordering on
// October 27, 2015 at 11:00AM PDT
bool const newTxOrder = checkLedger->info().closeTime > 499284000;
auto j = app.journal ("LedgerConsensus");
if (set)
{
@@ -1900,17 +1896,8 @@ void applyTransactions (
if (txn)
{
if (newTxOrder)
{
// All transactions execute in canonical order
retriableTxs.insert (txn);
}
else if (applyTransaction(app, view, txn, true, flags, j) ==
LedgerConsensusImp::resultRetry)
{
// Failures are retried in canonical order
retriableTxs.insert (txn);
}
// All transactions execute in canonical order
retriableTxs.insert (txn);
}
}
}

View File

@@ -24,15 +24,6 @@
namespace ripple {
namespace path {
static
bool enableDirRestartFix (
std::uint32_t parentCloseTime)
{
// Mon Aug 17 11:00:00am PDT
static std::uint32_t const enableAfter = 493149600;
return parentCloseTime > enableAfter;
}
// At the right most node of a list of consecutive offer nodes, given the amount
// requested to be delivered, push towards the left nodes the amount requested
// for the right nodes so we can compute how much to deliver from the source.
@@ -54,11 +45,6 @@ TER PathCursor::deliverNodeReverseImpl (
{
TER resultCode = tesSUCCESS;
if (!enableDirRestartFix (rippleCalc_.view.info ().parentCloseTime))
{
node().directory.restart(multiQuality_);
}
// Accumulation of what the previous node must deliver.
// Possible optimization: Note this gets zeroed on each increment, ideally
// only on first increment, then it could be a limit on the forward pass.
@@ -370,11 +356,8 @@ TER PathCursor::deliverNodeReverse (
// increment
) const
{
if (enableDirRestartFix (rippleCalc_.view.info ().parentCloseTime))
{
for (int i = nodeIndex_; i >= 0 && !node (i).isAccount(); --i)
node (i).directory.restart (multiQuality_);
}
for (int i = nodeIndex_; i >= 0 && !node (i).isAccount(); --i)
node (i).directory.restart (multiQuality_);
return deliverNodeReverseImpl(uOutAccountID, saOutReq, saOutAct);
}

View File

@@ -41,73 +41,51 @@ public:
// would remove the first "taker gets" xrp offer, even though the offer is
// still funded and not used for the payment.
// Mon Aug 17 11:00:00am PDT
static NetClock::time_point const switchoverTime (
std::chrono::seconds (493149600));
using namespace jtx;
Env env (*this);
for(int i=0; i<2; ++i)
{
using namespace jtx;
Env env (*this);
// ledger close times have a dynamic resolution depending on network
// conditions it appears the resolution in test is 10 seconds
env.close ();
auto const tp = switchoverTime + std::chrono::seconds (i);
bool const enableFix = tp > switchoverTime;
expect (enableFix == bool(i));
auto const gw = Account ("gateway");
auto const USD = gw["USD"];
auto const BTC = gw["BTC"];
Account const alice ("alice");
Account const bob ("bob");
Account const carol ("carol");
// ledger close times have a dynamic resolution depending on network
// conditions it appears the resolution in test is 10 seconds
env.close (tp, {});
env.fund (XRP (10000), alice, bob, carol, gw);
env.trust (USD (1000), alice, bob, carol);
env.trust (BTC (1000), alice, bob, carol);
NetClock::time_point const pct (
std::chrono::seconds (env.open ()->info ().parentCloseTime));
if (enableFix)
expect (pct > switchoverTime);
else
expect (pct <= switchoverTime);
env (pay (gw, alice, BTC (1000)));
auto const gw = Account ("gateway");
auto const USD = gw["USD"];
auto const BTC = gw["BTC"];
Account const alice ("alice");
Account const bob ("bob");
Account const carol ("carol");
env (pay (gw, carol, USD (1000)));
env (pay (gw, carol, BTC (1000)));
env.fund (XRP (10000), alice, bob, carol, gw);
env.trust (USD (1000), alice, bob, carol);
env.trust (BTC (1000), alice, bob, carol);
// Must be two offers at the same quality
// "taker gets" must be XRP
// (Different amounts so I can distinguish the offers)
env (offer (carol, BTC (49), XRP (49)));
env (offer (carol, BTC (51), XRP (51)));
env (pay (gw, alice, BTC (1000)));
// Offers for the poor quality path
// Must be two offers at the same quality
env (offer (carol, XRP (50), USD (50)));
env (offer (carol, XRP (50), USD (50)));
env (pay (gw, carol, USD (1000)));
env (pay (gw, carol, BTC (1000)));
// Offers for the good quality path
env (offer (carol, BTC (1), USD (100)));
// Must be two offers at the same quality
// "taker gets" must be XRP
// (Different amounts so I can distinguish the offers)
env (offer (carol, BTC (49), XRP (49)));
env (offer (carol, BTC (51), XRP (51)));
PathSet paths (Path (XRP, USD), Path (USD));
// Offers for the poor quality path
// Must be two offers at the same quality
env (offer (carol, XRP (50), USD (50)));
env (offer (carol, XRP (50), USD (50)));
env (pay ("alice", "bob", USD (100)), json (paths.json ()),
sendmax (BTC (1000)), txflags (tfPartialPayment));
// Offers for the good quality path
env (offer (carol, BTC (1), USD (100)));
PathSet paths (Path (XRP, USD), Path (USD));
env (pay ("alice", "bob", USD (100)), json (paths.json ()),
sendmax (BTC (1000)), txflags (tfPartialPayment));
env.require (balance ("bob", USD (100)));
if (enableFix)
expect (!isOffer (env, "carol", BTC (1), USD (100)) &&
isOffer (env, "carol", BTC (49), XRP (49)));
else
expect (!isOffer (env, "carol", BTC (1), USD (100)) &&
!isOffer (env, "carol", BTC (49), XRP (49)));
}
env.require (balance ("bob", USD (100)));
expect (!isOffer (env, "carol", BTC (1), USD (100)) &&
isOffer (env, "carol", BTC (49), XRP (49)));
}
void testCanceledOffer ()
{

View File

@@ -658,8 +658,6 @@ CreateOffer::applyGuts (ApplyView& view, ApplyView& view_cancel)
auto const sleCreator = view.peek (keylet::account(account_));
deprecatedWrongOwnerCount_ = (*sleCreator)[sfOwnerCount];
auto const uSequence = ctx_.tx.getSequence ();
// This is the original rate of the offer, and is the rate at which
@@ -809,19 +807,8 @@ CreateOffer::applyGuts (ApplyView& view, ApplyView& view_cancel)
}
{
// Mon Aug 17 11:00:00am PDT
static NetClock::time_point const switchoverTime (
std::chrono::seconds (493149600));
XRPAmount reserve;
if (ctx_.view().info().parentCloseTime <=
switchoverTime.time_since_epoch().count())
reserve = ctx_.view().fees().accountReserve(
deprecatedWrongOwnerCount_+1);
else
reserve = ctx_.view().fees().accountReserve(
sleCreator->getFieldU32 (sfOwnerCount) + 1);
XRPAmount reserve = ctx_.view().fees().accountReserve(
sleCreator->getFieldU32 (sfOwnerCount) + 1);
if (mPriorBalance < reserve)
{

View File

@@ -122,7 +122,6 @@ private:
private:
// What kind of offer we are placing
CrossType cross_type_;
std::uint32_t deprecatedWrongOwnerCount_;
// The number of steps to take through order books while crossing
OfferStream::StepCounter stepCounter_;

View File

@@ -28,17 +28,6 @@ namespace ripple {
// See https://ripple.com/wiki/Transaction_Format#Payment_.280.29
// Mon Aug 17 11:00:00am PDT
static std::uint32_t const deliverMinTime = 493149600;
static
bool
allowDeliverMin (ReadView const& view, ApplyFlags const& flags)
{
return view.info().parentCloseTime > deliverMinTime ||
(flags & tapENABLE_TESTING);
}
TER
Payment::preflight (PreflightContext const& ctx)
{
@@ -199,14 +188,6 @@ Payment::preflight (PreflightContext const& ctx)
TER
Payment::preclaim(PreclaimContext const& ctx)
{
auto const deliverMin = ctx.tx[~sfDeliverMin];
if (deliverMin)
{
if (!allowDeliverMin(ctx.view, ctx.flags))
return temMALFORMED;
}
// Ripple if source or destination is non-native or if there are paths.
std::uint32_t const uTxFlags = ctx.tx.getFlags();
bool const partialPaymentAllowed = uTxFlags & tfPartialPayment;