Compare commits

..

18 Commits

Author SHA1 Message Date
Nik Bougalis
427c33dbd7 Set version to 0.30.1-hf2 2016-02-26 15:58:09 -08:00
seelabs
675cbb72a6 Fix underflow issue for XRP:
When specifying that a result should be rounded up,
the code rounded up to a value suitable for a non-xrp
amount. When called with an xrp amount, if that rounded-up
value was less than one drop, the code rounded down to zero.

This could cause funded offers to be removed as unfunded.
2016-02-26 15:57:39 -08:00
Vinnie Falco
7837eed21b Disable Rules assignment in Ledger::setup:
This is a temporary fix for a thread-unsafe access.
2016-02-22 14:40:44 -05:00
Vinnie Falco
f0624581d1 Set version to 0.30.1-hf1 2016-02-11 18:19:31 -05:00
Vinnie Falco
cb23352a35 Revert "Set version to 0.30.1-hf1"
This reverts commit 9fea06ad84.
2016-02-11 18:19:08 -05:00
Vinnie Falco
9fea06ad84 Set version to 0.30.1-hf1 2016-02-11 15:48:32 -05:00
Miguel Portilla
2beeb9a293 Improved reporting for delivered_amount:
* Determine tx success from metadata result.
* Report delivered_amount for legacy account_tx queries.
2016-02-11 15:47:40 -05:00
Nik Bougalis
c717006c44 Set version to 0.30.1 2016-02-08 15:37:02 -08:00
Nik Bougalis
fd33d693c4 Merge remote-tracking branch 'upstream/master' 2016-02-08 15:36:04 -08:00
Nik Bougalis
31ecb4dcf3 Revert "Set version to 0.30.1"
This reverts commit 5a4e900a21.
2016-02-08 15:35:22 -08:00
Nik Bougalis
5a4e900a21 Set version to 0.30.1 2016-02-03 14:49:07 -08:00
Nik Bougalis
5062e65277 Set version to 0.30.1-rc4 2016-01-27 13:33:07 -08:00
seelabs
bd44880d5a Enforce no-ripple constraints 2016-01-27 13:32:38 -08:00
Nik Bougalis
ad2383bd4b Set version to 0.30.0-hf2 2016-01-27 12:27:27 -08:00
Nik Bougalis
5b5a01989c Improve compile-time OpenSSL version check 2016-01-27 12:27:18 -08:00
seelabs
c17f7e8b37 Enforce no-ripple constraints 2016-01-26 13:52:41 -08:00
Nik Bougalis
5f4fe9fccb Set version to 0.30.1-rc3 2016-01-20 15:56:16 -08:00
Nik Bougalis
db9885e1fc Delete unfunded offers in predictable order 2016-01-20 15:56:10 -08:00
12 changed files with 94 additions and 28 deletions

View File

@@ -714,6 +714,7 @@ Ledger::setup (Config const& config)
Throw(); Throw();
} }
#if 0
try try
{ {
rules_ = Rules(*this); rules_ = Rules(*this);
@@ -726,6 +727,7 @@ Ledger::setup (Config const& config)
{ {
Throw(); Throw();
} }
#endif
return ret; return ret;
} }

View File

@@ -799,6 +799,19 @@ TER PathState::checkNoRipple (
if (terStatus != tesSUCCESS) if (terStatus != tesSUCCESS)
return terStatus; return terStatus;
} }
if (!nodes_[i - 1].isAccount() &&
nodes_[i].isAccount() &&
nodes_[i + 1].isAccount() &&
nodes_[i -1].issue_.account != nodes_[i].account_)
{ // offer -> account -> account
auto const& currencyID = nodes_[i].issue_.currency;
terStatus = checkNoRipple (
nodes_[i-1].issue_.account, nodes_[i].account_, nodes_[i+1].account_,
currencyID);
if (terStatus != tesSUCCESS)
return terStatus;
}
} }
return tesSUCCESS; return tesSUCCESS;

View File

