5

I understand the entire path of a parachain block upto and including its candidateReciept being "included" on the relaychain, and its erasure coded PoVs being available with the relaychain validators - incase the parent block's collator fails to share the block.

What I do not understand is how does the subsequent collator know which is the block (or rather the hash) that it should build on?

Does the collator attempt to read the relaychain state to find the latest parchain block hash in the parachain relevant storage (the ones that are updated upon candidateReceipt inclusion) either explicitly or implicitly? Does it read the relaychain blocks for it? Does it somehow depend on the relaychain validators for this info?

Also, at what point is this info apparent to the collator?

Further, and very importantly, once a collator has recognized which parachain parent block to build on and then imported it, we can consider the parachain parent block to be "finalized", right? Save for relaychain re-orgs that is.

I would greatly appreciate if this were to be pointed out in code as well.

Thank you very much!!

2 Answers 2

1

All parachain nodes are required to follow the relay chain they are connected to as well. By following I mean to know about which relay chain blocks are being imported/finalized. To follow the relay chain a parachain node needs to be connected to a relay chain node. When using Cumulus there are multiple ways, like using the included relay chain node or using a relay chain node connected via RPC or a light client.

To find out what is the best parachain block to build on, the parachain node will use the best relay chain block and read the state of this block. In the state of this relay chain block there is the parachain header stored and this header defines the parachain block "assigned" to this relay chain block. The same applies then to find out what is the last finalized parachain block.

Collators are currently building on all the relay chain blocks they are "seeing". The blocks they are building on are not required to be finalized.

3
  • Thank you for the answer! Could you also please tell us if and how a collator can easily know if a certain relaychain block (or even better the relaychain block that contained the candidate receipt for a given parachain block) has been finalized on the relaychain by GRANDPA Apr 19 at 13:26
  • This information is put in the justification which can be found in a new block. Apr 19 at 15:35
  • The collator is trusting the relay chain node. This also means that your collator should not be connected to any random relay chain node as there are no further checks being done. The relay chain node itself is then running grandpa to finalize blocks or by importing justifications when doing a major syncing.
    – bkchr
    Apr 20 at 8:24
1

A collator consists of a relay chain node and a parachain node. One of the reasons is because it needs to communicate with the relay chain nodes (networking) to be in sync with the chain. In other words, be updated about the latest changes to the state (updates about latest (finalized) blocks).

The relay chain state stores the latest head-data, also known as parahead, of each registered parachain (ref). When a collator (polkadot node side of things) receives a new best/finalized block, it can simply see which latest parahead was added to the state of the relay chain.

Regarding finality, when a relay chain block is finalized. It means that the parachain block which was added in that block, as well as it ascendants, are finalized as well.

This brings us to polkadot's shared security. The parachain's finalized state is guaranteed on the relay chain. More specifically, information regarding a parachain block, whether it is included, reverted or finalized, is acquired from the relay chain

1
  • Thanks a lot! Could you also please point out where in the cumulus code this head-data is being read? Also, are there apis in the parachain node to easily query relaychain storage? Apr 19 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.