Commit 20112775 authored by George Hotz's avatar George Hotz

does this make the test work?

parent 5da909f8
......@@ -34,8 +34,9 @@ func TestCompareUnicornEvm(t *testing.T) {
evmram := make(map[uint32](uint32))
LoadMappedFile(fn, evmram, 0)
inputFile := fmt.Sprintf("/tmp/cannon/%d_%d/input", 0, 13284469)
LoadMappedFile(inputFile, evmram, 0x30000000)
// not for test.bin
/*inputFile := fmt.Sprintf("/tmp/cannon/%d_%d/input", 0, 13284469)
LoadMappedFile(inputFile, evmram, 0x30000000)*/
// init registers to 0 in evm
for i := uint32(0xC0000000); i < 0xC0000000+36*4; i += 4 {
WriteRam(evmram, i, 0)
......
......@@ -9,9 +9,9 @@ import (
uc "github.com/unicorn-engine/unicorn/bindings/go/unicorn"
)
func WriteCheckpoint(ram map[uint32](uint32), fn string) {
func WriteCheckpoint(ram map[uint32](uint32), fn string, step int) {
trieroot := RamToTrie(ram)
dat := TrieToJson(trieroot)
dat := TrieToJson(trieroot, step)
fmt.Printf("writing %s len %d with root %s\n", fn, len(dat), trieroot)
ioutil.WriteFile(fn, dat, 0644)
}
......@@ -32,7 +32,7 @@ func main() {
if step%10000000 == 0 {
SyncRegs(mu, ram)
fn := fmt.Sprintf("%s/checkpoint_%d.json", root, step)
WriteCheckpoint(ram, fn)
WriteCheckpoint(ram, fn, step)
}
lastStep = step
})
......@@ -40,7 +40,7 @@ func main() {
ZeroRegisters(ram)
// not ready for golden yet
LoadMappedFileUnicorn(mu, "mipigo/minigeth.bin", ram, 0)
WriteCheckpoint(ram, "/tmp/cannon/golden.json")
WriteCheckpoint(ram, "/tmp/cannon/golden.json", -1)
if root == "" {
fmt.Println("exiting early without a block number")
os.Exit(0)
......@@ -50,7 +50,7 @@ func main() {
mu.Start(0, 0x5ead0004)
SyncRegs(mu, ram)
WriteCheckpoint(ram, fmt.Sprintf("%s/checkpoint_%d.json", root, lastStep))
WriteCheckpoint(ram, fmt.Sprintf("%s/checkpoint_final.json", root), lastStep)
// step 2 (optional), validate each 1 million chunk in EVM
......
......@@ -116,7 +116,7 @@ func RunFull() {
root := RamToTrie(ram)
//ParseNode(root, 0)
ioutil.WriteFile("/tmp/cannon/trie.json", TrieToJson(root), 0644)
ioutil.WriteFile("/tmp/cannon/trie.json", TrieToJson(root, -1), 0644)
for k, v := range Preimages {
fmt.Println("AddTrieNode", k)
......
......@@ -19,11 +19,12 @@ var Preimages = make(map[common.Hash][]byte)
type Jtree struct {
Root common.Hash `json:"root"`
Step int `json:"step"`
Preimages map[common.Hash][]byte `json:"preimages"`
}
func TrieToJson(root common.Hash) []byte {
b, err := json.Marshal(Jtree{Preimages: Preimages, Root: root})
func TrieToJson(root common.Hash, step int) []byte {
b, err := json.Marshal(Jtree{Preimages: Preimages, Step: step, Root: root})
check(err)
return b
}
......
......@@ -17,7 +17,7 @@ func TestTrie(t *testing.T) {
root := RamToTrie(ram)
//ParseNode(root, 0)
dat := TrieToJson(root)
dat := TrieToJson(root, -1)
fmt.Println("serialized length is", len(dat))
ioutil.WriteFile("/tmp/cannon/ramtrie.json", dat, 0644)
}
......
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