diff --git a/cmd/config/set/hub_rpc.go b/cmd/config/set/hub_rpc.go index 8f7b7e28..64c57e17 100644 --- a/cmd/config/set/hub_rpc.go +++ b/cmd/config/set/hub_rpc.go @@ -1,29 +1,52 @@ package set import ( - "github.com/dymensionxyz/roller/relayer" + "fmt" + "path/filepath" + + "github.com/pterm/pterm" + + "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/utils/config/tomlconfig" + "github.com/dymensionxyz/roller/utils/config/yamlconfig" "github.com/dymensionxyz/roller/utils/roller" "github.com/dymensionxyz/roller/utils/sequencer" servicemanager "github.com/dymensionxyz/roller/utils/service_manager" ) +// setHubRPC function  func setHubRPC(rlpCfg roller.RollappConfig, value string) error { + pterm.Info.Println("updating roller config file with the new hub rpc endpoint") rlpCfg.HubData.RpcUrl = value + rlpCfg.HubData.ArchiveRpcUrl = value if err := roller.WriteConfig(rlpCfg); err != nil { return err } - if err := relayer.UpdateRlyConfigValue( - rlpCfg, []string{"chains", rlpCfg.HubData.ID, "value", "rpc-addr"}, - value, - ); err != nil { + + pterm.Info.Println("updating relayer config file with the new hub rpc endpoint") + updates := map[string]interface{}{ + fmt.Sprintf("chains.%s.value.rpc-addr", rlpCfg.HubData.ID): value, + } + + rlyConfigPath := filepath.Join( + rlpCfg.Home, + consts.ConfigDirName.Relayer, + "config", + "config.yaml", + ) + err := yamlconfig.UpdateNestedYAML(rlyConfigPath, updates) + if err != nil { + pterm.Error.Printf("Error updating YAML: %v\n", err) return err } + + pterm.Info.Println("updating dymint config file with the new hub rpc endpoint") dymintTomlPath := sequencer.GetDymintFilePath(rlpCfg.Home) - err := tomlconfig.UpdateFieldInFile(dymintTomlPath, "settlement_node_address", value) + err = tomlconfig.UpdateFieldInFile(dymintTomlPath, "settlement_node_address", value) if err != nil { return err } + pterm.Info.Println("restarting system services to apply the changes") return servicemanager.RestartSystemServices([]string{"rollapp", "relayer"}, rlpCfg.Home) } diff --git a/cmd/consts/da.go b/cmd/consts/da.go index 95df5b99..cb631933 100644 --- a/cmd/consts/da.go +++ b/cmd/consts/da.go @@ -54,7 +54,6 @@ var DaNetworks = map[string]DaData{ StateNodes: []string{ "mocha-4-consensus.mesa.newmetric.xyz", "public-celestia-mocha4-consensus.numia.xyz", - "mocha-4-consensus.mesa.newmetric.xyz", "full.consensus.mocha-4.celestia-mocha.com", "consensus-full-mocha-4.celestia-mocha.com", "rpc-mocha.pops.one", @@ -63,12 +62,13 @@ var DaNetworks = map[string]DaData{ }, string(CelestiaMainnet): { Backend: Celestia, - ApiUrl: "api-celestia.mzonder.com", + ApiUrl: "https://api.celestia.pops.one", ID: CelestiaMainnet, - RpcUrl: "rpc-celestia.mzonder.com", - CurrentStateNode: "", + RpcUrl: "http://rpc.celestia.pops.one:26657", + CurrentStateNode: "rpc.celestia.pops.one", StateNodes: []string{ - "", + "rpc-celestia.alphab.ai", + "celestia.rpc.kjnodes.com", }, GasPrice: "0.002", }, diff --git a/cmd/consts/dymension.go b/cmd/consts/dymension.go index 1401dc62..2b54bd3c 100644 --- a/cmd/consts/dymension.go +++ b/cmd/consts/dymension.go @@ -2,10 +2,10 @@ package consts var MainnetHubData = HubData{ Environment: "mainnet", - ApiUrl: "https://dymension-mainnet-rest.public.blastapi.io", + ApiUrl: "https://dymension-mainnet-rest.public.blastapi.io:443", ID: MainnetHubID, - RpcUrl: "https://dymension-mainnet-tendermint.public.blastapi.io", - ArchiveRpcUrl: "https://dymension-mainnet-tendermint.public.blastapi.io", + RpcUrl: "https://dymension-mainnet-tendermint.public.blastapi.io:443", + ArchiveRpcUrl: "https://dymension-mainnet-tendermint.public.blastapi.io:443", GasPrice: "7000000000", DaNetwork: CelestiaMainnet, } diff --git a/cmd/eibc/init/init.go b/cmd/eibc/init/init.go index f9c0dde7..55c490b6 100644 --- a/cmd/eibc/init/init.go +++ b/cmd/eibc/init/init.go @@ -395,7 +395,7 @@ func initializeEibcForEnvironment() (consts.HubData, error) { pterm.Info.Println("initializing for environment") var hd consts.HubData - envs := []string{"playground", "blumbus", "custom"} + envs := []string{"playground", "blumbus", "custom", "mainnet"} env, _ := pterm.DefaultInteractiveSelect. WithDefaultText( "select the environment you want to initialize eibc client for", diff --git a/cmd/rollapp/init/init.go b/cmd/rollapp/init/init.go index f0572cb3..780dd649 100644 --- a/cmd/rollapp/init/init.go +++ b/cmd/rollapp/init/init.go @@ -119,7 +119,7 @@ func Cmd() *cobra.Command { if shouldUseMockBackend { env = "mock" } else { - envs := []string{"mock", "playground", "blumbus", "custom"} + envs := []string{"mock", "playground", "blumbus", "custom", "mainnet"} env, _ = pterm.DefaultInteractiveSelect. WithDefaultText("select the environment you want to initialize for"). WithOptions(envs). diff --git a/data_layer/da_layer.go b/data_layer/da_layer.go index a80b39bd..1ab436cb 100644 --- a/data_layer/da_layer.go +++ b/data_layer/da_layer.go @@ -65,6 +65,12 @@ func GetDaInfo(env, daBackend string) (*consts.DaData, error) { } else { return nil, fmt.Errorf("unsupported DA backend: %s", daBackend) } + case "mainnet": + if daBackend == string(consts.Celestia) { + daNetwork = string(consts.CelestiaMainnet) + } else { + return nil, fmt.Errorf("unsupported DA backend: %s", daBackend) + } case "custom": if daBackend == string(consts.Celestia) { daNetwork = string(consts.CelestiaTestnet) diff --git a/relayer/config.go b/relayer/config.go index ae5791e1..941a9869 100644 --- a/relayer/config.go +++ b/relayer/config.go @@ -151,22 +151,28 @@ func UpdateRlyConfigValue( "config", "config.yaml", ) + data, err := os.ReadFile(rlyConfigPath) if err != nil { return fmt.Errorf("failed to load %s: %v", rlyConfigPath, err) } + var rlyCfg map[interface{}]interface{} + err = yaml.Unmarshal(data, &rlyCfg) if err != nil { return fmt.Errorf("failed to unmarshal yaml: %v", err) } + if err := utils.SetNestedValue(rlyCfg, keyPath, newValue); err != nil { return err } + newData, err := yaml.Marshal(rlyCfg) if err != nil { return fmt.Errorf("failed to marshal updated config: %v", err) } + // nolint:gofumpt return os.WriteFile(rlyConfigPath, newData, 0o644) } diff --git a/utils/config/propmts.go b/utils/config/propmts.go index 1df3158d..a918a7aa 100644 --- a/utils/config/propmts.go +++ b/utils/config/propmts.go @@ -24,7 +24,7 @@ func PromptRaID() string { } func PromptEnvironment() string { - envs := []string{"playground", "blumbus", "custom"} + envs := []string{"playground", "blumbus", "custom", "mainnet"} env, _ := pterm.DefaultInteractiveSelect. WithDefaultText( "select the environment you want to initialize relayer for", diff --git a/utils/dependencies/celestia.go b/utils/dependencies/celestia.go index e450a990..792111c0 100644 --- a/utils/dependencies/celestia.go +++ b/utils/dependencies/celestia.go @@ -8,8 +8,8 @@ import ( ) const ( - DefaultCelestiaNodeVersion = "v0.20.4-mocha" - DefaultCelestiaAppVersion = "v2.3.1" + DefaultCelestiaNodeVersion = "v0.20.4" + DefaultCelestiaAppVersion = "v3.2.0" ) func DefaultCelestiaNodeDependency() types.Dependency { diff --git a/utils/keys/keyring_backend.go b/utils/keys/keyring_backend.go index 6e9d489a..7a395dc7 100644 --- a/utils/keys/keyring_backend.go +++ b/utils/keys/keyring_backend.go @@ -21,6 +21,11 @@ func KeyringBackendFromEnv(env string) consts.SupportedKeyringBackend { switch env { case "mock", "playground", "blumbus": return consts.SupportedKeyringBackends.Test + case "mainnet": + if runtime.GOOS != "darwin" { + return consts.SupportedKeyringBackends.OS + } + return consts.SupportedKeyringBackends.Test case "custom": krBackends := []string{"test"} if runtime.GOOS != "darwin" { diff --git a/utils/relayer/relayer.go b/utils/relayer/relayer.go index 4e0d725c..1fa96695 100644 --- a/utils/relayer/relayer.go +++ b/utils/relayer/relayer.go @@ -86,7 +86,7 @@ func promptForRaAndHd() (string, *consts.HubData, string, error) { raID := config.PromptRaID() env := config.PromptEnvironment() - if env == "playground" || env == "blumbus" { + if env == "playground" || env == "blumbus" || env == "mainnet" { hd = consts.Hubs[env] } else { chd, err := config.CreateCustomHubData() diff --git a/utils/rollapp/rollapp.go b/utils/rollapp/rollapp.go index b6da9cac..865b563e 100644 --- a/utils/rollapp/rollapp.go +++ b/utils/rollapp/rollapp.go @@ -233,6 +233,8 @@ func PopulateRollerConfigWithRaMetadataFromChain( switch hd.ID { case consts.MockHubID: + case consts.MainnetHubID: + DA = consts.DaNetworks[string(consts.CelestiaMainnet)] default: DA = consts.DaNetworks[string(consts.CelestiaTestnet)] }