0xPolygonMiden / miden-vm

STARK-based virtual machine
MIT License
611 stars 148 forks source link

Block hash table: don't iterate over entire trace to find `HALT` #1344

Open plafer opened 1 month ago

plafer commented 1 month ago

_Originally posted by @bobbinth in https://github.com/0xPolygonMiden/miden-vm/pull/1333#discussion_r1617769942_

Probably not for this PR, but I wonder how expensive this .find() is. Basically, we need to iterate through the whole trace to find the first HALT row.

One alternative to this is to get the program hash from the last row (excluding the random rows at the end). This should be possible because because the semantics of HALT are such that it copies over the entire state of the VM (including the decoder registers) to the next cycle. So, program hash should be the same in the last row as in the first HALT row.