Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
evm: reset cache after csdb is committed (#676)
Browse files Browse the repository at this point in the history
* reset after commit, fix wrong apphash when restart a node with snapshot

* remove ClearStateObjects

* add comment, edit the CHANGELOG.md
  • Loading branch information
KamiD authored Dec 30, 2020
1 parent 9659b81 commit d27810b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
9 changes: 6 additions & 3 deletions x/evm/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit d27810b

Please sign in to comment.