Description

Contributors

Work Started

Work Submitted

Work Paid

All Activity

Funder

Funder :

Email :

SolEVM-Enforcer Verifier

leapdao

JavaScript, Solidity, Shell

### Current description:
![](https://camo.githubusercontent.com/b6ff007723eef1757f8f7470c24c9c8c40b31813/68747470733a2f2f692e696d6775722e636f6d2f6f3146524d71702e706e67)
### In detail:
```
struct ExecutionState {
bytes32 hash,
uint step
}
struct ComputationPath {
bytes32 merkleRoot;
uint stepCount;
}
struct Dispute {
address solver;
address challenger;
ComputationPath solverComputationHashRoot;
ComputationPath challengerComputationHashRoot;
ExecutionState left; // state which both solver and challenger agree on
ExecutionState right; // state which solver and challenger disagree on, stores solver's hash
ExecutionState mid;
uint requiredStep;
uint timeout;
bool foundDiff;
bool success;
}
Dispute[] disputes;
uint timeoutDuration; // in second, or number of blocks
```
- `public initGame(executionId, solverComputationPath, challengerComputationPath, solver, challenger)`: called by Enforcer, when a **challenger** calls dispute. The Verifier will emit an event `DisputeStart(disputeId, requiredStep)` and set up a timeout. Before this timeout, the **solver** is required to submit a respond through the `respond` method, then the timeout is reset and the **challenger** is required to submit a respond. This proceed will repeat until the responds of the **solver** and **challenger** are different.
- `public respond(disputeId, execState, merkleProof)`: called by the **solver** or the **challenger**. `execState` is supposed to be the `ExecutionState` of the currently required step. The Verifier will check merkle proof of execState and put it to `prev` or `next` depends on the logic of binary search. If either the **solver** or the **challenger** fail to submit a valid state (timeout or submit invalid state), the other is considered correct. This procedure is repeated until found `left.step + 1 == right.step`. `foundDiff` will be set to `true`.
- `public detailEVMState(disputeId, compactedStack, stackSiblingHash, compactedMemory, memoryProof, ...and other parameters as in EthereumRuntime#execute)`: called by the **solver** after `foundDiff`. The Verifier will:
- Check that the hash of submitted data is the same as `left.hash`.
- Call `EthereumRuntime#executeStep`.
- Check that the hash of result is the same as `right.hash`.
If the process successes, **solver** is correct. Otherwise, **challenger** is correct. The Verifier will record the result and submit it to `Enforcer`.
Let's me hear your opinions :smile:
@johannbarbie @troggy @sunify