Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ The configuration file is located at `~/.supernode/config.yml` and contains the
supernode:
key_name: "mykey" # Name of the key for signing transactions
identity: "lumera15t2e8gjgmuqtj..." # Lumera address for this supernode
ip_address: "0.0.0.0" # IP address to bind the service
host: "0.0.0.0" # Host address to bind the service (IP or hostname)
port: 4444 # Port for the supernode service
gateway_port: 8002 # Port for the HTTP gateway service
```
Expand All @@ -373,7 +373,6 @@ keyring:
### P2P Configuration
```yaml
p2p:
listen_address: "0.0.0.0" # IP address for P2P networking
port: 4445 # P2P communication port (do not change)
data_dir: "data/p2p" # Directory for P2P data storage
```
Expand Down
135 changes: 0 additions & 135 deletions p2p/DEVDOCS.md

This file was deleted.

2 changes: 1 addition & 1 deletion supernode/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ var configCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(configCmd)
}
}
6 changes: 3 additions & 3 deletions supernode/cmd/config_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ func promptParameterSelection() (string, error) {
func updateSupernodeIP() error {
var newIP string
prompt := &survey.Input{
Message: "Enter new supernode IP address:",
Default: appConfig.SupernodeConfig.IpAddress,
Message: "Enter new supernode host address:",
Default: appConfig.SupernodeConfig.Host,
}
if err := survey.AskOne(prompt, &newIP); err != nil {
return err
}

appConfig.SupernodeConfig.IpAddress = newIP
appConfig.SupernodeConfig.Host = newIP
return saveConfig()
}

Expand Down
11 changes: 11 additions & 0 deletions supernode/cmd/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strings"

"github.com/LumeraProtocol/supernode/p2p"
"github.com/LumeraProtocol/supernode/pkg/keyring"
"github.com/LumeraProtocol/supernode/supernode/config"
cKeyring "github.com/cosmos/cosmos-sdk/crypto/keyring"
Expand Down Expand Up @@ -58,3 +59,13 @@ func isValidBIP39WordCount(wordCount int) bool {
}
return false
}

// createP2PConfig creates a P2P config from the app config and address
func createP2PConfig(config *config.Config, address string) *p2p.Config {
return &p2p.Config{
ListenAddress: config.SupernodeConfig.Host,
Port: config.P2PConfig.Port,
DataDir: config.GetP2PDataDir(),
ID: address,
}
}
2 changes: 1 addition & 1 deletion supernode/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ func createNewKey(kr consmoskeyring.Keyring, keyName string) (string, string, er
func updateAndSaveConfig(address, supernodeAddr string, supernodePort int, gatewayPort int, lumeraGrpcAddr string, chainID string) error {
// Update config with address and network settings
appConfig.SupernodeConfig.Identity = address
appConfig.SupernodeConfig.IpAddress = supernodeAddr
appConfig.SupernodeConfig.Host = supernodeAddr
appConfig.SupernodeConfig.Port = uint16(supernodePort)
appConfig.SupernodeConfig.GatewayPort = uint16(gatewayPort)
appConfig.LumeraClientConfig.GRPCAddr = lumeraGrpcAddr
Expand Down
2 changes: 1 addition & 1 deletion supernode/cmd/list_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var configListCmd = &cobra.Command{
// Display configuration parameters
fmt.Fprintf(w, "Key Name\t%s\n", appConfig.SupernodeConfig.KeyName)
fmt.Fprintf(w, "Address\t%s\n", appConfig.SupernodeConfig.Identity)
fmt.Fprintf(w, "Supernode Address\t%s\n", appConfig.SupernodeConfig.IpAddress)
fmt.Fprintf(w, "Supernode Address\t%s\n", appConfig.SupernodeConfig.Host)
fmt.Fprintf(w, "Supernode Port\t%d\n", appConfig.SupernodeConfig.Port)
fmt.Fprintf(w, "Keyring Backend\t%s\n", appConfig.KeyringConfig.Backend)
fmt.Fprintf(w, "Lumera GRPC Address\t%s\n", appConfig.LumeraClientConfig.GRPCAddr)
Expand Down
18 changes: 4 additions & 14 deletions supernode/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ import (
"github.com/spf13/cobra"
)

// createP2PConfig creates a P2P config from the app config and address
func createP2PConfig(config *config.Config, address string) *p2p.Config {
return &p2p.Config{
ListenAddress: config.P2PConfig.ListenAddress,
Port: config.P2PConfig.Port,
DataDir: config.GetP2PDataDir(),
ID: address,
}
}

// startCmd represents the start command
var startCmd = &cobra.Command{
Use: "start",
Expand Down Expand Up @@ -103,7 +93,7 @@ The supernode will connect to the Lumera network and begin participating in the

// Set the version in the status service package
supernodeService.Version = Version

// Create supernode status service
statusService := supernodeService.NewSupernodeStatusService(*p2pService, lumeraClient, appConfig)
statusService.RegisterTaskProvider(cService)
Expand All @@ -114,7 +104,7 @@ The supernode will connect to the Lumera network and begin participating in the
// Configure server
serverConfig := &server.Config{
Identity: appConfig.SupernodeConfig.Identity,
ListenAddresses: appConfig.SupernodeConfig.IpAddress,
ListenAddresses: appConfig.SupernodeConfig.Host,
Port: int(appConfig.SupernodeConfig.Port),
}

Expand All @@ -129,7 +119,7 @@ The supernode will connect to the Lumera network and begin participating in the
if gatewayPort == 0 {
gatewayPort = 8002 // Default fallback
}
gatewayServer, err := gateway.NewServer(int(gatewayPort), supernodeServer)
gatewayServer, err := gateway.NewServer(appConfig.SupernodeConfig.Host, int(gatewayPort), supernodeServer)
if err != nil {
return fmt.Errorf("failed to create gateway server: %w", err)
}
Expand Down Expand Up @@ -177,7 +167,7 @@ func initP2PService(ctx context.Context, config *config.Config, lumeraClient lum
// Create P2P config using helper function
p2pConfig := createP2PConfig(config, address.String())

logtrace.Info(ctx, "Initializing P2P service", logtrace.Fields{"listen_address": p2pConfig.ListenAddress, "port": p2pConfig.Port, "data_dir": p2pConfig.DataDir, "supernode_id": address.String()})
logtrace.Info(ctx, "Initializing P2P service", logtrace.Fields{"address": p2pConfig.ListenAddress, "port": p2pConfig.Port, "data_dir": p2pConfig.DataDir, "supernode_id": address.String()})

p2pService, err := p2p.New(ctx, p2pConfig, lumeraClient, kr, rqStore, cloud, mst)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions supernode/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
supernode:
key_name: "mykey" # Account name for the supernode in keyring
identity: "lumera1ccmw5plzuldntum2rz6kq6uq346vtrhrvwfzsa" # Identity of the supernode, lumera address
ip_address: "0.0.0.0"
host: "0.0.0.0"
port: 4444
gateway_port: 8002 # Port for the HTTP gateway

Expand All @@ -13,7 +13,6 @@ keyring:

# P2P Network Configuration
p2p:
listen_address: "0.0.0.0"
port: 4445
data_dir: "data/p2p" # P2P data directory in home folder

Expand Down
7 changes: 3 additions & 4 deletions supernode/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
type SupernodeConfig struct {
KeyName string `yaml:"key_name"`
Identity string `yaml:"identity"`
IpAddress string `yaml:"ip_address"`
Host string `yaml:"host"`
Port uint16 `yaml:"port"`
GatewayPort uint16 `yaml:"gateway_port"`
}
Expand All @@ -27,9 +27,8 @@ type KeyringConfig struct {
}

type P2PConfig struct {
ListenAddress string `yaml:"listen_address"`
Port uint16 `yaml:"port"`
DataDir string `yaml:"data_dir"`
Port uint16 `yaml:"port"`
DataDir string `yaml:"data_dir"`
}

type LumeraClientConfig struct {
Expand Down
7 changes: 3 additions & 4 deletions supernode/config/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func CreateDefaultConfig(keyName, identity, chainID string, keyringBackend, keyr
SupernodeConfig: SupernodeConfig{
KeyName: keyName,
Identity: identity,
IpAddress: "0.0.0.0",
Host: "0.0.0.0",
Port: 4444,
GatewayPort: 8002,
},
Expand All @@ -56,9 +56,8 @@ func CreateDefaultConfig(keyName, identity, chainID string, keyringBackend, keyr
PassFile: passFile,
},
P2PConfig: P2PConfig{
ListenAddress: "0.0.0.0",
Port: 4445,
DataDir: "data/p2p",
Port: 4445,
DataDir: "data/p2p",
},
LumeraClientConfig: LumeraClientConfig{
GRPCAddr: "localhost:9090",
Expand Down
11 changes: 8 additions & 3 deletions supernode/node/supernode/gateway/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package gateway
import (
"context"
"fmt"
"net"
"net/http"
"strconv"
"time"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
Expand All @@ -14,18 +16,20 @@ import (

// Server represents the HTTP gateway server
type Server struct {
ipAddress string
port int
server *http.Server
supernodeServer pb.SupernodeServiceServer
}

// NewServer creates a new HTTP gateway server that directly calls the service
func NewServer(port int, supernodeServer pb.SupernodeServiceServer) (*Server, error) {
func NewServer(ipAddress string, port int, supernodeServer pb.SupernodeServiceServer) (*Server, error) {
if supernodeServer == nil {
return nil, fmt.Errorf("supernode server is required")
}

return &Server{
ipAddress: ipAddress,
port: port,
supernodeServer: supernodeServer,
}, nil
Expand Down Expand Up @@ -66,15 +70,16 @@ func (s *Server) Run(ctx context.Context) error {

// Create HTTP server
s.server = &http.Server{
Addr: fmt.Sprintf(":%d", s.port),
Addr: net.JoinHostPort(s.ipAddress, strconv.Itoa(s.port)),
Handler: s.corsMiddleware(httpMux),
ReadTimeout: 15 * time.Second,
WriteTimeout: 15 * time.Second,
IdleTimeout: 60 * time.Second,
}

logtrace.Info(ctx, "Starting HTTP gateway server", logtrace.Fields{
"port": s.port,
"address": s.ipAddress,
"port": s.port,
})

// Start server
Expand Down
Loading