Consensus for a DAG with all history of events in a peer to peer network
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
In a conventional blockchain, transactions are packaged in blocks and linked together in a linear sequence, forming a chain. A Directed Acyclic Graph (DAG), however, presents a different structure where transactions directly link to one another, allowing for multiple branches to coexist and merge, which can lead to higher scalability and speed. Utilizing a DAG in a peer-to-peer (P2P) network necessitates a unique approach to consensus to maintain network integrity and security.
Understanding DAG and Its Structure
A DAG is a finite directed graph with no directed cycles. This means that it consists of vertices and edges (arrows) that do not loop back to themselves at any point. Each vertex represents a transaction, and each edge directs to transactions that are directly referenced (parents). The key advantage of a DAG over traditional blockchain is that transactions can be processed simultaneously, rather than waiting for the next block to be mined. This potentially results in faster transaction throughput and reduced delays in network communication.
Consensus Mechanisms in a DAG
The consensus mechanism is crucial to ensure that all participants in a network agree on a single version of the truth, despite the absence of blocks and miners to validate transactions as in traditional blockchains. Here's how consensus typically works in a DAG-based system:
1. Gossip about Gossip
The algorithm involves each node in the DAG constantly spreading the known information about transactions to its peers. This includes both own transactions and information received from others. Through this mechanism, information propagates throughout the network like a rumor, hence the term 'gossip.'
2. Virtual Voting
Each node, upon receiving new transactions or updates, implicitly votes on the transaction's validity based on the history it is aware of and the network's protocol rules. Due to the rapid and widespread information dispersion by the gossip mechanism, these votes can reach a consensus without requiring explicit votes or acknowledgements from every node, drastically reducing communication overhead.
3. Transaction Ordering
In contrast to linear blockchains, DAGs need a method to establish a consensus on the order of transactions, as parallel transactions could be unrelated and not conflicted with each other. Techniques such as using timestamps, Proof of Stake (PoS) tagging, or incorporating the selection of parent transactions based on specific node-defined criteria are common.
4. Tangle
The term popularized by IOTA, one of the first cryptocurrencies to employ a DAG, refers to a specific kind of DAG where transactions are linked like a web. In IOTA’s Tangle, a transaction must approve two previous transactions, which in turn need to approve other previous transactions, thus indirectly confirming the entire history of the ledger.
Challenges in DAG Consensus
Despite their potential, DAGs face challenges particularly concerning network security and integrity. The main issues include:
- Double Spend Attacks: Without blocks to finalize transactions, DAGs must embed other security measures to prevent double spending.
- Node Collusion: DAGs usually have fewer nodes responsible for consensus (e.g., Witness nodes in some implementations), which could be vulnerable to collusion.
- Scalability vs Security Trade-off: The balance between high throughput and robust security remains a delicate issue. Higher throughput may sometimes compromise the integrity if not well managed.
Examples and Implementations
Several projects have explored DAG technology, with different approaches to consensus:
- IOTA: Uses Tangle with a coordinator node to guard against double spends and ensure network consensus during its infancy stage.
- Nano: Uses a block-lattice structure where each account has its own blockchain (chain of transactions), which reduces reliance on global consensus.
Summary Table
| Feature | DAG | Traditional Blockchain |
| Structure | Graph-based, multi-branching | Linear, single sequence |
| Consensus Speed | Potentially high | Relatively slower |
| Scalability | High, due to parallelism | Lower, due to block size and interval |
| Resource Requirement | Lower, no miners | Higher, requires miners |
| Security Concerns | Potential vulnerability in node collusion | Well-studied security (e.g., 51% attacks) |
DAG technology offers a compelling alternative to traditional blockchains, promising faster transaction times and better scalability. However, the nuances of its consensus mechanism and security concerns must be carefully managed to realize its full potential in various applications.

