Commit 05db1a9b authored by George Hotz's avatar George Hotz

store tmp data in /tmp/cannon

parent 77683af8
......@@ -16,7 +16,7 @@ jobs:
- name: Build minigeth
run: |
(cd minigeth/ && go build)
mkdir -p /tmp/eth
mkdir -p /tmp/cannon
- name: Test block 13284491 (0 tx)
run: minigeth/go-ethereum 13284491
- name: Test block 13284469 (few tx)
......
......@@ -49,7 +49,8 @@ func main() {
pkwtrie := trie.NewStackTrie(pkw)
blockNumber, _ := strconv.Atoi(os.Args[1])
oracle.SetRoot(fmt.Sprintf("/tmp/eth/%d", blockNumber))
// TODO: get the chainid
oracle.SetRoot(fmt.Sprintf("/tmp/cannon/0_%d", blockNumber))
oracle.PrefetchBlock(big.NewInt(int64(blockNumber)), true, nil)
oracle.PrefetchBlock(big.NewInt(int64(blockNumber)+1), false, pkwtrie)
hash, err := pkwtrie.Commit()
......
......@@ -14,7 +14,7 @@ import (
)
var preimages = make(map[common.Hash][]byte)
var root = "/tmp/eth"
var root = "/tmp/cannon"
func SetRoot(newRoot string) {
root = newRoot
......
......@@ -34,7 +34,7 @@ func TestCompareUnicornEvm(t *testing.T) {
evmram := make(map[uint32](uint32))
LoadMappedFile(fn, evmram, 0)
inputFile := fmt.Sprintf("/tmp/eth/%d", 13284469)
inputFile := fmt.Sprintf("/tmp/cannon/%d_%d", 0, 13284469)
LoadMappedFile(inputFile, evmram, 0x30000000)
// init registers to 0 in evm
for i := uint32(0xC0000000); i < 0xC0000000+36*4; i += 4 {
......
......@@ -16,7 +16,7 @@ func WriteCheckpoint(ram map[uint32](uint32), root string, step int) {
}
func main() {
root := fmt.Sprintf("/tmp/eth/%d", 13284469)
root := fmt.Sprintf("/tmp/cannon/%d_%d", 0, 13284469)
// step 1, generate the checkpoints every million steps using unicorn
ram := make(map[uint32](uint32))
......
......@@ -124,6 +124,7 @@ func (s *StateDB) GetState(fakeaddr common.Address, hash common.Hash) common.Has
binary.BigEndian.PutUint32(oracle_hash[i:i+4], ram[0x30001000+i])
}
hash := common.BytesToHash(oracle_hash)
// TODO: this is wrong, need root
key := fmt.Sprintf("/tmp/eth/%s", hash)
value, _ := ioutil.ReadFile(key)
......
......@@ -95,7 +95,8 @@ func LoadData(dat []byte, ram map[uint32](uint32), base uint32) {
}
func LoadMappedFile(fn string, ram map[uint32](uint32), base uint32) {
dat, _ := ioutil.ReadFile(fn)
dat, err := ioutil.ReadFile(fn)
check(err)
LoadData(dat, ram, base)
}
......@@ -115,7 +116,7 @@ func RunFull() {
root := RamToTrie(ram)
//ParseNode(root, 0)
ioutil.WriteFile("/tmp/eth/trie.json", TrieToJson(root), 0644)
ioutil.WriteFile("/tmp/cannon/trie.json", TrieToJson(root), 0644)
for k, v := range Preimages {
fmt.Println("AddTrieNode", k)
......
......@@ -159,14 +159,15 @@ func GetHookedUnicorn(root string, ram map[uint32](uint32), callback func(int, u
}
func LoadMappedFileUnicorn(mu uc.Unicorn, fn string, ram map[uint32](uint32), base uint32) {
dat, _ := ioutil.ReadFile(fn)
dat, err := ioutil.ReadFile(fn)
check(err)
LoadData(dat, ram, base)
mu.MemWrite(uint64(base), dat)
}
// reimplement simple.py in go
func RunUnicorn(fn string, ram map[uint32](uint32), checkIO bool, callback func(int, uc.Unicorn, map[uint32](uint32))) {
root := "/tmp/eth/13284469"
root := "/tmp/cannon/0_13284469"
mu := GetHookedUnicorn(root, ram, callback)
// loop forever to match EVM
......
......@@ -19,7 +19,7 @@ func TestTrie(t *testing.T) {
dat := TrieToJson(root)
fmt.Println("serialized length is", len(dat))
ioutil.WriteFile("/tmp/eth/ramtrie.json", dat, 0644)
ioutil.WriteFile("/tmp/cannon/ramtrie.json", dat, 0644)
}
func printRoot(ram map[uint32](uint32)) {
......
#!/bin/bash -e
(cd minigeth/ && go build)
mkdir -p /tmp/eth
mkdir -p /tmp/cannon
# 0 tx: 13284491
# low tx: 13284469
......
const { deploy } = require("../scripts/lib")
const fs = require("fs")
async function main() {
var [c, m, mm] = await deploy()
console.log("deployed at", c.address, m.address, mm.address)
let [c, m, mm] = await deploy()
let json = {
"Challenge": c.address,
"MIPS": m.address,
"MIPSMemory": mm.address,
}
console.log("deployed", json)
}
main()
......
#!/bin/bash -e
(cd minigeth/ && go build)
mkdir -p /tmp/eth
mkdir -p /tmp/cannon
# london starts at 12965000
BLOCK=$1
......
......@@ -25,8 +25,8 @@ describe("Challenge contract", function () {
const assertionRoot = "0x9e0261efe4509912b8862f3d45a0cb8404b99b239247df9c55871bd3844cebbd"
const finalSystemState = "0xf02b4450a07d492c17b4b554851f0dcb12192e2439a507b12fcea8f801a596a6"
let startTrie = JSON.parse(fs.readFileSync("/tmp/eth/13284469/checkpoint_-1.json"))
let finalTrie = JSON.parse(fs.readFileSync("/tmp/eth/13284469/checkpoint_85059435.json"))
let startTrie = JSON.parse(fs.readFileSync("/tmp/cannon/0_13284469/checkpoint_-1.json"))
let finalTrie = JSON.parse(fs.readFileSync("/tmp/cannon/0_13284469/checkpoint_85059435.json"))
while (1) {
try {
......
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