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
635af73a
Unverified
Commit
635af73a
authored
Dec 07, 2021
by
George Hotz
Committed by
GitHub
Dec 07, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #36 from geohot/oracletest
oracle test
parents
b825df28
ac06c5ed
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
81 additions
and
6 deletions
+81
-6
README
mipsevm/README
+1
-0
minievm.go
mipsevm/minievm.go
+6
-2
mips_evm_test.go
mipsevm/mips_evm_test.go
+1
-1
run_unicorn.go
mipsevm/run_unicorn.go
+7
-3
oracle.bin
mipsevm/test/bin/oracle.bin
+0
-0
oracle.asm
mipsevm/test/oracle.asm
+65
-0
0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad
...5a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad
+1
-0
No files found.
mipsevm/README
View file @
635af73a
...
@@ -2,6 +2,7 @@ Running MIPS processor on chain
...
@@ -2,6 +2,7 @@ Running MIPS processor on chain
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
Requires https://github.com/sergev/LiteBSD/releases/download/tools/gcc-4.8.1-mips-macosx.tgz to build
Instruction set used by minigeth, 55 instructions:
Instruction set used by minigeth, 55 instructions:
['addi', 'addiu', 'addu', 'and', 'andi',
['addi', 'addiu', 'addu', 'and', 'andi',
...
...
mipsevm/minievm.go
View file @
635af73a
...
@@ -127,11 +127,15 @@ func (s *StateDB) GetState(fakeaddr common.Address, hash common.Hash) common.Has
...
@@ -127,11 +127,15 @@ func (s *StateDB) GetState(fakeaddr common.Address, hash common.Hash) common.Has
binary
.
BigEndian
.
PutUint32
(
oracle_hash
[
i
:
i
+
4
],
ram
[
0x30001000
+
i
])
binary
.
BigEndian
.
PutUint32
(
oracle_hash
[
i
:
i
+
4
],
ram
[
0x30001000
+
i
])
}
}
hash
:=
common
.
BytesToHash
(
oracle_hash
)
hash
:=
common
.
BytesToHash
(
oracle_hash
)
if
s
.
root
==
""
{
if
s
.
root
==
""
{
log
.
Fatal
(
"need root if using
hash oracle"
)
log
.
Fatal
(
"need root if using
oracle for "
,
hash
)
}
}
key
:=
fmt
.
Sprintf
(
"%s/%s"
,
s
.
root
,
hash
)
key
:=
fmt
.
Sprintf
(
"%s/%s"
,
s
.
root
,
hash
)
value
,
_
:=
ioutil
.
ReadFile
(
key
)
value
,
err
:=
ioutil
.
ReadFile
(
key
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
WriteRam
(
ram
,
0x31000000
,
uint32
(
len
(
value
)))
WriteRam
(
ram
,
0x31000000
,
uint32
(
len
(
value
)))
value
=
append
(
value
,
0
,
0
,
0
)
value
=
append
(
value
,
0
,
0
,
0
)
...
...
mipsevm/mips_evm_test.go
View file @
635af73a
...
@@ -27,7 +27,7 @@ func TestSimpleEVM(t *testing.T) {
...
@@ -27,7 +27,7 @@ func TestSimpleEVM(t *testing.T) {
LoadMappedFile
(
fn
,
ram
,
0
)
LoadMappedFile
(
fn
,
ram
,
0
)
start
:=
time
.
Now
()
start
:=
time
.
Now
()
remainingGas
,
err
:=
RunWithRam
(
ram
,
100
,
0
,
""
,
nil
)
remainingGas
,
err
:=
RunWithRam
(
ram
,
100
,
0
,
"
testoracle/
"
,
nil
)
elapsed
:=
time
.
Now
()
.
Sub
(
start
)
elapsed
:=
time
.
Now
()
.
Sub
(
start
)
fmt
.
Println
(
err
,
remainingGas
,
elapsed
,
fmt
.
Println
(
err
,
remainingGas
,
elapsed
,
...
...
mipsevm/run_unicorn.go
View file @
635af73a
...
@@ -83,7 +83,8 @@ func GetHookedUnicorn(root string, ram map[uint32](uint32), callback func(int, u
...
@@ -83,7 +83,8 @@ func GetHookedUnicorn(root string, ram map[uint32](uint32), callback func(int, u
oracle_hash
,
_
:=
mu
.
MemRead
(
0x30001000
,
0x20
)
oracle_hash
,
_
:=
mu
.
MemRead
(
0x30001000
,
0x20
)
hash
:=
common
.
BytesToHash
(
oracle_hash
)
hash
:=
common
.
BytesToHash
(
oracle_hash
)
key
:=
fmt
.
Sprintf
(
"%s/%s"
,
root
,
hash
)
key
:=
fmt
.
Sprintf
(
"%s/%s"
,
root
,
hash
)
value
,
_
:=
ioutil
.
ReadFile
(
key
)
value
,
err
:=
ioutil
.
ReadFile
(
key
)
check
(
err
)
tmp
:=
[]
byte
{
0
,
0
,
0
,
0
}
tmp
:=
[]
byte
{
0
,
0
,
0
,
0
}
binary
.
BigEndian
.
PutUint32
(
tmp
,
uint32
(
len
(
value
)))
binary
.
BigEndian
.
PutUint32
(
tmp
,
uint32
(
len
(
value
)))
...
@@ -179,7 +180,9 @@ func RunUnicorn(fn string, ram map[uint32](uint32), checkIO bool, callback func(
...
@@ -179,7 +180,9 @@ func RunUnicorn(fn string, ram map[uint32](uint32), checkIO bool, callback func(
mu
.
MemWrite
(
0
,
dat
)
mu
.
MemWrite
(
0
,
dat
)
// inputs
// inputs
inputs
,
_
:=
ioutil
.
ReadFile
(
fmt
.
Sprintf
(
"%s/input"
,
root
))
inputs
,
err
:=
ioutil
.
ReadFile
(
fmt
.
Sprintf
(
"%s/input"
,
root
))
check
(
err
)
mu
.
MemWrite
(
0x30000000
,
inputs
[
0
:
0xc0
])
mu
.
MemWrite
(
0x30000000
,
inputs
[
0
:
0xc0
])
// load into ram
// load into ram
...
@@ -191,7 +194,8 @@ func RunUnicorn(fn string, ram map[uint32](uint32), checkIO bool, callback func(
...
@@ -191,7 +194,8 @@ func RunUnicorn(fn string, ram map[uint32](uint32), checkIO bool, callback func(
mu
.
Start
(
0
,
0x5ead0004
)
mu
.
Start
(
0
,
0x5ead0004
)
if
checkIO
{
if
checkIO
{
outputs
,
_
:=
ioutil
.
ReadFile
(
fmt
.
Sprintf
(
"%s/output"
,
root
))
outputs
,
err
:=
ioutil
.
ReadFile
(
fmt
.
Sprintf
(
"%s/output"
,
root
))
check
(
err
)
real
:=
append
([]
byte
{
0x13
,
0x37
,
0xf0
,
0x0d
},
outputs
...
)
real
:=
append
([]
byte
{
0x13
,
0x37
,
0xf0
,
0x0d
},
outputs
...
)
output
,
_
:=
mu
.
MemRead
(
0x30000800
,
0x44
)
output
,
_
:=
mu
.
MemRead
(
0x30000800
,
0x44
)
if
bytes
.
Compare
(
real
,
output
)
!=
0
{
if
bytes
.
Compare
(
real
,
output
)
!=
0
{
...
...
mipsevm/test/bin/oracle.bin
0 → 100644
View file @
635af73a
File added
mipsevm/test/oracle.asm
0 → 100644
View file @
635af73a
.
section
.
test
,
"x"
.
balign
4
.
set
noreorder
.
global
test
.
ent
test
#
load
hash
at
0x30001000
#
0x47173285
a8d7341e
5
e972fc6
77286384
f802f8ef
42
a5ec5f
03
bbfa25
4
cb01fad
=
"hello world"
test
:
lui
$
s0
,
0x3000
ori
$
s0
,
0x1000
lui
$
t0
,
0x4717
ori
$
t0
,
0x3285
sw
$
t0
,
0
(
$
s0
)
lui
$
t0
,
0xa8d7
ori
$
t0
,
0x341e
sw
$
t0
,
4
(
$
s0
)
lui
$
t0
,
0x5e97
ori
$
t0
,
0x2fc6
sw
$
t0
,
8
(
$
s0
)
lui
$
t0
,
0x7728
ori
$
t0
,
0x6384
sw
$
t0
,
0xc
(
$
s0
)
lui
$
t0
,
0xf802
ori
$
t0
,
0xf8ef
sw
$
t0
,
0x10
(
$
s0
)
lui
$
t0
,
0x42a5
ori
$
t0
,
0xec5f
sw
$
t0
,
0x14
(
$
s0
)
lui
$
t0
,
0x03bb
ori
$
t0
,
0xfa25
sw
$
t0
,
0x18
(
$
s0
)
lui
$
t0
,
0x4cb0
ori
$
t0
,
0x1fad
sw
$
t0
,
0x1c
(
$
s0
)
#
syscall
4020
to
trigger
li
$
v0
,
4020
syscall
#
length
at
0x31000000
lui
$
s1
,
0x3100
lw
$
t0
,
0
(
$
s1
)
#
should
be
len
(
"hello world"
)
==
11
li
$
t4
,
11
subu
$
t5
,
$
t0
,
$
t4
sltiu
$
v0
,
$
t5
,
1
#
data
at
0x31000004
#
save
results
lui
$
s0
,
0xbfff
#
Load
the
base
address
0xbffffff0
ori
$
s0
,
0xfff0
ori
$
s1
,
$
0
,
1
#
Prepare
the
'
done
'
status
sw
$
v0
,
8
(
$
s0
)
#
Set
the
test
result
sw
$
s1
,
4
(
$
s0
)
#
Set
'
done
'
$
done
:
jr
$
ra
nop
.
end
test
mipsevm/testoracle/0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad
0 → 100644
View file @
635af73a
hello world
\ No newline at end of file
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