diff --git a/cmd/eibc/eibc.go b/cmd/eibc/eibc.go index 9e7019dd..67fe6ca0 100644 --- a/cmd/eibc/eibc.go +++ b/cmd/eibc/eibc.go @@ -4,7 +4,6 @@ import ( "github.com/spf13/cobra" "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" @@ -24,7 +23,6 @@ func Cmd() *cobra.Command { cmd.AddCommand(eibcinit.Cmd()) cmd.AddCommand(start.Cmd()) cmd.AddCommand(scale.Cmd()) - cmd.AddCommand(funds.Cmd()) cmd.AddCommand(fulfill.Cmd()) sl := []string{"eibc"} diff --git a/cmd/eibc/fulfill/denoms/denoms.go b/cmd/eibc/fulfill/denoms/denoms.go deleted file mode 100644 index 25806034..00000000 --- a/cmd/eibc/fulfill/denoms/denoms.go +++ /dev/null @@ -1,23 +0,0 @@ -package denoms - -import ( - "github.com/spf13/cobra" - - "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" -) - -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 deleted file mode 100644 index 6e345974..00000000 --- a/cmd/eibc/fulfill/denoms/list/list.go +++ /dev/null @@ -1,62 +0,0 @@ -package list - -import ( - "fmt" - "os" - "path/filepath" - - "github.com/pterm/pterm" - "github.com/spf13/cobra" - "gopkg.in/yaml.v3" - - "github.com/dymensionxyz/roller/cmd/consts" - eibcutils "github.com/dymensionxyz/roller/utils/eibc" - "github.com/dymensionxyz/roller/utils/filesystem" -) - -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 := filesystem.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 deleted file mode 100644 index 062accc2..00000000 --- a/cmd/eibc/fulfill/denoms/remove/remove.go +++ /dev/null @@ -1,76 +0,0 @@ -package remove - -import ( - "fmt" - "os" - "path/filepath" - - "github.com/pterm/pterm" - "github.com/spf13/cobra" - "gopkg.in/yaml.v3" - - "github.com/dymensionxyz/roller/cmd/consts" - "github.com/dymensionxyz/roller/utils/eibc" - "github.com/dymensionxyz/roller/utils/filesystem" -) - -func Cmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "remove ", - Short: "Commands to manage the whitelist of RollApps to fulfill eibc orders for", - Args: cobra.ExactArgs(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 := filesystem.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.RemoveDenom(asset) - config.RemoveAllowedBalanceThreshold(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 deleted file mode 100644 index d0d216db..00000000 --- a/cmd/eibc/fulfill/denoms/set/set.go +++ /dev/null @@ -1,88 +0,0 @@ -package set - -import ( - "fmt" - "math/big" - "os" - "path/filepath" - - "github.com/pterm/pterm" - "github.com/spf13/cobra" - "gopkg.in/yaml.v3" - - "github.com/dymensionxyz/roller/cmd/consts" - "github.com/dymensionxyz/roller/utils/config/yamlconfig" - "github.com/dymensionxyz/roller/utils/filesystem" -) - -func Cmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "set ", - Short: "Commands to manage the whitelist of ibc-denoms to fulfill eibc orders for", - Long: `Commands to manage the whitelist of ibc-denoms to fulfill eibc orders for - -The fee-percentage is a float number between 0 and 100 which represents -the minimal percentage of the order fee that you want to receive for fulfilling an order. -Assume there's an eibc order for 100 with a fee of 3, -if the percentage is set to 4, this order will be ignored by your eibc client -instance. -`, - 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 := filesystem.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] - - vf, _, err := big.ParseFloat(value, 10, 64, big.ToNearestEven) - valueFloat, _ := vf.Float32() - 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) - updates := map[string]interface{}{ - fmt.Sprintf("fulfill_criteria.min_fee_percentage.asset.%s", ibcDenom): valueFloat, - fmt.Sprintf("whale.allowed_balance_thresholds.%s", ibcDenom): "1000000000000000000", - } - err = yamlconfig.UpdateNestedYAML(eibcConfigPath, updates) - if err != nil { - pterm.Error.Println("failed to update config", err) - return - } - }, - } - - return cmd -} diff --git a/cmd/eibc/fulfill/fulfill.go b/cmd/eibc/fulfill/fulfill.go index a7d4e471..6c4c3376 100644 --- a/cmd/eibc/fulfill/fulfill.go +++ b/cmd/eibc/fulfill/fulfill.go @@ -3,7 +3,6 @@ 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" ) @@ -16,7 +15,6 @@ func Cmd() *cobra.Command { cmd.AddCommand(order.Cmd()) cmd.AddCommand(rollapps.Cmd()) - cmd.AddCommand(denoms.Cmd()) return cmd } diff --git a/cmd/eibc/fulfill/rollapps/list/list.go b/cmd/eibc/fulfill/rollapps/list/list.go index d96237f4..add896c2 100644 --- a/cmd/eibc/fulfill/rollapps/list/list.go +++ b/cmd/eibc/fulfill/rollapps/list/list.go @@ -52,8 +52,11 @@ func Cmd() *cobra.Command { return } - for chain, percentage := range config.FulfillCriteria.MinFeePercentage.Chain { - fmt.Printf("%s: %.6f\n", chain, percentage) + for k, v := range config.Rollapps { + fmt.Printf("%s requires %s validation(s):\n", k, v.MinConfirmations) + for _, v := range v.FullNodes { + fmt.Printf("\t%s\n", v) + } } }, } diff --git a/cmd/eibc/fulfill/rollapps/set/set.go b/cmd/eibc/fulfill/rollapps/set/set.go index 392b1aca..e6409d6f 100644 --- a/cmd/eibc/fulfill/rollapps/set/set.go +++ b/cmd/eibc/fulfill/rollapps/set/set.go @@ -3,6 +3,7 @@ package set import ( "os" "path/filepath" + "strings" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -14,7 +15,7 @@ import ( func Cmd() *cobra.Command { cmd := &cobra.Command{ - Use: "set ", + Use: "set ", Short: "Commands to manage the whitelist of RollApps to fulfill eibc orders for", Long: `Commands to manage the whitelist of RollApps to fulfill eibc orders for @@ -45,8 +46,15 @@ instance. } rollAppID := args[0] + fullNodes := args[1] + if len(fullNodes) == 0 { + pterm.Error.Println("please provide at least one full node") + return + } + + fNodes := strings.Split(fullNodes, ",") - err = eibc.AddRollappToEibc(rollAppID, eibcHome, []string{"mock"}) + err = eibc.AddRollappToEibc(rollAppID, eibcHome, fNodes) if err != nil { return } diff --git a/cmd/eibc/funds/funds.go b/cmd/eibc/funds/funds.go deleted file mode 100644 index 2ac1d33f..00000000 --- a/cmd/eibc/funds/funds.go +++ /dev/null @@ -1,33 +0,0 @@ -package funds - -import ( - "fmt" - - "github.com/pterm/pterm" - "github.com/spf13/cobra" - - "github.com/dymensionxyz/roller/utils/bash" - eibcutils "github.com/dymensionxyz/roller/utils/eibc" -) - -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/utils/config/yamlconfig/yaml.go b/utils/config/yamlconfig/yaml.go index 986e8716..6bc660cc 100644 --- a/utils/config/yamlconfig/yaml.go +++ b/utils/config/yamlconfig/yaml.go @@ -4,9 +4,7 @@ import ( "fmt" "os" "strings" - "time" - "github.com/ignite/cli/ignite/pkg/cosmosaccount" "gopkg.in/yaml.v3" ) @@ -63,67 +61,3 @@ func setNestedValue(data map[string]interface{}, keys []string, value interface{ } return nil } - -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"` -} - -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) -} diff --git a/utils/dependencies/dependencies.go b/utils/dependencies/dependencies.go index 6e9fd03a..bf8055c8 100644 --- a/utils/dependencies/dependencies.go +++ b/utils/dependencies/dependencies.go @@ -93,7 +93,7 @@ func InstallBinaries(withMockDA bool, raResp rollapp.ShowRollappResponse) ( } if withMockDA { - // @20240913 libwasm is necessary on the host VM to be able to run the rollapp binary + // @20240913 libwasm is necessary on the host VM to be able to run the prebuilt rollapp binary var outputPath string var libName string libVersion := "v1.2.3" diff --git a/utils/eibc/types.go b/utils/eibc/types.go index 4074235d..8e606306 100644 --- a/utils/eibc/types.go +++ b/utils/eibc/types.go @@ -7,19 +7,18 @@ import ( ) 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"` + Fulfillers fulfillerConfig `yaml:"fulfillers"` + Gas GasConfig `yaml:"gas"` + + LogLevel string `yaml:"log_level"` + NodeAddress string `yaml:"node_address"` + + OperatorConfig operatorConfig `yaml:"operator"` + OrderPolling OrderPollingConfig `yaml:"order_polling"` + Rollapps map[string]RollappConfig `yaml:"rollapps"` + + SlackConfig slackConfig `yaml:"slack"` + Validation validationConfig `yaml:"validation"` } type OrderPollingConfig struct { @@ -28,25 +27,34 @@ type OrderPollingConfig struct { Enabled bool `yaml:"enabled"` } +type RollappConfig struct { + FullNodes []string `yaml:"full_nodes"` + MinConfirmations string `yaml:"min_confirmations"` +} + type GasConfig struct { - Prices string `yaml:"prices"` - Fees string `yaml:"fees"` - MinimumGasBalance string `yaml:"minimum_gas_balance"` + Prices string `yaml:"prices"` } -type botConfig struct { - NumberOfBots int `yaml:"number_of_bots"` +type fulfillerConfig struct { + Scale int `yaml:"scale"` KeyringBackend cosmosaccount.KeyringBackend `yaml:"keyring_backend"` KeyringDir string `yaml:"keyring_dir"` - TopUpFactor int `yaml:"top_up_factor"` MaxOrdersPerTx int `yaml:"max_orders_per_tx"` + PolicyAddress string `yaml:"policy_address"` } -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 operatorConfig struct { + AccountName string `yaml:"account_name"` + GroupID string `yaml:"group_id"` + KeyringBackend cosmosaccount.KeyringBackend `yaml:"keyring_backend"` + KeyringDir string `yaml:"keyring_dir"` + MinFeeShare float32 `yaml:"min_fee_share"` +} + +type validationConfig struct { + FallbackLevel string `yaml:"fallback_level"` + ValidationWaitTime string `yaml:"validation_wait_time"` } type fulfillCriteria struct { @@ -66,13 +74,5 @@ type slackConfig struct { } func (e *Config) RemoveChain(chainId string) { - delete(e.FulfillCriteria.MinFeePercentage.Chain, chainId) -} - -func (e *Config) RemoveAllowedBalanceThreshold(denom string) { - delete(e.Whale.AllowedBalanceThresholds, denom) -} - -func (e *Config) RemoveDenom(denom string) { - delete(e.FulfillCriteria.MinFeePercentage.Asset, denom) + delete(e.Rollapps, chainId) }