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:
@@ -2,7 +2,7 @@ version: "3.9"
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
chorus:
|
chorus:
|
||||||
image: anthonyrawlins/chorus:v0.5.4-p2p-fix
|
image: anthonyrawlins/chorus:v0.5.5-p2p-simple
|
||||||
|
|
||||||
# REQUIRED: License configuration (CHORUS will not start without this)
|
# REQUIRED: License configuration (CHORUS will not start without this)
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
16
p2p/node.go
16
p2p/node.go
@@ -11,7 +11,6 @@ import (
|
|||||||
kaddht "github.com/libp2p/go-libp2p-kad-dht"
|
kaddht "github.com/libp2p/go-libp2p-kad-dht"
|
||||||
"github.com/libp2p/go-libp2p/core/host"
|
"github.com/libp2p/go-libp2p/core/host"
|
||||||
"github.com/libp2p/go-libp2p/core/peer"
|
"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/security/noise"
|
||||||
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
|
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
@@ -46,26 +45,13 @@ func NewNode(ctx context.Context, opts ...Option) (*Node, error) {
|
|||||||
listenAddrs = append(listenAddrs, ma)
|
listenAddrs = append(listenAddrs, ma)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create connection manager with scaling-optimized limits
|
// Create libp2p host with security and transport options
|
||||||
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
|
|
||||||
h, err := libp2p.New(
|
h, err := libp2p.New(
|
||||||
libp2p.ListenAddrs(listenAddrs...),
|
libp2p.ListenAddrs(listenAddrs...),
|
||||||
libp2p.Security(noise.ID, noise.New),
|
libp2p.Security(noise.ID, noise.New),
|
||||||
libp2p.Transport(tcp.NewTCPTransport),
|
libp2p.Transport(tcp.NewTCPTransport),
|
||||||
libp2p.DefaultMuxers,
|
libp2p.DefaultMuxers,
|
||||||
libp2p.EnableRelay(),
|
libp2p.EnableRelay(),
|
||||||
libp2p.ConnectionManager(connManager), // Add connection management
|
|
||||||
libp2p.EnableAutoRelayWithStaticRelays([]peer.AddrInfo{}), // Enable AutoRelay with empty static list
|
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cancel()
|
cancel()
|
||||||
|
|||||||
Reference in New Issue
Block a user