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
ffe42fb7
Commit
ffe42fb7
authored
Oct 31, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
separate input and output
parent
69791851
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
17 deletions
+22
-17
prefetch.go
minigeth/oracle/prefetch.go
+18
-14
main.go
mipsevm/main.go
+1
-0
unicorn.go
mipsevm/unicorn.go
+3
-3
No files found.
minigeth/oracle/prefetch.go
View file @
ffe42fb7
...
...
@@ -187,24 +187,22 @@ func PrefetchCode(blockNumber *big.Int, addrHash common.Hash) {
preimages
[
hash
]
=
ret
}
var
inputs
[
8
]
common
.
Hash
var
inputs
[
6
]
common
.
Hash
var
outputs
[
2
]
common
.
Hash
func
Input
(
index
int
)
common
.
Hash
{
if
index
<
0
||
index
>
5
{
panic
(
"bad input index"
)
}
return
inputs
[
index
]
}
func
Output
(
output
common
.
Hash
,
receipts
common
.
Hash
)
{
if
receipts
!=
inputs
[
7
]
{
fmt
.
Println
(
"WARNING, receipts don't match"
,
receipts
,
"!="
,
inputs
[
7
])
if
receipts
!=
outputs
[
1
]
{
fmt
.
Println
(
"WARNING, receipts don't match"
,
receipts
,
"!="
,
outputs
[
1
])
panic
(
"BAD receipts"
)
}
if
output
==
inputs
[
6
]
{
if
output
==
outputs
[
0
]
{
fmt
.
Println
(
"good transition"
)
}
else
{
fmt
.
Println
(
output
,
"!="
,
inputs
[
6
])
fmt
.
Println
(
output
,
"!="
,
outputs
[
0
])
panic
(
"BAD transition :(("
)
}
}
...
...
@@ -294,17 +292,23 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
inputs
[
4
]
=
common
.
BigToHash
(
big
.
NewInt
(
int64
(
blockHeader
.
GasLimit
)))
inputs
[
5
]
=
common
.
BigToHash
(
big
.
NewInt
(
int64
(
blockHeader
.
Time
)))
// secret input
inputs
[
6
]
=
blockHeader
.
Root
inputs
[
7
]
=
blockHeader
.
ReceiptHash
// save the inputs
saveinput
:=
make
([]
byte
,
0
)
for
i
:=
0
;
i
<
len
(
inputs
);
i
++
{
saveinput
=
append
(
saveinput
,
inputs
[
i
]
.
Bytes
()[
:
]
...
)
}
key
:=
fmt
.
Sprintf
(
"%s/input"
,
root
)
ioutil
.
WriteFile
(
key
,
saveinput
,
0644
)
ioutil
.
WriteFile
(
fmt
.
Sprintf
(
"%s/input"
,
root
),
saveinput
,
0644
)
// secret input aka output
outputs
[
0
]
=
blockHeader
.
Root
outputs
[
1
]
=
blockHeader
.
ReceiptHash
// save the outputs
saveoutput
:=
make
([]
byte
,
0
)
for
i
:=
0
;
i
<
len
(
outputs
);
i
++
{
saveoutput
=
append
(
saveoutput
,
outputs
[
i
]
.
Bytes
()[
:
]
...
)
}
ioutil
.
WriteFile
(
fmt
.
Sprintf
(
"%s/output"
,
root
),
saveoutput
,
0644
)
// save the txs
txs
:=
make
([]
*
types
.
Transaction
,
len
(
jr
.
Result
.
Transactions
))
...
...
mipsevm/main.go
View file @
ffe42fb7
...
...
@@ -22,6 +22,7 @@ func main() {
lastStep
:=
0
mu
:=
GetHookedUnicorn
(
root
,
ram
,
func
(
step
int
,
mu
uc
.
Unicorn
,
ram
map
[
uint32
](
uint32
))
{
// this can be raised to 10,000,000 if the files are too large
if
step
%
1000000
==
0
{
SyncRegs
(
mu
,
ram
)
WriteCheckpoint
(
ram
,
root
,
step
)
...
...
mipsevm/unicorn.go
View file @
ffe42fb7
...
...
@@ -178,8 +178,7 @@ func RunUnicorn(fn string, ram map[uint32](uint32), checkIO bool, callback func(
mu
.
MemWrite
(
0
,
dat
)
// inputs
inputFile
:=
fmt
.
Sprintf
(
"%s/input"
,
root
)
inputs
,
_
:=
ioutil
.
ReadFile
(
inputFile
)
inputs
,
_
:=
ioutil
.
ReadFile
(
fmt
.
Sprintf
(
"%s/input"
,
root
))
mu
.
MemWrite
(
0xB0000000
,
inputs
[
0
:
0xc0
])
// load into ram
...
...
@@ -191,7 +190,8 @@ func RunUnicorn(fn string, ram map[uint32](uint32), checkIO bool, callback func(
mu
.
Start
(
0
,
0x5ead0004
)
if
checkIO
{
real
:=
append
([]
byte
{
0x13
,
0x37
,
0xf0
,
0x0d
},
inputs
[
0xc0
:
]
...
)
outputs
,
_
:=
ioutil
.
ReadFile
(
fmt
.
Sprintf
(
"%s/output"
,
root
))
real
:=
append
([]
byte
{
0x13
,
0x37
,
0xf0
,
0x0d
},
outputs
...
)
output
,
_
:=
mu
.
MemRead
(
0xB0000800
,
0x44
)
if
bytes
.
Compare
(
real
,
output
)
!=
0
{
log
.
Fatal
(
"mismatch output"
)
...
...
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