mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-19 01:51:19 +00:00
state: fix GetStorage on blockcache with unknown account
This commit is contained in:
parent
e257307b01
commit
a976721a97
@ -95,9 +95,11 @@ func (cache *BlockCache) GetStorage(addr Word256, key Word256) (value Word256) {
|
|||||||
if removed {
|
if removed {
|
||||||
panic("GetStorage() on removed account")
|
panic("GetStorage() on removed account")
|
||||||
}
|
}
|
||||||
if storage == nil {
|
if acc != nil && storage == nil {
|
||||||
storage = makeStorage(cache.db, acc.StorageRoot)
|
storage = makeStorage(cache.db, acc.StorageRoot)
|
||||||
cache.accounts[string(addr.Prefix(20))] = accountInfo{acc, storage, false, dirty}
|
cache.accounts[string(addr.Prefix(20))] = accountInfo{acc, storage, false, dirty}
|
||||||
|
} else if acc == nil {
|
||||||
|
return Zero256
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load and set cache
|
// Load and set cache
|
||||||
@ -145,6 +147,9 @@ func (cache *BlockCache) Sync() {
|
|||||||
addr, key := Tuple256Split(storageKey)
|
addr, key := Tuple256Split(storageKey)
|
||||||
if addr != curAddr || curAcc == nil {
|
if addr != curAddr || curAcc == nil {
|
||||||
acc, storage, removed, _ := cache.accounts[string(addr.Prefix(20))].unpack()
|
acc, storage, removed, _ := cache.accounts[string(addr.Prefix(20))].unpack()
|
||||||
|
if storage == nil {
|
||||||
|
storage = makeStorage(cache.db, acc.StorageRoot)
|
||||||
|
}
|
||||||
curAddr = addr
|
curAddr = addr
|
||||||
curAcc = acc
|
curAcc = acc
|
||||||
curAccRemoved = removed
|
curAccRemoved = removed
|
||||||
@ -161,6 +166,7 @@ func (cache *BlockCache) Sync() {
|
|||||||
curStorage.Remove(key.Bytes())
|
curStorage.Remove(key.Bytes())
|
||||||
} else {
|
} else {
|
||||||
curStorage.Set(key.Bytes(), value.Bytes())
|
curStorage.Set(key.Bytes(), value.Bytes())
|
||||||
|
cache.accounts[string(addr.Prefix(20))] = accountInfo{curAcc, curStorage, false, true}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user