Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Set rollapp default listen addr to 0.0.0.0:26657 #345

Merged
merged 5 commits into from
Aug 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 36 additions & 18 deletions cmd/config/init/rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,56 +17,74 @@ import (

func initializeRollappConfig(initConfig config.RollappConfig) error {
home := filepath.Join(initConfig.Home, consts.ConfigDirName.Rollapp)

initRollappCmd := exec.Command(initConfig.RollappBinary, "init", consts.KeysIds.HubSequencer, "--chain-id",
initConfig.RollappID, "--home", home)
_, err := utils.ExecBashCommandWithStdout(initRollappCmd)
if err != nil {
return err
}

seqPubKey, err := utils.GetSequencerPubKey(initConfig)
if err != nil {
return err
}

setGentxCmd := exec.Command(initConfig.RollappBinary, "gentx_seq",
"--pubkey", seqPubKey, "--from", consts.KeysIds.RollappSequencer, "--keyring-backend", "test", "--home", home)
_, err = utils.ExecBashCommandWithStdout(setGentxCmd)
if err != nil {
return err
}

err = setRollappAppConfig(filepath.Join(initConfig.Home, consts.ConfigDirName.Rollapp, "config", "app.toml"),
initConfig.Denom)
if err != nil {
if err = setRollappConfig(initConfig); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad name, same as above func

setRollappAppConfig probably should call
SetDefaultDymintConfig,setAppConfig and `setTMConfig

return err
}
return nil
}

if err = sequencer.SetDefaultDymintConfig(initConfig); err != nil {
func setRollappConfig(rlpCfg config.RollappConfig) error {
if err := setAppConfig(rlpCfg); err != nil {
return err
}
if err := setTMConfig(rlpCfg); err != nil {
return err
}
if err := sequencer.SetDefaultDymintConfig(rlpCfg); err != nil {
return err
}
return nil
}

func setRollappAppConfig(appConfigFilePath string, denom string) error {
config, err := toml.LoadFile(appConfigFilePath)
func setAppConfig(rlpCfg config.RollappConfig) error {
appConfigFilePath := filepath.Join(rlpCfg.Home, consts.ConfigDirName.Rollapp, "config", "app.toml")
appCfg, err := toml.LoadFile(appConfigFilePath)
if err != nil {
return fmt.Errorf("failed to load %s: %v", appConfigFilePath, err)
}

config.Set("minimum-gas-prices", "0"+denom)
config.Set("api.enable", "true")
config.Set("rpc.laddr", "tcp://0.0.0.0:26657")
if config.Has("json-rpc") {
config.Set("json-rpc.address", "0.0.0.0:8545")
config.Set("json-rpc.ws-address", "0.0.0.0:8546")
appCfg.Set("minimum-gas-prices", "0"+rlpCfg.Denom)
appCfg.Set("api.enable", "true")

if appCfg.Has("json-rpc") {
appCfg.Set("json-rpc.address", "0.0.0.0:8545")
appCfg.Set("json-rpc.ws-address", "0.0.0.0:8546")
}
file, err := os.Create(appConfigFilePath)
return writeTomlTreeToFile(appCfg, appConfigFilePath)
}

func setTMConfig(rlpCfg config.RollappConfig) error {
configFilePath := filepath.Join(rlpCfg.Home, consts.ConfigDirName.Rollapp, "config", "config.toml")
var tomlCfg, err = toml.LoadFile(configFilePath)
if err != nil {
return fmt.Errorf("failed to load %s: %v", configFilePath, err)
}
tomlCfg.Set("rpc.laddr", "tcp://0.0.0.0:26657")
return writeTomlTreeToFile(tomlCfg, configFilePath)
}

func writeTomlTreeToFile(tomlConfig *toml.Tree, path string) error {
file, err := os.Create(path)
if err != nil {
return err
}
_, err = file.WriteString(config.String())
_, err = file.WriteString(tomlConfig.String())
if err != nil {
return err
}
Expand Down