From 96502b3c5ed36193cfaa22a0a6d4cfef9097682b Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Mon, 2 Sep 2024 21:51:19 +0400 Subject: [PATCH 01/27] chore: update to new relayer version --- cmd/relayer/run/run.go | 40 ++++++++++ go.mod | 1 + go.sum | 2 + scripts/install-binaries.sh | 2 +- utils/config/yamlconfig/yaml.go | 134 +++++++++++++++++++++++++------- 5 files changed, 148 insertions(+), 31 deletions(-) diff --git a/cmd/relayer/run/run.go b/cmd/relayer/run/run.go index 1345c300..738f3a97 100644 --- a/cmd/relayer/run/run.go +++ b/cmd/relayer/run/run.go @@ -215,6 +215,46 @@ func Cmd() *cobra.Command { return } + err = yamlconfig.UpdateNestedYAML( + contentNode, + []string{"chains", rollappConfig.HubData.ID, "value", "is-dym-hub"}, + true, + ) + if err != nil { + fmt.Printf("Error updating YAML: %v\n", err) + return + } + + err = yamlconfig.UpdateNestedYAML( + contentNode, + []string{"chains", rollappConfig.RollappID, "value", "http-addr"}, + rollappConfig.HubData.API_URL, + ) + if err != nil { + fmt.Printf("Error updating YAML: %v\n", err) + return + } + + err = yamlconfig.UpdateNestedYAML( + contentNode, + []string{"chains", rollappConfig.RollappID, "value", "is-dym-rollapp"}, + true, + ) + if err != nil { + fmt.Printf("Error updating YAML: %v\n", err) + return + } + + 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(&node) if err != nil { fmt.Printf("Error marshaling YAML: %v\n", err) diff --git a/go.mod b/go.mod index 86dfb886..9650960a 100644 --- a/go.mod +++ b/go.mod @@ -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.26.1 github.com/manifoldco/promptui v0.9.0 github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416 github.com/olekukonko/tablewriter v0.0.5 diff --git a/go.sum b/go.sum index 76795836..8b9d9e23 100644 --- a/go.sum +++ b/go.sum @@ -994,6 +994,8 @@ github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47 github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= +github.com/ignite/cli v0.26.1 h1:T4qMjM9H38JOBsgCruilGcsfrlDGHO2K1V88gIe0ubs= +github.com/ignite/cli v0.26.1/go.mod h1:0BQcJCseK0O5RG8HYP/lvVTFbZQjkw+AY8B+wDklj38= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= diff --git a/scripts/install-binaries.sh b/scripts/install-binaries.sh index fe8beb2f..3c9a89c6 100755 --- a/scripts/install-binaries.sh +++ b/scripts/install-binaries.sh @@ -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-0" CELESTIA_VERSION="v0.16.0-rc0" CELESTIA_APP_VERSION="v2.0.0" diff --git a/utils/config/yamlconfig/yaml.go b/utils/config/yamlconfig/yaml.go index 8c605d6b..01a4c861 100644 --- a/utils/config/yamlconfig/yaml.go +++ b/utils/config/yamlconfig/yaml.go @@ -2,9 +2,10 @@ package yamlconfig import ( "fmt" - "strconv" + "time" - yaml "gopkg.in/yaml.v3" + "github.com/ignite/cli/ignite/pkg/cosmosaccount" + "gopkg.in/yaml.v3" ) func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { @@ -30,51 +31,124 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { } // If the path doesn't exist, create it - newNode := &yaml.Node{ + // Create a new key node + newKeyNode := &yaml.Node{ Kind: yaml.ScalarNode, Value: path[0], Tag: "!!str", } - valueNode := &yaml.Node{Kind: yaml.ScalarNode} - node.Content = append(node.Content, newNode, valueNode) - return UpdateNestedYAML(valueNode, path[1:], value) + node.Content = append(node.Content, newKeyNode) + + // Determine the kind of the new value node + var newValueNode *yaml.Node + if len(path) == 1 { + // If this is the last element in the path, set the value + newValueNode = &yaml.Node{ + Kind: yaml.ScalarNode, + Tag: "!!str", // You can adjust the tag based on the type of `value` + } + } else { + // Otherwise, create a new mapping node for the next level + newValueNode = &yaml.Node{ + Kind: yaml.MappingNode, + } + } + + node.Content = append(node.Content, newValueNode) + return UpdateNestedYAML(newValueNode, path[1:], value) } func setNodeValue(node *yaml.Node, value interface{}) error { switch v := value.(type) { case string: - node.Value = v + node.Kind = yaml.ScalarNode node.Tag = "!!str" + node.Value = v case int: - node.Value = strconv.Itoa(v) + node.Kind = yaml.ScalarNode node.Tag = "!!int" + node.Value = fmt.Sprintf("%d", v) + case float32: + node.Kind = yaml.ScalarNode + node.Tag = "!!float" + node.Value = fmt.Sprintf("%f", v) case float64: - node.Value = strconv.FormatFloat(v, 'f', -1, 64) + node.Kind = yaml.ScalarNode node.Tag = "!!float" + node.Value = fmt.Sprintf("%f", v) + case bool: + node.Kind = yaml.ScalarNode + node.Tag = "!!bool" + node.Value = fmt.Sprintf("%t", v) default: - return fmt.Errorf("unsupported type: %T", value) + return fmt.Errorf("unsupported value type: %T", value) } return nil } -func PrintYAMLStructure(node *yaml.Node, indent string) { - switch node.Kind { - case yaml.DocumentNode: - for _, n := range node.Content { - PrintYAMLStructure(n, indent) - } - case yaml.MappingNode: - fmt.Printf("%sMapping:\n", indent) - for i := 0; i < len(node.Content); i += 2 { - fmt.Printf("%s %s:\n", indent, node.Content[i].Value) - PrintYAMLStructure(node.Content[i+1], indent+" ") - } - case yaml.SequenceNode: - fmt.Printf("%sSequence:\n", indent) - for _, n := range node.Content { - PrintYAMLStructure(n, indent+" ") - } - case yaml.ScalarNode: - fmt.Printf("%sScalar: %s\n", indent, node.Value) - } +type EibcConfig struct { + HomeDir string `mapstructure:"home_dir"` + NodeAddress string `mapstructure:"node_address"` + DBPath string `mapstructure:"db_path"` + Gas GasConfig `mapstructure:"gas"` + OrderPolling OrderPollingConfig `mapstructure:"order_polling"` + + Whale whaleConfig `mapstructure:"whale"` + Bots botConfig `mapstructure:"bots"` + FulfillCriteria fulfillCriteria `mapstructure:"fulfill_criteria"` + + LogLevel string `mapstructure:"log_level"` + SlackConfig slackConfig `mapstructure:"slack"` + SkipRefund bool `mapstructure:"skip_refund"` +} + +type OrderPollingConfig struct { + IndexerURL string `mapstructure:"indexer_url"` + Interval time.Duration `mapstructure:"interval"` + Enabled bool `mapstructure:"enabled"` +} + +type GasConfig struct { + Prices string `mapstructure:"prices"` + Fees string `mapstructure:"fees"` + MinimumGasBalance string `mapstructure:"minimum_gas_balance"` +} + +type botConfig struct { + NumberOfBots int `mapstructure:"number_of_bots"` + KeyringBackend cosmosaccount.KeyringBackend `mapstructure:"keyring_backend"` + KeyringDir string `mapstructure:"keyring_dir"` + TopUpFactor int `mapstructure:"top_up_factor"` + MaxOrdersPerTx int `mapstructure:"max_orders_per_tx"` +} + +type whaleConfig struct { + AccountName string `mapstructure:"account_name"` + KeyringBackend cosmosaccount.KeyringBackend `mapstructure:"keyring_backend"` + KeyringDir string `mapstructure:"keyring_dir"` + AllowedBalanceThresholds map[string]string `mapstructure:"allowed_balance_thresholds"` +} + +type fulfillCriteria struct { + MinFeePercentage minFeePercentage `mapstructure:"min_fee_percentage"` +} + +type minFeePercentage struct { + Chain map[string]float32 `mapstructure:"chain"` + Asset map[string]float32 `mapstructure:"asset"` +} + +type slackConfig struct { + Enabled bool `mapstructure:"enabled"` + BotToken string `mapstructure:"bot_token"` + AppToken string `mapstructure:"app_token"` + ChannelID string `mapstructure:"channel_id"` +} + +func (e *EibcConfig) RemoveChain(chainId string) { + delete(e.FulfillCriteria.MinFeePercentage.Chain, chainId) +} + +func (e *EibcConfig) RemoveDenom(denom string) { + delete(e.FulfillCriteria.MinFeePercentage.Asset, denom) } From 07c405162c8e762c02627aeac66b98a3b0576783 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 12:57:45 +0400 Subject: [PATCH 02/27] chore: debug --- cmd/relayer/run/run.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/relayer/run/run.go b/cmd/relayer/run/run.go index 738f3a97..3ec21933 100644 --- a/cmd/relayer/run/run.go +++ b/cmd/relayer/run/run.go @@ -7,12 +7,9 @@ import ( "os" "path/filepath" "strconv" + "strings" comettypes "github.com/cometbft/cometbft/types" - "github.com/pterm/pterm" - "github.com/spf13/cobra" - "gopkg.in/yaml.v3" - initconfig "github.com/dymensionxyz/roller/cmd/config/init" "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/cmd/utils" @@ -27,6 +24,9 @@ import ( "github.com/dymensionxyz/roller/utils/errorhandling" genesisutils "github.com/dymensionxyz/roller/utils/genesis" rollapputils "github.com/dymensionxyz/roller/utils/rollapp" + "github.com/pterm/pterm" + "github.com/spf13/cobra" + "gopkg.in/yaml.v3" ) // TODO: Test relaying on 35-C and update the prices @@ -215,6 +215,14 @@ func Cmd() *cobra.Command { return } + fmt.Println( + "updating: ", strings.Join( + []string{ + "chains", rollappConfig.HubData.ID, "value", + "is-dym-hub", + }, ".", + ), + ) err = yamlconfig.UpdateNestedYAML( contentNode, []string{"chains", rollappConfig.HubData.ID, "value", "is-dym-hub"}, From b6f80ee67ef54e8f30f45f515458318fac79124c Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:00:32 +0400 Subject: [PATCH 03/27] chore: debug --- utils/config/yamlconfig/yaml.go | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/config/yamlconfig/yaml.go b/utils/config/yamlconfig/yaml.go index 01a4c861..0a24ffb9 100644 --- a/utils/config/yamlconfig/yaml.go +++ b/utils/config/yamlconfig/yaml.go @@ -31,6 +31,7 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { } // If the path doesn't exist, create it + fmt.Println("kind:", node.Kind) // Create a new key node newKeyNode := &yaml.Node{ Kind: yaml.ScalarNode, From 81631093f831e45af2d63835158c04d3afeb0b8c Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:02:40 +0400 Subject: [PATCH 04/27] chore: debug --- utils/config/yamlconfig/yaml.go | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/config/yamlconfig/yaml.go b/utils/config/yamlconfig/yaml.go index 0a24ffb9..0dea1f28 100644 --- a/utils/config/yamlconfig/yaml.go +++ b/utils/config/yamlconfig/yaml.go @@ -32,6 +32,7 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { // If the path doesn't exist, create it fmt.Println("kind:", node.Kind) + fmt.Println("content:", node.Content) // Create a new key node newKeyNode := &yaml.Node{ Kind: yaml.ScalarNode, From 96b8b109339743ddb61ad2cb936ec3beb474387f Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:04:00 +0400 Subject: [PATCH 05/27] chore: debug --- utils/config/yamlconfig/yaml.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/config/yamlconfig/yaml.go b/utils/config/yamlconfig/yaml.go index 0dea1f28..67a93d35 100644 --- a/utils/config/yamlconfig/yaml.go +++ b/utils/config/yamlconfig/yaml.go @@ -30,9 +30,8 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { } } + fmt.Println(path) // If the path doesn't exist, create it - fmt.Println("kind:", node.Kind) - fmt.Println("content:", node.Content) // Create a new key node newKeyNode := &yaml.Node{ Kind: yaml.ScalarNode, From 110999822e39486ce61e2b5eca4ac4fd30bac308 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:16:12 +0400 Subject: [PATCH 06/27] chore: debug --- cmd/relayer/run/run.go | 9 --------- utils/config/yamlconfig/yaml.go | 4 +++- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/cmd/relayer/run/run.go b/cmd/relayer/run/run.go index 3ec21933..c15df338 100644 --- a/cmd/relayer/run/run.go +++ b/cmd/relayer/run/run.go @@ -7,7 +7,6 @@ import ( "os" "path/filepath" "strconv" - "strings" comettypes "github.com/cometbft/cometbft/types" initconfig "github.com/dymensionxyz/roller/cmd/config/init" @@ -215,14 +214,6 @@ func Cmd() *cobra.Command { return } - fmt.Println( - "updating: ", strings.Join( - []string{ - "chains", rollappConfig.HubData.ID, "value", - "is-dym-hub", - }, ".", - ), - ) err = yamlconfig.UpdateNestedYAML( contentNode, []string{"chains", rollappConfig.HubData.ID, "value", "is-dym-hub"}, diff --git a/utils/config/yamlconfig/yaml.go b/utils/config/yamlconfig/yaml.go index 67a93d35..fc102d38 100644 --- a/utils/config/yamlconfig/yaml.go +++ b/utils/config/yamlconfig/yaml.go @@ -2,6 +2,7 @@ package yamlconfig import ( "fmt" + "strings" "time" "github.com/ignite/cli/ignite/pkg/cosmosaccount" @@ -9,6 +10,7 @@ import ( ) func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { + fmt.Printf("settings %s to %w", strings.Join(path, "."), value) if node.Kind == yaml.DocumentNode { if len(node.Content) == 0 { return fmt.Errorf("empty document node") @@ -46,7 +48,7 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { // If this is the last element in the path, set the value newValueNode = &yaml.Node{ Kind: yaml.ScalarNode, - Tag: "!!str", // You can adjust the tag based on the type of `value` + Tag: "!!str", } } else { // Otherwise, create a new mapping node for the next level From 135f60e2ef06f290ea6fa252fff6e18ca6fb8b3f Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:17:22 +0400 Subject: [PATCH 07/27] chore: debug --- utils/config/yamlconfig/yaml.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/config/yamlconfig/yaml.go b/utils/config/yamlconfig/yaml.go index fc102d38..c4155b56 100644 --- a/utils/config/yamlconfig/yaml.go +++ b/utils/config/yamlconfig/yaml.go @@ -10,7 +10,7 @@ import ( ) func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { - fmt.Printf("settings %s to %w", strings.Join(path, "."), value) + fmt.Printf("settings %s to %v\n", strings.Join(path, "."), value) if node.Kind == yaml.DocumentNode { if len(node.Content) == 0 { return fmt.Errorf("empty document node") From d62817d12e7b92ae01b5682a36825667d3be291c Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:23:02 +0400 Subject: [PATCH 08/27] chore: debug --- utils/config/yamlconfig/yaml.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/utils/config/yamlconfig/yaml.go b/utils/config/yamlconfig/yaml.go index c4155b56..23f29862 100644 --- a/utils/config/yamlconfig/yaml.go +++ b/utils/config/yamlconfig/yaml.go @@ -10,7 +10,8 @@ import ( ) func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { - fmt.Printf("settings %s to %v\n", strings.Join(path, "."), value) + fmt.Printf("Updating path: %s to value: %v\n", strings.Join(path, "."), value) + if node.Kind == yaml.DocumentNode { if len(node.Content) == 0 { return fmt.Errorf("empty document node") @@ -28,13 +29,13 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { for i := 0; i < len(node.Content); i += 2 { if node.Content[i].Value == path[0] { + fmt.Printf("Found existing key: %s\n", path[0]) return UpdateNestedYAML(node.Content[i+1], path[1:], value) } } - fmt.Println(path) + fmt.Printf("Path not found, creating new key: %s\n", path[0]) // If the path doesn't exist, create it - // Create a new key node newKeyNode := &yaml.Node{ Kind: yaml.ScalarNode, Value: path[0], From 3e4eaf06858903b1180e89e19ad273ef374446bb Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:25:30 +0400 Subject: [PATCH 09/27] chore: debu --- utils/config/yamlconfig/yaml.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/utils/config/yamlconfig/yaml.go b/utils/config/yamlconfig/yaml.go index 23f29862..2435e345 100644 --- a/utils/config/yamlconfig/yaml.go +++ b/utils/config/yamlconfig/yaml.go @@ -12,6 +12,11 @@ import ( func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { fmt.Printf("Updating path: %s to value: %v\n", strings.Join(path, "."), value) + if len(path) == 0 { + // If the path is empty, we should not attempt to update further + return fmt.Errorf("path is empty, cannot update node") + } + if node.Kind == yaml.DocumentNode { if len(node.Content) == 0 { return fmt.Errorf("empty document node") @@ -19,17 +24,17 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { return UpdateNestedYAML(node.Content[0], path, value) } - if len(path) == 0 { - return setNodeValue(node, value) - } - if node.Kind != yaml.MappingNode { return fmt.Errorf("expected a mapping node, got %v", node.Kind) } for i := 0; i < len(node.Content); i += 2 { if node.Content[i].Value == path[0] { - fmt.Printf("Found existing key: %s\n", path[0]) + if len(path) == 1 { + // If this is the last element in the path, set the value + return setNodeValue(node.Content[i+1], value) + } + // Continue to the next level return UpdateNestedYAML(node.Content[i+1], path[1:], value) } } @@ -51,6 +56,7 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { Kind: yaml.ScalarNode, Tag: "!!str", } + setNodeValue(newValueNode, value) } else { // Otherwise, create a new mapping node for the next level newValueNode = &yaml.Node{ From ce875a3cde1d35138d55c065b6a55c91b6dd02ba Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:27:58 +0400 Subject: [PATCH 10/27] chore: debug --- utils/config/yamlconfig/yaml.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/utils/config/yamlconfig/yaml.go b/utils/config/yamlconfig/yaml.go index 2435e345..78da0343 100644 --- a/utils/config/yamlconfig/yaml.go +++ b/utils/config/yamlconfig/yaml.go @@ -12,11 +12,6 @@ import ( func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { fmt.Printf("Updating path: %s to value: %v\n", strings.Join(path, "."), value) - if len(path) == 0 { - // If the path is empty, we should not attempt to update further - return fmt.Errorf("path is empty, cannot update node") - } - if node.Kind == yaml.DocumentNode { if len(node.Content) == 0 { return fmt.Errorf("empty document node") @@ -24,16 +19,17 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { return UpdateNestedYAML(node.Content[0], path, value) } + if len(path) == 0 { + // Set the value of the current node + return setNodeValue(node, value) + } + if node.Kind != yaml.MappingNode { return fmt.Errorf("expected a mapping node, got %v", node.Kind) } for i := 0; i < len(node.Content); i += 2 { if node.Content[i].Value == path[0] { - if len(path) == 1 { - // If this is the last element in the path, set the value - return setNodeValue(node.Content[i+1], value) - } // Continue to the next level return UpdateNestedYAML(node.Content[i+1], path[1:], value) } @@ -53,10 +49,10 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { if len(path) == 1 { // If this is the last element in the path, set the value newValueNode = &yaml.Node{ - Kind: yaml.ScalarNode, - Tag: "!!str", + Kind: yaml.ScalarNode, + Tag: "!!str", + Value: fmt.Sprintf("%v", value), // Set the value directly } - setNodeValue(newValueNode, value) } else { // Otherwise, create a new mapping node for the next level newValueNode = &yaml.Node{ @@ -65,6 +61,10 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { } node.Content = append(node.Content, newValueNode) + if len(path) == 1 { + // If this is the last element, we are done + return nil + } return UpdateNestedYAML(newValueNode, path[1:], value) } From c71b8d4e2372f9f277986aa762d8837ff0f79bfb Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:33:34 +0400 Subject: [PATCH 11/27] chore: debug --- utils/config/yamlconfig/yaml.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/utils/config/yamlconfig/yaml.go b/utils/config/yamlconfig/yaml.go index 78da0343..a383a426 100644 --- a/utils/config/yamlconfig/yaml.go +++ b/utils/config/yamlconfig/yaml.go @@ -11,7 +11,6 @@ import ( func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { fmt.Printf("Updating path: %s to value: %v\n", strings.Join(path, "."), value) - if node.Kind == yaml.DocumentNode { if len(node.Content) == 0 { return fmt.Errorf("empty document node") @@ -20,7 +19,6 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { } if len(path) == 0 { - // Set the value of the current node return setNodeValue(node, value) } @@ -30,13 +28,13 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { for i := 0; i < len(node.Content); i += 2 { if node.Content[i].Value == path[0] { - // Continue to the next level return UpdateNestedYAML(node.Content[i+1], path[1:], value) } } fmt.Printf("Path not found, creating new key: %s\n", path[0]) // If the path doesn't exist, create it + // Create a new key node newKeyNode := &yaml.Node{ Kind: yaml.ScalarNode, Value: path[0], @@ -49,9 +47,8 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { if len(path) == 1 { // If this is the last element in the path, set the value newValueNode = &yaml.Node{ - Kind: yaml.ScalarNode, - Tag: "!!str", - Value: fmt.Sprintf("%v", value), // Set the value directly + Kind: yaml.ScalarNode, + Tag: "!!str", // You can adjust the tag based on the type of `value` } } else { // Otherwise, create a new mapping node for the next level @@ -61,10 +58,6 @@ func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { } node.Content = append(node.Content, newValueNode) - if len(path) == 1 { - // If this is the last element, we are done - return nil - } return UpdateNestedYAML(newValueNode, path[1:], value) } From 3c68c77b69ae18fb01883904d184a7afaabf7e91 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:37:38 +0400 Subject: [PATCH 12/27] chore: debug --- cmd/eibc/eibc.go | 28 +++++- cmd/eibc/fulfill/denoms/denoms.go | 22 +++++ cmd/eibc/fulfill/denoms/list/list.go | 61 ++++++++++++ cmd/eibc/fulfill/denoms/remove/remove.go | 74 +++++++++++++++ cmd/eibc/fulfill/denoms/set/set.go | 102 +++++++++++++++++++++ cmd/eibc/fulfill/fulfill.go | 22 +++++ cmd/eibc/fulfill/order/order.go | 80 ++++++++++++++++ cmd/eibc/fulfill/rollapps/list/list.go | 61 ++++++++++++ cmd/eibc/fulfill/rollapps/remove/remove.go | 72 +++++++++++++++ cmd/eibc/fulfill/rollapps/rollapps.go | 23 +++++ cmd/eibc/fulfill/rollapps/set/set.go | 97 ++++++++++++++++++++ cmd/eibc/funds/funds.go | 32 +++++++ cmd/eibc/{ => init}/init.go | 28 ++---- cmd/eibc/{ => scale}/scale.go | 22 +---- cmd/eibc/{ => start}/start.go | 29 ++---- cmd/relayer/relayer.go | 12 ++- cmd/rollapp/rollapp.go | 11 ++- cmd/services/load/load.go | 60 ++---------- cmd/services/restart/restart.go | 23 +---- cmd/services/services.go | 3 +- cmd/services/start/start.go | 26 +++++- cmd/services/stop/stop.go | 45 +++++++++ go.mod | 26 ++++-- go.sum | 32 ++++++- {cmd/utils => utils/docker}/docker.go | 2 +- cmd/eibc/utils.go => utils/eibc/eibc.go | 66 +++++++++++-- utils/eibc/types.go | 74 +++++++++++++++ utils/service_manager/service.go | 11 +++ 28 files changed, 987 insertions(+), 157 deletions(-) create mode 100644 cmd/eibc/fulfill/denoms/denoms.go create mode 100644 cmd/eibc/fulfill/denoms/list/list.go create mode 100644 cmd/eibc/fulfill/denoms/remove/remove.go create mode 100644 cmd/eibc/fulfill/denoms/set/set.go create mode 100644 cmd/eibc/fulfill/fulfill.go create mode 100644 cmd/eibc/fulfill/order/order.go create mode 100644 cmd/eibc/fulfill/rollapps/list/list.go create mode 100644 cmd/eibc/fulfill/rollapps/remove/remove.go create mode 100644 cmd/eibc/fulfill/rollapps/rollapps.go create mode 100644 cmd/eibc/fulfill/rollapps/set/set.go create mode 100644 cmd/eibc/funds/funds.go rename cmd/eibc/{ => init}/init.go (92%) rename cmd/eibc/{ => scale}/scale.go (69%) rename cmd/eibc/{ => start}/start.go (67%) create mode 100644 cmd/services/stop/stop.go rename {cmd/utils => utils/docker}/docker.go (99%) rename cmd/eibc/utils.go => utils/eibc/eibc.go (55%) create mode 100644 utils/eibc/types.go diff --git a/cmd/eibc/eibc.go b/cmd/eibc/eibc.go index b68287f2..8793c652 100644 --- a/cmd/eibc/eibc.go +++ b/cmd/eibc/eibc.go @@ -1,6 +1,16 @@ package eibc import ( + "github.com/dymensionxyz/roller/cmd/eibc/fulfill" + "github.com/dymensionxyz/roller/cmd/eibc/funds" + eibcinit "github.com/dymensionxyz/roller/cmd/eibc/init" + "github.com/dymensionxyz/roller/cmd/eibc/scale" + "github.com/dymensionxyz/roller/cmd/eibc/start" + "github.com/dymensionxyz/roller/cmd/services" + loadservices "github.com/dymensionxyz/roller/cmd/services/load" + restartservices "github.com/dymensionxyz/roller/cmd/services/restart" + startservices "github.com/dymensionxyz/roller/cmd/services/start" + stopservices "github.com/dymensionxyz/roller/cmd/services/stop" "github.com/spf13/cobra" ) @@ -10,9 +20,21 @@ func Cmd() *cobra.Command { Short: "Commands for running and managing eibc client", } - cmd.AddCommand(initCmd()) - cmd.AddCommand(startCmd()) - cmd.AddCommand(scaleCmd()) + cmd.AddCommand(eibcinit.Cmd()) + cmd.AddCommand(start.Cmd()) + cmd.AddCommand(scale.Cmd()) + cmd.AddCommand(funds.Cmd()) + cmd.AddCommand(fulfill.Cmd()) + + sl := []string{"eibc"} + cmd.AddCommand( + services.Cmd( + loadservices.Cmd(sl, cmd.Use), + startservices.EibcCmd(), + restartservices.Cmd(sl), + stopservices.Cmd(sl), + ), + ) return cmd } diff --git a/cmd/eibc/fulfill/denoms/denoms.go b/cmd/eibc/fulfill/denoms/denoms.go new file mode 100644 index 00000000..cb58a05f --- /dev/null +++ b/cmd/eibc/fulfill/denoms/denoms.go @@ -0,0 +1,22 @@ +package denoms + +import ( + "github.com/dymensionxyz/roller/cmd/eibc/fulfill/denoms/list" + "github.com/dymensionxyz/roller/cmd/eibc/fulfill/denoms/remove" + "github.com/dymensionxyz/roller/cmd/eibc/fulfill/denoms/set" + "github.com/spf13/cobra" +) + +func Cmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "denoms", + Short: "Commands to manage the whitelist of Denoms to fulfill eibc orders for", + Args: cobra.MaximumNArgs(1), + } + + cmd.AddCommand(list.Cmd()) + cmd.AddCommand(remove.Cmd()) + cmd.AddCommand(set.Cmd()) + + return cmd +} diff --git a/cmd/eibc/fulfill/denoms/list/list.go b/cmd/eibc/fulfill/denoms/list/list.go new file mode 100644 index 00000000..2feb8176 --- /dev/null +++ b/cmd/eibc/fulfill/denoms/list/list.go @@ -0,0 +1,61 @@ +package list + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/dymensionxyz/roller/cmd/consts" + globalutils "github.com/dymensionxyz/roller/utils" + eibcutils "github.com/dymensionxyz/roller/utils/eibc" + "github.com/pterm/pterm" + "github.com/spf13/cobra" + "gopkg.in/yaml.v3" +) + +func Cmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "list", + Short: "Commands to manage the whitelist of RollApps to fulfill eibc orders for", + Run: func(cmd *cobra.Command, args []string) { + home, err := os.UserHomeDir() + if err != nil { + pterm.Error.Println("failed to get user home dir", err) + return + } + + eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc) + isEibcClientInitialized, err := globalutils.DirNotEmpty(eibcHome) + if err != nil { + pterm.Error.Println("failed to check eibc client initialized", err) + return + } + + if !isEibcClientInitialized { + pterm.Error.Println("eibc client not initialized") + return + } + + eibcConfigPath := filepath.Join(eibcHome, "config.yaml") + data, err := os.ReadFile(eibcConfigPath) + if err != nil { + pterm.Error.Printf("Error reading file: %v\n", err) + return + } + + // Parse the YAML + var config eibcutils.Config + err = yaml.Unmarshal(data, &config) + if err != nil { + pterm.Error.Printf("Error reading file: %v\n", err) + return + } + + for asset, percentage := range config.FulfillCriteria.MinFeePercentage.Asset { + fmt.Printf("%s: %.6f\n", asset, percentage) + } + }, + } + + return cmd +} diff --git a/cmd/eibc/fulfill/denoms/remove/remove.go b/cmd/eibc/fulfill/denoms/remove/remove.go new file mode 100644 index 00000000..17cdd225 --- /dev/null +++ b/cmd/eibc/fulfill/denoms/remove/remove.go @@ -0,0 +1,74 @@ +package remove + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/dymensionxyz/roller/cmd/consts" + globalutils "github.com/dymensionxyz/roller/utils" + "github.com/dymensionxyz/roller/utils/eibc" + "github.com/pterm/pterm" + "github.com/spf13/cobra" + "gopkg.in/yaml.v3" +) + +func Cmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "remove", + Short: "Commands to manage the whitelist of RollApps to fulfill eibc orders for", + Args: cobra.MaximumNArgs(1), + Run: func(cmd *cobra.Command, args []string) { + home, err := os.UserHomeDir() + if err != nil { + pterm.Error.Println("failed to get user home dir", err) + return + } + + eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc) + isEibcClientInitialized, err := globalutils.DirNotEmpty(eibcHome) + if err != nil { + pterm.Error.Println("failed to check eibc client initialized", err) + return + } + + if !isEibcClientInitialized { + pterm.Error.Println("eibc client not initialized") + return + } + + eibcConfigPath := filepath.Join(eibcHome, "config.yaml") + data, err := os.ReadFile(eibcConfigPath) + if err != nil { + pterm.Error.Printf("Error reading file: %v\n", err) + return + } + + // Parse the YAML + var config eibc.Config + + asset := args[0] + err = yaml.Unmarshal(data, &config) + if err != nil { + pterm.Error.Printf("Error reading file: %v\n", err) + return + } + + config.RemoveChain(asset) + updatedData, err := yaml.Marshal(&config) + fmt.Println(string(updatedData)) + if err != nil { + pterm.Error.Printf("Error reading file: %v\n", err) + return + } + + err = os.WriteFile(eibcConfigPath, updatedData, 0o644) + if err != nil { + pterm.Error.Printf("Error reading file: %v\n", err) + return + } + }, + } + + return cmd +} diff --git a/cmd/eibc/fulfill/denoms/set/set.go b/cmd/eibc/fulfill/denoms/set/set.go new file mode 100644 index 00000000..cbc48fea --- /dev/null +++ b/cmd/eibc/fulfill/denoms/set/set.go @@ -0,0 +1,102 @@ +package set + +import ( + "fmt" + "os" + "path/filepath" + "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" +) + +func Cmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "set ", + Short: "Commands to manage the whitelist of RollApps to fulfill eibc orders for", + Args: cobra.ExactArgs(2), + Run: func(cmd *cobra.Command, args []string) { + home, err := os.UserHomeDir() + if err != nil { + pterm.Error.Println("failed to get user home dir", err) + return + } + + eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc) + isEibcClientInitialized, err := globalutils.DirNotEmpty(eibcHome) + if err != nil { + pterm.Error.Println("failed to check eibc client initialized", err) + return + } + + if !isEibcClientInitialized { + pterm.Error.Println("eibc client not initialized") + return + } + + eibcConfigPath := filepath.Join(eibcHome, "config.yaml") + data, err := os.ReadFile(eibcConfigPath) + if err != nil { + pterm.Error.Printf("Error reading file: %v\n", err) + return + } + + // Parse the YAML + var node yaml.Node + ibcDenom := args[0] + value := args[1] + + if !strings.HasPrefix(ibcDenom, "ibc/") { + pterm.Error.Println("invalid ibc denom") + return + } + + valueFloat, err := strconv.ParseFloat(value, 32) + if err != nil { + pterm.Error.Println("failed to convert value to float", err) + return + } + 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] + } + + err = yamlconfig.UpdateNestedYAML( + contentNode, + []string{"fulfill_criteria", "min_fee_percentage", "asset", ibcDenom}, + valueFloat, + ) + if err != nil { + fmt.Printf("Error updating YAML: %v\n", err) + return + } + + updatedData, err := yaml.Marshal(&node) + if err != nil { + fmt.Printf("Error marshaling YAML: %v\n", err) + return + } + + // Write the updated YAML back to the original file + err = os.WriteFile(eibcConfigPath, updatedData, 0o644) + if err != nil { + fmt.Printf("Error writing file: %v\n", err) + return + } + }, + } + + return cmd +} diff --git a/cmd/eibc/fulfill/fulfill.go b/cmd/eibc/fulfill/fulfill.go new file mode 100644 index 00000000..a7d4e471 --- /dev/null +++ b/cmd/eibc/fulfill/fulfill.go @@ -0,0 +1,22 @@ +package fulfill + +import ( + "github.com/spf13/cobra" + + "github.com/dymensionxyz/roller/cmd/eibc/fulfill/denoms" + "github.com/dymensionxyz/roller/cmd/eibc/fulfill/order" + "github.com/dymensionxyz/roller/cmd/eibc/fulfill/rollapps" +) + +func Cmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "fulfill", + Short: "Commands related to fulfillment of eibc orders", + } + + cmd.AddCommand(order.Cmd()) + cmd.AddCommand(rollapps.Cmd()) + cmd.AddCommand(denoms.Cmd()) + + return cmd +} diff --git a/cmd/eibc/fulfill/order/order.go b/cmd/eibc/fulfill/order/order.go new file mode 100644 index 00000000..e09b1515 --- /dev/null +++ b/cmd/eibc/fulfill/order/order.go @@ -0,0 +1,80 @@ +package order + +import ( + "fmt" + + "github.com/pterm/pterm" + "github.com/spf13/cobra" + + initconfig "github.com/dymensionxyz/roller/cmd/config/init" + "github.com/dymensionxyz/roller/cmd/utils" + globalutils "github.com/dymensionxyz/roller/utils" + "github.com/dymensionxyz/roller/utils/bash" + "github.com/dymensionxyz/roller/utils/config/tomlconfig" + "github.com/dymensionxyz/roller/utils/eibc" + "github.com/dymensionxyz/roller/utils/tx" +) + +func Cmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "order", + Short: "Commands related to fulfillment of eibc orders", + Args: cobra.MaximumNArgs(1), + Run: func(cmd *cobra.Command, args []string) { + err := initconfig.AddFlags(cmd) + if err != nil { + pterm.Error.Println("failed to add flags") + return + } + + home, err := globalutils.ExpandHomePath(cmd.Flag(utils.FlagNames.Home).Value.String()) + if err != nil { + pterm.Error.Println("failed to expand home directory") + return + } + + rollerCfg, err := tomlconfig.LoadRollerConfig(home) + if err != nil { + return + } + + var orderId string + if len(args) != 0 { + orderId = args[0] + } else { + orderId, _ = pterm.DefaultInteractiveTextInput.WithDefaultText( + "provide an order id that you want to fulfill", + ).Show() + } + + fmt.Println("orders related to fulfillment of eibc orders") + gCmd, err := eibc.GetFulfillOrderCmd( + orderId, + rollerCfg.HubData, + ) + if err != nil { + pterm.Error.Println("failed to fulfill order: ", err) + return + } + + txOutput, err := bash.ExecCommandWithInput(gCmd, "signatures") + if err != nil { + pterm.Error.Println("failed to update sequencer metadata", err) + return + } + + txHash, err := bash.ExtractTxHash(txOutput) + if err != nil { + return + } + + err = tx.MonitorTransaction(rollerCfg.HubData.RPC_URL, txHash) + if err != nil { + pterm.Error.Println("transaction failed", err) + return + } + }, + } + + return cmd +} diff --git a/cmd/eibc/fulfill/rollapps/list/list.go b/cmd/eibc/fulfill/rollapps/list/list.go new file mode 100644 index 00000000..e1a71561 --- /dev/null +++ b/cmd/eibc/fulfill/rollapps/list/list.go @@ -0,0 +1,61 @@ +package list + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/dymensionxyz/roller/cmd/consts" + globalutils "github.com/dymensionxyz/roller/utils" + eibcutils "github.com/dymensionxyz/roller/utils/eibc" + "github.com/pterm/pterm" + "github.com/spf13/cobra" + "gopkg.in/yaml.v3" +) + +func Cmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "list", + Short: "Commands to manage the whitelist of RollApps to fulfill eibc orders for", + Run: func(cmd *cobra.Command, args []string) { + home, err := os.UserHomeDir() + if err != nil { + pterm.Error.Println("failed to get user home dir", err) + return + } + + eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc) + isEibcClientInitialized, err := globalutils.DirNotEmpty(eibcHome) + if err != nil { + pterm.Error.Println("failed to check eibc client initialized", err) + return + } + + if !isEibcClientInitialized { + pterm.Error.Println("eibc client not initialized") + return + } + + eibcConfigPath := filepath.Join(eibcHome, "config.yaml") + data, err := os.ReadFile(eibcConfigPath) + if err != nil { + pterm.Error.Printf("Error reading file: %v\n", err) + return + } + + // Parse the YAML + var config eibcutils.Config + err = yaml.Unmarshal(data, &config) + if err != nil { + pterm.Error.Printf("Error reading file: %v\n", err) + return + } + + for chain, percentage := range config.FulfillCriteria.MinFeePercentage.Chain { + fmt.Printf("%s: %.6f\n", chain, percentage) + } + }, + } + + return cmd +} diff --git a/cmd/eibc/fulfill/rollapps/remove/remove.go b/cmd/eibc/fulfill/rollapps/remove/remove.go new file mode 100644 index 00000000..a7972a33 --- /dev/null +++ b/cmd/eibc/fulfill/rollapps/remove/remove.go @@ -0,0 +1,72 @@ +package remove + +import ( + "os" + "path/filepath" + + "github.com/dymensionxyz/roller/cmd/consts" + globalutils "github.com/dymensionxyz/roller/utils" + "github.com/dymensionxyz/roller/utils/eibc" + "github.com/pterm/pterm" + "github.com/spf13/cobra" + "gopkg.in/yaml.v3" +) + +func Cmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "remove", + Short: "Commands to manage the whitelist of RollApps to fulfill eibc orders for", + Args: cobra.MaximumNArgs(1), + Run: func(cmd *cobra.Command, args []string) { + home, err := os.UserHomeDir() + if err != nil { + pterm.Error.Println("failed to get user home dir", err) + return + } + + eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc) + isEibcClientInitialized, err := globalutils.DirNotEmpty(eibcHome) + if err != nil { + pterm.Error.Println("failed to check eibc client initialized", err) + return + } + + if !isEibcClientInitialized { + pterm.Error.Println("eibc client not initialized") + return + } + + eibcConfigPath := filepath.Join(eibcHome, "config.yaml") + data, err := os.ReadFile(eibcConfigPath) + if err != nil { + pterm.Error.Printf("Error reading file: %v\n", err) + return + } + + // Parse the YAML + var config eibc.Config + + rollAppID := args[0] + err = yaml.Unmarshal(data, &config) + if err != nil { + pterm.Error.Printf("Error reading file: %v\n", err) + return + } + + config.RemoveChain(rollAppID) + updatedData, err := yaml.Marshal(&config) + if err != nil { + pterm.Error.Printf("Error reading file: %v\n", err) + return + } + + err = os.WriteFile(eibcConfigPath, updatedData, 0o644) + if err != nil { + pterm.Error.Printf("Error reading file: %v\n", err) + return + } + }, + } + + return cmd +} diff --git a/cmd/eibc/fulfill/rollapps/rollapps.go b/cmd/eibc/fulfill/rollapps/rollapps.go new file mode 100644 index 00000000..6f98ebff --- /dev/null +++ b/cmd/eibc/fulfill/rollapps/rollapps.go @@ -0,0 +1,23 @@ +package rollapps + +import ( + "github.com/spf13/cobra" + + "github.com/dymensionxyz/roller/cmd/eibc/fulfill/rollapps/list" + "github.com/dymensionxyz/roller/cmd/eibc/fulfill/rollapps/remove" + "github.com/dymensionxyz/roller/cmd/eibc/fulfill/rollapps/set" +) + +func Cmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "rollapps", + Short: "Commands to manage the whitelist of RollApps to fulfill eibc orders for", + Args: cobra.MaximumNArgs(1), + } + + cmd.AddCommand(set.Cmd()) + cmd.AddCommand(list.Cmd()) + cmd.AddCommand(remove.Cmd()) + + return cmd +} diff --git a/cmd/eibc/fulfill/rollapps/set/set.go b/cmd/eibc/fulfill/rollapps/set/set.go new file mode 100644 index 00000000..1a8c1b2a --- /dev/null +++ b/cmd/eibc/fulfill/rollapps/set/set.go @@ -0,0 +1,97 @@ +package set + +import ( + "fmt" + "os" + "path/filepath" + "strconv" + + "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 { + cmd := &cobra.Command{ + Use: "set ", + Short: "Commands to manage the whitelist of RollApps to fulfill eibc orders for", + Args: cobra.ExactArgs(2), + Run: func(cmd *cobra.Command, args []string) { + home, err := os.UserHomeDir() + if err != nil { + pterm.Error.Println("failed to get user home dir", err) + return + } + + eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc) + isEibcClientInitialized, err := globalutils.DirNotEmpty(eibcHome) + if err != nil { + pterm.Error.Println("failed to check eibc client initialized", err) + return + } + + if !isEibcClientInitialized { + pterm.Error.Println("eibc client not initialized") + return + } + + eibcConfigPath := filepath.Join(eibcHome, "config.yaml") + data, err := os.ReadFile(eibcConfigPath) + if err != nil { + pterm.Error.Printf("Error reading file: %v\n", err) + return + } + + // Parse the YAML + var node yaml.Node + rollAppID := args[0] + value := args[1] + + valueFloat, err := strconv.ParseFloat(value, 32) + if err != nil { + pterm.Error.Println("failed to convert value to float", err) + return + } + 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] + } + + err = yamlconfig.UpdateNestedYAML( + contentNode, + []string{"fulfill_criteria", "min_fee_percentage", "chain", rollAppID}, + valueFloat, + ) + if err != nil { + fmt.Printf("Error updating YAML: %v\n", err) + return + } + + updatedData, err := yaml.Marshal(&node) + if err != nil { + fmt.Printf("Error marshaling YAML: %v\n", err) + return + } + + // Write the updated YAML back to the original file + err = os.WriteFile(eibcConfigPath, updatedData, 0o644) + if err != nil { + fmt.Printf("Error writing file: %v\n", err) + return + } + }, + } + + return cmd +} diff --git a/cmd/eibc/funds/funds.go b/cmd/eibc/funds/funds.go new file mode 100644 index 00000000..bf2401ab --- /dev/null +++ b/cmd/eibc/funds/funds.go @@ -0,0 +1,32 @@ +package funds + +import ( + "fmt" + + "github.com/dymensionxyz/roller/utils/bash" + eibcutils "github.com/dymensionxyz/roller/utils/eibc" + "github.com/pterm/pterm" + "github.com/spf13/cobra" +) + +func Cmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "funds", + Short: "Get an overview of available and pending fund status", + Run: func(cmd *cobra.Command, args []string) { + spin, _ := pterm.DefaultSpinner.Start("Fetching funds...") + c := eibcutils.GetFundsCmd() + out, err := bash.ExecCommandWithStdout(c) + if err != nil { + spin.Fail("failed to retrieve funds") + pterm.Error.Println(err) + return + } + spin.Success("Funds retrieved successfully") + + pterm.Info.Println("current eibc wallet fund distribution:") + fmt.Println(out.String()) + }, + } + return cmd +} diff --git a/cmd/eibc/init.go b/cmd/eibc/init/init.go similarity index 92% rename from cmd/eibc/init.go rename to cmd/eibc/init/init.go index d0df4ac1..b68f7022 100644 --- a/cmd/eibc/init.go +++ b/cmd/eibc/init/init.go @@ -1,15 +1,10 @@ -package eibc +package init import ( "fmt" "os" - "os/exec" "path/filepath" - "github.com/pterm/pterm" - "github.com/spf13/cobra" - yaml "gopkg.in/yaml.v3" - initconfig "github.com/dymensionxyz/roller/cmd/config/init" "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/cmd/utils" @@ -17,10 +12,14 @@ import ( "github.com/dymensionxyz/roller/utils/bash" "github.com/dymensionxyz/roller/utils/config/tomlconfig" "github.com/dymensionxyz/roller/utils/config/yamlconfig" + eibcutils "github.com/dymensionxyz/roller/utils/eibc" "github.com/dymensionxyz/roller/utils/errorhandling" + "github.com/pterm/pterm" + "github.com/spf13/cobra" + "gopkg.in/yaml.v3" ) -func initCmd() *cobra.Command { +func Cmd() *cobra.Command { cmd := &cobra.Command{ Use: "init", Short: "Initialize eibc client", @@ -84,14 +83,14 @@ func initCmd() *cobra.Command { } } - c := GetInitCommand() + c := eibcutils.GetInitCmd() err = bash.ExecCmd(c) if err != nil { pterm.Error.Println("failed to initialize eibc client", err) return } - err = ensureWhaleAccount() + err = eibcutils.EnsureWhaleAccount() if err != nil { pterm.Error.Printf("failed to create whale account: %v\n", err) return @@ -154,7 +153,8 @@ func initCmd() *cobra.Command { } pterm.Info.Println("eibc config updated successfully") - pterm.Info.Printf("eibc client initialized successfully at %s\n", + pterm.Info.Printf( + "eibc client initialized successfully at %s\n", pterm.DefaultBasicText.WithStyle(pterm.FgYellow.ToStyle()). Sprintf(eibcHome), ) @@ -168,11 +168,3 @@ func initCmd() *cobra.Command { } return cmd } - -func GetInitCommand() *exec.Cmd { - cmd := exec.Command( - consts.Executables.Eibc, - "init", - ) - return cmd -} diff --git a/cmd/eibc/scale.go b/cmd/eibc/scale/scale.go similarity index 69% rename from cmd/eibc/scale.go rename to cmd/eibc/scale/scale.go index c494e3b8..f4e8276c 100644 --- a/cmd/eibc/scale.go +++ b/cmd/eibc/scale/scale.go @@ -1,15 +1,12 @@ -package eibc +package scale import ( - "os/exec" - - "github.com/spf13/cobra" - - "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/utils/bash" + eibcutils "github.com/dymensionxyz/roller/utils/eibc" + "github.com/spf13/cobra" ) -func scaleCmd() *cobra.Command { +func Cmd() *cobra.Command { cmd := &cobra.Command{ Use: "scale [count]", Short: "Scale the number of fulfiller addresses to [count]", @@ -23,7 +20,7 @@ a good number to start with is 30 (default when initializing the eibc client) Run: func(cmd *cobra.Command, args []string) { count := args[0] - c := GetScaleCmd(count) + c := eibcutils.GetScaleCmd(count) err := bash.ExecCmdFollow(c) if err != nil { @@ -33,12 +30,3 @@ a good number to start with is 30 (default when initializing the eibc client) } return cmd } - -func GetScaleCmd(count string) *exec.Cmd { - cmd := exec.Command( - consts.Executables.Eibc, - "scale", - count, - ) - return cmd -} diff --git a/cmd/eibc/start.go b/cmd/eibc/start/start.go similarity index 67% rename from cmd/eibc/start.go rename to cmd/eibc/start/start.go index a1120ffb..7c6f3f31 100644 --- a/cmd/eibc/start.go +++ b/cmd/eibc/start/start.go @@ -1,53 +1,52 @@ -package eibc +package start import ( "fmt" "log" "os" - "os/exec" "path/filepath" - "github.com/spf13/cobra" - "github.com/dymensionxyz/roller/cmd/consts" - global_utils "github.com/dymensionxyz/roller/utils" + globalutils "github.com/dymensionxyz/roller/utils" "github.com/dymensionxyz/roller/utils/bash" + eibcutils "github.com/dymensionxyz/roller/utils/eibc" + "github.com/spf13/cobra" ) -func startCmd() *cobra.Command { +func Cmd() *cobra.Command { cmd := &cobra.Command{ Use: "start", Short: "Start the eibc client", Run: func(cmd *cobra.Command, args []string) { home, _ := os.UserHomeDir() eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc) - ok, err := global_utils.DirNotEmpty(eibcHome) + ok, err := globalutils.DirNotEmpty(eibcHome) if err != nil { return } if !ok { fmt.Println("eibc home directory not present, running init") - c := GetInitCommand() + c := eibcutils.GetInitCmd() _, err := bash.ExecCommandWithStdout(c) if err != nil { return } - err = ensureWhaleAccount() + err = eibcutils.EnsureWhaleAccount() if err != nil { log.Printf("failed to create whale account: %v\n", err) return } } - err = createMongoDbContainer() + err = eibcutils.CreateMongoDbContainer() if err != nil { return } - c := GetStartCmd() + c := eibcutils.GetStartCmd() err = bash.ExecCmdFollow(c) if err != nil { return @@ -56,11 +55,3 @@ func startCmd() *cobra.Command { } return cmd } - -func GetStartCmd() *exec.Cmd { - cmd := exec.Command( - consts.Executables.Eibc, - "start", - ) - return cmd -} diff --git a/cmd/relayer/relayer.go b/cmd/relayer/relayer.go index d1332c3c..df6d49f1 100644 --- a/cmd/relayer/relayer.go +++ b/cmd/relayer/relayer.go @@ -1,8 +1,6 @@ package relayer import ( - "github.com/spf13/cobra" - "github.com/dymensionxyz/roller/cmd/relayer/run" "github.com/dymensionxyz/roller/cmd/relayer/start" "github.com/dymensionxyz/roller/cmd/relayer/status" @@ -10,6 +8,8 @@ import ( loadservices "github.com/dymensionxyz/roller/cmd/services/load" restartservices "github.com/dymensionxyz/roller/cmd/services/restart" startservices "github.com/dymensionxyz/roller/cmd/services/start" + stopservices "github.com/dymensionxyz/roller/cmd/services/stop" + "github.com/spf13/cobra" ) func Cmd() *cobra.Command { @@ -17,14 +17,18 @@ func Cmd() *cobra.Command { Use: "relayer", Short: "Commands for running and managing the RollApp relayer.", } + cmd.AddCommand(run.Cmd()) cmd.AddCommand(start.Cmd()) cmd.AddCommand(status.Cmd()) + + sl := []string{"relayer"} cmd.AddCommand( services.Cmd( - loadservices.RelayerCmd(), + loadservices.Cmd(sl, cmd.Use), startservices.RelayerCmd(), - restartservices.RelayerCmd(), + restartservices.Cmd(sl), + stopservices.Cmd(sl), ), ) diff --git a/cmd/rollapp/rollapp.go b/cmd/rollapp/rollapp.go index 87d082b2..bc1ae5c3 100644 --- a/cmd/rollapp/rollapp.go +++ b/cmd/rollapp/rollapp.go @@ -1,8 +1,6 @@ package rollapp import ( - "github.com/spf13/cobra" - "github.com/dymensionxyz/roller/cmd/rollapp/config" initrollapp "github.com/dymensionxyz/roller/cmd/rollapp/init" "github.com/dymensionxyz/roller/cmd/rollapp/run" @@ -13,6 +11,8 @@ import ( loadservices "github.com/dymensionxyz/roller/cmd/services/load" restartservices "github.com/dymensionxyz/roller/cmd/services/restart" startservices "github.com/dymensionxyz/roller/cmd/services/start" + stopservices "github.com/dymensionxyz/roller/cmd/services/stop" + "github.com/spf13/cobra" ) func Cmd() *cobra.Command { @@ -27,11 +27,14 @@ func Cmd() *cobra.Command { cmd.AddCommand(config.Cmd()) cmd.AddCommand(run.Cmd()) cmd.AddCommand(sequencer.Cmd()) + + sl := []string{"rollapp", "da-light-client"} cmd.AddCommand( services.Cmd( - loadservices.RollappCmd(), + loadservices.Cmd(sl, cmd.Use), startservices.RollappCmd(), - restartservices.RollappCmd(), + restartservices.Cmd(sl), + stopservices.Cmd(sl), ), ) diff --git a/cmd/services/load/load.go b/cmd/services/load/load.go index 45d20f04..a8eea18c 100644 --- a/cmd/services/load/load.go +++ b/cmd/services/load/load.go @@ -10,12 +10,11 @@ import ( "strings" "text/template" - "github.com/pterm/pterm" - "github.com/spf13/cobra" - "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/utils/bash" "github.com/dymensionxyz/roller/utils/errorhandling" + "github.com/pterm/pterm" + "github.com/spf13/cobra" ) type Service struct { @@ -29,7 +28,7 @@ type ServiceTemplateData struct { UserName string } -func RollappCmd() *cobra.Command { +func Cmd(services []string, module string) *cobra.Command { cmd := &cobra.Command{ Use: "load", Short: "Loads the different RollApp services on the local machine", @@ -43,53 +42,7 @@ func RollappCmd() *cobra.Command { return } - services := []string{"rollapp", "da-light-client"} - for _, service := range services { - serviceData := ServiceTemplateData{ - Name: service, - ExecPath: consts.Executables.Roller, - UserName: os.Getenv("USER"), - } - tpl, err := generateServiceTemplate(serviceData) - errorhandling.PrettifyErrorIfExists(err) - err = writeServiceFile(tpl, service) - errorhandling.PrettifyErrorIfExists(err) - } - _, err := bash.ExecCommandWithStdout( - exec.Command("sudo", "systemctl", "daemon-reload"), - ) - errorhandling.PrettifyErrorIfExists(err) - pterm.Success.Printf( - "💈 Services %s been loaded successfully.\n", - strings.Join(services, ", "), - ) - pterm.Info.Println("next steps:") - pterm.Info.Printf( - "run %s to start rollapp and da-light-client on your local machine\n", - pterm.DefaultBasicText.WithStyle(pterm.FgYellow.ToStyle()). - Sprintf("roller rollapp services start"), - ) - }, - } - return cmd -} - -func RelayerCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "load", - Short: "Loads the different RollApp services on the local machine", - Run: func(cmd *cobra.Command, args []string) { - if runtime.GOOS != "linux" { - pterm.Error.Printf( - "the %s commands are only available on linux machines\n", - pterm.DefaultBasicText.WithStyle(pterm.FgYellow.ToStyle()). - Sprintf("'services'"), - ) - - return - } - services := []string{"relayer"} for _, service := range services { serviceData := ServiceTemplateData{ Name: service, @@ -101,10 +54,12 @@ func RelayerCmd() *cobra.Command { err = writeServiceFile(tpl, service) errorhandling.PrettifyErrorIfExists(err) } + _, err := bash.ExecCommandWithStdout( exec.Command("sudo", "systemctl", "daemon-reload"), ) errorhandling.PrettifyErrorIfExists(err) + pterm.Success.Printf( "💈 Services %s been loaded successfully.\n", strings.Join(services, ", "), @@ -112,9 +67,10 @@ func RelayerCmd() *cobra.Command { pterm.Info.Println("next steps:") pterm.Info.Printf( - "run %s to start rollapp and da-light-client on your local machine\n", + "run %s to start %s on your local machine\n", pterm.DefaultBasicText.WithStyle(pterm.FgYellow.ToStyle()). - Sprintf("roller rollapp services start"), + Sprintf("roller %s services start", module), + strings.Join(services, ", "), ) }, } diff --git a/cmd/services/restart/restart.go b/cmd/services/restart/restart.go index d34976be..fe8f8a6c 100644 --- a/cmd/services/restart/restart.go +++ b/cmd/services/restart/restart.go @@ -11,28 +11,11 @@ import ( servicemanager "github.com/dymensionxyz/roller/utils/service_manager" ) -func RollappCmd() *cobra.Command { +func Cmd(services []string) *cobra.Command { cmd := &cobra.Command{ Use: "restart", Short: "Restarts the systemd services relevant to RollApp", Run: func(cmd *cobra.Command, args []string) { - services := []string{"rollapp", "da-light-client"} - err := restartSystemdServices(services) - if err != nil { - pterm.Error.Println("failed to restart systemd services:", err) - return - } - }, - } - return cmd -} - -func RelayerCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "restart", - Short: "Restarts the systemd services relevant to the relayer", - Run: func(cmd *cobra.Command, args []string) { - services := []string{"relayer"} err := restartSystemdServices(services) if err != nil { pterm.Error.Println("failed to restart systemd services:", err) @@ -52,11 +35,11 @@ func restartSystemdServices(services []string) error { for _, service := range services { err := servicemanager.RestartSystemdService(fmt.Sprintf("%s.service", service)) if err != nil { - return fmt.Errorf("failed to start %s systemd service: %v", service, err) + return fmt.Errorf("failed to restart %s systemd service: %v", service, err) } } pterm.Success.Printf( - "💈 Services %s started successfully.\n", + "💈 Services %s restarted successfully.\n", strings.Join(services, ", "), ) return nil diff --git a/cmd/services/services.go b/cmd/services/services.go index b4614c7a..66ce863b 100644 --- a/cmd/services/services.go +++ b/cmd/services/services.go @@ -2,7 +2,7 @@ package services import "github.com/spf13/cobra" -func Cmd(loadCmd, startCmd, restartCmd *cobra.Command) *cobra.Command { +func Cmd(loadCmd, startCmd, restartCmd, stopCmd *cobra.Command) *cobra.Command { cmd := &cobra.Command{ Use: "services [command]", Short: "Commands for managing systemd services.", @@ -10,5 +10,6 @@ func Cmd(loadCmd, startCmd, restartCmd *cobra.Command) *cobra.Command { cmd.AddCommand(loadCmd) cmd.AddCommand(startCmd) cmd.AddCommand(restartCmd) + cmd.AddCommand(stopCmd) return cmd } diff --git a/cmd/services/start/start.go b/cmd/services/start/start.go index 089191bd..864fc159 100644 --- a/cmd/services/start/start.go +++ b/cmd/services/start/start.go @@ -5,16 +5,15 @@ import ( "runtime" "strings" + servicemanager "github.com/dymensionxyz/roller/utils/service_manager" "github.com/pterm/pterm" "github.com/spf13/cobra" - - servicemanager "github.com/dymensionxyz/roller/utils/service_manager" ) func RollappCmd() *cobra.Command { cmd := &cobra.Command{ Use: "start", - Short: "Loads the different RollApp services on the local machine", + Short: "Start the systemd services on local machine", Run: func(cmd *cobra.Command, args []string) { services := []string{"rollapp", "da-light-client"} err := startSystemdServices(services) @@ -57,6 +56,27 @@ func RelayerCmd() *cobra.Command { return cmd } +func EibcCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "start", + Short: "Start the systemd services on local machine", + Run: func(cmd *cobra.Command, args []string) { + services := []string{"eibc"} + err := startSystemdServices(services) + if err != nil { + pterm.Error.Println("failed to start systemd services:", err) + return + } + + pterm.Info.Println("next steps:") + pterm.Info.Printf( + "that's all folks", + ) + }, + } + return cmd +} + func startSystemdServices(services []string) error { if runtime.GOOS != "linux" { return fmt.Errorf( diff --git a/cmd/services/stop/stop.go b/cmd/services/stop/stop.go new file mode 100644 index 00000000..f4b3d0be --- /dev/null +++ b/cmd/services/stop/stop.go @@ -0,0 +1,45 @@ +package stop + +import ( + "fmt" + "runtime" + "strings" + + servicemanager "github.com/dymensionxyz/roller/utils/service_manager" + "github.com/pterm/pterm" + "github.com/spf13/cobra" +) + +func Cmd(services []string) *cobra.Command { + cmd := &cobra.Command{ + Use: "restart", + Short: "Restarts the systemd services relevant to RollApp", + Run: func(cmd *cobra.Command, args []string) { + err := stopSystemdServices(services) + if err != nil { + pterm.Error.Println("failed to restart systemd services:", err) + return + } + }, + } + return cmd +} + +func stopSystemdServices(services []string) error { + if runtime.GOOS != "linux" { + return fmt.Errorf( + "the services commands are only available on linux machines", + ) + } + for _, service := range services { + err := servicemanager.RestartSystemdService(fmt.Sprintf("%s.service", service)) + if err != nil { + return fmt.Errorf("failed to stop %s systemd service: %v", service, err) + } + } + pterm.Success.Printf( + "💈 Services %s stopped successfully.\n", + strings.Join(services, ", "), + ) + return nil +} diff --git a/go.mod b/go.mod index 9650960a..e48691f7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/dymensionxyz/roller -go 1.22.5 +go 1.23.0 require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -21,7 +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.26.1 + 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 @@ -50,11 +50,19 @@ require ( github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect github.com/DataDog/zstd v1.5.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/aead/siphash v1.0.1 // indirect github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 // indirect github.com/armon/go-metrics v0.4.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect + github.com/btcsuite/btcd v0.23.4 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect + github.com/btcsuite/btcd/btcutil v1.1.3 // indirect + github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect + github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect + github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect + github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect + github.com/btcsuite/winsvc v1.0.0 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect @@ -68,14 +76,14 @@ require ( github.com/cometbft/cometbft v0.37.5 // indirect github.com/cometbft/cometbft-db v0.11.0 // indirect github.com/confio/ics23/go v0.9.0 // indirect - github.com/containerd/console v1.0.3 // indirect + github.com/containerd/console v1.0.4-0.20230508195404-8d3c090fd31c // indirect github.com/containerd/log v0.1.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/gogoproto v1.4.10 // indirect github.com/cosmos/iavl v0.20.1 // indirect - github.com/cosmos/ibc-go/v7 v7.5.1 // indirect + github.com/cosmos/ibc-go/v7 v7.8.0 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect @@ -85,9 +93,10 @@ require ( github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/deckarep/golang-set v1.8.0 // indirect github.com/decred/base58 v1.0.3 // indirect - github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect + github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect github.com/decred/dcrd/dcrec/edwards v1.0.0 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + github.com/decred/dcrd/lru v1.0.0 // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgraph-io/badger/v2 v2.2007.4 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect @@ -133,11 +142,14 @@ require ( github.com/hdevalence/ed25519consensus v0.1.0 // indirect github.com/huandu/skiplist v1.2.0 // 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 + github.com/jrick/logrotate v1.0.0 // indirect + github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 // indirect github.com/klauspost/compress v1.17.0 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect - github.com/lib/pq v1.10.7 // indirect + github.com/lib/pq v1.10.9 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/linxGnu/grocksdb v1.8.12 // indirect github.com/lithammer/fuzzysearch v1.1.8 // indirect diff --git a/go.sum b/go.sum index 8b9d9e23..ecb5267b 100644 --- a/go.sum +++ b/go.sum @@ -330,6 +330,7 @@ github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNu github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6/go.mod h1:eSYp2T6f0apnuW8TzhV3f6Aff2SE8Dwio++U4ha4yEM= +github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI= @@ -399,28 +400,41 @@ github.com/briandowns/spinner v1.23.0/go.mod h1:rPG4gmXeN3wQV/TsAY4w8lPdIM6RX3yq github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.21.0-beta.0.20201114000516-e9c7a5ac6401/go.mod h1:Sv4JPQ3/M+teHz9Bo5jBpkNcP0x6r7rdihlNL/7tTAs= +github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= github.com/btcsuite/btcd v0.22.1/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y= +github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= github.com/btcsuite/btcd v0.23.4 h1:IzV6qqkfwbItOS/sg/aDfPDsjPP8twrCOE2R93hxMlQ= +github.com/btcsuite/btcd v0.23.4/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= +github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= github.com/btcsuite/btcd/btcec/v2 v2.1.2/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= +github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= +github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 h1:KdUfX2zKommPRa+PD0sWZUyXe9w277ABlgELO7H04IM= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190207003914-4c204d697803/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ= github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= +github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= @@ -507,6 +521,8 @@ github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1 github.com/consensys/gnark-crypto v0.5.3/go.mod h1:hOdPlWQV1gDLp7faZVeg8Y0iEPFaOUnCc4XeCCk96p0= github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= +github.com/containerd/console v1.0.4-0.20230508195404-8d3c090fd31c h1:sgmd9/Gm5SFfxHSVVD7HAaEQlaUJKdJ2VlQM8SwUxvs= +github.com/containerd/console v1.0.4-0.20230508195404-8d3c090fd31c/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= @@ -535,6 +551,8 @@ github.com/cosmos/iavl v0.20.1 h1:rM1kqeG3/HBT85vsZdoSNsehciqUQPWrR4BYmqE2+zg= github.com/cosmos/iavl v0.20.1/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= github.com/cosmos/ibc-go/v7 v7.5.1 h1:KqS/g7W7EMX1OtOvufS8lWMJibOKpdgtNNZIU6fAgVU= github.com/cosmos/ibc-go/v7 v7.5.1/go.mod h1:ktFg5GvKOyrGCqTWtW7Grj5uweU4ZapxrNeVS1CLLbo= +github.com/cosmos/ibc-go/v7 v7.8.0 h1:hvnQRejkMoGiM4v2r6Va5UefNeMU3V+ooIWdG96SYoU= +github.com/cosmos/ibc-go/v7 v7.8.0/go.mod h1:zzFhtp9g9RrN/UxXWrdUu5VyonBALCAHujXQCzrZSu8= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw= @@ -565,11 +583,16 @@ github.com/decred/base58 v1.0.3 h1:KGZuh8d1WEMIrK0leQRM47W85KqCAdl2N+uagbctdDI= github.com/decred/base58 v1.0.3/go.mod h1:pXP9cXCfM2sFLb2viz2FNIdeMWmZDBKG3ZBYbiSM78E= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/edwards v1.0.0 h1:UDcPNzclKiJlWqV3x1Fl8xMCJrolo4PB4X9t8LwKDWU= github.com/decred/dcrd/dcrec/edwards v1.0.0/go.mod h1:HblVh1OfMt7xSxUL1ufjToaEvpbjpWvvTAUx4yem8BI= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/decred/dcrd/lru v1.0.0 h1:Kbsb1SFDsIlaupWPwsPp+dkxiBY1frcS07PCPgotKz8= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M= github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw= @@ -994,8 +1017,8 @@ github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47 github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= -github.com/ignite/cli v0.26.1 h1:T4qMjM9H38JOBsgCruilGcsfrlDGHO2K1V88gIe0ubs= -github.com/ignite/cli v0.26.1/go.mod h1:0BQcJCseK0O5RG8HYP/lvVTFbZQjkw+AY8B+wDklj38= +github.com/ignite/cli v0.27.2 h1:NFzZqQrt8vhRQeStSvAMhpq65ag+lEAVP5ulw7cu3Y4= +github.com/ignite/cli v0.27.2/go.mod h1:7uaYQQ07tyOBiVAlRYAcZk2g/Y1vtgU0J09oPNntR4E= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= @@ -1016,6 +1039,7 @@ github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1: github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= @@ -1025,6 +1049,7 @@ github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/jrick/logrotate v1.0.0 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -1045,6 +1070,7 @@ github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= @@ -1085,6 +1111,8 @@ github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgx github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= diff --git a/cmd/utils/docker.go b/utils/docker/docker.go similarity index 99% rename from cmd/utils/docker.go rename to utils/docker/docker.go index 17e1fd5c..ff07a330 100644 --- a/cmd/utils/docker.go +++ b/utils/docker/docker.go @@ -1,4 +1,4 @@ -package utils +package docker import ( "context" diff --git a/cmd/eibc/utils.go b/utils/eibc/eibc.go similarity index 55% rename from cmd/eibc/utils.go rename to utils/eibc/eibc.go index ee8aa879..9a66cc81 100644 --- a/cmd/eibc/utils.go +++ b/utils/eibc/eibc.go @@ -4,19 +4,73 @@ import ( "context" "fmt" "os" + "os/exec" + "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" ) -// ensureWhaleAccount function makes sure that eibc whale account is present in +func GetStartCmd() *exec.Cmd { + cmd := exec.Command( + consts.Executables.Eibc, + "start", + ) + return cmd +} + +func GetInitCmd() *exec.Cmd { + cmd := exec.Command( + consts.Executables.Eibc, + "init", + ) + return cmd +} + +func GetScaleCmd(count string) *exec.Cmd { + cmd := exec.Command( + consts.Executables.Eibc, + "scale", + count, + ) + return cmd +} + +func GetFundsCmd() *exec.Cmd { + cmd := exec.Command( + consts.Executables.Eibc, + "funds", + ) + return cmd +} + +func GetFulfillOrderCmd(orderId string, hd consts.HubData) (*exec.Cmd, error) { + home, err := os.UserHomeDir() + if err != nil { + return nil, err + } + + cmd := exec.Command( + consts.Executables.Dymension, + "tx", "eibc", "fulfill-order", + orderId, + "--from", consts.KeysIds.Eibc, + "--home", filepath.Join(home, consts.ConfigDirName.Eibc), + "--keyring-backend", "test", + "--node", hd.RPC_URL, "--chain-id", hd.ID, + ) + + return cmd, nil +} + +// EnsureWhaleAccount function makes sure that eibc whale account is present in // the keyring. In eibc client, whale account is the wallet that acts as the bank // and distributes funds across a set of wallets that fulfill the eibc orders -func ensureWhaleAccount() error { +func EnsureWhaleAccount() error { home, _ := os.UserHomeDir() kc := utils.KeyConfig{ Dir: consts.ConfigDirName.Eibc, @@ -42,14 +96,14 @@ func ensureWhaleAccount() error { // createMongoDbContainer function creates a mongodb container using docker // sdk. Any 'DOCKER_HOST' can be used for this mongodb container. // Mongodb is used to store information about processed eibc orders -func createMongoDbContainer() error { +func CreateMongoDbContainer() error { cc, err := client.NewClientWithOpts(client.FromEnv) if err != nil { fmt.Printf("failed to create docker client: %v\n", err) return err } - err = utils.CheckAndCreateMongoDBContainer( + err = dockerutils.CheckAndCreateMongoDBContainer( context.Background(), cc, ) diff --git a/utils/eibc/types.go b/utils/eibc/types.go new file mode 100644 index 00000000..241b3fef --- /dev/null +++ b/utils/eibc/types.go @@ -0,0 +1,74 @@ +package eibc + +import ( + "time" + + "github.com/ignite/cli/ignite/pkg/cosmosaccount" +) + +type Config struct { + HomeDir string `yaml:"home_dir"` + NodeAddress string `yaml:"node_address"` + DBPath string `yaml:"db_path"` + Gas GasConfig `yaml:"gas"` + OrderPolling OrderPollingConfig `yaml:"order_polling"` + + Whale whaleConfig `yaml:"whale"` + Bots botConfig `yaml:"bots"` + FulfillCriteria fulfillCriteria `yaml:"fulfill_criteria"` + + LogLevel string `yaml:"log_level"` + SlackConfig slackConfig `yaml:"slack"` + SkipRefund bool `yaml:"skip_refund"` +} + +type OrderPollingConfig struct { + IndexerURL string `yaml:"indexer_url"` + Interval time.Duration `yaml:"interval"` + Enabled bool `yaml:"enabled"` +} + +type GasConfig struct { + Prices string `yaml:"prices"` + Fees string `yaml:"fees"` + MinimumGasBalance string `yaml:"minimum_gas_balance"` +} + +type botConfig struct { + NumberOfBots int `yaml:"number_of_bots"` + KeyringBackend cosmosaccount.KeyringBackend `yaml:"keyring_backend"` + KeyringDir string `yaml:"keyring_dir"` + TopUpFactor int `yaml:"top_up_factor"` + MaxOrdersPerTx int `yaml:"max_orders_per_tx"` +} + +type whaleConfig struct { + AccountName string `yaml:"account_name"` + KeyringBackend cosmosaccount.KeyringBackend `yaml:"keyring_backend"` + KeyringDir string `yaml:"keyring_dir"` + AllowedBalanceThresholds map[string]string `yaml:"allowed_balance_thresholds"` +} + +type fulfillCriteria struct { + MinFeePercentage minFeePercentage `yaml:"min_fee_percentage"` +} + +type minFeePercentage struct { + Chain map[string]float32 `yaml:"chain"` + Asset map[string]float32 `yaml:"asset"` +} + +type slackConfig struct { + Enabled bool `yaml:"enabled"` + BotToken string `yaml:"bot_token"` + AppToken string `yaml:"app_token"` + ChannelID string `yaml:"channel_id"` +} + +func (e *Config) RemoveChain(chainId string) { + delete(e.FulfillCriteria.MinFeePercentage.Chain, chainId) +} + +func (e *Config) RemoveDenom(denom string) { + delete(e.FulfillCriteria.MinFeePercentage.Asset, denom) +} diff --git a/utils/service_manager/service.go b/utils/service_manager/service.go index 143c25aa..f59e2b9e 100644 --- a/utils/service_manager/service.go +++ b/utils/service_manager/service.go @@ -134,3 +134,14 @@ func RestartSystemdService(serviceName string) error { return nil } + +func StopSystemdService(serviceName string) error { + // not ideal, shouldn't run sudo commands from within roller + cmd := exec.Command("sudo", "systemctl", "stop", serviceName) + err := bash.ExecCmd(cmd) + if err != nil { + return err + } + + return nil +} From 15e5d816115fff613656d04771e18e0c68a61e09 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:47:08 +0400 Subject: [PATCH 13/27] chore: refactor update yaml func --- utils/config/yamlconfig/yaml.go | 60 +++++++-------------------------- 1 file changed, 13 insertions(+), 47 deletions(-) diff --git a/utils/config/yamlconfig/yaml.go b/utils/config/yamlconfig/yaml.go index a383a426..a016e6c8 100644 --- a/utils/config/yamlconfig/yaml.go +++ b/utils/config/yamlconfig/yaml.go @@ -2,63 +2,29 @@ package yamlconfig import ( "fmt" - "strings" "time" "github.com/ignite/cli/ignite/pkg/cosmosaccount" "gopkg.in/yaml.v3" ) -func UpdateNestedYAML(node *yaml.Node, path []string, value interface{}) error { - fmt.Printf("Updating path: %s to value: %v\n", strings.Join(path, "."), value) - if node.Kind == yaml.DocumentNode { - if len(node.Content) == 0 { - return fmt.Errorf("empty document node") - } - return UpdateNestedYAML(node.Content[0], path, value) - } - - if len(path) == 0 { - return setNodeValue(node, value) +func UpdateNestedYAML(data map[interface{}]interface{}, keyPath []string, value interface{}) error { + if len(keyPath) == 0 { + return fmt.Errorf("empty key path") } - - if node.Kind != yaml.MappingNode { - return fmt.Errorf("expected a mapping node, got %v", node.Kind) - } - - for i := 0; i < len(node.Content); i += 2 { - if node.Content[i].Value == path[0] { - return UpdateNestedYAML(node.Content[i+1], path[1:], value) + if len(keyPath) == 1 { + if value == nil { + delete(data, keyPath[0]) + } else { + data[keyPath[0]] = value } + return nil } - - fmt.Printf("Path not found, creating new key: %s\n", path[0]) - // If the path doesn't exist, create it - // Create a new key node - newKeyNode := &yaml.Node{ - Kind: yaml.ScalarNode, - Value: path[0], - Tag: "!!str", + nextMap, ok := data[keyPath[0]].(map[interface{}]interface{}) + if !ok { + return fmt.Errorf("failed to set nested map for key: %s", keyPath[0]) } - node.Content = append(node.Content, newKeyNode) - - // Determine the kind of the new value node - var newValueNode *yaml.Node - if len(path) == 1 { - // If this is the last element in the path, set the value - newValueNode = &yaml.Node{ - Kind: yaml.ScalarNode, - Tag: "!!str", // You can adjust the tag based on the type of `value` - } - } else { - // Otherwise, create a new mapping node for the next level - newValueNode = &yaml.Node{ - Kind: yaml.MappingNode, - } - } - - node.Content = append(node.Content, newValueNode) - return UpdateNestedYAML(newValueNode, path[1:], value) + return UpdateNestedYAML(nextMap, keyPath[1:], value) } func setNodeValue(node *yaml.Node, value interface{}) error { From 4bee7095fdbfa7a3d32920bcfcd46e4056e4816a Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:50:56 +0400 Subject: [PATCH 14/27] refactor: yaml --- cmd/relayer/run/run.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/cmd/relayer/run/run.go b/cmd/relayer/run/run.go index c15df338..95d55e65 100644 --- a/cmd/relayer/run/run.go +++ b/cmd/relayer/run/run.go @@ -191,18 +191,8 @@ func Cmd() *cobra.Command { fmt.Printf("Error reading file: %v\n", err) } - // Parse the YAML - var node yaml.Node - err = yaml.Unmarshal(data, &node) - if err != nil { - pterm.Error.Println("failed to unmarshal config.yaml") - return - } - - 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, @@ -254,7 +244,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 From 63c9031b6649db54572e857d0de925a41d69f243 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:59:48 +0400 Subject: [PATCH 15/27] refactor: yaml --- .pre-commit-config.yaml | 14 +++++++------- cmd/eibc/fulfill/denoms/set/set.go | 15 +++++++-------- cmd/eibc/init/init.go | 16 +++------------- utils/config/yamlconfig/yaml.go | 29 ----------------------------- 4 files changed, 17 insertions(+), 57 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b943a96f..843c5868 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.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: diff --git a/cmd/eibc/fulfill/denoms/set/set.go b/cmd/eibc/fulfill/denoms/set/set.go index cbc48fea..fab14ff2 100644 --- a/cmd/eibc/fulfill/denoms/set/set.go +++ b/cmd/eibc/fulfill/denoms/set/set.go @@ -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 { @@ -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, @@ -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 diff --git a/cmd/eibc/init/init.go b/cmd/eibc/init/init.go index b68f7022..89724604 100644 --- a/cmd/eibc/init/init.go +++ b/cmd/eibc/init/init.go @@ -103,19 +103,9 @@ 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( @@ -139,7 +129,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 diff --git a/utils/config/yamlconfig/yaml.go b/utils/config/yamlconfig/yaml.go index a016e6c8..60f4ac1b 100644 --- a/utils/config/yamlconfig/yaml.go +++ b/utils/config/yamlconfig/yaml.go @@ -5,7 +5,6 @@ import ( "time" "github.com/ignite/cli/ignite/pkg/cosmosaccount" - "gopkg.in/yaml.v3" ) func UpdateNestedYAML(data map[interface{}]interface{}, keyPath []string, value interface{}) error { @@ -27,34 +26,6 @@ func UpdateNestedYAML(data map[interface{}]interface{}, keyPath []string, value return UpdateNestedYAML(nextMap, keyPath[1:], value) } -func setNodeValue(node *yaml.Node, value interface{}) error { - switch v := value.(type) { - case string: - node.Kind = yaml.ScalarNode - node.Tag = "!!str" - node.Value = v - case int: - node.Kind = yaml.ScalarNode - node.Tag = "!!int" - node.Value = fmt.Sprintf("%d", v) - case float32: - node.Kind = yaml.ScalarNode - node.Tag = "!!float" - node.Value = fmt.Sprintf("%f", v) - case float64: - node.Kind = yaml.ScalarNode - node.Tag = "!!float" - node.Value = fmt.Sprintf("%f", v) - case bool: - node.Kind = yaml.ScalarNode - node.Tag = "!!bool" - node.Value = fmt.Sprintf("%t", v) - default: - return fmt.Errorf("unsupported value type: %T", value) - } - return nil -} - type EibcConfig struct { HomeDir string `mapstructure:"home_dir"` NodeAddress string `mapstructure:"node_address"` From 913550140b6e4d831237f92fae5ad456704ad8d8 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:00:37 +0400 Subject: [PATCH 16/27] chore: yaml --- cmd/eibc/fulfill/rollapps/set/set.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/eibc/fulfill/rollapps/set/set.go b/cmd/eibc/fulfill/rollapps/set/set.go index 1a8c1b2a..ff7efbaf 100644 --- a/cmd/eibc/fulfill/rollapps/set/set.go +++ b/cmd/eibc/fulfill/rollapps/set/set.go @@ -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, @@ -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 From c690c1ec751c277803a84a9d6691f7b2509f583d Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:09:19 +0400 Subject: [PATCH 17/27] chore: debug --- cmd/relayer/run/run.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/relayer/run/run.go b/cmd/relayer/run/run.go index 95d55e65..75feb171 100644 --- a/cmd/relayer/run/run.go +++ b/cmd/relayer/run/run.go @@ -9,6 +9,10 @@ import ( "strconv" comettypes "github.com/cometbft/cometbft/types" + "github.com/pterm/pterm" + "github.com/spf13/cobra" + "gopkg.in/yaml.v2" + initconfig "github.com/dymensionxyz/roller/cmd/config/init" "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/cmd/utils" @@ -23,9 +27,6 @@ import ( "github.com/dymensionxyz/roller/utils/errorhandling" genesisutils "github.com/dymensionxyz/roller/utils/genesis" rollapputils "github.com/dymensionxyz/roller/utils/rollapp" - "github.com/pterm/pterm" - "github.com/spf13/cobra" - "gopkg.in/yaml.v3" ) // TODO: Test relaying on 35-C and update the prices @@ -193,6 +194,9 @@ func Cmd() *cobra.Command { var contentNode map[interface{}]interface{} err = yaml.Unmarshal(data, &contentNode) + if err != nil { + pterm.Error.Println("failed to unmarshal", err) + } err = yamlconfig.UpdateNestedYAML( contentNode, From 2babd4eeff76c8b67827a40a3b71f5b18027cbe8 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:12:19 +0400 Subject: [PATCH 18/27] chore: debug --- cmd/relayer/run/run.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/relayer/run/run.go b/cmd/relayer/run/run.go index 75feb171..cae3a483 100644 --- a/cmd/relayer/run/run.go +++ b/cmd/relayer/run/run.go @@ -253,6 +253,7 @@ func Cmd() *cobra.Command { fmt.Printf("Error marshaling YAML: %v\n", err) return } + fmt.Println(string(updatedData)) // Write the updated YAML back to the original file err = os.WriteFile(filepath.Join(path, "config.yaml"), updatedData, 0o644) From b1a980ff92ec162e58d5b2602675140c6a0560db Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:14:13 +0400 Subject: [PATCH 19/27] chore: debug --- cmd/relayer/run/run.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/relayer/run/run.go b/cmd/relayer/run/run.go index cae3a483..d806fb17 100644 --- a/cmd/relayer/run/run.go +++ b/cmd/relayer/run/run.go @@ -253,7 +253,10 @@ 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(path, "config.yaml")) // Write the updated YAML back to the original file err = os.WriteFile(filepath.Join(path, "config.yaml"), updatedData, 0o644) From 40fd006b7a570e401ca68bd26f15b8c37445a43e Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:16:53 +0400 Subject: [PATCH 20/27] fix: order --- cmd/relayer/run/run.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/cmd/relayer/run/run.go b/cmd/relayer/run/run.go index d806fb17..d585b446 100644 --- a/cmd/relayer/run/run.go +++ b/cmd/relayer/run/run.go @@ -185,6 +185,23 @@ func Cmd() *cobra.Command { return } + pterm.Info.Println( + "updating dymint config to 5s block time for relayer configuration", + ) + err = dymintutils.UpdateDymintConfigForIBC(home, "5s", false) + if err != nil { + pterm.Error.Println( + "failed to update dymint config for ibc creation", + err, + ) + return + } + + if err := relayer.CreatePath(rollappConfig); err != nil { + pterm.Error.Printf("failed to create relayer IBC path: %v\n", err) + return + } + pterm.Info.Println("updating application relayer config") path := filepath.Join(relayerHome, "config") data, err := os.ReadFile(filepath.Join(path, "config.yaml")) @@ -264,23 +281,6 @@ func Cmd() *cobra.Command { fmt.Printf("Error writing file: %v\n", err) return } - - pterm.Info.Println( - "updating dymint config to 5s block time for relayer configuration", - ) - err = dymintutils.UpdateDymintConfigForIBC(home, "5s", false) - if err != nil { - pterm.Error.Println( - "failed to update dymint config for ibc creation", - err, - ) - return - } - - if err := relayer.CreatePath(rollappConfig); err != nil { - pterm.Error.Printf("failed to create relayer IBC path: %v\n", err) - return - } } if isRelayerInitialized && !shouldOverwrite { From c823c8ebcd64f57924ca06f6078432f6386411c7 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:51:58 +0400 Subject: [PATCH 21/27] chore: fix typo --- cmd/relayer/run/run.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/relayer/run/run.go b/cmd/relayer/run/run.go index d585b446..abddea2a 100644 --- a/cmd/relayer/run/run.go +++ b/cmd/relayer/run/run.go @@ -203,8 +203,8 @@ func Cmd() *cobra.Command { } pterm.Info.Println("updating application relayer config") - path := filepath.Join(relayerHome, "config") - data, err := os.ReadFile(filepath.Join(path, "config.yaml")) + 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) } @@ -237,7 +237,7 @@ func Cmd() *cobra.Command { err = yamlconfig.UpdateNestedYAML( contentNode, - []string{"chains", rollappConfig.RollappID, "value", "http-addr"}, + []string{"chains", rollappConfig.HubData.ID, "value", "http-addr"}, rollappConfig.HubData.API_URL, ) if err != nil { @@ -273,10 +273,14 @@ func Cmd() *cobra.Command { fmt.Println("writing") fmt.Println(string(updatedData)) fmt.Println("to") - fmt.Println(filepath.Join(path, "config.yaml")) + fmt.Println(filepath.Join(relayerConfigPath, "config.yaml")) // Write the updated YAML back to the original file - err = os.WriteFile(filepath.Join(path, "config.yaml"), updatedData, 0o644) + err = os.WriteFile( + filepath.Join(relayerConfigPath, "config.yaml"), + updatedData, + 0o644, + ) if err != nil { fmt.Printf("Error writing file: %v\n", err) return From d800052cc9a2dc1aa19ac402b9ea602b3be88230 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:53:09 +0400 Subject: [PATCH 22/27] chore: update relayer version --- scripts/install-binaries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install-binaries.sh b/scripts/install-binaries.sh index 3c9a89c6..61881082 100755 --- a/scripts/install-binaries.sh +++ b/scripts/install-binaries.sh @@ -7,7 +7,7 @@ DYMD_VERSION="main" DYMD_COMMIT="f42674ae" EIBC_VERSION="main" -RLY_VERSION="v0.3.4-v2.5.2-relayer-canon-0" +RLY_VERSION="v0.3.4-v2.5.2-relayer-canon-1" CELESTIA_VERSION="v0.16.0-rc0" CELESTIA_APP_VERSION="v2.0.0" From 6a69742e43f50c6934c2f0fcf12adbf7819fc7a0 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:55:45 +0400 Subject: [PATCH 23/27] fix: handle existing channels --- cmd/relayer/run/run.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/relayer/run/run.go b/cmd/relayer/run/run.go index abddea2a..748cbfd2 100644 --- a/cmd/relayer/run/run.go +++ b/cmd/relayer/run/run.go @@ -372,7 +372,10 @@ func Cmd() *cobra.Command { err := rly.WriteRelayerStatus(status) if err != nil { fmt.Println(err) + return } + + return } if !rly.ChannelReady() { From 3874702f66322de7c703380bd2a569c0f3372525 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:57:47 +0400 Subject: [PATCH 24/27] chore: fix typo --- cmd/relayer/run/run.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/relayer/run/run.go b/cmd/relayer/run/run.go index 748cbfd2..07fae120 100644 --- a/cmd/relayer/run/run.go +++ b/cmd/relayer/run/run.go @@ -375,6 +375,7 @@ func Cmd() *cobra.Command { return } + pterm.Info.Println(status) return } From b53b61e0e77e28d518af5be771b20abb3e44b18f Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:59:35 +0400 Subject: [PATCH 25/27] chore: remove debug --- cmd/utils/key_info.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/utils/key_info.go b/cmd/utils/key_info.go index 260e3513..216adc1e 100644 --- a/cmd/utils/key_info.go +++ b/cmd/utils/key_info.go @@ -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 { From 91b449f0110a1c0cbdbc2ba8b831954f7921df04 Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:59:53 +0400 Subject: [PATCH 26/27] chore: remove debug --- utils/dymint/dymint.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/dymint/dymint.go b/utils/dymint/dymint.go index 726eca2d..fb67cf00 100644 --- a/utils/dymint/dymint.go +++ b/utils/dymint/dymint.go @@ -9,12 +9,13 @@ import ( "time" "github.com/BurntSushi/toml" + "github.com/pterm/pterm" + "github.com/dymensionxyz/roller/sequencer" "github.com/dymensionxyz/roller/utils" "github.com/dymensionxyz/roller/utils/bash" "github.com/dymensionxyz/roller/utils/config/tomlconfig" servicemanager "github.com/dymensionxyz/roller/utils/service_manager" - "github.com/pterm/pterm" ) // TODO: use dymint instead @@ -186,8 +187,6 @@ func waitForHealthyRollApp(url string) { var response RollappHealthResponse err = json.Unmarshal(body, &response) - fmt.Println("response: ", string(body)) - if err != nil { fmt.Printf("Error unmarshaling JSON: %v\n", err) continue From d435f7f566c782549e289b1c42dca18870c5f9ff Mon Sep 17 00:00:00 2001 From: artemijspavlovs <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:01:21 +0400 Subject: [PATCH 27/27] chore: output --- cmd/relayer/run/run.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/relayer/run/run.go b/cmd/relayer/run/run.go index 07fae120..8f79e986 100644 --- a/cmd/relayer/run/run.go +++ b/cmd/relayer/run/run.go @@ -365,7 +365,7 @@ 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, )