Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced state implementation #7

Open
dabasov opened this issue Sep 11, 2019 · 0 comments
Open

Advanced state implementation #7

dabasov opened this issue Sep 11, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@dabasov
Copy link
Collaborator

dabasov commented Sep 11, 2019

1. Use sparse merkle tree as state storage instead of patricia merkle trie used now.
SMT described here https://eprint.iacr.org/2016/683.pdf has several benefits with regard to proof size and usage:

  • use log(n)*hash_size bytes for proof
  • easy leaf absence proof
  • simple map based implementation

Implementation details:

  • SMT is binary tree which is full and has predefined slots for all possible leafs, it means that it has 2^n leafs and 2^n(2^n - 1) nodes.
  • Leafs are indexed sequentially with integers from 0 to 2^n - 1.
  • Not leaf nodes contain hashes of it's siblings keccak256(append(left.value, right.value))
  • Nodes are indexed with two integers which determine it's subtree: minor - leftmost leaf, major - leftmost leaf of its right sibling
  • empty not leaf node has []byte{0} as it's hash when needed for hash calculation

2. Implement true snapshot state management.

  • state tree repeats blockchain structure
  • for each block only needed accounts are stored
  • from newest to oldest block lookup for accounts is implemented
@dabasov dabasov self-assigned this Sep 11, 2019
@dabasov dabasov added the enhancement New feature or request label Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant