Skip to content

Replace RocksDB with Redb as backing for EVM database #1873

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 5 commits into
base: redb
Choose a base branch
from

Conversation

owanikin
Copy link

@owanikin owanikin commented Jun 3, 2025

Issue #1845

What was wrong?

The client previously used RocksDB for persistent storage of EVM-related data such as accounts, storage slots, block hashes, and contract bytecode. However, RocksDB has several drawbacks for our use case:

  • It’s very slow to compile and bloats build times.
  • It’s picky about Rust toolchains and system dependencies.
  • It isn’t a truly ACID-compliant database.
  • It’s a large C++-based dependency that introduces unnecessary complexity for a Rust-native project.

How was it fixed?

  • Replaced RocksDB with Redb, a Rust-native, embeddable ACID key-value store. Redb provides:
  • Simpler integration with Rust projects
  • Much faster compile times
  • Fully ACID-compliant transactions
  • A smaller dependency footprint
  • The following changes were made:
  • Introduced redb::Database as the backing store in EvmDB.
  • Defined typed TableDefinitions for each data category (accounts, storage, contracts, block hashes).
  • Refactored RocksDB-based put, get, and delete logic into Redb transactional APIs using begin_read and begin_write.
  • Updated the .e2ss state import logic, trie operations, and block hash window logic to use Redb.
  • Removed all RocksDB-related code and dependencies.
  • Added a setup_redb() utility for initializing and opening the database at the configured path.

@KolbyML
Copy link
Member

KolbyML commented Jun 3, 2025

@owanikin can you fix CI and rebase?

@KolbyML
Copy link
Member

KolbyML commented Jun 3, 2025

@owanikin if you need help rebasing or fixing CI just message me on discord and we can jump on a call and fix it quick

@owanikin
Copy link
Author

owanikin commented Jun 3, 2025

@owanikin if you need help rebasing or fixing CI just message me on discord and we can jump on a call and fix it quick

Thanks @KolbyML . I’ve already rebased the branch and resolved the CI issues — everything should be clean now. Let me know if you need anything else from my end.

@KolbyML
Copy link
Member

KolbyML commented Jun 3, 2025

Hi @owanikin github is still reporting a conflict

image

you can fix the conflict by running

git fetch upstream
git rebase upstream/master

fix the conflicts

// don't pull
git push --force

@owanikin owanikin force-pushed the replace-rocksdb-with-redb branch from 81a240b to 751799e Compare June 3, 2025 21:25
@KolbyML
Copy link
Member

KolbyML commented Jun 4, 2025

@owanikin CI is failing again

@owanikin owanikin force-pushed the replace-rocksdb-with-redb branch from 751799e to 5216df3 Compare June 4, 2025 07:44
@owanikin
Copy link
Author

owanikin commented Jun 4, 2025

@owanikin CI is failing again

@KolbyML CI is passing now.

@morph-dev
Copy link
Collaborator

morph-dev commented Jun 22, 2025

Sorry for the late response, as you might be aware of, there were some changes and Trin is no longer actively maintained.

Therefore I don't think there is much value in reviewing this entire PR, making sure that everything works as expected, and checking if there are some performance degradation.

With that being said, if you don't want all this work to go to waste, I would be fine with creating new branch (redb) and you can create PR to merge the code there (I might do a quick review in the process). Then if Trin is resurrected in the future, somebody can do a proper review and merge that branch into master.

What do you think?

@owanikin
Copy link
Author

Sorry for the late response, as you might be aware of, there were some changes and Trin is no longer actively maintained.

Therefore I don't think there is much value in reviewing this entire PR, making sure that everything works as expected, and checking if there are some performance degradation.

With that being said, if you don't want all this work to go to waste, I would be fine with creating new branch (redb) and you can create PR to merge the code there (I might do a quick review in the process). Then if Trin is resurrected in the future, somebody can do a proper review and merge that branch into master.

What do you think?

Thank you @morph-dev , I'll really appreciate that!

@morph-dev morph-dev changed the base branch from master to redb June 25, 2025 12:18
@morph-dev
Copy link
Collaborator

I created new branch and changed the base branch of this PR. Do you mind rebasing your code (to solve conflicts)?

@owanikin owanikin force-pushed the replace-rocksdb-with-redb branch from 5216df3 to 74e6749 Compare July 2, 2025 12:36
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