ADR-40 Replace IAVL and decouple state commitment from storage #8297
Replies: 30 comments 116 replies
-
@jlandrews, referencing your comment here: #7100 (comment), Regen Network's "orm" package automates construction of secondary indexes on top of a KV store: https://github.com/regen-network/regen-ledger/tree/master/orm. With a bit of work, it could probably do most of what's in SQL. I have proposed including it in the SDK proper (#7098). I am curious, however, if there is a viable high-performance SQL solution that could work as an alternative to a KV store or maybe on top of a KV store. I wonder for instance how much speed up there is with sqlite prepared statements vs parsing queries on demand. I personally think SQL for the storage layer would be ideal compared to what we're doing now if we could make it performant. |
Beta Was this translation helpful? Give feedback.
-
I agree with prioritizing the separation of storage from storage commitments. And that porting SMT is probably the shortest path to a new storage commitment system. I would also propose though that there be some sort of standardized interface for what a storage commitment scheme is supposed to provide, so that future alternatives could be easily swapped in, and so that performance could be easily compared. |
Beta Was this translation helpful? Give feedback.
-
I would note that separating storage and commitments as proposed is a relatively big API change. Likely a valuable one, but it would mean refactoring the whole storage layer of the SDK. So a stepwise, opt-in approach makes sense. As in, we get a |
Beta Was this translation helpful? Give feedback.
-
Ian asked:
Response: SMT must be small to fit in a memory. It's goal is to validate and update commitments. We need to store objects in a storage anyway to allow fast queries. Storing objects in SMT will bloat it and adds redundancy. |
Beta Was this translation helpful? Give feedback.
-
Simple "decoupling" of state and proofs, doesn't describe saving "old state". We need a way to store previous versions of data. This is also strongly related to "pruning" topic. Questions
Possible methods of storing old stateNaive Version PrefixEach key is prefixed with version. For each version all data belonging to that version is stored.
Database snapshotDatabase-layer snapshots used to store old versions. Version suffixEach key has a version as a suffix.
PruningSaving every n-th block
|
Beta Was this translation helpful? Give feedback.
-
ADR-040 draftOn Friday 15 Jan we had a kick off meeting to discuss the SMT integration in Cosmos SDK and review the ADR-040 proposal. |
Beta Was this translation helpful? Give feedback.
-
Discord ChatWe created the |
Beta Was this translation helpful? Give feedback.
-
SnapshotsNOTE: snapshot is not the same a version management. Snapshot is used for fast sync feature and recover. We don't need version management on DB level. In the ADR I propose to implement snapshots using the underlying DB engine snapshot function. This will limit the supported backends of course (Badger, RocksDB). |
Beta Was this translation helpful? Give feedback.
-
Version management.NOTE: (read above): version management is not necessary same thing as snapshot. Versioning is required by SDK to process and possible roll back transaction. At minimum, AFAICT, we don't need version management on the storage engine - this could be done as it is now using However, the |
Beta Was this translation helpful? Give feedback.
-
I'm wondering if we should rework a bit the store interfaces. Mainly break the
Motivation:
|
Beta Was this translation helpful? Give feedback.
-
Integrating LazyLedger SMT with Cosmos SDKWe created |
Beta Was this translation helpful? Give feedback.
-
SMT Dev Call 2021-01-28 Notes
|
Beta Was this translation helpful? Give feedback.
-
SMT Dev Call 2021-02-05 Notes
Next up:
|
Beta Was this translation helpful? Give feedback.
-
i think so...
Le dim. 7 févr. 2021 à 13:40, Tomasz Zdybał <[email protected]> a
écrit :
… SSI - Serializable Snapshot Isolation.
I'm 99% sure they're not durable. But "Checkpoints", definitely are. The
downside of checkpoints is, they will require more "glue code" to provide
access to historical state.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#8297 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASXWWFPFDO52RDKKERVQUS3S52C23ANCNFSM4V5Y6UYQ>
.
|
Beta Was this translation helpful? Give feedback.
-
Serializable Snapshot Isolation.
Le sam. 6 févr. 2021 à 18:56, Robert Zaremba <[email protected]> a
écrit :
… So, the bare snapshot in RocksDB is not durable? I thought it contains a
list of files or an index file descriptor.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#8297 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASXWWFLIUJO36W6NGPEYSI3S5V7ENANCNFSM4V5Y6UYQ>
.
|
Beta Was this translation helpful? Give feedback.
-
AvaLabs is building CedrusDB which looks like a potential candidate that would support our needs. It looks like source available soon. |
Beta Was this translation helpful? Give feedback.
-
SMT Dev Call 2021-02-12 NotesDuring the call we were looking at Badger performance and discussing the DB writes:
We also reviewed the scope of SMT changes needed to implement ADR-40. The initial list is following (this is only the SMT part, without going into SDK changes):
Next Up:
|
Beta Was this translation helpful? Give feedback.
-
I had a look into https://github.com/cockroachdb/pebble and it looks to be a strong contender. Planning to add it into benchmark. |
Beta Was this translation helpful? Give feedback.
-
Potentially naive question: how will historical IAVL state data be handled during sync/resync? Or rather, how will the transition from IAVL to SMT be handled during a sync/resync? The AppHash in historical headers may have been generated from merkleization of the data as part of an IAVL data structure, that same data represented in SMT will not produce the same hashes. So if syncing an application's state from genesis, the app will first need to apply txs into IAVL until some point at which it switches over to using SMT? |
Beta Was this translation helpful? Give feedback.
-
This weekend I read and analyzed Verkle Tire proposed by Dankrad Feist from Ethereum.
My recommendation is to stick with what we have planned. We can always update the SMT internal structure to Kate once Ethereum folks will implement it and test it. |
Beta Was this translation helpful? Give feedback.
-
Scope of work and MilestonesToday we had a meeting to plan the milestones. Notes: https://hackmd.io/rwNyKLAnQ3WRUiRH4UxJ4w?view |
Beta Was this translation helpful? Give feedback.
-
Using BadgerDB for managing version:
|
Beta Was this translation helpful? Give feedback.
-
Storage Hard Fork vs IBC and Merkle Proofs.While doing ADR-40 review, we discussed the potential problems of the state hard fork with regards to IBC. TL;DR: we need to design a mechanism for IBC which will work support hard forks anyway. Hard forks may change a module data layout, account layout or anything with a storage (even if we won't do any changes in the SMT). They are inevitable. Concerns and AnswersMerkle Proof StructureThe LazyLedger SMT has implemented functionality to construct merkle proofs. However, they are not ICS-23 compliant. We put in the scope of work to update the implementation and make it ICS-23 compliant. Storage migrationADR-40 requires a full storage migration. It's a hard fork. We didn't define the eventual update mechanism. We were thinking about doing a standard hard fork upgrade path by resetting the chain:
This will reset all light client proofs and will make IBC hard to use. Few ideas how to handle it:
Module data layout migrationModules can migrate their data layout without storage implementation change involved. This will invalidate all past merkle proofs. cc: @cwgoes , @colin-axner , @AdityaSripal |
Beta Was this translation helpful? Give feedback.
-
Yes, how we combine (key, value) (pre-hashing, length prefixing, post-hashing, etc) to form the leaf hash is defined in the ics23 spec. Note that if you switch out the underlying store, you will need to change the Proof Spec. This is tied to the client structure, but in theory should be updatable by a governance vote (like you would need to authorize after any state reset) |
Beta Was this translation helpful? Give feedback.
-
Removing MultistoreMultistore is one for the relics of current store design, which has many issues (problems related to race condition and sync eg: #6370). The idea is to remove the MultiStore from the SDK, and use a single instance of Let's continue the discussion about the concept here, and in the PR let's focus more on technicalities. |
Beta Was this translation helpful? Give feedback.
-
Removing Multistore -- using Record IDsAlternative to the prefix store based design described above for removing multistore. Copying a comment from ADR-40: use prefix store instead of multistore #9355 pull request. The concept is researched by AiB (@jgimeno , @fdymylja ):
Where,
NOTE: AiB proposed different interface, but the concept is similar. |
Beta Was this translation helpful? Give feedback.
-
I'd suggest for MultiStore to be replaced by something like an "ObjectStore" in which the KVStore follows a "folder" structure where every folder is a protobuf object. The KVStore prefix for the protobuf object does not necessarily need to be the protobuf fullname of the message itself (ex: bank.v1beta1.Balance), but rather a 2 bytes (maybe?) prefix. I'm not sure though how a module should signal that it would like to use a custom (shortened) prefix for the object instead of the object fullname. Also, registering length-variable object prefixes requires peculiar care when it comes to iterating an object prefix in order not to end up in other object domains.
Iterating over bank.Balance would make us end up in auth.Account domain too. StoreKeys of Modules have just the duty to check that a module is not trying to access another module domain of objects. I feel this could even simplify a lot genesis exporting/importing. |
Beta Was this translation helpful? Give feedback.
-
While reviewing ADR-40 and getting more requests to let modules manages their own state and be able to only commit to some values, we propose the following update to ADR-40 to provide a low level access to State Commitment only: #9451 |
Beta Was this translation helpful? Give feedback.
-
I'm generally confused as to why there seems to be consensus that the following is true:
I don't see how this is true. The SMT upgrade will change the IBC-subtree from being stored under an IAVL subtree, to instead being stored under an SMT subtree. This requires chain B to know how to verify proofs from an SMT subtree. (An |
Beta Was this translation helpful? Give feedback.
-
In the interim, this may help with db performance |
Beta Was this translation helpful? Give feedback.
-
IAVL has effectively become an orphaned project within the Cosmos ecosystem and it's proven to be an inefficient state commitment.
The goal of this discussion is to spec the next Cosmos-SDK solution for state-commitment and storage. It's important to treat this things separately.
References:
Beta Was this translation helpful? Give feedback.
All reactions