ForkBase: An Efficient Storage Engine for Blockchain and Forkable Applications

Sheng Wang, Tien Tuan Anh Dinh, Qian Lin, Zhongle Xie, Meihui Zhang, Qingchao Cai, Gang Chen, Beng Chin Ooi, Pingcheng Ruan

TL;DR

ForkBase is a distributed storage engine tailored for blockchains, collaborative analytics, and versioned systems. By combining a novel data structure called the POS-Tree with native fork-on-demand and fork-on-conflict semantics, it eliminates redundant data across versions and branches while providing built-in tamper evidence and out-of-the-box support for fast analytical queries.

What Problem Does This Paper Address?

Modern data-intensive applications increasingly need three core capabilities:

  1. Multiversioning (tracking derivation history),
  2. Branching/Forking (either explicit for isolated work, or implicit from concurrent conflicting updates), and
  3. Tamper evidence (cryptographic guarantees that history cannot be rewritten undetected).

Today, systems such as blockchains (Ethereum, Hyperledger) and collaborative data tools (Datahub, OrpheusDB) build these features in an ad-hoc fashion on top of generic key-value stores (LevelDB, RocksDB) or file systems (git). This design pattern has severe drawbacks:

  • High development effort: Developers must repeatedly implement custom Merkle trees and delta logs.
  • Storage bloat: Delta encoding fails when branches diverge or when identical data is committed non-consecutively, while standard B$^+$-trees alter page structures based on insertion order, thwarting page-level deduplication.
  • Poor analytical query performance: Blockchains store state data as opaque, serialized byte arrays, making provenance tracking or historical analytics require full-chain scans.

Methods

ForkBase pushes versioning, forking, and integrity verification down into the storage layer through several core innovations:

  • SIRI (Structurally-Invariant Reusable Indexes): A class of search indexes whose physical layout is strictly determined by the set of records rather than their insertion order, allowing identical sub-structures to be shared across distinct index instances.
  • POS-Tree (Pattern-Oriented-Split Tree): An implementation of SIRI that unifies B$^+$-tree indexing, Merkle trees, and content-based slicing:
  • Leaf splitting: Detects split boundaries using cyclic polynomial rolling hashes over record contents, ensuring robust page-level deduplication.
  • Index splitting: Uses bit patterns from child node cryptographic hashes (e.g., SHA-256) to maintain balanced trees without expensive rolling hashes on inner nodes.
  • Sub-tree Diffs and Merges: Enables fast diffing ($O(D \log N)$ where $D$ is the count of modified leaves) and allows three-way branch merges to swap and reuse entire sub-trees without descending to the individual record level.
  • Unified Fork Semantics: Natively supports both Fork on Demand (FoD) (explicit tagged branching, like Git) and Fork on Conflict (FoC) (implicit untagged branches, like Dynamo conflict resolution or blockchain forks).
  • Extended Key-Value Data Model & Two-Layer Partitioning: Supports primitive types (String, Integer) and chunkable types (Blob, List, Map, Set). To prevent skew on hot pages, dispatchers route by key hash to servlets, while servlets distribute immutable content chunks across nodes by chunk ID (CID).

Datasets

The authors evaluated ForkBase across micro-benchmarks and three distinct application workloads:

  • Blockchain (Blockbench / YCSB): Evaluated via a key-value smart contract on Hyperledger v0.6 running up to 1 million write operations (1 KB value size) over a 12,000-block chain.
  • Collaborative Wiki Editing: 32 concurrent clients editing 3,200 pages (initial size 15 KB, averaging 40 versions per page, generating >2 GB data) under variable update-vs-insert ratios and Zipfian skew ($z = 0.5$).
  • Collaborative Analytics Benchmark: 5 million relational records loaded from a CSV file (~180 bytes/record, 12-byte primary keys, integer, and textual fields; ~927 MB initial commit), comparing row- and column-oriented layouts against OrpheusDB.

Key Insights and Ideas

  • Making Tree Layout Deterministic Unlocks Page Deduplication: Standard B$^+$-trees with identical keys can end up with entirely different internal page splits depending on update order. POS-Trees solve this by defining split points based on content patterns, allowing divergent branches and versions to share unchanged pages safely.
  • Tamper Evidence as a Free Byproduct: Because POS-Tree node pointers are cryptographic hashes of their children (content-addressable Merkle pointers), every committed root automatically acts as a tamper-evident digest.
  • Analytics-Ready Blockchains: Replacing bespoke Merkle bucket trees and separate "state deltas" with nested, version-aware Map and Blob objects reduced Hyperledger's state management codebase from 1900+ lines to just 18 lines, while exposing direct pointers to prior states without requiring chain replays.

Key Results

  • Blockchain Analytics Acceleration: On Hyperledger, ForkBase achieved identical transaction commit throughput and commit latency to RocksDB. However, for historical queries (state scan and block scan), ForkBase was 2 to 4 orders of magnitude faster than RocksDB by eliminating full-chain pre-processing scans.
  • Wiki Storage Savings: Compared to Redis, ForkBase achieved a 55% reduction in storage footprint for multi-version wiki histories via automatic POS-Tree deduplication. Reading historical versions was faster on ForkBase because clients could reuse cached chunks.
  • Analytical Query Performance: On the 5-million record dataset, ForkBase’s column-oriented layout ran aggregation queries $10\times$ faster than OrpheusDB because it completely avoided version reconstruction costs. Version diffs were significantly faster than OrpheusDB when version differences were small.
  • Linear Scalability: The two-layer distributed architecture achieved near-linear throughput scaling across 64 servlets.

Limitations and Future Work

  • Write Overhead from Hashing: Content-based slicing via rolling hashes accounts for ~20% of POS-Tree construction time, meaning raw write throughput for fresh inputs is lower than in-memory engines like Redis or pure append-only LSM trees.
  • Small Delta Inefficiency: Chunk-level deduplication is less space-efficient than record-level delta encoding when updates consist of tiny byte modifications dispersed across large chunks.
  • Degraded Diffing on Large Divergence: While sub-tree diffing is extremely fast for small edits, the cost scales up when differences are dispersed across the entire tree, requiring deep traversals.
  • Future Work: The authors propose combining POS-Tree chunk deduplication with delta encoding on similar chunks, as well as integrating trusted hardware primitives (e.g., Intel SGX) to enforce freshness guarantees alongside tamper evidence.

Summary updated

BibTeX
@article{wang2018forkbase,
  author = {Sheng Wang and Tien Tuan Anh Dinh and Qian Lin and Zhongle Xie and Meihui Zhang and Qingchao Cai and Gang Chen and Beng Chin Ooi and Pingcheng Ruan},
  title = {{ForkBase: An Efficient Storage Engine for Blockchain and Forkable Applications}},
  journal = {Proc. VLDB Endow.},
  year = {2018},
  url = {https://openreview.net/forum?id=3lNLThxWktK},
}
Figure