Skip to content

Commit

Permalink
fix tip sync
Browse files Browse the repository at this point in the history
  • Loading branch information
jimjbrettj committed Feb 16, 2024
1 parent a785d32 commit f29f534
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 34 deletions.
17 changes: 9 additions & 8 deletions dot/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,15 @@ func (n *Node) Start() error {
// Stop stops all dot node services
func (n *Node) Stop() {
// stop all node services
n.ServiceRegistry.StopAll()
n.wg.Done()
if n.metricsServer != nil {
err := n.metricsServer.Stop()
if err != nil {
log.Errorf("cannot stop metrics server: %s", err)
}
}
panic("This is temp shutdown")
//n.ServiceRegistry.StopAll()
//n.wg.Done()
//if n.metricsServer != nil {
// err := n.metricsServer.Stop()
// if err != nil {
// log.Errorf("cannot stop metrics server: %s", err)
// }
//}
}

func (nodeBuilder) loadRuntime(config *cfg.Config, ns *runtime.NodeStorage,
Expand Down
10 changes: 5 additions & 5 deletions dot/sync/chain_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,11 @@ func (cs *chainSync) requestChainBlocks(announcedHeader, bestBlockHeader *types.
startAtBlock = announcedHeader.Number - uint(*request.Max) + 1
totalBlocks = *request.Max

logger.Infof("requesting %d blocks, descending request from #%d (%s)",
peerWhoAnnounced, gapLength, announcedHeader.Number, announcedHeader.Hash().Short())
logger.Infof("requesting %d blocks from peer: %v, descending request from #%d (%s)",
gapLength, peerWhoAnnounced, announcedHeader.Number, announcedHeader.Hash().Short())
} else {
request = network.NewBlockRequest(startingBlock, 1, network.BootstrapRequestData, network.Descending)
logger.Infof("requesting a single block #%d (%s)",
logger.Infof("requesting a single block from peer: %v with Number: #%d and Hash: (%s)",
peerWhoAnnounced, announcedHeader.Number, announcedHeader.Hash().Short())
}

Expand Down Expand Up @@ -446,8 +446,8 @@ func (cs *chainSync) requestForkBlocks(bestBlockHeader, highestFinalizedHeader,
request = network.NewBlockRequest(startingBlock, gapLength, network.BootstrapRequestData, network.Descending)
}

logger.Infof("requesting %d fork blocks, starting at #%d (%s)",
peerWhoAnnounced, gapLength, announcedHeader.Number, announcedHash.Short())
logger.Infof("requesting %d fork blocks from peer: %v starting at #%d (%s)",
gapLength, peerWhoAnnounced, announcedHeader.Number, announcedHash.Short())

resultsQueue := make(chan *syncTaskResult)
cs.workerPool.submitRequest(request, &peerWhoAnnounced, resultsQueue)
Expand Down
6 changes: 4 additions & 2 deletions dot/sync/worker_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ func (s *syncWorkerPool) submitRequest(request *network.BlockRequestMessage,

if who != nil {
syncWorker := s.workers[*who]
syncWorker.queue <- task
return
if syncWorker != nil {
syncWorker.queue <- task
return
}
}

// if the exact peer is not specified then
Expand Down
36 changes: 17 additions & 19 deletions lib/grandpa/message_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,25 @@ func (h *MessageHandler) handleMessage(from peer.ID, m GrandpaMessage) (network.
}

func (h *MessageHandler) handleNeighbourMessage(msg *NeighbourPacketV1) error {
if h.grandpa.authority {
// TODO(#2931): this is a simple hack to ensure that the neighbour messages
// sent by gossamer are being received by substrate nodes
// not intended to be production code
h.grandpa.roundLock.Lock()
neighbourMessage := &NeighbourPacketV1{
Round: h.grandpa.state.round,
SetID: h.grandpa.state.setID,
Number: uint32(h.grandpa.head.Number),
}
h.grandpa.roundLock.Unlock()

cm, err := neighbourMessage.ToConsensusMessage()
if err != nil {
return fmt.Errorf("converting neighbour message to network message: %w", err)
}

logger.Debugf("sending neighbour message: %v", neighbourMessage)
h.grandpa.network.GossipMessage(cm)
// TODO(#2931): this is a simple hack to ensure that the neighbour messages
// sent by gossamer are being received by substrate nodes
// not intended to be production code
h.grandpa.roundLock.Lock()
neighbourMessage := &NeighbourPacketV1{
Round: h.grandpa.state.round,
SetID: h.grandpa.state.setID,
Number: uint32(h.grandpa.head.Number),
}
h.grandpa.roundLock.Unlock()

cm, err := neighbourMessage.ToConsensusMessage()
if err != nil {
return fmt.Errorf("converting neighbour message to network message: %w", err)
}

logger.Debugf("sending neighbour message: %v", neighbourMessage)
h.grandpa.network.GossipMessage(cm)

currFinalized, err := h.blockState.GetFinalisedHeader(0, 0)
if err != nil {
return err
Expand Down

0 comments on commit f29f534

Please sign in to comment.