0xPolygonMiden / miden-vm

STARK-based virtual machine
MIT License
615 stars 152 forks source link

MAST deserialization: don't recompute all node hashes #1391

Closed plafer closed 3 days ago

plafer commented 1 month ago

_Originally posted by @bobbinth in https://github.com/0xPolygonMiden/miden-vm/pull/1370#discussion_r1674688727_ and https://github.com/0xPolygonMiden/miden-vm/pull/1370#discussion_r1674689715

This is fine for now, but ideally, we should use a different set of constructors to build MastNode structs to avoid the cost of computing digests of these nodes (also relevant for all other constructors in this function).

This goes back to having two serialization formats: (1) fast trusted format and (2) compact untrusted format. What we are implementing in this PR is the "fast trusted" format and so we can assume that the serialization was done correctly and save on re-computing hashes which were computed during serialization (this could be very significant).

Let's create an issue to make sure we come back and update this later.

sergerad commented 1 week ago

I can pick this up after I wrap up my current PR

bobbinth commented 1 week ago

That would be awesome! I think one thing would be great to add as a part of this work is some benchmarks for how long it takes to deserialize standard library. This way, we'd be able to see the improvement between the current state and the improved state.

bobbinth commented 3 days ago

Closed by #1453.