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) 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"); auto j = app.journal ("LedgerConsensus");
if (set) if (set)
{ {
@@ -1900,17 +1896,8 @@ void applyTransactions (
if (txn) if (txn)
{ {
if (newTxOrder) // All transactions execute in canonical order
{ retriableTxs.insert (txn);
// 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);
}
} }
} }
} }

View File

@@ -24,15 +24,6 @@
namespace ripple { namespace ripple {
namespace path { 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 // 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 // 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. // 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; TER resultCode = tesSUCCESS;
if (!enableDirRestartFix (rippleCalc_.view.info ().parentCloseTime))
{
node().directory.restart(multiQuality_);
}
// Accumulation of what the previous node must deliver. // Accumulation of what the previous node must deliver.
// Possible optimization: Note this gets zeroed on each increment, ideally // Possible optimization: Note this gets zeroed on each increment, ideally
// only on first increment, then it could be a limit on the forward pass. // only on first increment, then it could be a limit on the forward pass.
@@ -370,11 +356,8 @@ TER PathCursor::deliverNodeReverse (
// increment // increment
) const ) 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); 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 // would remove the first "taker gets" xrp offer, even though the offer is
// still funded and not used for the payment. // still funded and not used for the payment.
// Mon Aug 17 11:00:00am PDT using namespace jtx;
static NetClock::time_point const switchoverTime ( Env env (*this);
std::chrono::seconds (493149600));
for(int i=0; i<2; ++i) // ledger close times have a dynamic resolution depending on network
{ // conditions it appears the resolution in test is 10 seconds
using namespace jtx; env.close ();
Env env (*this);
auto const tp = switchoverTime + std::chrono::seconds (i); auto const gw = Account ("gateway");
bool const enableFix = tp > switchoverTime; auto const USD = gw["USD"];
expect (enableFix == bool(i)); 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 env.fund (XRP (10000), alice, bob, carol, gw);
// conditions it appears the resolution in test is 10 seconds env.trust (USD (1000), alice, bob, carol);
env.close (tp, {}); env.trust (BTC (1000), alice, bob, carol);
NetClock::time_point const pct ( env (pay (gw, alice, BTC (1000)));
std::chrono::seconds (env.open ()->info ().parentCloseTime));
if (enableFix)
expect (pct > switchoverTime);
else
expect (pct <= switchoverTime);
auto const gw = Account ("gateway"); env (pay (gw, carol, USD (1000)));
auto const USD = gw["USD"]; env (pay (gw, carol, BTC (1000)));
auto const BTC = gw["BTC"];
Account const alice ("alice");
Account const bob ("bob");
Account const carol ("carol");
env.fund (XRP (10000), alice, bob, carol, gw); // Must be two offers at the same quality
env.trust (USD (1000), alice, bob, carol); // "taker gets" must be XRP
env.trust (BTC (1000), alice, bob, carol); // (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))); // Offers for the good quality path
env (pay (gw, carol, BTC (1000))); env (offer (carol, BTC (1), USD (100)));
// Must be two offers at the same quality PathSet paths (Path (XRP, USD), Path (USD));
// "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)));
// Offers for the poor quality path env (pay ("alice", "bob", USD (100)), json (paths.json ()),
// Must be two offers at the same quality sendmax (BTC (1000)), txflags (tfPartialPayment));
env (offer (carol, XRP (50), USD (50)));
env (offer (carol, XRP (50), USD (50)));
// Offers for the good quality path env.require (balance ("bob", USD (100)));
env (offer (carol, BTC (1), USD (100))); expect (!isOffer (env, "carol", BTC (1), USD (100)) &&
isOffer (env, "carol", BTC (49), XRP (49)));
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)));
}
} }
void testCanceledOffer () void testCanceledOffer ()
{ {

View File

@@ -658,8 +658,6 @@ CreateOffer::applyGuts (ApplyView& view, ApplyView& view_cancel)
auto const sleCreator = view.peek (keylet::account(account_)); auto const sleCreator = view.peek (keylet::account(account_));
deprecatedWrongOwnerCount_ = (*sleCreator)[sfOwnerCount];
auto const uSequence = ctx_.tx.getSequence (); auto const uSequence = ctx_.tx.getSequence ();
// This is the original rate of the offer, and is the rate at which // 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 XRPAmount reserve = ctx_.view().fees().accountReserve(
static NetClock::time_point const switchoverTime ( sleCreator->getFieldU32 (sfOwnerCount) + 1);
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);
if (mPriorBalance < reserve) if (mPriorBalance < reserve)
{ {

View File

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

View File

@@ -28,17 +28,6 @@ namespace ripple {
// See https://ripple.com/wiki/Transaction_Format#Payment_.280.29 // 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 TER
Payment::preflight (PreflightContext const& ctx) Payment::preflight (PreflightContext const& ctx)
{ {
@@ -199,14 +188,6 @@ Payment::preflight (PreflightContext const& ctx)
TER TER
Payment::preclaim(PreclaimContext const& ctx) 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. // Ripple if source or destination is non-native or if there are paths.
std::uint32_t const uTxFlags = ctx.tx.getFlags(); std::uint32_t const uTxFlags = ctx.tx.getFlags();
bool const partialPaymentAllowed = uTxFlags & tfPartialPayment; bool const partialPaymentAllowed = uTxFlags & tfPartialPayment;