Skip to content

Commit 18163be

Browse files
vladjdkalmk-dev
andauthored
refactor(config): remove evmAppOptions entirely (#661)
* move tests to remove circular dependency * remove ante2 * wip: move all config files out of evmd * wip: add todos * reset config to fix test * fix evmd tests by adding resets to the evmappoptions * remove testutil/config constants consolidates these constants into one file in /config * fix eips test the test was using a duplicate eips multiplier value instead of the global one moved to config * remove all configs except for genesis from testutil/config and consolidate into /config * changelogchangelogchangelogchangelogchangelog * lints * wip: removing app options (tests failing) app options is removed from new app creation. however, we're getting a recovered panic on *restarting* the chain due to prepareproposal running before preblocker: +0x120\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).PrepareProposal.func1()\n\tgithub.com/cosmos/[email protected]/baseapp/abci.go:433 +0x38\npanic({0x1061c8160?, 0x10912faa0?})\n\truntime/panic.go:783 +0x120\ngithub.com/cosmos/evm/x/vm/types.GetEVMCoinDecimals(...)\n\tgithub.com/cosmos/[email protected]/x/vm/types/denom_config.go:61\ngithub.com/cosmos/evm/x/vm/types.ConvertAmountTo18DecimalsLegacy(...)\n\tgithub.com/cosmos/[email protected]/x/vm/types/scaling.go:17\ngithub.com/cosmos/evm/x/vm/wrappers.FeeMarketWrapper.GetBaseFee({{_, _}}, {{0x10698a810, 0x109225540}, {0x1069b51c0, 0x14001f4c200}, {{0x0, 0x0}, {0x16dc0f689, 0x4}, ...}, ...})\n\tgithub.com/cosmos/[email protected]/x/vm/wrappers/feemarket.go:38 +0x68\ngithub.com/cosmos/evm/x/vm/keeper.Keeper.GetBaseFee({{0x1069b4890, 0x14001eddeb0}, {0x10695e0b0, 0x14003560450}, {0x10695e240, 0x14003560490}, 0x140035637a0, {0x1400189d3e0, 0x14, 0x20}, ...}, ...)\n\tgithub.com/cosmos/[email protected]/x/vm/keeper/keeper.go:355 +0xe4\ngithub.com/cosmos/evm/mempool.(*ExperimentalEVMMempool).getIterators(0x14003cbd180, {0x10698a848?, 0x14002c39c08?}, {0x109225540, 0x0, 0x0})\n\tgithub.com/cosmos/[email protected]/mempool/mempool.go:439 +0x20c\ngithub.com/cosmos/evm/mempool.(*ExperimentalEVMMempool).SelectBy(0x14003cbd180, {0x10698a848?, 0x14002c39c08?}, {0x109225540?, 0x14000085ce8?, 0x104cce034?}, 0x140044cd540)\n\tgithub.com/cosmos/[email protected]/mempool/mempool.go:370 +0xe0\ngithub.com/cosmos/cosmos-sdk/types/mempool.SelectBy({0x10698a848?, 0x14002c39c08?}, {0x10698b108?, 0x14003cbd180?}, {0x109225540?, 0x0?, 0x0?}, 0x140044cd540)\n\tgithub.com/cosmos/[email protected]/types/mempool/mempool.go:58 +0xa0\ngithub.com/cosmos/evm/evmd.NewExampleApp.(*DefaultProposalHandler).PrepareProposalHandler.func3({{0x10698a810, 0x109225540}, {0x1069b51c0, 0x14001f4c200}, {{0x0, 0x0}, {0x16dc0f689, 0x4}, 0xd, {0x3507e5b0, ...}, ...}, ...}, ...)\n\tgithub.com/cosmos/[email protected]/baseapp/abci_utils.go:294 +0x250\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).PrepareProposal(0x14002d32488, 0x140015f42c0)\n\tgithub.com/cosmos/[email protected]/baseapp/abci.go:439 * begin storing coin info in the vm keeper storage the mempool needed the global variable, but that wasn't set, so we set it in the vm keeper storage and use it from there in the mempool everything else still uses the global variable, but we now have a foundation to move it over to the state storage * remove debugging artifact * artifact removal 2 * fix unit tests * wip: fix ibc testing * delete all evmappoptions from tests * fix ibc precompile integration test balance getters we were getting the 6 decimal balance when we were operating in 18-balance territory. now that we have a separation in the ibc tests, we should check balances accordingly * fix all evmd tests * fix precisebank keeper test * fix smore tests * lol * add upgrade handler * lints * changelog * Fix imports, add upgrade for non-18-decimal chains, and add migration guide * fix system test * Update docs/migrations/v0.4.0_to_v0.5.0_UNRELEASED.md Co-authored-by: Abdul Malek <[email protected]> * fix monodecorator test * Remove test* denoms and replace with default* * extract var * match vars * remove chain config from configurator * undo uint8 change * comment fixes * Auto stash before merge of "vlad/remove-app-options" and "origin/main" * set chain config in vm integ tests * lint * fix error on test * fix denoms for ibc chain * Revert "fix denoms for ibc chain" This reverts commit cbbaa44. * use app options chain id instead of passing param * lints * revert make race --------- Co-authored-by: Abdul Malek <[email protected]>
1 parent 2bbff66 commit 18163be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+6518
-4321
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
- [\#477](https://github.com/cosmos/evm/pull/477) Refactor precompile constructors to accept keeper interfaces instead of concrete implementations, breaking the existing `NewPrecompile` function signatures.
6666
- [\#594](https://github.com/cosmos/evm/pull/594) Remove all usage of x/params
6767
- [\#577](https://github.com/cosmos/evm/pull/577) Changed the way to create a stateful precompile based on the cmn.Precompile, change `NewPrecompile` to not return error.
68+
- [\#661](https://github.com/cosmos/evm/pull/661) Removes evmAppOptions from the repository and moves initialization to genesis. Chains must now have a display and denom metadata set for the defined EVM denom in the bank module's metadata.
69+
6870

6971
## v0.4.1
7072

ante/evm/fee_checker_test.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,24 @@ func TestSDKTxFeeChecker(t *testing.T) {
3535
// without extension option
3636
// london hardfork enableness
3737
chainID := uint64(config.EighteenDecimalsChainID)
38-
encodingConfig := encoding.MakeConfig(chainID)
39-
err := config.EvmAppOptions(chainID)
38+
encodingConfig := encoding.MakeConfig(chainID) //nolint:staticcheck // this is used
39+
40+
configurator := evmtypes.NewEVMConfigurator()
41+
configurator.ResetTestConfig()
42+
// set global chain config
43+
ethCfg := evmtypes.DefaultChainConfig(chainID)
44+
if err := evmtypes.SetChainConfig(ethCfg); err != nil {
45+
panic(err)
46+
}
47+
err := configurator.
48+
WithExtendedEips(evmtypes.DefaultCosmosEVMActivators).
49+
// NOTE: we're using the 18 decimals default for the example chain
50+
WithEVMCoinInfo(config.ChainsCoinInfo[chainID]).
51+
Configure()
4052
require.NoError(t, err)
53+
if err != nil {
54+
panic(err)
55+
}
4156

4257
evmDenom := evmtypes.GetEVMCoinDenom()
4358
minGasPrices := sdk.NewDecCoins(sdk.NewDecCoin(evmDenom, math.NewInt(10)))

ante/evm/mono_decorator.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,11 @@ func (md MonoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
111111
Time: uint64(ctx.BlockTime().Unix()), //nolint:gosec
112112
Difficulty: big.NewInt(0),
113113
}
114+
115+
chainConfig := evmtypes.GetEthChainConfig()
116+
114117
if err := txpool.ValidateTransaction(ethTx, &header, decUtils.Signer, &txpool.ValidationOptions{
115-
Config: evmtypes.GetEthChainConfig(),
118+
Config: chainConfig,
116119
Accept: AcceptedTxType,
117120
MaxSize: math.MaxUint64, // tx size is checked in cometbft
118121
MinTip: new(big.Int),

ante/evm/mono_decorator_test.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ func toMsgSlice(msgs []*evmsdktypes.MsgEthereumTx) []sdk.Msg {
147147

148148
func TestMonoDecorator(t *testing.T) {
149149
chainID := uint64(config.EighteenDecimalsChainID)
150-
require.NoError(t, config.EvmAppOptions(chainID))
151150
cfg := encoding.MakeConfig(chainID)
152151

153152
testCases := []struct {
@@ -197,6 +196,23 @@ func TestMonoDecorator(t *testing.T) {
197196

198197
for _, tc := range testCases {
199198
t.Run(tc.name, func(t *testing.T) {
199+
configurator := evmsdktypes.NewEVMConfigurator()
200+
configurator.ResetTestConfig()
201+
chainConfig := evmsdktypes.DefaultChainConfig(evmsdktypes.DefaultEVMChainID)
202+
err := evmsdktypes.SetChainConfig(chainConfig)
203+
require.NoError(t, err)
204+
coinInfo := evmsdktypes.EvmCoinInfo{
205+
Denom: evmsdktypes.DefaultEVMExtendedDenom,
206+
ExtendedDenom: evmsdktypes.DefaultEVMExtendedDenom,
207+
DisplayDenom: evmsdktypes.DefaultEVMDisplayDenom,
208+
Decimals: 18,
209+
}
210+
err = configurator.
211+
WithExtendedEips(evmsdktypes.DefaultCosmosEVMActivators).
212+
// NOTE: we're using the 18 decimals default for the example chain
213+
WithEVMCoinInfo(coinInfo).
214+
Configure()
215+
require.NoError(t, err)
200216
privKey, _ := ethsecp256k1.GenerateKey()
201217
keeper, cosmosAddr := setupFundedKeeper(t, privKey)
202218
accountKeeper := MockAccountKeeper{FundedAddr: cosmosAddr}

0 commit comments

Comments
 (0)