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

Fix bootstrapping warn log #3156

Merged
merged 7 commits into from
Jun 28, 2024
Merged
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
47 changes: 26 additions & 21 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ type Node struct {
// Specifies how much disk usage each peer can cause before
// we rate-limit them.
diskTargeter tracker.Targeter

// Closed when a sufficient amount of bootstrap nodes are connected to
onSufficientlyConnected chan struct{}
}

/*
Expand Down Expand Up @@ -596,36 +599,19 @@ func (n *Node) initNetworking(reg prometheus.Registerer) error {
}
}

n.onSufficientlyConnected = make(chan struct{})
numBootstrappers := n.bootstrappers.Count(constants.PrimaryNetworkID)
requiredConns := (3*numBootstrappers + 3) / 4

if requiredConns > 0 {
onSufficientlyConnected := make(chan struct{})
consensusRouter = &beaconManager{
Router: consensusRouter,
beacons: n.bootstrappers,
requiredConns: int64(requiredConns),
onSufficientlyConnected: onSufficientlyConnected,
onSufficientlyConnected: n.onSufficientlyConnected,
}

// Log a warning if we aren't able to connect to a sufficient portion of
// nodes.
go func() {
timer := time.NewTimer(n.Config.BootstrapBeaconConnectionTimeout)
defer timer.Stop()

select {
case <-timer.C:
if n.shuttingDown.Get() {
return
}
n.Log.Warn("failed to connect to bootstrap nodes",
zap.Stringer("bootstrappers", n.bootstrappers),
zap.Duration("duration", n.Config.BootstrapBeaconConnectionTimeout),
)
case <-onSufficientlyConnected:
}
}()
} else {
close(n.onSufficientlyConnected)
}

// add node configs to network config
Expand Down Expand Up @@ -715,6 +701,25 @@ func (n *Node) Dispatch() error {
n.Shutdown(1)
})

// Log a warning if we aren't able to connect to a sufficient portion of
// nodes.
go func() {
joshua-kim marked this conversation as resolved.
Show resolved Hide resolved
joshua-kim marked this conversation as resolved.
Show resolved Hide resolved
timer := time.NewTimer(n.Config.BootstrapBeaconConnectionTimeout)
defer timer.Stop()

select {
case <-timer.C:
if n.shuttingDown.Get() {
return
}
n.Log.Warn("failed to connect to bootstrap nodes",
zap.Stringer("bootstrappers", n.bootstrappers),
zap.Duration("duration", n.Config.BootstrapBeaconConnectionTimeout),
)
case <-n.onSufficientlyConnected:
}
}()

// Add state sync nodes to the peer network
for i, peerIP := range n.Config.StateSyncIPs {
n.Net.ManuallyTrack(n.Config.StateSyncIDs[i], peerIP)
Expand Down
Loading