What is Kaspa’s GhostDAG and how does it work?

What is GhostDAG?
GhostDAG (Greedy Heaviest Observed SubTree Directed Acyclic Graph) is a consensus mechanism used by Kaspa. GhostDAG was developed as an extension of Bitcoin’s classic Proof-of-Work consensus model, which was developed by Satoshi Nakamoto. The biggest difference: GhostDAG is applied to a Directed Acyclic Graph (DAG) instead of a linear blockchain. A Directed Acyclic Graph (DAG) is a data structure in which blocks are not placed in one straight chain, but as a network of nodes with multiple connections, where each new block can refer to multiple previous blocks without creating cyclic (recurring) connections. If that did happen, a block would indirectly refer back to itself. This makes it unclear in what order transactions occurred, and the network can no longer maintain a reliable history.
In traditional blockchains, only one block per unit of time is accepted (also called the block time), while competing blocks are discarded as “orphans”. GhostDAG breaks this model by allowing parallel blocks and integrating them into one shared data structure (blockDAG). This allows Kaspa to achieve higher transaction speeds with less computing power and therefore energy. In addition, decentralization is preserved and even strengthened, because miners no longer compete with each other to validate a single block; instead, virtually all produced blocks contribute to the network, lowering the barrier to entry and making power less concentrated among large mining pools.
As a result, GhostDAG represents a clearly different interpretation of how Proof-of-Work consensus can be applied.
Key Takeaways
- GhostDAG is the current consensus protocol of the Kaspa network and forms the foundation of how it operates.
- It uses a fixed k-parameter to reach consensus within the network.
- The protocol makes it possible to process multiple blocks in parallel within a BlockDAG structure.
- This allows the network to process transactions faster and more efficiently than traditional blockchains.
- GhostDAG maintains a strong security model, where the network remains secure as long as an attacker controls less than 50% of the hashpower.
- It is used in practice daily and has proven itself as a stable and scalable solution.
How does GhostDAG work?
GhostDAG operates based on a blockDAG structure, in which blocks can have multiple “parents” (preceding blocks) and can be added to the network simultaneously. Instead of a straight chain of blocks, a network of blocks emerges that are connected to each other. This makes it possible to handle simultaneously found blocks much more efficiently.
That blocks can have multiple preceding blocks is immediately the major difference compared to traditional blockchains such as Bitcoin, Ethereum, and Solana. Here there is always only one order, and only one block can be added to the blockchain at a time.
Example: when two miners find a block at the same time, a conflict arises and ultimately one of the two blocks is discarded (an orphan block).
With GhostDAG, multiple blocks can exist at the same time, new blocks can refer to multiple previous blocks, and blocks are not discarded. This creates an efficient system that makes optimal use of the computing power contributed by miners.
In short: A blockDAG and a blockchain are both types of distributed ledger, but they differ in structure and processing: a blockchain works as a linear chain of blocks that are added one by one, while a blockDAG uses a network structure in which multiple blocks can be added simultaneously and in parallel.
Greedy Heaviest Subtree algorithm
The logical question then is: how does the network determine which block comes “earlier” if multiple blocks are created at the same time?
This is handled by the Greedy Heaviest Subtree algorithm (GhostDAG). This algorithm, built into Kaspa’s code, helps nodes impose order on all incoming blocks.
In practice, it works as follows: nodes collect all the blocks they receive and then examine which group of blocks together required the most computing power (hashpower) to create. Each block contains a certain amount of work (proof-of-work), and by adding these together you get a total. The higher this total, the harder it is to replicate or attack that structure, and therefore the more reliable it is considered.
Based on that, each node determines for itself what the best ordering of blocks is. Because all nodes follow the same rules, they ultimately arrive at virtually the same order. This creates consensus in the network.
Blue set vs red set
Another important part of GhostDAG is that blocks are classified into two categories, namely blue blocks and red blocks:
- Blue blocks: these are blocks that fit well within the main structure of the network and are sufficiently connected to other blocks.
- Red blocks: these are blocks that connect less well, for example because they deviate too much or have too few connections.
Unlike traditional blockchains, red blocks are not discarded as orphans, but remain part of the network and play a smaller role in the final ordering of transactions.
This classification helps the network quickly determine which blocks are “reliable enough” to receive priority, without losing valuable information.
The GhostDAG whitepaper
The GhostDAG whitepaper forms the theoretical basis of the consensus mechanism used in Kaspa and aims to address the blockchain trilemma: the challenge of achieving scalability, security, and decentralization at the same time.
It builds on the earlier PHANTOM protocol, an academic proposal that was the first to try to securely order a blockDAG. While PHANTOM was strong from a theoretical perspective, it proved difficult to implement efficiently in practice. GhostDAG was developed as a practically usable and efficient variant that retains the same principles but is more scalable in a real network.
Achieving consensus
One of the whitepaper’s main contributions is extending the classic Nakamoto consensus model by achieving consensus using a DAG structure instead of a single linear chain of blocks. This means multiple blocks can be produced simultaneously without wasting computing power, partly by using so-called blue and red blocks. Traditional blockchains can only process one block at a time, causing other found blocks to be discarded as orphan blocks.
Preserving block reliability
A central element in GhostDAG is the so-called k-parameter. This parameter determines how many simultaneous blocks are still considered “safe” and reliable within the network. In other words, it indicates how much deviation (due to network delay or simultaneous block production) is still acceptable without jeopardizing security. The choice of k depends on factors such as network latency and block production speed, and it plays an important role in the balance between speed and security.
Security
Just like with Bitcoin, GhostDAG’s security model remains based on the assumption that an attacker controls less than 50% of the total computing power (hashpower). As long as this condition holds, it is extremely difficult for an attacker to manipulate the ordering of transactions or rewrite the network.
Throughput improvement
An important goal of GhostDAG is increasing throughput (the number of blocks and transactions that can be processed per second). Because blocks no longer compete with each other but are combined, the network can produce blocks much faster.
Unlike traditional blockchains, a higher block frequency here does not automatically lead to more forks or wasted blocks. This allows GhostDAG to achieve significantly higher scalability without making concessions on security.
Difference between GhostDAG and DAGKnight
DAGKnight can be seen as the next evolution of GhostDAG. While GhostDAG uses a fixed k-parameter (based on assumptions such as network latency), DAGKnight is designed without a fixed parameter and dynamically adapts to current network conditions.
This makes DAGKnight more flexible and better able to withstand fluctuations in the network, such as delays or spikes in activity. Both protocols maintain the same security model, where the network remains secure as long as an attacker controls less than 50% of the total hashpower.
At the moment, GhostDAG forms the active foundation of the Kaspa network and is used daily to process transactions and reach consensus. DAGKnight is still under development and is seen as a future upgrade of the protocol.
In short: GhostDAG is Kaspa’s current engine, while DAGKnight is being developed as a more flexible and scalable successor that dynamically adapts to network conditions.
What role does GhostDAG play within Kaspa?
1. Core infrastructure:
GhostDAG forms the foundation of the Kaspa network and determines how everything works. It ensures that transactions are placed in the correct order, validates new blocks, and ensures that all nodes in the network agree with each other (consensus).
2. High speed and scalability:
Thanks to GhostDAG, multiple blocks can be processed at the same time, allowing Kaspa to produce multiple blocks per second. This leads to high throughput without the network becoming centralized.
3. No wasted mining:
Unlike traditional blockchains, blocks are not thrown away when they are found at the same time. Virtually all blocks are used within the blockDAG, making the utilized computing power (hashpower) more efficiently used.
4. Preserving Proof-of-Work principles:
GhostDAG ensures that Kaspa retains the most important properties of Proof-of-Work, such as decentralization, security based on hashpower, and an open (permissionless) network. At the same time, it adds the scalability of a DAG structure.
Final thoughts
GhostDAG forms the core of the Kaspa network and shows how a BlockDAG structure can function efficiently and securely in practice. By using a fixed k-parameter, the protocol manages to find a good balance between speed, security, and consensus, even in a network with many simultaneous blocks.
Although new developments such as DAGKnight are emerging, GhostDAG already proves today that it is a robust and scalable solution for processing transactions. As such, it represents an important step in the evolution of distributed networks and lays the foundation for further innovations within the Kaspa ecosystem.