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

store tmp data in /tmp/cannon

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