bor module is responsible for managing span intervals and coordinating interactions with the Bor chain. Specifically, it determines when a new span can be proposed on Heimdall based on the current block number and the current span.
Preliminary terminology
- A
side-transactionis a normal heimdall transaction but the data with which the message is composed needs to be voted on by the validators since the data is obscure to the consensus protocol itself, and it has no way of validating the data’s correctness. - A
sprintcomprises of 16 bor blocks (configured in bor). - A
spancomprises 400 sprints in bor (check heimdall’s bor params endpoint).
Overview
The validators on the bor chain produce blocks in sprints and spans. Hence, it is imperative for the protocol to formalize the validators who will be producers in a range of blocks (span). The bor module in heimdall facilitates this by pseudo-randomly selecting validators who will producing blocks (producers) from the current validator set. The bor chain fetches and persists this information before the next span begins. bor module is a crucial component in heimdall since the PoS chain “liveness” depends on it.
How it works
ASpan is defined by the data structure:
idmeans the id of the span, calculated by monotonically incrementing the id of the previous span.start_blockcorresponds to the block in bor from which the given span would begin.end_blockcorresponds to the block in bor at which the given span would conclude.validator_setdefines the set of active validators.selected_producersare the validators selected to produce blocks in bor from the validator set.bor_chain_idcorresponds to bor chain ID.
ProposeSpan handler for basic sanity (verify whether the proposed span is in continuity, appropriate span duration, correct chain ID, etc.). Since this is a side-transaction, the validators then vote on the data present in MsgProposeSpan on the basis of its correctness. All these checks are done in SideHandleMsgSpan (verifying seed, span continuity, etc.) and if correct, the validator would vote YES.
Finally, if there are 2/3+ YES votes, the PostHandleMsgSpan persists the proposed span in the state via the keeper :
FreezeSet internally invokes SelectNextProducers, which pseudo-randomly picks producers from the validator set, leaning more towards validators with higher voting power based on stake:
Proposing a span manually
A validator can use the CLI to propose a span:Query commands
One can run the following query commands from the bor module:span- Query the span corresponding to the given span id.span-list- Fetch span list.latest-span- Query the latest span.next-span-seed- Query the seed for the next span.next-span- Query the next span.params- Fetch the parameters associated with the bor module.