Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
srene committed Nov 21, 2024
1 parent bd6ddd1 commit 4680773
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand Down
29 changes: 14 additions & 15 deletions p2p/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion p2p/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 4680773

Please sign in to comment.