Skip to content

Commit

Permalink
Merge pull request #7 from tendermint/vm_fixes
Browse files Browse the repository at this point in the history
state: fix GetStorage on blockcache with unknown account
  • Loading branch information
ebuchman committed Mar 31, 2015
2 parents e257307 + abe570d commit 6a570cc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion state/block_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ func (cache *BlockCache) GetStorage(addr Word256, key Word256) (value Word256) {
if removed {
panic("GetStorage() on removed account")
}
if storage == nil {
if acc != nil && storage == nil {
storage = makeStorage(cache.db, acc.StorageRoot)
cache.accounts[string(addr.Prefix(20))] = accountInfo{acc, storage, false, dirty}
} else if acc == nil {
return Zero256
}

// Load and set cache
Expand Down Expand Up @@ -145,6 +147,9 @@ func (cache *BlockCache) Sync() {
addr, key := Tuple256Split(storageKey)
if addr != curAddr || curAcc == nil {
acc, storage, removed, _ := cache.accounts[string(addr.Prefix(20))].unpack()
if storage == nil {
storage = makeStorage(cache.db, acc.StorageRoot)
}
curAddr = addr
curAcc = acc
curAccRemoved = removed
Expand All @@ -161,6 +166,7 @@ func (cache *BlockCache) Sync() {
curStorage.Remove(key.Bytes())
} else {
curStorage.Set(key.Bytes(), value.Bytes())
cache.accounts[string(addr.Prefix(20))] = accountInfo{curAcc, curStorage, false, true}
}
}

Expand Down

0 comments on commit 6a570cc

Please sign in to comment.