Skip to content

Latest commit

 

History

History
62 lines (27 loc) · 3.61 KB

bootstrap-catchup.md

File metadata and controls

62 lines (27 loc) · 3.61 KB

Bootstrap and catchup

Before it can start producing blocks, a node needs to reconstruct the transition frontier by querying peers for blocks of transactions. This begins with the root block and the best tip (the latest block of the chain with the highest score), followed by the contents of the blocks between the root and the best tip.

This is the initial process for new nodes that connect to the Mina network, and served as our starting point. All components involved in this process have been rewritten into Rust code.

image

After a node joins the network, discovers its peers and establishes secure connections with them, it can then query other nodes for the root block and the best tip.

For this purpose, the node utilizes remote procedure calls (RPCs) made across the P2P layer (P2P/RPCS). RPCs use strongly typed interfaces, which means that the types of requests and responses are well-defined and enforced, which can help ensure that queries are structured correctly and that the expected data is returned.

Before a node can fully participate in Mina (i.e. produce blocks that extend the blockchain), she needs to sync with other nodes in the network.

This process begins with her node bootstrapping.

To do that, a Mina node needs to:

  1. Discover her peers
  2. Query for a root (earliest known) block
  3. Query for the best tip (latest block with the highest score)
  4. Catch up with the rest of the network by querying the contents of the blocks between the root and the best tip.

For nodes to request and receive this type of information, we utilize RPC (remote procedure call) communication that is performed across the Mina P2P network. Note that in other networks, RPCs usually refer to the functionality exposed via HTTPS endpoints outside the P2P. However, in Mina, these endpoints are in GraphQL, and RPC communication is part of the Mina P2P network.

Querying for the root block.

The node queries other blocks in the network to provide her with the current root block (earliest block) of the _transition frontier _(tree-like data store containing the last k blocks). Subsequent blocks that are obtained during the catchup process are applied from this initial state determined by the root block.

Querying for the best tip

The node then makes the get_best_tip RPC which queries for the best tip, the Mina blockchain's latest block with the highest known chain strength (a scoring method Mina utilizes to determine the canonical block)

Catchup - filling in blocks between root and best tip

The node now has the root block as well as the best tip. All that remains for her to sync is to catchup the blocks between the root and the tip.

image

The node uses the RPC get_transition_chain to call peers (other nodes in the P2P network).

image

This returns a bulk set of blocks associated with a provided set of state hashes. With this information, The node can apply blocks to their staged ledger and scan state, which

reconstructs the transition frontier.

image

Once this process is complete, the node has all of the blocks required, can now sync with the network and potentially produce blocks that extend the Mina blockchain.