diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c73bc8936..2c3d6ca0f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * Remove unsupported database types [#1760](https://github.com/provenance-io/provenance/issues/1760). * Update ibc and migrate params [#1760](https://github.com/provenance-io/provenance/issues/1760). * Replace ModuleBasics with BasicModuleManager [#1760](https://github.com/provenance-io/provenance/issues/1760). +* Updated app.go to use RegisterStreamingServices on BaseApp [#1760](https://github.com/provenance-io/provenance/issues/1760). * Bump the SDK to `v0.50.5-pio-1` (from an earlier ephemeral version) [#1897](https://github.com/provenance-io/provenance/pull/1897). --- diff --git a/app/app.go b/app/app.go index dd82a4e5bf..39e1226c41 100644 --- a/app/app.go +++ b/app/app.go @@ -22,7 +22,6 @@ import ( "cosmossdk.io/log" sdkmath "cosmossdk.io/math" - // "cosmossdk.io/store/streaming" // TODO[1760]: streaming: See if we can use this directly or if we have needed modifications. storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/evidence" evidencekeeper "cosmossdk.io/x/evidence/keeper" @@ -58,13 +57,16 @@ import ( servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + sigtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" + "github.com/cosmos/cosmos-sdk/x/auth/tx" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" + txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" @@ -236,6 +238,7 @@ type App struct { legacyAmino *codec.LegacyAmino appCodec codec.Codec interfaceRegistry types.InterfaceRegistry + txConfig client.TxConfig invCheckPeriod uint @@ -385,7 +388,10 @@ func New( } // Register State listening services. - app.RegisterStreamingServices(appOpts) + if err := app.BaseApp.RegisterStreamingServices(appOpts, app.keys); err != nil { + app.Logger().Error("failed to register streaming plugin", "error", err) + os.Exit(1) + } // Register helpers for state-sync status. statesync.RegisterSyncStatus() @@ -433,6 +439,21 @@ func New( logger, ) + // optional: enable sign mode textual by overwriting the default tx config (after setting the bank keeper) + enabledSignModes := append(tx.DefaultSignModes, sigtypes.SignMode_SIGN_MODE_TEXTUAL) + txConfigOpts := tx.ConfigOptions{ + EnabledSignModes: enabledSignModes, + TextualCoinMetadataQueryFn: txmodule.NewBankKeeperCoinMetadataQueryFn(app.BankKeeper), + } + txConfig, err := tx.NewTxConfigWithOptions( + appCodec, + txConfigOpts, + ) + if err != nil { + panic(err) + } + app.txConfig = txConfig + app.StakingKeeper = stakingkeeper.NewKeeper( appCodec, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, govAuthority, authcodec.NewBech32Codec(valAddrPrefix), authcodec.NewBech32Codec(consAddrPrefix), ) @@ -455,7 +476,7 @@ func New( app.MsgFeesKeeper = msgfeeskeeper.NewKeeper( appCodec, keys[msgfeestypes.StoreKey], app.GetSubspace(msgfeestypes.ModuleName), authtypes.FeeCollectorName, pioconfig.GetProvenanceConfig().FeeDenom, - app.SimulateProv, encodingConfig.TxConfig.TxDecoder(), interfaceRegistry, + app.SimulateProv, app.txConfig.TxDecoder(), interfaceRegistry, ) pioMsgFeesRouter := app.MsgServiceRouter().(*piohandlers.PioMsgServiceRouter) @@ -586,7 +607,7 @@ func New( wasmDir := filepath.Join(homePath, "data", "wasm") wasmWrap := WasmWrapper{Wasm: wasmtypes.DefaultWasmConfig()} - err := viper.Unmarshal(&wasmWrap) + err = viper.Unmarshal(&wasmWrap) if err != nil { panic("error while reading wasm config: " + err.Error()) } @@ -724,7 +745,7 @@ func New( // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. app.mm = module.NewManager( - genutil.NewAppModule(app.AccountKeeper, app.StakingKeeper, app.BaseApp, encodingConfig.TxConfig), + genutil.NewAppModule(app.AccountKeeper, app.StakingKeeper, app.BaseApp, app.txConfig), auth.NewAppModule(appCodec, app.AccountKeeper, nil, app.GetSubspace(authtypes.ModuleName)), vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), @@ -1028,7 +1049,7 @@ func New( antewrapper.HandlerOptions{ AccountKeeper: app.AccountKeeper, BankKeeper: app.BankKeeper, - TxSigningHandlerMap: encodingConfig.TxConfig.SignModeHandler(), + TxSigningHandlerMap: app.txConfig.SignModeHandler(), FeegrantKeeper: app.FeeGrantKeeper, MsgFeesKeeper: app.MsgFeesKeeper, SigGasConsumer: ante.DefaultSigVerificationGasConsumer, @@ -1044,7 +1065,7 @@ func New( BankKeeper: app.BankKeeper, FeegrantKeeper: app.FeeGrantKeeper, MsgFeesKeeper: app.MsgFeesKeeper, - Decoder: encodingConfig.TxConfig.TxDecoder(), + Decoder: app.txConfig.TxDecoder(), }) if err != nil { @@ -1130,7 +1151,7 @@ func (app *App) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper { // GetTxConfig implements the TestingApp interface (for ibc testing). func (app *App) GetTxConfig() client.TxConfig { - return MakeEncodingConfig().TxConfig + return app.txConfig } // Name returns the name of the App @@ -1302,36 +1323,6 @@ func (app *App) RegisterNodeService(clientCtx client.Context, cfg serverconfig.C nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) } -// RegisterStreamingServices registers types.ABCIListener State Listening services with the App. -func (app *App) RegisterStreamingServices(appOpts servertypes.AppOptions) { - // TODO[1760]: streaming: Ensure that this change is correct. - if err := app.BaseApp.RegisterStreamingServices(appOpts, app.keys); err != nil { - app.Logger().Error("failed to register streaming plugin", "error", err) - os.Exit(1) - } - /* - // register streaming services - streamingCfg := cast.ToStringMap(appOpts.Get(baseapp.StreamingTomlKey)) - for service := range streamingCfg { - pluginKey := fmt.Sprintf("%s.%s.%s", baseapp.StreamingTomlKey, service, baseapp.StreamingABCIPluginTomlKey) - pluginName := strings.TrimSpace(cast.ToString(appOpts.Get(pluginKey))) - if len(pluginName) > 0 { - logLevel := cast.ToString(appOpts.Get(flags.FlagLogLevel)) - plugin, err := streaming.NewStreamingPlugin(pluginName, logLevel) - if err != nil { - app.Logger().Error("failed to load streaming plugin", "error", err) - os.Exit(1) - } - if err := app.BaseApp.RegisterStreamingServices(appOpts, app.keys, plugin); err != nil { - app.Logger().Error("failed to register streaming plugin", "error", err) - os.Exit(1) - } - app.Logger().Info("streaming service registered", "service", service, "plugin", pluginName) - } - } - */ -} - // RegisterSwaggerAPI registers swagger route with API Server func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router) { statikFS, err := fs.New() diff --git a/cmd/provenanced/cmd/root.go b/cmd/provenanced/cmd/root.go index 95ac719580..09b7c52b22 100644 --- a/cmd/provenanced/cmd/root.go +++ b/cmd/provenanced/cmd/root.go @@ -26,6 +26,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" + clientconfig "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/debug" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/keys" @@ -39,7 +40,10 @@ import ( simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/types/tx/signing" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" + "github.com/cosmos/cosmos-sdk/x/auth/tx" + 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" @@ -96,10 +100,37 @@ func NewRootCmd(sealConfig bool) (*cobra.Command, params.EncodingConfig) { cmd.SetOut(cmd.OutOrStdout()) cmd.SetErr(cmd.ErrOrStderr()) - if cmd.Flags().Changed(flags.FlagHome) { - rootDir, _ := cmd.Flags().GetString(flags.FlagHome) - initClientCtx = initClientCtx.WithHomeDir(rootDir) + initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags()) + if err != nil { + return err + } + + // TODO[1760]: client: Check impact that this has on our custom client config. + initClientCtx, err = clientconfig.ReadFromClientConfig(initClientCtx) + if err != nil { + return err } + + // This needs to go after ReadFromClientConfig, as that function + // sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode + // is only available if the client is online. + if !initClientCtx.Offline { + enabledSignModes := append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) + txConfigOpts := tx.ConfigOptions{ + EnabledSignModes: enabledSignModes, + TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx), + } + txConfig, err := tx.NewTxConfigWithOptions( + initClientCtx.Codec, + txConfigOpts, + ) + if err != nil { + return err + } + + initClientCtx = initClientCtx.WithTxConfig(txConfig) + } + if err := client.SetCmdClientContext(cmd, initClientCtx); err != nil { return err }