Skip to content

Commit

Permalink
Problem: ethermint develop branch is not used (#1069)
Browse files Browse the repository at this point in the history
* Problem: ethermint develop branch is not used

* bump ibc-go to v6.1.0 as ethermint

* fix opendb

* make proto-swagger-gen

* add change doc

* fix test

* align receipt type

for more info, see https://github.com/evmos/ethermint/pull/1413/files\#diff-a83f62065f56450b4c27cba1a248cb4c79d2033a9fadeb6c6b77d357ebbecd2fR219

* fix migrate

* update ibc-go to v6.2.0

* rename

* update ibc proto

* fix sim test
  • Loading branch information
mmsqe authored Jul 5, 2023
1 parent b181dda commit 51e5552
Show file tree
Hide file tree
Showing 57 changed files with 872 additions and 475 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- [cronos#795](https://github.com/crypto-org-chain/cronos/pull/795) Support permissions in cronos.
- [cronos#997](https://github.com/crypto-org-chain/cronos/pull/997) Fix logic to support proxy contract for cronos originated crc20.
- [cronos#1005](https://github.com/crypto-org-chain/cronos/pull/1005) Support specify channel id for send-to-ibc event in case of source token.
- [cronos#1069](https://github.com/crypto-org-chain/cronos/pull/1069) Update ethermint to develop, go-ethereum to `v1.10.26` and ibc-go to `v6.2.0`.

### Bug Fixes

Expand Down
51 changes: 27 additions & 24 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/posthandler"
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
Expand Down Expand Up @@ -90,24 +91,23 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ibcfee "github.com/cosmos/ibc-go/v5/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/types"
ibcfee "github.com/cosmos/ibc-go/v6/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v6/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v6/modules/apps/29-fee/types"

appparams "github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/ibc-go/v5/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v5/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v5/modules/core"
ibcclient "github.com/cosmos/ibc-go/v5/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v5/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types"
porttypes "github.com/cosmos/ibc-go/v5/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v5/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v5/modules/core/keeper"
"github.com/cosmos/ibc-go/v6/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v6/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v6/modules/core"
ibcclient "github.com/cosmos/ibc-go/v6/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v6/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v6/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
tmjson "github.com/tendermint/tendermint/libs/json"

ethermintapp "github.com/evmos/ethermint/app"
evmante "github.com/evmos/ethermint/app/ante"
srvflags "github.com/evmos/ethermint/server/flags"
ethermint "github.com/evmos/ethermint/types"
Expand Down Expand Up @@ -442,7 +442,7 @@ func New(

// IBC Fee Module keeper
app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(
appCodec, keys[ibcfeetypes.StoreKey], app.GetSubspace(ibcfeetypes.ModuleName),
appCodec, keys[ibcfeetypes.StoreKey],
app.IBCKeeper.ChannelKeeper, // more middlewares can be added in future
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper,
Expand All @@ -466,15 +466,18 @@ func New(
tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer))

// Create Ethermint keepers
feeMarketS := app.GetSubspace(feemarkettypes.ModuleName)
app.FeeMarketKeeper = feemarketkeeper.NewKeeper(
appCodec, app.GetSubspace(feemarkettypes.ModuleName), keys[feemarkettypes.StoreKey], tkeys[feemarkettypes.TransientKey],
appCodec, authtypes.NewModuleAddress(govtypes.ModuleName),
keys[feemarkettypes.StoreKey], tkeys[feemarkettypes.TransientKey], feeMarketS,
)

// Set authority to x/gov module account to only expect the module account to update params
evmS := app.GetSubspace(evmtypes.ModuleName)
app.EvmKeeper = evmkeeper.NewKeeper(
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], app.GetSubspace(evmtypes.ModuleName),
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName),
app.AccountKeeper, app.BankKeeper, stakingKeeper,
&app.FeeMarketKeeper,
nil, geth.NewEVM, tracer,
nil, geth.NewEVM, tracer, evmS,
)

var gravityKeeper gravitykeeper.Keeper
Expand Down Expand Up @@ -602,8 +605,8 @@ func New(
ibc.NewAppModule(app.IBCKeeper),
transferModule,
feeModule,
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper),
feemarket.NewAppModule(app.FeeMarketKeeper),
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, evmS),
feemarket.NewAppModule(app.FeeMarketKeeper, feeMarketS),
cronosModule,
}

Expand Down Expand Up @@ -720,7 +723,7 @@ func New(
// transactions
overrideModules := map[string]module.AppModuleSimulation{
// Use custom RandomGenesisAccounts so that auth module could create random EthAccounts in genesis state when genesis.json not specified
authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AccountKeeper, ethermintapp.RandomGenesisAccounts),
authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts),
}
app.sm = module.NewSimulationManagerFromAppModules(app.mm.Modules, overrideModules)

Expand Down Expand Up @@ -970,8 +973,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(evmtypes.ModuleName)
paramsKeeper.Subspace(feemarkettypes.ModuleName)
paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable()) //nolint: staticcheck
paramsKeeper.Subspace(feemarkettypes.ModuleName).WithKeyTable(feemarkettypes.ParamKeyTable())
if !skipGravity {
paramsKeeper.Subspace(gravitytypes.ModuleName)
}
Expand Down
16 changes: 10 additions & 6 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strings"
"testing"

