Skip to content
This repository was archived by the owner on Apr 4, 2024. It is now read-only.

Commit f43e8c6

Browse files
GAtom22mergify[bot]
authored andcommitted
refactor(params): store all params under one key in evm module (#1617)
* refactor(params): store all params under one key in evm module * refactor(params): add changelog entry * refactor(params): update based on review comments. Remove params getter functions * refactor(params): refactor params store key * refactor(params): remove unnecessary store keys * refactor(params): add paramSetPairs for backwards compatibility * Update CHANGELOG.md * refactor(params): add license to params_legacy file * Apply suggestions from code review * fix(evm): handle RC1 params during migration (#1624) * fix(evm): handle RC1 params during migration * migration * fix: test case updated for RC1 * v5 migration * tests * tests pt2 * comment * execute make proto-all Co-authored-by: Vladislav Varadinov <vladislav.varadinov@gmail.com> Co-authored-by: MalteHerrmann <malte@evmos.org> * Apply suggestions from code review * rm dup vars Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Vladislav Varadinov <vladislav.varadinov@gmail.com> Co-authored-by: MalteHerrmann <malte@evmos.org> (cherry picked from commit f07b14f) # Conflicts: # CHANGELOG.md
1 parent 64e80be commit f43e8c6

29 files changed

+1317
-1373
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,23 @@ Ref: https://keepachangelog.com/en/1.0.0/
3636

3737
# Changelog
3838

39+
<<<<<<< HEAD
3940
## [v0.21.0-rc2] - 2022-01-20
41+
=======
42+
## Unreleased
43+
44+
### Bug Fixes
45+
46+
* (rpc) [#1613](https://github.com/evmos/ethermint/pull/1613) Change the default json-rpc listen address to localhost.
47+
* (upgrade) [#1617](https://github.com/evmos/ethermint/pull/1617) Refactor `evm` module's parameters to store them under a single store key
48+
* (rpc) [#1611](https://github.com/evmos/ethermint/pull/1611) Add missing next fee in fee history, fix wrong oldestBlock and align earliest input as ethereum.
49+
50+
### Improvements
51+
52+
* (cli) [#1615](https://github.com/evmos/ethermint/pull/1615) Support customize db opener in `StartCmd`.
53+
54+
## [v0.21.0-rc1] - 2022-1-13
55+
>>>>>>> f07b14f1 (refactor(params): store all params under one key in evm module (#1617))
4056
4157
### State Machine Breaking
4258

app/ante/eth.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula
149149
return next(newCtx, tx, simulate)
150150
}
151151

152-
chainCfg := egcd.evmKeeper.GetChainConfig(ctx)
152+
evmParams := egcd.evmKeeper.GetParams(ctx)
153+
chainCfg := evmParams.GetChainConfig()
153154
ethCfg := chainCfg.EthereumConfig(egcd.evmKeeper.ChainID())
154155

155156
blockHeight := big.NewInt(ctx.BlockHeight())
@@ -183,7 +184,7 @@ func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula
183184
gasWanted += txData.GetGas()
184185
}
185186

186-
evmDenom := egcd.evmKeeper.GetEVMDenom(ctx)
187+
evmDenom := evmParams.GetEvmDenom()
187188

188189
fees, err := keeper.VerifyFee(txData, evmDenom, baseFee, homestead, istanbul, ctx.IsCheckTx())
189190
if err != nil {

app/ante/fee_market.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ func NewGasWantedDecorator(
4242
}
4343

4444
func (gwd GasWantedDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
45-
chainCfg := gwd.evmKeeper.GetChainConfig(ctx)
45+
evmParams := gwd.evmKeeper.GetParams(ctx)
46+
chainCfg := evmParams.GetChainConfig()
4647
ethCfg := chainCfg.EthereumConfig(gwd.evmKeeper.ChainID())
4748

4849
blockHeight := big.NewInt(ctx.BlockHeight())

app/ante/fees.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ func (mpd MinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
8888
if minGasPrice.IsZero() || simulate {
8989
return next(ctx, tx, simulate)
9090
}
91-
92-
evmDenom := mpd.evmKeeper.GetEVMDenom(ctx)
91+
evmParams := mpd.evmKeeper.GetParams(ctx)
92+
evmDenom := evmParams.GetEvmDenom()
9393
minGasPrices := sdk.DecCoins{
9494
{
9595
Denom: evmDenom,
@@ -133,7 +133,8 @@ func (empd EthMinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul
133133
return next(ctx, tx, simulate)
134134
}
135135

136-
chainCfg := empd.evmKeeper.GetChainConfig(ctx)
136+
evmParams := empd.evmKeeper.GetParams(ctx)
137+
chainCfg := evmParams.GetChainConfig()
137138
ethCfg := chainCfg.EthereumConfig(empd.evmKeeper.ChainID())
138139
baseFee := empd.evmKeeper.GetBaseFee(ctx, ethCfg)
139140

@@ -191,7 +192,8 @@ func (mfd EthMempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat
191192
if !ctx.IsCheckTx() || simulate {
192193
return next(ctx, tx, simulate)
193194
}
194-
chainCfg := mfd.evmKeeper.GetChainConfig(ctx)
195+
evmParams := mfd.evmKeeper.GetParams(ctx)
196+
chainCfg := evmParams.GetChainConfig()
195197
ethCfg := chainCfg.EthereumConfig(mfd.evmKeeper.ChainID())
196198

197199
baseFee := mfd.evmKeeper.GetBaseFee(ctx, ethCfg)
@@ -200,7 +202,7 @@ func (mfd EthMempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat
200202
return next(ctx, tx, simulate)
201203
}
202204

203-
evmDenom := mfd.evmKeeper.GetEVMDenom(ctx)
205+
evmDenom := evmParams.GetEvmDenom()
204206
minGasPrice := ctx.MinGasPrices().AmountOf(evmDenom)
205207

206208
for _, msg := range tx.GetMsgs() {

app/ante/interfaces.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ type EVMKeeper interface {
4949
GetBalance(ctx sdk.Context, addr common.Address) *big.Int
5050
ResetTransientGasUsed(ctx sdk.Context)
5151
GetTxIndexTransient(ctx sdk.Context) uint64
52-
GetChainConfig(ctx sdk.Context) evmtypes.ChainConfig
53-
GetAllowUnprotectedTxs(ctx sdk.Context) bool
54-
GetEVMDenom(ctx sdk.Context) string
55-
GetEnableCall(ctx sdk.Context) bool
56-
GetEnableCreate(ctx sdk.Context) bool
52+
GetParams(ctx sdk.Context) evmtypes.Params
5753
}
5854

5955
type protoTxProvider interface {

app/ante/setup.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,14 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu
152152
txFee := sdk.Coins{}
153153
txGasLimit := uint64(0)
154154

155-
chainCfg := vbd.evmKeeper.GetChainConfig(ctx)
155+
evmParams := vbd.evmKeeper.GetParams(ctx)
156+
chainCfg := evmParams.GetChainConfig()
156157
chainID := vbd.evmKeeper.ChainID()
157158
ethCfg := chainCfg.EthereumConfig(chainID)
158159
baseFee := vbd.evmKeeper.GetBaseFee(ctx, ethCfg)
159-
enableCreate := vbd.evmKeeper.GetEnableCreate(ctx)
160-
enableCall := vbd.evmKeeper.GetEnableCall(ctx)
161-
evmDenom := vbd.evmKeeper.GetEVMDenom(ctx)
160+
enableCreate := evmParams.GetEnableCreate()
161+
enableCall := evmParams.GetEnableCall()
162+
evmDenom := evmParams.GetEvmDenom()
162163

163164
for _, msg := range protoTx.GetMsgs() {
164165
msgEthTx, ok := msg.(*evmtypes.MsgEthereumTx)

app/ante/sigverify.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ func NewEthSigVerificationDecorator(ek EVMKeeper) EthSigVerificationDecorator {
4444
// won't see the error message.
4545
func (esvd EthSigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
4646
chainID := esvd.evmKeeper.ChainID()
47-
chainCfg := esvd.evmKeeper.GetChainConfig(ctx)
47+
evmParams := esvd.evmKeeper.GetParams(ctx)
48+
chainCfg := evmParams.GetChainConfig()
4849
ethCfg := chainCfg.EthereumConfig(chainID)
4950
blockNum := big.NewInt(ctx.BlockHeight())
5051
signer := ethtypes.MakeSigner(ethCfg, blockNum)
@@ -55,7 +56,7 @@ func (esvd EthSigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, s
5556
return ctx, errorsmod.Wrapf(errortypes.ErrUnknownRequest, "invalid message type %T, expected %T", msg, (*evmtypes.MsgEthereumTx)(nil))
5657
}
5758

58-
allowUnprotectedTxs := esvd.evmKeeper.GetAllowUnprotectedTxs(ctx)
59+
allowUnprotectedTxs := evmParams.GetAllowUnprotectedTxs()
5960
ethTx := msgEthTx.AsTransaction()
6061
if !allowUnprotectedTxs && !ethTx.Protected() {
6162
return ctx, errorsmod.Wrapf(

app/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
863863
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
864864
paramsKeeper.Subspace(ibchost.ModuleName)
865865
// ethermint subspaces
866-
paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable())
866+
paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable()) //nolint: staticcheck
867867
paramsKeeper.Subspace(feemarkettypes.ModuleName).WithKeyTable(feemarkettypes.ParamKeyTable())
868868
return paramsKeeper
869869
}

proto/ethermint/evm/v1/evm.proto

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,14 @@ message Params {
1515
// enable_call toggles state transitions that use the vm.Call function
1616
bool enable_call = 3 [(gogoproto.moretags) = "yaml:\"enable_call\""];
1717
// extra_eips defines the additional EIPs for the vm.Config
18-
ExtraEIPs extra_eips = 4 [
19-
(gogoproto.customname) = "ExtraEIPs",
20-
(gogoproto.moretags) = "yaml:\"extra_eips\"",
21-
(gogoproto.nullable) = false
22-
];
18+
repeated int64 extra_eips = 4 [(gogoproto.customname) = "ExtraEIPs", (gogoproto.moretags) = "yaml:\"extra_eips\""];
2319
// chain_config defines the EVM chain configuration parameters
2420
ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false];
2521
// allow_unprotected_txs defines if replay-protected (i.e non EIP155
2622
// signed) transactions can be executed on the state machine.
2723
bool allow_unprotected_txs = 6;
2824
}
2925

30-
// ExtraEIPs represents extra EIPs for the vm.Config
31-
message ExtraEIPs {
32-
// eips defines the additional EIPs for the vm.Config
33-
repeated int64 eips = 1 [(gogoproto.customname) = "EIPs", (gogoproto.moretags) = "yaml:\"eips\""];
34-
}
35-
3626
// ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int values
3727
// instead of *big.Int.
3828
message ChainConfig {

x/evm/handler_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,8 @@ func (suite *EvmTestSuite) TestERC20TransferReverted() {
597597

598598
before := k.GetBalance(suite.ctx, suite.from)
599599

600-
ethCfg := suite.app.EvmKeeper.GetChainConfig(suite.ctx).EthereumConfig(nil)
600+
evmParams := suite.app.EvmKeeper.GetParams(suite.ctx)
601+
ethCfg := evmParams.GetChainConfig().EthereumConfig(nil)
601602
baseFee := suite.app.EvmKeeper.GetBaseFee(suite.ctx, ethCfg)
602603

603604
txData, err := types.UnpackTxData(tx.Data)

0 commit comments

Comments
 (0)