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

Replace mtree_cwm with mtree_clone #762

Closed
3 tasks
Tracked by #7
grjte opened this issue Mar 8, 2023 · 1 comment
Closed
3 tasks
Tracked by #7

Replace mtree_cwm with mtree_clone #762

grjte opened this issue Mar 8, 2023 · 1 comment
Assignees

Comments

@grjte
Copy link
Contributor

grjte commented Mar 8, 2023

As discussed here in #750, SMT and MMR would be easier to support if we change the way that the AdviceProvider handles clone and update operations.

Currently we offer the copy with modify operation mtree_cwm, but we would like to remove this and add mtree_clone instead. Users who want to make an update in the AdviceProvider would instead then call mtree_clone followed by mtree_set.

The required changes as described by @bobbinth are as follows:

To support a separate clone operation, we need to add a new method to the AdviceProvider interface. Something like:

pub trait AdviceProvider {
    fn clone_merkle_set(&mut self, root: Word) -> Result<(), ExecutionError>;
}

In the implementation (e.g., MemAdviceProvider) this shouldn't be too difficult to support either - i.e., instead of using BTreeMap<[u8; 32], MerkleSet> we could use BTreeMap<[u8; 32], Vec<MerkleSet>> and then clone operation would add new item to the vector under the specified key.

  • add a new method to the advice provider
  • replace Assembly instruction mtree_cwm with mtree_clone
  • update the docs
@grjte
Copy link
Contributor Author

grjte commented Mar 9, 2023

With the implementation of MerkleStore this will no longer be necessary

@grjte grjte closed this as completed Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants