TrueBitFoundation / dispute-resolution-layer

[DEPRECATED] Generic dispute resolution layer for Truebit verification games
MIT License
6 stars 10 forks source link

Simplify state #24

Closed juztamau5 closed 6 years ago

juztamau5 commented 6 years ago

Currently, the VM state is hard-coded to several words. This should be abstracted so the state can be fulfilled by a CAS hash someday. For now, bytes32 is generic enough.

bytes32 is big enough to store a sum, so the test case has been modified to encode the sum directly in the state. All other variables, like the instruction and step count, can be dropped from the state.

This fixes the off-by-one error in https://github.com/TrueBitFoundation/truebit-os/issues/7.

Before:

{
  "solution": "0x0000000000000000000000000000000000000000000000000000000000000024",
  "finalized": true,
  "data": [1,2,3,4,5,6,7,8,9]
}

After:

{
  "solution": "0x000000000000000000000000000000000000000000000000000000000000002d",
  "finalized": true,
  "data": [1,2,3,4,5,6,7,8,9]
}

Requires: https://github.com/TrueBitFoundation/truebit-os/pull/9

hswick commented 6 years ago

So I originally had thought about representing the state as a single bytes32 as you've done but realized that was an oversimplification, and distracted from the intent of the repo. Which is meant to educate how the VM behind Truebit works in a simplified form. The main idea for a VM is that it is a stack. The minimal VM needed to do interesting operations is 2 cells + program counter. The idea is that we should be able to reuse BasicVerificationGame for other computation layers, with possibly larger stacks. By representing the VM with a single value, you aren't really showing that there is a VM with memory cells, which is how the real Truebit VM works in webasm-solidity.

A more ideal implementation would address #18

juztamau5 commented 6 years ago

Superseded by https://github.com/TrueBitFoundation/dispute-resolution-layer/pull/25.