Open dfstio opened 1 month ago
Yes I'm aware of this, had the same problem in the offchain state implementation (this also shows a workaround) https://github.com/o1-labs/o1js/blob/72a2779c6728e80e0c9d1462020347c954a0ffb5/src/lib/mina/actions/offchain-state-rollup.ts#L287-L292
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: