> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monad.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Blocksync

> 用于同步缺失区块的机制

## 概要

Blocksync 是节点用于获取缺失区块的机制。当观察到引用未知区块的法定人数证书 (Quorum Certificate) 时,该区块被视为缺失。

节点可能在以下两种场景中缺失区块:

1. 节点完成 statesync 之后,其本地区块高度已足够接近网络最新区块。
2. 在正常共识运行期间,节点未收到足够的 RaptorCast 数据块以解码该区块。这可能是由于数据包丢失或网络分区导致的。

## Blocksync 流程

1. 发起一次头部请求,请求以 `last_block_id` 开始的 `num_blocks` 个区块范围。
2. 收到 `num_blocks` 个头部构成的链,形成一条可加密验证的、回溯到 `last_block_` 的链。
3. 对于收到的 `num_blocks` 个头部中的每一个,并发发起(达到最大并发因子)包含头部中 `body_id` 的主体请求。
4. 每个主体响应可以通过与对应头部的 `body_id` 比较进行加密验证。

<img src="https://mintcdn.com/monadfoundation-40611fb6/asJraP9TfdYeo6NL/static/img/monad-arch/consensus/blocksync/blocksync_procedure.svg?fit=max&auto=format&n=asJraP9TfdYeo6NL&q=85&s=8465b71b6acee6b5248e42e1b691047b" alt="Blocksync procedure" width="656" height="1281" data-path="static/img/monad-arch/consensus/blocksync/blocksync_procedure.svg" />
