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
fb89747e
Commit
fb89747e
authored
Oct 29, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check output in unicorn run
parent
0ea43a93
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
prefetch.go
minigeth/oracle/prefetch.go
+3
-2
unicorn.go
mipsevm/unicorn.go
+14
-3
No files found.
minigeth/oracle/prefetch.go
View file @
fb89747e
...
@@ -79,8 +79,9 @@ type Account struct {
...
@@ -79,8 +79,9 @@ type Account struct {
CodeHash
[]
byte
CodeHash
[]
byte
}
}
//var nodeUrl = "http://192.168.1.213:8545"
var
nodeUrl
=
"http://192.168.1.213:8545"
var
nodeUrl
=
"https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"
//var nodeUrl = "https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"
func
toFilename
(
key
string
)
string
{
func
toFilename
(
key
string
)
string
{
return
fmt
.
Sprintf
(
"%s/json_%s"
,
root
,
key
)
return
fmt
.
Sprintf
(
"%s/json_%s"
,
root
,
key
)
...
...
mipsevm/unicorn.go
View file @
fb89747e
package
main
package
main
import
(
import
(
"bytes"
"encoding/binary"
"encoding/binary"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
...
@@ -74,6 +75,8 @@ func RunUnicorn(fn string, ram map[uint32](uint32), totalSteps int, slowMode boo
...
@@ -74,6 +75,8 @@ func RunUnicorn(fn string, ram map[uint32](uint32), totalSteps int, slowMode boo
mu
,
err
:=
uc
.
NewUnicorn
(
uc
.
ARCH_MIPS
,
uc
.
MODE_32
|
uc
.
MODE_BIG_ENDIAN
)
mu
,
err
:=
uc
.
NewUnicorn
(
uc
.
ARCH_MIPS
,
uc
.
MODE_32
|
uc
.
MODE_BIG_ENDIAN
)
check
(
err
)
check
(
err
)
root
:=
"/tmp/eth/13284469"
mu
.
HookAdd
(
uc
.
HOOK_INTR
,
func
(
mu
uc
.
Unicorn
,
intno
uint32
)
{
mu
.
HookAdd
(
uc
.
HOOK_INTR
,
func
(
mu
uc
.
Unicorn
,
intno
uint32
)
{
if
intno
!=
17
{
if
intno
!=
17
{
log
.
Fatal
(
"invalid interrupt "
,
intno
,
" at step "
,
steps
)
log
.
Fatal
(
"invalid interrupt "
,
intno
,
" at step "
,
steps
)
...
@@ -83,7 +86,7 @@ func RunUnicorn(fn string, ram map[uint32](uint32), totalSteps int, slowMode boo
...
@@ -83,7 +86,7 @@ func RunUnicorn(fn string, ram map[uint32](uint32), totalSteps int, slowMode boo
if
syscall_no
==
4020
{
if
syscall_no
==
4020
{
oracle_hash
,
_
:=
mu
.
MemRead
(
0xB0001000
,
0x20
)
oracle_hash
,
_
:=
mu
.
MemRead
(
0xB0001000
,
0x20
)
hash
:=
common
.
BytesToHash
(
oracle_hash
)
hash
:=
common
.
BytesToHash
(
oracle_hash
)
key
:=
fmt
.
Sprintf
(
"
/tmp/eth/%s"
,
hash
)
key
:=
fmt
.
Sprintf
(
"
%s/%s"
,
root
,
hash
)
value
,
_
:=
ioutil
.
ReadFile
(
key
)
value
,
_
:=
ioutil
.
ReadFile
(
key
)
tmp
:=
[]
byte
{
0
,
0
,
0
,
0
}
tmp
:=
[]
byte
{
0
,
0
,
0
,
0
}
...
@@ -178,12 +181,20 @@ func RunUnicorn(fn string, ram map[uint32](uint32), totalSteps int, slowMode boo
...
@@ -178,12 +181,20 @@ func RunUnicorn(fn string, ram map[uint32](uint32), totalSteps int, slowMode boo
mu
.
MemWrite
(
0
,
dat
)
mu
.
MemWrite
(
0
,
dat
)
// inputs
// inputs
inputFile
:=
fmt
.
Sprintf
(
"
/tmp/eth/%d"
,
13284469
)
inputFile
:=
fmt
.
Sprintf
(
"
%s/input"
,
root
)
inputs
,
_
:=
ioutil
.
ReadFile
(
inputFile
)
inputs
,
_
:=
ioutil
.
ReadFile
(
inputFile
)
mu
.
MemWrite
(
0xB0000000
,
inputs
)
mu
.
MemWrite
(
0xB0000000
,
inputs
[
0
:
0xc0
]
)
LoadMappedFile
(
fn
,
ram
,
0
)
LoadMappedFile
(
fn
,
ram
,
0
)
LoadMappedFile
(
inputFile
,
ram
,
0xB0000000
)
LoadMappedFile
(
inputFile
,
ram
,
0xB0000000
)
mu
.
Start
(
0
,
0x5ead0004
)
mu
.
Start
(
0
,
0x5ead0004
)
real
:=
append
([]
byte
{
0x13
,
0x37
,
0xf0
,
0x0d
},
inputs
[
0xc0
:
]
...
)
output
,
_
:=
mu
.
MemRead
(
0xB0000800
,
0x44
)
if
bytes
.
Compare
(
real
,
output
)
!=
0
{
log
.
Fatal
(
"mismatch output"
)
}
else
{
fmt
.
Println
(
"output match"
)
}
}
}
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