From 72f0af48bc4bdeecf95153801dcb672cd7f4731c Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Thu, 18 Aug 2022 13:09:14 -0700 Subject: [PATCH] fixup! Improve handling of 0 drop reference fee with TxQ * Appropos of nothing, allow 0 reserves, too. --- src/ripple/app/misc/impl/TxQ.cpp | 18 +++++++++++++----- src/test/app/TxQ_test.cpp | 6 +++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/ripple/app/misc/impl/TxQ.cpp b/src/ripple/app/misc/impl/TxQ.cpp index f34427e46b1..8b56945c719 100644 --- a/src/ripple/app/misc/impl/TxQ.cpp +++ b/src/ripple/app/misc/impl/TxQ.cpp @@ -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 diff --git a/src/test/app/TxQ_test.cpp b/src/test/app/TxQ_test.cpp index 8b3ef686776..e25c9f60de1 100644 --- a/src/test/app/TxQ_test.cpp +++ b/src/test/app/TxQ_test.cpp @@ -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);