celestiaorg / smt

A Go library that implements a Sparse Merkle tree for a key-value map.
https://godoc.org/github.com/celestiaorg/smt
MIT License
138 stars 53 forks source link

Don't recompute the root on every update; only on commit #72

Open musalbas opened 2 years ago

musalbas commented 2 years ago

We should pull @roysc's rewrite of smt.go upstream here (https://github.com/vulcanize/smt), as it provides a substantial and well-written performance improvement by not recomputing the root on every update, that also produces the same roots as this smt.

In order to do so we need to first:

  1. Re-implement deepsubtree;
  2. Re-add value storage.

Given that the Cosmos SDK store v2 may be abandoned, we are looking into resuming the work of integrating SMT into store v1 (https://github.com/celestiaorg/cosmos-sdk/pull/12) by @tzdybal. The way that we re-add value storage will depend on the requirements of store v1 and in particular its requirements for historical state access, rollback, and pruning, so this needs to be analyzed first.