diff --git a/config/defaults.go b/config/defaults.go index b72ef3aac..9bd8e0269 100644 --- a/config/defaults.go +++ b/config/defaults.go @@ -39,7 +39,7 @@ func DefaultConfig(home string) *NodeConfig { }, P2PConfig: P2PConfig{ GossipSubCacheSize: 50, - BootstrapRetryTime: 30 * time.Second, + BootstrapRetryTime: 20 * time.Second, BlockSyncRequestIntervalTime: 30 * time.Second, ListenAddress: DefaultListenAddress, BootstrapNodes: "", diff --git a/p2p/client.go b/p2p/client.go index 50b2fa2ba..3475463ea 100644 --- a/p2p/client.go +++ b/p2p/client.go @@ -410,7 +410,7 @@ func (c *Client) setupPeerDiscovery(ctx context.Context) error { // wait for DHT select { case <-ctx.Done(): - return ctx.Err() + return nil case <-c.DHT.RefreshRoutingTable(): } c.disc = discovery.NewRoutingDiscovery(c.DHT) @@ -569,24 +569,23 @@ func (c *Client) bootstrapLoop(ctx context.Context) { ticker := time.NewTicker(c.conf.BootstrapRetryTime) defer ticker.Stop() for { - if len(c.Peers()) == 0 { - err := c.DHT.Bootstrap(ctx) - if err != nil { - c.logger.Error("Re-bootstrap DHT: %w", err) - } - } - persistentNodes := c.GetSeedAddrInfo(c.conf.PersistentNodes) - for _, peer := range persistentNodes { - found := c.findConnection(peer) - if !found { - c.tryConnect(ctx, peer) - } - } select { case <-ctx.Done(): return case <-ticker.C: - continue + if len(c.Peers()) == 0 { + err := c.DHT.Bootstrap(ctx) + if err != nil { + c.logger.Error("Re-bootstrap DHT: %w", err) + } + } + persistentNodes := c.GetSeedAddrInfo(c.conf.PersistentNodes) + for _, peer := range persistentNodes { + found := c.findConnection(peer) + if !found { + c.tryConnect(ctx, peer) + } + } } } } diff --git a/p2p/validator.go b/p2p/validator.go index 011455618..513714e4f 100644 --- a/p2p/validator.go +++ b/p2p/validator.go @@ -85,7 +85,7 @@ func (v *Validator) BlockValidator() GossipValidator { return false } if err := gossipedBlock.Validate(v.stateGetter.GetProposerPubKey()); err != nil { - v.logger.Error("Failed to validate gossiped block at P2P level.", "height", gossipedBlock.Block.Header.Height) + v.logger.Error("P2P block validation.", "height", gossipedBlock.Block.Header.Height, "err", err) return false }