DAG Layer 1 forms a network itself, similar to Global L0. However, the main process of the DAG Layer 1 is a consensus mechanism that ends up with a block.
DAG Layer 1 is created in the same way as other state channels, but with one difference. A state channel should produce state channel snapshots while DAG Layer 1 produces blocks.
The main logic is placed in
BlockConsensusCell extends the
Cell definition. A
Cell basically is a function
A -> B, which is an output of hylomorphism on the provided recursive structure. In fact, the Cell type is
A -> M[B] when
M is a monad to allow effectful operations in (un)folding steps.
class BlockConsensusCell[F[_]: Async: SecurityProvider: KryoSerializer: Random: Logger](
) extends Cell[F, StackF, BlockConsensusInput, Either[CellError, Ω], CoalgebraCommand](
The recursive structure mentioned above is
StackF. It consists of two operations:
More(operation) that can be stacked, like:
BlockConsensusCell input is defined as
BlockConsensusInput which is the following disjoint union:
The output of the
BlockConsensusCell is either
FinalBlock or no consensus (
- The node must be connected to the network with at least two other peers that can be selected as facilitators
- The node must fetch the global snapshot from Global Layer 0, to get to know about Blocks that can be parents (tips) for new Blocks.
- The node has enough valid transactions (empty Block is not valid).
- Create a round and inform facilitators
- Pull valid transactions forming the correct, consecutive chain
- Send transactions to facilitators as a Proposal
- Gather all proposals, validate them and fold them into a Block
- Broadcast Block signature to facilitators
- Fold all Block signatures into the final Block and finish the consensus round
In case of any failure, cancel the existing round and try to inform facilitators about cancellation.