-
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.
Implemented ability to run da light node
- Loading branch information
1 parent
825a385
commit 6b73731
Showing
11 changed files
with
248 additions
and
10 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,18 @@ | ||
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.", | ||
|
||
Run: func(cmd *cobra.Command, args []string) { | ||
}, | ||
} | ||
cmd.AddCommand(da_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
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" | ||
) | ||
|
||
func StartCmd() *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) | ||
startRollappCmd := getCelestiaCmd(rollappConfig) | ||
utils.RunBashCmdAsync(startRollappCmd, printOutput, parseError) | ||
}, | ||
} | ||
utils.AddGlobalFlags(runCmd) | ||
return runCmd | ||
} | ||
|
||
func printOutput() { | ||
fmt.Println("💈 The data availability light node is running on your local machine!") | ||
fmt.Println("💈 Light node endpoint: http://0.0.0.0:26659") | ||
} | ||
|
||
func parseError(errMsg string) string { | ||
return errMsg | ||
} | ||
|
||
func getCelestiaCmd(rollappConfig initconfig.InitConfig) *exec.Cmd { | ||
return exec.Command( | ||
consts.Executables.Celestia, "light", "start", | ||
"--core.ip", "consensus-full-arabica-8.celestia-arabica.com", | ||
"--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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package sequnecer_start | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
"path/filepath" | ||
|
||
"strings" | ||
|
||
initconfig "github.com/dymensionxyz/roller/cmd/config/init" | ||
"github.com/dymensionxyz/roller/cmd/consts" | ||
"github.com/dymensionxyz/roller/cmd/utils" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func StartCmd() *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) | ||
LightNodeEndpoint := cmd.Flag(FlagNames.DAEndpoint).Value.String() | ||
startRollappCmd := getStartRollapCmd(rollappConfig, LightNodeEndpoint) | ||
utils.RunBashCmdAsync(startRollappCmd, printOutput, parseError) | ||
}, | ||
} | ||
utils.AddGlobalFlags(runCmd) | ||
runCmd.Flags().StringP(FlagNames.DAEndpoint, "", "http://localhost:26659", "The data availability light node endpoint.") | ||
return runCmd | ||
} | ||
|
||
var FlagNames = struct { | ||
DAEndpoint string | ||
}{ | ||
DAEndpoint: "da-endpoint", | ||
} | ||
|
||
func printOutput() { | ||
fmt.Println("💈 The Rollapp sequencer is running on your local machine!") | ||
fmt.Println("💈 EVM RPC: http://0.0.0.0:8545") | ||
fmt.Println("💈 Node RPC: http://0.0.0.0:26657") | ||
fmt.Println("💈 Rest API: http://0.0.0.0:1317") | ||
} | ||
|
||
func parseError(errMsg string) string { | ||
lines := strings.Split(errMsg, "\n") | ||
if len(lines) > 0 && lines[0] == "Error: failed to initialize database: resource temporarily unavailable" { | ||
return "The Rollapp sequencer is already running. Only one sequencer can run on the machine at any given time." | ||
} | ||
return errMsg | ||
} | ||
|
||
func getStartRollapCmd(rollappConfig initconfig.InitConfig, lightNodeEndpoint string) *exec.Cmd { | ||
daConfig := fmt.Sprintf(`{"base_url": "%s", "timeout": 60000000000, "fee":20000, "gas_limit": 20000000, "namespace_id":[0,0,0,0,0,0,255,255]}`, | ||
lightNodeEndpoint) | ||
rollappConfigDir := filepath.Join(rollappConfig.Home, consts.ConfigDirName.Rollapp) | ||
|
||
// TODO: Update the gas_fees to 2000000udym before 35-c launch. | ||
settlementConfig := fmt.Sprintf(`{"node_address": "%s", "rollapp_id": "%s", "dym_account_name": "%s", "keyring_home_dir": "%s", "keyring_backend":"test", "gas_fees": "0udym"}`, rollappConfig.HubData.RPC_URL, rollappConfig.RollappID, consts.KeyNames.HubSequencer, rollappConfigDir) | ||
|
||
return exec.Command( | ||
rollappConfig.RollappBinary, "start", | ||
"--dymint.aggregator", | ||
"--json-rpc.enable", | ||
"--json-rpc.api", "eth,txpool,personal,net,debug,web3,miner", | ||
"--dymint.da_layer", "celestia", | ||
"--dymint.da_config", daConfig, | ||
"--dymint.settlement_layer", "dymension", | ||
"--dymint.settlement_config", settlementConfig, | ||
"--dymint.block_batch_size", "1200", | ||
"--dymint.namespace_id", "000000000000ffff", | ||
"--dymint.block_time", "0.2s", | ||
"--home", rollappConfigDir, | ||
"--log_level", "debug", | ||
"--log-file", filepath.Join(rollappConfigDir, "rollapp.log"), | ||
"--max-log-size", "2000", | ||
"--module-log-level-override", "", | ||
) | ||
} |
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