Commit bbcdbb02 authored by George Hotz's avatar George Hotz

move stuff, more readme, add back DenyStateTransition

parent 6e8f697f
...@@ -16,7 +16,7 @@ It's half geth, half of what I think truebit was supposed to be. When it's done, ...@@ -16,7 +16,7 @@ It's half geth, half of what I think truebit was supposed to be. When it's done,
``` ```
minigeth -- A standalone "geth" capable of computing a block transition minigeth -- A standalone "geth" capable of computing a block transition
mipigo -- minigeth compiled for MIPS. Outputs a binary that's run and mapped at 0x0 mipigo -- minigeth compiled for MIPS. Outputs a MIPS binary that's run and mapped at 0x0
mipsevm -- A MIPS runtime in the EVM (see also contracts/) mipsevm -- A MIPS runtime in the EVM (see also contracts/)
``` ```
......
...@@ -164,4 +164,19 @@ contract Challenge { ...@@ -164,4 +164,19 @@ contract Challenge {
emit ChallengerWins(challengeId); emit ChallengerWins(challengeId);
} }
function DenyStateTransition(uint256 challengeId, bytes32 finalRiscState) external {
Chal storage c = challenges[challengeId];
require(c.challenger != address(0), "invalid challenge");
require(owner == msg.sender, "must be owner");
require(c.L + 1 == c.R, "binary search not finished");
// it's 0 if you agree with all attacker states except the final one
// in which case, you get a free pass to submit now
require(c.defendedState[c.R] == finalRiscState || c.defendedState[c.R] == bytes32(0), "must be consistent with state");
require(mips.Step(c.defendedState[c.L]) == finalRiscState, "wrong asserted state");
// consider the challenger mocked
emit ChallengerLoses(challengeId);
}
} }
...@@ -5,6 +5,7 @@ import struct ...@@ -5,6 +5,7 @@ import struct
from rangetree import RangeTree from rangetree import RangeTree
from elftools.elf.elffile import ELFFile from elftools.elf.elffile import ELFFile
# TODO: refactor this to not use unicorn
from unicorn import * from unicorn import *
from unicorn.mips_const import * from unicorn.mips_const import *
......
Running MIPS processor on chain Running MIPS processor on chain
We considered using
https://github.com/cartesi/machine-solidity-step
but it's around 5000 lines!
* We don't have any virtual memory
* We don't support any CSRs
* MIPS is two files, MIPS + MIPSMemory
cartesi also has a second version of the emulator in Rust. we use the EVM one in both places
Tests from https://github.com/grantae/OpenMIPS/tree/master/software/test/macro/tests Tests from https://github.com/grantae/OpenMIPS/tree/master/software/test/macro/tests
Licensed GPLv3 Licensed GPLv3
...@@ -24,9 +14,7 @@ Instruction set used by minigeth, 55 instructions: ...@@ -24,9 +14,7 @@ Instruction set used by minigeth, 55 instructions:
'sb', 'sll', 'sllv', 'slt', 'slti', 'sltiu', 'sltu', 'sra', 'srl', 'srlv', 'subu', 'sw', 'swr', 'sync', 'syscall', 'sb', 'sll', 'sllv', 'slt', 'slti', 'sltiu', 'sltu', 'sra', 'srl', 'srlv', 'subu', 'sw', 'swr', 'sync', 'syscall',
'xor', 'xori'] 'xor', 'xori']
STEPS=100000000 ./evm.sh unicorn ../mipigo/minigeth.bin There's three ways to run the embedded MIPS engine, see "run_<type>":
There's three ways to run this, see "run_<type>":
* unicorn -- fastest, uses none of the solidity * unicorn -- fastest, uses none of the solidity
* evm -- uses MIPS.sol, but stubs MIPSMemory.sol and doesn't compute the merkle trie * evm -- uses MIPS.sol, but stubs MIPSMemory.sol to SLOAD/SSTORE and doesn't compute the merkle trie
* chain -- uses MIPS.sol + MIPSMemory.sol, will actually run on chain like this * chain -- uses MIPS.sol + MIPSMemory.sol, slowest, will actually run on chain like this
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment