Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve node connection resiliency #159

Merged
merged 5 commits into from
Jul 22, 2024
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
1 change: 1 addition & 0 deletions cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func run() int {
host.WithDialBackWebsocketPort(cfg.Connectivity.WebsocketDialbackPort),
host.WithWebsocket(cfg.Connectivity.Websocket),
host.WithWebsocketPort(cfg.Connectivity.WebsocketPort),
host.WithMustReachBootNodes(cfg.Connectivity.MustReachBootNodes),
}

if !cfg.Connectivity.NoDialbackPeers {
Expand Down
19 changes: 11 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ type Log struct {

// Connectivity describes the libp2p host that the node will use.
type Connectivity struct {
Address string `koanf:"address" flag:"address,a"`
Port uint `koanf:"port" flag:"port,p"`
PrivateKey string `koanf:"private-key" flag:"private-key"`
DialbackAddress string `koanf:"dialback-address" flag:"dialback-address"`
DialbackPort uint `koanf:"dialback-port" flag:"dialback-port"`
Websocket bool `koanf:"websocket" flag:"websocket,w"`
WebsocketPort uint `koanf:"websocket-port" flag:"websocket-port"`
Address string `koanf:"address" flag:"address,a"`
Port uint `koanf:"port" flag:"port,p"`
PrivateKey string `koanf:"private-key" flag:"private-key"`
DialbackAddress string `koanf:"dialback-address" flag:"dialback-address"`
DialbackPort uint `koanf:"dialback-port" flag:"dialback-port"`
Websocket bool `koanf:"websocket" flag:"websocket,w"`
WebsocketPort uint `koanf:"websocket-port" flag:"websocket-port"`
WebsocketDialbackPort uint `koanf:"websocket-dialback-port" flag:"websocket-dialback-port"`
NoDialbackPeers bool `koanf:"no-dialback-peers" flag:"no-dialback-peers"`
NoDialbackPeers bool `koanf:"no-dialback-peers" flag:"no-dialback-peers"`
MustReachBootNodes bool `koanf:"must-reach-boot-nodes" flag:"must-reach-boot-nodes"`
}

type Head struct {
Expand Down Expand Up @@ -139,6 +140,8 @@ func getFlagDescription(flag string) string {
return "memory limit (kB) for Blockless Functions"
case "no-dialback-peers":
return "start without dialing back peers from previous runs"
case "must-reach-boot-nodes":
return "halt node if we fail to reach boot nodes on start"
default:
return ""
}
Expand Down
29 changes: 24 additions & 5 deletions host/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import (

// defaultConfig used to create Host.
var defaultConfig = Config{
PrivateKey: "",
ConnectionThreshold: 20,
DialBackPeersLimit: 100,
DiscoveryInterval: 10 * time.Second,
Websocket: false,
PrivateKey: "",
ConnectionThreshold: 20,
DialBackPeersLimit: 100,
DiscoveryInterval: 10 * time.Second,
Websocket: false,
BootNodesReachabilityCheckInterval: 1 * time.Minute,
MustReachBootNodes: defaultMustReachBootNodes,
}

// Config represents the Host configuration.
Expand All @@ -33,6 +35,9 @@ type Config struct {
DialBackAddress string
DialBackPort uint
DialBackWebsocketPort uint

BootNodesReachabilityCheckInterval time.Duration
MustReachBootNodes bool
}

// WithPrivateKey specifies the private key for the Host.
Expand Down Expand Up @@ -108,3 +113,17 @@ func WithWebsocketPort(port uint) func(*Config) {
cfg.WebsocketPort = port
}
}

// WithMustReachBootNodes specifies if we should treat failure to reach boot nodes as a halting error.
func WithMustReachBootNodes(b bool) func(*Config) {
return func(cfg *Config) {
cfg.MustReachBootNodes = b
}
}

// WithBootNodesReachabilityInterval specifies how often should we recheck and reconnect to boot nodes.
func WithBootNodesReachabilityInterval(d time.Duration) func(cfg *Config) {
return func(cfg *Config) {
cfg.BootNodesReachabilityCheckInterval = d
}
}
177 changes: 0 additions & 177 deletions host/dht.go

This file was deleted.

Loading
Loading