Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Add stateRoot when generating a block #6752

Closed
Tracked by #6749
shuse2 opened this issue Sep 8, 2021 · 0 comments
Closed
Tracked by #6749

Add stateRoot when generating a block #6752

shuse2 opened this issue Sep 8, 2021 · 0 comments

Comments

@shuse2
Copy link
Collaborator

shuse2 commented Sep 8, 2021

Description

State root must be calculated and add it to the block header.

  • Define sparse merkle tree database prefix in lisk-chain
  • Update sparse merkle tree leaf value to only contain leaf prefix to avoid duplicate data - Update Sparse Merkle Tree leaf value to be hashed #6900
  • Update state store finalize to update sparse merkle tree
  • Calculate state root at the end of block generation and add it to block header
  • Add verification of the state root against block header in consensus
  • Store SMT at the end of block execution
  • Add re-calculation of sparse merkle tree for deleting block

Acceptance Criteria

  • Add unit tests
  • Add integration test to show generation and execution produce the same stateRoot
  • Add integration test to show deletion of the block will revert the state root to the previous block

Additional Information

Related Issue #6749

  • sparse merkle tree should not be part of diff
  • sparse merkle tree should use the newly defined database prefix

for reverting, diff can be used like below.

for (const kv of updated) {
  await smt.update(kv.key, kv.value);
}
for (const kv of removed) {
  await smt.remove(kv.key, kv.value);
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants