Skip to content

Commit

Permalink
fix state key for saving to watchdb (#87)
Browse files Browse the repository at this point in the history
Co-authored-by: KamiD <[email protected]>
  • Loading branch information
ilovers and KamiD authored Mar 29, 2023
1 parent 450b47a commit 222dfaa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions x/evm/types/state_object_mpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ func (so *stateObject) updateTrie(db ethstate.Database) (updated bool) {
}
updated = true
so.originStorage[key] = value

usedStorage = append(usedStorage, ethcmn.CopyBytes(key[:])) // Copy needed for closure
copyKey := ethcmn.CopyBytes(key[:])
usedStorage = append(usedStorage) // Copy needed for closure
if (value == ethcmn.Hash{}) {
store.Delete(key[:])
if !so.stateDB.ctx.IsCheckTx() {
if so.stateDB.ctx.GetWatcher().Enabled() {
so.stateDB.ctx.GetWatcher().SaveState(so.Address(), key[:], ethcmn.Hash{}.Bytes())
so.stateDB.ctx.GetWatcher().SaveState(so.Address(), copyKey, ethcmn.Hash{}.Bytes())
}
}
} else {
Expand All @@ -161,7 +161,7 @@ func (so *stateObject) updateTrie(db ethstate.Database) (updated bool) {
store.Set(key[:], v)
if !so.stateDB.ctx.IsCheckTx() {
if so.stateDB.ctx.GetWatcher().Enabled() {
so.stateDB.ctx.GetWatcher().SaveState(so.Address(), key[:], v)
so.stateDB.ctx.GetWatcher().SaveState(so.Address(), copyKey, v)
}
}
}
Expand Down

0 comments on commit 222dfaa

Please sign in to comment.