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

fix: Fixed connection-id missing key would cause relayer start to fail #503

Merged
merged 1 commit into from
Sep 5, 2023
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
15 changes: 11 additions & 4 deletions relayer/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import (
"path/filepath"

"github.com/dymensionxyz/roller/cmd/consts"
"github.com/dymensionxyz/roller/cmd/utils"
cmdutils "github.com/dymensionxyz/roller/cmd/utils"
"github.com/dymensionxyz/roller/utils"
)

// TODO: Change to use the connection for fetching relevant channel using connection-channels rly command
func (r *Relayer) LoadActiveChannel() (string, string, error) {
output, err := utils.ExecBashCommandWithStdout(r.queryChannelsRollappCmd())
output, err := cmdutils.ExecBashCommandWithStdout(r.queryChannelsRollappCmd())
if err != nil {
return "", "", err
}
Expand All @@ -27,7 +29,12 @@ func (r *Relayer) LoadActiveChannel() (string, string, error) {

activeConnectionID, err = r.GetActiveConnection()
if err != nil {
return "", "", err
if keyErr, ok := err.(*utils.KeyNotFoundError); ok {
r.logger.Printf("No active connection found. Key not found: %v", keyErr)
return "", "", nil
} else {
return "", "", err
}
}
if activeConnectionID == "" {
return "", "", nil
Expand All @@ -52,7 +59,7 @@ func (r *Relayer) LoadActiveChannel() (string, string, error) {
// found STATE_OPEN channel
// Check if the channel is open on the hub
var res HubQueryResult
outputHub, err := utils.ExecBashCommandWithStdout(r.queryChannelsHubCmd(outputStruct.Counterparty.ChannelID))
outputHub, err := cmdutils.ExecBashCommandWithStdout(r.queryChannelsHubCmd(outputStruct.Counterparty.ChannelID))
if err != nil {
return "", "", err
}
Expand Down
2 changes: 1 addition & 1 deletion relayer/create_ibc_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (r *Relayer) CreateIBCChannel(override bool, logFileOption utils.CommandOpt
utils.RunCommandEvery(ctx, updateClientsCmd.Path, updateClientsCmd.Args[1:], 20, utils.WithDiscardLogging())

//wait for block to be created
status = "Creating block..."
status = "Waiting for block creation..."
fmt.Printf("💈 %s\n", status)
if err := r.WriteRelayerStatus(status); err != nil {
return ConnectionChannels{}, err
Expand Down
11 changes: 11 additions & 0 deletions utils/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package utils

import "fmt"

type KeyNotFoundError struct {
Key string
}

func (e *KeyNotFoundError) Error() string {
return fmt.Sprintf("key not found: %s", e.Key)
}
2 changes: 1 addition & 1 deletion utils/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func GetNestedValue(data map[interface{}]interface{}, keyPath []string) (interfa
}
value, ok := data[keyPath[0]]
if !ok {
return nil, fmt.Errorf("key not found: %s", keyPath[0])
return nil, &KeyNotFoundError{Key: keyPath[0]}
}
if len(keyPath) == 1 {
return value, nil
Expand Down
Loading