Skip to content

Commit

Permalink
fix: celestia node to v0.20.0-mocha
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs committed Nov 15, 2024
1 parent 19473c7 commit 4501ac7
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 30 deletions.
3 changes: 3 additions & 0 deletions cmd/da-light-client/da_light_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/spf13/cobra"

da_start "github.com/dymensionxyz/roller/cmd/da-light-client/start"
"github.com/dymensionxyz/roller/cmd/da-light-client/update"
)

func DALightClientCmd() *cobra.Command {
Expand All @@ -12,5 +13,7 @@ func DALightClientCmd() *cobra.Command {
Short: "Commands for running and managing the data availability light client.",
}
cmd.AddCommand(da_start.Cmd())
cmd.AddCommand(update.Cmd())

return cmd
}
55 changes: 55 additions & 0 deletions cmd/da-light-client/update/update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package update

import (
"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/dymensionxyz/roller/utils/dependencies"
servicemanager "github.com/dymensionxyz/roller/utils/service_manager"
)

const (
rpcEndpointFlag = "rpc-endpoint"
metricsEndpointFlag = "metrics-endpoint"
)

func Cmd() *cobra.Command {
runCmd := &cobra.Command{
Use: "update",
Short: "Runs the DA light client.",
Run: func(cmd *cobra.Command, args []string) {
pterm.Info.Println("stopping existing system services, if any...")
err := servicemanager.StopSystemServices([]string{"da-light-client"})
if err != nil {
pterm.Error.Println("failed to stop system services: ", err)
return
}

dep := dependencies.DefaultCelestiaNodeDependency()
err = dependencies.InstallBinaryFromRepo(
dep, dep.DependencyName,
)
if err != nil {
pterm.Error.Println("failed to install binary: ", err)
return
}

pterm.Info.Println("stopping existing system services, if any...")
err = servicemanager.Start([]string{"da-light-client"})
if err != nil {
pterm.Error.Println("failed to stop system services: ", err)
return
}
},
}

addFlags(runCmd)
return runCmd
}

func addFlags(cmd *cobra.Command) {
cmd.Flags().
StringP(rpcEndpointFlag, "", "mocha-4-consensus.mesa.newmetric.xyz", "The DA rpc endpoint to connect to.")
cmd.Flags().
StringP(metricsEndpointFlag, "", "", "The OTEL collector metrics endpoint to connect to.")
}
2 changes: 1 addition & 1 deletion cmd/rollapp/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func Cmd() *cobra.Command {
}
}

err = servicemanager.StopSystemServices()
err = servicemanager.StopSystemServices(consts.RollappSystemdServices)
if err != nil {
pterm.Error.Println("failed to stop system services: ", err)
return
Expand Down
1 change: 0 additions & 1 deletion cmd/services/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ func EibcCmd() *cobra.Command {
)
}
}()

},
}
return cmd
Expand Down
41 changes: 41 additions & 0 deletions utils/dependencies/celestia.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package dependencies

import (
"os/exec"

"github.com/dymensionxyz/roller/cmd/consts"
"github.com/dymensionxyz/roller/utils/dependencies/types"
)

const (
DefaultCelestiaNodeVersion = "v0.20.0-mocha"
DefaultCelestiaAppVersion = "v2.3.1"
)

func DefaultCelestiaNodeDependency() types.Dependency {
return types.Dependency{
DependencyName: "celestia",
RepositoryOwner: "celestiaorg",
RepositoryName: "celestia-node",
RepositoryUrl: "https://github.com/celestiaorg/celestia-node.git",
Release: DefaultCelestiaNodeVersion,
Binaries: []types.BinaryPathPair{
{
Binary: "./build/celestia",
BinaryDestination: consts.Executables.Celestia,
BuildCommand: exec.Command(
"make",
"build",
),
},
{
Binary: "./cel-key",
BinaryDestination: consts.Executables.CelKey,
BuildCommand: exec.Command(
"make",
"cel-key",
),
},
},
}
}
6 changes: 5 additions & 1 deletion utils/dependencies/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func InstallBinaries(withMockDA bool, raResp rollapp.ShowRollappResponse) (
if !withMockDA {
rbi := NewRollappBinaryInfo(
raResp.Rollapp.GenesisInfo.Bech32Prefix,
raResp.Rollapp.GenesisInfo.NativeDenom.Base,
raBinCommit,
raVmType,
)

Expand Down Expand Up @@ -273,6 +273,10 @@ func InstallBinaryFromRelease(dep types.Dependency) error {
goArch = "x86_64"
}

if goArch == "amd64" && dep.DependencyName == "celestia-node" {
goArch = "x86_64"
}

targetDir, err := os.MkdirTemp(os.TempDir(), dep.DependencyName)
if err != nil {
// nolint: errcheck,gosec
Expand Down
26 changes: 1 addition & 25 deletions utils/dependencies/rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,7 @@ func NewRollappBinaryInfo(bech32Prefix, commit, vmType string) RollappBinaryInfo
func DefaultRollappBuildableDependencies(raBinInfo RollappBinaryInfo) map[string]types.Dependency {
deps := map[string]types.Dependency{}

deps["celestia"] = types.Dependency{
DependencyName: "celestia",
RepositoryOwner: "celestiaorg",
RepositoryName: "celestia-node",
RepositoryUrl: "https://github.com/celestiaorg/celestia-node.git",
Release: "v0.18.2-mocha",
Binaries: []types.BinaryPathPair{
{
Binary: "./build/celestia",
BinaryDestination: consts.Executables.Celestia,
BuildCommand: exec.Command(
"make",
"build",
),
},
{
Binary: "./cel-key",
BinaryDestination: consts.Executables.CelKey,
BuildCommand: exec.Command(
"make",
"cel-key",
),
},
},
}
deps["celestia"] = DefaultCelestiaNodeDependency()

switch raBinInfo.VMType {
case "evm":
Expand Down
32 changes: 30 additions & 2 deletions utils/service_manager/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os/exec"
"path/filepath"
"runtime"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -121,6 +122,33 @@ func (s *ServiceConfig) RunServiceWithRestart(name string, options ...bash.Comma
}()
}

func Start(services []string) error {
pterm.Info.Println("starting existing system services, if any...")
switch runtime.GOOS {
case "linux":
for _, svc := range services {
err := StartSystemdService(svc)
if err != nil {
return fmt.Errorf("failed to start %s systemd service: %v", svc, err)
}
}
case "darwin":
for _, svc := range services {
err := StartLaunchctlService(svc)
if err != nil {
return fmt.Errorf("failed to start %s systemd service: %v", svc, err)
}
}
default:
pterm.Error.Printf("unsupported platform: %s", runtime.GOOS)
}
pterm.Success.Printf(
"💈 Services %s started successfully.\n",
strings.Join(services, ", "),
)
return nil
}

func StartSystemdService(serviceName string) error {
cmd := exec.Command("sudo", "systemctl", "start", serviceName)

Expand Down Expand Up @@ -221,11 +249,11 @@ func StopLaunchdService(serviceName string) error {
return nil
}

func StopSystemServices() error {
func StopSystemServices(services []string) error {
pterm.Info.Println("stopping existing system services, if any...")
switch runtime.GOOS {
case "linux":
for _, svc := range consts.RollappSystemdServices {
for _, svc := range services {
err := StopSystemdService(svc)
if err != nil {
pterm.Error.Println("failed to stop systemd service: ", err)
Expand Down

0 comments on commit 4501ac7

Please sign in to comment.