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
05db1a9b
Commit
05db1a9b
authored
Nov 04, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
store tmp data in /tmp/cannon
parent
77683af8
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
26 additions
and
16 deletions
+26
-16
test_minigeth.yml
.github/workflows/test_minigeth.yml
+1
-1
main.go
minigeth/main.go
+2
-1
preimage.go
minigeth/oracle/preimage.go
+1
-1
compare_unievm_test.go
mipsevm/compare_unievm_test.go
+1
-1
main.go
mipsevm/main.go
+1
-1
minievm.go
mipsevm/minievm.go
+1
-0
run_chain.go
mipsevm/run_chain.go
+3
-2
run_unicorn.go
mipsevm/run_unicorn.go
+3
-2
trie_test.go
mipsevm/trie_test.go
+1
-1
run.sh
run.sh
+1
-1
deploy.js
scripts/deploy.js
+8
-2
test.sh
test.sh
+1
-1
challenge_test.js
test/challenge_test.js
+2
-2
No files found.
.github/workflows/test_minigeth.yml
View file @
05db1a9b
...
@@ -16,7 +16,7 @@ jobs:
...
@@ -16,7 +16,7 @@ jobs:
-
name
:
Build minigeth
-
name
:
Build minigeth
run
:
|
run
:
|
(cd minigeth/ && go build)
(cd minigeth/ && go build)
mkdir -p /tmp/
eth
mkdir -p /tmp/
cannon
-
name
:
Test block 13284491 (0 tx)
-
name
:
Test block 13284491 (0 tx)
run
:
minigeth/go-ethereum
13284491
run
:
minigeth/go-ethereum
13284491
-
name
:
Test block 13284469 (few tx)
-
name
:
Test block 13284469 (few tx)
...
...
minigeth/main.go
View file @
05db1a9b
...
@@ -49,7 +49,8 @@ func main() {
...
@@ -49,7 +49,8 @@ func main() {
pkwtrie
:=
trie
.
NewStackTrie
(
pkw
)
pkwtrie
:=
trie
.
NewStackTrie
(
pkw
)
blockNumber
,
_
:=
strconv
.
Atoi
(
os
.
Args
[
1
])
blockNumber
,
_
:=
strconv
.
Atoi
(
os
.
Args
[
1
])
oracle
.
SetRoot
(
fmt
.
Sprintf
(
"/tmp/eth/%d"
,
blockNumber
))
// TODO: get the chainid
oracle
.
SetRoot
(
fmt
.
Sprintf
(
"/tmp/cannon/0_%d"
,
blockNumber
))
oracle
.
PrefetchBlock
(
big
.
NewInt
(
int64
(
blockNumber
)),
true
,
nil
)
oracle
.
PrefetchBlock
(
big
.
NewInt
(
int64
(
blockNumber
)),
true
,
nil
)
oracle
.
PrefetchBlock
(
big
.
NewInt
(
int64
(
blockNumber
)
+
1
),
false
,
pkwtrie
)
oracle
.
PrefetchBlock
(
big
.
NewInt
(
int64
(
blockNumber
)
+
1
),
false
,
pkwtrie
)
hash
,
err
:=
pkwtrie
.
Commit
()
hash
,
err
:=
pkwtrie
.
Commit
()
...
...
minigeth/oracle/preimage.go
View file @
05db1a9b
...
@@ -14,7 +14,7 @@ import (
...
@@ -14,7 +14,7 @@ import (
)
)
var
preimages
=
make
(
map
[
common
.
Hash
][]
byte
)
var
preimages
=
make
(
map
[
common
.
Hash
][]
byte
)
var
root
=
"/tmp/
eth
"
var
root
=
"/tmp/
cannon
"
func
SetRoot
(
newRoot
string
)
{
func
SetRoot
(
newRoot
string
)
{
root
=
newRoot
root
=
newRoot
...
...
mipsevm/compare_unievm_test.go
View file @
05db1a9b
...
@@ -34,7 +34,7 @@ func TestCompareUnicornEvm(t *testing.T) {
...
@@ -34,7 +34,7 @@ func TestCompareUnicornEvm(t *testing.T) {
evmram
:=
make
(
map
[
uint32
](
uint32
))
evmram
:=
make
(
map
[
uint32
](
uint32
))
LoadMappedFile
(
fn
,
evmram
,
0
)
LoadMappedFile
(
fn
,
evmram
,
0
)
inputFile
:=
fmt
.
Sprintf
(
"/tmp/
eth/%d"
,
13284469
)
inputFile
:=
fmt
.
Sprintf
(
"/tmp/
cannon/%d_%d"
,
0
,
13284469
)
LoadMappedFile
(
inputFile
,
evmram
,
0x30000000
)
LoadMappedFile
(
inputFile
,
evmram
,
0x30000000
)
// init registers to 0 in evm
// init registers to 0 in evm
for
i
:=
uint32
(
0xC0000000
);
i
<
0xC0000000
+
36
*
4
;
i
+=
4
{
for
i
:=
uint32
(
0xC0000000
);
i
<
0xC0000000
+
36
*
4
;
i
+=
4
{
...
...
mipsevm/main.go
View file @
05db1a9b
...
@@ -16,7 +16,7 @@ func WriteCheckpoint(ram map[uint32](uint32), root string, step int) {
...
@@ -16,7 +16,7 @@ func WriteCheckpoint(ram map[uint32](uint32), root string, step int) {
}
}
func
main
()
{
func
main
()
{
root
:=
fmt
.
Sprintf
(
"/tmp/
eth/%d"
,
13284469
)
root
:=
fmt
.
Sprintf
(
"/tmp/
cannon/%d_%d"
,
0
,
13284469
)
// 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
))
...
...
mipsevm/minievm.go
View file @
05db1a9b
...
@@ -124,6 +124,7 @@ func (s *StateDB) GetState(fakeaddr common.Address, hash common.Hash) common.Has
...
@@ -124,6 +124,7 @@ func (s *StateDB) GetState(fakeaddr common.Address, hash common.Hash) common.Has
binary
.
BigEndian
.
PutUint32
(
oracle_hash
[
i
:
i
+
4
],
ram
[
0x30001000
+
i
])
binary
.
BigEndian
.
PutUint32
(
oracle_hash
[
i
:
i
+
4
],
ram
[
0x30001000
+
i
])
}
}
hash
:=
common
.
BytesToHash
(
oracle_hash
)
hash
:=
common
.
BytesToHash
(
oracle_hash
)
// TODO: this is wrong, need root
key
:=
fmt
.
Sprintf
(
"/tmp/eth/%s"
,
hash
)
key
:=
fmt
.
Sprintf
(
"/tmp/eth/%s"
,
hash
)
value
,
_
:=
ioutil
.
ReadFile
(
key
)
value
,
_
:=
ioutil
.
ReadFile
(
key
)
...
...
mipsevm/run_chain.go
View file @
05db1a9b
...
@@ -95,7 +95,8 @@ func LoadData(dat []byte, ram map[uint32](uint32), base uint32) {
...
@@ -95,7 +95,8 @@ func LoadData(dat []byte, ram map[uint32](uint32), base uint32) {
}
}
func
LoadMappedFile
(
fn
string
,
ram
map
[
uint32
](
uint32
),
base
uint32
)
{
func
LoadMappedFile
(
fn
string
,
ram
map
[
uint32
](
uint32
),
base
uint32
)
{
dat
,
_
:=
ioutil
.
ReadFile
(
fn
)
dat
,
err
:=
ioutil
.
ReadFile
(
fn
)
check
(
err
)
LoadData
(
dat
,
ram
,
base
)
LoadData
(
dat
,
ram
,
base
)
}
}
...
@@ -115,7 +116,7 @@ func RunFull() {
...
@@ -115,7 +116,7 @@ func RunFull() {
root
:=
RamToTrie
(
ram
)
root
:=
RamToTrie
(
ram
)
//ParseNode(root, 0)
//ParseNode(root, 0)
ioutil
.
WriteFile
(
"/tmp/
eth
/trie.json"
,
TrieToJson
(
root
),
0644
)
ioutil
.
WriteFile
(
"/tmp/
cannon
/trie.json"
,
TrieToJson
(
root
),
0644
)
for
k
,
v
:=
range
Preimages
{
for
k
,
v
:=
range
Preimages
{
fmt
.
Println
(
"AddTrieNode"
,
k
)
fmt
.
Println
(
"AddTrieNode"
,
k
)
...
...
mipsevm/run_unicorn.go
View file @
05db1a9b
...
@@ -159,14 +159,15 @@ func GetHookedUnicorn(root string, ram map[uint32](uint32), callback func(int, u
...
@@ -159,14 +159,15 @@ func GetHookedUnicorn(root string, ram map[uint32](uint32), callback func(int, u
}
}
func
LoadMappedFileUnicorn
(
mu
uc
.
Unicorn
,
fn
string
,
ram
map
[
uint32
](
uint32
),
base
uint32
)
{
func
LoadMappedFileUnicorn
(
mu
uc
.
Unicorn
,
fn
string
,
ram
map
[
uint32
](
uint32
),
base
uint32
)
{
dat
,
_
:=
ioutil
.
ReadFile
(
fn
)
dat
,
err
:=
ioutil
.
ReadFile
(
fn
)
check
(
err
)
LoadData
(
dat
,
ram
,
base
)
LoadData
(
dat
,
ram
,
base
)
mu
.
MemWrite
(
uint64
(
base
),
dat
)
mu
.
MemWrite
(
uint64
(
base
),
dat
)
}
}
// reimplement simple.py in go
// reimplement simple.py in go
func
RunUnicorn
(
fn
string
,
ram
map
[
uint32
](
uint32
),
checkIO
bool
,
callback
func
(
int
,
uc
.
Unicorn
,
map
[
uint32
](
uint32
)))
{
func
RunUnicorn
(
fn
string
,
ram
map
[
uint32
](
uint32
),
checkIO
bool
,
callback
func
(
int
,
uc
.
Unicorn
,
map
[
uint32
](
uint32
)))
{
root
:=
"/tmp/
eth/
13284469"
root
:=
"/tmp/
cannon/0_
13284469"
mu
:=
GetHookedUnicorn
(
root
,
ram
,
callback
)
mu
:=
GetHookedUnicorn
(
root
,
ram
,
callback
)
// loop forever to match EVM
// loop forever to match EVM
...
...
mipsevm/trie_test.go
View file @
05db1a9b
...
@@ -19,7 +19,7 @@ func TestTrie(t *testing.T) {
...
@@ -19,7 +19,7 @@ func TestTrie(t *testing.T) {
dat
:=
TrieToJson
(
root
)
dat
:=
TrieToJson
(
root
)
fmt
.
Println
(
"serialized length is"
,
len
(
dat
))
fmt
.
Println
(
"serialized length is"
,
len
(
dat
))
ioutil
.
WriteFile
(
"/tmp/
eth
/ramtrie.json"
,
dat
,
0644
)
ioutil
.
WriteFile
(
"/tmp/
cannon
/ramtrie.json"
,
dat
,
0644
)
}
}
func
printRoot
(
ram
map
[
uint32
](
uint32
))
{
func
printRoot
(
ram
map
[
uint32
](
uint32
))
{
...
...
run.sh
View file @
05db1a9b
#!/bin/bash -e
#!/bin/bash -e
(
cd
minigeth/
&&
go build
)
(
cd
minigeth/
&&
go build
)
mkdir
-p
/tmp/
eth
mkdir
-p
/tmp/
cannon
# 0 tx: 13284491
# 0 tx: 13284491
# low tx: 13284469
# low tx: 13284469
...
...
scripts/deploy.js
View file @
05db1a9b
const
{
deploy
}
=
require
(
"
../scripts/lib
"
)
const
{
deploy
}
=
require
(
"
../scripts/lib
"
)
const
fs
=
require
(
"
fs
"
)
async
function
main
()
{
async
function
main
()
{
var
[
c
,
m
,
mm
]
=
await
deploy
()
let
[
c
,
m
,
mm
]
=
await
deploy
()
console
.
log
(
"
deployed at
"
,
c
.
address
,
m
.
address
,
mm
.
address
)
let
json
=
{
"
Challenge
"
:
c
.
address
,
"
MIPS
"
:
m
.
address
,
"
MIPSMemory
"
:
mm
.
address
,
}
console
.
log
(
"
deployed
"
,
json
)
}
}
main
()
main
()
...
...
test.sh
View file @
05db1a9b
#!/bin/bash -e
#!/bin/bash -e
(
cd
minigeth/
&&
go build
)
(
cd
minigeth/
&&
go build
)
mkdir
-p
/tmp/
eth
mkdir
-p
/tmp/
cannon
# london starts at 12965000
# london starts at 12965000
BLOCK
=
$1
BLOCK
=
$1
...
...
test/challenge_test.js
View file @
05db1a9b
...
@@ -25,8 +25,8 @@ describe("Challenge contract", function () {
...
@@ -25,8 +25,8 @@ describe("Challenge contract", function () {
const
assertionRoot
=
"
0x9e0261efe4509912b8862f3d45a0cb8404b99b239247df9c55871bd3844cebbd
"
const
assertionRoot
=
"
0x9e0261efe4509912b8862f3d45a0cb8404b99b239247df9c55871bd3844cebbd
"
const
finalSystemState
=
"
0xf02b4450a07d492c17b4b554851f0dcb12192e2439a507b12fcea8f801a596a6
"
const
finalSystemState
=
"
0xf02b4450a07d492c17b4b554851f0dcb12192e2439a507b12fcea8f801a596a6
"
let
startTrie
=
JSON
.
parse
(
fs
.
readFileSync
(
"
/tmp/
eth/
13284469/checkpoint_-1.json
"
))
let
startTrie
=
JSON
.
parse
(
fs
.
readFileSync
(
"
/tmp/
cannon/0_
13284469/checkpoint_-1.json
"
))
let
finalTrie
=
JSON
.
parse
(
fs
.
readFileSync
(
"
/tmp/
eth/
13284469/checkpoint_85059435.json
"
))
let
finalTrie
=
JSON
.
parse
(
fs
.
readFileSync
(
"
/tmp/
cannon/0_
13284469/checkpoint_85059435.json
"
))
while
(
1
)
{
while
(
1
)
{
try
{
try
{
...
...
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