Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
bbcdbb02
Commit
bbcdbb02
authored
Oct 31, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move stuff, more readme, add back DenyStateTransition
parent
6e8f697f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
16 deletions
+20
-16
README.md
README.md
+1
-1
Challenge.sol
contracts/Challenge.sol
+15
-0
compile.py
mipigo/compile.py
+1
-0
README
mipsevm/README
+3
-15
mips_evm_test.go
mipsevm/mips_evm_test.go
+0
-0
No files found.
README.md
View file @
bbcdbb02
...
@@ -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/)
```
```
...
...
contracts/Challenge.sol
View file @
bbcdbb02
...
@@ -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);
}
}
}
mipigo/compile.py
View file @
bbcdbb02
...
@@ -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
*
...
...
mipsevm/README
View file @
bbcdbb02
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
mipsevm/mips_
run
_test.go
→
mipsevm/mips_
evm
_test.go
View file @
bbcdbb02
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment