Skip to content

Conversation

@bthomee
Copy link
Collaborator

@bthomee bthomee commented Feb 2, 2026

High Level Overview of Change

This change replaces void const* by uint256 const& for database fetches.

Context of Change

Object hashes are expressed using the uint256 data type, and are converted to void * when calling the fetch or fetchBatch functions. However, in these fetch functions they are converted back to uint256, making the conversion process unnecessary. In a few cases the underlying pointer is needed, but that can then be easy obtained via [hash variable].data().

I tested this change with both NuDB and RocksDB using an existing database, and the binary was able to use those databases and proceed to sync with the network.

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

Copilot AI review requested due to automatic review settings February 2, 2026 16:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the nodestore backend API to use uint256 const& directly instead of void const* for database fetch operations, eliminating unnecessary pointer conversions.

Changes:

  • Updated the Backend interface to accept uint256 const& instead of void const* for fetch() and fetchBatch() methods
  • Modified all backend implementations (RocksDB, NuDB, Memory, Null) to use the new signature
  • Updated all callers to pass hash objects directly instead of using .data() or .begin()
  • Removed unnecessary pointer vector conversion code in DatabaseNodeImp::fetchBatch()
  • Improved variable naming from "key" to "hash" in test files for better semantic clarity

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
include/xrpl/nodestore/Backend.h Updated virtual method signatures and documentation for fetch() and fetchBatch() to use uint256 const&
src/libxrpl/nodestore/backend/RocksDBFactory.cpp Updated implementation to accept uint256 const&, using hash.data() for RocksDB Slice and DecodedBlob
src/libxrpl/nodestore/backend/NullFactory.cpp Updated null backend stub implementation signatures
src/libxrpl/nodestore/backend/NuDBFactory.cpp Updated implementation to accept uint256 const&, using hash.data() for NuDB API and DecodedBlob
src/libxrpl/nodestore/backend/MemoryFactory.cpp Removed unnecessary fromVoid() conversion and updated signatures
src/libxrpl/nodestore/DatabaseRotatingImp.cpp Updated caller to pass hash directly instead of hash.data()
src/libxrpl/nodestore/DatabaseNodeImp.cpp Updated caller and removed redundant pointer vector creation in fetchBatch()
src/test/nodestore/TestBase.h Updated test helper to pass hash directly and removed .cbegin() calls
src/test/nodestore/Timing_test.cpp Updated test code to use "hash" variable naming and pass hash directly, removing .data() calls

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bthomee bthomee requested a review from vlntb February 2, 2026 16:51
@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

❌ Patch coverage is 52.63158% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.9%. Comparing base (11e8d1f) to head (6780d42).

Files with missing lines Patch % Lines
src/libxrpl/nodestore/backend/MemoryFactory.cpp 33.3% 2 Missing ⚠️
src/libxrpl/nodestore/backend/NuDBFactory.cpp 66.7% 2 Missing ⚠️
src/libxrpl/nodestore/backend/NullFactory.cpp 0.0% 2 Missing ⚠️
src/libxrpl/nodestore/backend/RocksDBFactory.cpp 60.0% 2 Missing ⚠️
src/libxrpl/nodestore/DatabaseNodeImp.cpp 50.0% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #6313     +/-   ##
=========================================
- Coverage     79.9%   79.9%   -0.0%     
=========================================
  Files          840     840             
  Lines        65508   65503      -5     
  Branches      7248    7269     +21     
=========================================
- Hits         52354   52322     -32     
- Misses       13154   13181     +27     
Files with missing lines Coverage Δ
include/xrpl/nodestore/Backend.h 16.7% <ø> (ø)
src/libxrpl/nodestore/DatabaseRotatingImp.cpp 63.9% <100.0%> (ø)
src/libxrpl/nodestore/DatabaseNodeImp.cpp 41.7% <50.0%> (+5.1%) ⬆️
src/libxrpl/nodestore/backend/MemoryFactory.cpp 67.6% <33.3%> (-0.5%) ⬇️
src/libxrpl/nodestore/backend/NuDBFactory.cpp 64.0% <66.7%> (+0.2%) ⬆️
src/libxrpl/nodestore/backend/NullFactory.cpp 20.7% <0.0%> (ø)
src/libxrpl/nodestore/backend/RocksDBFactory.cpp 50.9% <60.0%> (ø)

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

@bthomee bthomee requested a review from godexsoft February 2, 2026 18:38
Copy link
Collaborator

@vlntb vlntb left a comment

Choose a reason for hiding this comment

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

LGTM. The change improves type safety by replacing void const* with uint256 const&, follows East const notation, and eliminates unnecessary temporary vectors.

Base automatically changed from bthomee/disable-cache to develop February 6, 2026 14:42
@bthomee bthomee requested a review from a team February 6, 2026 14:42
Copilot AI review requested due to automatic review settings February 11, 2026 14:16
@bthomee bthomee requested a review from a1q123456 February 11, 2026 14:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 11, 2026 15:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@godexsoft godexsoft left a comment

Choose a reason for hiding this comment

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

Overall looks like a good idea. If you want to allow the old API then we could add overloads for each function to take the old void* and pass them to the new functions.
Definitely try to get rid of reinterpret_cast 👍


rocksdb::ReadOptions const options;
rocksdb::Slice const slice(static_cast<char const*>(key), m_keyBytes);
rocksdb::Slice const slice(reinterpret_cast<char const*>(hash.data()), m_keyBytes);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be nice to avoid reinterpret_cast. It's only good as last resort.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed this to std::bit_cast, as the to and from types are trivially copyable and have the same size.

  • hash: is our custom uint256, which is aliased to our base_uint<256> and wraps a std::array<std::uint32_t, WIDTH> data_; with WIDTH = 256/32 = 8.
  • hash.data(): calls reinterpret_cast<const_pointer>(data_.data()), whereby it takes the uint32_t const* and casts it to unsigned char const*.
  • The std::bit_cast<char const*> then converts unsigned char const* to a char const*, as needed by RocksDB.

I built and tested the binary locally and was able to sync up with testnet using RocksDB. While this is not the ultimate test, it's a good sanity check.

@bthomee bthomee requested a review from godexsoft February 12, 2026 20:28
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