ethermintapp "github.com/evmos/ethermint/app"
evmante "github.com/evmos/ethermint/app/ante"
evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/stretchr/testify/require"
Expand All @@ -36,6 +35,7 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
cronosmoduletypes "github.com/crypto-org-chain/cronos/v2/x/cronos/types"
)

Expand Down Expand Up @@ -96,6 +96,7 @@ func TestFullAppSimulation(t *testing.T) {
require.NoError(t, err, "simulation setup failed")

config.ChainID = SimAppChainID
config.BlockMaxGas = SimBlockMaxGas

defer func() {
require.NoError(t, db.Close())
Expand All @@ -112,7 +113,7 @@ func TestFullAppSimulation(t *testing.T) {
os.Stdout,
app.BaseApp,
StateFn(app.AppCodec(), app.SimulationManager()),
ethermintapp.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simapp.SimulationOperations(app, app.AppCodec(), config),
app.ModuleAccountAddrs(),
config,
Expand All @@ -137,6 +138,7 @@ func TestAppImportExport(t *testing.T) {
require.NoError(t, err, "simulation setup failed")

config.ChainID = SimAppChainID
config.BlockMaxGas = SimBlockMaxGas

defer func() {
require.NoError(t, db.Close())
Expand All @@ -153,7 +155,7 @@ func TestAppImportExport(t *testing.T) {
os.Stdout,
app.BaseApp,
StateFn(app.AppCodec(), app.SimulationManager()),
ethermintapp.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simapp.SimulationOperations(app, app.AppCodec(), config),
app.ModuleAccountAddrs(),
config,
Expand Down Expand Up @@ -258,6 +260,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
require.NoError(t, err, "simulation setup failed")

config.ChainID = SimAppChainID
config.BlockMaxGas = SimBlockMaxGas

defer func() {
require.NoError(t, db.Close())
Expand All @@ -274,7 +277,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
os.Stdout,
app.BaseApp,
StateFn(app.AppCodec(), app.SimulationManager()),
ethermintapp.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simapp.SimulationOperations(app, app.AppCodec(), config),
app.ModuleAccountAddrs(),
config,
Expand Down Expand Up @@ -324,7 +327,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
os.Stdout,
newApp.BaseApp,
StateFn(app.AppCodec(), app.SimulationManager()),
ethermintapp.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simapp.SimulationOperations(newApp, newApp.AppCodec(), config),
app.ModuleAccountAddrs(),
config,
Expand All @@ -346,6 +349,7 @@ func TestAppStateDeterminism(t *testing.T) {
config.OnOperation = false
config.AllInvariants = false
config.ChainID = SimAppChainID
config.BlockMaxGas = SimBlockMaxGas

numSeeds := 3
numTimesToRunPerSeed := 5
Expand Down Expand Up @@ -376,7 +380,7 @@ func TestAppStateDeterminism(t *testing.T) {
os.Stdout,
app.BaseApp,
StateFn(app.AppCodec(), app.SimulationManager()),
ethermintapp.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
simapp.SimulationOperations(app, app.AppCodec(), config),
app.ModuleAccountAddrs(),
config,
Expand Down
1 change: 1 addition & 0 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (

const (
SimAppChainID = "simulation_777-1"
SimBlockMaxGas = 81500000
TestAppChainID = "cronos_777-1"
)

Expand Down
Loading

0 comments on commit 51e5552

Please sign in to comment.