Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
66f195e
Prevent divide by zero in mulDiv:
ximinez Feb 27, 2019
1ef7528
Merge branch 'develop' into overflow2
ximinez Nov 12, 2025
86a4875
Merge branch 'develop' into overflow2
ximinez Nov 13, 2025
73b9d95
Merge branch 'develop' into overflow2
ximinez Nov 15, 2025
0ac4a55
Merge branch 'develop' into overflow2
ximinez Nov 19, 2025
1d8c7ca
Merge branch 'develop' into overflow2
ximinez Nov 21, 2025
764e527
Merge branch 'develop' into overflow2
ximinez Nov 25, 2025
bc6d3de
Merge branch 'develop' into overflow2
ximinez Nov 28, 2025
23dfdf8
Merge branch 'develop' into overflow2
ximinez Dec 1, 2025
891667e
Merge branch 'develop' into overflow2
ximinez Dec 3, 2025
98625a9
Merge branch 'develop' into overflow2
ximinez Dec 6, 2025
d71633f
Merge branch 'develop' into overflow2
ximinez Dec 13, 2025
32ca091
Merge branch 'develop' into overflow2
ximinez Dec 19, 2025
693d888
Merge branch 'develop' into overflow2
ximinez Dec 22, 2025
3ac9939
Merge branch 'develop' into overflow2
ximinez Jan 6, 2026
cd9f795
Merge branch 'develop' into overflow2
ximinez Jan 8, 2026
1e24631
Merge branch 'develop' into overflow2
ximinez Jan 8, 2026
f8ce7ca
Merge branch 'develop' into overflow2
ximinez Jan 11, 2026
3ba6670
Merge branch 'develop' into overflow2
ximinez Jan 12, 2026
964a3f8
Merge branch 'develop' into overflow2
ximinez Jan 13, 2026
b9e31e4
Merge branch 'develop' into overflow2
ximinez Jan 15, 2026
7f4a1bc
Merge branch 'develop' into overflow2
ximinez Jan 28, 2026
f35c81b
Fix formatting
ximinez Jan 29, 2026
c5f828a
Merge branch 'develop' into overflow2
ximinez Feb 4, 2026
56779c7
Merge branch 'develop' into overflow2
ximinez Feb 19, 2026
2b8fd7a
Merge branch 'develop' into overflow2
ximinez Feb 19, 2026
b0b2735
Merge branch 'develop' into overflow2
ximinez Feb 20, 2026
ffd3e24
Merge branch 'develop' into overflow2
ximinez Feb 24, 2026
e6d5938
Merge branch 'develop' into overflow2
ximinez Mar 4, 2026
0784656
Merge branch 'develop' into overflow2
ximinez Mar 4, 2026
e7374fc
Merge branch 'develop' into overflow2
ximinez Mar 6, 2026
61efdac
Merge branch 'develop' into overflow2
ximinez Mar 10, 2026
283b620
Merge branch 'develop' into overflow2
ximinez Apr 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/libxrpl/basics/mulDiv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ namespace xrpl {
std::optional<std::uint64_t>
mulDiv(std::uint64_t value, std::uint64_t mul, std::uint64_t div)
{
XRPL_ASSERT(div != 0, "ripple::mulDiv : non-zero divisor);

boost::multiprecision::uint128_t result;

result = multiply(result, value, mul);

result /= div;
Expand Down
84 changes: 83 additions & 1 deletion src/test/app/TxQ_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3838,9 +3838,91 @@ class TxQPosNegFlows_test : public beast::unit_test::suite
txCount -= 4;
checkMetrics(*this, env, txCount, 54, 4, 3);

// From 28 expected back down to 3 in 3 "slow" ledgers.
// With 100% decrease percent, went from 28
// expected back down to 3 in 1 "slow" ledger.

BEAST_EXPECT(!txCount);

// Ensure it stays stable
env.close(env.now() + 5s, 10000ms);
checkMetrics(__LINE__, env, txCount, 54, 0, 3, 256);
env.close(env.now() + 5s, 10000ms);
checkMetrics(__LINE__, env, txCount, 54, 0, 3, 256);
}

{
// Use a mostly default config
Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "3"}}));
auto alice = Account("alice");

checkMetrics(__LINE__, env, 0, std::nullopt, 0, 3, 256);
env.fund(XRP(50000000), alice);

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

// Verify that the numbers stay steady by creating
// a relatively large open ledger, then doing a slow
// close
for (int i = 0; i < 50; ++i)
{
env(noop(alice), openLedgerFee(env));
}
checkMetrics(__LINE__, env, 0, std::nullopt, 54, 3, 256);
// Close the ledger with a delay.
env.close(env.now() + 5s, 10000ms);

// expectedPerLedger should never go below 3
checkMetrics(__LINE__, env, 0, std::nullopt, 0, 3, 256, 9991129);

// Do it again
for (int i = 0; i < 50; ++i)
{
env(noop(alice), openLedgerFee(env));
}
checkMetrics(__LINE__, env, 0, std::nullopt, 50, 3, 256, 9991129);

// Close the ledger with a delay.
env.close(env.now() + 5s, 10000ms);

// expectedPerLedger should never go below 3
checkMetrics(__LINE__, env, 0, std::nullopt, 0, 3, 256, 666630336);

// we don't crash anymore
env(noop(alice));
}

{
// Use a "bad" config - minimum of 0. Treated as 1 for
// escalation calculations
Env env(*this, makeConfig({{"minimum_txn_in_ledger_standalone", "0"}}));

checkMetrics(__LINE__, env, 0, std::nullopt, 0, 0, 256);
// we don't crash anymore
env(noop(env.master));

{
// The open ledger fee is 256 - as if min was 1.
auto const& view = *env.current();
auto const metrics = env.app().getTxQ().getMetrics(view);
BEAST_EXPECT(metrics.openLedgerFeeLevel == 256);
auto const openLedgerDrops =
mulDiv(metrics.openLedgerFeeLevel, view.fees().base, metrics.referenceFeeLevel);
BEAST_EXPECT(openLedgerDrops && *openLedgerDrops + 1 == 11);
}

// another transaction will trigger escalation
env(noop(env.master));

{
// But the open ledger fee does grow
auto const& view = *env.current();
auto metrics = env.app().getTxQ().getMetrics(view);
BEAST_EXPECT(metrics.openLedgerFeeLevel == 512000);
auto const openLedgerDrops =
mulDiv(metrics.openLedgerFeeLevel, view.fees().base, metrics.referenceFeeLevel);
BEAST_EXPECT(openLedgerDrops && *openLedgerDrops == 20000);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/xrpld/app/misc/detail/TxQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ TxQ::FeeMetrics::scaleFeeLevel(Snapshot const& snapshot, OpenView const& view)
// Transactions in the open ledger so far
auto const current = view.txCount();

auto const target = snapshot.txnsExpected;
auto const target = snapshot.txnsExpected == 0 ? 1 : snapshot.txnsExpected;
auto const multiplier = snapshot.escalationMultiplier;

// Once the open ledger bypasses the target,
Expand Down Expand Up @@ -216,7 +216,7 @@ TxQ::FeeMetrics::escalatedSeriesFeeLevel(
*/
auto const last = current + seriesSize - 1;

auto const target = snapshot.txnsExpected;
auto const target = snapshot.txnsExpected == 0 ? 1 : snapshot.txnsExpected;
auto const multiplier = snapshot.escalationMultiplier;

XRPL_ASSERT(
Expand Down