@@ -32,7 +32,7 @@ namespace {
static static
TER TER
deleteOffers (ApplyView& view, deleteOffers (ApplyView& view,
OfferSet const& offers, beast::Journal j) std::set<uint256> const& offers, beast::Journal j)
{ {
for (auto& e: offers) for (auto& e: offers)
if (TER r = offerDelete (view, if (TER r = offerDelete (view,
@@ -201,7 +201,7 @@ TER RippleCalc::rippleCalculate ()
getRate (saDstAmountReq_, saMaxAmountReq_) : 0; getRate (saDstAmountReq_, saMaxAmountReq_) : 0;
// Offers that became unfunded. // Offers that became unfunded.
OfferSet unfundedOffersFromBestPaths; std::set<uint256> unfundedOffersFromBestPaths;
int iPass = 0; int iPass = 0;

View File

@@ -106,10 +106,10 @@ public:
PaymentSandbox& view; PaymentSandbox& view;
// If the transaction fails to meet some constraint, still need to delete // If the transaction fails to meet some constraint, still need to delete
// unfunded offers. // unfunded offers in a deterministic order (hence the ordered container).
// //
// Offers that were found unfunded. // Offers that were found unfunded.
path::OfferSet permanentlyUnfundedOffers_; std::set<uint256> permanentlyUnfundedOffers_;
// First time working in reverse a funding source was mentioned. Source may // First time working in reverse a funding source was mentioned. Source may
// only be used there. // only be used there.

View File

@@ -30,8 +30,6 @@ namespace path {
using NodeIndex = unsigned int; using NodeIndex = unsigned int;
using OfferSet = hash_set <uint256>;
} }
using AccountIssueToNodeIndex = hash_map <AccountIssue, path::NodeIndex>; using AccountIssueToNodeIndex = hash_map <AccountIssue, path::NodeIndex>;

View File

@@ -382,16 +382,19 @@ multiply (STAmount const& v1, STAmount const& v2, Issue const& issue);
class STAmountCalcSwitchovers class STAmountCalcSwitchovers
{ {
bool enableUnderflowFix_ {false}; bool enableUnderflowFix_ {false};
bool enableUnderflowFix2_ {false};
public: public:
STAmountCalcSwitchovers () = delete; STAmountCalcSwitchovers () = delete;
explicit explicit
STAmountCalcSwitchovers (NetClock::time_point parentCloseTime); STAmountCalcSwitchovers (NetClock::time_point parentCloseTime);
explicit explicit
STAmountCalcSwitchovers (bool enableAll) STAmountCalcSwitchovers (bool enableAll)
: enableUnderflowFix_ (enableAll) {} : enableUnderflowFix_ (enableAll), enableUnderflowFix2_(enableAll) {}
bool enableUnderflowFix () const; bool enableUnderflowFix () const;
bool enableUnderflowFix2 () const;
// for tests // for tests
static NetClock::time_point enableUnderflowFixCloseTime (); static NetClock::time_point enableUnderflowFixCloseTime ();
static NetClock::time_point enableUnderflowFixCloseTime2 ();
}; };
// multiply, or divide rounding result in specified direction // multiply, or divide rounding result in specified direction

View File

@@ -35,7 +35,7 @@ char const* getRawVersionString ()
// //
// The build version number (edit this for each release) // The build version number (edit this for each release)
// //
"0.30.1-rc2" "0.30.1-hf2"
// //
// Must follow the format described here: // Must follow the format described here:
// //

View File

@@ -1207,10 +1207,20 @@ mulRound (STAmount const& v1, STAmount const& v2,
STAmount result (issue, amount, offset, resultNegative); STAmount result (issue, amount, offset, resultNegative);
if (switchovers.enableUnderflowFix () && roundUp && !resultNegative && !result) if (switchovers.enableUnderflowFix () && roundUp && !resultNegative && !result)
{ {
// return the smallest value above zero if (isXRP(issue) && switchovers.enableUnderflowFix2 ())
amount = STAmount::cMinValue; {
offset = STAmount::cMinOffset; // return the smallest value above zero
return STAmount (issue, amount, offset, resultNegative); amount = 1;
offset = 0;
return STAmount(issue, amount, offset, resultNegative);
}
else
{
// return the smallest value above zero
amount = STAmount::cMinValue;
offset = STAmount::cMinOffset;
return STAmount(issue, amount, offset, resultNegative);
}
} }
return result; return result;
} }
@@ -1267,10 +1277,20 @@ divRound (STAmount const& num, STAmount const& den,
STAmount result (issue, amount, offset, resultNegative); STAmount result (issue, amount, offset, resultNegative);
if (switchovers.enableUnderflowFix () && roundUp && !resultNegative && !result) if (switchovers.enableUnderflowFix () && roundUp && !resultNegative && !result)
{ {
// return the smallest value above zero if (isXRP(issue) && switchovers.enableUnderflowFix2 ())
amount = STAmount::cMinValue; {
offset = STAmount::cMinOffset; // return the smallest value above zero
return STAmount (issue, amount, offset, resultNegative); amount = 1;
offset = 0;
return STAmount(issue, amount, offset, resultNegative);
}
else
{
// return the smallest value above zero
amount = STAmount::cMinValue;
offset = STAmount::cMinOffset;
return STAmount(issue, amount, offset, resultNegative);
}
} }
return result; return result;
} }
@@ -1283,9 +1303,18 @@ STAmountCalcSwitchovers::enableUnderflowFixCloseTime ()
return NetClock::time_point{504640800s}; return NetClock::time_point{504640800s};
} }
NetClock::time_point
STAmountCalcSwitchovers::enableUnderflowFixCloseTime2 ()
{
using namespace std::chrono_literals;
// Fri Feb 26, 2016 9:00:00pm PST
return NetClock::time_point{509864400s};
}
STAmountCalcSwitchovers::STAmountCalcSwitchovers (NetClock::time_point parentCloseTime) STAmountCalcSwitchovers::STAmountCalcSwitchovers (NetClock::time_point parentCloseTime)
{ {
enableUnderflowFix_ = parentCloseTime > enableUnderflowFixCloseTime(); enableUnderflowFix_ = parentCloseTime > enableUnderflowFixCloseTime();
enableUnderflowFix2_ = parentCloseTime > enableUnderflowFixCloseTime2();
} }
@@ -1294,4 +1323,9 @@ bool STAmountCalcSwitchovers::enableUnderflowFix () const
return enableUnderflowFix_; return enableUnderflowFix_;
} }
bool STAmountCalcSwitchovers::enableUnderflowFix2 () const
{
return enableUnderflowFix2_;
}
} // ripple } // ripple

