Skip to content

Commit

Permalink
fix: relayer client creation flow (#876)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs committed Sep 3, 2024
1 parent a535725 commit 2dddc4a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 78 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 9 additions & 14 deletions cmd/relayer/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const (
flagOverride = "override"
)

// nolint gocyclo
func Cmd() *cobra.Command {
relayerStartCmd := &cobra.Command{
Use: "run",
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:")
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 1 addition & 55 deletions relayer/create_ibc_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion utils/eibc/eibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2dddc4a

Please sign in to comment.