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
8977f137
Commit
8977f137
authored
Sep 24, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
in the embedded world, we use a different oracle
parent
1f3eba66
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
8 deletions
+56
-8
embedded.go
minigeth/oracle/embedded.go
+31
-0
prefetch.go
minigeth/oracle/prefetch.go
+3
-1
preimage.go
minigeth/oracle/preimage.go
+5
-0
build.sh
risc/build.sh
+1
-2
data
risc/data
+1
-0
run.py
risc/run.py
+15
-5
No files found.
minigeth/oracle/embedded.go
0 → 100644
View file @
8977f137
//go:build mips
package
oracle
import
(
"fmt"
"io/ioutil"
"math/big"
"os"
"github.com/ethereum/go-ethereum/common"
)
func
Preimage
(
hash
common
.
Hash
)
[]
byte
{
f
,
err
:=
os
.
Open
(
fmt
.
Sprintf
(
"/tmp/eth/%s"
,
hash
))
if
err
!=
nil
{
panic
(
"missing preimage"
)
}
defer
f
.
Close
()
ret
,
err
:=
ioutil
.
ReadAll
(
f
)
if
err
!=
nil
{
panic
(
"preimage read failed"
)
}
return
ret
}
// these are stubs in embedded world
func
PrefetchStorage
(
blockNumber
*
big
.
Int
,
addr
common
.
Address
,
skey
common
.
Hash
)
{}
func
PrefetchAccount
(
blockNumber
*
big
.
Int
,
addr
common
.
Address
)
{}
func
PrefetchCode
(
blockNumber
*
big
.
Int
,
addrHash
common
.
Hash
)
{}
minigeth/oracle/prefetch.go
View file @
8977f137
//go:build !mips
package
oracle
import
(
...
...
@@ -65,7 +67,7 @@ type Account struct {
var
nodeUrl
=
"https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"
func
toFilename
(
key
string
)
string
{
return
fmt
.
Sprintf
(
"/tmp/eth/%s"
,
key
)
return
fmt
.
Sprintf
(
"/tmp/eth/
json_
%s"
,
key
)
}
func
cacheRead
(
key
string
)
[]
byte
{
...
...
minigeth/oracle/preimage.go
View file @
8977f137
//go:build !mips
package
oracle
import
(
"fmt"
"io/ioutil"
"github.com/ethereum/go-ethereum/common"
)
...
...
@@ -10,6 +13,8 @@ var preimages = make(map[common.Hash][]byte)
func
Preimage
(
hash
common
.
Hash
)
[]
byte
{
val
,
ok
:=
preimages
[
hash
]
key
:=
fmt
.
Sprintf
(
"/tmp/eth/%s"
,
hash
)
ioutil
.
WriteFile
(
key
,
val
,
0644
)
if
!
ok
{
fmt
.
Println
(
"can't find preimage"
,
hash
)
panic
(
"preimage missing"
)
...
...
risc/build.sh
View file @
8977f137
...
...
@@ -5,5 +5,4 @@ cp go-ethereum ../risc/go-ethereum
cd
../risc
file go-ethereum
GOOS
=
linux
GOARCH
=
mips go build test.go
#GOOS=linux GOARCH=mips go build test.go
risc/data
0 → 120000
View file @
8977f137
../data/
\ No newline at end of file
risc/run.py
View file @
8977f137
...
...
@@ -16,9 +16,11 @@ regs = ["at", "v0", "v1", "a0", "a1", "a2", "a3"]
SIZE
=
16
*
1024
*
1024
heap_start
=
16
*
1024
*
1024
tfd
=
10
files
=
{}
fcnt
=
0
def
hook_interrupt
(
uc
,
intno
,
user_data
):
global
heap_start
,
fcnt
global
heap_start
,
fcnt
,
files
,
tfd
pc
=
uc
.
reg_read
(
UC_MIPS_REG_PC
)
if
intno
==
17
:
syscall_no
=
uc
.
reg_read
(
UC_MIPS_REG_V0
)
...
...
@@ -42,12 +44,15 @@ def hook_interrupt(uc, intno, user_data):
if
syscall_no
==
4005
:
filename
=
uc
.
reg_read
(
UC_MIPS_REG_A0
)
print
(
'open("
%
s")'
%
uc
.
mem_read
(
filename
,
0x100
)
.
split
(
b
"
\x00
"
)[
0
]
.
decode
(
'utf-8'
))
# open fd=4
uc
.
reg_write
(
UC_MIPS_REG_V0
,
4
)
elif
syscall_no
==
4288
:
dfd
=
uc
.
reg_read
(
UC_MIPS_REG_A0
)
filename
=
uc
.
reg_read
(
UC_MIPS_REG_A1
)
print
(
'openat(
%
d, "
%
s")'
%
(
dfd
,
uc
.
mem_read
(
filename
,
0x100
)
.
split
(
b
"
\x00
"
)[
0
]
.
decode
(
'utf-8'
)))
filename
=
uc
.
mem_read
(
filename
,
0x100
)
.
split
(
b
"
\x00
"
)[
0
]
.
decode
(
'utf-8'
)
print
(
'openat(
%
d, "
%
s")'
%
(
dfd
,
filename
))
files
[
tfd
]
=
open
(
filename
,
"rb"
)
uc
.
reg_write
(
UC_MIPS_REG_V0
,
tfd
)
tfd
+=
1
elif
syscall_no
==
4238
:
addr
=
uc
.
reg_read
(
UC_MIPS_REG_A0
)
print
(
"futex"
,
hex
(
addr
))
...
...
@@ -76,8 +81,13 @@ def hook_interrupt(uc, intno, user_data):
buf
=
uc
.
reg_read
(
UC_MIPS_REG_A1
)
count
=
uc
.
reg_read
(
UC_MIPS_REG_A2
)
print
(
"read"
,
fd
,
hex
(
buf
),
count
)
uc
.
mem_write
(
buf
,
b
"16384
\n\x00
"
)
uc
.
reg_write
(
UC_MIPS_REG_V0
,
6
)
if
fd
==
4
:
uc
.
mem_write
(
buf
,
b
"16384
\n\x00
"
)
uc
.
reg_write
(
UC_MIPS_REG_V0
,
6
)
else
:
ret
=
files
[
fd
]
.
read
(
count
)
uc
.
mem_write
(
buf
,
ret
)
uc
.
reg_write
(
UC_MIPS_REG_V0
,
len
(
ret
))
elif
syscall_no
==
4246
:
print
(
"EXIT"
)
return
False
...
...
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