Skip to content

Advanced state implementation  #7

@dabasov

Description

@dabasov

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions