diff --git a/chia/full_node/full_node.py b/chia/full_node/full_node.py index 5c4238deed9c..f75bf72b3604 100644 --- a/chia/full_node/full_node.py +++ b/chia/full_node/full_node.py @@ -1102,6 +1102,9 @@ async def validate_block_batches( ) -> None: fork_info: Optional[ForkInfo] = None + block_rate = 0 + block_rate_time = time.monotonic() + block_rate_height = -1 while True: res: Optional[Tuple[WSChiaConnection, List[FullBlock]]] = await inner_batch_queue.get() if res is None: @@ -1111,6 +1114,9 @@ async def validate_block_batches( start_height = blocks[0].height end_height = blocks[-1].height + if block_rate_height == -1: + block_rate_height = start_height + # in case we're validating a reorg fork (i.e. not extending the # main chain), we need to record the coin set from that fork in # fork_info. Otherwise validation is very expensive, especially @@ -1142,7 +1148,13 @@ async def validate_block_batches( if success is False: await peer.close(600) raise ValueError(f"Failed to validate block batch {start_height} to {end_height}") - self.log.info(f"Added blocks {start_height} to {end_height}") + if end_height - block_rate_height > 100: + now = time.monotonic() + block_rate = int((end_height - block_rate_height) // (now - block_rate_time)) + block_rate_time = now + block_rate_height = end_height + + self.log.info(f"Added blocks {start_height} to {end_height} ({block_rate} blocks/s)") peak = self.blockchain.get_peak() if state_change_summary is not None: assert peak is not None