Comments (4)
One possible design is to have the target position of the element on stack and the Merkle tree root:
Stack: [el_pos, tree_root ...]
And the decorator would push the leaf position to the advice stack.
The Advantage of the above is that a single decorator supports not only the first/last position, but also arbitrary values in-between. The disadvantage is that to get the position of the last element either the number of elements must be known, or a magic value needs to be used.
from miden-vm.
I'd probably go for the simpler approach for now as figuring out the correct position will be quite complicating, I think.
A couple things to clarify:
- We probably want to return both the index and the depth as zero nodes could theoretically be located at different depths in different parts of the tree.
- What should we return if there are no zero nodes in the tree?
from miden-vm.
correct position will be quite complicating, I think
It should be easy:
container.inner_nodes().filter(|n| n.is_leaf()).nth(index)
The complexity is basically O(n)
where n
is the number of leaves.
What should we return if there are no zero nodes in the tree?
Undefined? We can easily check if the tree is empty by looking at the root value.
from miden-vm.
It should be easy:
container.inner_nodes().filter(|n| n.is_leaf()).nth(index)
Not sure this will work as in the MerkleStore
the order of nodes is not defined.
What should we return if there are no zero nodes in the tree?
Undefined? We can easily check if the tree is empty by looking at the root value.
Comparing against empty tree root in MASM would require comparing words. I think we we return a well-defined value for empty trees we can make it more efficient (i.e., need to compare only single element).
Assuming, this decorator puts (depth, index)
on the top of advice stack, we could say that (0, 0)
means that the tree is empty. Or maybe just returning depth=0
is good enough.
from miden-vm.
Related Issues (20)
- Hexadecimal literals in constants are not supported HOT 1
- Add `on_assert_failed()` method to the `Host` trait HOT 1
- Consider adding tracing to the `Host` interface HOT 1
- Implement more optimized version of `u32lt` HOT 1
- Create newtype wrapper for advice map
- `ExecutionTrace.main_trace`: change type to `MainTrace`
- `AuxColumnBuilder`: consider using a `BTreeMap` for requests HOT 3
- Investigate faster polynomial evaluation in Falcon DSA HOT 1
- docs.rs build is failling because of stdlib masl compilation HOT 7
- Add infrastructure to isolate the contents of the Advice Provider based on the call context.
- `mtree_get` should return only `V` (not the root as well) HOT 1
- Rewrite MAST to use structure-of-arrays/table-based representation HOT 6
- `stdlib smt`: add support for leaves with multiple key/value pairs
- Remove `smt64` from `stdlib` HOT 1
- Implement`adv.push_smtset` and `adv.push_smtget`
- Allow the removal of entries from advice map
- Handle extra memory requests made by new `RCombBase` op HOT 1
- `debug.stack` decorator is broken HOT 1
- Implement extensible subsystem for on-demand storage/provisioning of MAST objects HOT 7
- Test to ensure that `RCOMBBASE` instruction can be executed and proven HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miden-vm.