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
7c3b3af0
Commit
7c3b3af0
authored
Nov 06, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow mipsevm to use both unicorn and the evm
parent
20d6c36d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
26 deletions
+43
-26
test_challenge.yml
.github/workflows/test_challenge.yml
+1
-1
main.go
mipsevm/main.go
+41
-24
run_unicorn.go
mipsevm/run_unicorn.go
+1
-1
No files found.
.github/workflows/test_challenge.yml
View file @
7c3b3af0
...
@@ -34,6 +34,6 @@ jobs:
...
@@ -34,6 +34,6 @@ jobs:
cd mipsevm
cd mipsevm
go build
go build
-
name
:
Generate checkpoints for
13284469
-
name
:
Generate checkpoints for
13284469
run
:
mipsevm
/mipsevm
13284469
run
:
cd mipsevm && .
/mipsevm
13284469
-
name
:
Run test challenge
-
name
:
Run test challenge
run
:
npx hardhat test test/challenge_test.js
run
:
npx hardhat test test/challenge_test.js
mipsevm/main.go
View file @
7c3b3af0
...
@@ -26,12 +26,27 @@ func main() {
...
@@ -26,12 +26,27 @@ func main() {
if
len
(
os
.
Args
)
>
2
{
if
len
(
os
.
Args
)
>
2
{
target
,
_
=
strconv
.
Atoi
(
os
.
Args
[
2
])
target
,
_
=
strconv
.
Atoi
(
os
.
Args
[
2
])
}
}
evm
:=
false
if
len
(
os
.
Args
)
>
3
&&
os
.
Args
[
3
]
==
"evm"
{
evm
=
true
}
// step 1, generate the checkpoints every million steps using unicorn
// step 1, generate the checkpoints every million steps using unicorn
ram
:=
make
(
map
[
uint32
](
uint32
))
ram
:=
make
(
map
[
uint32
](
uint32
))
lastStep
:=
0
lastStep
:=
1
mu
:=
GetHookedUnicorn
(
root
,
ram
,
func
(
step
int
,
mu
uc
.
Unicorn
,
ram
map
[
uint32
](
uint32
))
{
if
evm
{
ZeroRegisters
(
ram
)
LoadMappedFile
(
"../mipigo/minigeth.bin"
,
ram
,
0
)
WriteCheckpoint
(
ram
,
"/tmp/cannon/golden.json"
,
-
1
)
LoadMappedFile
(
fmt
.
Sprintf
(
"%s/input"
,
root
),
ram
,
0x30000000
)
RunWithRam
(
ram
,
target
-
1
,
0
,
nil
)
lastStep
+=
target
-
1
fn
:=
fmt
.
Sprintf
(
"%s/checkpoint_%d.json"
,
root
,
lastStep
)
WriteCheckpoint
(
ram
,
fn
,
lastStep
)
}
else
{
mu
:=
GetHookedUnicorn
(
root
,
ram
,
func
(
lstep
int
,
mu
uc
.
Unicorn
,
ram
map
[
uint32
](
uint32
))
{
step
:=
lstep
+
1
// this can be raised to 10,000,000 if the files are too large
// this can be raised to 10,000,000 if the files are too large
if
step
%
10000000
==
0
||
step
==
target
{
if
step
%
10000000
==
0
||
step
==
target
{
SyncRegs
(
mu
,
ram
)
SyncRegs
(
mu
,
ram
)
...
@@ -47,7 +62,7 @@ func main() {
...
@@ -47,7 +62,7 @@ func main() {
ZeroRegisters
(
ram
)
ZeroRegisters
(
ram
)
// not ready for golden yet
// not ready for golden yet
LoadMappedFileUnicorn
(
mu
,
"
mipigo/minigeth.bin"
,
ram
,
0
)
LoadMappedFileUnicorn
(
mu
,
"../
mipigo/minigeth.bin"
,
ram
,
0
)
WriteCheckpoint
(
ram
,
"/tmp/cannon/golden.json"
,
-
1
)
WriteCheckpoint
(
ram
,
"/tmp/cannon/golden.json"
,
-
1
)
if
root
==
""
{
if
root
==
""
{
fmt
.
Println
(
"exiting early without a block number"
)
fmt
.
Println
(
"exiting early without a block number"
)
...
@@ -59,6 +74,8 @@ func main() {
...
@@ -59,6 +74,8 @@ func main() {
mu
.
Start
(
0
,
0x5ead0004
)
mu
.
Start
(
0
,
0x5ead0004
)
SyncRegs
(
mu
,
ram
)
SyncRegs
(
mu
,
ram
)
}
if
target
==
-
1
{
if
target
==
-
1
{
WriteCheckpoint
(
ram
,
fmt
.
Sprintf
(
"%s/checkpoint_final.json"
,
root
),
lastStep
)
WriteCheckpoint
(
ram
,
fmt
.
Sprintf
(
"%s/checkpoint_final.json"
,
root
),
lastStep
)
}
}
...
...
mipsevm/run_unicorn.go
View file @
7c3b3af0
...
@@ -20,7 +20,7 @@ func check(err error) {
...
@@ -20,7 +20,7 @@ func check(err error) {
}
}
}
}
var
steps
int
=
1
var
steps
int
=
0
var
heap_start
uint64
=
0
var
heap_start
uint64
=
0
func
WriteBytes
(
fd
int
,
bytes
[]
byte
)
{
func
WriteBytes
(
fd
int
,
bytes
[]
byte
)
{
...
...
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