Hydra Head protocol: an open source solution for scalability
Understand the purpose, functionality, and roadmap of Cardano's off-chain ledger framework for efficient blockchain development
The Hydra Head Protocol, hereby simply referred to as Hydra, is a scalability solution on Cardano. It materializes as an open source framework for the creation of off-chain ledgers and can assist developers with using blockchain in a more efficient way.
The project results from a joint effort of engineers at the Cardano Foundation and IOG. Besides making the code public, it has an equally public process to interact with the team and propose contributions. However, despite the many previous mentions to Hydra, some confusion remains about the project and how it serves the community. So let us quickly review the fundamentals about Hydra, where the project currently stands, and where it is headed.
What is Hydra
The Head protocol presents an isomorphic layer-2 solution that belongs to the family of state-channel solutions.
Generally speaking, a channel is a bi-directional communication link between two or more peers. Applied to blockchains, it means an instrument that allows two or more parties to exchange transactions other than by broadcasting them onto the main network. In this context, a state-channel fundamentally offers a way of constructing small networks that operate in parallel with a main network. State-channels also come as a generalization of payment-channels, which were used to build the Lightning Network, Bitcoin’s layer-2 payment protocol to facilitate faster transactions. While payment channels only support the transfer of assets, state channels allow the execution of scripts as well as more elaborate transactions, including metadata, multi-assets UTxO, and so on.
In the case of Hydra, we can picture it as a replicated portion of the Cardano chain that runs independently of Cardano and between a more limited set of actors. In this way, actors have the possibility of performing transactions at a fast pace on their private network, a.k.a. their Hydra Head. They may then settle the result of their operations onto the main Cardano chain to let the rest of the network know about the outcome of their interactions. As such, Hydra heads can be created at will in a semi-controlled setting and by any actor seeing a need for such fast-paced traffic. We will provide more examples later on.
In the context of distributed ledger technology (DLT), layer-1—or the base layer—refers to a blockchain’s mainchain, while layer-2 corresponds to any solution or product assembled atop the mainchain. Layer-2 solutions frequently bring extra scalability to a chain. The Hydra Head protocol is therefore considered a layer-2 solution because it is built on top of the Cardano mainchain.
In addition, Hydra appears characterized as isomorphic because transactions in a Hydra head share the same capabilities as the transactions running on Cardano. The term itself hints at this similarity: iso- means equal, and -morphic denotes shape, form, or structure—literally, having the same form. Furthermore, in Mathematics an isomorphism indicates a bi-directional mapping between elements from a domain to another that preserves the elements’ structure between the two domains. Said differently, there is a direct structural correspondence between transactions running on Cardano and those running in a Hydra Head. Subsequently, Hydra also supports any programming language backed by Cardano. Since Cardano allows the use of both mainstream and specialized languages, this implies transactions in Hydra can be constructed wielding the same existing tooling already familiar to developers.
On the other hand, while a Hydra Head features a ledger technology akin to the one used on the Cardano mainchain, the two diverge when it comes to establishing consensus, as well as to validating and propagating transactions amongst peers. In a Hydra head there are no stake pools involved whatsoever, and consensus between participants of a head is a full consensus: everyone needs to agree on every transaction. This offers strong security guarantees to participants of a Hydra head, yet limits the total number of participants of a single head. It also suggests that, while participants do not necessarily trust one another, they still have a common interest—or incentive—in participating in the protocol.
It bears repeating that, contrary to popular belief, a hard fork does not enable Hydra, nor will Hydra become a capability of the base layer itself. Hydra is, first and foremost, a framework and an infrastructure stack that projects running on Cardano can leverage to speed up a part of their use case.
In a sense, Hydra acts as a DApp for DApp developers seeking to scale their own protocols. It is a building block in a larger landscape and comes mainly in two parts:
- •a set of on-chain scripts that drive and secure the execution of the Hydra Head protocol;
- •a software stack, named Hydra node, giving developers a high-level interface using widespread web technologies such as WebSocket and JSON.
Hydra in retrospective
Plenty happened around Hydra this past year. If asked to summarize it in one sentence, one might say 2022 was about ramping up software quality and preparing Hydra for the first pioneers to build.
Early in the year, the team explored and quantified limitations of the protocols through benchmarks, in particular with regards to on-chain restrictions. Indeed, with a set of on-chain scripts driving it, the protocol is not immune to the usual restrictions in execution resources common in the development of DApps. As a consequence, the team drafted CIP-0042 to request the introduction of new core primitives in Plutus, simplifying some of the on-chain operations in Hydra.
The project also extended its reach, embracing open source with welcome arms and encouraging contributors to join the effort. Since February 2022, Hydra maintains a public roadmap. Similarly, the following month the team launched a website to host all information regarding the project and the Hydra software stack. The website provides a rather sizable amount of information: Not just a user manual with installation instructions, demos, and api reference, but also architectural decision records, test coverage results, benchmarks, and much more. Definitely a great place for those looking to start building on Hydra.
Moreover, March had the extra significance of witnessing the first Hydra Head open on a public testnet as the result of a team hackathon in Lyon, France. From there, the team began filling the gap to bring the solution closer to a production-ready software stack.
In particular, the work commenced on the formalization of the Coordinated Head Protocol—a slight variation on the original Hydra paper currently undergoing implementation. As often when research meets engineering, adjustments from the theory had to be made to better reflect reality. Part of the effort included the development of the new testing library quickcheck-dynamic, which combines property-based testing, model-testing, and temporal logic to formulate and verify strong properties about a protocol like the Hydra Head protocol.
Then, during the summer, the team diligently worked on integrating the new Babbage era introduced by the Vasil hard fork. As a project running on Cardano, Hydra can also leverage new features—such as reference scripts and reference inputs—to push some limitation boundaries even further. The summer equally offered a great opportunity to make numerous kinds of usability improvements to ease the developer experience. In parallel, the first pioneers were already active and experimenting with the project.
Between August and September, the team remained busy onboarding three new members to the project. As the project matures, it becomes better equipped to, and more capable of, expanding its internal team while also diversifying its activities.
Behind the scenes, the first builders were getting ready to announce some exciting projects. In October, during the Rare Bloom event, SundaeSwap Labs showcased how they could run part of their protocol through a Hydra head. It was the first public demo of a substantial smart contract running via a Hydra head. While still on test networks and with several footnotes, it represents a major step forward in the adoption of Hydra. And it took only a month before Obsidian Systems and IOG announced Hydra for Payments, an open software development kit bespoke to payments through Hydra heads. At the same time, TxPipe demonstrated how they had been working on providing Hydra Head as a service through their new platform Demeter.
All such projects demonstrate one thing clearly: the interest in Hydra is growing, and the first builders have started turning towards adopting it. Indeed, as a token of recognition the community nominated and elected Sebastian Nagel—Hydra's team lead—for the "Dev Team" speaker category at the Cardano Summit 2022.
Finally, while the Summit presented the entire community with a great moment to gather and meet up, it also gave the Hydra team an opportunity to sit in front of a whiteboard and rethink the project goals as well as the strategy for the years to come.
Where Hydra is headed
Until November 2022, the Hydra project aimed to have 99% of all Cardano traffic happen off-chain in Hydra heads—an ambitious goal used as a guiding star to prioritize decisions. However, in November 2022 the team set a new objective: being the number one DApp on Cardano by all known metrics, whether one considers total value locked (TVL), traffic, volume, or other standards. Both goals fundamentally illustrate the idea of increasing adoption and enabling growth of the Cardano ecosystem, but the second feels more concrete and will better help to drive the project's roadmap.
Hydra has long been perceived as a magical switch that will make Cardano faster. The team wants to break with this narrative and get more builders in the ecosystem to understand Hydra itself is, in essence, a DApp, requiring integration and adoption to become truly useful.
Where 2022 mainly prioritized gaining stability and reaching a point where the first pioneers could more easily onboard Hydra, 2023 will focus on adoption. From the get go, the Hydra project always intended to equip pioneers and help projects get started. Many use cases are already being explored, such as payments, games, governance, and marketplaces. And the end of 2022 demonstrated how the first pioneers have started utilizing the Hydra framework. Moving forward, the Hydra team intends to enable them even more, and to help new pioneers adopt Hydra as part of their toolstack.