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
EN-8343-optimize-trie-sync #2517
Conversation
@@ -100,11 +100,6 @@ func (ts *trieSyncer) StartSyncing(rootHash []byte, ctx context.Context) error { | |||
|
|||
numUnResolved := ts.requestNodes() | |||
if !shouldRetryAfterRequest && numUnResolved == 0 { | |||
err = ts.trie.Commit() |
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.
why delete this ? isn't it better to have the final commit done ?
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.
If we commit here, the whole trie will be loaded again from storage. The current approach is to commit each node as it is synced.
} | ||
|
||
ts.trie.root = collapsedRoot | ||
ts.rootFound = true |
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.
so we set root only after finding all its childs ?
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.
Yes, it should have no impact upon the functioning of the algorithm.
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.
System tests passed.
Instead of keeping the whole trie in memory during the syncing process, and Commit() the trie when it is fully synced, only keep the collapsed root and commit each node individually as it is synced.