cosmos-sdk/docs/architecture/adr-040-storage-and-smt-sta...

289 lines
23 KiB
Markdown
Raw Normal View History

ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
# ADR 040: Storage and SMT State Commitments
## Changelog
- 2020-01-15: Draft
## Status
DRAFT Not Implemented
## Abstract
Sparse Merkle Tree ([SMT](https://osf.io/8mcnh/)) is a version of a Merkle Tree with various storage and performance optimizations. This ADR defines a separation of state commitments from data storage and the Cosmos SDK transition from IAVL to SMT.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
## Context
Currently, Cosmos SDK uses IAVL for both state [commitments](https://cryptography.fandom.com/wiki/Commitment_scheme) and data storage.
IAVL has effectively become an orphaned project within the Cosmos ecosystem and it's proven to be an inefficient state commitment data structure.
In the current design, IAVL is used for both data storage and as a Merkle Tree for state commitments. IAVL is meant to be a standalone Merkelized key/value database, however it's using a KV DB engine to store all tree nodes. So, each node is stored in a separate record in the KV DB. This causes many inefficiencies and problems:
+ Each object query requires a tree traversal from the root. Subsequent queries for the same object are cached on the Cosmos SDK level.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
+ Each edge traversal requires a DB query.
+ Creating snapshots is [expensive](https://github.com/cosmos/cosmos-sdk/issues/7215#issuecomment-684804950). It takes about 30 seconds to export less than 100 MB of state (as of March 2020).
+ Updates in IAVL may trigger tree reorganization and possible O(log(n)) hashes re-computation, which can become a CPU bottleneck.
+ The node structure is pretty expensive - it contains a standard tree node elements (key, value, left and right element) and additional metadata such as height, version (which is not required by the Cosmos SDK). The entire node is hashed, and that hash is used as the key in the underlying database, [ref](https://github.com/cosmos/iavl/blob/master/docs/node/node.md
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
).
Moreover, the IAVL project lacks support and a maintainer and we already see better and well-established alternatives. Instead of optimizing the IAVL, we are looking into other solutions for both storage and state commitments.
## Decision
docs: Update ADR-040 to store hash(value) in SMT leaf (#9680) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description This revises ADR-40 to specify storing `hash(value)` as the SMT mapped value. This should allow the same indexing functionality as using `hash(key + value)`, while working much better with IPLD by storing only the hash of the mapped content. Some discussion here: https://github.com/cosmos/cosmos-sdk/discussions/9331#discussioncomment-992325 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - N/A - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - N/A - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - N/A - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - N/A - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-09-15 04:42:27 -07:00
We propose to separate the concerns of state commitment (**SC**), needed for consensus, and state storage (**SS**), needed for state machine. Finally we replace IAVL with [Celestia's SMT](https://github.com/lazyledger/smt). Celestia SMT is based on Diem (called jellyfish) design [*] - it uses a compute-optimised SMT by replacing subtrees with only default values with a single node (same approach is used by Ethereum2) and implements compact proofs.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
The storage model presented here doesn't deal with data structure nor serialization. It's a Key-Value database, where both key and value are binaries. The storage user is responsible for data serialization.
### Decouple state commitment from storage
Separation of storage and commitment (by the SMT) will allow the optimization of different components according to their usage and access patterns.
docs: Update ADR-040 to store hash(value) in SMT leaf (#9680) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description This revises ADR-40 to specify storing `hash(value)` as the SMT mapped value. This should allow the same indexing functionality as using `hash(key + value)`, while working much better with IPLD by storing only the hash of the mapped content. Some discussion here: https://github.com/cosmos/cosmos-sdk/discussions/9331#discussioncomment-992325 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - N/A - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - N/A - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - N/A - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - N/A - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-09-15 04:42:27 -07:00
`SC` (SMT) is used to commit to a data and compute Merkle proofs. `SS` is used to directly access data. To avoid collisions, both `SS` and `SC` will use a separate storage namespace (they could use the same database underneath). `SS` will store each record directly (mapping `(key, value)` as `key → value`).
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
docs: Update ADR-040 to store hash(value) in SMT leaf (#9680) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description This revises ADR-40 to specify storing `hash(value)` as the SMT mapped value. This should allow the same indexing functionality as using `hash(key + value)`, while working much better with IPLD by storing only the hash of the mapped content. Some discussion here: https://github.com/cosmos/cosmos-sdk/discussions/9331#discussioncomment-992325 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - N/A - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - N/A - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - N/A - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - N/A - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-09-15 04:42:27 -07:00
SMT is a merkle tree structure: we don't store keys directly. For every `(key, value)` pair, `hash(key)` is used as leaf path (we hash a key to uniformly distribute leaves in the tree) and `hash(value)` as the leaf contents. The tree structure is specified in more depth [below](#smt-for-state-commitment).
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
docs: Update ADR-040 to store hash(value) in SMT leaf (#9680) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description This revises ADR-40 to specify storing `hash(value)` as the SMT mapped value. This should allow the same indexing functionality as using `hash(key + value)`, while working much better with IPLD by storing only the hash of the mapped content. Some discussion here: https://github.com/cosmos/cosmos-sdk/discussions/9331#discussioncomment-992325 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - N/A - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - N/A - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - N/A - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - N/A - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-09-15 04:42:27 -07:00
For data access we propose 2 additional KV buckets (implemented as namespaces for the key-value pairs, sometimes called [column family](https://github.com/facebook/rocksdb/wiki/Terminology)):
1. B1: `key → value`: the principal object storage, used by a state machine, behind the Cosmos SDK `KVStore` interface: provides direct access by key and allows prefix iteration (KV DB backend must support it).
docs: Update ADR-040 to store hash(value) in SMT leaf (#9680) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description This revises ADR-40 to specify storing `hash(value)` as the SMT mapped value. This should allow the same indexing functionality as using `hash(key + value)`, while working much better with IPLD by storing only the hash of the mapped content. Some discussion here: https://github.com/cosmos/cosmos-sdk/discussions/9331#discussioncomment-992325 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - N/A - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - N/A - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - N/A - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - N/A - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-09-15 04:42:27 -07:00
2. B2: `hash(key) → key`: a reverse index to get a key from an SMT path. Internally the SMT will store `(key, value)` as `prefix || hash(key) || hash(value)`. So, we can get an object value by composing `hash(key) → B2 → B1`.
3. We could use more buckets to optimize the app usage if needed.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
docs: adr-40: reduce multistore and make it atomic (#9355) * adr-40: use prefix store instead of multistore * add note about prefix.Store * Update SC and SS setup information and historical versions sepc * add note about key prefix optimization * rephrased the changes related to multistore * Apply suggestions from code review Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * design update * update merkle proofs * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * reword huffman compression paragraph * ADR-40: update on multi-store refactor and IBC proofs (#10191) * Update on multistore refactor and IBC proof * cleanup whitespace * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * revise for PR * add todo * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Robert Zaremba <robert@zaremba.ch> * review updates * add todo for protobuf message type compression * add link to a discussion * guarantee atomic commit with IBC workaround proposal * adding more links to references * Apply suggestions from code review Co-authored-by: Roy Crihfield <roy@manteia.ltd> * reword the module key compression part Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Roy Crihfield <roy@manteia.ltd>
2021-10-22 03:45:00 -07:00
We propose to use a KV database for both `SS` and `SC`. The store interface will allow to use the same physical DB backend for both `SS` and `SC` as well two separate DBs. The latter option allows for the separation of `SS` and `SC` into different hardware units, providing support for more complex setup scenarios and improving overall performance: one can use different backends (eg RocksDB and Badger) as well as independently tuning the underlying DB configuration.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
### Requirements
State Storage requirements:
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
+ range queries
+ quick (key, value) access
+ creating a snapshot
+ historical versioning
+ pruning (garbage collection)
State Commitment requirements:
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
+ fast updates
+ tree path should be short
docs: adr-40: reduce multistore and make it atomic (#9355) * adr-40: use prefix store instead of multistore * add note about prefix.Store * Update SC and SS setup information and historical versions sepc * add note about key prefix optimization * rephrased the changes related to multistore * Apply suggestions from code review Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * design update * update merkle proofs * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * reword huffman compression paragraph * ADR-40: update on multi-store refactor and IBC proofs (#10191) * Update on multistore refactor and IBC proof * cleanup whitespace * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * revise for PR * add todo * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Robert Zaremba <robert@zaremba.ch> * review updates * add todo for protobuf message type compression * add link to a discussion * guarantee atomic commit with IBC workaround proposal * adding more links to references * Apply suggestions from code review Co-authored-by: Roy Crihfield <roy@manteia.ltd> * reword the module key compression part Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Roy Crihfield <roy@manteia.ltd>
2021-10-22 03:45:00 -07:00
+ query historical commitment proofs using ICS-23 standard
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
+ pruning (garbage collection)
docs: Update ADR-040 to store hash(value) in SMT leaf (#9680) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description This revises ADR-40 to specify storing `hash(value)` as the SMT mapped value. This should allow the same indexing functionality as using `hash(key + value)`, while working much better with IPLD by storing only the hash of the mapped content. Some discussion here: https://github.com/cosmos/cosmos-sdk/discussions/9331#discussioncomment-992325 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - N/A - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - N/A - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - N/A - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - N/A - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-09-15 04:42:27 -07:00
### SMT for State Commitment
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
A Sparse Merkle tree is based on the idea of a complete Merkle tree of an intractable size. The assumption here is that as the size of the tree is intractable, there would only be a few leaf nodes with valid data blocks relative to the tree size, rendering a sparse tree.
docs: Update ADR-040 to store hash(value) in SMT leaf (#9680) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description This revises ADR-40 to specify storing `hash(value)` as the SMT mapped value. This should allow the same indexing functionality as using `hash(key + value)`, while working much better with IPLD by storing only the hash of the mapped content. Some discussion here: https://github.com/cosmos/cosmos-sdk/discussions/9331#discussioncomment-992325 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - N/A - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - N/A - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - N/A - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - N/A - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-09-15 04:42:27 -07:00
The full specification can be found at [Celestia](https://github.com/celestiaorg/celestia-specs/blob/ec98170398dfc6394423ee79b00b71038879e211/src/specs/data_structures.md#sparse-merkle-tree). In summary:
* The SMT consists of a binary Merkle tree, constructed in the same fashion as described in [Certificate Transparency (RFC-6962)](https://tools.ietf.org/html/rfc6962), but using as the hashing function SHA-2-256 as defined in [FIPS 180-4](https://doi.org/10.6028/NIST.FIPS.180-4).
* Leaves and internal nodes are hashed differently: the one-byte `0x00` is prepended for leaf nodes while `0x01` is prepended for internal nodes.
* Default values are given to leaf nodes with empty leaves.
* While the above rule is sufficient to pre-compute the values of intermediate nodes that are roots of empty subtrees, a further simplification is to extend this default value to all nodes that are roots of empty subtrees. The 32-byte zero is used as the default value. This rule takes precedence over the above one.
* An internal node that is the root of a subtree that contains exactly one non-empty leaf is replaced by that leaf's leaf node.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
### Snapshots for storage sync and state versioning
Below, with simple _snapshot_ we refer to a database snapshot mechanism, not to a _ABCI snapshot sync_. The latter will be referred as _snapshot sync_ (which will directly use DB snapshot as described below).
docs: adr-40: reduce multistore and make it atomic (#9355) * adr-40: use prefix store instead of multistore * add note about prefix.Store * Update SC and SS setup information and historical versions sepc * add note about key prefix optimization * rephrased the changes related to multistore * Apply suggestions from code review Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * design update * update merkle proofs * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * reword huffman compression paragraph * ADR-40: update on multi-store refactor and IBC proofs (#10191) * Update on multistore refactor and IBC proof * cleanup whitespace * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * revise for PR * add todo * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Robert Zaremba <robert@zaremba.ch> * review updates * add todo for protobuf message type compression * add link to a discussion * guarantee atomic commit with IBC workaround proposal * adding more links to references * Apply suggestions from code review Co-authored-by: Roy Crihfield <roy@manteia.ltd> * reword the module key compression part Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Roy Crihfield <roy@manteia.ltd>
2021-10-22 03:45:00 -07:00
Database snapshot is a view of DB state at a certain time or transaction. It's not a full copy of a database (it would be too big). Usually a snapshot mechanism is based on a _copy on write_ and it allows DB state to be efficiently delivered at a certain stage.
Some DB engines support snapshotting. Hence, we propose to reuse that functionality for the state sync and versioning (described below). We limit the supported DB engines to ones which efficiently implement snapshots. In a final section we discuss the evaluated DBs.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
One of the Stargate core features is a _snapshot sync_ delivered in the `/snapshot` package. It provides a way to trustlessly sync a blockchain without repeating all transactions from the genesis. This feature is implemented in Cosmos SDK and requires storage support. Currently IAVL is the only supported backend. It works by streaming to a client a snapshot of a `SS` at a certain version together with a header chain.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
docs: adr-40: reduce multistore and make it atomic (#9355) * adr-40: use prefix store instead of multistore * add note about prefix.Store * Update SC and SS setup information and historical versions sepc * add note about key prefix optimization * rephrased the changes related to multistore * Apply suggestions from code review Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * design update * update merkle proofs * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * reword huffman compression paragraph * ADR-40: update on multi-store refactor and IBC proofs (#10191) * Update on multistore refactor and IBC proof * cleanup whitespace * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * revise for PR * add todo * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Robert Zaremba <robert@zaremba.ch> * review updates * add todo for protobuf message type compression * add link to a discussion * guarantee atomic commit with IBC workaround proposal * adding more links to references * Apply suggestions from code review Co-authored-by: Roy Crihfield <roy@manteia.ltd> * reword the module key compression part Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Roy Crihfield <roy@manteia.ltd>
2021-10-22 03:45:00 -07:00
A new database snapshot will be created in every `EndBlocker` and identified by a block height. The `root` store keeps track of the available snapshots to offer `SS` at a certain version. The `root` store implements the `RootStore` interface described below. In essence, `RootStore` encapsulates a `Committer` interface. `Committer` has a `Commit`, `SetPruning`, `GetPruning` functions which will be used for creating and removing snapshots. The `rootStore.Commit` function creates a new snapshot and increments the version on each call, and checks if it needs to remove old versions. We will need to update the SMT interface to implement the `Committer` interface.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
NOTE: `Commit` must be called exactly once per block. Otherwise we risk going out of sync for the version number and block height.
NOTE: For the Cosmos SDK storage, we may consider splitting that interface into `Committer` and `PruningCommitter` - only the multiroot should implement `PruningCommitter` (cache and prefix store don't need pruning).
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
docs: adr-40: reduce multistore and make it atomic (#9355) * adr-40: use prefix store instead of multistore * add note about prefix.Store * Update SC and SS setup information and historical versions sepc * add note about key prefix optimization * rephrased the changes related to multistore * Apply suggestions from code review Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * design update * update merkle proofs * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * reword huffman compression paragraph * ADR-40: update on multi-store refactor and IBC proofs (#10191) * Update on multistore refactor and IBC proof * cleanup whitespace * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * revise for PR * add todo * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Robert Zaremba <robert@zaremba.ch> * review updates * add todo for protobuf message type compression * add link to a discussion * guarantee atomic commit with IBC workaround proposal * adding more links to references * Apply suggestions from code review Co-authored-by: Roy Crihfield <roy@manteia.ltd> * reword the module key compression part Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Roy Crihfield <roy@manteia.ltd>
2021-10-22 03:45:00 -07:00
Number of historical versions for `abci.RequestQuery` and state sync snapshots is part of a node configuration, not a chain configuration (configuration implied by the blockchain consensus). A configuration should allow to specify number of past blocks and number of past blocks modulo some number (eg: 100 past blocks and one snapshot every 100 blocks for past 2000 blocks). Archival nodes can keep all past versions.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
docs: adr-40: reduce multistore and make it atomic (#9355) * adr-40: use prefix store instead of multistore * add note about prefix.Store * Update SC and SS setup information and historical versions sepc * add note about key prefix optimization * rephrased the changes related to multistore * Apply suggestions from code review Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * design update * update merkle proofs * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * reword huffman compression paragraph * ADR-40: update on multi-store refactor and IBC proofs (#10191) * Update on multistore refactor and IBC proof * cleanup whitespace * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * revise for PR * add todo * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Robert Zaremba <robert@zaremba.ch> * review updates * add todo for protobuf message type compression * add link to a discussion * guarantee atomic commit with IBC workaround proposal * adding more links to references * Apply suggestions from code review Co-authored-by: Roy Crihfield <roy@manteia.ltd> * reword the module key compression part Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Roy Crihfield <roy@manteia.ltd>
2021-10-22 03:45:00 -07:00
Pruning old snapshots is effectively done by a database. Whenever we update a record in `SC`, SMT won't update nodes - instead it creates new nodes on the update path, without removing the old one. Since we are snapshotting each block, we need to change that mechanism to immediately remove orphaned nodes from the database. This is a safe operation - snapshots will keep track of the records and make it available when accessing past versions.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
docs: adr-40: reduce multistore and make it atomic (#9355) * adr-40: use prefix store instead of multistore * add note about prefix.Store * Update SC and SS setup information and historical versions sepc * add note about key prefix optimization * rephrased the changes related to multistore * Apply suggestions from code review Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * design update * update merkle proofs * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * reword huffman compression paragraph * ADR-40: update on multi-store refactor and IBC proofs (#10191) * Update on multistore refactor and IBC proof * cleanup whitespace * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * revise for PR * add todo * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Robert Zaremba <robert@zaremba.ch> * review updates * add todo for protobuf message type compression * add link to a discussion * guarantee atomic commit with IBC workaround proposal * adding more links to references * Apply suggestions from code review Co-authored-by: Roy Crihfield <roy@manteia.ltd> * reword the module key compression part Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Roy Crihfield <roy@manteia.ltd>
2021-10-22 03:45:00 -07:00
To manage the active snapshots we will either use a DB _max number of snapshots_ option (if available), or we will remove DB snapshots in the `EndBlocker`. The latter option can be done efficiently by identifying snapshots with block height and calling a store function to remove past versions.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
#### Accessing old state versions
docs: adr-40: reduce multistore and make it atomic (#9355) * adr-40: use prefix store instead of multistore * add note about prefix.Store * Update SC and SS setup information and historical versions sepc * add note about key prefix optimization * rephrased the changes related to multistore * Apply suggestions from code review Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * design update * update merkle proofs * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * reword huffman compression paragraph * ADR-40: update on multi-store refactor and IBC proofs (#10191) * Update on multistore refactor and IBC proof * cleanup whitespace * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * revise for PR * add todo * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Robert Zaremba <robert@zaremba.ch> * review updates * add todo for protobuf message type compression * add link to a discussion * guarantee atomic commit with IBC workaround proposal * adding more links to references * Apply suggestions from code review Co-authored-by: Roy Crihfield <roy@manteia.ltd> * reword the module key compression part Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Roy Crihfield <roy@manteia.ltd>
2021-10-22 03:45:00 -07:00
One of the functional requirements is to access old state. This is done through `abci.RequestQuery` structure. The version is specified by a block height (so we query for an object by a key `K` at block height `H`). The number of old versions supported for `abci.RequestQuery` is configurable. Accessing an old state is done by using available snapshots.
`abci.RequestQuery` doesn't need old state of `SC` unless the `prove=true` parameter is set. The SMT merkle proof must be included in the `abci.ResponseQuery` only if both `SC` and `SS` have a snapshot for requested version.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
docs: adr-40: reduce multistore and make it atomic (#9355) * adr-40: use prefix store instead of multistore * add note about prefix.Store * Update SC and SS setup information and historical versions sepc * add note about key prefix optimization * rephrased the changes related to multistore * Apply suggestions from code review Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * design update * update merkle proofs * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * reword huffman compression paragraph * ADR-40: update on multi-store refactor and IBC proofs (#10191) * Update on multistore refactor and IBC proof * cleanup whitespace * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * revise for PR * add todo * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Robert Zaremba <robert@zaremba.ch> * review updates * add todo for protobuf message type compression * add link to a discussion * guarantee atomic commit with IBC workaround proposal * adding more links to references * Apply suggestions from code review Co-authored-by: Roy Crihfield <roy@manteia.ltd> * reword the module key compression part Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Roy Crihfield <roy@manteia.ltd>
2021-10-22 03:45:00 -07:00
Moreover, Cosmos SDK could provide a way to directly access a historical state. However, a state machine shouldn't do that - since the number of snapshots is configurable, it would lead to nondeterministic execution.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
We positively [validated](https://github.com/cosmos/cosmos-sdk/discussions/8297) a versioning and snapshot mechanism for querying old state with regards to the database we evaluated.
### State Proofs
For any object stored in State Store (SS), we have corresponding object in `SC`. A proof for object `V` identified by a key `K` is a branch of `SC`, where the path corresponds to the key `hash(K)`, and the leaf is `hash(K, V)`.
### Rollbacks
We need to be able to process transactions and roll-back state updates if a transaction fails. This can be done in the following way: during transaction processing, we keep all state change requests (writes) in a `CacheWrapper` abstraction (as it's done today). Once we finish the block processing, in the `Endblocker`, we commit a root store - at that time, all changes are written to the SMT and to the `SS` and a snapshot is created.
### Committing to an object without saving it
We identified use-cases, where modules will need to save an object commitment without storing an object itself. Sometimes clients are receiving complex objects, and they have no way to prove a correctness of that object without knowing the storage layout. For those use cases it would be easier to commit to the object without storing it directly.
docs: adr-40: reduce multistore and make it atomic (#9355) * adr-40: use prefix store instead of multistore * add note about prefix.Store * Update SC and SS setup information and historical versions sepc * add note about key prefix optimization * rephrased the changes related to multistore * Apply suggestions from code review Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * design update * update merkle proofs * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * reword huffman compression paragraph * ADR-40: update on multi-store refactor and IBC proofs (#10191) * Update on multistore refactor and IBC proof * cleanup whitespace * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * revise for PR * add todo * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Robert Zaremba <robert@zaremba.ch> * review updates * add todo for protobuf message type compression * add link to a discussion * guarantee atomic commit with IBC workaround proposal * adding more links to references * Apply suggestions from code review Co-authored-by: Roy Crihfield <roy@manteia.ltd> * reword the module key compression part Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Roy Crihfield <roy@manteia.ltd>
2021-10-22 03:45:00 -07:00
### Refactor MultiStore
The Stargate `/store` implementation (store/v1) adds an additional layer in the SDK store construction - the `MultiStore` structure. The multistore exists to support the modularity of the Cosmos SDK - each module is using its own instance of IAVL, but in the current implementation, all instances share the same database. The latter indicates, however, that the implementation doesn't provide true modularity. Instead it causes problems related to race condition and atomic DB commits (see: [\#6370](https://github.com/cosmos/cosmos-sdk/issues/6370) and [discussion](https://github.com/cosmos/cosmos-sdk/discussions/8297#discussioncomment-757043)).
We propose to reduce the multistore concept from the SDK, and to use a single instance of `SC` and `SS` in a `RootStore` object. To avoid confusion, we should rename the `MultiStore` interface to `RootStore`. The `RootStore` will have the following interface; the methods for configuring tracing and listeners are omitted for brevity.
```go
// Used where read-only access to versions is needed.
type BasicRootStore interface {
Store
GetKVStore(StoreKey) KVStore
CacheRootStore() CacheRootStore
}
// Used as the main app state, replacing CommitMultiStore.
type CommitRootStore interface {
BasicRootStore
Committer
Snapshotter
GetVersion(uint64) (BasicRootStore, error)
SetInitialVersion(uint64) error
... // Trace and Listen methods
}
// Replaces CacheMultiStore for branched state.
type CacheRootStore interface {
BasicRootStore
Write()
... // Trace and Listen methods
}
// Example of constructor parameters for the concrete type.
type RootStoreConfig struct {
Upgrades *StoreUpgrades
InitialVersion uint64
ReservePrefix(StoreKey, StoreType)
}
```
<!-- TODO: Review whether these types can be further reduced or simplified -->
<!-- TODO: RootStorePersistentCache type -->
In contrast to `MultiStore`, `RootStore` doesn't allow to dynamically mount sub-stores or provide an arbitrary backing DB for individual sub-stores.
NOTE: modules will be able to use a special commitment and their own DBs. For example: a module which will use ZK proofs for state can store and commit this proof in the `RootStore` (usually as a single record) and manage the specialized store privately or using the `SC` low level interface.
#### Compatibility support
To ease the transition to this new interface for users, we can create a shim which wraps a `CommitMultiStore` but provides a `CommitRootStore` interface, and expose functions to safely create and access the underlying `CommitMultiStore`.
The new `RootStore` and supporting types can be implemented in a `store/v2` package to avoid breaking existing code.
#### Merkle Proofs and IBC
Currently, an IBC (v1.0) Merkle proof path consists of two elements (`["<store-key>", "<record-key>"]`), with each key corresponding to a separate proof. These are each verified according to individual [ICS-23 specs](https://github.com/cosmos/ibc-go/blob/f7051429e1cf833a6f65d51e6c3df1609290a549/modules/core/23-commitment/types/merkle.go#L17), and the result hash of each step is used as the committed value of the next step, until a root commitment hash is obtained.
The root hash of the proof for `"<record-key>"` is hashed with the `"<store-key>"` to validate against the App Hash.
This is not compatible with the `RootStore`, which stores all records in a single Merkle tree structure, and won't produce separate proofs for the store- and record-key. Ideally, the store-key component of the proof could just be omitted, and updated to use a "no-op" spec, so only the record-key is used. However, because the IBC verification code hardcodes the `"ibc"` prefix and applies it to the SDK proof as a separate element of the proof path, this isn't possible without a breaking change. Breaking this behavior would severely impact the Cosmos ecosystem which already widely adopts the IBC module. Requesting an update of the IBC module across the chains is a time consuming effort and not easily feasible.
As a workaround, the `RootStore` will have to use two separate SMTs (they could use the same underlying DB): one for IBC state and one for everything else. A simple Merkle map that reference these SMTs will act as a Merkle Tree to create a final App hash. The Merkle map is not stored in a DBs - it's constructed in the runtime. The IBC substore key must be `"ibc"`.
The workaround can still guarantee atomic syncs: the [proposed DB backends](#evaluated-kv-databases) support atomic transactions and efficient rollbacks, which will be used in the commit phase.
The presented workaround can be used until the IBC module is fully upgraded to supports single-element commitment proofs.
### Optimization: compress module key prefixes
We consider a compression of prefix keys by creating a mapping from module key to an integer, and serializing the integer using varint coding. Varint coding assures that different values don't have common byte prefix. For Merkle Proofs we can't use prefix compression - so it should only apply for the `SS` keys. Moreover, the prefix compression should be only applied for the module namespace. More precisely:
style: lint go and markdown (#10060) ## Description + fixing `x/bank/migrations/v44.migrateDenomMetadata` - we could potentially put a wrong data in a new key if the old keys have variable length. + linting the code Putting in the same PR because i found the issue when running a linter. Depends on: #10112 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-10-30 06:43:04 -07:00
docs: adr-40: reduce multistore and make it atomic (#9355) * adr-40: use prefix store instead of multistore * add note about prefix.Store * Update SC and SS setup information and historical versions sepc * add note about key prefix optimization * rephrased the changes related to multistore * Apply suggestions from code review Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * design update * update merkle proofs * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * reword huffman compression paragraph * ADR-40: update on multi-store refactor and IBC proofs (#10191) * Update on multistore refactor and IBC proof * cleanup whitespace * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * revise for PR * add todo * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Robert Zaremba <robert@zaremba.ch> * review updates * add todo for protobuf message type compression * add link to a discussion * guarantee atomic commit with IBC workaround proposal * adding more links to references * Apply suggestions from code review Co-authored-by: Roy Crihfield <roy@manteia.ltd> * reword the module key compression part Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Roy Crihfield <roy@manteia.ltd>
2021-10-22 03:45:00 -07:00
+ each module has it's own namespace;
+ when accessing a module namespace we create a KVStore with embedded prefix;
+ that prefix will be compressed only when accessing and managing `SS`.
We need to assure that the codes won't change. We can fix the mapping in a static variable (provided by an app) or SS state under a special key.
TODO: need to make decision about the key compression.
## Optimization: SS key compression
Some objects may be saved with key, which contains a Protobuf message type. Such keys are long. We could save a lot of space if we can map Protobuf message types in varints.
TODO: finalize this or move to another ADR.
docs: ADR-40 Migration spec (#10891) ## Description Iterative update to the ADR-40 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-19 10:18:58 -08:00
## Migration
Using the new store will require a migration. 2 Migrations are proposed:
1. Genesis export -- it will reset the blockchain history.
2. In place migration: we can reuse `UpgradeKeeper.SetUpgradeHandler` to provide the migration logic:
```go
app.UpgradeKeeper.SetUpgradeHandler("adr-40", func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
storev2.Migrate(iavlstore, v2.store)
// RunMigrations returns the VersionMap
// with the updated module ConsensusVersions
return app.mm.RunMigrations(ctx, vm)
})
```
The `Migrate` function will read all entries from a store/v1 DB and save them to the AD-40 combined KV store.
Cache layer should not be used and the operation must finish with a single Commit call.
Inserting records to the `SC` (SMT) component is the bottleneck. Unfortunately SMT doesn't support batch transactions.
Adding batch transactions to `SC` layer is considered as a feature after the main release.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
## Consequences
### Backwards Compatibility
This ADR doesn't introduce any Cosmos SDK level API changes.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
We change the storage layout of the state machine, a storage hard fork and network upgrade is required to incorporate these changes. SMT provides a merkle proof functionality, however it is not compatible with ICS23. Updating the proofs for ICS23 compatibility is required.
### Positive
+ Decoupling state from state commitment introduce better engineering opportunities for further optimizations and better storage patterns.
+ Performance improvements.
docs: Update ADR-040 to store hash(value) in SMT leaf (#9680) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description This revises ADR-40 to specify storing `hash(value)` as the SMT mapped value. This should allow the same indexing functionality as using `hash(key + value)`, while working much better with IPLD by storing only the hash of the mapped content. Some discussion here: https://github.com/cosmos/cosmos-sdk/discussions/9331#discussioncomment-992325 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - N/A - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - N/A - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - N/A - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - N/A - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-09-15 04:42:27 -07:00
+ Joining SMT based camp which has wider and proven adoption than IAVL. Example projects which decided on SMT: Ethereum2, Diem (Libra), Trillan, Tezos, Celestia.
docs: adr-40: reduce multistore and make it atomic (#9355) * adr-40: use prefix store instead of multistore * add note about prefix.Store * Update SC and SS setup information and historical versions sepc * add note about key prefix optimization * rephrased the changes related to multistore * Apply suggestions from code review Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * design update * update merkle proofs * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * reword huffman compression paragraph * ADR-40: update on multi-store refactor and IBC proofs (#10191) * Update on multistore refactor and IBC proof * cleanup whitespace * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * revise for PR * add todo * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Robert Zaremba <robert@zaremba.ch> * review updates * add todo for protobuf message type compression * add link to a discussion * guarantee atomic commit with IBC workaround proposal * adding more links to references * Apply suggestions from code review Co-authored-by: Roy Crihfield <roy@manteia.ltd> * reword the module key compression part Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Roy Crihfield <roy@manteia.ltd>
2021-10-22 03:45:00 -07:00
+ Multistore removal fixes a longstanding issue with the current MultiStore design.
+ Simplifies merkle proofs - all modules, except IBC, have only one pass for merkle proof.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
### Negative
+ Storage migration
+ LL SMT doesn't support pruning - we will need to add and test that functionality.
docs: adr-40: reduce multistore and make it atomic (#9355) * adr-40: use prefix store instead of multistore * add note about prefix.Store * Update SC and SS setup information and historical versions sepc * add note about key prefix optimization * rephrased the changes related to multistore * Apply suggestions from code review Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * design update * update merkle proofs * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * reword huffman compression paragraph * ADR-40: update on multi-store refactor and IBC proofs (#10191) * Update on multistore refactor and IBC proof * cleanup whitespace * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * revise for PR * add todo * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Robert Zaremba <robert@zaremba.ch> * review updates * add todo for protobuf message type compression * add link to a discussion * guarantee atomic commit with IBC workaround proposal * adding more links to references * Apply suggestions from code review Co-authored-by: Roy Crihfield <roy@manteia.ltd> * reword the module key compression part Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Roy Crihfield <roy@manteia.ltd>
2021-10-22 03:45:00 -07:00
+ `SS` keys will have an overhead of a key prefix. This doesn't impact `SC` because all keys in `SC` have same size (they are hashed).
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
### Neutral
+ Deprecating IAVL, which is one of the core proposals of Cosmos Whitepaper.
## Alternative designs
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
Most of the alternative designs were evaluated in [state commitments and storage report](https://paper.dropbox.com/published/State-commitments-and-storage-review--BDvA1MLwRtOx55KRihJ5xxLbBw-KeEB7eOd11pNrZvVtqUgL3h).
Ethereum research published [Verkle Trie](https://dankradfeist.de/ethereum/2021/06/18/verkle-trie-for-eth1.html) - an idea of combining polynomial commitments with merkle tree in order to reduce the tree height. This concept has a very good potential, but we think it's too early to implement it. The current, SMT based design could be easily updated to the Verkle Trie once other research implement all necessary libraries. The main advantage of the design described in this ADR is the separation of state commitments from the data storage and designing a more powerful interface.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
## Further Discussions
### Evaluated KV Databases
We verified existing databases KV databases for evaluating snapshot support. The following databases provide efficient snapshot mechanism: Badger, RocksDB, [Pebble](https://github.com/cockroachdb/pebble). Databases which don't provide such support or are not production ready: boltdb, leveldb, goleveldb, membdb, lmdb.
### RDBMS
Use of RDBMS instead of simple KV store for state. Use of RDBMS will require a Cosmos SDK API breaking change (`KVStore` interface) and will allow better data extraction and indexing solutions. Instead of saving an object as a single blob of bytes, we could save it as record in a table in the state storage layer, and as a `hash(key, protobuf(object))` in the SMT as outlined above. To verify that an object registered in RDBMS is same as the one committed to SMT, one will need to load it from RDBMS, marshal using protobuf, hash and do SMT search.
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
### Off Chain Store
We were discussing use case where modules can use a support database, which is not automatically committed. Module will responsible for having a sound storage model and can optionally use the feature discussed in __Committing to an object without saving it_ section.
## References
+ [IAVL What's Next?](https://github.com/cosmos/cosmos-sdk/issues/7100)
+ [IAVL overview](https://docs.google.com/document/d/16Z_hW2rSAmoyMENO-RlAhQjAG3mSNKsQueMnKpmcBv0/edit#heading=h.yd2th7x3o1iv) of it's state v0.15
+ [State commitments and storage report](https://paper.dropbox.com/published/State-commitments-and-storage-review--BDvA1MLwRtOx55KRihJ5xxLbBw-KeEB7eOd11pNrZvVtqUgL3h)
docs: Update ADR-040 to store hash(value) in SMT leaf (#9680) <!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description This revises ADR-40 to specify storing `hash(value)` as the SMT mapped value. This should allow the same indexing functionality as using `hash(key + value)`, while working much better with IPLD by storing only the hash of the mapped content. Some discussion here: https://github.com/cosmos/cosmos-sdk/discussions/9331#discussioncomment-992325 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - N/A - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - N/A - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - N/A - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - N/A - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-09-15 04:42:27 -07:00
+ [Celestia (LazyLedger) SMT](https://github.com/lazyledger/smt)
ADR-040: Storage and SMT State Commitments (#8430) * ADR-040: Storage and SMT State Commitments * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * Added more details for snapshotting and pruning. * updated links and references * add blockchains which already use SMT * reorganize versioning and pruning * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> * adding a paragraph about state management * adr-40: update 'accessing old state' section * update based on all recent discussions and validations * adding more explanation about KV interface * Apply suggestions from code review Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> * Apply suggestions from code review Co-authored-by: Marko <marbar3778@yahoo.com> * review comments * adding paragraph about commiting to an object without storying it * review updates * Apply suggestions from code review Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com> * review udpates * adding clarification Co-authored-by: Ismail Khoffi <Ismail.Khoffi@gmail.com> Co-authored-by: Tomasz Zdybał <tomek@zdybal.lap.pl> Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Roy Crihfield <30845198+roysc@users.noreply.github.com>
2021-05-11 13:45:29 -07:00
+ Facebook Diem (Libra) SMT [design](https://developers.diem.com/papers/jellyfish-merkle-tree/2021-01-14.pdf)
+ [Trillian Revocation Transparency](https://github.com/google/trillian/blob/master/docs/papers/RevocationTransparency.pdf), [Trillian Verifiable Data Structures](https://github.com/google/trillian/blob/master/docs/papers/VerifiableDataStructures.pdf).
+ Design and implementation [discussion](https://github.com/cosmos/cosmos-sdk/discussions/8297).
docs: adr-40: reduce multistore and make it atomic (#9355) * adr-40: use prefix store instead of multistore * add note about prefix.Store * Update SC and SS setup information and historical versions sepc * add note about key prefix optimization * rephrased the changes related to multistore * Apply suggestions from code review Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * design update * update merkle proofs * Apply suggestions from code review Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * reword huffman compression paragraph * ADR-40: update on multi-store refactor and IBC proofs (#10191) * Update on multistore refactor and IBC proof * cleanup whitespace * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * revise for PR * add todo * Update docs/architecture/adr-040-storage-and-smt-state-commitments.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Robert Zaremba <robert@zaremba.ch> * review updates * add todo for protobuf message type compression * add link to a discussion * guarantee atomic commit with IBC workaround proposal * adding more links to references * Apply suggestions from code review Co-authored-by: Roy Crihfield <roy@manteia.ltd> * reword the module key compression part Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Roy Crihfield <roy@manteia.ltd>
2021-10-22 03:45:00 -07:00
+ [How to Upgrade IBC Chains and their Clients](https://github.com/cosmos/ibc-go/blob/main/docs/ibc/upgrades/quick-guide.md)
+ [ADR-40 Effect on IBC](https://github.com/cosmos/ibc-go/discussions/256)