Commit Graph

13498 Commits

Author SHA1 Message Date
Ed Hennis
6d49b42497 fixup! Lending protocol implementation (XLS-0066) 2025-05-14 15:28:46 +01:00
Ed Hennis
f91a737184 Rename XRPL_ASSERT2 to XRPL_ASSERT_PARTS, and document it 2025-05-14 15:28:45 +01:00
Ed Hennis
8483115637 Lending protocol implementation (XLS-0066)
- Add the LendingProtocol amendment
- Add Loan Broker and Loan ledger objects:
- Also add new SFields, Keylet functions, and an Invariant to verify no
  illegal field modification
- Update list of "constant" fields from spec
- Also add a general check for all object types for the type and index
  fields
- refactor: Check transaction flags in preflight0
- Adds a flagMask parameter to preflight1 so that it's impossible to
  forget to check flags.
- Also adds a short hash prefix to all Transactor log messages.
- refactor: Generalize Transactor preflight:
- Derived classes no longer need to explicitly check amendments, nor
  call into preflight1 or preflight2.
- implemeng LoanBrokerSet
- Transactions: LoanDelete, LoanManage, LoanDraw, LoanPay
- LoanBrokerSet creation mostly done. Need update.
- Also added a lookup table for pseudo account fields.
- Update changed field name.
- Modify modifiable fields in an update. Note there are only two.
- Add a node field to dirLink, defaulting sfOwnerNode, so other
  relationships can be updated.
- Create some helper classes for transaction fields
- Test that they work by converting some of the existing classes
- Finish creating helper classes for JTx fields
- Also change the pseudo account field lookup to a function that uses
  a switch
- Update tests, update pseudo-account checking
- Generalize some of the Invariant checks using macro files
  - Valid ledger entry type
  - Valid new account root and pseudo account check
- Enumerate transaction privileges for invariants
  - Allows them to be defined in transactions.macro instead of needing to
    scrutinize every existing Invariant class.
  - List is not necessarily comprehensive, but does cover every check
    where more than one transaction type is involved.
- Reserve a few values between Vault and Lending for future use
- Pseudo-account improvements
  - Define pseudo-account fields with an sfield flag
  - Pseudo-account invariant checks rules whenever a pseudo-account is
    created or modified.
- Move some helper functions.
- Check the regular key in the pseudo-transaction invariant check.
- Transactor::checkSign will always fail for a pseudo-account, so even
  if someone figures out how to get a good signature, it won't work.
- Fix account creation to check both amendments
- Add a validity range for sfDebtMaximum
- Change more "failed" messages. The goal here is to be able to search
  the log for "failed" and ONLY get test failures.
- NoModifiedUnmodifiableFields and ValidPseudoAccounts
- Move the Invariants_test class into the test namespace
- Clang wants an explicit ctor to emplace in a vector
- Refactor: Add a Transactor base function to make it easier to get the
  owner reserve increment as a fee.
- Refactor: Add an overload jtx::fee(increment) to pay an owner reserve.
- Initial implementation of LoanBrokerDelete
- Generalize the LoanBroker lifecycle test
- Refactor ApplyView::dirAdd to give access to low-level operations
  - Takes a page from #5362, which may turn out to be useful!
- Start writing Loan Broker invariants and tests
  - Specifically those mentioned for LoanBrokerDelete
- Move all detail namespaces to be under ripple
  - Avoids problems with namespace collisions / ambiguous symbol issues
    with unity builds, especially when adding or removing files.
- Add LoanBrokerCoverDeposit transaction
- Add LoanBrokerCoverWithdraw transaction
- Start writing tests for LoanBrokerCover*
- Add support for `Asset` and `MPTIssue` to some `jtx` helper classes
  and functions (`balance`, `expectLine`)
- Add support for pseudo-accounts to `jtx::Account` by allowing directly
  setting the AccountID without a matching key.
- Add Asset and MPTIssue support to more jtx objects / functions
  - Unfortunately, to work around some ambiguous symbol compilation
    errors, I had to change the implicit conversion from IOU to Asset to
    a conversion from IOU to PrettyAsset, and add a more explicit
    `asset()` function. This workaround only required changing two
    existing tests, so seems acceptable.
