cartesi / machine-emulator

The off-chain implementation of the Cartesi Machine
GNU Lesser General Public License v3.0
64 stars 33 forks source link

Support inspect/advance in cartesi machine cli without explicitly spawning remote cartesi machines #206

Closed edubart closed 5 months ago

edubart commented 6 months ago

Context

Currently if you want to load a machine + advance states or inspect states its state once + store the machine, you always need to spawn a jsonrpc-remote-cartesi-machine beforehand, this make it's usability a bit more complex, we could improve this.

Possible solutions

There are some possible solutions for this:

  1. cartesi-machine could spawn jsonrpc-remote-cartesi-machine on its own and close it, abstracting away the need for the user to explicitly invoke jsonrpc-remote-cartesi-machine
  2. We could allow the cartesi-machine cli to work in a "single shot" mode, where it can only do one advance/inspect state and then close immediately because there is no support for rollback the state. This would need many adjustments and checks in the cartesi-machine.lua.
  3. Local machines could support snapshot/rollback, to have this we could implement a dumb fork() method that duplicates the whole machine state. This would make remote cartesi machines not needed to use the cli in most situations. In the future this fork could be improved to maybe be more performant. I am in favor of doing this way, because it would also allow cloning machines in environments where network stack is not available (e.g. WASM).