From 1b44e2d489320a163fbdf0baa343db1da8274bab Mon Sep 17 00:00:00 2001 From: Michael Tsitrin <114929630+mtsitrin@users.noreply.github.com> Date: Tue, 22 Aug 2023 23:30:25 +0300 Subject: [PATCH] fix: adjusted timeouts. added retry loop over create channels (#426) --- relayer/create_ibc_channel.go | 64 ++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/relayer/create_ibc_channel.go b/relayer/create_ibc_channel.go index 65898239..5707360a 100644 --- a/relayer/create_ibc_channel.go +++ b/relayer/create_ibc_channel.go @@ -34,7 +34,7 @@ func (r *Relayer) CreateIBCChannel(override bool, logFileOption utils.CommandOpt updateClientsCmd := r.GetUpdateClientsCmd() return utils.ExecBashCmd(updateClientsCmd, logFileOption) }, - retry.Delay(time.Duration(10)*time.Second), + retry.Delay(time.Duration(30)*time.Second), retry.DelayType(retry.FixedDelay), retry.Attempts(5), retry.OnRetry(func(n uint, err error) { @@ -55,39 +55,47 @@ func (r *Relayer) CreateIBCChannel(override bool, logFileOption utils.CommandOpt return ConnectionChannels{}, err } - createChannelCmd := r.getCreateChannelCmd(override) - status = "Creating channel..." - fmt.Printf("💈 %s\n", status) - if err := r.WriteRelayerStatus(status); err != nil { - return ConnectionChannels{}, err - } - if err := utils.ExecBashCmd(createChannelCmd, logFileOption); err != nil { - return ConnectionChannels{}, err - } - status = "Waiting for channel finalization..." - fmt.Printf("💈 %s\n", status) - if err := r.WriteRelayerStatus(status); err != nil { - return ConnectionChannels{}, err - } var src, dst string err = retry.Do( func() error { - var err error - src, dst, err = r.LoadChannels() - if err != nil { + createChannelCmd := r.getCreateChannelCmd(override) + status = "Creating channel..." + fmt.Printf("💈 %s\n", status) + if err := r.WriteRelayerStatus(status); err != nil { return err } - if src == "" || dst == "" { - return fmt.Errorf("could not load channels") + if err := utils.ExecBashCmd(createChannelCmd, logFileOption); err != nil { + return err } - return nil - }, - retry.Delay(time.Duration(10)*time.Second), + status = "Waiting for channel finalization..." + fmt.Printf("💈 %s\n", status) + if err := r.WriteRelayerStatus(status); err != nil { + return err + } + + err = retry.Do( + func() error { + var err error + src, dst, err = r.LoadChannels() + if err != nil { + return err + } + if src == "" || dst == "" { + return fmt.Errorf("could not load channels") + } + return nil + }, + retry.Delay(time.Duration(30)*time.Second), + retry.DelayType(retry.FixedDelay), + retry.Attempts(3), + retry.OnRetry(func(n uint, err error) { + r.logger.Printf("error validating clients created. attempt %d, error %s", n, err) + }), + ) + return err + }, retry.Delay(time.Duration(30)*time.Second), retry.DelayType(retry.FixedDelay), retry.Attempts(5), - retry.OnRetry(func(n uint, err error) { - r.logger.Printf("error validating clients created. attempt %d, error %s", n, err) - }), ) if err != nil { return ConnectionChannels{}, err @@ -112,7 +120,7 @@ func (r *Relayer) getCreateClientsCmd(override bool) *exec.Cmd { } func (r *Relayer) getCreateConnectionCmd(override bool) *exec.Cmd { - args := []string{"tx", "connection", "-t", "300s"} + args := []string{"tx", "connection", "-t", "30s", "-r", "20"} if override { args = append(args, "--override") } @@ -121,7 +129,7 @@ func (r *Relayer) getCreateConnectionCmd(override bool) *exec.Cmd { } func (r *Relayer) getCreateChannelCmd(override bool) *exec.Cmd { - args := []string{"tx", "channel", "-t", "300s"} + args := []string{"tx", "channel", "-t", "30s", "-r", "20"} if override { args = append(args, "--override") }