Skip to content

Commit

Permalink
fix: adjusted timeouts. added retry loop over create channels (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin authored Aug 22, 2023
1 parent 37a1aae commit 1b44e2d
Showing 1 changed file with 36 additions and 28 deletions.
64 changes: 36 additions & 28 deletions relayer/create_ibc_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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")
}
Expand All @@ -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")
}
Expand Down

0 comments on commit 1b44e2d

Please sign in to comment.