View File

@@ -163,7 +163,7 @@ Json::Value doAccountTx (RPC::Context& context)
{ {
auto meta = it.second->getJson (1); auto meta = it.second->getJson (1);
addPaymentDeliveredAmount (meta, context, it.first, it.second); addPaymentDeliveredAmount (meta, context, it.first, it.second);
jvObj[jss::meta] = meta; jvObj[jss::meta] = std::move(meta);
std::uint32_t uLedgerIndex = it.second->getLgrSeq (); std::uint32_t uLedgerIndex = it.second->getLgrSeq ();

View File

@@ -29,6 +29,7 @@
#include <ripple/resource/Fees.h> #include <ripple/resource/Fees.h>
#include <ripple/rpc/Context.h> #include <ripple/rpc/Context.h>
#include <ripple/rpc/impl/LookupLedger.h> #include <ripple/rpc/impl/LookupLedger.h>
#include <ripple/rpc/impl/Utilities.h>
#include <ripple/server/Role.h> #include <ripple/server/Role.h>
namespace ripple { namespace ripple {
@@ -183,7 +184,10 @@ Json::Value doAccountTxOld (RPC::Context& context)
{ {
std::uint32_t uLedgerIndex = it->second->getLgrSeq (); std::uint32_t uLedgerIndex = it->second->getLgrSeq ();
jvObj[jss::meta] = it->second->getJson (0); auto meta = it->second->getJson(0);
addPaymentDeliveredAmount(meta, context, it->first, it->second);
jvObj[jss::meta] = std::move(meta);
jvObj[jss::validated] jvObj[jss::validated]
= bValidated = bValidated
&& uValidatedMin <= uLedgerIndex && uValidatedMin <= uLedgerIndex

View File

@@ -39,20 +39,29 @@ addPaymentDeliveredAmount (
{ {
// We only want to add a "delivered_amount" field if the transaction // We only want to add a "delivered_amount" field if the transaction
// succeeded - otherwise nothing could have been delivered. // succeeded - otherwise nothing could have been delivered.
if (!transaction || transaction->getResult () != tesSUCCESS) if (! transaction)
return; return;
auto serializedTx = transaction->getSTransaction (); auto serializedTx = transaction->getSTransaction ();
if (! serializedTx || serializedTx->getTxnType () != ttPAYMENT)
if (!serializedTx || serializedTx->getTxnType () != ttPAYMENT)
return; return;
// If the transaction explicitly specifies a DeliveredAmount in the if (transactionMeta)
// metadata then we use it. {
if (transactionMeta && transactionMeta->hasDeliveredAmount ()) if (transactionMeta->getResultTER() != tesSUCCESS)
return;
// If the transaction explicitly specifies a DeliveredAmount in the
// metadata then we use it.
if (transactionMeta->hasDeliveredAmount ())
{
meta[jss::delivered_amount] =
transactionMeta->getDeliveredAmount ().getJson (1);
return;
}
}
else if (transaction->getResult() != tesSUCCESS)
{ {
meta[jss::delivered_amount] =
transactionMeta->getDeliveredAmount ().getJson (1);
return; return;
} }

View File

@@ -94,7 +94,10 @@ suite 'Discrepancy test', ->
suite 'RIPD 304', -> suite 'RIPD 304', ->
get_context = server_setup_teardown({server_opts: {ledger_file: 'ledger-7145315.json'}}) get_context = server_setup_teardown({server_opts: {ledger_file: 'ledger-7145315.json'}})
test 'B1A305038D43BCDF3EA1D096E6A0ACC5FB0ECAE0C8F5D3A54AD76A2AA1E20EC4', (done) -> # Skip - New rounding code makes the actaul value differ from the expected
# by tiny amounts. Re-enable after we figure out what this test is meant to
# be testing.
test.skip 'B1A305038D43BCDF3EA1D096E6A0ACC5FB0ECAE0C8F5D3A54AD76A2AA1E20EC4', (done) ->
{remote} = get_context() {remote} = get_context()
txns_to_submit = [ txns_to_submit = [