diff --git a/go.sum b/go.sum index fbaed8f07..33c9d2df5 100644 --- a/go.sum +++ b/go.sum @@ -687,8 +687,8 @@ golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d h1:Zu/JngovGLVi6t2J3nmAf3AoTDwuzw85YZ3b9o4yU7s= -golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c h1:aFV+BgZ4svzjfabn8ERpuB4JI4N6/rdy1iusx77G3oU= +golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/helper/config.go b/helper/config.go index 5607e15fc..4c01dc34d 100644 --- a/helper/config.go +++ b/helper/config.go @@ -198,8 +198,9 @@ func InitHeimdallConfigWith(homeDir string, heimdallConfigFilePath string) { heimdallViper.SetConfigFile(heimdallConfigFilePath) // set config file explicitly } + // Handle errors reading the config file err := heimdallViper.ReadInConfig() - if err != nil { // Handle errors reading the config file + if err != nil { log.Fatal(err) } @@ -228,6 +229,24 @@ func InitHeimdallConfigWith(homeDir string, heimdallConfigFilePath string) { conf.BorRPCTimeout = DefaultBorRPCTimeout } + if conf.SHStateSyncedInterval == 0 { + // fallback to default + Logger.Debug("Invalid self-healing StateSynced interval provided, falling back to default value", "interval", DefaultSHStateSyncedInterval) + conf.SHStateSyncedInterval = DefaultSHStateSyncedInterval + } + + if conf.SHStakeUpdateInterval == 0 { + // fallback to default + Logger.Debug("Invalid self-healing StakeUpdate interval provided, falling back to default value", "interval", DefaultSHStakeUpdateInterval) + conf.SHStakeUpdateInterval = DefaultSHStakeUpdateInterval + } + + if conf.SHMaxDepthDuration == 0 { + // fallback to default + Logger.Debug("Invalid self-healing max depth duration provided, falling back to default value", "duration", DefaultSHMaxDepthDuration) + conf.SHMaxDepthDuration = DefaultSHMaxDepthDuration + } + if mainRPCClient, err = rpc.Dial(conf.EthRPCUrl); err != nil { log.Fatalln("Unable to dial via ethClient", "URL=", conf.EthRPCUrl, "chain=eth", "Error", err) } diff --git a/helper/toml.go b/helper/toml.go index 2a27b490a..b0d37258d 100644 --- a/helper/toml.go +++ b/helper/toml.go @@ -63,12 +63,11 @@ func init() { } } -// ParseConfig retrieves the default environment configuration for the -// application. +// ParseConfig retrieves the default environment configuration for the application. func ParseConfig() (*Configuration, error) { - conf := GetDefaultHeimdallConfig() - err := viper.Unmarshal(conf) - return &conf, err + defaultConf := GetDefaultHeimdallConfig() + err := viper.Unmarshal(defaultConf) + return &defaultConf, err } // WriteConfigFile renders config using the template and writes it to