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
d0dcb828
Unverified
Commit
d0dcb828
authored
May 01, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mipsevm: update readme, expose PatchVM function
parent
a0c650e8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
22 deletions
+29
-22
README
mipsevm/README
+0
-17
README.md
mipsevm/README.md
+24
-0
evm_test.go
mipsevm/evm_test.go
+2
-2
patch.go
mipsevm/patch.go
+1
-1
state_test.go
mipsevm/state_test.go
+2
-2
No files found.
mipsevm/README
deleted
100644 → 0
View file @
a0c650e8
Running MIPS processor on chain
Instruction set used by minigeth, 55 instructions:
['addi', 'addiu', 'addu', 'and', 'andi',
'b', 'beq', 'beqz', 'bgez', 'bgtz', 'blez', 'bltz', 'bne', 'bnez',
'clz', 'divu',
'j', 'jal', 'jalr', 'jr',
'lb', 'lbu', 'lui', 'lw', 'lwr',
'mfhi', 'mflo', 'move', 'movn', 'movz', 'mtlo', 'mul', 'multu',
'negu', 'nop', 'not', 'or', 'ori',
'sb', 'sll', 'sllv', 'slt', 'slti', 'sltiu', 'sltu', 'sra', 'srl', 'srlv', 'subu', 'sw', 'swr', 'sync', 'syscall',
'xor', 'xori']
There's three ways to run the embedded MIPS engine, see "run_<type>":
* unicorn -- fastest, uses none of the solidity
* evm -- uses MIPS.sol, but stubs MIPSMemory.sol to SLOAD/SSTORE and doesn't compute the merkle trie
* chain -- uses MIPS.sol + MIPSMemory.sol, slowest, will actually run on chain like this
mipsevm/README.md
0 → 100644
View file @
d0dcb828
# `mipsevm`
Supported 55 instructions:
```
'addi', 'addiu', 'addu', 'and', 'andi',
'b', 'beq', 'beqz', 'bgez', 'bgtz', 'blez', 'bltz', 'bne', 'bnez',
'clz', 'divu',
'j', 'jal', 'jalr', 'jr',
'lb', 'lbu', 'lui', 'lw', 'lwr',
'mfhi', 'mflo', 'move', 'movn', 'movz', 'mtlo', 'mul', 'multu',
'negu', 'nop', 'not', 'or', 'ori',
'sb', 'sll', 'sllv', 'slt', 'slti', 'sltiu', 'sltu', 'sra', 'srl', 'srlv', 'subu', 'sw', 'swr', 'sync', 'syscall',
'xor', 'xori'
```
To run:
1.
Load a program into a state, e.g. using
`LoadELF`
.
2.
Patch the program if necessary: e.g. using
`PatchVM`
for Go programs.
3.
Load the state into a MIPS-32 configured unicorn instance, using
`NewUnicorn`
,
`LoadUnicorn`
4.
Implement the
`PreimageOracle`
interface
5.
Instrument the emulator with the state, and pre-image oracle, using
`NewUnicornState`
6.
Step through the instrumented state with
`Step(proof)`
,
where
`proof==true`
if witness data should be generated. Steps are faster with
`proof==false`
.
7.
Optionally repeat the step on-chain by calling
`MIPS.sol`
and
`Oracle.sol`
, using the above witness data.
mipsevm/evm_test.go
View file @
d0dcb828
...
...
@@ -128,7 +128,7 @@ func TestHelloEVM(t *testing.T) {
state
,
err
:=
LoadELF
(
elfProgram
)
require
.
NoError
(
t
,
err
,
"load ELF into state"
)
err
=
p
atchVM
(
elfProgram
,
state
)
err
=
P
atchVM
(
elfProgram
,
state
)
require
.
NoError
(
t
,
err
,
"apply Go runtime patches"
)
mu
,
err
:=
NewUnicorn
()
...
...
@@ -199,7 +199,7 @@ func TestClaimEVM(t *testing.T) {
state
,
err
:=
LoadELF
(
elfProgram
)
require
.
NoError
(
t
,
err
,
"load ELF into state"
)
err
=
p
atchVM
(
elfProgram
,
state
)
err
=
P
atchVM
(
elfProgram
,
state
)
require
.
NoError
(
t
,
err
,
"apply Go runtime patches"
)
mu
,
err
:=
NewUnicorn
()
...
...
mipsevm/patch.go
View file @
d0dcb828
...
...
@@ -51,7 +51,7 @@ func LoadELF(f *elf.File) (*State, error) {
return
s
,
nil
}
func
p
atchVM
(
f
*
elf
.
File
,
st
*
State
)
error
{
func
P
atchVM
(
f
*
elf
.
File
,
st
*
State
)
error
{
symbols
,
err
:=
f
.
Symbols
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to read symbols data, cannot patch program: %w"
,
err
)
...
...
mipsevm/state_test.go
View file @
d0dcb828
...
...
@@ -92,7 +92,7 @@ func TestHello(t *testing.T) {
state
,
err
:=
LoadELF
(
elfProgram
)
require
.
NoError
(
t
,
err
,
"load ELF into state"
)
err
=
p
atchVM
(
elfProgram
,
state
)
err
=
P
atchVM
(
elfProgram
,
state
)
require
.
NoError
(
t
,
err
,
"apply Go runtime patches"
)
mu
,
err
:=
NewUnicorn
()
...
...
@@ -194,7 +194,7 @@ func TestClaim(t *testing.T) {
state
,
err
:=
LoadELF
(
elfProgram
)
require
.
NoError
(
t
,
err
,
"load ELF into state"
)
err
=
p
atchVM
(
elfProgram
,
state
)
err
=
P
atchVM
(
elfProgram
,
state
)
require
.
NoError
(
t
,
err
,
"apply Go runtime patches"
)
mu
,
err
:=
NewUnicorn
()
...
...
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