-
Notifications
You must be signed in to change notification settings - Fork 268
Add tmp trie store implementation in snapshot processor #3231
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
base: add-tmp-trie-store-in-rsk-context
Are you sure you want to change the base?
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
c8c3934 to
7699791
Compare
e8e272c to
9ebc2e3
Compare
|
f3fa8f1 to
c3bc1d2
Compare
fmacleal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
I just have a few comments and questions.
| private final TrieStore trieStore; | ||
| private final KeyValueDataSource tmpSnapSyncKeyValueDataSource; | ||
| public static final int TMP_NODES_SIZE_KEY = -1; | ||
| private static final int TMP_NODES_SIZE_KEY = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question:
why this value is -1? What is this value used for? Is it a seed? If it's a seed, wouldn't be better to be a random value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is where the size of the nodes are stored, since we are storing things in a key / value map, we don't have the size of the nodes and RocksDB might create other keys in it's inner workings. We want that size to iterate all the nodes in the map because the key is the index of the node as the nodes were in a list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if it's a key value map, why not have it set as a random final value instead of a fix -1? The key is fixed, if a new key clashes with this one, it would fail in RocksDB instead of overwrite no?
The -1 it's predictable, maybe it can easily be changed by someone trying to exploit this no?
If I understood, this is the key where you will store the size of all nodes saved, is it?
| } | ||
| nodes.get(0).setLeftHash(firstNodeLeftHash); | ||
|
|
||
| tmpSnapSyncKeyValueDataSource.put(ByteUtil.intToBytes(TMP_NODES_SIZE_KEY), ByteUtil.intToBytes(nodes.size() + existingNodesSize)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question:
What are you saving at this part? After you save all the tries you save the size of the nodes you have in the for plus the size of nodes you have saved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am storing the size of the nodes when every chunk arrives. Each chunk comes with a new list of nodes to be added, so we need to keep the size of the nodes up to date
rskj-core/src/main/java/co/rsk/trie/TrieDTOInOrderRecoverer.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/trie/TrieDTOInOrderRecoverer.java
Outdated
Show resolved
Hide resolved
a4e52ae to
b4cd299
Compare
43cc2e0 to
d683186
Compare
e1ad2bc to
3e440b6
Compare
d683186 to
fb36402
Compare
3e440b6 to
00738fb
Compare
fb36402 to
cff2a6a
Compare
00738fb to
4d43533
Compare
cff2a6a to
49de2c3
Compare
|





Description
Add tmp trie store implementation in snapshot processor
For validating if the trie structure is correct within the Temporary Datasource:
hashin the trie or the DB, then we can say the trie is invalid.When the validation is successful, we can move the content from the Temporary Datasource to the actual Trie Store. We need to make sure the temporary entries are deleted after data is moved.
Motivation and Context
Considering the snap sync protocol working theory, we will use a Temporary Trie Store to save the snap sync chunk messages and validate it. One we the validation succeeds , we can move all the data from the Temporary Datasource to the Actual Trie Store
In this PR we are adding the changes to store snap chunks in temporarydatasource and when the snap sync finishes we move it to the Actual Trie Store and clean the Temporary Datasource.
How Has This Been Tested?
Types of changes
Checklist: