Contents

  • Introduction

  • What is a DAG?

  • How does a DAG work?

  • Advantages and disadvantages of directed acyclic graphs

    • The advantages of DAGs

    • The disadvantages of DAGs

  • To conclude


Introduction

When you think of cryptocurrencies, the terms “blockchain” or “distributed ledger” probably come to mind. Since Bitcoin's launch, hundreds of other cryptocurrencies have been created. Most of them are based on a similar network architecture. Their data structures allow users to transfer value or interact with decentralized applications.

In a blockchain, a new block is periodically added to an expanding chain of blocks. Each block is connected to the previous one by some sort of cryptographic link (more precisely, a hash). In each of these blocks are recent transactions that have been broadcast by users.

But there is often a waiting period between broadcasting a transaction and including it in a block. Think of it like waiting for a train at a station. Depending on the size of the cars (block size) and how many other people are waiting (pending transactions), you may not even be able to catch the next train. Or even the one after that. You can wait anywhere from a few seconds to a few hours for the transaction to be confirmed.

For many, this is a wise compromise. After all, it offers a very high level of security without relying on a centralized coordinator. For others, blockchain technology has an expiration date. Critics believe that in the long term, the scalability issues faced by blockchain technology will prevent mass adoption.

Some believe that the future of cryptocurrency payment networks lies in a completely different architecture: directed acyclic graphs (or DAGs).


What is a DAG?

A DAG is a different type of data structure, like a database that connects different pieces of information. “Directed acyclic graph” is a complex term, so let’s start by breaking it down.


Graphe orienté acyclique.

Directed acyclic graph.


Conceptually, DAGs look like what is described above. They are made up of vertices (the spheres) and edges (the lines that connect them). They are directed because they are going in only one direction (you can see the arrows). They are acyclic (i.e. non-cyclic) because the vertices do not form a loop on themselves. If you start at one point and follow the graph, you cannot return to that same point. All this will soon be clearer.

These data structures are generally used to model data. You can rely on a DAG in scientific or medical fields to observe the relationship between variables and determine their mutual impact. For example, you might take things like nutrition, sleep cycles, and physical symptoms, so you can make connections between them to determine how they affect a patient.

For our part, we are more interested in how they can contribute to achieving consensus in a distributed cryptocurrency network.


How does a DAG work?

In a DAG-based cryptocurrency, each vertex of the structure represents a transaction. There is no concept of a block here, nor is there any need to mine to expand the database. So instead of putting transactions together into blocks, each transaction is built on top of another. However, a small proof-of-work operation is performed when a node submits a transaction. This ensures that the network is not polluted and validates previous transactions.

For a new transaction to be added, it must rely on older transactions. Suppose Alice creates a new transaction. To be taken into account, this transaction must reference previous transactions. Kind of like how a Bitcoin block references the one before it, but with multiple transactions referenced.

In some systems, an algorithm selects transactions (or “tips”) on which a new transaction should be made. Tips more likely to be selected are those with more accumulated weight: a measure of the number of confirmations on the path to the tip.

The transactions that Alice will add are unconfirmed. But once Alice references them, they will become confirmed. Alice's transaction is now unconfirmed. Someone else must add a new transaction for it to be accepted.

Users are more likely to confirm transactions with “heavier” weight so that the system continues to grow. Otherwise, there would be nothing to stop a user from continually adding new transactions to older transactions.

With blockchains, it is quite easy to protect against double spending. The same funds cannot be spent twice in a block: nodes can easily detect any attempts and reject any blocks containing conflicting transactions. Since producing blocks is so expensive for miners, they have an incentive to be honest.

DAGs also have a mechanism to avoid double spending. It's a bit the same, but without the minors. When a node confirms older transactions, it evaluates an entire path to the very first transaction in the DAG to ensure the sender has sufficient balance. There may be multiple paths, but only one should be verified.


Animation d'un DAG en action


If users use an invalid path, they run the risk of their own transaction being ignored. Theirs could be legitimate, but since the previous one was not, no one will want to continue this path.

This isn't intuitive at first: couldn't you find yourself in a situation where multiple branches that aren't aware of each other exist? Wouldn't it therefore be possible to spend the same funds in these different branches?


DAG avec plusieurs branches


This is indeed a possibility, but it is resolved by a selection algorithm that favors transactions with greater cumulative weight. This means that over time you will end up with one branch that is much stronger than the others. The weakest ones will be abandoned and the network will continue to develop on the heaviest.

As with blockchains, there is no absolute finality: you can never be 100% sure that a transaction will not be canceled. It's incredibly unlikely, but you can theoretically rollback a Bitcoin or Ethereum block, which reverses all transactions inside it. The more blocks you add after the transaction, the more confidence you can have in your transaction. This is why it is recommended to wait for six confirmations before spending funds.

In a DAG such as IOTA's Tangle, there is a concept of confirmation trust. The selection algorithm is run 100 times, and you count how many times your transaction was approved directly or indirectly in the selected boards. The higher the percentage, the more confident you can be that your transaction will stay settled.

This may seem to result in a poor user experience. But this is not the case. If Alice sends Bob 10 MagicDAGTokens, she does not have to worry about selecting the right transactions from the graph. In the background, its wallet can perform the following operations:

  • Select the heaviest transactions (remember, these are the ones with the most accumulated confirmations).

  • Follow the procedure for returning previous transactions to ensure transactions have sufficient balance for expenses.

  • Once this is done, she adds her transaction to the DAG confirming the transactions on which it was carried out.

To Alice, this will simply look like the usual procedure for a cryptocurrency. She enters Bob's address and the amount she wants to spend, then hits Send. The list above is the proof of work that each participant executes when they create a transaction.


➟ Do you want to get started with cryptocurrencies? Buy Bitcoins on Binance!


Advantages and disadvantages of directed acyclic graphs

The advantages of DAGs

Speed

Without being limited by block times, anyone can broadcast and have their transactions processed at any time. There is no limit to the number of transactions users can submit, as long as they confirm old ones when they do so.


No mining

DAGs do not use PoW consensus algorithms as is usually the case. Their carbon footprint is therefore a fraction of that of cryptocurrencies which rely on mining to secure their blockchain network.


No transaction fees

Since there are no miners, users do not need to pay any fees to broadcast their transactions. That said, some require a small fee to be paid to particular types of nodes. Low fees (or better, no fees) are attractive for micropayments, because they are not possible on networks with high fees.


No scalability issues

Without block time constraints, DAGs can process many more transactions per second than traditional blockchain networks. Many proponents believe this will make them valuable in Internet of Things (IoT) use cases, where all types of objects and machines will interact with each other.


The disadvantages of DAGs

Not fully decentralized

Protocols that rely on DAGs have different centralization elements. For some, this is likely a short-term solution to bootstrap the network, but it remains unclear whether DAGs can thrive without third-party intervention. If not, they open themselves up to attack vectors that could ultimately cripple their networks.


Not tested on a large scale

Although DAG-based cryptocurrencies have been around for a few years, they still have a long way to go before they see widespread use. Therefore, it is difficult to predict what incentives users might receive for maintaining the system in the future.


To conclude

Directed acyclic graphs are certainly an interesting technology for building cryptocurrency networks. So far, there are relatively few projects that use this data structure, and they have not yet fully evolved.

That said, if they can harness their potential, they could power extremely scalable ecosystems. DAG technology presents a myriad of use cases in areas that demand high throughput and no fees, such as in the Internet of Things (IoT) and micropayments.