From 3c6402e47c9c5484f4aaa9de79a6f606072c804a Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:59:35 +0700 Subject: [PATCH 01/24] fix: improve relayer ibc path creation and verification handler --- cmd/relayer/setup/setup.go | 10 +++++++--- utils/relayer/config.go | 36 ++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/cmd/relayer/setup/setup.go b/cmd/relayer/setup/setup.go index 3422cce9..076b912c 100644 --- a/cmd/relayer/setup/setup.go +++ b/cmd/relayer/setup/setup.go @@ -1,6 +1,7 @@ package setup import ( + "encoding/json" "fmt" "os" @@ -98,10 +99,10 @@ func Cmd() *cobra.Command { return } - var isRelayerIbcPathValid bool + var ibcPathChains *relayerutils.IbcPathChains if isRelayerDirPresent { - isRelayerIbcPathValid, err = relayerutils.ValidateIbcPathChains( + ibcPathChains, err = relayerutils.ValidateIbcPathChains( relayerHome, raID, *hd, @@ -122,7 +123,10 @@ func Cmd() *cobra.Command { } } - if !isRelayerIbcPathValid { + j, _ := json.MarshalIndent(ibcPathChains, "", " ") + fmt.Println(string(j)) + + if ibcPathChains == nil { pterm.Warning.Println("relayer config verification failed...") pterm.Info.Println("populating relayer config with correct values...") err = relayerutils.InitializeRelayer(home, *rollappChainData) diff --git a/utils/relayer/config.go b/utils/relayer/config.go index b6298f68..d1ad4add 100644 --- a/utils/relayer/config.go +++ b/utils/relayer/config.go @@ -37,25 +37,30 @@ func UpdateConfigWithDefaultValues(relayerHome string, rollerData roller.Rollapp return nil } -func ValidateIbcPathChains(relayerHome, raID string, hd consts.HubData) (bool, error) { - var srcChainOk bool - var dstChainOk bool - var defaultPathOk bool - var relayerConfigExists bool +type IbcPathChains struct { + SrcChainOk bool + DstChainOk bool + DefaultPathOk bool + RelayerConfigExists bool +} + +func ValidateIbcPathChains(relayerHome, raID string, hd consts.HubData) (*IbcPathChains, error) { var err error + ibcPathChains := IbcPathChains{} relayerConfigPath := GetConfigFilePath(relayerHome) pterm.Info.Println("checking configuration") // 2. config file exists - relayerConfigExists, err = filesystem.DoesFileExist(relayerConfigPath) + relayerConfigExists, err := filesystem.DoesFileExist(relayerConfigPath) if err != nil { - return false, err + return nil, err } + ibcPathChains.RelayerConfigExists = relayerConfigExists if relayerConfigExists { // 2.1. path exist - defaultPathOk, err = VerifyDefaultPath(relayerHome) + defaultPathOk, err := VerifyDefaultPath(relayerHome) if err != nil { pterm.Error.Printf( "failed to verify relayer path %s: %v\n", @@ -63,28 +68,31 @@ func ValidateIbcPathChains(relayerHome, raID string, hd consts.HubData) (bool, e err, ) } + ibcPathChains.DefaultPathOk = defaultPathOk if defaultPathOk { // 2.2. isHubChainPresent - srcChainOk, err = VerifyPathSrcChain(relayerHome, hd) + srcChainOk, err := VerifyPathSrcChain(relayerHome, hd) if err != nil { pterm.Error.Printf( "failed to verify source chain in relayer path: %v\n", err, ) } + ibcPathChains.SrcChainOk = srcChainOk // 2.3. isRollappChainPresent - dstChainOk, err = VerifyPathDstChain(relayerHome, raID) + dstChainOk, err := VerifyPathDstChain(relayerHome, raID) if err != nil { - return false, err + return &ibcPathChains, err } + ibcPathChains.DstChainOk = dstChainOk } } - if !relayerConfigExists || !srcChainOk || !dstChainOk { - return false, nil + if !relayerConfigExists || !ibcPathChains.SrcChainOk || !ibcPathChains.DstChainOk { + return &ibcPathChains, nil } - return true, nil + return &ibcPathChains, nil } From f834c4eb7455a214f38ddc903bdb6fb3e774b4a9 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:05:03 +0700 Subject: [PATCH 02/24] chore: debug --- utils/relayer/connection.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/relayer/connection.go b/utils/relayer/connection.go index d62e6739..73ad53cf 100644 --- a/utils/relayer/connection.go +++ b/utils/relayer/connection.go @@ -1,6 +1,7 @@ package relayer import ( + "encoding/json" "fmt" "os" @@ -23,6 +24,9 @@ func VerifyDefaultPath(relayerHome string) (bool, error) { return false, err } + j, _ := json.MarshalIndent(config, "", " ") + fmt.Println(string(j)) + // Navigate to paths and check for hub-rollapp if paths, ok := config["paths"].(map[interface{}]interface{}); ok { if _, exists := paths[consts.DefaultRelayerPath]; exists { From 7f304c4f4bd2bd2744121e35a7ffc9866df48cca Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:13:57 +0700 Subject: [PATCH 03/24] chore: debug --- utils/relayer/connection.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/utils/relayer/connection.go b/utils/relayer/connection.go index 73ad53cf..a0d7d866 100644 --- a/utils/relayer/connection.go +++ b/utils/relayer/connection.go @@ -1,7 +1,6 @@ package relayer import ( - "encoding/json" "fmt" "os" @@ -24,15 +23,18 @@ func VerifyDefaultPath(relayerHome string) (bool, error) { return false, err } - j, _ := json.MarshalIndent(config, "", " ") - fmt.Println(string(j)) - // Navigate to paths and check for hub-rollapp if paths, ok := config["paths"].(map[interface{}]interface{}); ok { if _, exists := paths[consts.DefaultRelayerPath]; exists { fmt.Println("hub-rollapp exists in the YAML configuration.") return true, nil } + + fmt.Println("want:", consts.DefaultRelayerPath) + fmt.Println("have:", paths[consts.DefaultRelayerPath]) + + y, _ := yaml.Marshal(paths) + fmt.Println("paths", string(y)) } return false, nil From b43c945612b4962c5d38a399a1c0d851e08b9f48 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:21:26 +0700 Subject: [PATCH 04/24] chore: debug --- utils/relayer/connection.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/relayer/connection.go b/utils/relayer/connection.go index a0d7d866..2f658d6d 100644 --- a/utils/relayer/connection.go +++ b/utils/relayer/connection.go @@ -4,6 +4,7 @@ import ( "fmt" "os" + "github.com/pterm/pterm" "gopkg.in/yaml.v3" "github.com/dymensionxyz/roller/cmd/consts" @@ -14,19 +15,21 @@ func VerifyDefaultPath(relayerHome string) (bool, error) { data, err := os.ReadFile(cfp) if err != nil { + pterm.Error.Println("failed to read config file:", err) return false, err } var config map[string]interface{} err = yaml.Unmarshal(data, &config) if err != nil { + pterm.Error.Println("failed to unmarshal config file:", err) return false, err } // Navigate to paths and check for hub-rollapp if paths, ok := config["paths"].(map[interface{}]interface{}); ok { if _, exists := paths[consts.DefaultRelayerPath]; exists { - fmt.Println("hub-rollapp exists in the YAML configuration.") + pterm.Success.Println("hub-rollapp exists in the YAML configuration.") return true, nil } From adc73961dde6990e2589fe74a113c522195be639 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:28:22 +0700 Subject: [PATCH 05/24] chore: debug --- utils/relayer/connection.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/relayer/connection.go b/utils/relayer/connection.go index 2f658d6d..252b762d 100644 --- a/utils/relayer/connection.go +++ b/utils/relayer/connection.go @@ -11,6 +11,7 @@ import ( ) func VerifyDefaultPath(relayerHome string) (bool, error) { + pterm.Info.Println("verifying default path") cfp := GetConfigFilePath(relayerHome) data, err := os.ReadFile(cfp) @@ -19,6 +20,7 @@ func VerifyDefaultPath(relayerHome string) (bool, error) { return false, err } + pterm.Info.Println("unmarshalling config file") var config map[string]interface{} err = yaml.Unmarshal(data, &config) if err != nil { @@ -26,6 +28,7 @@ func VerifyDefaultPath(relayerHome string) (bool, error) { return false, err } + pterm.Info.Println("navigating to paths and checking for hub-rollapp") // Navigate to paths and check for hub-rollapp if paths, ok := config["paths"].(map[interface{}]interface{}); ok { if _, exists := paths[consts.DefaultRelayerPath]; exists { From b5cfce6fa4a3b6a7a2a641e9d5f9d55ce786f19b Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:29:51 +0700 Subject: [PATCH 06/24] chore: debug --- utils/relayer/config.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/utils/relayer/config.go b/utils/relayer/config.go index d1ad4add..033aef62 100644 --- a/utils/relayer/config.go +++ b/utils/relayer/config.go @@ -87,12 +87,10 @@ func ValidateIbcPathChains(relayerHome, raID string, hd consts.HubData) (*IbcPat return &ibcPathChains, err } ibcPathChains.DstChainOk = dstChainOk + } else { + pterm.Error.Println("default path not found in relayer config") } } - if !relayerConfigExists || !ibcPathChains.SrcChainOk || !ibcPathChains.DstChainOk { - return &ibcPathChains, nil - } - return &ibcPathChains, nil } From d49d78ebc09b5ce0911004cf77c2fc3b1bfe12ed Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:31:57 +0700 Subject: [PATCH 07/24] chore: debug --- utils/relayer/connection.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/relayer/connection.go b/utils/relayer/connection.go index 252b762d..a14f0dd0 100644 --- a/utils/relayer/connection.go +++ b/utils/relayer/connection.go @@ -28,6 +28,8 @@ func VerifyDefaultPath(relayerHome string) (bool, error) { return false, err } + fmt.Println("config", config["paths"].(map[interface{}]interface{})) + pterm.Info.Println("navigating to paths and checking for hub-rollapp") // Navigate to paths and check for hub-rollapp if paths, ok := config["paths"].(map[interface{}]interface{}); ok { From 3d0c396690b5f99c0d641e716a2749aff960d074 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:32:48 +0700 Subject: [PATCH 08/24] chore: debug --- utils/relayer/connection.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/relayer/connection.go b/utils/relayer/connection.go index a14f0dd0..850b470f 100644 --- a/utils/relayer/connection.go +++ b/utils/relayer/connection.go @@ -28,7 +28,7 @@ func VerifyDefaultPath(relayerHome string) (bool, error) { return false, err } - fmt.Println("config", config["paths"].(map[interface{}]interface{})) + fmt.Println("config", config["paths"]) pterm.Info.Println("navigating to paths and checking for hub-rollapp") // Navigate to paths and check for hub-rollapp From 8f717a78895c8ac15856bc521785d35e40487066 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:50:32 +0700 Subject: [PATCH 09/24] chore: debug --- utils/relayer/connection.go | 15 +++++---------- utils/relayer/types.go | 12 ++++++++++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/utils/relayer/connection.go b/utils/relayer/connection.go index 850b470f..b438b91e 100644 --- a/utils/relayer/connection.go +++ b/utils/relayer/connection.go @@ -3,6 +3,7 @@ package relayer import ( "fmt" "os" + "reflect" "github.com/pterm/pterm" "gopkg.in/yaml.v3" @@ -21,27 +22,21 @@ func VerifyDefaultPath(relayerHome string) (bool, error) { } pterm.Info.Println("unmarshalling config file") - var config map[string]interface{} + var config Config err = yaml.Unmarshal(data, &config) if err != nil { pterm.Error.Println("failed to unmarshal config file:", err) return false, err } - fmt.Println("config", config["paths"]) - pterm.Info.Println("navigating to paths and checking for hub-rollapp") // Navigate to paths and check for hub-rollapp - if paths, ok := config["paths"].(map[interface{}]interface{}); ok { - if _, exists := paths[consts.DefaultRelayerPath]; exists { - pterm.Success.Println("hub-rollapp exists in the YAML configuration.") - return true, nil - } + if !reflect.DeepEqual(config, Config{}) { fmt.Println("want:", consts.DefaultRelayerPath) - fmt.Println("have:", paths[consts.DefaultRelayerPath]) + fmt.Println("have:", config.Paths.HubRollapp) - y, _ := yaml.Marshal(paths) + y, _ := yaml.Marshal(config.Paths) fmt.Println("paths", string(y)) } diff --git a/utils/relayer/types.go b/utils/relayer/types.go index 67ce4d6b..d6c387b6 100644 --- a/utils/relayer/types.go +++ b/utils/relayer/types.go @@ -35,11 +35,19 @@ type Config struct { Paths struct { HubRollapp struct { Dst struct { - ChainID string `yaml:"chain-id"` + ChainID string `yaml:"chain-id"` + ClientID string `yaml:"client-id"` + ConnectionID string `yaml:"connection-id"` } `yaml:"dst"` Src struct { - ChainID string `yaml:"chain-id"` + ChainID string `yaml:"chain-id"` + ClientID string `yaml:"client-id"` + ConnectionID string `yaml:"connection-id"` } `yaml:"src"` + SrcChannelFilter struct { + ChannelList []string `yaml:"channel-list"` + Rule string `yaml:"rule"` + } `yaml:"src-channel-filter"` } `yaml:"hub-rollapp"` } `yaml:"paths"` } From 05eda52a129206b1441e5ba82c18e313513f8e53 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:59:51 +0700 Subject: [PATCH 10/24] chore: debug --- utils/relayer/connection.go | 13 ++++--------- utils/relayer/types.go | 10 +++++----- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/utils/relayer/connection.go b/utils/relayer/connection.go index b438b91e..8b7dc3a9 100644 --- a/utils/relayer/connection.go +++ b/utils/relayer/connection.go @@ -1,9 +1,7 @@ package relayer import ( - "fmt" "os" - "reflect" "github.com/pterm/pterm" "gopkg.in/yaml.v3" @@ -32,15 +30,12 @@ func VerifyDefaultPath(relayerHome string) (bool, error) { pterm.Info.Println("navigating to paths and checking for hub-rollapp") // Navigate to paths and check for hub-rollapp - if !reflect.DeepEqual(config, Config{}) { - fmt.Println("want:", consts.DefaultRelayerPath) - fmt.Println("have:", config.Paths.HubRollapp) - - y, _ := yaml.Marshal(config.Paths) - fmt.Println("paths", string(y)) + if config.Paths == nil || config.Paths.HubRollapp == nil { + pterm.Error.Println("hub-rollapp not found in the YAML configuration.") + return false, nil } - return false, nil + return true, nil } func VerifyPathSrcChain(relayerHome string, hd consts.HubData) (bool, error) { diff --git a/utils/relayer/types.go b/utils/relayer/types.go index d6c387b6..c880bb7f 100644 --- a/utils/relayer/types.go +++ b/utils/relayer/types.go @@ -32,19 +32,19 @@ type Channels struct { // Config struct represents the paths section inside the relayer // configuration file type Config struct { - Paths struct { - HubRollapp struct { - Dst struct { + Paths *struct { + HubRollapp *struct { + Dst *struct { ChainID string `yaml:"chain-id"` ClientID string `yaml:"client-id"` ConnectionID string `yaml:"connection-id"` } `yaml:"dst"` - Src struct { + Src *struct { ChainID string `yaml:"chain-id"` ClientID string `yaml:"client-id"` ConnectionID string `yaml:"connection-id"` } `yaml:"src"` - SrcChannelFilter struct { + SrcChannelFilter *struct { ChannelList []string `yaml:"channel-list"` Rule string `yaml:"rule"` } `yaml:"src-channel-filter"` From 0c08fb50fb2c72ff16e5dd590e9e5654d514533d Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:09:28 +0700 Subject: [PATCH 11/24] fix: reset the ibc path in config if something is wrong --- cmd/relayer/setup/setup.go | 16 +++++++++++----- relayer/config.go | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/cmd/relayer/setup/setup.go b/cmd/relayer/setup/setup.go index 076b912c..9145e8da 100644 --- a/cmd/relayer/setup/setup.go +++ b/cmd/relayer/setup/setup.go @@ -1,7 +1,6 @@ package setup import ( - "encoding/json" "fmt" "os" @@ -123,11 +122,18 @@ func Cmd() *cobra.Command { } } - j, _ := json.MarshalIndent(ibcPathChains, "", " ") - fmt.Println(string(j)) - - if ibcPathChains == nil { + if !ibcPathChains.DefaultPathOk || !ibcPathChains.SrcChainOk || + !ibcPathChains.DstChainOk { pterm.Warning.Println("relayer config verification failed...") + if ibcPathChains.DefaultPathOk { + pterm.Info.Printfln("removing path from config %s", consts.DefaultRelayerPath) + err := relayer.DeletePath(*rollappChainData) + if err != nil { + pterm.Error.Printf("failed to delete relayer IBC path: %v\n", err) + return + } + } + pterm.Info.Println("populating relayer config with correct values...") err = relayerutils.InitializeRelayer(home, *rollappChainData) if err != nil { diff --git a/relayer/config.go b/relayer/config.go index 08d6f622..76ba97f3 100644 --- a/relayer/config.go +++ b/relayer/config.go @@ -35,6 +35,25 @@ func CreatePath(rlpCfg roller.RollappConfig) error { return nil } +func DeletePath(rlpCfg roller.RollappConfig) error { + relayerHome := filepath.Join(rlpCfg.Home, consts.ConfigDirName.Relayer) + pterm.Info.Printf("removing ibc path from %s to %s\n", rlpCfg.HubData.ID, rlpCfg.RollappID) + + newPathCmd := exec.Command( + consts.Executables.Relayer, + "paths", + "delete", + consts.DefaultRelayerPath, + "--home", + relayerHome, + ) + if err := newPathCmd.Run(); err != nil { + return err + } + + return nil +} + type ChainConfig struct { ID string RPC string From 98301226803dea19cf1d3711c281ae074821528c Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 20:02:12 +0700 Subject: [PATCH 12/24] fix: reset the ibc path in config if something is wrong --- relayer/create_ibc_channel.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/relayer/create_ibc_channel.go b/relayer/create_ibc_channel.go index 11178330..f37659db 100644 --- a/relayer/create_ibc_channel.go +++ b/relayer/create_ibc_channel.go @@ -52,6 +52,8 @@ func (r *Relayer) CreateIBCChannel( time.Sleep(15 * time.Second) // we ran create channel with override, as it not recovarable anyway createChannelCmd := r.getCreateChannelCmd(true) + + fmt.Println("createChannelCmd", createChannelCmd.String()) // TODO: switch to spinned pterm.Info.Println("💈 Creating channel (this may take a while)...") if err := r.WriteRelayerStatus(status); err != nil { From cde9b8f183aa283fae417f2b08a39a751cbc7edf Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 20:53:18 +0700 Subject: [PATCH 13/24] fix: typo --- utils/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/config/config.go b/utils/config/config.go index a3a6f69a..ec968ecc 100644 --- a/utils/config/config.go +++ b/utils/config/config.go @@ -75,7 +75,7 @@ func createCustomHubDataFromFile() (*consts.HubData, error) { { "id": "", "rpcUrl": "", - "restUrl": "", + "apiUrl": "", }`) path, _ := pterm.DefaultInteractiveTextInput.WithDefaultText("").Show() for len(path) == 0 { From 45e26cecc15aac6a5cd2414b28b2dd45f5c899cc Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:14:16 +0700 Subject: [PATCH 14/24] fix: typo --- utils/rollapp/rollapp.go | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/rollapp/rollapp.go b/utils/rollapp/rollapp.go index d1529c99..365046ca 100644 --- a/utils/rollapp/rollapp.go +++ b/utils/rollapp/rollapp.go @@ -212,6 +212,7 @@ func PopulateRollerConfigWithRaMetadataFromChain( ) rollerData, err := roller.LoadConfig(home) if err != nil { + pterm.Error.Printf("failed to load roller config: %v\n", err) return nil, err } if rollerData.KeyringBackend == "" { From aa5e5ebfbfba305c5f83ab5dc95d6c784bbe2553 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:19:13 +0700 Subject: [PATCH 15/24] chore: debug --- cmd/relayer/setup/setup.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/relayer/setup/setup.go b/cmd/relayer/setup/setup.go index 9145e8da..fc62b0d9 100644 --- a/cmd/relayer/setup/setup.go +++ b/cmd/relayer/setup/setup.go @@ -62,6 +62,7 @@ func Cmd() *cobra.Command { if !ok { pterm.Error.Printf("%s rollapp not registered on %s", raID, hd.ID) + return } raRpc, err := sequencerutils.GetRpcEndpointFromChain(raID, *hd) @@ -83,6 +84,7 @@ func Cmd() *cobra.Command { *hd, ) errorhandling.PrettifyErrorIfExists(err) + pterm.Info.Println("rollappChainData", rollappChainData) err = rollappChainData.ValidateConfig() if err != nil { From 0b003b6b15f5bf26199000e1fc18c2a8fd4f9988 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:21:01 +0700 Subject: [PATCH 16/24] chore: debug --- cmd/relayer/setup/setup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/relayer/setup/setup.go b/cmd/relayer/setup/setup.go index fc62b0d9..2c05ef1b 100644 --- a/cmd/relayer/setup/setup.go +++ b/cmd/relayer/setup/setup.go @@ -84,13 +84,13 @@ func Cmd() *cobra.Command { *hd, ) errorhandling.PrettifyErrorIfExists(err) - pterm.Info.Println("rollappChainData", rollappChainData) err = rollappChainData.ValidateConfig() if err != nil { pterm.Error.Println("rollapp data validation error: ", err) return } + pterm.Info.Println("rollapp chain data validation passed") // things to check: // 1. relayer folder exists From 94d0122b4516048deb83b36ec68b904bec6da5f5 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:23:45 +0700 Subject: [PATCH 17/24] chore: debug --- cmd/relayer/setup/setup.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/relayer/setup/setup.go b/cmd/relayer/setup/setup.go index 2c05ef1b..10da969c 100644 --- a/cmd/relayer/setup/setup.go +++ b/cmd/relayer/setup/setup.go @@ -1,6 +1,7 @@ package setup import ( + "encoding/json" "fmt" "os" @@ -124,6 +125,9 @@ func Cmd() *cobra.Command { } } + j, _ := json.MarshalIndent(ibcPathChains, "", " ") + pterm.Info.Println(string(j)) + if !ibcPathChains.DefaultPathOk || !ibcPathChains.SrcChainOk || !ibcPathChains.DstChainOk { pterm.Warning.Println("relayer config verification failed...") From 63cb83eef728c83fa818a5fd304a5019db8d1ac9 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:24:59 +0700 Subject: [PATCH 18/24] chore: debug --- utils/relayer/config.go | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/relayer/config.go b/utils/relayer/config.go index 033aef62..57a006f0 100644 --- a/utils/relayer/config.go +++ b/utils/relayer/config.go @@ -92,5 +92,6 @@ func ValidateIbcPathChains(relayerHome, raID string, hd consts.HubData) (*IbcPat } } + pterm.Info.Println("ibc path validation passed") return &ibcPathChains, nil } From f46387354aa2367e713ff614d92ce273644681ba Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:26:39 +0700 Subject: [PATCH 19/24] chore: debug --- cmd/relayer/setup/setup.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cmd/relayer/setup/setup.go b/cmd/relayer/setup/setup.go index 10da969c..f574c002 100644 --- a/cmd/relayer/setup/setup.go +++ b/cmd/relayer/setup/setup.go @@ -1,7 +1,6 @@ package setup import ( - "encoding/json" "fmt" "os" @@ -125,11 +124,8 @@ func Cmd() *cobra.Command { } } - j, _ := json.MarshalIndent(ibcPathChains, "", " ") - pterm.Info.Println(string(j)) - if !ibcPathChains.DefaultPathOk || !ibcPathChains.SrcChainOk || - !ibcPathChains.DstChainOk { + !ibcPathChains.DstChainOk || ibcPathChains == nil { pterm.Warning.Println("relayer config verification failed...") if ibcPathChains.DefaultPathOk { pterm.Info.Printfln("removing path from config %s", consts.DefaultRelayerPath) From 0b5929ba4831fe0c04a53cf287e25a5daedd40a2 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:27:25 +0700 Subject: [PATCH 20/24] chore: debug --- cmd/relayer/setup/setup.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/relayer/setup/setup.go b/cmd/relayer/setup/setup.go index f574c002..e35f7d9a 100644 --- a/cmd/relayer/setup/setup.go +++ b/cmd/relayer/setup/setup.go @@ -124,8 +124,8 @@ func Cmd() *cobra.Command { } } - if !ibcPathChains.DefaultPathOk || !ibcPathChains.SrcChainOk || - !ibcPathChains.DstChainOk || ibcPathChains == nil { + if ibcPathChains == nil || !ibcPathChains.DefaultPathOk || !ibcPathChains.SrcChainOk || + !ibcPathChains.DstChainOk { pterm.Warning.Println("relayer config verification failed...") if ibcPathChains.DefaultPathOk { pterm.Info.Printfln("removing path from config %s", consts.DefaultRelayerPath) From 5792c91c17683bad1322685cd91af7070971e996 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:28:18 +0700 Subject: [PATCH 21/24] chore: debug --- cmd/relayer/setup/setup.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/relayer/setup/setup.go b/cmd/relayer/setup/setup.go index e35f7d9a..14affde6 100644 --- a/cmd/relayer/setup/setup.go +++ b/cmd/relayer/setup/setup.go @@ -124,7 +124,12 @@ func Cmd() *cobra.Command { } } - if ibcPathChains == nil || !ibcPathChains.DefaultPathOk || !ibcPathChains.SrcChainOk || + if ibcPathChains == nil { + pterm.Error.Println("ibc path chains are nil") + return + } + + if !ibcPathChains.DefaultPathOk || !ibcPathChains.SrcChainOk || !ibcPathChains.DstChainOk { pterm.Warning.Println("relayer config verification failed...") if ibcPathChains.DefaultPathOk { From bbd4a8a896a96eb2f1e1c2f31411201045fd1532 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:29:41 +0700 Subject: [PATCH 22/24] chore: debug --- cmd/relayer/setup/setup.go | 44 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/cmd/relayer/setup/setup.go b/cmd/relayer/setup/setup.go index 14affde6..4cea60c4 100644 --- a/cmd/relayer/setup/setup.go +++ b/cmd/relayer/setup/setup.go @@ -124,33 +124,33 @@ func Cmd() *cobra.Command { } } - if ibcPathChains == nil { - pterm.Error.Println("ibc path chains are nil") - return - } + if ibcPathChains != nil { + if !ibcPathChains.DefaultPathOk || !ibcPathChains.SrcChainOk || + !ibcPathChains.DstChainOk { + pterm.Warning.Println("relayer config verification failed...") + if ibcPathChains.DefaultPathOk { + pterm.Info.Printfln( + "removing path from config %s", + consts.DefaultRelayerPath, + ) + err := relayer.DeletePath(*rollappChainData) + if err != nil { + pterm.Error.Printf("failed to delete relayer IBC path: %v\n", err) + return + } + } - if !ibcPathChains.DefaultPathOk || !ibcPathChains.SrcChainOk || - !ibcPathChains.DstChainOk { - pterm.Warning.Println("relayer config verification failed...") - if ibcPathChains.DefaultPathOk { - pterm.Info.Printfln("removing path from config %s", consts.DefaultRelayerPath) - err := relayer.DeletePath(*rollappChainData) + pterm.Info.Println("populating relayer config with correct values...") + err = relayerutils.InitializeRelayer(home, *rollappChainData) if err != nil { - pterm.Error.Printf("failed to delete relayer IBC path: %v\n", err) + pterm.Error.Printf("failed to initialize relayer config: %v\n", err) return } - } - pterm.Info.Println("populating relayer config with correct values...") - err = relayerutils.InitializeRelayer(home, *rollappChainData) - if err != nil { - pterm.Error.Printf("failed to initialize relayer config: %v\n", err) - return - } - - if err := relayer.CreatePath(*rollappChainData); err != nil { - pterm.Error.Printf("failed to create relayer IBC path: %v\n", err) - return + if err := relayer.CreatePath(*rollappChainData); err != nil { + pterm.Error.Printf("failed to create relayer IBC path: %v\n", err) + return + } } } From 5ca8f69158a1002b411484ea09a357b14fdf3475 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:31:54 +0700 Subject: [PATCH 23/24] chore: debug --- cmd/relayer/setup/setup.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/relayer/setup/setup.go b/cmd/relayer/setup/setup.go index 4cea60c4..d1a04c9c 100644 --- a/cmd/relayer/setup/setup.go +++ b/cmd/relayer/setup/setup.go @@ -152,6 +152,18 @@ func Cmd() *cobra.Command { return } } + } else { + pterm.Info.Println("populating relayer config with correct values...") + err = relayerutils.InitializeRelayer(home, *rollappChainData) + if err != nil { + pterm.Error.Printf("failed to initialize relayer config: %v\n", err) + return + } + + if err := relayer.CreatePath(*rollappChainData); err != nil { + pterm.Error.Printf("failed to create relayer IBC path: %v\n", err) + return + } } if err := relayerutils.UpdateConfigWithDefaultValues(relayerHome, *rollappChainData); err != nil { From e4ac9f8bd296238ff21dbd4beac211a01ec3f613 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Fri, 8 Nov 2024 22:00:36 +0700 Subject: [PATCH 24/24] chore: remvove debug --- utils/relayer/config.go | 1 - utils/relayer/connection.go | 5 ----- 2 files changed, 6 deletions(-) diff --git a/utils/relayer/config.go b/utils/relayer/config.go index 57a006f0..12f1a1de 100644 --- a/utils/relayer/config.go +++ b/utils/relayer/config.go @@ -50,7 +50,6 @@ func ValidateIbcPathChains(relayerHome, raID string, hd consts.HubData) (*IbcPat relayerConfigPath := GetConfigFilePath(relayerHome) - pterm.Info.Println("checking configuration") // 2. config file exists relayerConfigExists, err := filesystem.DoesFileExist(relayerConfigPath) if err != nil { diff --git a/utils/relayer/connection.go b/utils/relayer/connection.go index 8b7dc3a9..8bc30dda 100644 --- a/utils/relayer/connection.go +++ b/utils/relayer/connection.go @@ -10,7 +10,6 @@ import ( ) func VerifyDefaultPath(relayerHome string) (bool, error) { - pterm.Info.Println("verifying default path") cfp := GetConfigFilePath(relayerHome) data, err := os.ReadFile(cfp) @@ -19,7 +18,6 @@ func VerifyDefaultPath(relayerHome string) (bool, error) { return false, err } - pterm.Info.Println("unmarshalling config file") var config Config err = yaml.Unmarshal(data, &config) if err != nil { @@ -27,9 +25,6 @@ func VerifyDefaultPath(relayerHome string) (bool, error) { return false, err } - pterm.Info.Println("navigating to paths and checking for hub-rollapp") - // Navigate to paths and check for hub-rollapp - if config.Paths == nil || config.Paths.HubRollapp == nil { pterm.Error.Println("hub-rollapp not found in the YAML configuration.") return false, nil