Commit b91851e0 authored by George Hotz's avatar George Hotz

don't delete from ram trie

parent 71c33ceb
...@@ -32,12 +32,16 @@ func TestCompare(t *testing.T) { ...@@ -32,12 +32,16 @@ func TestCompare(t *testing.T) {
cevm := make(chan []uint32, 1) cevm := make(chan []uint32, 1)
cuni := make(chan []uint32, 1) cuni := make(chan []uint32, 1)
ram := make(map[uint32](uint32)) evmram := make(map[uint32](uint32))
LoadMappedFile(fn, ram, 0) LoadMappedFile(fn, evmram, 0)
inputFile := fmt.Sprintf("/tmp/eth/%d", 13284469) inputFile := fmt.Sprintf("/tmp/eth/%d", 13284469)
LoadMappedFile(inputFile, ram, 0xB0000000) LoadMappedFile(inputFile, evmram, 0xB0000000)
// init registers to 0 in evm
for i := uint32(0xC0000000); i < 0xC0000000+36*4; i += 4 {
WriteRam(evmram, i, 0)
}
go RunWithRam(ram, steps, 0, func(step int, ram map[uint32](uint32)) { go RunWithRam(evmram, steps, 0, func(step int, ram map[uint32](uint32)) {
//fmt.Printf("%d evm %x\n", step, ram[0xc0000080]) //fmt.Printf("%d evm %x\n", step, ram[0xc0000080])
cevm <- RegSerialize(ram) cevm <- RegSerialize(ram)
done.Lock() done.Lock()
...@@ -76,9 +80,9 @@ func TestCompare(t *testing.T) { ...@@ -76,9 +80,9 @@ func TestCompare(t *testing.T) {
// final ram check // final ram check
done.Lock() done.Lock()
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
for k, v := range ram { for k, v := range uniram {
if uniram[k] != v { if val, ok := evmram[k]; !ok || val != v {
fmt.Printf("ram mismatch at %x, evm %x != uni %x\n", k, v, uniram[k]) fmt.Printf("ram mismatch at %x, evm %x != uni %x\n", k, evmram[k], uniram[k])
mismatch = true mismatch = true
} }
} }
......
...@@ -145,11 +145,7 @@ func (s *StateDB) SetState(fakeaddr common.Address, key, value common.Hash) { ...@@ -145,11 +145,7 @@ func (s *StateDB) SetState(fakeaddr common.Address, key, value common.Hash) {
fmt.Println("HOOKED WRITE! ", fmt.Sprintf("%x = %x (at step %d)", addr, dat, pcCount)) fmt.Println("HOOKED WRITE! ", fmt.Sprintf("%x = %x (at step %d)", addr, dat, pcCount))
} }
if dat == 0 { WriteRam(ram, addr, dat)
delete(ram, addr)
} else {
ram[addr] = dat
}
} }
func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addressPresent bool, slotPresent bool) { func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addressPresent bool, slotPresent bool) {
return true, true return true, true
......
...@@ -33,10 +33,14 @@ func WriteBytes(fd int, bytes []byte) { ...@@ -33,10 +33,14 @@ func WriteBytes(fd int, bytes []byte) {
} }
func WriteRam(ram map[uint32](uint32), addr uint32, value uint32) { func WriteRam(ram map[uint32](uint32), addr uint32, value uint32) {
if value != 0 { // we no longer delete from ram, since deleting from tries is hard
ram[addr] = value if value == 0 && false {
} else {
delete(ram, addr) delete(ram, addr)
} else {
/*if addr < 0xc0000000 {
fmt.Printf("store %x = %x\n", addr, value)
}*/
ram[addr] = value
} }
} }
......
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