Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update relayer flow to support lc #875

Merged
merged 28 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
96502b3
chore: update to new relayer version
artemijspavlovs Sep 2, 2024
07c4051
chore: debug
artemijspavlovs Sep 3, 2024
b6f80ee
chore: debug
artemijspavlovs Sep 3, 2024
8163109
chore: debug
artemijspavlovs Sep 3, 2024
96b8b10
chore: debug
artemijspavlovs Sep 3, 2024
1109998
chore: debug
artemijspavlovs Sep 3, 2024
135f60e
chore: debug
artemijspavlovs Sep 3, 2024
d62817d
chore: debug
artemijspavlovs Sep 3, 2024
3e4eaf0
chore: debu
artemijspavlovs Sep 3, 2024
ce875a3
chore: debug
artemijspavlovs Sep 3, 2024
c71b8d4
chore: debug
artemijspavlovs Sep 3, 2024
3c68c77
chore: debug
artemijspavlovs Sep 3, 2024
15e5d81
chore: refactor update yaml func
artemijspavlovs Sep 3, 2024
4bee709
refactor: yaml
artemijspavlovs Sep 3, 2024
63c9031
refactor: yaml
artemijspavlovs Sep 3, 2024
9135501
chore: yaml
artemijspavlovs Sep 3, 2024
c690c1e
chore: debug
artemijspavlovs Sep 3, 2024
2babd4e
chore: debug
artemijspavlovs Sep 3, 2024
b1a980f
chore: debug
artemijspavlovs Sep 3, 2024
40fd006
fix: order
artemijspavlovs Sep 3, 2024
c823c8e
chore: fix typo
artemijspavlovs Sep 3, 2024
d800052
chore: update relayer version
artemijspavlovs Sep 3, 2024
6a69742
fix: handle existing channels
artemijspavlovs Sep 3, 2024
3874702
chore: fix typo
artemijspavlovs Sep 3, 2024
b53b61e
chore: remove debug
artemijspavlovs Sep 3, 2024
91b449f
chore: remove debug
artemijspavlovs Sep 3, 2024
d435f7f
chore: output
artemijspavlovs Sep 3, 2024
adf150f
Merge branch 'main' into artemijspavlovs/update-relayer-flow
artemijspavlovs Sep 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.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/compilerla/conventional-pre-commit
rev: v3.2.0
hooks:
Expand Down
15 changes: 7 additions & 8 deletions cmd/eibc/fulfill/denoms/set/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import (
"strconv"
"strings"

"github.com/dymensionxyz/roller/cmd/consts"
globalutils "github.com/dymensionxyz/roller/utils"
"github.com/dymensionxyz/roller/utils/config/yamlconfig"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"

"github.com/dymensionxyz/roller/cmd/consts"
globalutils "github.com/dymensionxyz/roller/utils"
"github.com/dymensionxyz/roller/utils/config/yamlconfig"
)

