Skip to content

Commit

Permalink
Make the FeeEscalation amendment permanent (RIPD-1654):
Browse files Browse the repository at this point in the history
The FeeEscalation amendment has been enabled on the XRP Ledger network
since May 19, 2016. The transaction which activated this amendment is:
5B1F1E8E791A9C243DD728680F108FEF1F28F21BA3B202B8F66E7833CA71D3C3.

This change removes all conditional code based around the FeeEscalation
amendment, but leaves the amendment definition itself since removing the
definition would cause nodes to think an unknown amendment was activate
causing them to become amendment blocked.

The commit also removes the redundant precomputed hashes from the
supportedAmendments vector.
  • Loading branch information
ximinez authored and nbougalis committed Nov 6, 2018
1 parent a96cb8f commit 58f786c
Show file tree
Hide file tree
Showing 16 changed files with 190 additions and 324 deletions.
12 changes: 11 additions & 1 deletion src/ripple/app/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1212,8 +1212,18 @@ bool ApplicationImp::setup()

// Configure the amendments the server supports
{
auto const& sa = detail::supportedAmendments();
std::vector<std::string> saHashes;
saHashes.reserve(sa.size());
for (auto const& name : sa)
{
auto const f = getRegisteredFeature(name);
BOOST_ASSERT(f);
if (f)
saHashes.push_back(to_string(*f) + " " + name);
}
Section supportedAmendments ("Supported Amendments");
supportedAmendments.append (detail::supportedAmendments ());
supportedAmendments.append (saHashes);

Section enabledAmendments = config_->section (SECTION_AMENDMENTS);

Expand Down
80 changes: 37 additions & 43 deletions src/ripple/app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class NetworkOPsImp final
ServerFeeSummary() = default;

ServerFeeSummary(std::uint64_t fee,
boost::optional<TxQ::Metrics>&& escalationMetrics,
TxQ::Metrics&& escalationMetrics,
LoadFeeTrack const & loadFeeTrack);
bool
operator !=(ServerFeeSummary const & b) const;
Expand Down Expand Up @@ -1587,7 +1587,7 @@ void NetworkOPsImp::pubManifest (Manifest const& mo)

NetworkOPsImp::ServerFeeSummary::ServerFeeSummary(
std::uint64_t fee,
boost::optional<TxQ::Metrics>&& escalationMetrics,
TxQ::Metrics&& escalationMetrics,
LoadFeeTrack const & loadFeeTrack)
: loadFactorServer{loadFeeTrack.getLoadFactor()}
, loadBaseServer{loadFeeTrack.getLoadBase()}
Expand Down Expand Up @@ -2208,43 +2208,40 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin, bool counters)
auto const escalationMetrics = app_.getTxQ().getMetrics(
*app_.openLedger().current());

constexpr std::uint64_t max32 =
std::numeric_limits<std::uint32_t>::max();

auto const loadFactorServer = app_.getFeeTrack().getLoadFactor();
auto const loadBaseServer = app_.getFeeTrack().getLoadBase();
auto const loadFactorFeeEscalation = escalationMetrics ?
escalationMetrics->openLedgerFeeLevel : 1;
auto const loadBaseFeeEscalation = escalationMetrics ?
escalationMetrics->referenceFeeLevel : 1;
auto const loadFactorFeeEscalation =
escalationMetrics.openLedgerFeeLevel;
auto const loadBaseFeeEscalation =
escalationMetrics.referenceFeeLevel;

auto const loadFactor = std::max(static_cast<std::uint64_t>(loadFactorServer),
mulDiv(loadFactorFeeEscalation, loadBaseServer, loadBaseFeeEscalation).second);

