-
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: Add ability to run Celestia DA light node (#71)
- Loading branch information
1 parent
3eb406f
commit eb18261
Showing
11 changed files
with
199 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package initconfig | |
import ( | ||
"os/exec" | ||
"path/filepath" | ||
|
||
"github.com/dymensionxyz/roller/cmd/consts" | ||
) | ||
|
||
|
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,15 @@ | ||
package da_light_client | ||
|
||
import ( | ||
da_start "github.com/dymensionxyz/roller/cmd/da-light-client/start" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func DALightClientCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "da-light-client", | ||
Short: "Commands for running and managing the data availability light client.", | ||
} | ||
cmd.AddCommand(da_start.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,58 @@ | ||
package start | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
"path/filepath" | ||
|
||
initconfig "github.com/dymensionxyz/roller/cmd/config/init" | ||
"github.com/dymensionxyz/roller/cmd/consts" | ||
"github.com/dymensionxyz/roller/cmd/utils" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
const rpcEndpointFlag = "--rpc-endpoint" | ||
|
||
func Cmd() *cobra.Command { | ||
runCmd := &cobra.Command{ | ||
Use: "start", | ||
Short: "Runs the rollapp sequencer.", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
home := cmd.Flag(utils.FlagNames.Home).Value.String() | ||
rollappConfig, err := initconfig.LoadConfigFromTOML(home) | ||
utils.PrettifyErrorIfExists(err) | ||
rpcEndpoint := cmd.Flag(rpcEndpointFlag).Value.String() | ||
startRollappCmd := getStartCelestiaLCCmd(rollappConfig, rpcEndpoint) | ||
utils.RunBashCmdAsync(startRollappCmd, printOutput, parseError) | ||
}, | ||
} | ||
utils.AddGlobalFlags(runCmd) | ||
addFlags(runCmd) | ||
return runCmd | ||
} | ||
|
||
func addFlags(cmd *cobra.Command) { | ||
cmd.Flags().StringP(rpcEndpointFlag, "", "consensus-full-arabica-8.celestia-arabica.com", | ||
"The DA rpc endpoint to connect to.") | ||
} | ||
|
||
func printOutput() { | ||
fmt.Println("💈 The data availability light node is running on your local machine!") | ||
fmt.Println("💈 Light node endpoint: http://127.0.0.1:26659") | ||
} | ||
|
||
func parseError(errMsg string) string { | ||
return errMsg | ||
} | ||
|
||
func getStartCelestiaLCCmd(rollappConfig initconfig.InitConfig, rpcEndpoint string) *exec.Cmd { | ||
return exec.Command( | ||
consts.Executables.Celestia, "light", "start", | ||
"--core.ip", rpcEndpoint, | ||
"--node.store", filepath.Join(rollappConfig.Home, consts.ConfigDirName.DALightNode), | ||
"--gateway", | ||
"--gateway.addr", "127.0.0.1", | ||
"--gateway.port", "26659", | ||
"--p2p.network", "arabica", | ||
) | ||
} |
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,15 @@ | ||
package sequencer | ||
|
||
import ( | ||
sequnecer_start "github.com/dymensionxyz/roller/cmd/sequencer/start" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func SequencerCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "sequencer", | ||
Short: "Commands for running and managing the RollApp sequnecer.", | ||
} | ||
cmd.AddCommand(sequnecer_start.StartCmd()) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package utils | ||
|
||
import ( | ||
"bytes" | ||
"errors" | ||
"os/exec" | ||
) | ||
|
||
func RunBashCmdAsync(cmd *exec.Cmd, printOutput func(), parseError func(errMsg string) string) { | ||
var stderr bytes.Buffer | ||
cmd.Stderr = &stderr | ||
err := cmd.Start() | ||
if err != nil { | ||
errMsg := parseError(stderr.String()) | ||
PrettifyErrorIfExists(errors.New(errMsg)) | ||
} | ||
printOutput() | ||
err = cmd.Wait() | ||
if err != nil { | ||
errMsg := parseError(stderr.String()) | ||
PrettifyErrorIfExists(errors.New(errMsg)) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,8 @@ | ||
package utils | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/fatih/color" | ||
"os" | ||
) | ||
|
||
func PrettifyErrorIfExists(err error) { | ||
|
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