From 2dddc4a112ea22b92cc00799e726e30ad81c6da3 Mon Sep 17 00:00:00 2001 From: artpav <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 18:12:36 +0300 Subject: [PATCH] fix: relayer client creation flow (#876) --- .pre-commit-config.yaml | 14 ++++----- cmd/relayer/run/run.go | 23 ++++++-------- go.mod | 1 - relayer/create_ibc_channel.go | 56 +---------------------------------- utils/eibc/eibc.go | 3 +- 5 files changed, 19 insertions(+), 78 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 843c5868..03d06f4a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,13 +8,13 @@ repos: - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - # - repo: https://github.com/golangci/golangci-lint - # rev: v1.59.1 - # hooks: - # - id: golangci-lint - # name: lint Go files - # args: [--new-from-rev=HEAD, -v, --fix, --exclude-use-default, --sort-results] - # files: \.go$ + - repo: https://github.com/golangci/golangci-lint + rev: v1.60.3 + hooks: + - id: golangci-lint + name: lint Go files + args: [--new-from-rev=HEAD, -v, --fix, --exclude-use-default, --sort-results] + files: \.go$ - repo: https://github.com/compilerla/conventional-pre-commit rev: v3.2.0 hooks: diff --git a/cmd/relayer/run/run.go b/cmd/relayer/run/run.go index 8f79e986..4faa4b45 100644 --- a/cmd/relayer/run/run.go +++ b/cmd/relayer/run/run.go @@ -34,7 +34,6 @@ const ( flagOverride = "override" ) -// nolint gocyclo func Cmd() *cobra.Command { relayerStartCmd := &cobra.Command{ Use: "run", @@ -270,14 +269,9 @@ func Cmd() *cobra.Command { fmt.Printf("Error marshaling YAML: %v\n", err) return } - fmt.Println("writing") - fmt.Println(string(updatedData)) - fmt.Println("to") - fmt.Println(filepath.Join(relayerConfigPath, "config.yaml")) - // Write the updated YAML back to the original file err = os.WriteFile( - filepath.Join(relayerConfigPath, "config.yaml"), + filepath.Join(relayerConfigPath), updatedData, 0o644, ) @@ -395,7 +389,6 @@ func Cmd() *cobra.Command { // TODO: look up relayer keys if createIbcChannels || shouldOverwrite { - err = verifyRelayerBalances(rollappConfig) if err != nil { pterm.Error.Printf("failed to verify relayer balances: %v\n", err) @@ -427,12 +420,14 @@ func Cmd() *cobra.Command { rly.DstChannel, ) - pterm.Info.Println("reverting dymint config to 1h") - err = dymintutils.UpdateDymintConfigForIBC(home, "1h0m0s", true) - if err != nil { - pterm.Error.Println("failed to update dymint config") - return - } + defer func() { + pterm.Info.Println("reverting dymint config to 1h") + err = dymintutils.UpdateDymintConfigForIBC(home, "1h0m0s", true) + if err != nil { + pterm.Error.Println("failed to update dymint config") + return + } + }() // select {} pterm.Info.Println("next steps:") diff --git a/go.mod b/go.mod index 9932b551..e48691f7 100644 --- a/go.mod +++ b/go.mod @@ -141,7 +141,6 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hdevalence/ed25519consensus v0.1.0 // indirect github.com/huandu/skiplist v1.2.0 // indirect - github.com/ignite/cli v0.27.2 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/jessevdk/go-flags v1.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect diff --git a/relayer/create_ibc_channel.go b/relayer/create_ibc_channel.go index b9ac8615..36c1a2d4 100644 --- a/relayer/create_ibc_channel.go +++ b/relayer/create_ibc_channel.go @@ -24,63 +24,9 @@ func (r *Relayer) CreateIBCChannel( ) (ConnectionChannels, error) { // ctx, cancel := context.WithCancel(context.Background()) // defer cancel() - - // Run send funds command from sequencer to itself to make sure the chain is - // progressing for connection and channel creation. - // replaced update clients to avoid account sequence mismatch and - // premature heights updates e.g "TrustedHeight {1 x} must be less than header height {1 y}" - // sequencerAddress, err := utils.GetAddressBinary( - // utils.KeyConfig{ - // Dir: filepath.Join(seq.RlpCfg.Home, consts.ConfigDirName.Rollapp), - // ID: consts.KeysIds.RollappSequencer, - // }, consts.Executables.RollappEVM, - // ) - // if err != nil { - // return ConnectionChannels{}, err - // } - // - // sendFundsCmd := seq.GetSendCmd(sequencerAddress) - // bash.RunCommandEvery( - // ctx, - // sendFundsCmd.Path, - // sendFundsCmd.Args[1:], - // 5, - // utils.WithDiscardLogging(), - // ) - // var status string - // Create client if it doesn't exist or override is true - clientsExist := false - if !override { - // Check if clients exist - clientsExist, _ = r.CheckClientsExist() - } - if !clientsExist { - // wait for block to be created - pterm.Info.Println("💈 Validating rollapp height > 2 before creating clients...") - if err := r.WriteRelayerStatus(status); err != nil { - return ConnectionChannels{}, err - } - - if err := waitForValidRollappHeight(seq); err != nil { - fmt.Println(err) - return ConnectionChannels{}, err - } - - // We always pass override otherwise this command hangs if there are too many clients - createClientsCmd := r.getCreateClientsCmd(true) - pterm.Info.Println("💈 Creating clients...") - if err := r.WriteRelayerStatus(status); err != nil { - return ConnectionChannels{}, err - } - - if err := bash.ExecCmd(createClientsCmd, logFileOption); err != nil { - fmt.Println(err) - return ConnectionChannels{}, err - } - } - + // TODO: this is probably not true anymore, review and remove the sleep if necessary // Sleep for a few seconds to make sure the clients are created // otherwise the connection creation attempt fails time.Sleep(10 * time.Second) diff --git a/utils/eibc/eibc.go b/utils/eibc/eibc.go index 9a66cc81..bdc64f6a 100644 --- a/utils/eibc/eibc.go +++ b/utils/eibc/eibc.go @@ -8,11 +8,12 @@ import ( "path/filepath" "github.com/docker/docker/client" + "github.com/pterm/pterm" + initconfig "github.com/dymensionxyz/roller/cmd/config/init" "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/cmd/utils" dockerutils "github.com/dymensionxyz/roller/utils/docker" - "github.com/pterm/pterm" ) func GetStartCmd() *exec.Cmd {