github.com/vipernet-xyz/tm@v0.34.24/spec/p2p/messages/state-sync.md (about)

     1  ---
     2  order: 5
     3  ---
     4  
     5  # State Sync
     6  
     7  ## Channels
     8  
     9  State sync has four distinct channels. The channel identifiers are listed below.
    10  
    11  | Name              | Number |
    12  |-------------------|--------|
    13  | SnapshotChannel   | 96     |
    14  | ChunkChannel      | 97     |
    15  | LightBlockChannel | 98     |
    16  | ParamsChannel     | 99     |
    17  
    18  ## Message Types
    19  
    20  ### SnapshotRequest
    21  
    22  When a new node begin state syncing, it will ask all peers it encounters if it has any
    23  available snapshots:
    24  
    25  | Name     | Type   | Description | Field Number |
    26  |----------|--------|-------------|--------------|
    27  
    28  ### SnapShotResponse
    29  
    30  The receiver will query the local ABCI application via `ListSnapshots`, and send a message
    31  containing snapshot metadata (limited to 4 MB) for each of the 10 most recent snapshots: and stored at the application layer. When a peer is starting it will request snapshots.  
    32  
    33  | Name     | Type   | Description                                               | Field Number |
    34  |----------|--------|-----------------------------------------------------------|--------------|
    35  | height   | uint64 | Height at which the snapshot was taken                    | 1            |
    36  | format   | uint32 | Format of the snapshot.                                   | 2            |
    37  | chunks   | uint32 | How many chunks make up the snapshot                      | 3            |
    38  | hash     | bytes  | Arbitrary snapshot hash                                   | 4            |
    39  | metadata | bytes  | Arbitrary application data. **May be non-deterministic.** | 5            |
    40  
    41  ### ChunkRequest
    42  
    43  The node running state sync will offer these snapshots to the local ABCI application via
    44  `OfferSnapshot` ABCI calls, and keep track of which peers contain which snapshots. Once a snapshot
    45  is accepted, the state syncer will request snapshot chunks from appropriate peers:
    46  
    47  | Name   | Type   | Description                                                 | Field Number |
    48  |--------|--------|-------------------------------------------------------------|--------------|
    49  | height | uint64 | Height at which the chunk was created                       | 1            |
    50  | format | uint32 | Format chosen for the chunk.  **May be non-deterministic.** | 2            |
    51  | index  | uint32 | Index of the chunk within the snapshot.                     | 3            |
    52  
    53  ### ChunkResponse
    54  
    55  The receiver will load the requested chunk from its local application via `LoadSnapshotChunk`,
    56  and respond with it (limited to 16 MB):
    57  
    58  | Name    | Type   | Description                                                 | Field Number |
    59  |---------|--------|-------------------------------------------------------------|--------------|
    60  | height  | uint64 | Height at which the chunk was created                       | 1            |
    61  | format  | uint32 | Format chosen for the chunk.  **May be non-deterministic.** | 2            |
    62  | index   | uint32 | Index of the chunk within the snapshot.                     | 3            |
    63  | hash    | bytes  | Arbitrary snapshot hash                                     | 4            |
    64  | missing | bool   | Arbitrary application data. **May be non-deterministic.**   | 5            |
    65  
    66  Here, `Missing` is used to signify that the chunk was not found on the peer, since an empty
    67  chunk is a valid (although unlikely) response.
    68  
    69  The returned chunk is given to the ABCI application via `ApplySnapshotChunk` until the snapshot
    70  is restored. If a chunk response is not returned within some time, it will be re-requested,
    71  possibly from a different peer.
    72  
    73  The ABCI application is able to request peer bans and chunk refetching as part of the ABCI protocol.
    74  
    75  ### LightBlockRequest
    76  
    77  To verify state and to provide state relevant information for consensus, the node will ask peers for
    78  light blocks at specified heights.
    79  
    80  | Name     | Type   | Description                | Field Number |
    81  |----------|--------|----------------------------|--------------|
    82  | height   | uint64 | Height of the light block  | 1            |
    83  
    84  ### LightBlockResponse
    85  
    86  The receiver will retrieve and construct the light block from both the block and state stores. The
    87  receiver will verify the data by comparing the hashes and store the header, commit and validator set
    88  if necessary. The light block at the height of the snapshot will be used to verify the `AppHash`.
    89  
    90  | Name          | Type                                                    | Description                          | Field Number |
    91  |---------------|---------------------------------------------------------|--------------------------------------|--------------|
    92  | light_block   | [LightBlock](../../core/data_structures.md#lightblock)  | Light block at the height requested  | 1            |
    93  
    94  State sync will use [light client verification](../../light-client/verification.README.md) to verify
    95  the light blocks.
    96  
    97  
    98  If no state sync is in progress (i.e. during normal operation), any unsolicited response messages
    99  are discarded.
   100  
   101  ### ParamsRequest
   102  
   103  In order to build tendermint state, the state provider will request the params at the height of the snapshot and use the header to verify it.
   104  
   105  | Name     | Type   | Description                | Field Number |
   106  |----------|--------|----------------------------|--------------|
   107  | height   | uint64 | Height of the consensus params  | 1            |
   108  
   109  
   110  ### ParamsResponse
   111  
   112  A reciever to the request will use the state store to fetch the consensus params at that height and return it to the sender.
   113  
   114  | Name     | Type   | Description                     | Field Number |
   115  |----------|--------|---------------------------------|--------------|
   116  | height   | uint64 | Height of the consensus params  | 1            |
   117  | consensus_params | [ConsensusParams](../../core/data_structures.md#ConsensusParams) | Consensus params at the height requested | 2 |
   118  
   119  
   120  ### Message
   121  
   122  Message is a [`oneof` protobuf type](https://developers.google.com/protocol-buffers/docs/proto#oneof). The `oneof` consists of eight messages.
   123  
   124  | Name                 | Type                                       | Description                                  | Field Number |
   125  |----------------------|--------------------------------------------|----------------------------------------------|--------------|
   126  | snapshots_request    | [SnapshotRequest](#snapshotrequest)        | Request a recent snapshot from a peer        | 1            |
   127  | snapshots_response   | [SnapshotResponse](#snapshotresponse)      | Respond with the most recent snapshot stored | 2            |
   128  | chunk_request        | [ChunkRequest](#chunkrequest)              | Request chunks of the snapshot.              | 3            |
   129  | chunk_response       | [ChunkRequest](#chunkresponse)             | Response of chunks used to recreate state.   | 4            |
   130  | light_block_request  | [LightBlockRequest](#lightblockrequest)    | Request a light block.                       | 5            |
   131  | light_block_response | [LightBlockResponse](#lightblockresponse)  | Respond with a light block                   | 6            |
   132  | params_request  | [ParamsRequest](#paramsrequest)    | Request the consensus params at a height.                       | 7            |
   133  | params_response | [ParamsResponse](#paramsresponse)  | Respond with the consensus params                   | 8            |