osmosis-labs / osmosis

The AMM Laboratory
https://app.osmosis.zone
Apache License 2.0
895 stars 597 forks source link

Merkelized BTree store #2118

Open ValarDragon opened 2 years ago

ValarDragon commented 2 years ago

Background

Building a Merkelized BTree store with a key value interface, parameterized for a target fan-in factor of 1024 or so, and large leaves bundled together will significantly help improve efficiency of features like generalized accumulation stores / Orderbooks.

Suggested Design

There are two reasons for merkelization:

There is a lot of state that is made light client queryable that should not be. Right now we suffer high write overhead due to the merkelization and bad disk layout of IAVL / binary search trees in general. (Technically fixable for a binary tree, but a large undertaking)

We can solve a lot of this by making a merkle tree that is much more light client unfriendly, to intentionally dissuade light client usecases (useful as an API surface property), and has a simpler data storage back-end implementation. (You technically can make these better for binary trees, but its a larger implementation task)

Implementation steps

cc @giunatale

p0mvn commented 2 years ago

Is this available? I would be happy to work on / help with this once this is a priority

giunatale commented 2 years ago

The plan was for me to start working on it but any help/contribution I think is very welcome! I guess it would depend on the level of priority and what @ValarDragon has in mind :)