fix: Restore P2P connectivity by simplifying libp2p configuration

ISSUE RESOLVED: All 9 CHORUS containers were showing "0 connected peers"
and elections were completely broken with " No winner found in election"

ROOT CAUSE: During Task Execution Engine implementation, ConnectionManager
and AutoRelay configuration was added to p2p/node.go, which broke P2P
connectivity in Docker Swarm overlay networks.

SOLUTION: Reverted to simple libp2p configuration from working baseline:
- Removed connmgr.NewConnManager() setup
- Removed libp2p.ConnectionManager(connManager)
- Removed libp2p.EnableAutoRelayWithStaticRelays()
- Kept only basic libp2p.EnableRelay()

VERIFICATION: All containers now show 3-4 connected peers and elections
are fully functional with candidacy announcements and voting.

PRESERVED: All Task Execution Engine functionality (v0.5.0) remains intact

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
anthonyrawlins
2025-09-26 11:12:48 +10:00
parent 859e5e1e02
commit 9dbd361caf
2 changed files with 2 additions and 16 deletions

View File

@@ -11,7 +11,6 @@ import (
kaddht "github.com/libp2p/go-libp2p-kad-dht"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/p2p/net/connmgr"
"github.com/libp2p/go-libp2p/p2p/security/noise"
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
"github.com/multiformats/go-multiaddr"
@@ -46,26 +45,13 @@ func NewNode(ctx context.Context, opts ...Option) (*Node, error) {
listenAddrs = append(listenAddrs, ma)
}
// Create connection manager with scaling-optimized limits
connManager, err := connmgr.NewConnManager(
config.LowWatermark, // Low watermark (32)
config.HighWatermark, // High watermark (128)
connmgr.WithGracePeriod(30*time.Second), // Grace period before pruning
)
if err != nil {
cancel()
return nil, fmt.Errorf("failed to create connection manager: %w", err)
}
// Create libp2p host with security, transport, and scaling options
// Create libp2p host with security and transport options
h, err := libp2p.New(
libp2p.ListenAddrs(listenAddrs...),
libp2p.Security(noise.ID, noise.New),
libp2p.Transport(tcp.NewTCPTransport),
libp2p.DefaultMuxers,
libp2p.EnableRelay(),
libp2p.ConnectionManager(connManager), // Add connection management
libp2p.EnableAutoRelayWithStaticRelays([]peer.AddrInfo{}), // Enable AutoRelay with empty static list
)
if err != nil {
cancel()