This repository was archived by the owner on Aug 7, 2026. It is now read-only.
feat(smt): Fjall storage backend for RocksDbStorage - #1101
Open
battlmonstr wants to merge 45 commits into
Open
Conversation
battlmonstr
force-pushed
the
smt-bench-fjall
branch
8 times, most recently
from
July 24, 2026 19:40
46ea10b to
ae1f4d3
Compare
to support RustRover IDE
Without --reset it is not possible to run the command twice in a row. It fails with an error when running on an existing db.
The existing target runs both smt::large and smt::large_forest unit tests. Running only smt::large is useful until the large_forest module is refactored.
The Makefile declares bench-large-smt-* targets to run benchmarks in the miden-crypto binary (main.rs). There are 2 more related benchmarks: * "criterion" - miden-crypto/benches/large_smt.rs * "codspeed" - benches/smt-codspeed/benches/smt_codspeed.rs It is useful to be able to run them in isolation for alternative backends comparison.
This is needed to make RocksDbConfig backend-agnostic. write_buffer_manager creation relies on rocksdb library.
for reuse across alternative backends
The constants are shared among alternative backends.
battlmonstr
force-pushed
the
smt-bench-fjall
branch
from
July 25, 2026 07:22
ae1f4d3 to
3b797b9
Compare
battlmonstr
marked this pull request as ready for review
July 25, 2026 07:25
|
Automated check (CONTRIBUTING.md) Findings:
Recommendations:
Next steps:
|
Author
|
/quality-review |
Author
|
@sergerad, @krushimir, @huitseeker this is ready for review, please approve the CI workflows 🙏 |
battlmonstr
force-pushed
the
smt-bench-fjall
branch
3 times, most recently
from
July 28, 2026 10:01
2ac8eb6 to
4e5d071
Compare
Defines traits to be implemented by alternative backends. Adds a RocksKVDB implementation to migrate RocksDB-specific code from RocksDbStorage.
Before RocksDbStorage implementation was tied to RocksKVDB backend. Now the implementation is renamed to KVDBSmtStorage<KVDB>. RocksDbStorage is an alias to KVDBSmtStorage<RocksKVDB>.
Before "rocksdb" feature enabled both persistence and RocksDB backend. This adds a new feature "smt-kvdb" for persistence (backend agnostic). A new feature set "smt-kvdb-*" to enable persistence with a particular backend. "rocksdb" is alias of "smt-kvdb-rocks". smt-kvdb-default feature is needed for --all-features builds. In such build smt-kvdb-default is enabled, and it effectively disables non-default backends.
change RocksDb prefix to PersistentSmtStorage on all related config types because this config is reused between different backends.
and RocksDbSnapshotStorage to PersistentSmtStorageSnapshot because this class can be backed by alternative backends.
After generic KVDBSmtStorage refactoring this implementation is not tied to RocksDB, so the comments need to be updated.
After generic KVDBSmtStorage refactoring this file is not tied to RocksDB.
battlmonstr
force-pushed
the
smt-bench-fjall
branch
2 times, most recently
from
July 29, 2026 13:06
7b95d5e to
a6f6eb5
Compare
battlmonstr
force-pushed
the
smt-bench-fjall
branch
from
July 30, 2026 15:18
a6f6eb5 to
44b7cfb
Compare
KVDB traits implementation using Fjall database. This backend can be selected by smt-kvdb-fjall feature flag.
battlmonstr
force-pushed
the
smt-bench-fjall
branch
from
July 30, 2026 17:07
44b7cfb to
7ede580
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The goal is to implement alternative storage backends for
merkle::smt::large::storageand compare them against each other. A Fjall database was chosen as a promising candidate alternative. A couple of others backends are tested but not included here.RocksDbStorage(rocksdb.rs) used to have business logic to store a large SMT. That business logic was wired to RocksDB but in theory could be applied to any key-value storage mechanism.Instead of copy-pasting
RocksDbStoragefor each backend an approach was chosen to refactor theRocksDbStorageto work with a new set of abstract KVDB traits. These traits can be implemented for multiple alternative backends. It saves time because instead of testing, updating and reviewing the whole 1700 SLOC per backend the new code has about 400 SLOC per backend.Contents
The PR commits are organized in this sequence:
RocksDbStoragerefactoring onto KVDB traits: the traits andRocksKVDBimplementation are introduced, thenRocksDbStorageis ported method by method, and finalized with a code cleanup.RocksDbStoragetoKVDBSmtStorageand introducing ansmt-kvdb-rocksfeature flag to prepare for alternative backends. Renamings after generalization.smt-kvdb-fjallfeature flag.Each intermediate commit produces a valid state in which tests and benchmarks pass.
It is recommended to do code review sequentially commit by commit.
Tests
Benchmarks
macOS 26, Mac Mini M4 Pro 10+4 cores
Fjall patch
Original Fjall runs criterion benchmarks and
rocksdb_large_smtintegration test much slower than RocksDB because it callsfsync()multiple times during normal operation while RocksDB doesn't.fjalllibrary and its dependencylsm-treeare patched to disable this behavior and speed up the tests.