adjustments to work with smt/v0.44.6
This commit is contained in:
parent
dbaaef07c7
commit
fc0ade482d
143
app/app.go
143
app/app.go
@ -3,6 +3,13 @@ package app
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/db"
|
||||||
|
types2 "github.com/cosmos/cosmos-sdk/store/types"
|
||||||
|
types3 "github.com/cosmos/cosmos-sdk/store/v2"
|
||||||
|
"github.com/cosmos/cosmos-sdk/store/v2/multi"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/auth/middleware"
|
||||||
|
|
||||||
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -14,13 +21,10 @@ import (
|
|||||||
|
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"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"
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
|
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
|
||||||
"github.com/cosmos/cosmos-sdk/client/rpc"
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||||
"github.com/cosmos/cosmos-sdk/server/api"
|
"github.com/cosmos/cosmos-sdk/server/api"
|
||||||
@ -64,6 +68,8 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||||
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
|
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
|
||||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||||
|
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||||
|
govv1beta2 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta2"
|
||||||
"github.com/cosmos/cosmos-sdk/x/mint"
|
"github.com/cosmos/cosmos-sdk/x/mint"
|
||||||
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
|
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
|
||||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||||
@ -87,7 +93,6 @@ import (
|
|||||||
ibctransferkeeper "github.com/cosmos/ibc-go/modules/apps/transfer/keeper"
|
ibctransferkeeper "github.com/cosmos/ibc-go/modules/apps/transfer/keeper"
|
||||||
ibctransfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types"
|
ibctransfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types"
|
||||||
ibc "github.com/cosmos/ibc-go/modules/core"
|
ibc "github.com/cosmos/ibc-go/modules/core"
|
||||||
ibcclient "github.com/cosmos/ibc-go/modules/core/02-client"
|
|
||||||
ibcclientclient "github.com/cosmos/ibc-go/modules/core/02-client/client"
|
ibcclientclient "github.com/cosmos/ibc-go/modules/core/02-client/client"
|
||||||
porttypes "github.com/cosmos/ibc-go/modules/core/05-port/types"
|
porttypes "github.com/cosmos/ibc-go/modules/core/05-port/types"
|
||||||
ibchost "github.com/cosmos/ibc-go/modules/core/24-host"
|
ibchost "github.com/cosmos/ibc-go/modules/core/24-host"
|
||||||
@ -208,13 +213,15 @@ type EthermintApp struct {
|
|||||||
cdc *codec.LegacyAmino
|
cdc *codec.LegacyAmino
|
||||||
appCodec codec.Codec
|
appCodec codec.Codec
|
||||||
interfaceRegistry types.InterfaceRegistry
|
interfaceRegistry types.InterfaceRegistry
|
||||||
|
legacyRouter *middleware.LegacyRouter
|
||||||
|
msgSvcRouter *middleware.MsgServiceRouter
|
||||||
|
|
||||||
invCheckPeriod uint
|
invCheckPeriod uint
|
||||||
|
|
||||||
// keys to access the substores
|
// keys to access the substores
|
||||||
keys map[string]*sdk.KVStoreKey
|
keys map[string]*types2.KVStoreKey
|
||||||
tkeys map[string]*sdk.TransientStoreKey
|
tkeys map[string]*types2.TransientStoreKey
|
||||||
memKeys map[string]*sdk.MemoryStoreKey
|
memKeys map[string]*types2.MemoryStoreKey
|
||||||
|
|
||||||
// keepers
|
// keepers
|
||||||
AccountKeeper authkeeper.AccountKeeper
|
AccountKeeper authkeeper.AccountKeeper
|
||||||
@ -261,32 +268,19 @@ type EthermintApp struct {
|
|||||||
// NewEthermintApp returns a reference to a new initialized Ethermint application.
|
// NewEthermintApp returns a reference to a new initialized Ethermint application.
|
||||||
func NewEthermintApp(
|
func NewEthermintApp(
|
||||||
logger log.Logger,
|
logger log.Logger,
|
||||||
db dbm.DB,
|
db db.DBConnection,
|
||||||
traceStore io.Writer,
|
traceStore io.Writer,
|
||||||
loadLatest bool,
|
|
||||||
skipUpgradeHeights map[int64]bool,
|
skipUpgradeHeights map[int64]bool,
|
||||||
homePath string,
|
homePath string,
|
||||||
invCheckPeriod uint,
|
invCheckPeriod uint,
|
||||||
encodingConfig simappparams.EncodingConfig,
|
encodingConfig simappparams.EncodingConfig,
|
||||||
appOpts servertypes.AppOptions,
|
appOpts servertypes.AppOptions,
|
||||||
baseAppOptions ...func(*baseapp.BaseApp),
|
baseAppOptions ...baseapp.AppOption,
|
||||||
) *EthermintApp {
|
) *EthermintApp {
|
||||||
appCodec := encodingConfig.Marshaler
|
appCodec := encodingConfig.Codec
|
||||||
cdc := encodingConfig.Amino
|
cdc := encodingConfig.Amino
|
||||||
interfaceRegistry := encodingConfig.InterfaceRegistry
|
interfaceRegistry := encodingConfig.InterfaceRegistry
|
||||||
|
|
||||||
// NOTE we use custom transaction decoder that supports the sdk.Tx interface instead of sdk.StdTx
|
|
||||||
bApp := baseapp.NewBaseApp(
|
|
||||||
appName,
|
|
||||||
logger,
|
|
||||||
db,
|
|
||||||
encodingConfig.TxConfig.TxDecoder(),
|
|
||||||
baseAppOptions...,
|
|
||||||
)
|
|
||||||
bApp.SetCommitMultiStoreTracer(traceStore)
|
|
||||||
bApp.SetVersion(version.Version)
|
|
||||||
bApp.SetInterfaceRegistry(interfaceRegistry)
|
|
||||||
|
|
||||||
keys := sdk.NewKVStoreKeys(
|
keys := sdk.NewKVStoreKeys(
|
||||||
// SDK keys
|
// SDK keys
|
||||||
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
|
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
|
||||||
@ -308,11 +302,57 @@ func NewEthermintApp(
|
|||||||
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey)
|
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey)
|
||||||
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
|
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
|
||||||
|
|
||||||
|
// initialize stores
|
||||||
|
setNamespaces := func(config *multi.StoreParams, ver uint64) error {
|
||||||
|
for _, key := range keys {
|
||||||
|
typ, err := types3.StoreKeyToType(key)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err = config.RegisterSubstore(key, typ); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, key := range memKeys {
|
||||||
|
typ, err := types3.StoreKeyToType(key)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err = config.RegisterSubstore(key, typ); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, key := range tkeys {
|
||||||
|
typ, err := types3.StoreKeyToType(key)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err = config.RegisterSubstore(key, typ); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
baseAppOptions = append(baseAppOptions, baseapp.StoreOption(setNamespaces))
|
||||||
|
|
||||||
|
// NOTE we use custom transaction decoder that supports the sdk.Tx interface instead of sdk.StdTx
|
||||||
|
bApp := baseapp.NewBaseApp(
|
||||||
|
appName,
|
||||||
|
logger,
|
||||||
|
db,
|
||||||
|
baseAppOptions...,
|
||||||
|
)
|
||||||
|
bApp.SetCommitMultiStoreTracer(traceStore)
|
||||||
|
bApp.SetVersion(version.Version)
|
||||||
|
bApp.SetInterfaceRegistry(interfaceRegistry)
|
||||||
|
|
||||||
app := &EthermintApp{
|
app := &EthermintApp{
|
||||||
BaseApp: bApp,
|
BaseApp: bApp,
|
||||||
cdc: cdc,
|
cdc: cdc,
|
||||||
appCodec: appCodec,
|
appCodec: appCodec,
|
||||||
interfaceRegistry: interfaceRegistry,
|
interfaceRegistry: interfaceRegistry,
|
||||||
|
legacyRouter: middleware.NewLegacyRouter(),
|
||||||
|
msgSvcRouter: middleware.NewMsgServiceRouter(interfaceRegistry),
|
||||||
invCheckPeriod: invCheckPeriod,
|
invCheckPeriod: invCheckPeriod,
|
||||||
keys: keys,
|
keys: keys,
|
||||||
tkeys: tkeys,
|
tkeys: tkeys,
|
||||||
@ -322,7 +362,7 @@ func NewEthermintApp(
|
|||||||
// init params keeper and subspaces
|
// init params keeper and subspaces
|
||||||
app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
|
app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
|
||||||
// set the BaseApp's parameter store
|
// set the BaseApp's parameter store
|
||||||
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable()))
|
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()))
|
||||||
|
|
||||||
// add capability keeper and ScopeToModule for ibc module
|
// add capability keeper and ScopeToModule for ibc module
|
||||||
app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
|
app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
|
||||||
@ -337,6 +377,7 @@ func NewEthermintApp(
|
|||||||
// use custom Ethermint account for contracts
|
// use custom Ethermint account for contracts
|
||||||
app.AccountKeeper = authkeeper.NewAccountKeeper(
|
app.AccountKeeper = authkeeper.NewAccountKeeper(
|
||||||
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), ethermint.ProtoAccount, maccPerms,
|
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), ethermint.ProtoAccount, maccPerms,
|
||||||
|
sdk.Bech32MainPrefix,
|
||||||
)
|
)
|
||||||
app.BankKeeper = bankkeeper.NewBaseKeeper(
|
app.BankKeeper = bankkeeper.NewBaseKeeper(
|
||||||
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.BlockedAddrs(),
|
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.BlockedAddrs(),
|
||||||
@ -350,7 +391,7 @@ func NewEthermintApp(
|
|||||||
)
|
)
|
||||||
app.DistrKeeper = distrkeeper.NewKeeper(
|
app.DistrKeeper = distrkeeper.NewKeeper(
|
||||||
appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
|
appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
|
||||||
&stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(),
|
&stakingKeeper, authtypes.FeeCollectorName,
|
||||||
)
|
)
|
||||||
app.SlashingKeeper = slashingkeeper.NewKeeper(
|
app.SlashingKeeper = slashingkeeper.NewKeeper(
|
||||||
appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName),
|
appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName),
|
||||||
@ -367,7 +408,8 @@ func NewEthermintApp(
|
|||||||
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()),
|
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()),
|
||||||
)
|
)
|
||||||
|
|
||||||
app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.BaseApp.MsgServiceRouter())
|
app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec,
|
||||||
|
app.msgSvcRouter, app.AccountKeeper)
|
||||||
|
|
||||||
tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer))
|
tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer))
|
||||||
|
|
||||||
@ -410,16 +452,19 @@ func NewEthermintApp(
|
|||||||
)
|
)
|
||||||
|
|
||||||
// register the proposal types
|
// register the proposal types
|
||||||
govRouter := govtypes.NewRouter()
|
govRouter := govv1beta1.NewRouter()
|
||||||
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
|
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
|
||||||
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
|
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
|
||||||
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
|
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
|
||||||
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
|
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper))
|
||||||
AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))
|
govConfig := govtypes.DefaultConfig()
|
||||||
|
/*
|
||||||
|
Example of setting gov params:
|
||||||
|
govConfig.MaxMetadataLen = 10000
|
||||||
|
*/
|
||||||
govKeeper := govkeeper.NewKeeper(
|
govKeeper := govkeeper.NewKeeper(
|
||||||
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
|
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
|
||||||
&stakingKeeper, govRouter,
|
&stakingKeeper, govRouter, app.msgSvcRouter, govConfig,
|
||||||
)
|
)
|
||||||
|
|
||||||
app.GovKeeper = *govKeeper.SetHooks(
|
app.GovKeeper = *govKeeper.SetHooks(
|
||||||
@ -468,7 +513,7 @@ func NewEthermintApp(
|
|||||||
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
|
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
|
||||||
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
|
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
|
||||||
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
|
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
|
||||||
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
|
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil),
|
||||||
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
|
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
|
||||||
distr.NewAppModule(appCodec, app.DistrKeeper, 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),
|
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
|
||||||
@ -535,8 +580,8 @@ func NewEthermintApp(
|
|||||||
)
|
)
|
||||||
|
|
||||||
app.mm.RegisterInvariants(&app.CrisisKeeper)
|
app.mm.RegisterInvariants(&app.CrisisKeeper)
|
||||||
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
|
app.mm.RegisterRoutes(app.legacyRouter, app.QueryRouter(), encodingConfig.Amino)
|
||||||
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
|
app.configurator = module.NewConfigurator(app.appCodec, app.msgSvcRouter, app.GRPCQueryRouter())
|
||||||
app.mm.RegisterServices(app.configurator)
|
app.mm.RegisterServices(app.configurator)
|
||||||
|
|
||||||
// add test gRPC service for testing gRPC queries in isolation
|
// add test gRPC service for testing gRPC queries in isolation
|
||||||
@ -551,7 +596,7 @@ func NewEthermintApp(
|
|||||||
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
|
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
|
||||||
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
|
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
|
||||||
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
|
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
|
||||||
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
|
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil),
|
||||||
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
|
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
|
||||||
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
|
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
|
||||||
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
|
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
|
||||||
@ -565,17 +610,12 @@ func NewEthermintApp(
|
|||||||
|
|
||||||
app.sm.RegisterStoreDecoders()
|
app.sm.RegisterStoreDecoders()
|
||||||
|
|
||||||
// initialize stores
|
|
||||||
app.MountKVStores(keys)
|
|
||||||
app.MountTransientStores(tkeys)
|
|
||||||
app.MountMemoryStores(memKeys)
|
|
||||||
|
|
||||||
// initialize BaseApp
|
// initialize BaseApp
|
||||||
app.SetInitChainer(app.InitChainer)
|
app.SetInitChainer(app.InitChainer)
|
||||||
app.SetBeginBlocker(app.BeginBlocker)
|
app.SetBeginBlocker(app.BeginBlocker)
|
||||||
|
|
||||||
// use Ethermint's custom AnteHandler
|
// use Ethermint's custom AnteHandler
|
||||||
app.SetAnteHandler(
|
app.SetTxHandler(
|
||||||
ante.NewAnteHandler(
|
ante.NewAnteHandler(
|
||||||
app.AccountKeeper, app.BankKeeper, app.EvmKeeper, app.FeeGrantKeeper, app.IBCKeeper.ChannelKeeper,
|
app.AccountKeeper, app.BankKeeper, app.EvmKeeper, app.FeeGrantKeeper, app.IBCKeeper.ChannelKeeper,
|
||||||
encodingConfig.TxConfig.SignModeHandler(),
|
encodingConfig.TxConfig.SignModeHandler(),
|
||||||
@ -584,12 +624,6 @@ func NewEthermintApp(
|
|||||||
|
|
||||||
app.SetEndBlocker(app.EndBlocker)
|
app.SetEndBlocker(app.EndBlocker)
|
||||||
|
|
||||||
if loadLatest {
|
|
||||||
if err := app.LoadLatestVersion(); err != nil {
|
|
||||||
tmos.Exit(err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
app.ScopedIBCKeeper = scopedIBCKeeper
|
app.ScopedIBCKeeper = scopedIBCKeeper
|
||||||
app.ScopedTransferKeeper = scopedTransferKeeper
|
app.ScopedTransferKeeper = scopedTransferKeeper
|
||||||
|
|
||||||
@ -621,7 +655,7 @@ func (app *EthermintApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain)
|
|||||||
|
|
||||||
// LoadHeight loads state at a particular height
|
// LoadHeight loads state at a particular height
|
||||||
func (app *EthermintApp) LoadHeight(height int64) error {
|
func (app *EthermintApp) LoadHeight(height int64) error {
|
||||||
return app.LoadVersion(height)
|
return errors.New("cannot load arbitrary height")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ModuleAccountAddrs returns all the app's module account addresses.
|
// ModuleAccountAddrs returns all the app's module account addresses.
|
||||||
@ -669,21 +703,21 @@ func (app *EthermintApp) InterfaceRegistry() types.InterfaceRegistry {
|
|||||||
// GetKey returns the KVStoreKey for the provided store key.
|
// GetKey returns the KVStoreKey for the provided store key.
|
||||||
//
|
//
|
||||||
// NOTE: This is solely to be used for testing purposes.
|
// NOTE: This is solely to be used for testing purposes.
|
||||||
func (app *EthermintApp) GetKey(storeKey string) *sdk.KVStoreKey {
|
func (app *EthermintApp) GetKey(storeKey string) *types3.KVStoreKey {
|
||||||
return app.keys[storeKey]
|
return app.keys[storeKey]
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTKey returns the TransientStoreKey for the provided store key.
|
// GetTKey returns the TransientStoreKey for the provided store key.
|
||||||
//
|
//
|
||||||
// NOTE: This is solely to be used for testing purposes.
|
// NOTE: This is solely to be used for testing purposes.
|
||||||
func (app *EthermintApp) GetTKey(storeKey string) *sdk.TransientStoreKey {
|
func (app *EthermintApp) GetTKey(storeKey string) *types3.TransientStoreKey {
|
||||||
return app.tkeys[storeKey]
|
return app.tkeys[storeKey]
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMemKey returns the MemStoreKey for the provided mem key.
|
// GetMemKey returns the MemStoreKey for the provided mem key.
|
||||||
//
|
//
|
||||||
// NOTE: This is solely used for testing purposes.
|
// NOTE: This is solely used for testing purposes.
|
||||||
func (app *EthermintApp) GetMemKey(storeKey string) *sdk.MemoryStoreKey {
|
func (app *EthermintApp) GetMemKey(storeKey string) *types3.MemoryStoreKey {
|
||||||
return app.memKeys[storeKey]
|
return app.memKeys[storeKey]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,7 +738,6 @@ func (app *EthermintApp) SimulationManager() *module.SimulationManager {
|
|||||||
// API server.
|
// API server.
|
||||||
func (app *EthermintApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
|
func (app *EthermintApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
|
||||||
clientCtx := apiSvr.ClientCtx
|
clientCtx := apiSvr.ClientCtx
|
||||||
rpc.RegisterRoutes(clientCtx, apiSvr.Router)
|
|
||||||
|
|
||||||
evmrest.RegisterTxRoutes(clientCtx, apiSvr.Router)
|
evmrest.RegisterTxRoutes(clientCtx, apiSvr.Router)
|
||||||
|
|
||||||
@ -754,7 +787,7 @@ func GetMaccPerms() map[string][]string {
|
|||||||
|
|
||||||
// initParamsKeeper init params keeper and its subspaces
|
// initParamsKeeper init params keeper and its subspaces
|
||||||
func initParamsKeeper(
|
func initParamsKeeper(
|
||||||
appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper {
|
appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey types3.StoreKey) paramskeeper.Keeper {
|
||||||
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)
|
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)
|
||||||
|
|
||||||
// SDK subspaces
|
// SDK subspaces
|
||||||
@ -764,7 +797,7 @@ func initParamsKeeper(
|
|||||||
paramsKeeper.Subspace(minttypes.ModuleName)
|
paramsKeeper.Subspace(minttypes.ModuleName)
|
||||||
paramsKeeper.Subspace(distrtypes.ModuleName)
|
paramsKeeper.Subspace(distrtypes.ModuleName)
|
||||||
paramsKeeper.Subspace(slashingtypes.ModuleName)
|
paramsKeeper.Subspace(slashingtypes.ModuleName)
|
||||||
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable())
|
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1beta2.ParamKeyTable())
|
||||||
paramsKeeper.Subspace(crisistypes.ModuleName)
|
paramsKeeper.Subspace(crisistypes.ModuleName)
|
||||||
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
|
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
|
||||||
paramsKeeper.Subspace(ibchost.ModuleName)
|
paramsKeeper.Subspace(ibchost.ModuleName)
|
||||||
|
@ -2,23 +2,27 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/db/memdb"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/simapp"
|
"github.com/cosmos/cosmos-sdk/simapp"
|
||||||
|
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
dbm "github.com/tendermint/tm-db"
|
|
||||||
|
|
||||||
"github.com/tharsis/ethermint/encoding"
|
"github.com/tharsis/ethermint/encoding"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestEthermintAppExport(t *testing.T) {
|
func TestEthermintAppExport(t *testing.T) {
|
||||||
db := dbm.NewMemDB()
|
db := memdb.NewDB()
|
||||||
app := NewEthermintApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
|
logger, err := log.NewDefaultLogger("plain", "info", false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
app := NewEthermintApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
|
||||||
|
|
||||||
genesisState := NewDefaultGenesisState()
|
genesisState := NewDefaultGenesisState()
|
||||||
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
|
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
|
||||||
@ -35,7 +39,11 @@ func TestEthermintAppExport(t *testing.T) {
|
|||||||
app.Commit()
|
app.Commit()
|
||||||
|
|
||||||
// Making a new app object with the db, so that initchain hasn't been called
|
// Making a new app object with the db, so that initchain hasn't been called
|
||||||
app2 := NewEthermintApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
|
logger, err = log.NewDefaultLogger("plain", "info", false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
app2 := NewEthermintApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
|
||||||
_, err = app2.ExportAppStateAndValidators(false, []string{})
|
_, err = app2.ExportAppStateAndValidators(false, []string{})
|
||||||
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
|
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
|
||||||
}
|
}
|
||||||
|
@ -2,19 +2,18 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/db/memdb"
|
||||||
"github.com/cosmos/cosmos-sdk/simapp"
|
"github.com/cosmos/cosmos-sdk/simapp"
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
dbm "github.com/tendermint/tm-db"
|
|
||||||
"github.com/tharsis/ethermint/encoding"
|
"github.com/tharsis/ethermint/encoding"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BenchmarkEthermintApp_ExportAppStateAndValidators(b *testing.B) {
|
func BenchmarkEthermintApp_ExportAppStateAndValidators(b *testing.B) {
|
||||||
db := dbm.NewMemDB()
|
db := memdb.NewDB()
|
||||||
app := NewEthermintApp(log.NewTMLogger(io.Discard), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
|
app := NewEthermintApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
|
||||||
|
|
||||||
genesisState := NewDefaultGenesisState()
|
genesisState := NewDefaultGenesisState()
|
||||||
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
|
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
|
||||||
@ -36,7 +35,7 @@ func BenchmarkEthermintApp_ExportAppStateAndValidators(b *testing.B) {
|
|||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
// Making a new app object with the db, so that initchain hasn't been called
|
// Making a new app object with the db, so that initchain hasn't been called
|
||||||
app2 := NewEthermintApp(log.NewTMLogger(log.NewSyncWriter(io.Discard)), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
|
app2 := NewEthermintApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
|
||||||
if _, err := app2.ExportAppStateAndValidators(false, []string{}); err != nil {
|
if _, err := app2.ExportAppStateAndValidators(false, []string{}); err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
// NewDefaultGenesisState generates the default state for the application.
|
// NewDefaultGenesisState generates the default state for the application.
|
||||||
func NewDefaultGenesisState() simapp.GenesisState {
|
func NewDefaultGenesisState() simapp.GenesisState {
|
||||||
encCfg := encoding.MakeConfig(ModuleBasics)
|
encCfg := encoding.MakeConfig(ModuleBasics)
|
||||||
return ModuleBasics.DefaultGenesis(encCfg.Marshaler)
|
return ModuleBasics.DefaultGenesis(encCfg.Codec)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExportAppStateAndValidators exports the state of the application for a genesis
|
// ExportAppStateAndValidators exports the state of the application for a genesis
|
||||||
|
@ -2,10 +2,12 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/db/memdb"
|
||||||
"github.com/cosmos/cosmos-sdk/simapp"
|
"github.com/cosmos/cosmos-sdk/simapp"
|
||||||
"github.com/tharsis/ethermint/encoding"
|
"github.com/tharsis/ethermint/encoding"
|
||||||
|
|
||||||
@ -13,13 +15,12 @@ import (
|
|||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
dbm "github.com/tendermint/tm-db"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultConsensusParams defines the default Tendermint consensus params used in
|
// DefaultConsensusParams defines the default Tendermint consensus params used in
|
||||||
// EthermintApp testing.
|
// EthermintApp testing.
|
||||||
var DefaultConsensusParams = &abci.ConsensusParams{
|
var DefaultConsensusParams = &tmproto.ConsensusParams{
|
||||||
Block: &abci.BlockParams{
|
Block: &tmproto.BlockParams{
|
||||||
MaxBytes: 200000,
|
MaxBytes: 200000,
|
||||||
MaxGas: -1, // no limit
|
MaxGas: -1, // no limit
|
||||||
},
|
},
|
||||||
@ -37,7 +38,7 @@ var DefaultConsensusParams = &abci.ConsensusParams{
|
|||||||
|
|
||||||
// Setup initializes a new EthermintApp. A Nop logger is set in EthermintApp.
|
// Setup initializes a new EthermintApp. A Nop logger is set in EthermintApp.
|
||||||
func Setup(isCheckTx bool) *EthermintApp {
|
func Setup(isCheckTx bool) *EthermintApp {
|
||||||
db := dbm.NewMemDB()
|
db := memdb.NewDB()
|
||||||
app := NewEthermintApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
|
app := NewEthermintApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
|
||||||
if !isCheckTx {
|
if !isCheckTx {
|
||||||
// init chain must be called to stop deliverState from being nil
|
// init chain must be called to stop deliverState from being nil
|
||||||
|
Loading…
Reference in New Issue
Block a user