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 23:39:21 +08:00 committed by GitHub
parent 9659b81ee1
commit d27810b6b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -60,6 +60,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes
* (evm) [\#674](https://github.com/cosmos/ethermint/issues/674) Reset all cache after account data has been committed in `EndBlock` to make sure every node state consistent
* (evm) [\#661](https://github.com/cosmos/ethermint/pull/661) Set nonce to the EVM account on genesis initialization.
* (rpc) [\#648](https://github.com/cosmos/ethermint/issues/648) Fix block cumulative gas used value.
* (evm) [\#621](https://github.com/cosmos/ethermint/issues/621) EVM `GenesisAccount` fields now share the same format as the auth module `Account`.

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())