From b037765c85d3c4bc0e3f01a2e087c4d32f674d54 Mon Sep 17 00:00:00 2001 From: emidev98 Date: Mon, 11 Mar 2024 13:42:38 +0200 Subject: [PATCH 1/2] fix: app encodings and remove unnecessary code --- app/app.go | 204 +++++++++++------------------------ app/app_test.go | 1 - app/export.go | 2 +- app/genesis.go | 23 ---- app/params/encoding.go | 2 +- app/params/proto.go | 36 ------- app/simulation_test.go | 4 - app/test_helpers.go | 22 ++-- cmd/allianced/cmd/root.go | 106 +++++++++++------- cmd/allianced/cmd/testnet.go | 1 + go.mod | 3 +- testutil/network/network.go | 82 -------------- x/alliance/module.go | 2 - 13 files changed, 142 insertions(+), 346 deletions(-) delete mode 100644 app/genesis.go delete mode 100644 app/params/proto.go delete mode 100644 testutil/network/network.go diff --git a/app/app.go b/app/app.go index fe03eb8c..7af1ab24 100644 --- a/app/app.go +++ b/app/app.go @@ -28,11 +28,13 @@ import ( "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/server/api" "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/cosmos/cosmos-sdk/std" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" @@ -48,9 +50,7 @@ import ( "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" - "github.com/cosmos/cosmos-sdk/x/bank" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - consensus "github.com/cosmos/cosmos-sdk/x/consensus" consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" "github.com/cosmos/cosmos-sdk/x/crisis" @@ -65,7 +65,6 @@ import ( govclient "github.com/cosmos/cosmos-sdk/x/gov/client" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/group" groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper" @@ -74,7 +73,6 @@ import ( mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" "github.com/cosmos/cosmos-sdk/x/params" - paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" 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" @@ -84,26 +82,22 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/cosmos/gogoproto/proto" "github.com/cosmos/ibc-go/modules/capability" capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts" - icahost "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host" - icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper" - icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" - icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" "github.com/cosmos/ibc-go/v8/modules/apps/transfer" ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ibc "github.com/cosmos/ibc-go/v8/modules/core" + ibcclient "github.com/cosmos/ibc-go/v8/modules/core/02-client" + ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ibcporttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" - solomachine "github.com/cosmos/ibc-go/v8/modules/light-clients/06-solomachine" - ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibc_tm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/spf13/cast" - appparams "github.com/terra-money/alliance/app/params" custombankmodule "github.com/terra-money/alliance/custom/bank" custombankkeeper "github.com/terra-money/alliance/custom/bank/keeper" @@ -111,11 +105,10 @@ import ( "github.com/terra-money/alliance/docs" + "cosmossdk.io/x/tx/signing" alliancemodule "github.com/terra-money/alliance/x/alliance" - alliancemoduleclient "github.com/terra-money/alliance/x/alliance/client" alliancemodulekeeper "github.com/terra-money/alliance/x/alliance/keeper" alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types" - // this line is used by starport scaffolding # stargate/app/moduleImport ) const ( @@ -123,62 +116,14 @@ const ( Name = "alliance" ) -// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals - -func getGovProposalHandlers() []govclient.ProposalHandler { - var govProposalHandlers []govclient.ProposalHandler - // this line is used by starport scaffolding # stargate/app/govProposalHandlers - - govProposalHandlers = append(govProposalHandlers, - paramsclient.ProposalHandler, - alliancemoduleclient.CreateAllianceProposalHandler, - alliancemoduleclient.UpdateAllianceProposalHandler, - alliancemoduleclient.DeleteAllianceProposalHandler, - // this line is used by starport scaffolding # stargate/app/govProposalHandler - ) - - return govProposalHandlers -} - var ( // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string - // ModuleBasics defines the module BasicManager is in charge of setting up basic, - // non-dependant module elements, such as codec registration - // and genesis verification. - ModuleBasics = module.NewBasicManager( - auth.AppModuleBasic{}, - genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), - authzmodule.AppModuleBasic{}, - bank.AppModuleBasic{}, - capability.AppModuleBasic{}, - staking.AppModuleBasic{}, - mint.AppModuleBasic{}, - distr.AppModuleBasic{}, - gov.NewAppModuleBasic(getGovProposalHandlers()), - params.AppModuleBasic{}, - crisis.AppModuleBasic{}, - slashing.AppModuleBasic{}, - feegrantmodule.AppModuleBasic{}, - groupmodule.AppModuleBasic{}, - ibc.AppModuleBasic{}, - ibctm.AppModuleBasic{}, - solomachine.AppModuleBasic{}, - upgrade.AppModuleBasic{}, - evidence.AppModuleBasic{}, - transfer.AppModuleBasic{}, - ica.AppModuleBasic{}, - vesting.AppModuleBasic{}, - consensus.AppModuleBasic{}, - alliancemodule.AppModuleBasic{}, - ) - // module account permissions maccPerms = map[string][]string{ authtypes.FeeCollectorName: nil, distrtypes.ModuleName: nil, - icatypes.ModuleName: nil, minttypes.ModuleName: {authtypes.Minter}, stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, @@ -186,7 +131,6 @@ var ( ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, alliancemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner}, alliancemoduletypes.RewardsPoolName: nil, - // this line is used by starport scaffolding # stargate/app/maccPerms } ) @@ -210,7 +154,7 @@ func init() { type App struct { *baseapp.BaseApp - cdc *codec.LegacyAmino + legacyAmino *codec.LegacyAmino appCodec codec.Codec txConfig client.TxConfig interfaceRegistry types.InterfaceRegistry @@ -238,7 +182,6 @@ type App struct { 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 - ICAHostKeeper icahostkeeper.Keeper FeeGrantKeeper feegrantkeeper.Keeper GroupKeeper groupkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper @@ -246,14 +189,12 @@ type App struct { // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper ScopedTransferKeeper capabilitykeeper.ScopedKeeper - ScopedICAHostKeeper capabilitykeeper.ScopedKeeper AllianceKeeper alliancemodulekeeper.Keeper - // this line is used by starport scaffolding # stargate/app/keeperDeclaration - // mm is the module manager - mm *module.Manager - bmm module.BasicManager + // ModuleManager is the module manager + ModuleManager *module.Manager + BasicModuleManager module.BasicManager // sm is the simulation manager sm *module.SimulationManager @@ -269,15 +210,29 @@ func New( skipUpgradeHeights map[int64]bool, homePath string, invCheckPeriod uint, - encodingConfig appparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *App { - appCodec := encodingConfig.Marshaler - cdc := encodingConfig.Amino - txConfig := encodingConfig.TxConfig - interfaceRegistry := encodingConfig.InterfaceRegistry - bApp := baseapp.NewBaseApp(Name, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) + interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ + ProtoFiles: proto.HybridResolver, + SigningOptions: signing.Options{ + AddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(), + }, + ValidatorAddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), + }, + }, + }) + appCodec := codec.NewProtoCodec(interfaceRegistry) + legacyAmino := codec.NewLegacyAmino() + txConfig := authtx.NewTxConfig(appCodec, authtx.DefaultSignModes) + + ibc_tm.RegisterInterfaces(interfaceRegistry) + std.RegisterLegacyAminoCodec(legacyAmino) + std.RegisterInterfaces(interfaceRegistry) + + bApp := baseapp.NewBaseApp(Name, logger, db, txConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) @@ -286,17 +241,16 @@ func New( keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, authz.ModuleName, banktypes.StoreKey, stakingtypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, - paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, - ibctransfertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, group.StoreKey, + paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, + evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, group.StoreKey, alliancemoduletypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey, - // this line is used by starport scaffolding # stargate/app/storeKey ) tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) app := &App{ BaseApp: bApp, - cdc: cdc, + legacyAmino: legacyAmino, appCodec: appCodec, txConfig: txConfig, interfaceRegistry: interfaceRegistry, @@ -308,7 +262,7 @@ func New( app.ParamsKeeper = initParamsKeeper( appCodec, - cdc, + legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey], ) @@ -327,8 +281,6 @@ func New( // grant capabilities for the ibc and ibc-transfer modules scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) - scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) - // this line is used by starport scaffolding # stargate/app/scopedKeeper // add keepers app.AccountKeeper = authkeeper.NewAccountKeeper( @@ -389,7 +341,7 @@ func New( app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, - cdc, + legacyAmino, runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), @@ -479,21 +431,6 @@ func New( transferModule := transfer.NewAppModule(app.TransferKeeper) transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) - app.ICAHostKeeper = icahostkeeper.NewKeeper( - appCodec, - keys[icahosttypes.StoreKey], - app.GetSubspace(icahosttypes.SubModuleName), - app.IBCKeeper.ChannelKeeper, - app.IBCKeeper.ChannelKeeper, - app.IBCKeeper.PortKeeper, - app.AccountKeeper, - scopedICAHostKeeper, - app.MsgServiceRouter(), - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper) - icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper) - // Create evidence Keeper for to register the IBC light client misbehaviour evidence route evidenceKeeper := evidencekeeper.NewKeeper( appCodec, @@ -509,7 +446,8 @@ func New( govRouter := govv1beta1.NewRouter() govRouter. AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). - AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)) + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). + AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) govConfig := govtypes.DefaultConfig() /* Example of setting gov params: @@ -534,13 +472,9 @@ func New( ), ) - // this line is used by starport scaffolding # stargate/app/keeperDefinition - // Create static IBC router, add transfer route, then set and seal it ibcRouter := ibcporttypes.NewRouter() - ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). - AddRoute(ibctransfertypes.ModuleName, transferIBCModule) - // this line is used by starport scaffolding # ibc/app/router + ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule) app.IBCKeeper.SetRouter(ibcRouter) /**** Module Options ****/ @@ -552,10 +486,10 @@ func New( // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. - app.mm = module.NewManager( + app.ModuleManager = module.NewManager( genutil.NewAppModule( app.AccountKeeper, app.StakingKeeper, app, - encodingConfig.TxConfig, + txConfig, ), auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), @@ -575,29 +509,29 @@ func New( ibc.NewAppModule(app.IBCKeeper), params.NewAppModule(app.ParamsKeeper), transferModule, - icaModule, alliancemodule.NewAppModule(appCodec, app.AllianceKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry, app.GetSubspace(alliancemoduletypes.ModuleName)), - // this line is used by starport scaffolding # stargate/app/appModule ) // BasicModuleManager defines the module BasicManager is in charge of setting up basic, // non-dependant module elements, such as codec registration and genesis verification. // By default it is composed of all the module from the module manager. // Additionally, app module basics can be overwritten by passing them as argument. - app.bmm = module.NewBasicManagerFromManager( - app.mm, + app.BasicModuleManager = module.NewBasicManagerFromManager( + app.ModuleManager, map[string]module.AppModuleBasic{ genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), govtypes.ModuleName: gov.NewAppModuleBasic( []govclient.ProposalHandler{}, ), }) + app.BasicModuleManager.RegisterLegacyAminoCodec(app.legacyAmino) + app.BasicModuleManager.RegisterInterfaces(app.interfaceRegistry) // 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. // NOTE: staking module is required if HistoricalEntries param > 0 - app.mm.SetOrderBeginBlockers( + app.ModuleManager.SetOrderBeginBlockers( // upgrades should be run first upgradetypes.ModuleName, capabilitytypes.ModuleName, @@ -611,7 +545,6 @@ func New( govtypes.ModuleName, crisistypes.ModuleName, ibctransfertypes.ModuleName, - icatypes.ModuleName, ibcexported.ModuleName, genutiltypes.ModuleName, authz.ModuleName, @@ -620,16 +553,14 @@ func New( paramstypes.ModuleName, vestingtypes.ModuleName, alliancemoduletypes.ModuleName, - // this line is used by starport scaffolding # stargate/app/beginBlockers ) - app.mm.SetOrderEndBlockers( + app.ModuleManager.SetOrderEndBlockers( crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, ibctransfertypes.ModuleName, ibcexported.ModuleName, - icatypes.ModuleName, capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, @@ -645,7 +576,6 @@ func New( upgradetypes.ModuleName, vestingtypes.ModuleName, alliancemoduletypes.ModuleName, - // this line is used by starport scaffolding # stargate/app/endBlockers ) // NOTE: The genutils module must occur after staking so that pools are @@ -653,7 +583,7 @@ func New( // 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. - app.mm.SetOrderInitGenesis( + app.ModuleManager.SetOrderInitGenesis( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, @@ -666,7 +596,6 @@ func New( genutiltypes.ModuleName, ibctransfertypes.ModuleName, ibcexported.ModuleName, - icatypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, @@ -675,16 +604,15 @@ func New( upgradetypes.ModuleName, vestingtypes.ModuleName, alliancemoduletypes.ModuleName, - // this line is used by starport scaffolding # stargate/app/initGenesis ) - // Uncomment if you want to set a custom migration order here. - // app.mm.SetOrderMigrations(custom order) + // UncoModuleManagerent if you want to set a custom migration order here. + // app.ModuleManager.SetOrderMigrations(custom order) - app.mm.RegisterInvariants(&app.CrisisKeeper) + app.ModuleManager.RegisterInvariants(&app.CrisisKeeper) app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) - if err := app.mm.RegisterServices(app.configurator); err != nil { + if err := app.ModuleManager.RegisterServices(app.configurator); err != nil { panic(err) } @@ -697,7 +625,7 @@ func New( } // create the simulation manager and define the order of the modules for deterministic simulations app.sm = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, overrideModules) - app.sm = module.NewSimulationManagerFromAppModules(app.mm.Modules, overrideModules) + app.sm = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, overrideModules) app.sm.RegisterStoreDecoders() @@ -714,7 +642,7 @@ func New( ante.HandlerOptions{ AccountKeeper: app.AccountKeeper, BankKeeper: app.BankKeeper, - SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), + SignModeHandler: txConfig.SignModeHandler(), FeegrantKeeper: app.FeeGrantKeeper, SigGasConsumer: ante.DefaultSigVerificationGasConsumer, }, @@ -736,7 +664,6 @@ func New( app.ScopedIBCKeeper = scopedIBCKeeper app.ScopedTransferKeeper = scopedTransferKeeper - // this line is used by starport scaffolding # stargate/app/beforeInitReturn return app } @@ -749,24 +676,24 @@ func (app App) GetBaseApp() *baseapp.BaseApp { return app.BaseApp } // BeginBlocker application updates every begin block func (app *App) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { - return app.mm.BeginBlock(ctx) + return app.ModuleManager.BeginBlock(ctx) } // EndBlocker application updates every end block func (app *App) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { - return app.mm.EndBlock(ctx) + return app.ModuleManager.EndBlock(ctx) } // InitChainer application update at chain initialization func (app *App) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { - var genesisState GenesisState + var genesisState map[string]json.RawMessage if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) } - if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()); err != nil { + if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil { return nil, err } - return app.mm.InitGenesis(ctx, app.appCodec, genesisState) + return app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState) } // LoadHeight loads a particular height @@ -799,7 +726,7 @@ func (app *App) BlockedModuleAccountAddrs() map[string]bool { // 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 *App) LegacyAmino() *codec.LegacyAmino { - return app.cdc + return app.legacyAmino } // AppCodec returns an app codec. @@ -829,7 +756,7 @@ func (app *App) TxConfig() client.TxConfig { // DefaultGenesis returns a default genesis from the registered AppModuleBasic's. func (app *App) DefaultGenesis() map[string]json.RawMessage { - return ModuleBasics.DefaultGenesis(app.appCodec) + return app.BasicModuleManager.DefaultGenesis(app.appCodec) } // GetTKey returns the TransientStoreKey for the provided store key. @@ -864,7 +791,7 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, _ config.APIConfig) { cmtservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register grpc-gateway routes for all modules. - ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + app.BasicModuleManager.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // register app's OpenAPI routes. apiSvr.Router.Handle("/static/openapi.yml", http.FileServer(http.FS(docs.Docs))) @@ -911,13 +838,10 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(minttypes.ModuleName).WithKeyTable(minttypes.ParamKeyTable()) paramsKeeper.Subspace(distrtypes.ModuleName).WithKeyTable(distrtypes.ParamKeyTable()) paramsKeeper.Subspace(slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable()) - paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) paramsKeeper.Subspace(crisistypes.ModuleName).WithKeyTable(crisistypes.ParamKeyTable()) paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibcexported.ModuleName) - paramsKeeper.Subspace(icahosttypes.SubModuleName) paramsKeeper.Subspace(alliancemoduletypes.ModuleName).WithKeyTable(alliancemoduletypes.ParamKeyTable()) - // this line is used by starport scaffolding # stargate/app/paramSubspace return paramsKeeper } @@ -926,7 +850,3 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino func (app *App) SimulationManager() *module.SimulationManager { return app.sm } - -func (app *App) BasicModuleManager() module.BasicManager { - return app.bmm -} diff --git a/app/app_test.go b/app/app_test.go index 8aed6a26..bf20dfd7 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -23,7 +23,6 @@ func TestAppExportAndBlockedAddrs(t *testing.T) { map[int64]bool{}, DefaultNodeHome, 0, - MakeTestEncodingConfig(), EmptyAppOptions{}, ) blockedAddrs := app.BlockedModuleAccountAddrs() diff --git a/app/export.go b/app/export.go index e2bf9a6d..e4894f69 100644 --- a/app/export.go +++ b/app/export.go @@ -31,7 +31,7 @@ func (app *App) ExportAppStateAndValidators( app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs) } - genState, err := app.mm.ExportGenesisForModules(ctx, app.appCodec, modulesToExport) + genState, err := app.ModuleManager.ExportGenesisForModules(ctx, app.appCodec, modulesToExport) if err != nil { return servertypes.ExportedApp{}, err } diff --git a/app/genesis.go b/app/genesis.go deleted file mode 100644 index 4fa23224..00000000 --- a/app/genesis.go +++ /dev/null @@ -1,23 +0,0 @@ -package app - -import ( - "encoding/json" - - "github.com/cosmos/cosmos-sdk/codec" -) - -// The genesis state of the blockchain is represented here as a map of raw json -// messages key'd by a identifier string. -// The identifier is used to determine which module genesis information belongs -// to so it may be appropriately routed during init chain. -// Within this application default genesis information is retrieved from -// the ModuleBasicManager which populates json from each BasicModule -// object provided to it during init. -type GenesisState map[string]json.RawMessage - -// NewDefaultGenesisState generates the default state for the application. -func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState { - defaultGenesis := ModuleBasics.DefaultGenesis(cdc) - - return defaultGenesis -} diff --git a/app/params/encoding.go b/app/params/encoding.go index 3d634abf..8ff9ea04 100644 --- a/app/params/encoding.go +++ b/app/params/encoding.go @@ -10,7 +10,7 @@ import ( // This is provided for compatibility between protobuf and amino implementations. type EncodingConfig struct { InterfaceRegistry types.InterfaceRegistry - Marshaler codec.Codec + Codec codec.Codec TxConfig client.TxConfig Amino *codec.LegacyAmino } diff --git a/app/params/proto.go b/app/params/proto.go deleted file mode 100644 index 0d8945f5..00000000 --- a/app/params/proto.go +++ /dev/null @@ -1,36 +0,0 @@ -package params - -import ( - "cosmossdk.io/x/tx/signing" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/address" - "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/tx" - "github.com/cosmos/gogoproto/proto" -) - -// MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. -func MakeEncodingConfig() EncodingConfig { - amino := codec.NewLegacyAmino() - interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ - ProtoFiles: proto.HybridResolver, - SigningOptions: signing.Options{ - AddressCodec: address.Bech32Codec{ - Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(), - }, - ValidatorAddressCodec: address.Bech32Codec{ - Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), - }, - }, - }) - marshaler := codec.NewProtoCodec(interfaceRegistry) - txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes) - - return EncodingConfig{ - InterfaceRegistry: interfaceRegistry, - Marshaler: marshaler, - TxConfig: txCfg, - Amino: amino, - } -} diff --git a/app/simulation_test.go b/app/simulation_test.go index 88bd9ec2..d81ba781 100644 --- a/app/simulation_test.go +++ b/app/simulation_test.go @@ -58,7 +58,6 @@ func TestFullAppSimulation(t *testing.T) { map[int64]bool{}, app.DefaultNodeHome, simcli.FlagPeriodValue, - app.MakeTestEncodingConfig(), simtestutil.EmptyAppOptions{}, baseapp.SetChainID(simulationAppChainID), ) @@ -107,8 +106,6 @@ func BenchmarkSimulation(b *testing.B) { require.NoError(b, err) }) - encoding := app.MakeTestEncodingConfig() - app := app.New(logger, db, nil, @@ -116,7 +113,6 @@ func BenchmarkSimulation(b *testing.B) { map[int64]bool{}, app.DefaultNodeHome, 0, - encoding, simtestutil.EmptyAppOptions{}, ) diff --git a/app/test_helpers.go b/app/test_helpers.go index f4471f69..085b39c0 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -23,7 +23,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" servertypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/cosmos/cosmos-sdk/std" "github.com/cosmos/cosmos-sdk/testutil/mock" "github.com/cosmos/cosmos-sdk/testutil/network" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -113,15 +112,14 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs return app } -func setup(withGenesis bool, invCheckPeriod uint) (*App, GenesisState) { +func setup(withGenesis bool, invCheckPeriod uint) (*App, map[string]json.RawMessage) { db := dbm.NewMemDB() - encCdc := MakeTestEncodingConfig() - app := New(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, invCheckPeriod, encCdc, EmptyAppOptions{}) + app := New(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, invCheckPeriod, EmptyAppOptions{}) if withGenesis { - return app, NewDefaultGenesisState(encCdc.Marshaler) + return app, app.DefaultGenesis() } - return app, GenesisState{} + return app, app.DefaultGenesis() } func MakeTestEncodingConfig() params.EncodingConfig { @@ -141,16 +139,11 @@ func MakeTestEncodingConfig() params.EncodingConfig { encodingConfig := params.EncodingConfig{ InterfaceRegistry: interfaceRegistry, - Marshaler: pcdc, + Codec: pcdc, TxConfig: tx.NewTxConfig(pcdc, tx.DefaultSignModes), Amino: cdc, } - std.RegisterLegacyAminoCodec(encodingConfig.Amino) - std.RegisterInterfaces(encodingConfig.InterfaceRegistry) - ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) - ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) - return encodingConfig } @@ -311,13 +304,12 @@ func NewTestNetworkFixture() network.TestFixture { map[int64]bool{}, dir, 0, - MakeTestEncodingConfig(), EmptyAppOptions{}, ) appCtr := func(val network.ValidatorI) servertypes.Application { return New( val.GetCtx().Logger, dbm.NewMemDB(), nil, true, map[int64]bool{}, - val.GetCtx().Config.RootDir, 0, MakeTestEncodingConfig(), + val.GetCtx().Config.RootDir, 0, EmptyAppOptions{}, bam.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)), bam.SetMinGasPrices(val.GetAppConfig().MinGasPrices), @@ -326,7 +318,7 @@ func NewTestNetworkFixture() network.TestFixture { return network.TestFixture{ AppConstructor: appCtr, - GenesisState: NewDefaultGenesisState(app.AppCodec()), + GenesisState: app.DefaultGenesis(), EncodingConfig: testutil.TestEncodingConfig{ InterfaceRegistry: app.InterfaceRegistry(), Codec: app.AppCodec(), diff --git a/cmd/allianced/cmd/root.go b/cmd/allianced/cmd/root.go index 26b0f826..cb19b803 100644 --- a/cmd/allianced/cmd/root.go +++ b/cmd/allianced/cmd/root.go @@ -5,8 +5,13 @@ import ( "io" "os" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/types/tx/signing" authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" + "github.com/cosmos/cosmos-sdk/x/auth/tx" + "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/spf13/cast" @@ -25,15 +30,17 @@ import ( "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" + simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli" "github.com/terra-money/alliance/app" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" + txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/crisis" - "github.com/cosmos/cosmos-sdk/x/genutil" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" @@ -43,9 +50,27 @@ import ( // NewRootCmd creates a new root command for simd. It is called once in the // main function. func NewRootCmd() (*cobra.Command, params.EncodingConfig) { - encodingConfig := app.MakeTestEncodingConfig() + // we "pre"-instantiate the application for getting the injected/configured encoding configuration + // note, this is not necessary when using app wiring, as depinject can be directly used (see root_v2.go) + tempApp := app.New(log.NewNopLogger(), + dbm.NewMemDB(), + nil, + true, + map[int64]bool{}, + app.DefaultNodeHome, + simcli.FlagPeriodValue, + simtestutil.EmptyAppOptions{}, + baseapp.SetChainID("alliance-testnet-1"), + ) + + encodingConfig := params.EncodingConfig{ + InterfaceRegistry: tempApp.InterfaceRegistry(), + Codec: tempApp.AppCodec(), + TxConfig: tempApp.TxConfig(), + Amino: tempApp.LegacyAmino(), + } initClientCtx := client.Context{}. - WithCodec(encodingConfig.Marshaler). + WithCodec(encodingConfig.Codec). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). @@ -72,6 +97,22 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { return err } + // This needs to go after ReadFromClientConfig, as that function + // sets the RPC client needed for SIGN_MODE_TEXTUAL. + enabledSignModes := append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) //nolint:gocritic // we know we aren't appending to the same slice + txConfigOpts := tx.ConfigOptions{ + EnabledSignModes: enabledSignModes, + TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx), + } + txConfigWithTextual, err := tx.NewTxConfigWithOptions( + codec.NewProtoCodec(encodingConfig.InterfaceRegistry), + txConfigOpts, + ) + if err != nil { + return err + } + initClientCtx = initClientCtx.WithTxConfig(txConfigWithTextual) + if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil { return err } @@ -83,7 +124,7 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { }, } - initRootCmd(rootCmd, encodingConfig) + initRootCmd(rootCmd, encodingConfig, tempApp.BasicModuleManager) return rootCmd, encodingConfig } @@ -157,44 +198,30 @@ lru_size = 0` return customAppTemplate, customAppConfig } -func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { +func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, basicManager module.BasicManager) { cfg := sdk.GetConfig() cfg.Seal() - gentxModule := app.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic) - a := appCreator{encodingConfig} - - tempApp := app.New( - log.NewNopLogger(), - dbm.NewMemDB(), - nil, - true, - map[int64]bool{}, - app.DefaultNodeHome, - 0, - encodingConfig, - app.EmptyAppOptions{}, - ) - mb := tempApp.BasicModuleManager() + gentxModule := basicManager[genutiltypes.ModuleName].(genutil.AppModuleBasic) rootCmd.AddCommand( - genutilcli.InitCmd(mb, app.DefaultNodeHome), + genutilcli.InitCmd(basicManager, app.DefaultNodeHome), genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, gentxModule.GenTxValidator, authcodec.NewBech32Codec(sdk.Bech32PrefixValAddr)), genutilcli.MigrateGenesisCmd(genutiltypes.MigrationMap{}), - genutilcli.GenTxCmd(mb, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, authcodec.NewBech32Codec(sdk.Bech32PrefixValAddr)), - genutilcli.ValidateGenesisCmd(mb), - genesisCommand(encodingConfig, tempApp.BasicModuleManager()), + genutilcli.GenTxCmd(basicManager, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, authcodec.NewBech32Codec(sdk.Bech32PrefixValAddr)), + genutilcli.ValidateGenesisCmd(basicManager), + genesisCommand(encodingConfig, basicManager), tmcli.NewCompletionCmd(rootCmd, true), - NewTestnetCmd(mb, banktypes.GenesisBalancesIterator{}), + NewTestnetCmd(basicManager, banktypes.GenesisBalancesIterator{}), debug.Cmd(), ) - server.AddCommands(rootCmd, app.DefaultNodeHome, a.newApp, a.appExport, addModuleInitFlags) + server.AddCommands(rootCmd, app.DefaultNodeHome, newApp, appExport, addModuleInitFlags) // add keybase, auxiliary RPC, query, and tx child commands rootCmd.AddCommand( queryCommand(), - txCommand(mb), + txCommand(), keys.Commands(), ) } @@ -228,14 +255,11 @@ func queryCommand() *cobra.Command { authcmd.QueryTxsByEventsCmd(), authcmd.QueryTxCmd(), ) - - app.ModuleBasics.AddQueryCommands(cmd) cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") - return cmd } -func txCommand(manager module.BasicManager) *cobra.Command { +func txCommand() *cobra.Command { cmd := &cobra.Command{ Use: "tx", Short: "Transactions subcommands", @@ -254,7 +278,6 @@ func txCommand(manager module.BasicManager) *cobra.Command { authcmd.GetEncodeCommand(), authcmd.GetDecodeCommand(), ) - manager.AddTxCommands(cmd) cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") return cmd @@ -265,7 +288,7 @@ type appCreator struct { } // newApp is an appCreator -func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application { +func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application { baseappOptions := server.DefaultBaseappOptions(appOpts) skipUpgradeHeights := make(map[int64]bool) @@ -277,7 +300,6 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a logger, db, traceStore, true, skipUpgradeHeights, cast.ToString(appOpts.Get(flags.FlagHome)), cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), - a.encCfg, appOpts, baseappOptions..., ) @@ -285,7 +307,7 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a // appExport creates a new app (optionally at a given height) // and exports state. -func (a appCreator) appExport( +func appExport( logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, appOpts servertypes.AppOptions, modulesToExport []string, ) (servertypes.ExportedApp, error) { var simApp *app.App @@ -295,14 +317,24 @@ func (a appCreator) appExport( } if height != -1 { - simApp = app.New(logger, db, traceStore, false, map[int64]bool{}, homePath, uint(1), a.encCfg, appOpts) + simApp = app.New(logger, db, traceStore, false, map[int64]bool{}, homePath, uint(1), appOpts) if err := simApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } else { - simApp = app.New(logger, db, traceStore, true, map[int64]bool{}, homePath, uint(1), a.encCfg, appOpts) + simApp = app.New(logger, db, traceStore, true, map[int64]bool{}, homePath, uint(1), appOpts) } return simApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) } + +var tempDir = func() string { + dir, err := os.MkdirTemp("", "alliance") + if err != nil { + dir = app.DefaultNodeHome + } + defer os.RemoveAll(dir) + + return dir +} diff --git a/cmd/allianced/cmd/testnet.go b/cmd/allianced/cmd/testnet.go index 497e1e87..115e9d4d 100644 --- a/cmd/allianced/cmd/testnet.go +++ b/cmd/allianced/cmd/testnet.go @@ -216,6 +216,7 @@ func initTestnetFiles( appConfig := srvconfig.DefaultConfig() appConfig.MinGasPrices = args.minGasPrices appConfig.API.Enable = true + appConfig.API.Swagger = true appConfig.Telemetry.Enabled = true appConfig.Telemetry.PrometheusRetentionTime = 60 appConfig.Telemetry.EnableHostnameLabel = false diff --git a/go.mod b/go.mod index 2bc6e00b..da86135b 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( cosmossdk.io/store v1.0.2 cosmossdk.io/x/evidence v0.1.0 cosmossdk.io/x/feegrant v0.1.0 + cosmossdk.io/x/tx v0.13.0 cosmossdk.io/x/upgrade v0.1.0 github.com/cometbft/cometbft v0.38.5 github.com/cosmos/cosmos-db v1.0.0 @@ -42,7 +43,6 @@ require ( cosmossdk.io/api v0.7.3 // indirect cosmossdk.io/collections v0.4.0 // indirect cosmossdk.io/depinject v1.0.0-alpha.4 // indirect - cosmossdk.io/x/tx v0.13.0 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect @@ -183,7 +183,6 @@ require ( google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect nhooyr.io/websocket v1.8.6 // indirect diff --git a/testutil/network/network.go b/testutil/network/network.go deleted file mode 100644 index cc00645c..00000000 --- a/testutil/network/network.go +++ /dev/null @@ -1,82 +0,0 @@ -package network - -import ( - "fmt" - "testing" - "time" - - pruningtypes "cosmossdk.io/store/pruning/types" - tmrand "github.com/cometbft/cometbft/libs/rand" - tmdb "github.com/cosmos/cosmos-db" - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - servertypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/cosmos/cosmos-sdk/testutil/network" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/stretchr/testify/require" - - "github.com/terra-money/alliance/app/params" - - "github.com/terra-money/alliance/app" -) - -type ( - Network = network.Network - Config = network.Config -) - -// New creates instance with fully configured cosmos network. -// Accepts optional config, that will be used in place of the DefaultConfig() if provided. -func New(t *testing.T, configs ...network.Config) *network.Network { - if len(configs) > 1 { - panic("at most one config should be provided") - } - var cfg network.Config - if len(configs) == 0 { - cfg = DefaultConfig() - } else { - cfg = configs[0] - } - net, err := network.New(t, t.TempDir(), cfg) - require.NoError(t, err) - t.Cleanup(net.Cleanup) - return net -} - -// DefaultConfig will initialize config for the network with custom application, -// genesis and single validator. All other parameters are inherited from cosmos-sdk/testutil/network.DefaultConfig -func DefaultConfig() network.Config { - encoding := params.MakeEncodingConfig() - return network.Config{ - Codec: encoding.Marshaler, - TxConfig: encoding.TxConfig, - LegacyAmino: encoding.Amino, - InterfaceRegistry: encoding.InterfaceRegistry, - AccountRetriever: authtypes.AccountRetriever{}, - AppConstructor: func(val network.ValidatorI) servertypes.Application { - return app.New( - val.GetCtx().Logger, tmdb.NewMemDB(), nil, true, map[int64]bool{}, val.GetCtx().Config.RootDir, 0, - encoding, - simtestutil.EmptyAppOptions{}, - baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)), - baseapp.SetMinGasPrices(val.GetAppConfig().MinGasPrices), - ) - }, - GenesisState: app.ModuleBasics.DefaultGenesis(encoding.Marshaler), - TimeoutCommit: 2 * time.Second, - ChainID: "chain-" + tmrand.NewRand().Str(6), - NumValidators: 1, - BondDenom: sdk.DefaultBondDenom, - MinGasPrices: fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), - AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction), - StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction), - BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction), - PruningStrategy: pruningtypes.PruningOptionNothing, - CleanupDir: true, - SigningAlgo: string(hd.Secp256k1Type), - KeyringOptions: []keyring.Option{}, - } -} diff --git a/x/alliance/module.go b/x/alliance/module.go index 296702af..7680adc8 100644 --- a/x/alliance/module.go +++ b/x/alliance/module.go @@ -9,8 +9,6 @@ import ( simulation2 "github.com/terra-money/alliance/x/alliance/tests/simulation" - // this line is used by starport scaffolding # 1 - "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" From 76363d46fd4a674006529288cc955878f3c5f0c9 Mon Sep 17 00:00:00 2001 From: emidev98 Date: Tue, 12 Mar 2024 07:52:56 +0200 Subject: [PATCH 2/2] fix: linting --- app/app.go | 5 +---- cmd/allianced/cmd/root.go | 15 --------------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/app/app.go b/app/app.go index 7af1ab24..78d5f924 100644 --- a/app/app.go +++ b/app/app.go @@ -90,8 +90,6 @@ import ( ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ibc "github.com/cosmos/ibc-go/v8/modules/core" - ibcclient "github.com/cosmos/ibc-go/v8/modules/core/02-client" - ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ibcporttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" @@ -446,8 +444,7 @@ func New( govRouter := govv1beta1.NewRouter() govRouter. AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). - AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). - AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)) govConfig := govtypes.DefaultConfig() /* Example of setting gov params: diff --git a/cmd/allianced/cmd/root.go b/cmd/allianced/cmd/root.go index cb19b803..fbab26cb 100644 --- a/cmd/allianced/cmd/root.go +++ b/cmd/allianced/cmd/root.go @@ -283,11 +283,6 @@ func txCommand() *cobra.Command { return cmd } -type appCreator struct { - encCfg params.EncodingConfig -} - -// newApp is an appCreator func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application { baseappOptions := server.DefaultBaseappOptions(appOpts) @@ -328,13 +323,3 @@ func appExport( return simApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) } - -var tempDir = func() string { - dir, err := os.MkdirTemp("", "alliance") - if err != nil { - dir = app.DefaultNodeHome - } - defer os.RemoveAll(dir) - - return dir -}