-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update sequencer metadata (#850)
- Loading branch information
1 parent
3febe76
commit 2166bc6
Showing
13 changed files
with
399 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/dymensionxyz/roller/cmd/rollapp/config/set" | ||
"github.com/dymensionxyz/roller/cmd/rollapp/config/show" | ||
) | ||
|
||
func Cmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "config", | ||
Short: "Update the relevant configuration values related to RollApp", | ||
} | ||
|
||
cmd.AddCommand(show.Cmd()) | ||
cmd.AddCommand(set.Cmd()) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package set | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
|
||
"github.com/pterm/pterm" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/dymensionxyz/roller/cmd/consts" | ||
cmdutils "github.com/dymensionxyz/roller/cmd/utils" | ||
"github.com/dymensionxyz/roller/utils" | ||
) | ||
|
||
func Cmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "set <key> <new-value>", | ||
Args: cobra.ExactArgs(2), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
k := args[0] | ||
v := args[1] | ||
home := cmd.Flag(cmdutils.FlagNames.Home).Value.String() | ||
|
||
dymintConfigPath := filepath.Join( | ||
home, | ||
consts.ConfigDirName.Rollapp, | ||
"config", | ||
"dymint.toml", | ||
) | ||
appConfigPath := filepath.Join( | ||
home, | ||
consts.ConfigDirName.Rollapp, | ||
"config", | ||
"app.toml", | ||
) | ||
// nice name, ik | ||
configConfigPath := filepath.Join( | ||
home, | ||
consts.ConfigDirName.Rollapp, | ||
"config", | ||
"config.toml", | ||
) | ||
|
||
// TODO: refactor, each configurable value can be a struct | ||
// containing config file path, key and the current value | ||
switch k { | ||
case "rollapp_minimum_gas_price": | ||
cfg := appConfigPath | ||
err := utils.UpdateFieldInToml(cfg, "minimum-gas-prices", v) | ||
if err != nil { | ||
pterm.Error.Printf("failed to update %s: %s", k, err) | ||
return | ||
} | ||
case "rollapp_rpc_port": | ||
cfg := configConfigPath | ||
err := utils.UpdateFieldInToml(cfg, "rpc.laddr", v) | ||
if err != nil { | ||
pterm.Error.Printf("failed to update %s: %s", k, err) | ||
return | ||
} | ||
case "rollapp_grpc_port": | ||
cfg := appConfigPath | ||
err := utils.UpdateFieldInToml(cfg, "grpc-web.address", v) | ||
if err != nil { | ||
pterm.Error.Printf("failed to update %s: %s", k, err) | ||
return | ||
} | ||
case "rollapp_rest_api_port": | ||
cfg := appConfigPath | ||
err := utils.UpdateFieldInToml(cfg, "api.address", v) | ||
if err != nil { | ||
pterm.Error.Printf("failed to update %s: %s", k, err) | ||
return | ||
} | ||
case "rollapp_json_rpc_port": | ||
cfg := appConfigPath | ||
err := utils.UpdateFieldInToml(cfg, "json-rpc.address", v) | ||
if err != nil { | ||
pterm.Error.Printf("failed to update %s: %s", k, err) | ||
return | ||
} | ||
case "rollapp_ws_port": | ||
cfg := appConfigPath | ||
err := utils.UpdateFieldInToml(cfg, "json-rpc.ws-address", v) | ||
if err != nil { | ||
pterm.Error.Printf("failed to update %s: %s", k, err) | ||
return | ||
} | ||
case "settlement_node_address": | ||
cfg := dymintConfigPath | ||
err := utils.UpdateFieldInToml(cfg, "settlement_node_address", v) | ||
if err != nil { | ||
pterm.Error.Printf("failed to update %s: %s", k, err) | ||
return | ||
} | ||
case "da_node_address": | ||
// Handle da_node_address | ||
fmt.Printf("Setting DA node address to: %s\n", v) | ||
// Add your logic here | ||
default: | ||
pterm.Error.Printf("unknown configuration key: %s\n", k) | ||
return | ||
} | ||
|
||
pterm.Info.Println("next steps:") | ||
pterm.Info.Println("if this was the only configuration value you wanted to update") | ||
pterm.Info.Printf( | ||
"run %s to restart the systemd services and apply the new values\n", | ||
pterm.DefaultBasicText.WithStyle(pterm.FgYellow.ToStyle()). | ||
Sprintf("roller rollapp services restart"), | ||
) | ||
}, | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package show | ||
|
||
import ( | ||
"github.com/pterm/pterm" | ||
"github.com/spf13/cobra" | ||
|
||
cmdutils "github.com/dymensionxyz/roller/cmd/utils" | ||
configutils "github.com/dymensionxyz/roller/utils/config" | ||
) | ||
|
||
func Cmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "show", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
home := cmd.Flag(cmdutils.FlagNames.Home).Value.String() | ||
|
||
err := configutils.ShowCurrentConfigurableValues(home) | ||
if err != nil { | ||
pterm.Error.Println("failed to retrieve configurable values: ", err) | ||
return | ||
} | ||
}, | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package restart | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
"strings" | ||
|
||
"github.com/pterm/pterm" | ||
"github.com/spf13/cobra" | ||
|
||
servicemanager "github.com/dymensionxyz/roller/utils/service_manager" | ||
) | ||
|
||
func RollappCmd() *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) | ||
return | ||
} | ||
}, | ||
} | ||
return cmd | ||
} | ||
|
||
func restartSystemdServices(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 start %s systemd service: %v", service, err) | ||
} | ||
} | ||
pterm.Success.Printf( | ||
"💈 Services %s started successfully.\n", | ||
strings.Join(services, ", "), | ||
) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.