diff --git a/PENDING.md b/PENDING.md index 74395be2d5bc..357d1c8b0b79 100644 --- a/PENDING.md +++ b/PENDING.md @@ -14,6 +14,7 @@ BREAKING CHANGES * SDK * [\#2752](https://github.com/cosmos/cosmos-sdk/pull/2752) Don't hardcode bondable denom. * [\#2019](https://github.com/cosmos/cosmos-sdk/issues/2019) Cap total number of signatures. Current per-transaction limit is 7, and if that is exceeded transaction is rejected. + * [\#2801](https://github.com/cosmos/cosmos-sdk/pull/2801) Remove AppInit structure. * Tendermint diff --git a/cmd/gaia/app/genesis.go b/cmd/gaia/app/genesis.go index e3c869ada1d6..7d95bbfa7d51 100644 --- a/cmd/gaia/app/genesis.go +++ b/cmd/gaia/app/genesis.go @@ -11,7 +11,6 @@ import ( "strings" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/server" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" distr "github.com/cosmos/cosmos-sdk/x/distribution" @@ -92,13 +91,6 @@ func (ga *GenesisAccount) ToAccount() (acc *auth.BaseAccount) { } } -// get app init parameters for server init command -func GaiaAppInit() server.AppInit { - - return server.AppInit{ - AppGenState: GaiaAppGenStateJSON, - } -} // Create the core parameters for genesis initialization for gaia // note that the pubkey input is this machines pubkey diff --git a/cmd/gaia/cmd/gaiad/main.go b/cmd/gaia/cmd/gaiad/main.go index 2a72b42cc6e7..bea3ac952541 100644 --- a/cmd/gaia/cmd/gaiad/main.go +++ b/cmd/gaia/cmd/gaiad/main.go @@ -37,15 +37,13 @@ func main() { Short: "Gaia Daemon (server)", PersistentPreRunE: server.PersistentPreRunEFn(ctx), } - appInit := app.GaiaAppInit() - rootCmd.AddCommand(gaiaInit.InitCmd(ctx, cdc, appInit)) + rootCmd.AddCommand(gaiaInit.InitCmd(ctx, cdc)) rootCmd.AddCommand(gaiaInit.CollectGenTxsCmd(ctx, cdc)) - rootCmd.AddCommand(gaiaInit.TestnetFilesCmd(ctx, cdc, server.AppInit{})) + rootCmd.AddCommand(gaiaInit.TestnetFilesCmd(ctx, cdc)) rootCmd.AddCommand(gaiaInit.GenTxCmd(ctx, cdc)) rootCmd.AddCommand(gaiaInit.AddGenesisAccountCmd(ctx, cdc)) - server.AddCommands(ctx, cdc, rootCmd, appInit, - newApp, exportAppStateAndTMValidators) + server.AddCommands(ctx, cdc, rootCmd, newApp, exportAppStateAndTMValidators) // prepare and add flags executor := cli.PrepareBaseCmd(rootCmd, "GA", app.DefaultNodeHome) diff --git a/cmd/gaia/init/init.go b/cmd/gaia/init/init.go index 1f12da6bde7c..19179233ab90 100644 --- a/cmd/gaia/init/init.go +++ b/cmd/gaia/init/init.go @@ -42,7 +42,7 @@ func displayInfo(cdc *codec.Codec, info printInfo) error { // get cmd to initialize all files for tendermint and application // nolint -func InitCmd(ctx *server.Context, cdc *codec.Codec, appInit server.AppInit) *cobra.Command { +func InitCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "init", Short: "Initialize private validator, p2p, genesis, and application configuration files", diff --git a/cmd/gaia/init/init_test.go b/cmd/gaia/init/init_test.go index d1d9b9ce2d6a..1eeba66ae5e8 100644 --- a/cmd/gaia/init/init_test.go +++ b/cmd/gaia/init/init_test.go @@ -32,10 +32,7 @@ func TestInitCmd(t *testing.T) { ctx := server.NewContext(cfg, logger) cdc := app.MakeCodec() - appInit := server.AppInit{ - AppGenState: mock.AppGenState, - } - cmd := InitCmd(ctx, cdc, appInit) + cmd := InitCmd(ctx, cdc) viper.Set(flagMoniker, "gaianode-test") @@ -65,13 +62,9 @@ func TestEmptyState(t *testing.T) { ctx := server.NewContext(cfg, logger) cdc := app.MakeCodec() - appInit := server.AppInit{ - AppGenState: mock.AppGenStateEmpty, - } - viper.Set(flagMoniker, "gaianode-test") - cmd := InitCmd(ctx, cdc, appInit) + cmd := InitCmd(ctx, cdc) err = cmd.RunE(nil, nil) require.NoError(t, err) @@ -116,10 +109,7 @@ func TestStartStandAlone(t *testing.T) { require.Nil(t, err) ctx := server.NewContext(cfg, logger) cdc := app.MakeCodec() - appInit := server.AppInit{ - AppGenState: mock.AppGenState, - } - initCmd := InitCmd(ctx, cdc, appInit) + initCmd := InitCmd(ctx, cdc) err = initCmd.RunE(nil, nil) require.NoError(t, err) diff --git a/cmd/gaia/init/testnet.go b/cmd/gaia/init/testnet.go index b0676515c144..73a7cea14538 100644 --- a/cmd/gaia/init/testnet.go +++ b/cmd/gaia/init/testnet.go @@ -38,8 +38,7 @@ var ( const nodeDirPerm = 0755 // get cmd to initialize all files for tendermint testnet and application -func TestnetFilesCmd(ctx *server.Context, cdc *codec.Codec, - appInit server.AppInit) *cobra.Command { +func TestnetFilesCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "testnet", diff --git a/docs/_attic/sdk/sdk-by-examples/simple-governance/bridging-it-all.md b/docs/_attic/sdk/sdk-by-examples/simple-governance/bridging-it-all.md index 546eb7d875f6..a90a6913e2c3 100644 --- a/docs/_attic/sdk/sdk-by-examples/simple-governance/bridging-it-all.md +++ b/docs/_attic/sdk/sdk-by-examples/simple-governance/bridging-it-all.md @@ -98,11 +98,6 @@ The `simplegovd` command will run the daemon server as a background process. Fir ```go // cmd/simplegovd/main.go -// SimpleGovAppInit initial parameters -var SimpleGovAppInit = server.AppInit{ - AppGenState: SimpleGovAppGenState, - AppGenTx: server.SimpleAppGenTx, -} // SimpleGovAppGenState sets up the app_state and appends the simpleGov app state func SimpleGovAppGenState(cdc *codec.Codec, appGenTxs []json.RawMessage) (appState json.RawMessage, err error) { @@ -137,7 +132,7 @@ func main() { PersistentPreRunE: server.PersistentPreRunEFn(ctx), } - server.AddCommands(ctx, cdc, rootCmd, SimpleGovAppInit, + server.AddCommands(ctx, cdc, rootCmd, server.ConstructAppCreator(newApp, "simplegov"), server.ConstructAppExporter(exportAppState, "simplegov")) diff --git a/docs/examples/basecoin/cmd/basecoind/main.go b/docs/examples/basecoin/cmd/basecoind/main.go index 731c5135f75d..318b36a8f573 100644 --- a/docs/examples/basecoin/cmd/basecoind/main.go +++ b/docs/examples/basecoin/cmd/basecoind/main.go @@ -39,11 +39,9 @@ func main() { PersistentPreRunE: server.PersistentPreRunEFn(ctx), } - appInit := server.DefaultAppInit - rootCmd.AddCommand(InitCmd(ctx, cdc, appInit)) + rootCmd.AddCommand(InitCmd(ctx, cdc)) - server.AddCommands(ctx, cdc, rootCmd, appInit, - newApp, exportAppStateAndTMValidators) + server.AddCommands(ctx, cdc, rootCmd, newApp, exportAppStateAndTMValidators) // prepare and add flags rootDir := os.ExpandEnv("$HOME/.basecoind") @@ -58,7 +56,7 @@ func main() { // get cmd to initialize all files for tendermint and application // nolint: errcheck -func InitCmd(ctx *server.Context, cdc *codec.Codec, appInit server.AppInit) *cobra.Command { +func InitCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "init", Short: "Initialize genesis config, priv-validator file, and p2p-node file", @@ -84,7 +82,7 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec, appInit server.AppInit) *cob return err } - appState, err := appInit.AppGenState( + appState, err := server.SimpleAppGenState( cdc, tmtypes.GenesisDoc{}, []json.RawMessage{genTx}) if err != nil { return err diff --git a/docs/examples/democoin/cmd/democoind/main.go b/docs/examples/democoin/cmd/democoind/main.go index 506d888a5c56..29e2640fde31 100644 --- a/docs/examples/democoin/cmd/democoind/main.go +++ b/docs/examples/democoin/cmd/democoind/main.go @@ -30,10 +30,6 @@ const ( flagClientHome = "home-client" ) -// init parameters -var CoolAppInit = server.AppInit{ - AppGenState: CoolAppGenState, -} // coolGenAppParams sets up the app_state and appends the cool app state func CoolAppGenState(cdc *codec.Codec, genDoc tmtypes.GenesisDoc, appGenTxs []json.RawMessage) ( @@ -65,7 +61,7 @@ func CoolAppGenState(cdc *codec.Codec, genDoc tmtypes.GenesisDoc, appGenTxs []js // get cmd to initialize all files for tendermint and application // nolint: errcheck -func InitCmd(ctx *server.Context, cdc *codec.Codec, appInit server.AppInit) *cobra.Command { +func InitCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "init", Short: "Initialize genesis config, priv-validator file, and p2p-node file", @@ -91,7 +87,7 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec, appInit server.AppInit) *cob return err } - appState, err := appInit.AppGenState(cdc, tmtypes.GenesisDoc{}, + appState, err := CoolAppGenState(cdc, tmtypes.GenesisDoc{}, []json.RawMessage{genTx}) if err != nil { return err @@ -157,11 +153,10 @@ func main() { PersistentPreRunE: server.PersistentPreRunEFn(ctx), } - rootCmd.AddCommand(InitCmd(ctx, cdc, CoolAppInit)) - rootCmd.AddCommand(gaiaInit.TestnetFilesCmd(ctx, cdc, CoolAppInit)) + rootCmd.AddCommand(InitCmd(ctx, cdc)) + rootCmd.AddCommand(gaiaInit.TestnetFilesCmd(ctx, cdc)) - server.AddCommands(ctx, cdc, rootCmd, CoolAppInit, - newApp, exportAppStateAndTMValidators) + server.AddCommands(ctx, cdc, rootCmd, newApp, exportAppStateAndTMValidators) // prepare and add flags rootDir := os.ExpandEnv("$HOME/.democoind") diff --git a/server/init.go b/server/init.go index 75e13f452653..3a6c6adae599 100644 --- a/server/init.go +++ b/server/init.go @@ -15,13 +15,6 @@ import ( tmtypes "github.com/tendermint/tendermint/types" ) -// Core functionality passed from the application to the server init command -type AppInit struct { - // AppGenState creates the core parameters initialization. It takes in a - // pubkey meant to represent the pubkey of the validator of this machine. - AppGenState func(cdc *codec.Codec, genDoc tmtypes.GenesisDoc, appGenTxs []json.RawMessage) ( - appState json.RawMessage, err error) -} // SimpleGenTx is a simple genesis tx type SimpleGenTx struct { @@ -30,10 +23,6 @@ type SimpleGenTx struct { //_____________________________________________________________________ -// simple default application init -var DefaultAppInit = AppInit{ - AppGenState: SimpleAppGenState, -} // Generate a genesis transaction func SimpleAppGenTx(cdc *codec.Codec, pk crypto.PubKey) ( diff --git a/server/util.go b/server/util.go index 633ad8870415..3d4a9d0b6586 100644 --- a/server/util.go +++ b/server/util.go @@ -129,7 +129,7 @@ func validateConfig(conf *cfg.Config) error { // add server commands func AddCommands( ctx *Context, cdc *codec.Codec, - rootCmd *cobra.Command, appInit AppInit, + rootCmd *cobra.Command, appCreator AppCreator, appExport AppExporter) { rootCmd.PersistentFlags().String("log_level", ctx.Config.LogLevel, "Log level")