Skip to content

Pre-lending protocol refactoring 1: Misc #5590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

ximinez
Copy link
Collaborator

@ximinez ximinez commented Jul 22, 2025

High Level Overview of Change

This PR is one of four which contain several small changes that are used as the baseline of #5270. Since they are significant and useful, I created this separate PR to get them merged sooner.

(It's not a pure refactor as some new minor functionality has been introduced.)

Context of Change

#5270 is large and complicated, and I had to lay some groundwork before I could implement the feature.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Refactor (non-breaking change that only restructures code)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)

Before / After

Highlights:

  • to_short_string(base_uint). Like to_string, but only returns the first 8 characters. (Similar to how a git commit ID can be abbreviated.) Used as a wrapped sink to prefix most transaction-related messages. More can be added later.
  • XRPL_ASSERT_PARTS. Convenience wrapper for XRPL_ASSERT, which takes the function and description as separate parameters.
  • SField::sMD_PseudoAccount. Metadata option for SField definitions to indicate that the field, if set in an AccountRoot indicates that account is a pseudo-account. Removes the need for hard-coded field lists all over the place. Added the flag to AMMID and VaultID.
  • Added functionality to SField ctor to detect both code and name collisions using asserts.
  • Convenience type aliases STLedgerEntry::const_pointer and STLedgerEntry::const_ref. (SLE is an alias to STLedgerEntry.)
  • Generalized feeunit.h (TaggedFee) into unit.h (ValueUnit) and added new "BIPS"-related tags for future use.
  • Restructured transactions.macro to do two big things
    1. Include the #include directives for transactor header files directly in the macro file. Removes the need to update applySteps.cpp and the resulting conflicts.
    2. Added a privileges parameter to the TRANSACTION macro, which specifies some of the operations a transaction is allowed to do. These privileges are enforced by invariant checks. Again, removed the need to update scattered lists of transaction types in various checks.
  • Unit tests:
    1. Moved more helper functions into TestHelpers.h and .cpp.
    2. Cleaned up the namespaces to prevent / mitigate random collisions and ambiguous symbols, particularly in unity builds.
    3. Generalized Env::balance to add support for MPTIssue and Asset.
    4. Added a set of helper classes to simplify Env transaction parameter classes: JTxField, JTxFieldWrapper, and a bunch of classes derived or aliased from it. For an example of how awesome it is, check the changes src/test/jtx/escrow.h for how much simpler the definitions are for finish_time, cancel_time, condition, and fulfillment.
    5. Generalized several of the amount-related helper classes to understand Assets.
  • Added a new Invariant: ValidPseudoAccounts which checks that all pseudo-accounts behave consistently through creation and updates, and that no "real" accounts look like pseudo-accounts (which means they don't have a 0 sequence).

ximinez added 2 commits May 21, 2025 11:39
…refactoring-1

* upstream/develop: (56 commits)
  Remove `include(default)` from libxrpl profile (#5587)
  refactor: Change boost::shared_mutex to std::shared_mutex (#5576)
  Fix macos runner (#5585)
  Remove the type filter from "ledger" RPC command (#4934)
  refactor: Update date, libarchive, nudb, openssl, sqlite3, xxhash packages (#5567)
  test: Run unit tests regardless of 'Supported' amendment status (#5537)
  Retire Flow Cross amendment (#5562)
  chore: Update CI to use Conan 2 (#5556)
  fixAMMClawbackRounding: adjust last holder's LPToken balance (#5513)
  chore: Add gcc-12 workaround (#5554)
  Add MPT related txns into issuer's account history  (#5530)
  chore: Remove unused headers (#5526)
  fix: add allowTrustLineLocking flag for account_info (#5525)
  Downgrade required CMake version for Antithesis SDK (#5548)
  fix: Link with boost libraries explicitly (#5546)
  chore: Fix compilation error with clang-20 and cleanup (#5543)
  test: Remove circular jtx.h dependencies (#5544)
  Decouple CredentialHelpers from xrpld/app/tx (#5487)
  fix: crash when trace-logging in tests (#5529)
  test: switch some unit tests to doctest (#5383)
  ...
@ximinez ximinez requested a review from a team as a code owner July 22, 2025 00:31
@ximinez ximinez changed the title Pre-lending protocol refactoring 1 Pre-lending protocol refactoring 1: Misc Jul 22, 2025
Copy link

codecov bot commented Jul 22, 2025

Codecov Report

❌ Patch coverage is 87.82609% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.8%. Comparing base (7179ce9) to head (66dd0de).

Files with missing lines Patch % Lines
src/xrpld/ledger/detail/View.cpp 48.9% 23 Missing ⚠️
src/xrpld/app/tx/detail/InvariantCheck.cpp 95.2% 3 Missing ⚠️
include/xrpl/protocol/Units.h 95.5% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #5590     +/-   ##
=========================================
- Coverage     78.8%   78.8%   -0.0%     
=========================================
  Files          814     814             
  Lines        71259   71339     +80     
  Branches      8345    8373     +28     
=========================================
+ Hits         56162   56190     +28     
- Misses       15097   15149     +52     
Files with missing lines Coverage Δ
include/xrpl/basics/base_uint.h 96.9% <100.0%> (+<0.1%) ⬆️
include/xrpl/protocol/SField.h 100.0% <ø> (ø)
include/xrpl/protocol/STLedgerEntry.h 100.0% <ø> (ø)
include/xrpl/protocol/STObject.h 93.1% <ø> (ø)
include/xrpl/protocol/STValidation.h 69.5% <ø> (ø)
include/xrpl/protocol/XRPAmount.h 98.9% <ø> (ø)
include/xrpl/protocol/detail/transactions.macro 100.0% <100.0%> (ø)
src/libxrpl/protocol/Permissions.cpp 95.3% <ø> (ø)
src/libxrpl/protocol/SField.cpp 83.0% <100.0%> (+1.6%) ⬆️
src/libxrpl/protocol/TxFormats.cpp 100.0% <ø> (ø)
... and 11 more

... and 7 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ximinez ximinez requested a review from Bronek July 22, 2025 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant