Skip to content

Commit

Permalink
fixup! Improve handling of 0 drop reference fee with TxQ
Browse files Browse the repository at this point in the history
* Appropos of nothing, allow 0 reserves, too.
  • Loading branch information
ximinez committed Aug 26, 2022
1 parent 5d8f25e commit fc53680
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
18 changes: 13 additions & 5 deletions src/ripple/app/misc/impl/TxQ.cpp
Expand Up @@ -1078,19 +1078,27 @@ TxQ::apply(
LastLedgerSeq and MaybeTx::retriesRemaining.
*/
auto const balance = (*sleAccount)[sfBalance].xrp();
/* Get the minimum possible reserve. If fees exceed
/* Get the minimum possible account reserve. If it
is at least 10 * the base fee, and fees exceed
this amount, the transaction can't be queued.
Considering that typical fees are several orders
Currently typical fees are several orders
of magnitude smaller than any current or expected
future reserve, this calculation is simpler than
future reserve. This calculation is simpler than
trying to figure out the potential changes to
the ownerCount that may occur to the account
as a result of these transactions, and removes
as a result of these transactions, and removes
any need to account for other transactions that
may affect the owner count while these are queued.
However, in case the account reserve is on a
comparable scale to the base fee, ignore the
reserve. Only check the account balance.
*/
auto const reserve = view.fees().accountReserve(0);
if (totalFee >= balance || totalFee >= reserve)
auto const base = view.fees().base;
if (totalFee >= balance ||
(reserve > 10 * base && totalFee >= reserve))
{
// Drop the current transaction
JLOG(j_.trace()) << "Ignoring transaction " << transactionID
Expand Down
6 changes: 3 additions & 3 deletions src/test/app/TxQ_test.cpp
Expand Up @@ -4803,15 +4803,15 @@ class TxQ1_test : public beast::unit_test::suite
makeConfig(
{{"minimum_txn_in_ledger_standalone", "3"}},
{{"reference_fee", "0"},
{"account_reserve", "200"},
{"owner_reserve", "50"}}));
{"account_reserve", "0"},
{"owner_reserve", "0"}}));

BEAST_EXPECT(env.current()->fees().base == 10);

checkMetrics(__LINE__, env, 0, std::nullopt, 0, 3, 256);

// ledgers in queue is 2 because of makeConfig
auto const initQueueMax = initFee(env, 3, 2, 0, 200, 50);
auto const initQueueMax = initFee(env, 3, 2, 0, 0, 0);

BEAST_EXPECT(env.current()->fees().base == 0);

Expand Down

0 comments on commit fc53680

Please sign in to comment.