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
df6dfbb8
Commit
df6dfbb8
authored
Oct 31, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor to use inputhash instead of input
parent
ffe42fb7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
36 deletions
+29
-36
main.go
minigeth/main.go
+13
-6
embedded_mips.go
minigeth/oracle/embedded_mips.go
+4
-23
prefetch.go
minigeth/oracle/prefetch.go
+12
-7
No files found.
minigeth/main.go
View file @
df6dfbb8
...
@@ -60,9 +60,16 @@ func main() {
...
@@ -60,9 +60,16 @@ func main() {
// init secp256k1BytePoints
// init secp256k1BytePoints
crypto
.
S256
()
crypto
.
S256
()
// get inputs
inputBytes
:=
oracle
.
Preimage
(
oracle
.
InputHash
())
var
inputs
[
6
]
common
.
Hash
for
i
:=
0
;
i
<
len
(
inputs
);
i
++
{
inputs
[
i
]
=
common
.
BytesToHash
(
inputBytes
[
i
*
0x20
:
i
*
0x20
+
0x20
])
}
// read start block header
// read start block header
var
parent
types
.
Header
var
parent
types
.
Header
check
(
rlp
.
DecodeBytes
(
oracle
.
Preimage
(
oracle
.
Input
(
0
)
),
&
parent
))
check
(
rlp
.
DecodeBytes
(
oracle
.
Preimage
(
inputs
[
0
]
),
&
parent
))
// read header
// read header
var
newheader
types
.
Header
var
newheader
types
.
Header
...
@@ -72,11 +79,11 @@ func main() {
...
@@ -72,11 +79,11 @@ func main() {
newheader
.
BaseFee
=
misc
.
CalcBaseFee
(
params
.
MainnetChainConfig
,
&
parent
)
newheader
.
BaseFee
=
misc
.
CalcBaseFee
(
params
.
MainnetChainConfig
,
&
parent
)
// from input oracle
// from input oracle
newheader
.
TxHash
=
oracle
.
Input
(
1
)
newheader
.
TxHash
=
inputs
[
1
]
newheader
.
Coinbase
=
common
.
BigToAddress
(
oracle
.
Input
(
2
)
.
Big
())
newheader
.
Coinbase
=
common
.
BigToAddress
(
inputs
[
2
]
.
Big
())
newheader
.
UncleHash
=
oracle
.
Input
(
3
)
newheader
.
UncleHash
=
inputs
[
3
]
newheader
.
GasLimit
=
oracle
.
Input
(
4
)
.
Big
()
.
Uint64
()
newheader
.
GasLimit
=
inputs
[
4
]
.
Big
()
.
Uint64
()
newheader
.
Time
=
oracle
.
Input
(
5
)
.
Big
()
.
Uint64
()
newheader
.
Time
=
inputs
[
5
]
.
Big
()
.
Uint64
()
bc
:=
core
.
NewBlockChain
(
&
parent
)
bc
:=
core
.
NewBlockChain
(
&
parent
)
database
:=
state
.
NewDatabase
(
parent
)
database
:=
state
.
NewDatabase
(
parent
)
...
...
minigeth/oracle/embedded_mips.go
View file @
df6dfbb8
...
@@ -16,10 +16,6 @@ import (
...
@@ -16,10 +16,6 @@ import (
var
preimages
=
make
(
map
[
common
.
Hash
][]
byte
)
var
preimages
=
make
(
map
[
common
.
Hash
][]
byte
)
// only 6 here
var
inputs
[
6
]
common
.
Hash
var
inputsLoaded
bool
=
false
func
byteAt
(
addr
uint64
,
length
int
)
[]
byte
{
func
byteAt
(
addr
uint64
,
length
int
)
[]
byte
{
var
ret
[]
byte
var
ret
[]
byte
bh
:=
(
*
reflect
.
SliceHeader
)(
unsafe
.
Pointer
(
&
ret
))
bh
:=
(
*
reflect
.
SliceHeader
)(
unsafe
.
Pointer
(
&
ret
))
...
@@ -29,25 +25,10 @@ func byteAt(addr uint64, length int) []byte {
...
@@ -29,25 +25,10 @@ func byteAt(addr uint64, length int) []byte {
return
ret
return
ret
}
}
func
Input
(
index
int
)
common
.
Hash
{
func
InputHash
()
common
.
Hash
{
if
index
<
0
||
index
>
6
{
ret
:=
byteAt
(
0xB0000000
,
0x20
)
panic
(
"bad input index"
)
os
.
Stderr
.
WriteString
(
"********* on chain starts here *********
\n
"
)
}
return
common
.
BytesToHash
(
ret
)
if
!
inputsLoaded
{
// before this isn't run on chain (confirm this isn't cached)
// does this interact with the GC?
ret
:=
byteAt
(
0xB0000000
,
len
(
inputs
)
*
0x20
)
os
.
Stderr
.
WriteString
(
"********* on chain starts here *********
\n
"
)
for
i
:=
0
;
i
<
len
(
inputs
);
i
++
{
inputs
[
i
]
=
common
.
BytesToHash
(
ret
[
i
*
0x20
:
i
*
0x20
+
0x20
])
//fmt.Println(i, inputs[i])
}
inputsLoaded
=
true
}
return
inputs
[
index
]
}
}
func
Halt
()
{
func
Halt
()
{
...
...
minigeth/oracle/prefetch.go
View file @
df6dfbb8
...
@@ -187,13 +187,15 @@ func PrefetchCode(blockNumber *big.Int, addrHash common.Hash) {
...
@@ -187,13 +187,15 @@ func PrefetchCode(blockNumber *big.Int, addrHash common.Hash) {
preimages
[
hash
]
=
ret
preimages
[
hash
]
=
ret
}
}
var
inputs
[
6
]
common
.
Hash
var
inputhash
common
.
Hash
var
outputs
[
2
]
common
.
Hash
func
Input
(
index
int
)
common
.
Hash
{
func
Input
Hash
(
)
common
.
Hash
{
return
input
s
[
index
]
return
input
hash
}
}
var
inputs
[
6
]
common
.
Hash
var
outputs
[
2
]
common
.
Hash
func
Output
(
output
common
.
Hash
,
receipts
common
.
Hash
)
{
func
Output
(
output
common
.
Hash
,
receipts
common
.
Hash
)
{
if
receipts
!=
outputs
[
1
]
{
if
receipts
!=
outputs
[
1
]
{
fmt
.
Println
(
"WARNING, receipts don't match"
,
receipts
,
"!="
,
outputs
[
1
])
fmt
.
Println
(
"WARNING, receipts don't match"
,
receipts
,
"!="
,
outputs
[
1
])
...
@@ -282,8 +284,8 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
...
@@ -282,8 +284,8 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
}
}
// second block
// second block
if
blockHeader
.
ParentHash
!=
Input
(
0
)
{
if
blockHeader
.
ParentHash
!=
inputs
[
0
]
{
fmt
.
Println
(
blockHeader
.
ParentHash
,
Input
(
0
)
)
fmt
.
Println
(
blockHeader
.
ParentHash
,
inputs
[
0
]
)
panic
(
"block transition isn't correct"
)
panic
(
"block transition isn't correct"
)
}
}
inputs
[
1
]
=
blockHeader
.
TxHash
inputs
[
1
]
=
blockHeader
.
TxHash
...
@@ -297,7 +299,10 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
...
@@ -297,7 +299,10 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
for
i
:=
0
;
i
<
len
(
inputs
);
i
++
{
for
i
:=
0
;
i
<
len
(
inputs
);
i
++
{
saveinput
=
append
(
saveinput
,
inputs
[
i
]
.
Bytes
()[
:
]
...
)
saveinput
=
append
(
saveinput
,
inputs
[
i
]
.
Bytes
()[
:
]
...
)
}
}
ioutil
.
WriteFile
(
fmt
.
Sprintf
(
"%s/input"
,
root
),
saveinput
,
0644
)
inputhash
=
crypto
.
Keccak256Hash
(
saveinput
)
preimages
[
inputhash
]
=
saveinput
ioutil
.
WriteFile
(
fmt
.
Sprintf
(
"%s/input"
,
root
),
inputhash
.
Bytes
(),
0644
)
//ioutil.WriteFile(fmt.Sprintf("%s/input", root), saveinput, 0644)
// secret input aka output
// secret input aka output
outputs
[
0
]
=
blockHeader
.
Root
outputs
[
0
]
=
blockHeader
.
Root
...
...
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