Skip to content

feat: first itereation of MVP #4

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 24 commits into
base: main
Choose a base branch
from
Open

feat: first itereation of MVP #4

wants to merge 24 commits into from

Conversation

damiramirez
Copy link

@damiramirez damiramirez commented Aug 14, 2025

This PR introduces a first implementation of EthrexDB

  • file_manager.rs: Handles file I/O and memory mapping
  • serialization.rs: Converts between MPT nodes and binary format using a 2-node system (Branch + Extend)
  • db.rs: Main API providing commit(), get(), and root() operations

In this first iteration, the DB depends on a root node, so I'm using ethrex::InMemoryTrieDB to handle the inserts. Once we finish adding values to the tree, we can call db.commit(&root_node) to serialize the entire MPT to a file.

Since we're using structs/function from Ethrex, the trie and RLP logic has been copied from the Ethrex repository. You can find this code under src/trie and src/rlp.


Benchmarking and Profiling

To run a benchmark comparing this new implementation against libmdbx (as we do in Ethrex), run:

make bench

To profile using Samply, run:

make profile

File Format

Implements a simple append-only file for storing complete MPT

[header: 8 bytes] -> points to latest version
[version 1: [prev_offset: 8 bytes][serialized_nodes]]
[version 2: [prev_offset: 8 bytes][serialized_nodes]]
...
[version N: [prev_offset: 8 bytes][serialized_nodes]] <- latest

Limitations of this iteration - Next steps

  • Does not support NodeRef::Hash references (supports only NodeRef::Node).
  • Stores complete tries instead of incremental deltas.
  • Add a new benchmark using Libmdbx with path
  • Error handling.

@damiramirez damiramirez marked this pull request as draft August 14, 2025 17:39
@damiramirez damiramirez marked this pull request as ready for review August 18, 2025 20:48
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