Skip to content

Commit

Permalink
add missing parameters and fix default values
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani authored and Pantani committed Dec 13, 2023
1 parent e5e32ce commit 823ef44
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 61 deletions.
44 changes: 16 additions & 28 deletions hermes/cmd/hermes_configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ const (
flagRestEnabled = "rest-enabled"
flagRestHost = "rest-host"
flagRestPort = "rest-port"
flagTracingServerEnabled = "tracing-server-enabled"
flagTracingServerHost = "tracing-server-host"
flagTracingServerPort = "tracing-server-port"
flagModeChannelsEnabled = "mode-channels-enabled"
flagModeClientsEnabled = "mode-clients-enabled"
flagModeClientsMisbehaviour = "mode-clients-misbehaviour"
Expand Down Expand Up @@ -106,28 +103,32 @@ func NewHermesConfigure() *cobra.Command {

c.Flags().String(flagChainAPortID, "transfer", "Port ID of the chain A")
c.Flags().String(flagChainBPortID, "transfer", "Port ID of the chain B")
c.Flags().Bool(flagChainACCVConsumerChain, false, "only specify true if the chain A is a CCV consumer")
c.Flags().Bool(flagChainBCCVConsumerChain, false, "only specify true if the chain B is a CCV consumer")
c.Flags().String(flagChainAEventSourceURL, "", "WS event source url of the chain A")
c.Flags().String(flagChainBEventSourceURL, "", "WS event source url of the chain B")
c.Flags().String(flagChainAEventSourceMode, "push", "WS event source mode of the chain A (event source url should be set to use this flag)")
c.Flags().String(flagChainBEventSourceMode, "push", "WS event source mode of the chain B (event source url should be set to use this flag)")
c.Flags().String(flagChainAEventSourceBatchDelay, "500ms", "WS event source batch delay time of the chain A (event source url should be set to use this flag)")
c.Flags().String(flagChainBEventSourceBatchDelay, "500ms", "WS event source batch delay time of the chain B (event source url should be set to use this flag)")
c.Flags().String(flagChainARPCTimeout, "15s", "RPC timeout of the chain A")
c.Flags().String(flagChainBRPCTimeout, "15s", "RPC timeout of the chain B")
c.Flags().String(flagChainAAddressType, "cosmos", "address type of the chain A")
c.Flags().String(flagChainBAddressType, "cosmos", "address type of the chain B")
c.Flags().String(flagChainARPCTimeout, "10s", "RPC timeout of the chain A")
c.Flags().String(flagChainBRPCTimeout, "10s", "RPC timeout of the chain B")
c.Flags().Bool(flagChainATrustedNode, false, "enable trusted node on the chain A")
c.Flags().Bool(flagChainBTrustedNode, false, "enable trusted node on the chain B")
c.Flags().String(flagChainAAccountPrefix, "cosmos", "account prefix of the chain A")
c.Flags().String(flagChainBAccountPrefix, "cosmos", "account prefix of the chain B")
c.Flags().String(flagChainAKeyName, "wallet", "hermes account name of the chain A")
c.Flags().String(flagChainBKeyName, "wallet", "hermes account name of the chain B")
c.Flags().String(flagChainAAddressType, "cosmos", "address type of the chain A")
c.Flags().String(flagChainBAddressType, "cosmos", "address type of the chain B")
c.Flags().String(flagChainAStorePrefix, "ibc", "store prefix of the chain A")
c.Flags().String(flagChainBStorePrefix, "ibc", "store prefix of the chain B")
c.Flags().Uint64(flagChainADefaultGas, 100000, "default gas used for transactions on chain A")
c.Flags().Uint64(flagChainBDefaultGas, 100000, "default gas used for transactions on chain B")
c.Flags().Uint64(flagChainAMaxGas, 400000, "max gas used for transactions on chain A")
c.Flags().Uint64(flagChainBMaxGas, 400000, "max gas used for transactions on chain B")
c.Flags().String(flagChainAGasPrice, "1stake", "gas price used for transactions on chain A")
c.Flags().String(flagChainBGasPrice, "1stake", "gas price used for transactions on chain B")
c.Flags().String(flagChainAGasPrice, "0.025stake", "gas price used for transactions on chain A")
c.Flags().String(flagChainBGasPrice, "0.025stake", "gas price used for transactions on chain B")
c.Flags().String(flagChainAGasMultiplier, "1.1", "gas multiplier used for transactions on chain A")
c.Flags().String(flagChainBGasMultiplier, "1.1", "gas multiplier used for transactions on chain B")
c.Flags().Uint64(flagChainAMaxMsgNum, 30, "max message number used for transactions on chain A")
Expand All @@ -136,32 +137,25 @@ func NewHermesConfigure() *cobra.Command {
c.Flags().Uint64(flagChainBMaxTxSize, 2097152, "max transaction size on chain B")
c.Flags().String(flagChainAClockDrift, "5s", "clock drift of the chain A")
c.Flags().String(flagChainBClockDrift, "5s", "clock drift of the chain B")
c.Flags().String(flagChainAMaxBlockTime, "10s", "maximum block time of the chain A")
c.Flags().String(flagChainBMaxBlockTime, "10s", "maximum block time of the chain B")
c.Flags().String(flagChainAMaxBlockTime, "30s", "maximum block time of the chain A")
c.Flags().String(flagChainBMaxBlockTime, "30s", "maximum block time of the chain B")
c.Flags().String(flagChainATrustingPeriod, "14days", "trusting period of the chain A")
c.Flags().String(flagChainBTrustingPeriod, "14days", "trusting period of the chain B")
c.Flags().Uint64(flagChainATrustThresholdNumerator, 1, "trusting threshold numerator of the chain A")
c.Flags().Uint64(flagChainBTrustThresholdNumerator, 1, "trusting threshold numerator of the chain B")
c.Flags().Uint64(flagChainATrustThresholdNumerator, 2, "trusting threshold numerator of the chain A")
c.Flags().Uint64(flagChainBTrustThresholdNumerator, 2, "trusting threshold numerator of the chain B")
c.Flags().Uint64(flagChainATrustThresholdDenominator, 3, "trusting threshold denominator of the chain A")
c.Flags().Uint64(flagChainBTrustThresholdDenominator, 3, "trusting threshold denominator of the chain B")
c.Flags().String(flagChainAFaucet, "", "faucet URL of the chain A")
c.Flags().String(flagChainBFaucet, "", "faucet URL of the chain B")
c.Flags().Bool(flagChainACCVConsumerChain, false, "only specify true if the chain A is a CCV consumer")
c.Flags().Bool(flagChainBCCVConsumerChain, false, "only specify true if the chain B is a CCV consumer")
c.Flags().Bool(flagChainATrustedNode, false, "enable trusted node on the chain A")
c.Flags().Bool(flagChainBTrustedNode, false, "enable trusted node on the chain B")
c.Flags().String(flagChainAMemoPrefix, "", "memo prefix of the chain A")
c.Flags().String(flagChainBMemoPrefix, "", "memo prefix of the chain B")
c.Flags().String(flagChainAFaucet, "", "faucet URL of the chain A")
c.Flags().String(flagChainBFaucet, "", "faucet URL of the chain B")

c.Flags().Bool(flagTelemetryEnabled, false, "enable hermes telemetry")
c.Flags().String(flagTelemetryHost, "127.0.0.1", "hermes telemetry host")
c.Flags().Uint64(flagTelemetryPort, 3001, "hermes telemetry port")
c.Flags().Bool(flagRestEnabled, false, "enable hermes rest")
c.Flags().String(flagRestHost, "127.0.0.1", "hermes rest host")
c.Flags().Uint64(flagRestPort, 3000, "hermes rest port")
c.Flags().Bool(flagTracingServerEnabled, false, "enable hermes tracing server")
c.Flags().String(flagTracingServerHost, "127.0.0.1", "hermes tracing server host")
c.Flags().Uint64(flagTracingServerPort, 5555, "hermes tracing server port")
c.Flags().Bool(flagModeChannelsEnabled, true, "enable hermes channels")
c.Flags().Bool(flagModeClientsEnabled, true, "enable hermes clients")
c.Flags().Bool(flagModeClientsMisbehaviour, true, "enable hermes clients misbehaviour")
Expand Down Expand Up @@ -513,9 +507,6 @@ func newHermesConfig(cmd *cobra.Command, args []string, customCfg string) (*herm
restEnabled, _ = cmd.Flags().GetBool(flagRestEnabled)
restHost, _ = cmd.Flags().GetString(flagRestHost)
restPort, _ = cmd.Flags().GetUint64(flagRestPort)
tracingServerEnabled, _ = cmd.Flags().GetBool(flagTracingServerEnabled)
tracingServerHost, _ = cmd.Flags().GetString(flagTracingServerHost)
tracingServerPort, _ = cmd.Flags().GetUint64(flagTracingServerPort)
modeChannelsEnabled, _ = cmd.Flags().GetBool(flagModeChannelsEnabled)
modeClientsEnabled, _ = cmd.Flags().GetBool(flagModeClientsEnabled)
modeClientsMisbehaviour, _ = cmd.Flags().GetBool(flagModeClientsMisbehaviour)
Expand All @@ -535,9 +526,6 @@ func newHermesConfig(cmd *cobra.Command, args []string, customCfg string) (*herm
hermes.WithRestEnabled(restEnabled),
hermes.WithRestHost(restHost),
hermes.WithRestPort(restPort),
hermes.WithTracingServerEnabled(tracingServerEnabled),
hermes.WithTracingServerHost(tracingServerHost),
hermes.WithTracingServerPort(tracingServerPort),
hermes.WithModeChannelsEnabled(modeChannelsEnabled),
hermes.WithModeClientsEnabled(modeClientsEnabled),
hermes.WithModeClientsMisbehaviour(modeClientsMisbehaviour),
Expand Down
38 changes: 5 additions & 33 deletions hermes/pkg/hermes/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ const (
type (
// Config represents the Hermes config struct.
Config struct {
Global Global `toml:"global" json:"global"`
Mode Mode `toml:"mode" json:"mode"`
Rest Rest `toml:"rest" json:"rest"`
Telemetry Telemetry `toml:"telemetry" json:"telemetry"`
TracingServer TracingServer `toml:"tracing_server" json:"tracing_server"`
Chains Chains `toml:"chains" json:"chains"`
Global Global `toml:"global" json:"global"`
Mode Mode `toml:"mode" json:"mode"`
Rest Rest `toml:"rest" json:"rest"`
Telemetry Telemetry `toml:"telemetry" json:"telemetry"`
Chains Chains `toml:"chains" json:"chains"`
}

// Global represents the global values into the Hermes config struct.
Expand Down Expand Up @@ -90,7 +89,6 @@ type (
// TracingServer represents the tracing server into the Hermes config struct.
TracingServer struct {
Enabled bool `toml:"enabled" json:"enabled"`
Host string `toml:"host" json:"host"`
Port uint64 `toml:"port" json:"port"`
}

Expand Down Expand Up @@ -289,27 +287,6 @@ func WithRestPort(port uint64) ConfigOption {
}
}

// WithTracingServerEnabled set TracingServer enable into the Hermes config.
func WithTracingServerEnabled(enabled bool) ConfigOption {
return func(c *Config) {
c.TracingServer.Enabled = enabled
}
}

// WithTracingServerHost set TracingServer host into the Hermes config.
func WithTracingServerHost(host string) ConfigOption {
return func(c *Config) {
c.TracingServer.Host = host
}
}

// WithTracingServerPort set TracingServer port into the Hermes config.
func WithTracingServerPort(port uint64) ConfigOption {
return func(c *Config) {
c.TracingServer.Port = port
}
}

// WithModeChannelsEnabled set ModeChannelsEnabled into the Hermes config.
func WithModeChannelsEnabled(enabled bool) ConfigOption {
return func(c *Config) {
Expand Down Expand Up @@ -416,11 +393,6 @@ func DefaultConfig(options ...ConfigOption) *Config {
Host: "127.0.0.1",
Port: 3001,
},
TracingServer: TracingServer{
Enabled: false,
Host: "127.0.0.1",
Port: 5555,
},
}
for _, o := range options {
o(cfg)
Expand Down

0 comments on commit 823ef44

Please sign in to comment.