Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to default self-healing config values #843

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
21 changes: 20 additions & 1 deletion helper/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}
Expand Down
9 changes: 4 additions & 5 deletions helper/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down