Skip to content

Conversation

@a1q123456
Copy link
Collaborator

@a1q123456 a1q123456 commented Jan 15, 2026

High Level Overview of Change

This PR modularise xrpld/rdb

Context of Change

The rdb module was not properly designed. We have 3 classes:

  1. The abstract class RelationalDB
  2. The abstract class SQLiteDatabase which inherits from RelationalDB and adds some more pure virtual methods
  3. The concrete class SQLiteDatabaseImp which inherits from SQLiteDatabase and implements all the methods.

The factory function RelationalDB::init method checks the config and only returns an instance of SQLiteDatabaseImp, we can see in the code base that we are doing dynamic_cast<SQLiteDatabase*>(app.getRelationalDb()) everywhere.

To address this problem and help modularise app/tx, the rdb module needs to be refactored and moved to libxrpl.

This PR is part of the modularisation of the transactors. See all PRs here:
#6222
#6223
#6224
#6225
#6226
#6227
#6228

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

@a1q123456 a1q123456 requested a review from a team as a code owner January 15, 2026 13:30
@a1q123456 a1q123456 requested review from kuznetsss and vlntb January 15, 2026 13:31
@a1q123456 a1q123456 force-pushed the a1q123456/modularise-relational-db branch 2 times, most recently from b7d8cbe to 32296b7 Compare January 15, 2026 13:56
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
@a1q123456 a1q123456 force-pushed the a1q123456/modularise-relational-db branch from dd1a1a9 to cf67641 Compare January 15, 2026 14:19
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

❌ Patch coverage is 79.31034% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.2%. Comparing base (c9dbea1) to head (922752a).

Files with missing lines Patch % Lines
...rc/xrpld/app/rdb/backend/detail/SQLiteDatabase.cpp 67.5% 13 Missing ⚠️
src/xrpld/app/rdb/backend/SQLiteDatabase.h 83.3% 3 Missing ⚠️
src/xrpld/app/main/Application.cpp 75.0% 1 Missing ⚠️
src/xrpld/rpc/handlers/AccountTx.cpp 80.0% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                             Coverage Diff                             @@
##           a1q123456/modularise-wallet-db-and-manifest   #6224   +/-   ##
===========================================================================
  Coverage                                         79.2%   79.2%           
===========================================================================
  Files                                              843     843           
  Lines                                            71717   71694   -23     
  Branches                                          8285    8284    -1     
===========================================================================
- Hits                                             56794   56780   -14     
+ Misses                                           14923   14914    -9     
Files with missing lines Coverage Δ
include/xrpl/core/ServiceRegistry.h 100.0% <ø> (ø)
include/xrpl/rdb/RelationalDatabase.h 100.0% <100.0%> (ø)
src/xrpld/app/ledger/Ledger.cpp 82.6% <100.0%> (+0.1%) ⬆️
src/xrpld/app/ledger/detail/LedgerMaster.cpp 41.6% <ø> (ø)
src/xrpld/app/misc/SHAMapStoreImp.cpp 75.6% <100.0%> (+0.1%) ⬆️
src/xrpld/app/misc/Transaction.h 96.3% <ø> (ø)
src/xrpld/app/misc/detail/Transaction.cpp 83.6% <100.0%> (+1.1%) ⬆️
src/xrpld/app/rdb/backend/detail/Node.cpp 58.9% <ø> (ø)
src/xrpld/overlay/detail/OverlayImpl.cpp 32.2% <ø> (ø)
src/xrpld/overlay/detail/PeerReservationTable.cpp 16.3% <ø> (ø)
... and 8 more

... and 2 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.

Comment on lines +53 to +54
std::uint32_t minLedger;
std::uint32_t maxLedger;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use LedgerRange?

using AccountTx =
std::pair<std::shared_ptr<Transaction>, std::shared_ptr<TxMeta>>;
using AccountTxs = std::vector<AccountTx>;
using txnMetaLedgerType = std::tuple<Blob, Blob, std::uint32_t>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to avoid pairs and tuples if possible because they decrease readability

closeTransactionDB() = 0;
};

template <class T, class C>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add concepts on T and C to improve compilation errors on misuse. Probably std::is_arithmetic and that std::is_convertible.

closeTransactionDB() override;

std::optional<LedgerHeader>
getLedgerInfoByIndex(LedgerIndex ledgerSeq) override;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add docs comments for added methods for consistency

std::optional<LedgerHeader>
getNewestLedgerInfo() override;

SQLiteDatabase(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move the implementation into cpp file?

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.

3 participants