- Ensure that an account is not deleted with an XRP balance
  - Updates the AccountRootsDeletedClean invariant
- Finish up the Loan Broker tests
- Move inclusion of Transactor headers to transactions.macro
  - Only need to update in one place when adding a new transaction.
- Start implementing LoanSet transactor
  - Add some more values and functions to make it easier to work with
    basis point values / bips.
  - Fix several earlier mistakes.
- Generalize the check*Sign functions to support CounterParty
  - checkSign, checkSingleSign, and checkMultiSign in STTx and Transactor
- Start writing Loan tests
  - Required adding support for counterparty signature to jtx framework:
    arbitrary signature field destination, multiple signer callbacks
- Get Counterparty signing working
- Add more LoanSet unit tests, added LoanBroker LoanSequence field
  - LoanSequence will prevent loan key collisions
- Change Loan object indexing, fix several broken LoanSet unit tests
  - Loan objects will now only be indexed by LoanBrokerID and
    LoanSequence, which is a new field in LoanBroker. Also changes
    Loan.Sequence to Loan.LoanSequence to match up.
  - Several tests weren't working because of `PrettyAsset` scaling. Also,
    `PrettyAsset` calculations could overflow. Made that less likely by
    changing the type of `scale_`.
  - LoanSet will fail if an account tries to loan to itself.
- Ensure that an account is not deleted with a non-zero owner count
  - Updates the AccountRootsDeletedClean invariant
- Add unit tests to create a Loan successfully
  - Fix a few field initializations in LoanSet
- Refactor issuance validity check in VaultCreate
  - Utility function: canAddHolding
  - Call canAddHolding from any transactor that call addEmptyHolding
    (LoanBrokerSet, LoanSet)
- Start implementing LoanManage transaction
  - Also add a ValidLoan invariant
- Finish `LoanManage` functionality and tests, modulo LoanDraw/Pay
- Allow existing trust lines to loan brokers to be managed (by issuer)
- Implement LoanDelete, and fix a bunch of math errors in LoanManage
- Update to match latest spec: compute interest, LoanBroker reserves
- refactor: Define getFlagsMask in the base Transactor class
  - Returns tfUniversalMask for most transactors
  - Only transactors that use other flags need to override
- Implement LoanDraw, and made good progress on related tests
- Start implementing LoanPay transaction
- Implement LoanPay
  - Also add an XRPL_ASSERT2, which splits the parts of the assert message
    so I don't have to remember the proper formatting.
2025-05-14 15:28:42 +01:00
Bronek Kozicki
024b016d83 Merge branch 'develop' into vault 2025-05-12 13:49:50 +01:00
Bart
c6c7c84355 Configure CODEOWNERS for changes to RPC code (#5266)
To ensure changes to any RPC-related code are compatible with other services, such as Clio, the RPC team will be required to review them.
2025-05-12 12:42:03 +00:00
yinyiqian1
28f50cb7cf fix: enable LedgerStateFix for delegation (#5427) 2025-05-10 10:36:11 -04:00
Bronek Kozicki
20f6f8958f Merge branch 'develop' into vault 2025-05-08 15:29:44 +01:00
Vito Tumas
3e152fec74 refactor: use east const convention (#5409)
This change refactors the codebase to use the "east const convention", and adds a clang-format rule to follow this convention.
2025-05-08 11:00:42 +00:00
yinyiqian1
2db2791805 Add PermissionDelegation feature (#5354)
This change implements the account permission delegation described in XLS-75d, see https://github.com/XRPLF/XRPL-Standards/pull/257.

* Introduces transaction-level and granular permissions that can be delegated to other accounts.
* Adds `DelegateSet` transaction to grant specified permissions to another account.
* Adds `ltDelegate` ledger object to maintain the permission list for delegating/delegated account pair.
* Adds an optional `Delegate` field in common fields, allowing a delegated account to send transactions on behalf of the delegating account within the granted permission scope. The `Account` field remains the delegating account; the `Delegate` field specifies the delegated account. The transaction is signed by the delegated account.
2025-05-08 06:14:02 -04:00
Bronek Kozicki
fc9197837c Add // LCOV_EXCL_LINE 2025-05-07 16:57:15 +01:00
Bronek Kozicki
65fe44a449 Review feedback 2025-05-06 20:07:02 +01:00
Bronek Kozicki
ac0e4dec96 Do not use isIntegral() 2025-05-06 19:57:15 +01:00
Bronek Kozicki
aead1bfb3d Review feedback 2025-05-06 19:06:45 +01:00
Bronek Kozicki
e6b9108d26 Add unit tests 2025-05-06 13:10:21 +01:00
Bronek Kozicki
8eaa9e7b96 Minor, use tecLOCKED when appropriate 2025-05-06 12:01:23 +01:00
Bronek Kozicki
283331b3bd Minor cleanup 2025-05-06 11:44:41 +01:00
Bronek Kozicki
4189aa8713 Merge branch 'develop' into vault 2025-05-02 17:53:51 +01:00
Bronek Kozicki
bbe49132a6 Reorganize and extend unit tests 2025-05-02 17:23:25 +01:00
Bronek Kozicki
84abcba497 Add defensive checks for IOU issuer and MPTokenIssuance 2025-05-02 16:56:47 +01:00
Vito Tumas
9ec2d7f8ff Enable passive squelching (#5358)
This change updates the squelching logic to accept squelch messages for untrusted validators. As a result, servers will also squelch untrusted validator messages reducing duplicate traffic they generate.

In particular:
* Updates squelch message handling logic to squelch messages for all validators, not only trusted ones.
* Updates the logic to send squelch messages to peers that don't squelch themselves
* Increases the threshold for the number of messages that a peer has to deliver to consider it as a candidate for validator messages.
2025-05-02 11:01:45 -04:00
Bronek Kozicki
a87f58eb22 Code cleanup in SetTrust 2025-05-02 11:38:08 +01:00
Bronek Kozicki
1925ceace6 Add unit test 2025-05-01 21:36:03 +01:00
Bronek Kozicki
140fd829a0 Enforce defult rippling in VaultCreate::preclaim 2025-05-01 21:11:16 +01:00
Ed Hennis
4a084ce34c Improve transaction relay logic (#4985)
Combines four related changes:
1. "Decrease `shouldRelay` limit to 30s." Pretty self-explanatory. Currently, the limit is 5 minutes, by which point the `HashRouter` entry could have expired, making this transaction look brand new (and thus causing it to be relayed back to peers which have sent it to us recently).
2.  "Give a transaction more chances to be retried." Will put a transaction into `LedgerMaster`'s held transactions if the transaction gets a `ter`, `tel`, or `tef` result. Old behavior was just `ter`.
     * Additionally, to prevent a transaction from being repeatedly held indefinitely, it must meet some extra conditions. (Documented in a comment in the code.)
3. "Pop all transactions with sequential sequences, or tickets." When a transaction is processed successfully, currently, one held transaction for the same account (if any) will be popped out of the held transactions list, and queued up for the next transaction batch. This change pops all transactions for the account, but only if they have sequential sequences (for non-ticket transactions) or use a ticket. This issue was identified from interactions with @mtrippled's #4504, which was merged, but unfortunately reverted later by #4852. When the batches were spaced out, it could potentially take a very long time for a large number of held transactions for an account to get processed through. However, whether batched or not, this change will help get held transactions cleared out, particularly if a missing earlier transaction is what held them up.
4. "Process held transactions through existing NetworkOPs batching." In the current processing, at the end of each consensus round, all held transactions are directly applied to the open ledger, then the held list is reset. This bypasses all of the logic in `NetworkOPs::apply` which, among other things, broadcasts successful transactions to peers. This means that the transaction may not get broadcast to peers for a really long time (5 minutes in the current implementation, or 30 seconds with this first commit). If the node is a bottleneck (either due to network configuration, or because the transaction was submitted locally), the transaction may not be seen by any other nodes or validators before it expires or causes other problems.
2025-05-01 13:58:18 -04:00
Bronek Kozicki
b3657220de More tests 2025-05-01 16:59:15 +01:00
Bronek Kozicki
117bfcc4a1 Consolidate preflight tests 2025-05-01 15:15:00 +01:00
Bronek Kozicki
4c6c8a08c9 Add LCOV_EXCL_LINE in appropriate locations 2025-05-01 12:30:33 +01:00
Bronek Kozicki
7b680ed47b Remove redundant check, add test
There is no way to pass a non-object params to an RPC because it is
always prepared as an object inside ServerHandler.cpp
2025-05-01 11:42:34 +01:00
Bronek Kozicki
6c97d2ec7e Update addEmptyHolding from review
Co-authored-by: Ed Hennis <ed@ripple.com>
2025-05-01 10:09:49 +01:00
Bronek Kozicki
3c386bee4e Minor cleanup 2025-04-30 18:18:49 +01:00
Bronek Kozicki
5472d7e1ff Minor cleanup 2025-04-30 13:45:28 +01:00
Bronek Kozicki
01cc089b0c Revert changes preventing deletion of a vault 2025-04-29 15:29:59 +01:00
Bronek Kozicki
ffb1959be5 Disallow deletion of vault if asset is under global lock 2025-04-29 14:38:57 +01:00
Bronek Kozicki
efe9f99b50 Unit test fix 2025-04-29 14:02:09 +01:00
Bronek Kozicki
b03cd57a92 Merge branch 'develop' into vault 2025-04-29 13:18:02 +01:00
Bronek Kozicki
071beca306 Allow freezeing trust line to vault, disallow deleting vault when asset is locked 2025-04-29 13:16:04 +01:00
Vito Tumas
3502df2174 fix: Replaces random endpoint resolution with sequential (#5365)
This change addresses an issue where `rippled` attempts to connect to an IPv6 address, even when the local network lacks IPv6 support, resulting in a "Network is unreachable" error.

The fix replaces the custom endpoint selection logic with `boost::async_connect`, which sequentially attempts to connect to available endpoints until one succeeds or all fail.
2025-04-28 15:38:55 -04:00
Bronek Kozicki
298aaac456 Check for pseudo-account in other transaction types 2025-04-28 19:41:14 +01:00
Bronek Kozicki
a205906e54 Prevent pseudo-accounts from receiving checks 2025-04-28 15:58:04 +01:00
Bronek Kozicki
d46a2d8a71 Allow resetting DomainID 2025-04-28 15:21:34 +01:00
Bronek Kozicki
5bfbb09970 Minor improvements 2025-04-28 14:49:47 +01:00
Bronek Kozicki
7e5845f209 Merge branch 'develop' into vault 2025-04-28 14:20:54 +01:00
Bronek Kozicki
22901af25d Minor cleanup 2025-04-25 19:57:14 +01:00
Bronek Kozicki
e9491669a7 Add unit tests 2025-04-25 16:31:28 +01:00
Vlad
fa1e25abef chore: Small clarification to lsfDefaultRipple comment (#5410) 2025-04-25 15:21:27 +00:00
Bronek Kozicki
77c70d8a64 Update RPC codes, improve seq parsing 2025-04-25 15:23:41 +01:00
Bronek Kozicki
afeb6287f5 Cleanup in MPTokenAuthorize 2025-04-25 14:09:26 +01:00
Bronek Kozicki
b2abfc0bd2 Minor cleanup in MPTokenIssuanceCreate 2025-04-25 13:03:43 +01:00
Bronek Kozicki
6a25ac9481 Decouple VaultDestroy from MPTokenIssuanceDestroy
Also drive-by fix in MPTokenIssuanceDestroy, the sfOutstandingAmount
field is required.
2025-04-25 12:37:53 +01:00
Bronek Kozicki
fb2eb3522d Prohibit VaultCreate to assets without real issuer 2025-04-24 15:53:35 +01:00