Skip to content

Commit 1fd8ef3

Browse files
yihuangaljo242
andauthored
fix: evmCoinInfo not exists in historical state (cosmos#790)
* Problem: evmCoinInfo not exists in historical state (cosmos#16) * support default evmCoinInfo * changelog * Update CHANGELOG.md --------- Co-authored-by: Alex | Cosmos Labs <[email protected]>
1 parent 1026be4 commit 1fd8ef3

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- [\#756](https://github.com/cosmos/evm/pull/756) Fix error message typo in NewMsgCancelProposal.
2323
- [\#772](https://github.com/cosmos/evm/pull/772) Avoid panic on close if evm mempool not used.
2424
- [\#774](https://github.com/cosmos/evm/pull/774) Emit proper allowance amount in erc20 event.
25+
- [\#790](https://github.com/cosmos/evm/pull/790) fix panic in historical query due to missing EvmCoinInfo.
2526

2627
## v0.5.0
2728

x/vm/keeper/coin_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (k Keeper) GetEvmCoinInfo(ctx sdk.Context) (coinInfo types.EvmCoinInfo) {
5656
store := ctx.KVStore(k.storeKey)
5757
bz := store.Get(types.KeyPrefixEvmCoinInfo)
5858
if bz == nil {
59-
return coinInfo
59+
return k.defaultEvmCoinInfo
6060
}
6161
k.cdc.MustUnmarshal(bz, &coinInfo)
6262
return

x/vm/keeper/keeper.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ type Keeper struct {
8585
// virtualFeeCollection enabling will use "Virtual" methods from the bank module to accumulate
8686
// fees to the fee collector module in the endBlocker instead of using regular sends during tx execution.
8787
virtualFeeCollection bool
88+
89+
// defaultEvmCoinInfo is the default EVM coin info used when evmCoinInfo is not initialized in the state,
90+
// mainly for historical queries.
91+
defaultEvmCoinInfo types.EvmCoinInfo
8892
}
8993

9094
// NewKeeper generates new evm module keeper
@@ -154,6 +158,12 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
154158
return ctx.Logger().With("module", types.ModuleName)
155159
}
156160

161+
// WithDefaultEvmCoinInfo set default EvmCoinInfo
162+
func (k *Keeper) WithDefaultEvmCoinInfo(coinInfo types.EvmCoinInfo) *Keeper {
163+
k.defaultEvmCoinInfo = coinInfo
164+
return k
165+
}
166+
157167
// ----------------------------------------------------------------------------
158168
// Block Bloom
159169
// Required by Web3 API.

0 commit comments

Comments
 (0)