You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// update tree root/length again, they aren't mutated :(
// TODO: this shows why the full tree should be the public output
tree.root=proof.publicOutput.root;
tree.length=proof.publicOutput.length;
I think it's ok that private proof inputs are not designed to be mutated - that's what return values are for.
So the solution for this issue will come once we enable zkprogram public outputs with auxiliary data. Then we can just return the entire merkle tree as output from the zkprogram, and it will have the updated content.
Thank you; this workaround works. I also got correct results by cloning the map, passing the cloned map to the ZkProgram, and repeating the same insert operation (that can be done with rawMethods to make sure that the code is the same) on the main map. But your workaround is much more efficient.
@mitschabaude
According to https://github.com/o1-labs/o1js/blob/main/src/lib/provable/merkle-tree-indexed.ts#L41, we can pass MerkleMap directly to the ZkProgram method. Doing so works correctly when used with
rawMethods
(without proof calculation) but does not update the root and length of the Indexed MerkleMap when used with proofs.The code to reproduce the issue:
The log:
The text was updated successfully, but these errors were encountered: