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

tool: tree recovery #29

Merged
merged 4 commits into from
Aug 11, 2022
Merged

tool: tree recovery #29

merged 4 commits into from
Aug 11, 2022

Conversation

j75689
Copy link
Contributor

@j75689 j75689 commented Aug 5, 2022

Description

Due to the introduction of the persistent SparseMerkleTree structure and support for persisting data to local (leveldb) and remote storage spaces (kvrocks, redis), we need a repair tool that can repair data when stored data is lost unexpectedly.

Structure and Data

A total of four types of tree structures (account, asset, liquidty, nft) are required for system operation. Fortunately, the system will write the hash value to the account_history, nft_history, and liquidity_history table of RDB according to the block height .

we can pass the SQL statement. e.g.

SELECT a.* FROM account_history a WHERE NOT EXISTS
	(SELECT * FROM account_history WHERE account_index = a.account_index AND l2_block_height <= ? 
        AND  l2_block_height > a.l2_block_height AND l2_block_height != -1) 
AND l2_block_height <= ? AND l2_block_height != -1 ORDER BY account_index

Read out the hash value of the corresponding height and put it back into the tree structure to generate a tree of that height.

Program

  1. make a command line tool. e.g.
recovery -config ./... -height 2293 -service committer

Changes

  1. refactor the SQL with gorm builder.
  2. add a new tool for tree recovery.
  3. batch read history table.

@unclezoro unclezoro changed the title [WIP] tree recovery [WIP] tool: tree recovery Aug 5, 2022
@forcodedancing forcodedancing added the work in progress work in progress label Aug 5, 2022
@j75689 j75689 force-pushed the feat/recovery_tool branch from b38127a to c2660f0 Compare August 9, 2022 05:26
@j75689 j75689 force-pushed the feat/recovery_tool branch from f11c04f to 73994ae Compare August 9, 2022 09:30
@j75689 j75689 marked this pull request as ready for review August 9, 2022 09:31
@j75689 j75689 changed the title [WIP] tool: tree recovery [R4R] tool: tree recovery Aug 9, 2022
@j75689 j75689 added ready for review ready for review and removed work in progress work in progress labels Aug 9, 2022
@forcodedancing forcodedancing changed the title [R4R] tool: tree recovery tool: tree recovery Aug 9, 2022
@j75689 j75689 requested a review from forcodedancing August 10, 2022 08:50
@unclezoro unclezoro merged commit fd563cf into develop Aug 11, 2022
@unclezoro unclezoro deleted the feat/recovery_tool branch August 25, 2022 13:53
ruslangm pushed a commit to ruslangm/zkbnb that referenced this pull request Jan 26, 2023
Added support for native keccak256 impl for block commitment calculation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants