Checkpoint
Checkpoints are the most crucial part of the Matic protocol. It represents snapshots of the Bor chain state and is supposed to be attested by ⅔+ of the validator set before it is validated and submitted on the contracts deployed on Ethereum.
Types
Checkpoint structure on Heimdall state looks like following:
Root hash
RootHash
is the Merkle hash of Bor block hashes from StartBlock
to EndBlock
. Root hash for the checkpoint is created using the following way:
Pseudocode for the root hash for 1
to n
Bor blocks:
Here are some snippets of how checkpoint is created from Bor chain block headers. Source: https://github.com/maticnetwork/heimdall/blob/develop/checkpoint/types/merkel.go#L60-L114
AccountRootHash
AccountRootHash
is the hash of the validator account-related information that needs to pass to the Ethereum chain at each checkpoint.
Pseudocode for the account root hash for 1
to n
Bor blocks:
Golang code for the account hash can be found here: https://github.com/maticnetwork/heimdall/blob/develop/types/dividend-account.go#L91-L101