2018-07-19 21:16:48 +00:00
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
2021-08-10 11:23:22 +00:00
|
|
|
"encoding/json"
|
2020-04-01 18:49:21 +00:00
|
|
|
"io"
|
2021-04-18 16:39:15 +00:00
|
|
|
"net/http"
|
2019-07-05 16:46:13 +00:00
|
|
|
"os"
|
2021-04-17 10:00:07 +00:00
|
|
|
"path/filepath"
|
2019-07-05 16:46:13 +00:00
|
|
|
|
2021-04-18 16:39:15 +00:00
|
|
|
"github.com/gorilla/mux"
|
|
|
|
"github.com/rakyll/statik/fs"
|
2021-06-29 17:02:21 +00:00
|
|
|
"github.com/spf13/cast"
|
|
|
|
|
2021-04-17 10:00:07 +00:00
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
|
|
tmos "github.com/tendermint/tendermint/libs/os"
|
|
|
|
dbm "github.com/tendermint/tm-db"
|
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
2021-06-29 17:02:21 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
|
2018-10-24 14:49:37 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
2021-04-17 10:00:07 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec/types"
|
2021-04-18 16:39:15 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/server/api"
|
|
|
|
"github.com/cosmos/cosmos-sdk/server/config"
|
2021-06-29 17:02:21 +00:00
|
|
|
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
2020-04-01 18:49:21 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/simapp"
|
2021-04-17 10:00:07 +00:00
|
|
|
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
2022-07-28 13:43:49 +00:00
|
|
|
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
2018-08-09 01:06:34 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2019-07-08 19:26:33 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/types/module"
|
2019-07-12 17:13:15 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/version"
|
2018-08-09 01:06:34 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
2021-04-17 10:00:07 +00:00
|
|
|
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
2022-07-28 13:43:49 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/auth/posthandler"
|
2021-04-17 10:00:07 +00:00
|
|
|
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
|
2021-06-29 17:02:21 +00:00
|
|
|
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
2021-04-17 10:00:07 +00:00
|
|
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
|
2022-01-04 16:00:37 +00:00
|
|
|
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
2021-06-29 17:02:21 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/authz"
|
|
|
|
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
|
|
|
|
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
|
2019-07-04 19:46:54 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/bank"
|
2021-04-17 10:00:07 +00:00
|
|
|
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
|
|
|
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/capability"
|
|
|
|
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
|
|
|
|
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
|
2019-07-12 17:13:15 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/crisis"
|
2021-04-17 10:00:07 +00:00
|
|
|
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
|
|
|
|
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
|
2019-07-04 19:46:54 +00:00
|
|
|
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
2021-04-17 10:00:07 +00:00
|
|
|
distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client"
|
|
|
|
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
|
|
|
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
2020-04-22 19:26:01 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/evidence"
|
2021-04-17 10:00:07 +00:00
|
|
|
evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper"
|
|
|
|
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
|
2021-06-29 17:02:21 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/feegrant"
|
|
|
|
feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
|
|
|
|
feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module"
|
2019-07-08 19:26:33 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/genutil"
|
2021-04-17 10:00:07 +00:00
|
|
|
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
2018-08-24 18:56:43 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/gov"
|
2022-07-28 13:43:49 +00:00
|
|
|
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
|
2021-04-17 10:00:07 +00:00
|
|
|
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
|
|
|
|
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
2022-07-28 13:43:49 +00:00
|
|
|
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
|
|
|
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
2019-07-04 19:46:54 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/mint"
|
2021-04-17 10:00:07 +00:00
|
|
|
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
|
|
|
|
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
2018-08-24 18:56:43 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/params"
|
2019-07-12 17:13:15 +00:00
|
|
|
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
|
2021-04-17 10:00:07 +00:00
|
|
|
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
|
|
|
|
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
|
|
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
2018-08-24 18:56:43 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/slashing"
|
2021-04-17 10:00:07 +00:00
|
|
|
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
|
|
|
|
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
|
2019-07-04 19:46:54 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/staking"
|
2021-04-17 10:00:07 +00:00
|
|
|
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
|
|
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
2020-08-25 19:17:15 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/upgrade"
|
|
|
|
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
|
2021-04-17 10:00:07 +00:00
|
|
|
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
|
|
|
|
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
|
|
|
|
2022-07-28 13:43:49 +00:00
|
|
|
"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"
|
|
|
|
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"
|
2021-06-29 17:02:21 +00:00
|
|
|
|
2021-04-17 10:00:07 +00:00
|
|
|
// unnamed import of statik for swagger UI support
|
2022-06-19 09:43:41 +00:00
|
|
|
_ "github.com/evmos/ethermint/client/docs/statik"
|
2018-08-09 01:06:34 +00:00
|
|
|
|
2022-06-19 09:43:41 +00:00
|
|
|
"github.com/evmos/ethermint/app/ante"
|
|
|
|
srvflags "github.com/evmos/ethermint/server/flags"
|
|
|
|
ethermint "github.com/evmos/ethermint/types"
|
|
|
|
"github.com/evmos/ethermint/x/evm"
|
|
|
|
evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
|
|
|
|
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
2022-09-15 11:54:02 +00:00
|
|
|
"github.com/evmos/ethermint/x/evm/vm/geth"
|
2022-06-19 09:43:41 +00:00
|
|
|
"github.com/evmos/ethermint/x/feemarket"
|
|
|
|
feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper"
|
|
|
|
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
|
2022-02-14 23:08:41 +00:00
|
|
|
|
|
|
|
// Force-load the tracer engines to trigger registration due to Go-Ethereum v1.10.15 changes
|
|
|
|
_ "github.com/ethereum/go-ethereum/eth/tracers/js"
|
|
|
|
_ "github.com/ethereum/go-ethereum/eth/tracers/native"
|
2018-07-19 21:16:48 +00:00
|
|
|
)
|
|
|
|
|
2020-08-05 13:27:48 +00:00
|
|
|
func init() {
|
2021-04-17 10:00:07 +00:00
|
|
|
userHomeDir, err := os.UserHomeDir()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-04-18 16:39:15 +00:00
|
|
|
DefaultNodeHome = filepath.Join(userHomeDir, ".ethermintd")
|
2020-08-05 13:27:48 +00:00
|
|
|
}
|
|
|
|
|
2021-04-18 16:39:15 +00:00
|
|
|
const appName = "ethermintd"
|
2018-11-28 22:19:22 +00:00
|
|
|
|
|
|
|
var (
|
2021-04-17 10:00:07 +00:00
|
|
|
// DefaultNodeHome default home directories for the application daemon
|
|
|
|
DefaultNodeHome string
|
2019-07-08 19:26:33 +00:00
|
|
|
|
2020-04-01 18:49:21 +00:00
|
|
|
// ModuleBasics defines the module BasicManager is in charge of setting up basic,
|
2019-07-12 17:13:15 +00:00
|
|
|
// non-dependant module elements, such as codec registration
|
|
|
|
// and genesis verification.
|
2019-07-08 19:26:33 +00:00
|
|
|
ModuleBasics = module.NewBasicManager(
|
|
|
|
auth.AppModuleBasic{},
|
2020-04-01 18:49:21 +00:00
|
|
|
genutil.AppModuleBasic{},
|
2019-07-08 19:26:33 +00:00
|
|
|
bank.AppModuleBasic{},
|
2021-04-17 10:00:07 +00:00
|
|
|
capability.AppModuleBasic{},
|
2019-07-08 19:26:33 +00:00
|
|
|
staking.AppModuleBasic{},
|
2019-07-12 17:13:15 +00:00
|
|
|
mint.AppModuleBasic{},
|
2019-07-08 19:26:33 +00:00
|
|
|
distr.AppModuleBasic{},
|
2022-07-28 13:43:49 +00:00
|
|
|
gov.NewAppModuleBasic([]govclient.ProposalHandler{
|
|
|
|
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.LegacyProposalHandler, upgradeclient.LegacyCancelProposalHandler,
|
2021-06-29 17:02:21 +00:00
|
|
|
ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler,
|
2022-07-28 13:43:49 +00:00
|
|
|
}),
|
2019-07-12 17:13:15 +00:00
|
|
|
params.AppModuleBasic{},
|
|
|
|
crisis.AppModuleBasic{},
|
2019-07-08 19:26:33 +00:00
|
|
|
slashing.AppModuleBasic{},
|
2021-04-17 10:00:07 +00:00
|
|
|
ibc.AppModuleBasic{},
|
2021-06-29 17:02:21 +00:00
|
|
|
authzmodule.AppModuleBasic{},
|
|
|
|
feegrantmodule.AppModuleBasic{},
|
2020-08-25 19:17:15 +00:00
|
|
|
upgrade.AppModuleBasic{},
|
2021-04-17 10:00:07 +00:00
|
|
|
evidence.AppModuleBasic{},
|
|
|
|
transfer.AppModuleBasic{},
|
|
|
|
vesting.AppModuleBasic{},
|
2021-08-26 10:08:11 +00:00
|
|
|
// Ethermint modules
|
2019-07-25 20:38:55 +00:00
|
|
|
evm.AppModuleBasic{},
|
2021-08-26 10:08:11 +00:00
|
|
|
feemarket.AppModuleBasic{},
|
2019-07-08 19:26:33 +00:00
|
|
|
)
|
2019-08-15 16:26:40 +00:00
|
|
|
|
|
|
|
// module account permissions
|
|
|
|
maccPerms = map[string][]string{
|
2021-04-17 10:00:07 +00:00
|
|
|
authtypes.FeeCollectorName: nil,
|
|
|
|
distrtypes.ModuleName: nil,
|
|
|
|
minttypes.ModuleName: {authtypes.Minter},
|
|
|
|
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
|
|
|
|
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
|
|
|
|
govtypes.ModuleName: {authtypes.Burner},
|
|
|
|
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
|
2021-06-30 15:28:38 +00:00
|
|
|
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account
|
2019-08-15 16:26:40 +00:00
|
|
|
}
|
2020-04-01 18:49:21 +00:00
|
|
|
|
|
|
|
// module accounts that are allowed to receive tokens
|
|
|
|
allowedReceivingModAcc = map[string]bool{
|
2021-04-17 10:00:07 +00:00
|
|
|
distrtypes.ModuleName: true,
|
2020-04-01 18:49:21 +00:00
|
|
|
}
|
2018-07-19 21:16:48 +00:00
|
|
|
)
|
|
|
|
|
2021-04-18 16:39:15 +00:00
|
|
|
var _ simapp.App = (*EthermintApp)(nil)
|
|
|
|
|
2021-06-25 08:31:57 +00:00
|
|
|
// var _ server.Application (*EthermintApp)(nil)
|
2019-07-08 19:26:33 +00:00
|
|
|
|
|
|
|
// EthermintApp implements an extended ABCI application. It is an application
|
|
|
|
// that may process transactions through Ethereum's EVM running atop of
|
|
|
|
// Tendermint consensus.
|
|
|
|
type EthermintApp struct {
|
2021-04-17 10:00:07 +00:00
|
|
|
*baseapp.BaseApp
|
2021-05-21 10:24:53 +00:00
|
|
|
|
|
|
|
// encoding
|
2021-04-17 10:00:07 +00:00
|
|
|
cdc *codec.LegacyAmino
|
2021-06-29 17:02:21 +00:00
|
|
|
appCodec codec.Codec
|
2021-04-17 10:00:07 +00:00
|
|
|
interfaceRegistry types.InterfaceRegistry
|
2019-07-08 19:26:33 +00:00
|
|
|
|
2019-07-12 17:13:15 +00:00
|
|
|
invCheckPeriod uint
|
|
|
|
|
|
|
|
// keys to access the substores
|
2022-07-28 13:43:49 +00:00
|
|
|
keys map[string]*storetypes.KVStoreKey
|
|
|
|
tkeys map[string]*storetypes.TransientStoreKey
|
|
|
|
memKeys map[string]*storetypes.MemoryStoreKey
|
2020-04-01 18:49:21 +00:00
|
|
|
|
2019-07-12 17:13:15 +00:00
|
|
|
// keepers
|
2021-04-17 10:00:07 +00:00
|
|
|
AccountKeeper authkeeper.AccountKeeper
|
|
|
|
BankKeeper bankkeeper.Keeper
|
|
|
|
CapabilityKeeper *capabilitykeeper.Keeper
|
|
|
|
StakingKeeper stakingkeeper.Keeper
|
|
|
|
SlashingKeeper slashingkeeper.Keeper
|
|
|
|
MintKeeper mintkeeper.Keeper
|
|
|
|
DistrKeeper distrkeeper.Keeper
|
|
|
|
GovKeeper govkeeper.Keeper
|
|
|
|
CrisisKeeper crisiskeeper.Keeper
|
|
|
|
UpgradeKeeper upgradekeeper.Keeper
|
|
|
|
ParamsKeeper paramskeeper.Keeper
|
2021-06-29 17:02:21 +00:00
|
|
|
FeeGrantKeeper feegrantkeeper.Keeper
|
|
|
|
AuthzKeeper authzkeeper.Keeper
|
2021-04-17 10:00:07 +00:00
|
|
|
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
|
|
|
|
EvidenceKeeper evidencekeeper.Keeper
|
|
|
|
TransferKeeper ibctransferkeeper.Keeper
|
|
|
|
|
|
|
|
// make scoped keepers public for test purposes
|
|
|
|
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
|
|
|
|
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
|
|
|
|
|
2021-04-18 16:39:15 +00:00
|
|
|
// Ethermint keepers
|
2021-08-26 10:08:11 +00:00
|
|
|
EvmKeeper *evmkeeper.Keeper
|
|
|
|
FeeMarketKeeper feemarketkeeper.Keeper
|
2019-07-12 17:13:15 +00:00
|
|
|
|
|
|
|
// the module manager
|
|
|
|
mm *module.Manager
|
2020-04-22 19:26:01 +00:00
|
|
|
|
|
|
|
// simulation manager
|
2021-04-18 16:39:15 +00:00
|
|
|
sm *module.SimulationManager
|
2021-06-29 17:02:21 +00:00
|
|
|
|
|
|
|
// the configurator
|
|
|
|
configurator module.Configurator
|
2019-07-08 19:26:33 +00:00
|
|
|
}
|
2018-07-19 21:16:48 +00:00
|
|
|
|
2021-05-21 10:24:53 +00:00
|
|
|
// NewEthermintApp returns a reference to a new initialized Ethermint application.
|
2019-08-15 16:26:40 +00:00
|
|
|
func NewEthermintApp(
|
2020-08-25 19:17:15 +00:00
|
|
|
logger log.Logger,
|
|
|
|
db dbm.DB,
|
|
|
|
traceStore io.Writer,
|
|
|
|
loadLatest bool,
|
|
|
|
skipUpgradeHeights map[int64]bool,
|
2021-04-17 10:00:07 +00:00
|
|
|
homePath string,
|
2020-08-25 19:17:15 +00:00
|
|
|
invCheckPeriod uint,
|
2021-04-17 10:00:07 +00:00
|
|
|
encodingConfig simappparams.EncodingConfig,
|
|
|
|
appOpts servertypes.AppOptions,
|
|
|
|
baseAppOptions ...func(*baseapp.BaseApp),
|
2020-04-01 18:49:21 +00:00
|
|
|
) *EthermintApp {
|
2022-07-28 13:43:49 +00:00
|
|
|
appCodec := encodingConfig.Codec
|
2021-04-17 10:00:07 +00:00
|
|
|
cdc := encodingConfig.Amino
|
|
|
|
interfaceRegistry := encodingConfig.InterfaceRegistry
|
2019-07-12 17:13:15 +00:00
|
|
|
|
2021-05-27 09:26:01 +00:00
|
|
|
// NOTE we use custom transaction decoder that supports the sdk.Tx interface instead of sdk.StdTx
|
2021-04-17 10:00:07 +00:00
|
|
|
bApp := baseapp.NewBaseApp(
|
|
|
|
appName,
|
|
|
|
logger,
|
|
|
|
db,
|
2021-06-30 09:35:11 +00:00
|
|
|
encodingConfig.TxConfig.TxDecoder(),
|
2021-04-17 10:00:07 +00:00
|
|
|
baseAppOptions...,
|
|
|
|
)
|
2020-04-01 18:49:21 +00:00
|
|
|
bApp.SetCommitMultiStoreTracer(traceStore)
|
2021-06-29 17:02:21 +00:00
|
|
|
bApp.SetVersion(version.Version)
|
2021-04-17 10:00:07 +00:00
|
|
|
bApp.SetInterfaceRegistry(interfaceRegistry)
|
2019-08-15 16:26:40 +00:00
|
|
|
|
2020-04-01 18:49:21 +00:00
|
|
|
keys := sdk.NewKVStoreKeys(
|
2021-04-17 10:00:07 +00:00
|
|
|
// SDK keys
|
|
|
|
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
|
|
|
|
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
|
2021-06-29 17:02:21 +00:00
|
|
|
govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey,
|
|
|
|
evidencetypes.StoreKey, capabilitytypes.StoreKey,
|
|
|
|
feegrant.StoreKey, authzkeeper.StoreKey,
|
|
|
|
// ibc keys
|
|
|
|
ibchost.StoreKey, ibctransfertypes.StoreKey,
|
2021-04-17 10:00:07 +00:00
|
|
|
// ethermint keys
|
2021-08-26 10:08:11 +00:00
|
|
|
evmtypes.StoreKey, feemarkettypes.StoreKey,
|
2020-04-01 18:49:21 +00:00
|
|
|
)
|
|
|
|
|
2021-05-25 12:56:36 +00:00
|
|
|
// Add the EVM transient store key
|
2022-06-05 09:22:33 +00:00
|
|
|
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey)
|
2021-04-17 10:00:07 +00:00
|
|
|
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
|
2019-07-12 17:13:15 +00:00
|
|
|
|
2019-08-15 16:26:40 +00:00
|
|
|
app := &EthermintApp{
|
2021-04-17 10:00:07 +00:00
|
|
|
BaseApp: bApp,
|
|
|
|
cdc: cdc,
|
|
|
|
appCodec: appCodec,
|
|
|
|
interfaceRegistry: interfaceRegistry,
|
|
|
|
invCheckPeriod: invCheckPeriod,
|
|
|
|
keys: keys,
|
|
|
|
tkeys: tkeys,
|
|
|
|
memKeys: memKeys,
|
2018-08-09 01:06:34 +00:00
|
|
|
}
|
2018-08-24 18:56:43 +00:00
|
|
|
|
2019-07-12 17:13:15 +00:00
|
|
|
// init params keeper and subspaces
|
2021-04-17 10:00:07 +00:00
|
|
|
app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
|
|
|
|
// set the BaseApp's parameter store
|
2022-07-28 13:43:49 +00:00
|
|
|
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()))
|
2021-04-17 10:00:07 +00:00
|
|
|
|
|
|
|
// add capability keeper and ScopeToModule for ibc module
|
|
|
|
app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
|
2021-06-29 17:02:21 +00:00
|
|
|
|
2021-04-17 10:00:07 +00:00
|
|
|
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
|
|
|
|
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
|
2020-04-01 18:49:21 +00:00
|
|
|
|
2021-08-06 12:47:49 +00:00
|
|
|
// Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating
|
|
|
|
// their scoped modules in `NewApp` with `ScopeToModule`
|
|
|
|
app.CapabilityKeeper.Seal()
|
|
|
|
|
2020-04-01 18:49:21 +00:00
|
|
|
// use custom Ethermint account for contracts
|
2021-04-17 10:00:07 +00:00
|
|
|
app.AccountKeeper = authkeeper.NewAccountKeeper(
|
2022-08-26 10:30:55 +00:00
|
|
|
appCodec, keys[authtypes.StoreKey],
|
|
|
|
app.GetSubspace(authtypes.ModuleName),
|
|
|
|
ethermint.ProtoAccount,
|
|
|
|
maccPerms,
|
|
|
|
sdk.GetConfig().GetBech32AccountAddrPrefix(),
|
2020-04-01 18:49:21 +00:00
|
|
|
)
|
2021-04-17 10:00:07 +00:00
|
|
|
app.BankKeeper = bankkeeper.NewBaseKeeper(
|
2022-08-26 10:30:55 +00:00
|
|
|
appCodec,
|
|
|
|
keys[banktypes.StoreKey],
|
|
|
|
app.AccountKeeper,
|
|
|
|
app.GetSubspace(banktypes.ModuleName),
|
|
|
|
app.BlockedAddrs(),
|
2020-04-01 18:49:21 +00:00
|
|
|
)
|
2021-04-17 10:00:07 +00:00
|
|
|
stakingKeeper := stakingkeeper.NewKeeper(
|
2022-08-26 10:30:55 +00:00
|
|
|
appCodec, keys[stakingtypes.StoreKey],
|
|
|
|
app.AccountKeeper,
|
|
|
|
app.BankKeeper,
|
|
|
|
app.GetSubspace(stakingtypes.ModuleName),
|
2020-04-01 18:49:21 +00:00
|
|
|
)
|
2021-04-17 10:00:07 +00:00
|
|
|
app.MintKeeper = mintkeeper.NewKeeper(
|
2022-08-26 10:30:55 +00:00
|
|
|
appCodec,
|
|
|
|
keys[minttypes.StoreKey],
|
|
|
|
app.GetSubspace(minttypes.ModuleName),
|
|
|
|
&stakingKeeper,
|
|
|
|
app.AccountKeeper,
|
|
|
|
app.BankKeeper,
|
|
|
|
authtypes.FeeCollectorName,
|
2020-04-01 18:49:21 +00:00
|
|
|
)
|
2021-04-17 10:00:07 +00:00
|
|
|
app.DistrKeeper = distrkeeper.NewKeeper(
|
2022-08-26 10:30:55 +00:00
|
|
|
appCodec,
|
|
|
|
keys[distrtypes.StoreKey],
|
|
|
|
app.GetSubspace(distrtypes.ModuleName),
|
|
|
|
app.AccountKeeper,
|
|
|
|
app.BankKeeper,
|
|
|
|
&stakingKeeper,
|
|
|
|
authtypes.FeeCollectorName,
|
2020-04-01 18:49:21 +00:00
|
|
|
)
|
2021-04-17 10:00:07 +00:00
|
|
|
app.SlashingKeeper = slashingkeeper.NewKeeper(
|
2022-08-26 10:30:55 +00:00
|
|
|
appCodec,
|
|
|
|
keys[slashingtypes.StoreKey],
|
|
|
|
&stakingKeeper,
|
|
|
|
app.GetSubspace(slashingtypes.ModuleName),
|
2020-04-01 18:49:21 +00:00
|
|
|
)
|
2021-04-17 10:00:07 +00:00
|
|
|
app.CrisisKeeper = crisiskeeper.NewKeeper(
|
2022-08-26 10:30:55 +00:00
|
|
|
app.GetSubspace(crisistypes.ModuleName),
|
|
|
|
invCheckPeriod,
|
|
|
|
app.BankKeeper,
|
|
|
|
authtypes.FeeCollectorName,
|
2020-04-01 18:49:21 +00:00
|
|
|
)
|
2022-08-26 10:30:55 +00:00
|
|
|
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(
|
|
|
|
appCodec,
|
|
|
|
keys[feegrant.StoreKey],
|
|
|
|
app.AccountKeeper)
|
2022-07-28 13:43:49 +00:00
|
|
|
|
|
|
|
// set the governance module account as the authority for conducting upgrades
|
2022-08-26 10:30:55 +00:00
|
|
|
app.UpgradeKeeper = upgradekeeper.NewKeeper(
|
|
|
|
skipUpgradeHeights,
|
|
|
|
keys[upgradetypes.StoreKey],
|
|
|
|
appCodec,
|
|
|
|
homePath,
|
|
|
|
app.BaseApp,
|
|
|
|
authtypes.NewModuleAddress(govtypes.ModuleName).String())
|
2021-04-17 10:00:07 +00:00
|
|
|
|
|
|
|
// register the staking hooks
|
|
|
|
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
|
|
|
|
app.StakingKeeper = *stakingKeeper.SetHooks(
|
2022-08-26 10:30:55 +00:00
|
|
|
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(),
|
|
|
|
app.SlashingKeeper.Hooks()),
|
2020-04-22 19:26:01 +00:00
|
|
|
)
|
|
|
|
|
2022-08-26 10:30:55 +00:00
|
|
|
app.AuthzKeeper = authzkeeper.NewKeeper(
|
|
|
|
keys[authzkeeper.StoreKey],
|
|
|
|
appCodec,
|
|
|
|
app.MsgServiceRouter(),
|
|
|
|
app.AccountKeeper)
|
2021-06-29 17:02:21 +00:00
|
|
|
|
2021-08-16 09:45:10 +00:00
|
|
|
tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer))
|
|
|
|
|
2021-04-18 16:39:15 +00:00
|
|
|
// Create Ethermint keepers
|
2021-10-04 14:58:06 +00:00
|
|
|
app.FeeMarketKeeper = feemarketkeeper.NewKeeper(
|
2022-06-05 09:22:33 +00:00
|
|
|
appCodec, app.GetSubspace(feemarkettypes.ModuleName), keys[feemarkettypes.StoreKey], tkeys[feemarkettypes.TransientKey],
|
2021-10-04 14:58:06 +00:00
|
|
|
)
|
|
|
|
|
2021-04-18 16:39:15 +00:00
|
|
|
app.EvmKeeper = evmkeeper.NewKeeper(
|
2021-06-30 09:35:11 +00:00
|
|
|
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], app.GetSubspace(evmtypes.ModuleName),
|
2021-10-04 14:58:06 +00:00
|
|
|
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper,
|
2022-09-15 11:54:02 +00:00
|
|
|
nil, geth.NewEVM, tracer,
|
2021-04-18 16:39:15 +00:00
|
|
|
)
|
|
|
|
|
2021-04-17 10:00:07 +00:00
|
|
|
// Create IBC Keeper
|
|
|
|
app.IBCKeeper = ibckeeper.NewKeeper(
|
2021-06-29 17:02:21 +00:00
|
|
|
appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper,
|
2020-04-01 18:49:21 +00:00
|
|
|
)
|
2019-07-12 17:13:15 +00:00
|
|
|
|
|
|
|
// register the proposal types
|
2022-07-28 13:43:49 +00:00
|
|
|
govRouter := govv1beta1.NewRouter()
|
|
|
|
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
|
2021-04-17 10:00:07 +00:00
|
|
|
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
|
|
|
|
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
|
|
|
|
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
|
2021-06-29 17:02:21 +00:00
|
|
|
AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))
|
2022-07-28 13:43:49 +00:00
|
|
|
govConfig := govtypes.DefaultConfig()
|
|
|
|
/*
|
|
|
|
Example of setting gov params:
|
|
|
|
govConfig.MaxMetadataLen = 10000
|
|
|
|
*/
|
2021-06-29 17:02:21 +00:00
|
|
|
govKeeper := govkeeper.NewKeeper(
|
2021-04-17 10:00:07 +00:00
|
|
|
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
|
2022-07-28 13:43:49 +00:00
|
|
|
&stakingKeeper, govRouter, app.MsgServiceRouter(), govConfig,
|
2020-04-01 18:49:21 +00:00
|
|
|
)
|
2019-07-12 17:13:15 +00:00
|
|
|
|
2021-06-29 17:02:21 +00:00
|
|
|
app.GovKeeper = *govKeeper.SetHooks(
|
|
|
|
govtypes.NewMultiGovHooks(
|
|
|
|
// register the governance hooks
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2021-04-17 10:00:07 +00:00
|
|
|
// Create Transfer Keepers
|
|
|
|
app.TransferKeeper = ibctransferkeeper.NewKeeper(
|
|
|
|
appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName),
|
2022-01-05 13:08:04 +00:00
|
|
|
app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
|
2021-04-17 10:00:07 +00:00
|
|
|
app.AccountKeeper, app.BankKeeper, scopedTransferKeeper,
|
2019-08-15 16:26:40 +00:00
|
|
|
)
|
2021-04-17 10:00:07 +00:00
|
|
|
transferModule := transfer.NewAppModule(app.TransferKeeper)
|
2022-01-03 16:30:28 +00:00
|
|
|
transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)
|
2021-04-17 10:00:07 +00:00
|
|
|
|
|
|
|
// Create static IBC router, add transfer route, then set and seal it
|
|
|
|
ibcRouter := porttypes.NewRouter()
|
2022-01-03 16:30:28 +00:00
|
|
|
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
|
2021-04-17 10:00:07 +00:00
|
|
|
app.IBCKeeper.SetRouter(ibcRouter)
|
|
|
|
|
|
|
|
// create evidence keeper with router
|
|
|
|
evidenceKeeper := evidencekeeper.NewKeeper(
|
|
|
|
appCodec, keys[evidencetypes.StoreKey], &app.StakingKeeper, app.SlashingKeeper,
|
|
|
|
)
|
|
|
|
// If evidence needs to be handled for the app, set routes in router here and seal
|
|
|
|
app.EvidenceKeeper = *evidenceKeeper
|
|
|
|
|
|
|
|
/**** Module Options ****/
|
|
|
|
|
|
|
|
// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
|
|
|
|
// we prefer to be more strict in what arguments the modules expect.
|
2021-08-16 09:45:10 +00:00
|
|
|
skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))
|
2019-07-12 17:13:15 +00:00
|
|
|
|
2020-04-01 18:49:21 +00:00
|
|
|
// NOTE: Any module instantiated in the module manager that is later modified
|
|
|
|
// must be passed by reference here.
|
2019-07-12 17:13:15 +00:00
|
|
|
app.mm = module.NewManager(
|
2021-04-17 10:00:07 +00:00
|
|
|
// SDK app modules
|
|
|
|
genutil.NewAppModule(
|
|
|
|
app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx,
|
|
|
|
encodingConfig.TxConfig,
|
|
|
|
),
|
|
|
|
auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts),
|
|
|
|
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper),
|
|
|
|
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
|
|
|
|
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
|
|
|
|
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
|
2022-07-28 13:43:49 +00:00
|
|
|
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
|
2021-04-17 10:00:07 +00:00
|
|
|
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
|
2022-07-28 13:43:49 +00:00
|
|
|
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil),
|
2021-04-17 10:00:07 +00:00
|
|
|
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
|
|
|
|
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
|
|
|
|
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
|
|
|
|
upgrade.NewAppModule(app.UpgradeKeeper),
|
2020-04-22 19:26:01 +00:00
|
|
|
evidence.NewAppModule(app.EvidenceKeeper),
|
2021-04-17 10:00:07 +00:00
|
|
|
params.NewAppModule(app.ParamsKeeper),
|
2021-06-29 17:02:21 +00:00
|
|
|
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
|
|
|
|
|
|
|
|
// ibc modules
|
|
|
|
ibc.NewAppModule(app.IBCKeeper),
|
2021-04-17 10:00:07 +00:00
|
|
|
transferModule,
|
2021-05-27 09:26:01 +00:00
|
|
|
// Ethermint app modules
|
2021-06-08 17:10:29 +00:00
|
|
|
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper),
|
2021-08-26 10:08:11 +00:00
|
|
|
feemarket.NewAppModule(app.FeeMarketKeeper),
|
2019-07-12 17:13:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// During begin block slashing happens after distr.BeginBlocker so that
|
|
|
|
// there is nothing left over in the validator fee pool, so as to keep the
|
|
|
|
// CanWithdrawInvariant invariant.
|
2021-04-17 10:00:07 +00:00
|
|
|
// NOTE: upgrade module must go first to handle software upgrades.
|
2022-07-28 13:43:49 +00:00
|
|
|
// NOTE: staking module is required if HistoricalEntries param > 0
|
2021-08-06 12:47:49 +00:00
|
|
|
// NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC)
|
2020-04-01 18:49:21 +00:00
|
|
|
app.mm.SetOrderBeginBlockers(
|
2021-04-17 10:00:07 +00:00
|
|
|
upgradetypes.ModuleName,
|
2021-08-06 12:47:49 +00:00
|
|
|
capabilitytypes.ModuleName,
|
2021-12-15 02:10:52 +00:00
|
|
|
feemarkettypes.ModuleName,
|
2021-04-17 10:00:07 +00:00
|
|
|
evmtypes.ModuleName,
|
2022-01-04 16:00:37 +00:00
|
|
|
minttypes.ModuleName,
|
|
|
|
distrtypes.ModuleName,
|
|
|
|
slashingtypes.ModuleName,
|
|
|
|
evidencetypes.ModuleName,
|
|
|
|
stakingtypes.ModuleName,
|
|
|
|
ibchost.ModuleName,
|
|
|
|
// no-op modules
|
|
|
|
ibctransfertypes.ModuleName,
|
|
|
|
authtypes.ModuleName,
|
|
|
|
banktypes.ModuleName,
|
|
|
|
govtypes.ModuleName,
|
|
|
|
crisistypes.ModuleName,
|
|
|
|
genutiltypes.ModuleName,
|
|
|
|
authz.ModuleName,
|
|
|
|
feegrant.ModuleName,
|
|
|
|
paramstypes.ModuleName,
|
|
|
|
vestingtypes.ModuleName,
|
2020-04-01 18:49:21 +00:00
|
|
|
)
|
2021-08-26 10:08:11 +00:00
|
|
|
|
|
|
|
// NOTE: fee market module must go last in order to retrieve the block gas used.
|
2020-04-01 18:49:21 +00:00
|
|
|
app.mm.SetOrderEndBlockers(
|
2022-01-04 16:00:37 +00:00
|
|
|
crisistypes.ModuleName,
|
|
|
|
govtypes.ModuleName,
|
|
|
|
stakingtypes.ModuleName,
|
|
|
|
evmtypes.ModuleName,
|
|
|
|
feemarkettypes.ModuleName,
|
|
|
|
// no-op modules
|
|
|
|
ibchost.ModuleName,
|
|
|
|
ibctransfertypes.ModuleName,
|
|
|
|
capabilitytypes.ModuleName,
|
|
|
|
authtypes.ModuleName,
|
|
|
|
banktypes.ModuleName,
|
|
|
|
distrtypes.ModuleName,
|
|
|
|
slashingtypes.ModuleName,
|
|
|
|
minttypes.ModuleName,
|
|
|
|
genutiltypes.ModuleName,
|
|
|
|
evidencetypes.ModuleName,
|
|
|
|
authz.ModuleName,
|
|
|
|
feegrant.ModuleName,
|
|
|
|
paramstypes.ModuleName,
|
|
|
|
upgradetypes.ModuleName,
|
|
|
|
vestingtypes.ModuleName,
|
2020-04-01 18:49:21 +00:00
|
|
|
)
|
2019-07-12 17:13:15 +00:00
|
|
|
|
2019-08-15 16:26:40 +00:00
|
|
|
// NOTE: The genutils module must occur after staking so that pools are
|
|
|
|
// properly initialized with tokens from genesis accounts.
|
2022-07-28 13:43:49 +00:00
|
|
|
// NOTE: The genutils module must also occur after auth so that it can access the params from auth.
|
2021-04-17 10:00:07 +00:00
|
|
|
// NOTE: Capability module must occur first so that it can initialize any capabilities
|
|
|
|
// so that other modules that want to create or claim capabilities afterwards in InitChain
|
|
|
|
// can do so safely.
|
2019-08-15 16:26:40 +00:00
|
|
|
app.mm.SetOrderInitGenesis(
|
2021-04-17 10:00:07 +00:00
|
|
|
// SDK modules
|
2022-01-04 16:00:37 +00:00
|
|
|
capabilitytypes.ModuleName,
|
|
|
|
authtypes.ModuleName,
|
|
|
|
banktypes.ModuleName,
|
|
|
|
distrtypes.ModuleName,
|
|
|
|
stakingtypes.ModuleName,
|
|
|
|
slashingtypes.ModuleName,
|
|
|
|
govtypes.ModuleName,
|
|
|
|
minttypes.ModuleName,
|
|
|
|
ibchost.ModuleName,
|
2022-05-31 16:28:46 +00:00
|
|
|
// evm module denomination is used by the feemarket module, in AnteHandle
|
|
|
|
evmtypes.ModuleName,
|
|
|
|
// NOTE: feemarket need to be initialized before genutil module:
|
|
|
|
// gentx transactions use MinGasPriceDecorator.AnteHandle
|
|
|
|
feemarkettypes.ModuleName,
|
2022-01-04 16:00:37 +00:00
|
|
|
genutiltypes.ModuleName,
|
|
|
|
evidencetypes.ModuleName,
|
|
|
|
ibctransfertypes.ModuleName,
|
|
|
|
authz.ModuleName,
|
|
|
|
feegrant.ModuleName,
|
|
|
|
paramstypes.ModuleName,
|
|
|
|
upgradetypes.ModuleName,
|
|
|
|
vestingtypes.ModuleName,
|
2021-04-17 10:00:07 +00:00
|
|
|
// NOTE: crisis module must go at the end to check for invariants on each module
|
|
|
|
crisistypes.ModuleName,
|
2019-08-15 16:26:40 +00:00
|
|
|
)
|
2018-08-24 18:56:43 +00:00
|
|
|
|
2022-07-28 13:43:49 +00:00
|
|
|
// Uncomment if you want to set a custom migration order here.
|
|
|
|
// app.mm.SetOrderMigrations(custom order)
|
|
|
|
|
2020-04-01 18:49:21 +00:00
|
|
|
app.mm.RegisterInvariants(&app.CrisisKeeper)
|
2021-04-17 10:00:07 +00:00
|
|
|
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
|
2021-06-29 17:02:21 +00:00
|
|
|
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
|
|
|
|
app.mm.RegisterServices(app.configurator)
|
2021-04-17 10:00:07 +00:00
|
|
|
|
2022-07-28 13:43:49 +00:00
|
|
|
// RegisterUpgradeHandlers is used for registering any on-chain upgrades.
|
|
|
|
// Make sure it's called after `app.mm` and `app.configurator` are set.
|
|
|
|
// app.RegisterUpgradeHandlers()
|
|
|
|
|
2021-06-25 08:31:57 +00:00
|
|
|
// add test gRPC service for testing gRPC queries in isolation
|
2021-04-17 10:00:07 +00:00
|
|
|
// testdata.RegisterTestServiceServer(app.GRPCQueryRouter(), testdata.TestServiceImpl{})
|
2018-08-24 18:56:43 +00:00
|
|
|
|
2021-06-25 08:31:57 +00:00
|
|
|
// create the simulation manager and define the order of the modules for deterministic simulations
|
2022-07-28 13:43:49 +00:00
|
|
|
//
|
2021-09-05 11:03:06 +00:00
|
|
|
// NOTE: this is not required apps that don't use the simulator for fuzz testing
|
2020-04-22 19:26:01 +00:00
|
|
|
// transactions
|
2022-07-28 13:43:49 +00:00
|
|
|
overrideModules := map[string]module.AppModuleSimulation{
|
|
|
|
authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts),
|
|
|
|
}
|
|
|
|
app.sm = module.NewSimulationManagerFromAppModules(app.mm.Modules, overrideModules)
|
2021-04-18 16:39:15 +00:00
|
|
|
|
|
|
|
app.sm.RegisterStoreDecoders()
|
2020-04-22 19:26:01 +00:00
|
|
|
|
2019-07-12 17:13:15 +00:00
|
|
|
// initialize stores
|
2019-08-15 16:26:40 +00:00
|
|
|
app.MountKVStores(keys)
|
|
|
|
app.MountTransientStores(tkeys)
|
2021-04-17 10:00:07 +00:00
|
|
|
app.MountMemoryStores(memKeys)
|
2020-04-01 18:49:21 +00:00
|
|
|
|
2019-07-12 17:13:15 +00:00
|
|
|
// initialize BaseApp
|
|
|
|
app.SetInitChainer(app.InitChainer)
|
2018-08-24 18:56:43 +00:00
|
|
|
app.SetBeginBlocker(app.BeginBlocker)
|
2022-07-28 13:43:49 +00:00
|
|
|
app.SetEndBlocker(app.EndBlocker)
|
|
|
|
app.setAnteHandler(encodingConfig.TxConfig, cast.ToUint64(appOpts.Get(srvflags.EVMMaxTxGasWanted)))
|
|
|
|
// In v0.46, the SDK introduces _postHandlers_. PostHandlers are like
|
|
|
|
// antehandlers, but are run _after_ the `runMsgs` execution. They are also
|
|
|
|
// defined as a chain, and have the same signature as antehandlers.
|
|
|
|
//
|
|
|
|
// In baseapp, postHandlers are run in the same store branch as `runMsgs`,
|
|
|
|
// meaning that both `runMsgs` and `postHandler` state will be committed if
|
|
|
|
// both are successful, and both will be reverted if any of the two fails.
|
|
|
|
//
|
|
|
|
// The SDK exposes a default empty postHandlers chain.
|
|
|
|
//
|
|
|
|
// Please note that changing any of the anteHandler or postHandler chain is
|
|
|
|
// likely to be a state-machine breaking change, which needs a coordinated
|
|
|
|
// upgrade.
|
|
|
|
app.setPostHandler()
|
|
|
|
|
|
|
|
if loadLatest {
|
|
|
|
if err := app.LoadLatestVersion(); err != nil {
|
|
|
|
tmos.Exit(err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
app.ScopedIBCKeeper = scopedIBCKeeper
|
|
|
|
app.ScopedTransferKeeper = scopedTransferKeeper
|
2021-04-17 10:00:07 +00:00
|
|
|
|
2022-07-28 13:43:49 +00:00
|
|
|
return app
|
|
|
|
}
|
2021-04-18 16:39:15 +00:00
|
|
|
|
2022-07-28 13:43:49 +00:00
|
|
|
// use Ethermint's custom AnteHandler
|
|
|
|
func (app *EthermintApp) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64) {
|
2022-07-19 04:50:31 +00:00
|
|
|
anteHandler, err := ante.NewAnteHandler(ante.HandlerOptions{
|
2022-08-10 22:33:38 +00:00
|
|
|
AccountKeeper: app.AccountKeeper,
|
|
|
|
BankKeeper: app.BankKeeper,
|
|
|
|
SignModeHandler: txConfig.SignModeHandler(),
|
|
|
|
FeegrantKeeper: app.FeeGrantKeeper,
|
|
|
|
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
|
|
|
|
IBCKeeper: app.IBCKeeper,
|
|
|
|
EvmKeeper: app.EvmKeeper,
|
|
|
|
FeeMarketKeeper: app.FeeMarketKeeper,
|
|
|
|
MaxTxGasWanted: maxGasWanted,
|
|
|
|
ExtensionOptionChecker: ethermint.HasDynamicFeeExtensionOption,
|
|
|
|
TxFeeChecker: ante.NewDynamicFeeChecker(app.EvmKeeper),
|
2022-07-19 04:50:31 +00:00
|
|
|
})
|
|
|
|
if err != nil {
|
2022-01-02 22:44:46 +00:00
|
|
|
panic(err)
|
|
|
|
}
|
2022-07-28 13:43:49 +00:00
|
|
|
|
2022-07-19 04:50:31 +00:00
|
|
|
app.SetAnteHandler(anteHandler)
|
2022-07-28 13:43:49 +00:00
|
|
|
}
|
2018-08-24 18:56:43 +00:00
|
|
|
|
2022-07-28 13:43:49 +00:00
|
|
|
func (app *EthermintApp) setPostHandler() {
|
|
|
|
postHandler, err := posthandler.NewPostHandler(
|
|
|
|
posthandler.HandlerOptions{},
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
2018-08-24 18:56:43 +00:00
|
|
|
}
|
2020-04-01 18:49:21 +00:00
|
|
|
|
2022-07-28 13:43:49 +00:00
|
|
|
app.SetPostHandler(postHandler)
|
2018-08-24 18:56:43 +00:00
|
|
|
}
|
2018-07-19 21:16:48 +00:00
|
|
|
|
2020-04-01 18:49:21 +00:00
|
|
|
// Name returns the name of the App
|
|
|
|
func (app *EthermintApp) Name() string { return app.BaseApp.Name() }
|
2018-11-28 22:19:22 +00:00
|
|
|
|
2019-09-27 14:08:45 +00:00
|
|
|
// BeginBlocker updates every begin block
|
2019-07-12 17:13:15 +00:00
|
|
|
func (app *EthermintApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
|
|
|
|
return app.mm.BeginBlock(ctx, req)
|
2018-08-24 18:56:43 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 14:08:45 +00:00
|
|
|
// EndBlocker updates every end block
|
2019-07-12 17:13:15 +00:00
|
|
|
func (app *EthermintApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
|
|
|
return app.mm.EndBlock(ctx, req)
|
|
|
|
}
|
|
|
|
|
2019-09-27 14:08:45 +00:00
|
|
|
// InitChainer updates at chain initialization
|
2019-07-12 17:13:15 +00:00
|
|
|
func (app *EthermintApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
|
2020-04-01 18:49:21 +00:00
|
|
|
var genesisState simapp.GenesisState
|
2021-08-10 11:23:22 +00:00
|
|
|
if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
|
2021-04-17 10:00:07 +00:00
|
|
|
return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
|
2019-07-12 17:13:15 +00:00
|
|
|
}
|
2018-11-28 22:19:22 +00:00
|
|
|
|
2019-09-27 14:08:45 +00:00
|
|
|
// LoadHeight loads state at a particular height
|
2019-07-12 17:13:15 +00:00
|
|
|
func (app *EthermintApp) LoadHeight(height int64) error {
|
2021-04-17 10:00:07 +00:00
|
|
|
return app.LoadVersion(height)
|
2018-08-24 18:56:43 +00:00
|
|
|
}
|
|
|
|
|
2019-08-15 16:26:40 +00:00
|
|
|
// ModuleAccountAddrs returns all the app's module account addresses.
|
|
|
|
func (app *EthermintApp) ModuleAccountAddrs() map[string]bool {
|
|
|
|
modAccAddrs := make(map[string]bool)
|
|
|
|
for acc := range maccPerms {
|
2021-04-17 10:00:07 +00:00
|
|
|
modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
|
2018-08-09 01:06:34 +00:00
|
|
|
}
|
|
|
|
|
2019-08-15 16:26:40 +00:00
|
|
|
return modAccAddrs
|
2018-08-09 01:06:34 +00:00
|
|
|
}
|
2020-04-01 18:49:21 +00:00
|
|
|
|
2021-04-17 10:00:07 +00:00
|
|
|
// BlockedAddrs returns all the app's module account addresses that are not
|
|
|
|
// allowed to receive external tokens.
|
|
|
|
func (app *EthermintApp) BlockedAddrs() map[string]bool {
|
|
|
|
blockedAddrs := make(map[string]bool)
|
2020-04-01 18:49:21 +00:00
|
|
|
for acc := range maccPerms {
|
2021-04-17 10:00:07 +00:00
|
|
|
blockedAddrs[authtypes.NewModuleAddress(acc).String()] = !allowedReceivingModAcc[acc]
|
2020-04-01 18:49:21 +00:00
|
|
|
}
|
|
|
|
|
2021-04-17 10:00:07 +00:00
|
|
|
return blockedAddrs
|
2020-04-01 18:49:21 +00:00
|
|
|
}
|
|
|
|
|
2021-04-17 10:00:07 +00:00
|
|
|
// LegacyAmino returns EthermintApp's amino codec.
|
|
|
|
//
|
|
|
|
// NOTE: This is solely to be used for testing purposes as it may be desirable
|
|
|
|
// for modules to register their own custom testing types.
|
|
|
|
func (app *EthermintApp) LegacyAmino() *codec.LegacyAmino {
|
|
|
|
return app.cdc
|
|
|
|
}
|
|
|
|
|
|
|
|
// AppCodec returns EthermintApp's app codec.
|
|
|
|
//
|
|
|
|
// NOTE: This is solely to be used for testing purposes as it may be desirable
|
|
|
|
// for modules to register their own custom testing types.
|
2021-06-29 17:02:21 +00:00
|
|
|
func (app *EthermintApp) AppCodec() codec.Codec {
|
2021-04-17 10:00:07 +00:00
|
|
|
return app.appCodec
|
|
|
|
}
|
|
|
|
|
|
|
|
// InterfaceRegistry returns EthermintApp's InterfaceRegistry
|
|
|
|
func (app *EthermintApp) InterfaceRegistry() types.InterfaceRegistry {
|
|
|
|
return app.interfaceRegistry
|
2020-04-22 19:26:01 +00:00
|
|
|
}
|
|
|
|
|
2020-04-01 18:49:21 +00:00
|
|
|
// GetKey returns the KVStoreKey for the provided store key.
|
|
|
|
//
|
|
|
|
// NOTE: This is solely to be used for testing purposes.
|
2022-07-28 13:43:49 +00:00
|
|
|
func (app *EthermintApp) GetKey(storeKey string) *storetypes.KVStoreKey {
|
2020-04-01 18:49:21 +00:00
|
|
|
return app.keys[storeKey]
|
|
|
|
}
|
|
|
|
|
2021-04-17 10:00:07 +00:00
|
|
|
// GetTKey returns the TransientStoreKey for the provided store key.
|
2020-04-01 18:49:21 +00:00
|
|
|
//
|
2021-04-17 10:00:07 +00:00
|
|
|
// NOTE: This is solely to be used for testing purposes.
|
2022-07-28 13:43:49 +00:00
|
|
|
func (app *EthermintApp) GetTKey(storeKey string) *storetypes.TransientStoreKey {
|
2021-04-17 10:00:07 +00:00
|
|
|
return app.tkeys[storeKey]
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetMemKey returns the MemStoreKey for the provided mem key.
|
|
|
|
//
|
|
|
|
// NOTE: This is solely used for testing purposes.
|
2022-07-28 13:43:49 +00:00
|
|
|
func (app *EthermintApp) GetMemKey(storeKey string) *storetypes.MemoryStoreKey {
|
2021-04-17 10:00:07 +00:00
|
|
|
return app.memKeys[storeKey]
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSubspace returns a param subspace for a given module name.
|
|
|
|
//
|
|
|
|
// NOTE: This is solely to be used for testing purposes.
|
|
|
|
func (app *EthermintApp) GetSubspace(moduleName string) paramstypes.Subspace {
|
|
|
|
subspace, _ := app.ParamsKeeper.GetSubspace(moduleName)
|
|
|
|
return subspace
|
|
|
|
}
|
|
|
|
|
|
|
|
// SimulationManager implements the SimulationApp interface
|
2021-04-18 16:39:15 +00:00
|
|
|
func (app *EthermintApp) SimulationManager() *module.SimulationManager {
|
|
|
|
return app.sm
|
|
|
|
}
|
2021-04-17 10:00:07 +00:00
|
|
|
|
|
|
|
// RegisterAPIRoutes registers all application module routes with the provided
|
|
|
|
// API server.
|
2021-04-18 16:39:15 +00:00
|
|
|
func (app *EthermintApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
|
2021-04-17 10:00:07 +00:00
|
|
|
clientCtx := apiSvr.ClientCtx
|
2021-04-18 16:39:15 +00:00
|
|
|
// Register new tx routes from grpc-gateway.
|
|
|
|
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
|
|
|
|
// Register new tendermint queries routes from grpc-gateway.
|
|
|
|
tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
|
|
|
|
|
2022-07-28 13:43:49 +00:00
|
|
|
// Register grpc-gateway routes for all modules.
|
2021-04-18 16:39:15 +00:00
|
|
|
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
|
2021-04-17 10:00:07 +00:00
|
|
|
|
|
|
|
// register swagger API from root so that other applications can override easily
|
|
|
|
if apiConfig.Swagger {
|
2021-04-18 16:39:15 +00:00
|
|
|
RegisterSwaggerAPI(clientCtx, apiSvr.Router)
|
2021-04-17 10:00:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:43:49 +00:00
|
|
|
// RegisterTxService implements the Application.RegisterTxService method.
|
2021-04-17 10:00:07 +00:00
|
|
|
func (app *EthermintApp) RegisterTxService(clientCtx client.Context) {
|
|
|
|
authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry)
|
|
|
|
}
|
|
|
|
|
2022-07-28 13:43:49 +00:00
|
|
|
// RegisterTendermintService implements the Application.RegisterTendermintService method.
|
2021-04-17 10:00:07 +00:00
|
|
|
func (app *EthermintApp) RegisterTendermintService(clientCtx client.Context) {
|
2022-07-28 13:43:49 +00:00
|
|
|
tmservice.RegisterTendermintService(
|
|
|
|
clientCtx,
|
|
|
|
app.BaseApp.GRPCQueryRouter(),
|
|
|
|
app.interfaceRegistry,
|
|
|
|
app.Query,
|
|
|
|
)
|
2020-04-01 18:49:21 +00:00
|
|
|
}
|
|
|
|
|
2021-04-18 16:39:15 +00:00
|
|
|
// RegisterSwaggerAPI registers swagger route with API Server
|
2021-06-29 17:02:21 +00:00
|
|
|
func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router) {
|
2021-04-18 16:39:15 +00:00
|
|
|
statikFS, err := fs.New()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
staticServer := http.FileServer(statikFS)
|
|
|
|
rtr.PathPrefix("/swagger/").Handler(http.StripPrefix("/swagger/", staticServer))
|
|
|
|
}
|
|
|
|
|
2020-04-01 18:49:21 +00:00
|
|
|
// GetMaccPerms returns a copy of the module account permissions
|
|
|
|
func GetMaccPerms() map[string][]string {
|
|
|
|
dupMaccPerms := make(map[string][]string)
|
|
|
|
for k, v := range maccPerms {
|
|
|
|
dupMaccPerms[k] = v
|
|
|
|
}
|
|
|
|
return dupMaccPerms
|
|
|
|
}
|
2021-04-17 10:00:07 +00:00
|
|
|
|
|
|
|
// initParamsKeeper init params keeper and its subspaces
|
2022-07-28 13:43:49 +00:00
|
|
|
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper {
|
2021-04-17 10:00:07 +00:00
|
|
|
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)
|
|
|
|
|
|
|
|
// SDK subspaces
|
|
|
|
paramsKeeper.Subspace(authtypes.ModuleName)
|
|
|
|
paramsKeeper.Subspace(banktypes.ModuleName)
|
|
|
|
paramsKeeper.Subspace(stakingtypes.ModuleName)
|
|
|
|
paramsKeeper.Subspace(minttypes.ModuleName)
|
|
|
|
paramsKeeper.Subspace(distrtypes.ModuleName)
|
|
|
|
paramsKeeper.Subspace(slashingtypes.ModuleName)
|
2022-07-28 13:43:49 +00:00
|
|
|
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable())
|
2021-04-17 10:00:07 +00:00
|
|
|
paramsKeeper.Subspace(crisistypes.ModuleName)
|
|
|
|
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
|
|
|
|
paramsKeeper.Subspace(ibchost.ModuleName)
|
|
|
|
// ethermint subspaces
|
|
|
|
paramsKeeper.Subspace(evmtypes.ModuleName)
|
2021-08-26 10:08:11 +00:00
|
|
|
paramsKeeper.Subspace(feemarkettypes.ModuleName)
|
2021-04-17 10:00:07 +00:00
|
|
|
return paramsKeeper
|
|
|
|
}
|