Compare commits

...

56 Commits

Author SHA1 Message Date
Ed Hennis
e038678bd0 Merge remote-tracking branch 'XRPLF/develop' into ximinez/lending-shortages
* XRPLF/develop:
  fix: Disable unnecessary sanity-check in VaultDeposit (7288)
  ci: [DEPENDABOT] bump actions/upload-artifact from 7.0.0 to 7.0.1 (7286)
  ci: Only run reusable package in public repos (7293)
  fix: Set default peering port to 2459 (6848)
  fix: Use account ledger entry when canceling token escrows (6171)
  refactor: Rename `account_` to `accountID_` (7284)
  ci: Add Linux package builds (DEB + RPM) to CI (6639)
  refactor: Clean up comments post-clang-tidy changes (7283)
  release: Set version to 3.3.0-b0 (7280)
  refactor: Rename static constants (7120)
  refactor: Use `isFlag` where possible instead of bitwise math (7278)
  ci: Update XRPLF/actions (7281)
2026-05-19 22:10:17 +01:00
Vito Tumas
93ac1aa7aa fix: Disable unnecessary sanity-check in VaultDeposit (#7288) 2026-05-19 16:38:50 +00:00
dependabot[bot]
d9a3af8207 ci: [DEPENDABOT] bump actions/upload-artifact from 7.0.0 to 7.0.1 (#7286)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-19 16:35:38 +00:00
Ayaz Salikhov
8d1083e5ea ci: Only run reusable package in public repos (#7293) 2026-05-19 13:15:11 +00:00
Fomo
1e45d363c5 fix: Set default peering port to 2459 (#6848)
Co-authored-by: Bart <bthomee@users.noreply.github.com>
2026-05-19 06:05:47 +00:00
Ed Hennis
395da870a1 Merge branch 'develop' into ximinez/lending-shortages 2026-05-14 20:39:41 -04:00
Ed Hennis
df932923a1 Merge branch 'develop' into ximinez/lending-shortages 2026-05-14 10:48:58 -04:00
Ed Hennis
08c8f5f3d6 Merge branch 'develop' into ximinez/lending-shortages 2026-05-13 12:04:19 -04:00
Ed Hennis
d604d2c066 Merge branch 'develop' into ximinez/lending-shortages 2026-05-12 20:11:47 -04:00
Ed Hennis
8aefdc673f Merge branch 'develop' into ximinez/lending-shortages 2026-05-07 18:10:40 -04:00
Ed Hennis
c5b997d50d Merge branch 'develop' into ximinez/lending-shortages 2026-05-07 14:19:47 -04:00
Ed Hennis
1e19e986b5 Merge branch 'develop' into ximinez/lending-shortages 2026-05-07 13:29:08 -04:00
Ed Hennis
a5917e7eb9 Merge branch 'develop' into ximinez/lending-shortages 2026-05-06 22:34:58 -04:00
Ed Hennis
b070161475 Merge branch 'develop' into ximinez/lending-shortages 2026-05-06 14:18:38 -04:00
Ed Hennis
1ba0517063 Merge remote-tracking branch 'XRPLF/develop' into ximinez/lending-shortages
* XRPLF/develop:
  fix: Fix regressions in `server_definitions` (7008)
  chore: Do not duplicate sanitizer flags (7058)
  ci: Run pre-commit on diff in clang-tidy workflow (7078)
  ci: Use XRPLF/create-issue (7076)
  ci: Rewrite clang-tidy workflow(s) in a reusable manner (7062)
  chore: Ignore identifier-naming update in git blame (7066)
  refactor: Enable clang-tidy `readability-identifier-naming` check (6571)
2026-05-05 20:06:12 -04:00
Ed Hennis
56f79d7f05 Merge branch 'develop' into ximinez/lending-shortages 2026-05-01 14:01:18 -04:00
Ed Hennis
9d2d8538d0 Merge remote-tracking branch 'XRPLF/develop' into ximinez/lending-shortages
* XRPLF/develop:
  chore: Enable clang-tidy modernize-use-nodiscard check (7015)
  fix: Resolve MSVC Debug build failure in JobQueue.h; re-enable _CRTDBG_MAP_ALLOC in CI (6993)
  docs: Update hybrid offer invariant comment (7007)
  fix: Fix flaky CI tests (7005)
  docs: Update bug bounty information (7006)
  fix: Make assorted Payments fixes (6585)
  refactor: Move `LendingHelpers` into `libxrpl/ledger/helpers` (6638)
2026-04-25 13:47:39 -05:00
Ed Hennis
78208a4fb3 Merge branch 'develop' into ximinez/lending-shortages 2026-04-23 15:56:40 -04:00
Ed Hennis
5f4dc06801 Merge branch 'develop' into ximinez/lending-shortages 2026-04-22 23:53:12 -04:00
Ed Hennis
d375ee23de Merge branch 'develop' into ximinez/lending-shortages 2026-04-22 14:49:38 -04:00
Ed Hennis
f50234be62 Merge branch 'develop' into ximinez/lending-shortages 2026-04-22 13:11:10 -04:00
Ed Hennis
b4369d0547 Merge branch 'develop' into ximinez/lending-shortages 2026-04-21 19:35:12 -04:00
Ed Hennis
5c81473819 Merge branch 'develop' into ximinez/lending-shortages 2026-04-20 17:50:11 -04:00
Ed Hennis
ed1662a86e Merge branch 'develop' into ximinez/lending-shortages 2026-04-20 15:45:29 -04:00
Ed Hennis
da0b73f82d Merge branch 'develop' into ximinez/lending-shortages 2026-04-20 11:39:35 -04:00
Ed Hennis
1881c08bfd Merge branch 'develop' into ximinez/lending-shortages 2026-04-17 18:21:09 -04:00
Ed Hennis
89c5a88111 Merge branch 'develop' into ximinez/lending-shortages 2026-04-16 13:45:00 -04:00
Ed Hennis
3da6041b45 Merge branch 'develop' into ximinez/lending-shortages 2026-04-15 19:09:44 -04:00
Ed Hennis
c4fc3fa095 Merge branch 'develop' into ximinez/lending-shortages 2026-04-15 14:29:21 -04:00
Ed Hennis
bc54d3126f Merge branch 'develop' into ximinez/lending-shortages 2026-04-13 20:45:24 -04:00
Ed Hennis
8da9017656 Merge branch 'develop' into ximinez/lending-shortages 2026-04-10 12:13:19 -04:00
Ed Hennis
b4425f5502 Merge branch 'develop' into ximinez/lending-shortages 2026-04-10 09:14:08 -04:00
Ed Hennis
f81500319b Merge remote-tracking branch 'XRPLF/develop' into ximinez/lending-shortages
* XRPLF/develop:
  fix: Add description for `terLOCKED` error (6811)
  fix: Address AI reviewer comments for Permission Delegation (6675)
  refactor: Combine `AMMHelpers` and `AMMUtils` (6733)
  feat: Add MPT support to DEX (5285)
2026-04-09 16:47:15 -04:00
Ed Hennis
585cbc8a56 Merge branch 'develop' into ximinez/lending-shortages 2026-04-07 17:11:57 -04:00
Ed Hennis
7e881e70ff Merge branch 'develop' into ximinez/lending-shortages 2026-03-12 15:04:59 -04:00
Ed Hennis
56dc85d417 Merge branch 'develop' into ximinez/lending-shortages 2026-03-10 13:39:27 -04:00
Ed Hennis
6e36944ebc Merge remote-tracking branch 'XRPLF/develop' into ximinez/lending-shortages
* XRPLF/develop:
  chore: Add custom cmake definitions for gersemi (6491)
  refactor: Update transaction folder structure (6483)
  chore: Apply gersemi changes (6486)
  chore: Use gersemi instead of ancient cmake-format (6486)
  Add Formats and Flags to `server_definitions` (6321)
  fix: Fix docs deployment for pull requests (6482)
  fix: Stop committing generated docs to prevent repo bloat (6474)
2026-03-06 12:33:15 -05:00
Ed Hennis
64a096130f Merge branch 'develop' into ximinez/lending-shortages 2026-03-04 17:12:14 -04:00
Ed Hennis
037f3152a7 Merge branch 'develop' into ximinez/lending-shortages 2026-03-03 18:38:35 -04:00
Ed Hennis
70f535fce2 Merge branch 'develop' into ximinez/lending-shortages 2026-02-24 17:43:47 -04:00
Ed Hennis
368d79515e Merge branch 'develop' into ximinez/lending-shortages 2026-02-20 18:51:11 -04:00
Ed Hennis
142aaa7ae3 Merge remote-tracking branch 'XRPLF/develop' into ximinez/lending-shortages
* XRPLF/develop:
  ci: [DEPENDABOT] bump actions/checkout from 4.3.0 to 6.0.2 (6397)
  ci: [DEPENDABOT] bump actions/setup-python from 5.6.0 to 6.2.0 (6395)
  ci: [DEPENDABOT] bump tj-actions/changed-files from 46.0.5 to 47.0.4 (6394)
  ci: [DEPENDABOT] bump codecov/codecov-action from 5.4.3 to 5.5.2 (6398)
  ci: Build docs in PRs and in private repos (6400)
  ci: Add dependabot config (6379)
  Fix tautological assertion (6393)
2026-02-20 17:48:27 -05:00
Ed Hennis
39c397a0fd Merge commit '2c1fad1023' into ximinez/lending-shortages
* commit '2c1fad1023':
  chore: Apply clang-format width 100 (6387)
2026-02-20 17:48:23 -05:00
Ed Hennis
6266899acb Update formatting 2026-02-20 17:45:50 -05:00
Ed Hennis
2a8d0ecca7 Merge commit '25cca465538a56cce501477f9e5e2c1c7ea2d84c' into ximinez/lending-shortages
* commit '25cca465538a56cce501477f9e5e2c1c7ea2d84c':
  chore: Set clang-format width to 100 in config file (6387)
2026-02-20 17:39:05 -05:00
Ed Hennis
1fc3f4dedc Merge branch 'develop' into ximinez/lending-shortages 2026-02-19 16:25:25 -05:00
Ed Hennis
6bb09ee163 Merge remote-tracking branch 'XRPLF/develop' into ximinez/lending-shortages
* XRPLF/develop:
  refactor: Modularize app/tx (6228)
  refactor: Decouple app/tx from `Application` and `Config` (6227)
  chore: Update clang-format to 21.1.8 (6352)
  refactor: Modularize `HashRouter`, `Conditions`, and `OrderBookDB` (6226)
  chore: Fix minor issues in comments (6346)
  refactor: Modularize the NetworkOPs interface (6225)
  chore: Fix `gcov` lib coverage build failure on macOS (6350)
  refactor: Modularize RelationalDB (6224)
  refactor: Modularize WalletDB and Manifest (6223)
  fix: Update invariant checks for Permissioned Domains (6134)
  refactor: Change main thread name to `xrpld-main` (6336)
  refactor: Fix spelling issues in tests (6199)
  test: Add file and line location to Env (6276)
  chore: Remove CODEOWNERS (6337)
  perf: Remove unnecessary caches (5439)
  chore: Restore unity builds (6328)
  refactor: Update secp256k1 to 0.7.1 (6331)
  fix: Increment sequence when accepting new manifests (6059)
  fix typo in LendingHelpers unit-test (6215)
2026-02-18 20:13:40 -05:00
Ed Hennis
c679707a39 Merge branch 'develop' into ximinez/lending-shortages 2026-02-04 17:18:38 -04:00
Ed Hennis
f58a0a551b Fix formatting 2026-01-28 19:24:45 -05:00
Ed Hennis
83799db46a Merge branch 'develop' into ximinez/lending-shortages 2026-01-28 19:30:57 -04:00
Ed Hennis
ef97ac2b7a Merge commit '5f638f55536def0d88b970d1018a465a238e55f4' into ximinez/lending-shortages
* commit '5f638f55536def0d88b970d1018a465a238e55f4':
  chore: Set ColumnLimit to 120 in clang-format (6288)
2026-01-28 18:28:42 -05:00
Ed Hennis
3823dbc74c Merge commit '92046785d1fea5f9efe5a770d636792ea6cab78b' into ximinez/lending-shortages
* commit '92046785d1fea5f9efe5a770d636792ea6cab78b':
  test: Fix the `xrpl.net` unit test using async read (6241)
  ci: Upload Conan recipes for develop, release candidates, and releases (6286)
  fix: Stop embedded tests from hanging on ARM by using `atomic_flag` (6248)
  fix:  Remove DEFAULT fields that change to the default in associateAsset (6259) (6273)
  refactor: Update Boost to 1.90 (6280)
  refactor: clean up uses of `std::source_location` (6272)
  ci: Pass missing sanitizers input to actions (6266)
  ci: Properly propagate Conan credentials (6265)
  ci: Explicitly set version when exporting the Conan recipe (6264)
  ci: Use plus instead of hyphen for Conan recipe version suffix (6261)
  chore: Detect uninitialized variables in CMake files (6247)
  ci: Run on-trigger and on-pr when generate-version is modified (6257)
  refactor: Enforce 15-char limit and simplify labels for thread naming (6212)
  docs: Update Ripple Bug Bounty public key (6258)
  ci: Add missing commit hash to Conan recipe version (6256)
  fix: Include `<functional>` header in `Number.h` (6254)
  ci: Upload Conan recipe for merges into develop and commits to release (6235)
  Limit reply size on `TMGetObjectByHash` queries (6110)
  ci: remove 'master' branch as a trigger (6234)
  Improve ledger_entry lookups for fee, amendments, NUNL, and hashes (5644)
2026-01-28 18:27:50 -05:00
Ed Hennis
958a7c12c6 Merge branch 'develop' into ximinez/lending-shortages 2026-01-15 13:16:46 -04:00
Ed Hennis
20d9cb89dd Merge branch 'develop' into ximinez/lending-shortages 2026-01-15 12:06:39 -04:00
Ed Hennis
e105d59b90 Revert "Partially revert aed8e2b166 Fill in payment computation shortages (#5941)"
This reverts commit 95fdbe520f.
2026-01-15 11:03:37 -05:00
Ed Hennis
8cae6b0adc Revert "Remove the shortage code completely"
This reverts commit 165478b929.
2026-01-14 20:43:03 -05:00
6 changed files with 153 additions and 31 deletions

View File

@@ -58,6 +58,7 @@ jobs:
package:
needs: [generate-matrix, generate-version]
if: ${{ github.event.repository.visibility == 'public' }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
@@ -88,8 +89,7 @@ jobs:
run: ./package/build_pkg.sh
- name: Upload package artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: ${{ github.event.repository.visibility == 'public' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ matrix.artifact_name }}-pkg-${{ needs.generate-version.outputs.version }}
path: |

View File

@@ -1466,10 +1466,7 @@ admin = 127.0.0.1
protocol = http
[port_peer]
# Many servers still use the legacy port of 51235, so for backward-compatibility
# we maintain that port number here. However, for new servers we recommend
# changing this to the default port of 2459.
port = 51235
port = 2459
ip = 0.0.0.0
# alternatively, to accept connections on IPv4 + IPv6, use:
#ip = ::

View File

@@ -1126,18 +1126,34 @@ computePaymentComponents(
"xrpl::detail::computePaymentComponents",
"excess non-negative");
};
// Helper to reduce deltas when they collectively exceed a limit.
// Order matters: we prefer to reduce interest first (most flexible),
// then management fee, then principal (least flexible).
auto giveTo = [](Number& component, Number& shortage, Number const& maximum) {
if (shortage > beast::kZero)
{
// Put as much of the shortage as we can into the provided part
// and the total
auto part = std::min(maximum - component, shortage);
component += part;
shortage -= part;
}
// If the shortage goes negative, we put too much, which should be
// impossible
XRPL_ASSERT_PARTS(
shortage >= beast::kZero,
"ripple::detail::computePaymentComponents",
"excess non-negative");
};
auto addressExcess = [&takeFrom](LoanStateDeltas& deltas, Number& excess) {
// This order is based on where errors are the least problematic
takeFrom(deltas.interest, excess);
takeFrom(deltas.managementFee, excess);
takeFrom(deltas.principal, excess);
};
// Check if deltas exceed the total outstanding value. This should never
// happen due to earlier caps, but handle it defensively.
auto addressShortage =
[&giveTo](LoanStateDeltas& deltas, Number& shortage, LoanState const& current) {
giveTo(deltas.interest, shortage, current.interestDue);
giveTo(deltas.managementFee, shortage, current.managementFeeDue);
giveTo(deltas.principal, shortage, current.principalOutstanding);
};
Number totalOverpayment = deltas.total() - currentLedgerState.valueOutstanding;
if (totalOverpayment > beast::kZero)
@@ -1165,14 +1181,33 @@ computePaymentComponents(
addressExcess(deltas, excess);
shortage = -excess;
}
else if (shortage > beast::kZero && totalOverpayment < beast::kZero)
{
// If there's a shortage, and there's room in the loan itself, we can
// top up the parts to make the payment correct.
shortage = std::min(-totalOverpayment, shortage);
addressShortage(deltas, shortage, currentLedgerState);
}
// At this point, shortage >= 0 means we're paying less than the full
// periodic payment (due to rounding or component caps).
// shortage < 0 would mean we're trying to pay more than allowed (bug).
// The shortage should never be negative, which indicates that the parts are
// trying to take more than the whole payment. The shortage should not be
// positive, either, which indicates that we're not going to take the whole
// payment amount. Only the last payment should be allowed to have a
// shortage, and that's handled in a special case above.
XRPL_ASSERT_PARTS(
shortage >= beast::kZero,
"xrpl::detail::computePaymentComponents",
shortage == beast::kZero,
"ripple::detail::computePaymentComponents",
"no shortage or excess");
#if LOANCOMPLETE
/*
// This used to be part of the above assert. It will eventually be removed
// if proved accurate
||
(shortage > beast::kZero &&
((asset.integral() && shortage < 3) ||
(scale - shortage.exponent() > 14)))
*/
#endif
// Final validation that all components are valid
XRPL_ASSERT_PARTS(

View File

@@ -7,6 +7,7 @@
#include <xrpl/ledger/helpers/MPTokenHelpers.h>
#include <xrpl/ledger/helpers/TokenHelpers.h>
#include <xrpl/ledger/helpers/VaultHelpers.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/Issue.h>
#include <xrpl/protocol/LedgerFormats.h>
@@ -252,19 +253,26 @@ VaultDeposit::doApply()
!isTesSuccess(ter))
return ter;
// Sanity check
if (accountHolds(
view(),
accountID_,
assetsDeposited.asset(),
FreezeHandling::IgnoreFreeze,
AuthHandling::IgnoreAuth,
j_) < beast::kZero)
// This check is wrong. Disable it with fixCleanup3_2_0.
// For XRP and MPT the predicate is structurally unsatisfiable: xrpLiquid clamps at zero, and
// MPT balances are unsigned. For IOUs it only fires when the deposit drove the depositor's
// trust line into debt the exact case preclaim authorizes via SpendableHandling::FullBalance.
// The check thus converts a preclaim- authorized deposit into tefINTERNAL after the asset
// transfer.
if (!view().rules().enabled(fixCleanup3_2_0))
{
// LCOV_EXCL_START
JLOG(j_.error()) << "VaultDeposit: negative balance of account assets.";
return tefINTERNAL;
// LCOV_EXCL_STOP
// Sanity check
if (accountHolds(
view(),
accountID_,
assetsDeposited.asset(),
FreezeHandling::IgnoreFreeze,
AuthHandling::IgnoreAuth,
j_) < beast::kZero)
{
JLOG(j_.error()) << "VaultDeposit: negative balance of account assets.";
return tefINTERNAL;
}
}
// Transfer shares from vault to depositor.

View File

@@ -2602,8 +2602,10 @@ protected:
broker.params.managementFeeRate);
BEAST_EXPECTS(
paymentComponents.specialCase == xrpl::detail::PaymentSpecialCase::Final ||
paymentComponents.trackedValueDelta <= roundedPeriodicPayment,
paymentComponents.trackedValueDelta == roundedPeriodicPayment ||
(paymentComponents.specialCase ==
xrpl::detail::PaymentSpecialCase::Final &&
paymentComponents.trackedValueDelta < roundedPeriodicPayment),
"Delta: " + to_string(paymentComponents.trackedValueDelta) +
", periodic payment: " + to_string(roundedPeriodicPayment));

View File

@@ -6140,10 +6140,90 @@ class Vault_test : public beast::unit_test::Suite
runTest(amendments);
}
// VaultDeposit::preclaim uses accountHolds(..., SpendableHandling::
// shFULL_BALANCE), which for an IOU asset adds the counterparty's
// LowLimit/HighLimit to the depositor's raw balance (TokenHelpers.cpp:
// getTrustLineBalance with includeOppositeLimit=true). When the
// depositor's raw balance < deposit amount but raw + opposite limit >=
// amount, preclaim is satisfied. doApply then calls
// directSendNoFeeIOU, which unconditionally subtracts saAmount from
// saBalance — driving the trust line negative — and returns tesSUCCESS.
// The post-send sanity check uses the default shSIMPLE_BALANCE (no
// opposite-limit add), sees a negative balance, and returns tefINTERNAL.
void
testVaultDepositNegativeBalanceFromOppositeLimit()
{
auto runTest = [&](FeatureBitset f, TER expected) {
using namespace test::jtx;
using namespace std::literals;
Env env{*this, f};
Account const gw{"gateway"};
Account const owner{"owner"};
Account const depositor{"depositor"};
env.fund(XRP(10000), gw, owner, depositor);
env.close();
// Gateway with DefaultRipple so vault creation on its IOU works.
env(fset(gw, asfDefaultRipple));
env.close();
// Depositor opens a trust line to gateway and receives a small
// balance.
PrettyAsset const usd = gw["USD"];
env.trust(usd(1000), depositor);
env(pay(gw, depositor, usd(100))); // raw trust-line balance: 100
env.close();
// Key precondition: gateway sets a non-zero limit on the same
// RippleState — the "opposite field" from depositor's perspective.
// This is what inflates shFULL_BALANCE in preclaim above the raw
// balance.
env(trust(gw, depositor["USD"](1000)));
env.close();
// Create the IOU vault.
Vault const vault{env};
auto [vaultTx, keylet] = vault.create({.owner = owner, .asset = usd});
env(vaultTx);
env.close();
// Submit a deposit of 500 USD:
// - raw balance: 100 USD
// - opposite limit (gw's side): 1000 USD
// - preclaim sees 100 + 1000 = 1100, passes (>= 500)
// - doApply transfers 500, depositor's trust-line balance
// becomes -400
// - sanity check at VaultDeposit.cpp:256 fires
// - tx returns tefINTERNAL (BUG — should be tesSUCCESS.
auto depositTx =
vault.deposit({.depositor = depositor, .id = keylet.key, .amount = usd(500)});
env(depositTx, Ter(expected));
env.close();
};
{
testcase(
"IOU vault deposit exceeding depositor's balance but "
"within counterparty's trust limit, pre-fixCleanup3_2_0 "
"(tefINTERNAL)");
runTest(test::jtx::testableAmendments() - fixCleanup3_2_0, tefINTERNAL);
}
{
testcase(
"IOU vault deposit exceeding depositor's balance but "
"within counterparty's trust limit, post-fixCleanup3_2_0 "
"(tesSUCCESS)");
runTest(test::jtx::testableAmendments(), tesSUCCESS);
}
}
public:
void
run() override
{
testVaultDepositNegativeBalanceFromOppositeLimit();
testSequences();
testPreflight();
testCreateFailXRP();