diff --git a/server/config/config.go b/server/config/config.go index b75b5bd87f8c..b08d7c8000ca 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -141,6 +141,15 @@ type GRPCConfig struct { MaxSendMsgSize int `mapstructure:"max-send-msg-size"` } +// RESTConfig defines configuration for the rest server. +type RESTConfig struct { + // Enable defines if the rest server should be enabled. + Enable bool `mapstructure:"enable"` + + // Address defines the API server to listen on + Address string `mapstructure:"address"` +} + // StateSyncConfig defines the state sync snapshot configuration. type StateSyncConfig struct { // SnapshotInterval sets the interval at which state sync snapshots are taken. @@ -184,6 +193,7 @@ type Config struct { Telemetry telemetry.Config `mapstructure:"telemetry"` API APIConfig `mapstructure:"api"` GRPC GRPCConfig `mapstructure:"grpc"` + REST RESTConfig `mapstructure:"rest"` StateSync StateSyncConfig `mapstructure:"state-sync"` Streaming StreamingConfig `mapstructure:"streaming"` Mempool MempoolConfig `mapstructure:"mempool"` diff --git a/simapp/simd/cmd/testnet.go b/simapp/simd/cmd/testnet.go index e060976d1376..fec1c1e238bd 100644 --- a/simapp/simd/cmd/testnet.go +++ b/simapp/simd/cmd/testnet.go @@ -248,6 +248,7 @@ func initTestnetFiles( rpcPort = 26657 apiPort = 1317 grpcPort = 9090 + restPort = 8080 ) p2pPortStart := 26656 @@ -263,6 +264,7 @@ func initTestnetFiles( nodeConfig.P2P.AllowDuplicateIP = true appConfig.API.Address = fmt.Sprintf("tcp://127.0.0.1:%d", apiPort+portOffset) appConfig.GRPC.Address = fmt.Sprintf("127.0.0.1:%d", grpcPort+portOffset) + appConfig.REST.Address = fmt.Sprintf("127.0.0.1:%d", restPort+portOffset) } nodeDirName := fmt.Sprintf("%s%d", args.nodeDirPrefix, i) diff --git a/simapp/v2/simdv2/cmd/testnet.go b/simapp/v2/simdv2/cmd/testnet.go index ed5786fb668c..dab0f327d037 100644 --- a/simapp/v2/simdv2/cmd/testnet.go +++ b/simapp/v2/simdv2/cmd/testnet.go @@ -20,6 +20,7 @@ import ( runtimev2 "cosmossdk.io/runtime/v2" serverv2 "cosmossdk.io/server/v2" "cosmossdk.io/server/v2/api/grpc" + "cosmossdk.io/server/v2/api/rest" "cosmossdk.io/server/v2/cometbft" "cosmossdk.io/server/v2/store" banktypes "cosmossdk.io/x/bank/types" @@ -184,6 +185,7 @@ func initTestnetFiles[T transaction.Tx]( rpcPort = 26657 apiPort = 1317 grpcPort = 9090 + restPort = 8080 ) p2pPortStart := 26656 @@ -192,6 +194,7 @@ func initTestnetFiles[T transaction.Tx]( for i := 0; i < args.numValidators; i++ { var portOffset int grpcConfig := grpc.DefaultConfig() + restConfig := rest.DefaultConfig() if args.singleMachine { portOffset = i p2pPortStart = 16656 // use different start point to not conflict with rpc port @@ -205,6 +208,11 @@ func initTestnetFiles[T transaction.Tx]( MaxRecvMsgSize: grpc.DefaultConfig().MaxRecvMsgSize, MaxSendMsgSize: grpc.DefaultConfig().MaxSendMsgSize, } + + restConfig = &rest.Config{ + Enable: true, + Address: fmt.Sprintf("127.0.0.1:%d", restPort+portOffset), + } } nodeDirName := fmt.Sprintf("%s%d", args.nodeDirPrefix, i) @@ -338,7 +346,8 @@ func initTestnetFiles[T transaction.Tx]( cometServer := cometbft.NewWithConfigOptions[T](cometbft.OverwriteDefaultConfigTomlConfig(nodeConfig)) storeServer := &store.Server[T]{} grpcServer := grpc.NewWithConfigOptions[T](grpc.OverwriteDefaultConfig(grpcConfig)) - server := serverv2.NewServer[T](serverCfg, cometServer, storeServer, grpcServer) + restServer := rest.NewWithConfigOptions[T](rest.OverwriteDefaultConfig(restConfig)) + server := serverv2.NewServer[T](serverCfg, cometServer, storeServer, grpcServer, restServer) err = server.WriteConfig(filepath.Join(nodeDir, "config")) if err != nil { return err