evm: reset cache after csdb is committed (#676)

* reset after commit, fix wrong apphash when restart a node with snapshot

* remove ClearStateObjects

* add comment, edit the CHANGELOG.md
This commit is contained in:
KamiD
2020-12-30 12:39:21 -03:00
committed by GitHub
parent 9659b81ee1
commit d27810b6b5
2 changed files with 7 additions and 3 deletions
+6 -3
View File
@@ -44,14 +44,17 @@ func (k Keeper) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.Valid
// Update account balances before committing other parts of state
k.UpdateAccounts(ctx)
root, err := k.Commit(ctx, true)
// Commit state objects to KV store
if _, err := k.Commit(ctx, true); err != nil {
if err != nil {
k.Logger(ctx).Error("failed to commit state objects", "error", err, "height", ctx.BlockHeight())
panic(err)
}
// Clear accounts cache after account data has been committed
k.ClearStateObjects(ctx)
// reset all cache after account data has been committed, that make sure node state consistent
if err = k.Reset(ctx, root); err != nil {
panic(err)
}
// set the block bloom filter bytes to store
bloom := ethtypes.BytesToBloom(k.Bloom.Bytes())