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
7 changes: 1 addition & 6 deletions p2p/kademlia/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,7 @@ func (s *DHT) ConfigureBootstrapNodes(ctx context.Context, bootstrapNodes string
}

// Extract IP from the address (remove port if present)
var ip string
if idx := strings.LastIndex(latestIP, ":"); idx != -1 {
ip = latestIP[:idx]
} else {
ip = latestIP
}
ip := parseSupernodeAddress(latestIP)

// Use p2p_port from supernode record
p2pPort := defaultSuperNodeP2PPort
Expand Down
4 changes: 4 additions & 0 deletions sdk/config/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package config

// DefaultSupernodePort is the default port used for supernode gRPC connections
const DefaultSupernodePort = "4444"
10 changes: 7 additions & 3 deletions sdk/net/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/LumeraProtocol/supernode/v2/pkg/net/grpc/client"
"github.com/LumeraProtocol/supernode/v2/sdk/adapters/lumera"
"github.com/LumeraProtocol/supernode/v2/sdk/adapters/supernodeservice"
"github.com/LumeraProtocol/supernode/v2/sdk/config"
"github.com/LumeraProtocol/supernode/v2/sdk/log"

"github.com/cosmos/cosmos-sdk/crypto/keyring"
Expand Down Expand Up @@ -64,13 +65,16 @@ func NewSupernodeClient(ctx context.Context, logger log.Logger, keyring keyring.
return nil, fmt.Errorf("failed to create credentials: %w", err)
}

// Append default port to the IP address from blockchain
endpointWithPort := fmt.Sprintf("%s:%s", targetSupernode.GrpcEndpoint, config.DefaultSupernodePort)

// Format connection address with identity for secure connection
targetAddress := ltc.FormatAddressWithIdentity(
targetSupernode.CosmosAddress,
targetSupernode.GrpcEndpoint,
endpointWithPort,
)

logger.Info(ctx, "Connecting to supernode securely", "endpoint", targetSupernode.GrpcEndpoint, "target_id", targetSupernode.CosmosAddress, "local_id", factoryConfig.LocalCosmosAddress, "peer_type", factoryConfig.PeerType)
logger.Info(ctx, "Connecting to supernode securely", "endpoint", endpointWithPort, "target_id", targetSupernode.CosmosAddress, "local_id", factoryConfig.LocalCosmosAddress, "peer_type", factoryConfig.PeerType)

// Use provided client options or defaults
options := clientOptions
Expand All @@ -87,7 +91,7 @@ func NewSupernodeClient(ctx context.Context, logger log.Logger, keyring keyring.
targetSupernode.CosmosAddress, err)
}

logger.Info(ctx, "Connected to supernode securely", "address", targetSupernode.CosmosAddress, "endpoint", targetSupernode.GrpcEndpoint)
logger.Info(ctx, "Connected to supernode securely", "address", targetSupernode.CosmosAddress, "endpoint", endpointWithPort)

// Create service clients
cascadeClient := supernodeservice.NewCascadeAdapter(
Expand Down
2 changes: 1 addition & 1 deletion tests/system/config.test-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
supernode:
key_name: "testkey1"
identity: "lumera1em87kgrvgttrkvuamtetyaagjrhnu3vjy44at4"
host: "0.0.0.0"
host: "127.0.0.1"
port: 4444
gateway_port: 8002

Expand Down
8 changes: 4 additions & 4 deletions tests/system/config.test-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
supernode:
key_name: "testkey2"
identity: "lumera1cf0ms9ttgdvz6zwlqfty4tjcawhuaq69p40w0c"
host: "0.0.0.0"
port: 4446
gateway_port: 8003
host: "127.0.0.2"
port: 4444
gateway_port: 8002

# Keyring Configuration
keyring:
Expand All @@ -15,7 +15,7 @@ keyring:

# P2P Network Configuration
p2p:
port: 4447
port: 4445
data_dir: "data/p2p"

# Lumera Chain Configuration
Expand Down
8 changes: 4 additions & 4 deletions tests/system/config.test-3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
supernode:
key_name: "testkey3"
identity: "lumera1cjyc4ruq739e2lakuhargejjkr0q5vg6x3d7kp"
host: "0.0.0.0"
port: 4448
gateway_port: 8004
host: "127.0.0.3"
port: 4444
gateway_port: 8002

# Keyring Configuration
keyring:
Expand All @@ -15,7 +15,7 @@ keyring:

# P2P Network Configuration
p2p:
port: 4449
port: 4445
data_dir: "data/p2p"

# Lumera Chain Configuration
Expand Down
12 changes: 6 additions & 6 deletions tests/system/e2e_cascade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestCascadeE2E(t *testing.T) {
t.Log("Registering multiple supernodes to process requests")

// Helper function to register a supernode
registerSupernode := func(nodeKey string, port string, addr string, p2pPort string) {
registerSupernode := func(nodeKey string, ipAddr string, addr string, p2pPort string) {
// Get account and validator addresses for registration
accountAddr := cli.GetKeyAddr(nodeKey)
valAddrOutput := cli.Keys("keys", "show", nodeKey, "--bech", "val", "-a")
Expand All @@ -99,7 +99,7 @@ func TestCascadeE2E(t *testing.T) {
registerCmd := []string{
"tx", "supernode", "register-supernode",
valAddr,
"localhost:" + port,
ipAddr,
addr,
"--p2p-port", p2pPort,
"--from", nodeKey,
Expand All @@ -112,10 +112,10 @@ func TestCascadeE2E(t *testing.T) {
sut.AwaitNextBlock(t)
}

// Register three supernodes with different ports
registerSupernode("node0", "4444", "lumera1em87kgrvgttrkvuamtetyaagjrhnu3vjy44at4", "4445")
registerSupernode("node1", "4446", "lumera1cf0ms9ttgdvz6zwlqfty4tjcawhuaq69p40w0c", "4447")
registerSupernode("node2", "4448", "lumera1cjyc4ruq739e2lakuhargejjkr0q5vg6x3d7kp", "4449")
// Register three supernodes with different IP addresses
registerSupernode("node0", "127.0.0.1", "lumera1em87kgrvgttrkvuamtetyaagjrhnu3vjy44at4", "4445")
registerSupernode("node1", "127.0.0.2", "lumera1cf0ms9ttgdvz6zwlqfty4tjcawhuaq69p40w0c", "4447")
registerSupernode("node2", "127.0.0.3", "lumera1cjyc4ruq739e2lakuhargejjkr0q5vg6x3d7kp", "4449")
t.Log("Successfully registered three supernodes")

// Fund Lume
Expand Down