Commit 1ffd01e1 authored by George Hotz's avatar George Hotz

PrefetchAccount

parent 0ea7d332
...@@ -18,9 +18,9 @@ It's half geth, half of what I think truebit was supposed to be. When it's done, ...@@ -18,9 +18,9 @@ It's half geth, half of what I think truebit was supposed to be. When it's done,
## State Oracle API ## State Oracle API
hash -> value such that hash(value) == hash Preimage(hash) -> value # hash(value) == hash
This works for the three types of state in ethereum, Accounts, Storage, and Code. PrefetchAccount, PrefetchStorage, PrefetchCode can be NOP in the VM
## License ## License
......
...@@ -513,7 +513,7 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject { ...@@ -513,7 +513,7 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject {
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
defer func(start time.Time) { s.AccountReads += time.Since(start) }(time.Now()) defer func(start time.Time) { s.AccountReads += time.Since(start) }(time.Now())
} }
oracle.PrefetchAddress(s.db.BlockNumber, addr) oracle.PrefetchAccount(s.db.BlockNumber, addr)
enc, err := s.trie.TryGet(addr.Bytes()) enc, err := s.trie.TryGet(addr.Bytes())
if err != nil { if err != nil {
s.setError(fmt.Errorf("getDeleteStateObject (%x) error: %v", addr.Bytes(), err)) s.setError(fmt.Errorf("getDeleteStateObject (%x) error: %v", addr.Bytes(), err))
......
...@@ -110,7 +110,7 @@ func PrefetchStorage(blockNumber *big.Int, addr common.Address, skey common.Hash ...@@ -110,7 +110,7 @@ func PrefetchStorage(blockNumber *big.Int, addr common.Address, skey common.Hash
} }
} }
func PrefetchAddress(blockNumber *big.Int, addr common.Address) { func PrefetchAccount(blockNumber *big.Int, addr common.Address) {
key := fmt.Sprintf("proof_%d_%s", blockNumber, addr) key := fmt.Sprintf("proof_%d_%s", blockNumber, addr)
if cached[key] { if cached[key] {
return return
......
...@@ -34,7 +34,7 @@ func NewDatabase(header types.Header) Database { ...@@ -34,7 +34,7 @@ func NewDatabase(header types.Header) Database {
triedb := Database{BlockNumber: header.Number, Root: header.Root} triedb := Database{BlockNumber: header.Number, Root: header.Root}
//triedb.preimages = make(map[common.Hash][]byte) //triedb.preimages = make(map[common.Hash][]byte)
fmt.Println("init database") fmt.Println("init database")
oracle.PrefetchAddress(header.Number, common.Address{}) oracle.PrefetchAccount(header.Number, common.Address{})
//panic("preseed") //panic("preseed")
return triedb return triedb
......
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