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
8212261c
Commit
8212261c
authored
Sep 24, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
15 million instructions for 5 txs
parent
55c25466
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
21 deletions
+38
-21
main.go
minigeth/main.go
+7
-0
run.py
risc/run.py
+31
-21
No files found.
minigeth/main.go
View file @
8212261c
...
...
@@ -9,12 +9,19 @@ import (
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
)
func
main
()
{
// init secp256k1BytePoints
crypto
.
S256
()
// before this isn't run on chain (confirm this isn't cached)
os
.
Stderr
.
WriteString
(
"********* on chain starts here *********
\n
"
)
blockNumber
,
_
:=
strconv
.
Atoi
(
os
.
Args
[
1
])
// read header
...
...
risc/run.py
View file @
8212261c
...
...
@@ -7,9 +7,6 @@ from elftools.elf.elffile import ELFFile
from
capstone
import
*
md
=
Cs
(
CS_ARCH_MIPS
,
CS_MODE_32
+
CS_MODE_BIG_ENDIAN
)
icount
=
0
bcount
=
0
from
termcolor
import
colored
,
cprint
from
hexdump
import
hexdump
from
unicorn
import
*
...
...
@@ -26,6 +23,34 @@ SIZE = 16*1024*1024
heap_start
=
0x20000000
# 0x20000000-0x30000000
brk_start
=
0x40000000
# 0x40000000-0x80000000
# hmm, very slow
icount
=
0
bcount
=
0
def
hook_code_simple
(
uc
,
address
,
size
,
user_data
):
global
icount
,
bcount
#assert size == 4
try
:
if
bcount
%
100000
==
0
:
dat
=
next
(
md
.
disasm
(
uc
.
mem_read
(
address
,
size
),
address
))
print
(
"
%10
d:
%
s
%
s"
%
(
icount
,
r
[
address
],
dat
))
icount
+=
size
//
4
bcount
+=
1
return
True
except
Exception
as
e
:
raise
e
except
:
raise
Exception
started
=
False
def
start_instrumenting
():
global
started
if
not
started
:
#mu.hook_add(UC_HOOK_CODE, hook_code_simple, user_data=mu)
if
os
.
getenv
(
"TRACE"
)
==
"1"
:
mu
.
hook_add
(
UC_HOOK_BLOCK
,
hook_code_simple
,
user_data
=
mu
)
started
=
True
tfd
=
10
files
=
{}
fcnt
=
0
...
...
@@ -41,6 +66,7 @@ def hook_interrupt(uc, intno, user_data):
fd
=
uc
.
reg_read
(
UC_MIPS_REG_A0
)
buf
=
uc
.
reg_read
(
UC_MIPS_REG_A1
)
count
=
uc
.
reg_read
(
UC_MIPS_REG_A2
)
#print("write(%d, %x, %d)" % (fd, buf, count))
if
fd
==
1
:
# stdout
os
.
write
(
fd
,
colored
(
uc
.
mem_read
(
buf
,
count
)
.
decode
(
'utf-8'
),
'green'
)
.
encode
(
'utf-8'
))
...
...
@@ -50,6 +76,8 @@ def hook_interrupt(uc, intno, user_data):
else
:
os
.
write
(
fd
,
uc
.
mem_read
(
buf
,
count
))
uc
.
reg_write
(
UC_MIPS_REG_A3
,
0
)
if
fd
==
2
:
start_instrumenting
()
return
True
if
syscall_no
==
4218
:
...
...
@@ -273,24 +301,6 @@ for section in elffile.iter_sections():
#mu.hook_add(UC_HOOK_CODE, hook_code, user_data=mu)
# hmm, very slow
def
hook_code_simple
(
uc
,
address
,
size
,
user_data
):
global
icount
,
bcount
#assert size == 4
try
:
if
bcount
%
1000000
==
0
:
dat
=
next
(
md
.
disasm
(
uc
.
mem_read
(
address
,
size
),
address
))
print
(
"
%10
d:
%
s
%
s"
%
(
icount
,
r
[
address
],
dat
))
icount
+=
size
//
4
bcount
+=
1
return
True
except
Exception
as
e
:
raise
e
except
:
raise
Exception
#mu.hook_add(UC_HOOK_CODE, hook_code_simple, user_data=mu)
if
os
.
getenv
(
"TRACE"
)
==
"1"
:
mu
.
hook_add
(
UC_HOOK_BLOCK
,
hook_code_simple
,
user_data
=
mu
)
def
hook_mem_invalid
(
uc
,
access
,
address
,
size
,
value
,
user_data
):
pc
=
uc
.
reg_read
(
UC_MIPS_REG_PC
)
...
...
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