diff --git a/CHANGELOG.md b/CHANGELOG.md index 319ea996c..4c583cb7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -172,6 +172,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* [\#11511](https://github.com/cosmos/cosmos-sdk/pull/11511) Add api server flags to start command. * [\#11484](https://github.com/cosmos/cosmos-sdk/pull/11484) Implement getter for keyring backend option. * [\#11449](https://github.com/cosmos/cosmos-sdk/pull/11449) Improved error messages when node isn't synced. * [\#11349](https://github.com/cosmos/cosmos-sdk/pull/11349) Add `RegisterAminoMsg` function that checks that a msg name is <40 chars (else this would break ledger nano signing) then registers the concrete msg type with amino, it should be used for registering `sdk.Msg`s with amino instead of `cdc.RegisterConcrete`. diff --git a/server/config/config.go b/server/config/config.go index c85b89fe4..8d4c003ea 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -15,6 +15,9 @@ import ( const ( defaultMinGasPrices = "" + // DefaultAPIAddress defines the default address to bind the API server to. + DefaultAPIAddress = "tcp://0.0.0.0:1317" + // DefaultGRPCAddress defines the default address to bind the gRPC server to. DefaultGRPCAddress = "0.0.0.0:9090" @@ -223,7 +226,7 @@ func DefaultConfig() *Config { API: APIConfig{ Enable: false, Swagger: false, - Address: "tcp://0.0.0.0:1317", + Address: DefaultAPIAddress, MaxOpenConnections: 1000, RPCReadTimeout: 10, RPCMaxBodyBytes: 1000000, diff --git a/server/start.go b/server/start.go index c6c6b2b47..f93ace066 100644 --- a/server/start.go +++ b/server/start.go @@ -59,6 +59,16 @@ const ( FlagStateSyncSnapshotInterval = "state-sync.snapshot-interval" FlagStateSyncSnapshotKeepRecent = "state-sync.snapshot-keep-recent" + // api-related flags + FlagAPIEnable = "api.enable" + FlagAPISwagger = "api.swagger" + FlagAPIAddress = "api.address" + FlagAPIMaxOpenConnections = "api.max-open-connections" + FlagRPCReadTimeout = "api.rpc-read-timeout" + FlagRPCWriteTimeout = "api.rpc-write-timeout" + FlagRPCMaxBodyBytes = "api.rpc-max-body-bytes" + FlagAPIEnableUnsafeCORS = "api.enabled-unsafe-cors" + // gRPC-related flags flagGRPCOnly = "grpc-only" flagGRPCEnable = "grpc.enable" @@ -153,6 +163,15 @@ is performed. Note, when enabled, gRPC will also be automatically enabled. cmd.Flags().Uint(FlagInvCheckPeriod, 0, "Assert registered invariants every N blocks") cmd.Flags().Uint64(FlagMinRetainBlocks, 0, "Minimum block height offset during ABCI commit to prune Tendermint blocks") + cmd.Flags().Bool(FlagAPIEnable, false, "Define if the API server should be enabled") + cmd.Flags().Bool(FlagAPISwagger, false, "Define if swagger documentation should automatically be registered (Note: api must also be enabled.)") + cmd.Flags().String(FlagAPIAddress, config.DefaultAPIAddress, "the API server address to listen on") + cmd.Flags().Uint(FlagAPIMaxOpenConnections, 1000, "Define the number of maximum open connections") + cmd.Flags().Uint(FlagRPCReadTimeout, 10, "Define the Tendermint RPC read timeout (in seconds)") + cmd.Flags().Uint(FlagRPCWriteTimeout, 0, "Define the Tendermint RPC write timeout (in seconds)") + cmd.Flags().Uint(FlagRPCMaxBodyBytes, 1000000, "Define the Tendermint maximum response body (in bytes)") + cmd.Flags().Bool(FlagAPIEnableUnsafeCORS, false, "Define if CORS should be enabled (unsafe - use it at your own risk)") + cmd.Flags().Bool(flagGRPCOnly, false, "Start the node in gRPC query only mode (no Tendermint process is started)") cmd.Flags().Bool(flagGRPCEnable, true, "Define if the gRPC server should be enabled") cmd.Flags().String(flagGRPCAddress, config.DefaultGRPCAddress, "the gRPC server address to listen on")