Commit 57f989f2 authored by George Hotz's avatar George Hotz

this should fix CI

parent 21f5e0fe
......@@ -8,12 +8,47 @@ import (
"io/ioutil"
"math/big"
"os"
"strconv"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
)
var preimages = make(map[common.Hash][]byte)
var inputs [6]common.Hash
var inputsLoaded bool = false
func Input(index int) common.Hash {
if index < 0 || index > 5 {
panic("bad input index")
}
if !inputsLoaded {
blockNumber, _ := strconv.Atoi(os.Args[1])
f, err := os.Open(fmt.Sprintf("/tmp/eth/%d", blockNumber))
if err != nil {
panic("missing inputs")
}
defer f.Close()
ret, err := ioutil.ReadAll(f)
for i := 0; i < len(inputs); i++ {
inputs[i] = common.BytesToHash(ret[i*0x20 : i*0x20+0x20])
}
inputsLoaded = true
}
return inputs[index]
}
func Output(output common.Hash) {
if output == inputs[5] {
fmt.Println("good transition")
} else {
fmt.Println(output, "!=", inputs[5])
panic("BAD transition :((")
}
}
func Preimage(hash common.Hash) []byte {
val, ok := preimages[hash]
......
......@@ -159,18 +159,20 @@ func PrefetchCode(blockNumber *big.Int, addrHash common.Hash) {
preimages[hash] = ret
}
var inputs [5]common.Hash
var realoutput common.Hash
var inputs [6]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) {
if output == realoutput {
if output == inputs[5] {
fmt.Println("good transition")
} else {
fmt.Println(output, "!=", realoutput)
fmt.Println(output, "!=", inputs[5])
panic("BAD transition :((")
}
}
......@@ -211,7 +213,17 @@ 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)))
realoutput = blockHeader.Root
// secret input
inputs[5] = blockHeader.Root
// save the inputs
saveinput := make([]byte, 0)
for i := 0; i < len(inputs); i++ {
saveinput = append(saveinput, inputs[i].Bytes()[:]...)
}
key := fmt.Sprintf("/tmp/eth/%d", blockNumber.Uint64()-1)
ioutil.WriteFile(key, saveinput, 0644)
txs := make([]*types.Transaction, len(jr.Result.Transactions))
for i := 0; i < len(jr.Result.Transactions); i++ {
......
......@@ -286,7 +286,7 @@ mu.mem_write(SIZE-0x2000, struct.pack(">IIIIIIIII",
_AT_PAGESZ, 0x1000, 0)) # auxv
# block
mu.mem_write(SIZE-0x800, b"13284491\x00")
mu.mem_write(SIZE-0x800, b"13284469\x00")
#mu.mem_write(SIZE-0x800, b"13284469\x00")
mu.mem_write(SIZE-0x400, b"GOGC=off\x00")
......
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