Skip to content

Commit

Permalink
rever block sync logic
Browse files Browse the repository at this point in the history
  • Loading branch information
blindchaser committed Oct 28, 2024
1 parent e007e86 commit d80b3c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/blocksync/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,12 @@ func (pool *BlockPool) SetPeerRange(peerID types.NodeID, base int64, height int6
pool.mtx.Lock()
defer pool.mtx.Unlock()

blockSyncPeers := pool.peerManager.GetBlockSyncPeers()
if len(blockSyncPeers) > 0 && !blockSyncPeers[peerID] {
pool.logger.Info(fmt.Sprintf("Skip adding peer %s for blocksync, num of blocksync peers: %d, num of pool peers: %d", peerID, len(blockSyncPeers), len(pool.peers)))
return
}

peer := pool.peers[peerID]
if peer != nil {
peer.base = base
Expand Down
4 changes: 4 additions & 0 deletions internal/state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,17 @@ func (blockExec *BlockExecutor) ApplyBlock(
defer commitSpan.End()
}
// Lock mempool, commit app state, update mempoool.
commitStart := time.Now()
retainHeight, err := blockExec.Commit(ctx, state, block, fBlockRes.TxResults)
if err != nil {
return state, fmt.Errorf("commit failed for application: %w", err)
}
if commitSpan != nil {
commitSpan.End()
}
if time.Since(commitStart) > 1000*time.Millisecond {
blockExec.logger.Info("Commit in blockExec took %s for height %d\n", time.Since(commitStart), block.Height)
}

// Update evpool with the latest state.
blockExec.evpool.Update(ctx, state, block.Evidence)
Expand Down

0 comments on commit d80b3c9

Please sign in to comment.