if (!human)
{
constexpr std::uint64_t max32 =
std::numeric_limits<std::uint32_t>::max();

info[jss::load_base] = loadBaseServer;
info[jss::load_factor] = static_cast<std::uint32_t>(
std::min(max32, loadFactor));
if (escalationMetrics)
{
info[jss::load_factor_server] = loadFactorServer;

/* Json::Value doesn't support uint64, so clamp to max
uint32 value. This is mostly theoretical, since there
probably isn't enough extant XRP to drive the factor
that high.
*/
info[jss::load_factor_fee_escalation] =
static_cast<std::uint32_t> (std::min(
max32, loadFactorFeeEscalation));
info[jss::load_factor_fee_queue] =
static_cast<std::uint32_t> (std::min(
max32, escalationMetrics->minProcessingFeeLevel));
info[jss::load_factor_fee_reference] =
static_cast<std::uint32_t> (std::min(
max32, loadBaseFeeEscalation));
}
info[jss::load_factor_server] = loadFactorServer;

/* Json::Value doesn't support uint64, so clamp to max
uint32 value. This is mostly theoretical, since there
probably isn't enough extant XRP to drive the factor
that high.
*/
info[jss::load_factor_fee_escalation] =
static_cast<std::uint32_t> (std::min(
max32, loadFactorFeeEscalation));
info[jss::load_factor_fee_queue] =
static_cast<std::uint32_t> (std::min(
max32, escalationMetrics.minProcessingFeeLevel));
info[jss::load_factor_fee_reference] =
static_cast<std::uint32_t> (std::min(
max32, loadBaseFeeEscalation));
}
else
{
Expand All @@ -2269,21 +2266,18 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin, bool counters)
info[jss::load_factor_cluster] =
static_cast<double> (fee) / loadBaseServer;
}
if (escalationMetrics)
{
if (loadFactorFeeEscalation !=
escalationMetrics->referenceFeeLevel &&
(admin || loadFactorFeeEscalation != loadFactor))
info[jss::load_factor_fee_escalation] =
static_cast<double> (loadFactorFeeEscalation) /
escalationMetrics->referenceFeeLevel;
if (escalationMetrics->minProcessingFeeLevel !=
escalationMetrics->referenceFeeLevel)
info[jss::load_factor_fee_queue] =
static_cast<double> (
escalationMetrics->minProcessingFeeLevel) /
escalationMetrics->referenceFeeLevel;
}
if (loadFactorFeeEscalation !=
escalationMetrics.referenceFeeLevel &&
(admin || loadFactorFeeEscalation != loadFactor))
info[jss::load_factor_fee_escalation] =
static_cast<double> (loadFactorFeeEscalation) /
escalationMetrics.referenceFeeLevel;
if (escalationMetrics.minProcessingFeeLevel !=
escalationMetrics.referenceFeeLevel)
info[jss::load_factor_fee_queue] =
static_cast<double> (
escalationMetrics.minProcessingFeeLevel) /
escalationMetrics.referenceFeeLevel;
}

bool valid = false;
Expand Down
15 changes: 2 additions & 13 deletions src/ripple/app/misc/TxQ.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,18 +315,14 @@ class TxQ
ReadView const& view, bool timeLeap);

/** Returns fee metrics in reference fee level units.
@returns Uninitialized boost::optional if the
FeeEscalation amendment is not enabled.
*/
boost::optional<Metrics>
Metrics
getMetrics(OpenView const& view) const;

