0xPolygonMiden / miden-vm

STARK-based virtual machine
MIT License
618 stars 156 forks source link

`mtree_get` should return only `V` (not the root as well) #1212

Closed plafer closed 7 months ago

plafer commented 7 months ago

mtree_get currently returns [VALUE, ROOT] on the stack. The root is unchanged from the operation, so there's no need to return it. If the user still wants the root, than it can dupw it before the call.

The current implementation results in the caller needing to add swapw dropw to drop the root in all cases where the root is already preserved elsewhere on the stack, such as this one, and in the new smt implementation.

plafer commented 7 months ago

This is not a good idea, because to return only V, mtree_get internally would need to essentially run a swapw dropw. It's better to let the user do it if needed (and leave it as is if not).