Skip to content

Commit

Permalink
chore: add mainnet (#1222)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs authored Jan 7, 2025
1 parent 5cb9ed3 commit ba017d7
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 20 deletions.
35 changes: 29 additions & 6 deletions cmd/config/set/hub_rpc.go
Original file line number Diff line number Diff line change
@@ -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)
}
10 changes: 5 additions & 5 deletions cmd/consts/da.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
},
Expand Down
6 changes: 3 additions & 3 deletions cmd/consts/dymension.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/eibc/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion cmd/rollapp/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
6 changes: 6 additions & 0 deletions data_layer/da_layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions relayer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion utils/config/propmts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions utils/dependencies/celestia.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions utils/keys/keyring_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
2 changes: 1 addition & 1 deletion utils/relayer/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions utils/rollapp/rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
}
Expand Down

0 comments on commit ba017d7

Please sign in to comment.