/** Returns information about the transactions currently
in the queue for the account.
@returns Empty `map` if the
FeeEscalation amendment is not enabled, OR if the
account has no transactions in the queue.
*/
std::map<TxSeq, AccountTxDetails const>
Expand All @@ -335,8 +331,7 @@ class TxQ
/** Returns information about all transactions currently
in the queue.
@returns Empty `vector` if the FeeEscalation
amendment is not enabled, OR if there are no transactions
@returns Empty `vector` if there are no transactions
in the queue.
*/
std::vector<TxDetails>
Expand Down Expand Up @@ -440,12 +435,6 @@ class TxQ
queue.
@param view Current open ledger.
@param txCountPadding Optional number of "extra" transactions
to assume are in the ledger. Can be used to determine a
padded fee, so a transaction can pay more if the user is
concerned that more transactions will get into the open
ledger between the time this fee is computed and the
transaction is submitted.
@return A fee level value.
*/
Expand Down
86 changes: 26 additions & 60 deletions src/ripple/app/misc/impl/TxQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,13 +619,6 @@ TxQ::apply(Application& app, OpenView& view,
std::shared_ptr<STTx const> const& tx,
ApplyFlags flags, beast::Journal j)
{
auto const allowEscalation =
(view.rules().enabled(featureFeeEscalation));
if (!allowEscalation)
{
return ripple::apply(app, view, *tx, flags, j);
}

auto const account = (*tx)[sfAccount];
auto const transactionID = tx->getTransactionID();
auto const tSeq = tx->getSequence();
Expand Down Expand Up @@ -1169,13 +1162,6 @@ void
TxQ::processClosedLedger(Application& app,
ReadView const& view, bool timeLeap)
{
auto const allowEscalation =
(view.rules().enabled(featureFeeEscalation));
if (!allowEscalation)
{
return;
}

std::lock_guard<std::mutex> lock(mutex_);

feeMetrics_.update(app, view, timeLeap, setup_);
Expand Down Expand Up @@ -1250,13 +1236,6 @@ bool
TxQ::accept(Application& app,
OpenView& view)
{
auto const allowEscalation =
(view.rules().enabled(featureFeeEscalation));
if (!allowEscalation)
{
return false;
}

/* Move transactions from the queue from largest fee level to smallest.
As we add more transactions, the required fee level will increase.
Stop when the transaction fee level gets lower than the required fee
Expand Down Expand Up @@ -1374,15 +1353,9 @@ TxQ::accept(Application& app,
return ledgerChanged;
}

auto
TxQ::Metrics
TxQ::getMetrics(OpenView const& view) const
-> boost::optional<Metrics>
{
auto const allowEscalation =
(view.rules().enabled(featureFeeEscalation));
if (!allowEscalation)
return boost::none;

Metrics result;

std::lock_guard<std::mutex> lock(mutex_);
Expand All @@ -1406,11 +1379,6 @@ auto
TxQ::getAccountTxs(AccountID const& account, ReadView const& view) const
-> std::map<TxSeq, AccountTxDetails const>
{
auto const allowEscalation =
(view.rules().enabled(featureFeeEscalation));
if (!allowEscalation)
return {};

std::lock_guard<std::mutex> lock(mutex_);

auto accountIter = byAccount_.find(account);
Expand Down Expand Up @@ -1440,11 +1408,6 @@ auto
TxQ::getTxs(ReadView const& view) const
-> std::vector<TxDetails>
{
auto const allowEscalation =
(view.rules().enabled(featureFeeEscalation));
if (!allowEscalation)
return {};

std::lock_guard<std::mutex> lock(mutex_);

if (byFee_.empty())
Expand Down Expand Up @@ -1483,45 +1446,48 @@ TxQ::doRPC(Application& app) const
using std::to_string;

auto const view = app.openLedger().current();
auto const metrics = getMetrics(*view);
if (!view)
{
BOOST_ASSERT(false);
return {};
}

if (!metrics)
return{};
auto const metrics = getMetrics(*view);

Json::Value ret(Json::objectValue);

auto& levels = ret[jss::levels] = Json::objectValue;

ret[jss::ledger_current_index] = view->info().seq;
ret[jss::expected_ledger_size] = to_string(metrics->txPerLedger);
ret[jss::current_ledger_size] = to_string(metrics->txInLedger);
ret[jss::current_queue_size] = to_string(metrics->txCount);
if (metrics->txQMaxSize)
ret[jss::max_queue_size] = to_string(*metrics->txQMaxSize);
ret[jss::expected_ledger_size] = to_string(metrics.txPerLedger);
ret[jss::current_ledger_size] = to_string(metrics.txInLedger);
ret[jss::current_queue_size] = to_string(metrics.txCount);
if (metrics.txQMaxSize)
ret[jss::max_queue_size] = to_string(*metrics.txQMaxSize);

levels[jss::reference_level] = to_string(metrics->referenceFeeLevel);
levels[jss::minimum_level] = to_string(metrics->minProcessingFeeLevel);
levels[jss::median_level] = to_string(metrics->medFeeLevel);
levels[jss::open_ledger_level] = to_string(metrics->openLedgerFeeLevel);
levels[jss::reference_level] = to_string(metrics.referenceFeeLevel);
levels[jss::minimum_level] = to_string(metrics.minProcessingFeeLevel);
levels[jss::median_level] = to_string(metrics.medFeeLevel);
levels[jss::open_ledger_level] = to_string(metrics.openLedgerFeeLevel);

auto const baseFee = view->fees().base;
auto& drops = ret[jss::drops] = Json::Value();

// Don't care about the overflow flags
drops[jss::base_fee] = to_string(mulDiv(
metrics->referenceFeeLevel, baseFee,
metrics->referenceFeeLevel).second);
metrics.referenceFeeLevel, baseFee,
metrics.referenceFeeLevel).second);
drops[jss::minimum_fee] = to_string(mulDiv(
metrics->minProcessingFeeLevel, baseFee,
metrics->referenceFeeLevel).second);
metrics.minProcessingFeeLevel, baseFee,
metrics.referenceFeeLevel).second);
drops[jss::median_fee] = to_string(mulDiv(
metrics->medFeeLevel, baseFee,
metrics->referenceFeeLevel).second);
metrics.medFeeLevel, baseFee,
metrics.referenceFeeLevel).second);
auto escalatedFee = mulDiv(
metrics->openLedgerFeeLevel, baseFee,
metrics->referenceFeeLevel).second;
if (mulDiv(escalatedFee, metrics->referenceFeeLevel,
baseFee).second < metrics->openLedgerFeeLevel)
metrics.openLedgerFeeLevel, baseFee,
metrics.referenceFeeLevel).second;
if (mulDiv(escalatedFee, metrics.referenceFeeLevel,
baseFee).second < metrics.openLedgerFeeLevel)
++escalatedFee;

drops[jss::open_ledger_fee] = to_string(escalatedFee);
Expand Down
1 change: 0 additions & 1 deletion src/ripple/protocol/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ foreachFeature(FeatureBitset bs, F&& f)
extern uint256 const featureMultiSign;
extern uint256 const featureTickets;
extern uint256 const featureTrustSetAuth;
extern uint256 const featureFeeEscalation;
extern uint256 const featureOwnerPaysFee;
extern uint256 const featureCompareFlowV1V2;
extern uint256 const featureSHAMapV2;
Expand Down
Loading

0 comments on commit 58f786c

Please sign in to comment.