cartesi/machine-emulator

Alternative ways to compute a machine's state hash

diegonehab opened this issue · 0 comments

Context

We need to make sure the machine Merkle tree implementation works correctly and indeed captures the entire state of the machine. It is therefore important that we be able to reproduce the root hash without using the code in the machine itself.

Possible solutions

At least two ways of doing this would be useful.

We should be able to, using the machine interface, iterate over the contents of the machine and externally compute the state hash. This would be useful in tests.

We should be able to, without instantiating a machine, and iterating over the contents of a machine config, compute the state hash. This would be useful to check integrity of a stored machine directory.

Subtasks

  • Ensure the machine API exposes enough information to allow the external computation of the state hash
  • Implement a function that computes the state hash given a machine instance
  • Implement a function that computes the state hash given a machine config