Commit 411aa9c8 authored by George Hotz's avatar George Hotz

check the receipts also

parent e7e3af9f
......@@ -113,12 +113,15 @@ func main() {
panic("wrong uncles for block " + newheader.UncleHash.String() + " " + block.Header().UncleHash.String())
}
_, _, _, err := processor.Process(block, statedb, vmconfig)
// validateState is more complete, gas used + bloom also
receipts, _, _, err := processor.Process(block, statedb, vmconfig)
receiptSha := types.DeriveSha(types.Receipts(receipts), trie.NewStackTrie(nil))
if err != nil {
log.Fatal(err)
}
newroot := statedb.IntermediateRoot(bc.Config().IsEIP158(newheader.Number))
fmt.Println("receipt count", len(receipts), "hash", receiptSha)
fmt.Println("process done with hash", parent.Root, "->", newroot)
oracle.Output(newroot)
oracle.Output(newroot, receiptSha)
}
......@@ -15,6 +15,7 @@ import (
)
var preimages = make(map[common.Hash][]byte)
// only 6 here
var inputs [6]common.Hash
var inputsLoaded bool = false
......@@ -54,9 +55,11 @@ func Halt() {
os.Exit(0)
}
func Output(output common.Hash) {
func Output(output common.Hash, receipts common.Hash) {
ret := byteAt(0x30000800, 0x20)
copy(ret, output.Bytes())
rret := byteAt(0x30000820, 0x20)
copy(rret, receipts.Bytes())
Halt()
}
......
......@@ -184,7 +184,7 @@ func PrefetchCode(blockNumber *big.Int, addrHash common.Hash) {
preimages[hash] = ret
}
var inputs [7]common.Hash
var inputs [8]common.Hash
func Input(index int) common.Hash {
if index < 0 || index > 5 {
......@@ -193,11 +193,12 @@ func Input(index int) common.Hash {
return inputs[index]
}
func Output(output common.Hash) {
if output == inputs[6] {
func Output(output common.Hash, receipts common.Hash) {
if output == inputs[6] && receipts == inputs[7] {
fmt.Println("good transition")
} else {
fmt.Println(output, "!=", inputs[6])
fmt.Println(receipts, "!=", inputs[7])
panic("BAD transition :((")
}
}
......@@ -289,6 +290,7 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
// secret input
inputs[6] = blockHeader.Root
inputs[7] = blockHeader.ReceiptHash
// save the inputs
saveinput := make([]byte, 0)
......
......@@ -187,10 +187,10 @@ func main() {
//fmt.Println(bytecode, jj.Bytecode)
statedb := &StateDB{Bytecode: bytecode}
bc := core.NewBlockChain()
var header types.Header
header.Number = big.NewInt(13284469)
header.Difficulty = common.Big0
bc := core.NewBlockChain(&header)
author := common.Address{}
blockContext := core.NewEVMBlockContext(&header, bc, &author)
txContext := vm.TxContext{}
......
......@@ -375,7 +375,7 @@ except unicorn.UcError:
if not died_well:
raise Exception("program exitted early")
real_hash = binascii.hexlify(inputs[-0x20:])
real_hash = binascii.hexlify(inputs[-0x40:-0x20])
compare_hash = binascii.hexlify(mu.mem_read(0x30000800, 0x20))
print("compare", real_hash, "to computed", compare_hash)
......
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