-
Notifications
You must be signed in to change notification settings - Fork 36
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
feat(SMT): reverse mutations generation, mutations serialization #355
base: next
Are you sure you want to change the base?
Conversation
}, | ||
Addition(node) => { | ||
if let Some(old_node) = self.insert_inner_node(index, node) { | ||
reverse_mutations.insert(index, Addition(old_node)); |
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.
Here we rely on the computation of mutations set, that it didn't generate useless update where new value is the same as previous (actually it does generate unnecessary changes in mutations set). Otherwise we would need to clone node
and compare it with old_node
.
for (key, value) in new_pairs { | ||
self.insert_value(key, value); | ||
if let Some(old_value) = self.insert_value(key.clone(), value) { | ||
reverse_pairs.insert(key, old_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.
Here we also rely on the computation of mutations set, that it didn't generate useless update where new value is the same as previous (actually it does generate unnecessary changes in mutations set). Otherwise we would need to clone value
and compare it with old_value
.
Quality Gate passedIssues Measures |
Related to 0xPolygonMiden/miden-node#527
While refactoring account inclusion proofs in-memory storage, I realized that it's very hard to keep persistent state for additional "initial" structure, and it would be easier to keep only reverse mutation sets and the latest state. Thus, we need to store only reverse mutations set, but latest state we can still reconstruct from the database.
In this PR I implemented reverse mutations set generation on mutations applying. Also implemented serialization of mutations set.
The only concern I have is that now we produce reverse mutations set on each applying of mutations set. For the node it's fine, because we always need them after changing of the latest accounts SMT. But if someone else uses our SMT, it might be unnecessary to calculate such reversion on each mutations set applying.