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
ef0ac994
Commit
ef0ac994
authored
Sep 26, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add timestamp to input oracle
parent
ac204c7e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
26 deletions
+10
-26
Challenge.sol
contracts/Challenge.sol
+2
-1
main.go
minigeth/main.go
+1
-0
embedded_mips.go
minigeth/oracle/embedded_mips.go
+2
-21
prefetch.go
minigeth/oracle/prefetch.go
+4
-3
trie.go
minigeth/trie/trie.go
+1
-1
No files found.
contracts/Challenge.sol
View file @
ef0ac994
...
...
@@ -92,13 +92,14 @@ contract Challenge {
// load starting info into the input oracle
// we both agree at the beginning
// the first instruction executed in MIPS should be an access of startState
// parentblockhash, txhash, coinbase, unclehash, gaslimit
// parentblockhash, txhash, coinbase, unclehash, gaslimit
, time
bytes32 startState = GlobalStartState;
startState = writeBytes32(startState, 0x30000000, parentHash);
startState = writeBytes32(startState, 0x30000020, Lib_RLPReader.readBytes32(blockNp1[4]));
startState = writeBytes32(startState, 0x30000040, bytes32(uint256(Lib_RLPReader.readAddress(blockNp1[2]))));
startState = writeBytes32(startState, 0x30000060, Lib_RLPReader.readBytes32(blockNp1[1]));
startState = writeBytes32(startState, 0x30000080, bytes32(Lib_RLPReader.readUint256(blockNp1[9])));
startState = writeBytes32(startState, 0x300000a0, bytes32(Lib_RLPReader.readUint256(blockNp1[11])));
// confirm the finalSystemHash asserts the state you claim (in $t0-$t7) and the machine is stopped
// you must load these proofs into MIPS before calling this
...
...
minigeth/main.go
View file @
ef0ac994
...
...
@@ -59,6 +59,7 @@ func main() {
newheader
.
Coinbase
=
common
.
BigToAddress
(
oracle
.
Input
(
2
)
.
Big
())
newheader
.
UncleHash
=
oracle
.
Input
(
3
)
newheader
.
GasLimit
=
oracle
.
Input
(
4
)
.
Big
()
.
Uint64
()
newheader
.
Time
=
oracle
.
Input
(
5
)
.
Big
()
.
Uint64
()
bc
:=
core
.
NewBlockChain
()
database
:=
state
.
NewDatabase
(
parent
)
...
...
minigeth/oracle/embedded_mips.go
View file @
ef0ac994
...
...
@@ -15,7 +15,7 @@ import (
)
var
preimages
=
make
(
map
[
common
.
Hash
][]
byte
)
var
inputs
[
6
]
common
.
Hash
var
inputs
[
7
]
common
.
Hash
var
inputsLoaded
bool
=
false
func
byteAt
(
addr
uint64
,
length
int
)
[]
byte
{
...
...
@@ -28,7 +28,7 @@ func byteAt(addr uint64, length int) []byte {
}
func
Input
(
index
int
)
common
.
Hash
{
if
index
<
0
||
index
>
5
{
if
index
<
0
||
index
>
6
{
panic
(
"bad input index"
)
}
if
!
inputsLoaded
{
...
...
@@ -56,31 +56,12 @@ func Halt() {
func
Output
(
output
common
.
Hash
)
{
ret
:=
byteAt
(
0x30000800
,
0x20
)
copy
(
ret
,
output
.
Bytes
())
/*if output == inputs[5] {
fmt.Println("good transition")
} else {
fmt.Println(output, "!=", inputs[5])
panic("BAD transition :((")
}*/
Halt
()
}
func
Preimage
(
hash
common
.
Hash
)
[]
byte
{
val
,
ok
:=
preimages
[
hash
]
if
!
ok
{
/*f, err := os.Open(fmt.Sprintf("/tmp/eth/%s", hash))
if err != nil {
panic("missing preimage")
}
defer f.Close()
ret, err := ioutil.ReadAll(f)
if err != nil {
panic("preimage read failed")
}*/
// load in hash
preImageHash
:=
byteAt
(
0x30001000
,
0x20
)
copy
(
preImageHash
,
hash
.
Bytes
())
...
...
minigeth/oracle/prefetch.go
View file @
ef0ac994
...
...
@@ -178,7 +178,7 @@ func PrefetchCode(blockNumber *big.Int, addrHash common.Hash) {
preimages
[
hash
]
=
ret
}
var
inputs
[
6
]
common
.
Hash
var
inputs
[
7
]
common
.
Hash
func
Input
(
index
int
)
common
.
Hash
{
if
index
<
0
||
index
>
5
{
...
...
@@ -188,7 +188,7 @@ func Input(index int) common.Hash {
}
func
Output
(
output
common
.
Hash
)
{
if
output
==
inputs
[
5
]
{
if
output
==
inputs
[
6
]
{
fmt
.
Println
(
"good transition"
)
}
else
{
fmt
.
Println
(
output
,
"!="
,
inputs
[
5
])
...
...
@@ -232,9 +232,10 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
inputs
[
2
]
=
blockHeader
.
Coinbase
.
Hash
()
inputs
[
3
]
=
blockHeader
.
UncleHash
inputs
[
4
]
=
common
.
BigToHash
(
big
.
NewInt
(
int64
(
blockHeader
.
GasLimit
)))
inputs
[
5
]
=
common
.
BigToHash
(
big
.
NewInt
(
int64
(
blockHeader
.
Time
)))
// secret input
inputs
[
5
]
=
blockHeader
.
Root
inputs
[
6
]
=
blockHeader
.
Root
// save the inputs
saveinput
:=
make
([]
byte
,
0
)
...
...
minigeth/trie/trie.go
View file @
ef0ac994
...
...
@@ -435,7 +435,7 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
}
if
pos
>=
0
{
if
pos
!=
16
{
fmt
.
Println
(
"delete fails here"
,
pos
,
n
.
Children
,
prefix
,
n
.
Children
[
pos
])
//
fmt.Println("delete fails here", pos, n.Children, prefix, n.Children[pos])
// If the remaining entry is a short node, it replaces
// n and its key gets the missing nibble tacked to the
// front. This avoids creating an invalid
...
...
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