Skip to content

Commit

Permalink
fix testnet.go
Browse files Browse the repository at this point in the history
  • Loading branch information
kocubinski committed Oct 1, 2024
1 parent 058248a commit c8c207c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion simapp/v2/simdv2/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func initRootCmd[T transaction.Tx](
genutilcli.InitCmd(moduleManager),
debug.Cmd(),
confixcmd.ConfigCommand(),
NewTestnetCmd(moduleManager),
NewTestnetCmd(store, moduleManager),
)

logger, err := serverv2.NewLogger(viper.New(), rootCmd.OutOrStdout())
Expand Down
13 changes: 8 additions & 5 deletions simapp/v2/simdv2/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
serverv2 "cosmossdk.io/server/v2"
"cosmossdk.io/server/v2/api/grpc"
"cosmossdk.io/server/v2/cometbft"
cometbfttypes "cosmossdk.io/server/v2/cometbft/types"
"cosmossdk.io/server/v2/store"
banktypes "cosmossdk.io/x/bank/types"
bankv2types "cosmossdk.io/x/bank/v2/types"
Expand Down Expand Up @@ -87,7 +88,7 @@ func addTestnetFlagsToCmd(cmd *cobra.Command) {

// NewTestnetCmd creates a root testnet command with subcommands to run an in-process testnet or initialize
// validator configuration files for running a multi-validator testnet in a separate process
func NewTestnetCmd[T transaction.Tx](mm *runtimev2.MM[T]) *cobra.Command {
func NewTestnetCmd[T transaction.Tx](rs cometbfttypes.Store, mm *runtimev2.MM[T]) *cobra.Command {
testnetCmd := &cobra.Command{
Use: "testnet",
Short: "subcommands for starting or configuring local testnets",
Expand All @@ -96,13 +97,13 @@ func NewTestnetCmd[T transaction.Tx](mm *runtimev2.MM[T]) *cobra.Command {
RunE: client.ValidateCmd,
}

testnetCmd.AddCommand(testnetInitFilesCmd(mm))
testnetCmd.AddCommand(testnetInitFilesCmd(rs, mm))

return testnetCmd
}

// testnetInitFilesCmd returns a cmd to initialize all files for CometBFT testnet and application
func testnetInitFilesCmd[T transaction.Tx](mm *runtimev2.MM[T]) *cobra.Command {
func testnetInitFilesCmd[T transaction.Tx](rs cometbfttypes.Store, mm *runtimev2.MM[T]) *cobra.Command {
cmd := &cobra.Command{
Use: "init-files",
Short: "Initialize config directories & files for a multi-validator testnet running locally via separate processes (e.g. Docker Compose or similar)",
Expand Down Expand Up @@ -143,7 +144,7 @@ Example:
return err
}

return initTestnetFiles(clientCtx, cmd, config, mm, args)
return initTestnetFiles(clientCtx, rs, cmd, config, mm, args)
},
}

Expand All @@ -165,6 +166,7 @@ const nodeDirPerm = 0o755
// initTestnetFiles initializes testnet files for a testnet to be run in a separate process
func initTestnetFiles[T transaction.Tx](
clientCtx client.Context,
rootStore cometbfttypes.Store,
cmd *cobra.Command,
nodeConfig *cmtconfig.Config,
mm *runtimev2.MM[T],
Expand Down Expand Up @@ -339,10 +341,11 @@ func initTestnetFiles[T transaction.Tx](
// Write server config
cometServer := cometbft.New[T](
&genericTxDecoder[T]{clientCtx.TxConfig},
rootStore,
cometbft.ServerOptions[T]{},
cometbft.OverwriteDefaultConfigTomlConfig(nodeConfig),
)
storeServer := store.New[T](newApp)
storeServer := store.New[T](rootStore)
grpcServer := grpc.New[T](grpc.OverwriteDefaultConfig(grpcConfig))
server := serverv2.NewServer(log.NewNopLogger(), serverCfg, cometServer, grpcServer, storeServer)
err = server.WriteConfig(filepath.Join(nodeDir, "config"))
Expand Down

0 comments on commit c8c207c

Please sign in to comment.