Commit ef0ac994 authored by George Hotz's avatar George Hotz

add timestamp to input oracle

parent ac204c7e
......@@ -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
......
......@@ -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)
......
......@@ -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())
......
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment