diff --git a/internal/blocksync/pool.go b/internal/blocksync/pool.go index 0a1f5b1eb..310f6d5e0 100644 --- a/internal/blocksync/pool.go +++ b/internal/blocksync/pool.go @@ -358,6 +358,11 @@ 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] { + return + } + peer := pool.peers[peerID] if peer != nil { peer.base = base diff --git a/internal/blocksync/reactor.go b/internal/blocksync/reactor.go index d2a5f1a73..1d85b89d4 100644 --- a/internal/blocksync/reactor.go +++ b/internal/blocksync/reactor.go @@ -258,6 +258,7 @@ func (r *Reactor) handleMessage(ctx context.Context, envelope *p2p.Envelope, blo return r.respondToPeer(ctx, msg, envelope.From, blockSyncCh) case *bcproto.BlockResponse: block, err := types.BlockFromProto(msg.Block) + fmt.Printf("[YIREN-DEBUG] Received block response from peer %s, block height: %d\n", envelope.From, block.Height) if err != nil { r.logger.Error("failed to convert block from proto", "peer", envelope.From, diff --git a/internal/state/execution.go b/internal/state/execution.go index bebac2640..b95623845 100644 --- a/internal/state/execution.go +++ b/internal/state/execution.go @@ -332,6 +332,7 @@ 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) @@ -339,6 +340,11 @@ func (blockExec *BlockExecutor) ApplyBlock( if commitSpan != nil { commitSpan.End() } + if time.Since(commitStart) > 1000*time.Millisecond { + blockExec.logger.Info("commit in blockExec", + "duration", time.Since(commitStart), + "height", block.Height) + } // Update evpool with the latest state. blockExec.evpool.Update(ctx, state, block.Evidence)