diff --git a/cmd/run/services_info.go b/cmd/run/services_info.go index efbca6e4..62cd7c66 100644 --- a/cmd/run/services_info.go +++ b/cmd/run/services_info.go @@ -22,7 +22,7 @@ func NewServicesInfoTable(rollappConfig config.RollappConfig, termWidth int) *wi seq := sequencer.GetInstance(rollappConfig) table.Rows = [][]string{ {"Name", "Log File", "Ports"}, - {"Sequencer", utils.GetSequencerLogPath(rollappConfig), fmt.Sprintf("%v, 8545, 1317", seq.RPCPort)}, + {"Sequencer", utils.GetSequencerLogPath(rollappConfig), fmt.Sprintf("%v, %v, %v", seq.RPCPort, seq.JsonRPCPort, seq.APIPort)}, {"Relayer", utils.GetRelayerLogPath(rollappConfig), ""}, } diff --git a/cmd/sequencer/start/start.go b/cmd/sequencer/start/start.go index cf938add..8b8a4423 100644 --- a/cmd/sequencer/start/start.go +++ b/cmd/sequencer/start/start.go @@ -52,9 +52,9 @@ func printOutput(rlpCfg config.RollappConfig) { fmt.Println("💈 The Rollapp sequencer is running on your local machine!") fmt.Println("💈 Endpoints:") - fmt.Println("💈 EVM RPC: http://0.0.0.0:8545") + fmt.Printf("💈 EVM RPC: http://0.0.0.0:%v\n", seq.JsonRPCPort) fmt.Printf("💈 Node RPC: http://0.0.0.0:%v\n", seq.RPCPort) - fmt.Println("💈 Rest API: http://0.0.0.0:1317") + fmt.Printf("💈 Rest API: http://0.0.0.0:%v\n", seq.APIPort) fmt.Println("💈 Log file path: ", LogPath) fmt.Println("💈 Rollapp root dir: ", RollappDirPath) diff --git a/sequencer/config.go b/sequencer/config.go index 91abdace..c2c2fd6c 100644 --- a/sequencer/config.go +++ b/sequencer/config.go @@ -72,7 +72,7 @@ func updateDaConfigInToml(rlpCfg config.RollappConfig, dymintCfg *toml.Tree) err } func SetAppConfig(rlpCfg config.RollappConfig) error { - appConfigFilePath := filepath.Join(rlpCfg.Home, consts.ConfigDirName.Rollapp, "config", "app.toml") + appConfigFilePath := filepath.Join(getSequencerConfigDir(rlpCfg.Home), "app.toml") appCfg, err := toml.LoadFile(appConfigFilePath) if err != nil { return fmt.Errorf("failed to load %s: %v", appConfigFilePath, err) @@ -90,7 +90,7 @@ func SetAppConfig(rlpCfg config.RollappConfig) error { } func SetTMConfig(rlpCfg config.RollappConfig) error { - configFilePath := filepath.Join(rlpCfg.Home, consts.ConfigDirName.Rollapp, "config", "config.toml") + configFilePath := filepath.Join(getSequencerConfigDir(rlpCfg.Home), "config.toml") var tomlCfg, err = toml.LoadFile(configFilePath) if err != nil { return fmt.Errorf("failed to load %s: %v", configFilePath, err) @@ -101,18 +101,25 @@ func SetTMConfig(rlpCfg config.RollappConfig) error { return utils.WriteTomlTreeToFile(tomlCfg, configFilePath) } -func (seq *Sequencer) ReadRPCPort() (string, error) { +func (seq *Sequencer) ReadPorts() error { rpcAddr, err := seq.GetConfigValue("rpc.laddr") if err != nil { - return "", err + return err } - parts := strings.Split(rpcAddr, ":") - port := parts[len(parts)-1] - return port, nil + seq.RPCPort = getPortFromAddress(rpcAddr) + appCfg, err := toml.LoadFile(filepath.Join(getSequencerConfigDir(seq.RlpCfg.Home), "app.toml")) + if err != nil { + return err + } + jsonRpcAddr := appCfg.Get("json-rpc.address") + seq.JsonRPCPort = getPortFromAddress(fmt.Sprint(jsonRpcAddr)) + apiAddr := appCfg.Get("api.address") + seq.APIPort = getPortFromAddress(fmt.Sprint(apiAddr)) + return nil } func (seq *Sequencer) GetConfigValue(key string) (string, error) { - configFilePath := filepath.Join(seq.RlpCfg.Home, consts.ConfigDirName.Rollapp, "config", "config.toml") + configFilePath := filepath.Join(getSequencerConfigDir(seq.RlpCfg.Home), "config.toml") var tomlCfg, err = toml.LoadFile(configFilePath) if err != nil { return "", fmt.Errorf("failed to load %s: %v", configFilePath, err) @@ -127,3 +134,12 @@ func (seq *Sequencer) GetConfigValue(key string) (string, error) { func (seq *Sequencer) GetRPCEndpoint() string { return "http://localhost:" + seq.RPCPort } + +func getSequencerConfigDir(rollerHome string) string { + return filepath.Join(rollerHome, consts.ConfigDirName.Rollapp, "config") +} + +func getPortFromAddress(addr string) string { + parts := strings.Split(addr, ":") + return parts[len(parts)-1] +} diff --git a/sequencer/sequencer_manager.go b/sequencer/sequencer_manager.go index a9c44090..f7976de1 100644 --- a/sequencer/sequencer_manager.go +++ b/sequencer/sequencer_manager.go @@ -11,9 +11,11 @@ import ( ) type Sequencer struct { - RlpCfg config.RollappConfig - RPCPort string - logger *log.Logger + RlpCfg config.RollappConfig + RPCPort string + APIPort string + JsonRPCPort string + logger *log.Logger } var instance *Sequencer @@ -25,11 +27,9 @@ func GetInstance(rlpCfg config.RollappConfig) *Sequencer { logger: log.New(io.Discard, "", 0), RlpCfg: rlpCfg, } - rpcPort, err := seq.ReadRPCPort() - if err != nil { + if err := seq.ReadPorts(); err != nil { panic(err) } - seq.RPCPort = rpcPort instance = seq }) return instance