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
20112775
Commit
20112775
authored
Nov 04, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
does this make the test work?
parent
5da909f8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
11 deletions
+13
-11
compare_unievm_test.go
mipsevm/compare_unievm_test.go
+3
-2
main.go
mipsevm/main.go
+5
-5
run_chain.go
mipsevm/run_chain.go
+1
-1
trie.go
mipsevm/trie.go
+3
-2
trie_test.go
mipsevm/trie_test.go
+1
-1
No files found.
mipsevm/compare_unievm_test.go
View file @
20112775
...
...
@@ -34,8 +34,9 @@ func TestCompareUnicornEvm(t *testing.T) {
evmram
:=
make
(
map
[
uint32
](
uint32
))
LoadMappedFile
(
fn
,
evmram
,
0
)
inputFile
:=
fmt
.
Sprintf
(
"/tmp/cannon/%d_%d/input"
,
0
,
13284469
)
LoadMappedFile
(
inputFile
,
evmram
,
0x30000000
)
// not for test.bin
/*inputFile := fmt.Sprintf("/tmp/cannon/%d_%d/input", 0, 13284469)
LoadMappedFile(inputFile, evmram, 0x30000000)*/
// init registers to 0 in evm
for
i
:=
uint32
(
0xC0000000
);
i
<
0xC0000000
+
36
*
4
;
i
+=
4
{
WriteRam
(
evmram
,
i
,
0
)
...
...
mipsevm/main.go
View file @
20112775
...
...
@@ -9,9 +9,9 @@ import (
uc
"github.com/unicorn-engine/unicorn/bindings/go/unicorn"
)
func
WriteCheckpoint
(
ram
map
[
uint32
](
uint32
),
fn
string
)
{
func
WriteCheckpoint
(
ram
map
[
uint32
](
uint32
),
fn
string
,
step
int
)
{
trieroot
:=
RamToTrie
(
ram
)
dat
:=
TrieToJson
(
trieroot
)
dat
:=
TrieToJson
(
trieroot
,
step
)
fmt
.
Printf
(
"writing %s len %d with root %s
\n
"
,
fn
,
len
(
dat
),
trieroot
)
ioutil
.
WriteFile
(
fn
,
dat
,
0644
)
}
...
...
@@ -32,7 +32,7 @@ func main() {
if
step
%
10000000
==
0
{
SyncRegs
(
mu
,
ram
)
fn
:=
fmt
.
Sprintf
(
"%s/checkpoint_%d.json"
,
root
,
step
)
WriteCheckpoint
(
ram
,
fn
)
WriteCheckpoint
(
ram
,
fn
,
step
)
}
lastStep
=
step
})
...
...
@@ -40,7 +40,7 @@ func main() {
ZeroRegisters
(
ram
)
// not ready for golden yet
LoadMappedFileUnicorn
(
mu
,
"mipigo/minigeth.bin"
,
ram
,
0
)
WriteCheckpoint
(
ram
,
"/tmp/cannon/golden.json"
)
WriteCheckpoint
(
ram
,
"/tmp/cannon/golden.json"
,
-
1
)
if
root
==
""
{
fmt
.
Println
(
"exiting early without a block number"
)
os
.
Exit
(
0
)
...
...
@@ -50,7 +50,7 @@ func main() {
mu
.
Start
(
0
,
0x5ead0004
)
SyncRegs
(
mu
,
ram
)
WriteCheckpoint
(
ram
,
fmt
.
Sprintf
(
"%s/checkpoint_
%d.json"
,
root
,
lastStep
)
)
WriteCheckpoint
(
ram
,
fmt
.
Sprintf
(
"%s/checkpoint_
final.json"
,
root
),
lastStep
)
// step 2 (optional), validate each 1 million chunk in EVM
...
...
mipsevm/run_chain.go
View file @
20112775
...
...
@@ -116,7 +116,7 @@ func RunFull() {
root
:=
RamToTrie
(
ram
)
//ParseNode(root, 0)
ioutil
.
WriteFile
(
"/tmp/cannon/trie.json"
,
TrieToJson
(
root
),
0644
)
ioutil
.
WriteFile
(
"/tmp/cannon/trie.json"
,
TrieToJson
(
root
,
-
1
),
0644
)
for
k
,
v
:=
range
Preimages
{
fmt
.
Println
(
"AddTrieNode"
,
k
)
...
...
mipsevm/trie.go
View file @
20112775
...
...
@@ -19,11 +19,12 @@ var Preimages = make(map[common.Hash][]byte)
type
Jtree
struct
{
Root
common
.
Hash
`json:"root"`
Step
int
`json:"step"`
Preimages
map
[
common
.
Hash
][]
byte
`json:"preimages"`
}
func
TrieToJson
(
root
common
.
Hash
)
[]
byte
{
b
,
err
:=
json
.
Marshal
(
Jtree
{
Preimages
:
Preimages
,
Root
:
root
})
func
TrieToJson
(
root
common
.
Hash
,
step
int
)
[]
byte
{
b
,
err
:=
json
.
Marshal
(
Jtree
{
Preimages
:
Preimages
,
Step
:
step
,
Root
:
root
})
check
(
err
)
return
b
}
...
...
mipsevm/trie_test.go
View file @
20112775
...
...
@@ -17,7 +17,7 @@ func TestTrie(t *testing.T) {
root
:=
RamToTrie
(
ram
)
//ParseNode(root, 0)
dat
:=
TrieToJson
(
root
)
dat
:=
TrieToJson
(
root
,
-
1
)
fmt
.
Println
(
"serialized length is"
,
len
(
dat
))
ioutil
.
WriteFile
(
"/tmp/cannon/ramtrie.json"
,
dat
,
0644
)
}
...
...
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