Software Consulting & Engineering Requirements to Production

Sparse Merkle tree storage

2025-2026

← Back to portfolio

  • Open source
  • Rust
  • Sparse Merkle trees
  • RocksDB

Implemented sparse Merkle tree forests with bounded history per tree, combining a flat SQLite representation with in-memory and key-value-backed overlays. The work spanned account persistence, authenticated state, and the queries used to retrieve it. Keeping database records and Merkle roots consistent required coordinated changes to schema, startup loading, and block application.

Integrated the forest into account updates and introduced partial storage-map queries, so callers could retrieve selected state. For incremental account updates, I replaced full-account loading with queries for the account header and balances affected by the delta. I also replaced an N+1 historical-vault query pattern with a single SQL query, preserving the latest value at the requested block and filtering deleted assets. Regression tests covered those historical-state semantics.

For RocksDB-backed account and nullifier trees, I integrated persistent loading and added paged initialization, explicit consistency checks against SQLite, and a forced-rebuild recovery path. The changes addressed the operational costs of reconstructing state as well as the amount of data read during block processing. The merged work includes forest integration, incremental account updates, and store recovery controls.