func Cmd() *cobra.Command {
Expand Down Expand Up @@ -68,10 +69,8 @@ func Cmd() *cobra.Command {
}

// Get the actual content node (usually the first child of the document node)
contentNode := &node
if node.Kind == yaml.DocumentNode && len(node.Content) > 0 {
contentNode = node.Content[0]
}
var contentNode map[interface{}]interface{}
err = yaml.Unmarshal(data, &contentNode)

err = yamlconfig.UpdateNestedYAML(
contentNode,
Expand All @@ -83,7 +82,7 @@ func Cmd() *cobra.Command {
return
}

updatedData, err := yaml.Marshal(&node)
updatedData, err := yaml.Marshal(contentNode)
if err != nil {
fmt.Printf("Error marshaling YAML: %v\n", err)
return
Expand Down
8 changes: 3 additions & 5 deletions cmd/eibc/fulfill/rollapps/set/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ func Cmd() *cobra.Command {
}

// Get the actual content node (usually the first child of the document node)
contentNode := &node
if node.Kind == yaml.DocumentNode && len(node.Content) > 0 {
contentNode = node.Content[0]
}
var contentNode map[interface{}]interface{}
err = yaml.Unmarshal(data, &contentNode)

err = yamlconfig.UpdateNestedYAML(
contentNode,
Expand All @@ -78,7 +76,7 @@ func Cmd() *cobra.Command {
return
}

updatedData, err := yaml.Marshal(&node)
updatedData, err := yaml.Marshal(contentNode)
if err != nil {
fmt.Printf("Error marshaling YAML: %v\n", err)
return
Expand Down
17 changes: 3 additions & 14 deletions cmd/eibc/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,8 @@ func Cmd() *cobra.Command {
return
}

// Parse the YAML
var node yaml.Node
err = yaml.Unmarshal(data, &node)
if err != nil {
pterm.Error.Println("failed to unmarshal config.yaml")
return
}

// Get the actual content node (usually the first child of the document node)
contentNode := &node
if node.Kind == yaml.DocumentNode && len(node.Content) > 0 {
contentNode = node.Content[0]
}
var contentNode map[interface{}]interface{}
err = yaml.Unmarshal(data, &contentNode)

// Update the nested fields
err = yamlconfig.UpdateNestedYAML(
Expand All @@ -139,7 +128,7 @@ func Cmd() *cobra.Command {
}

// Marshal the updated YAML
updatedData, err := yaml.Marshal(&node)
updatedData, err := yaml.Marshal(contentNode)
if err != nil {
fmt.Printf("Error marshaling YAML: %v\n", err)
return
Expand Down
101 changes: 73 additions & 28 deletions cmd/relayer/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
comettypes "github.com/cometbft/cometbft/types"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
"gopkg.in/yaml.v2"

initconfig "github.com/dymensionxyz/roller/cmd/config/init"
"github.com/dymensionxyz/roller/cmd/consts"
Expand Down Expand Up @@ -185,24 +185,34 @@ func Cmd() *cobra.Command {
return
}

pterm.Info.Println("updating application relayer config")
path := filepath.Join(relayerHome, "config")
data, err := os.ReadFile(filepath.Join(path, "config.yaml"))
pterm.Info.Println(
"updating dymint config to 5s block time for relayer configuration",
)
err = dymintutils.UpdateDymintConfigForIBC(home, "5s", false)
if err != nil {
fmt.Printf("Error reading file: %v\n", err)
pterm.Error.Println(
"failed to update dymint config for ibc creation",
err,
)
return
}

// Parse the YAML
var node yaml.Node
err = yaml.Unmarshal(data, &node)
if err != nil {
pterm.Error.Println("failed to unmarshal config.yaml")
if err := relayer.CreatePath(rollappConfig); err != nil {
pterm.Error.Printf("failed to create relayer IBC path: %v\n", err)
return
}

contentNode := &node
if node.Kind == yaml.DocumentNode && len(node.Content) > 0 {
contentNode = node.Content[0]
pterm.Info.Println("updating application relayer config")
relayerConfigPath := filepath.Join(relayerHome, "config", "config.yaml")
data, err := os.ReadFile(filepath.Join(relayerConfigPath))
if err != nil {
fmt.Printf("Error reading file: %v\n", err)
}

var contentNode map[interface{}]interface{}
err = yaml.Unmarshal(data, &contentNode)
if err != nil {
pterm.Error.Println("failed to unmarshal", err)
}

err = yamlconfig.UpdateNestedYAML(
Expand All @@ -215,33 +225,64 @@ func Cmd() *cobra.Command {
return
}

updatedData, err := yaml.Marshal(&node)
err = yamlconfig.UpdateNestedYAML(
contentNode,
[]string{"chains", rollappConfig.HubData.ID, "value", "is-dym-hub"},
true,
)
if err != nil {
fmt.Printf("Error marshaling YAML: %v\n", err)
fmt.Printf("Error updating YAML: %v\n", err)
return
}

// Write the updated YAML back to the original file
err = os.WriteFile(filepath.Join(path, "config.yaml"), updatedData, 0o644)
err = yamlconfig.UpdateNestedYAML(
contentNode,
[]string{"chains", rollappConfig.HubData.ID, "value", "http-addr"},
rollappConfig.HubData.API_URL,
)
if err != nil {
fmt.Printf("Error writing file: %v\n", err)
fmt.Printf("Error updating YAML: %v\n", err)
return
}

pterm.Info.Println(
"updating dymint config to 5s block time for relayer configuration",
err = yamlconfig.UpdateNestedYAML(
contentNode,
[]string{"chains", rollappConfig.RollappID, "value", "is-dym-rollapp"},
true,
)
err = dymintutils.UpdateDymintConfigForIBC(home, "5s", false)
if err != nil {
pterm.Error.Println(
"failed to update dymint config for ibc creation",
err,
)
fmt.Printf("Error updating YAML: %v\n", err)
return
}

if err := relayer.CreatePath(rollappConfig); err != nil {
pterm.Error.Printf("failed to create relayer IBC path: %v\n", err)
err = yamlconfig.UpdateNestedYAML(
contentNode,
[]string{"chains", rollappConfig.RollappID, "value", "trust-period"},
"240h",
)
if err != nil {
fmt.Printf("Error updating YAML: %v\n", err)
return
}

updatedData, err := yaml.Marshal(contentNode)
if err != nil {
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"),
updatedData,
0o644,
)
if err != nil {
fmt.Printf("Error writing file: %v\n", err)
return
}
}
Expand Down Expand Up @@ -324,14 +365,18 @@ func Cmd() *cobra.Command {
Println("IBC transfer channel is already established!")

status := fmt.Sprintf(
"Active rollapp: %s\n<->\nhub: %s",
"Active\nrollapp: %s\n<->\nhub: %s",
rly.SrcChannel,
rly.DstChannel,
)
err := rly.WriteRelayerStatus(status)
if err != nil {
fmt.Println(err)
return
}

pterm.Info.Println(status)
return
}

if !rly.ChannelReady() {
Expand Down
1 change: 0 additions & 1 deletion cmd/utils/key_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ func IsRlyAddressWithNameInKeyring(
consts.Executables.Relayer,
"keys", "list", chainId, "--home", info.Dir,
)
fmt.Println(cmd.String())

out, err := bash.ExecCommandWithStdout(cmd)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ require (
github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240823151307-f42674aede1d
github.com/gizak/termui/v3 v3.1.0
github.com/gogo/protobuf v1.3.3
github.com/ignite/cli v0.27.2
github.com/manifoldco/promptui v0.9.0
github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416
github.com/olekukonko/tablewriter v0.0.5
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DYMD_VERSION="main"
DYMD_COMMIT="f42674ae"

EIBC_VERSION="main"
RLY_VERSION="v0.3.4-v2.5.2-relayer"
RLY_VERSION="v0.3.4-v2.5.2-relayer-canon-1"
CELESTIA_VERSION="v0.16.0-rc0"
CELESTIA_APP_VERSION="v2.0.0"

Expand Down
Loading
Loading