michaelpj / hydra-poc

Proof of concept for the Hydra Head protocol :construction_worker:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hydra Proof of Concept (POC)

A home to our colorful experiments and prototypes.

πŸŒ„ Introduction

Hydra is the layer-two scalability solution for Cardano, which aims to increase the speed of transactions (low latency, high throughput) and minimize transaction cost.

This repository contains the proof-of-concept implementation the Hydra engineering team has put together during exploration and can be considered a "developer preview". It outlines the basic architecture of a hydra-node, which runs a simplified (coordinated) Hydra Head protocol, connects to other hydra-nodes, interfaces the Cardano blockchain and provides an API to clients such as the included terminal user interface hydra-tui.

⚠️ This is still prototypical and exploratory work shared here for your interest - it is NOT ready for production (yet) ⚠️

Please also note that as we did develop this while in "move fast, break things" experimentation mode, the code quality seen around here may not always represent our best practices and you will find many code smells and dirty hacks.

Thanks for visiting and enjoy!

🌈 Features

Proof of concept:

  • Coordinated Hydra Head protocol
  • Single Head per hydra-node
  • Stubbed chain using external process
  • Network statically configured, direct TCP connections
  • WebSocket, message-based API Server
  • Terminal user interface client

Later:

  • Cardano-node integration (direct or via PAB)
  • Persisted Head state
  • Multiple Heads per hydra-node, managed via API
  • Support for external wallets (e.g. hardware wallets)
  • Optimistic Head closure and incremental de-/commit protocol extension
  • Relay-capable, mesh network

πŸš€ Getting started

The quickest way to get a hydra-node running is to use our docker images.

docker pull inputoutput/hydra:hydra-node-latest
docker run -rm inputoutput/hydra:hydra-node-latest --help

In the POC, a hydra-node can only participate in a single Head and thus needs a single signing key --me. Also, we use simplified keys for easier debugging.

To generate a new key:

head -c8 /dev/random > test.sk

Using this you can now start a hydra-node, our (currently) stubbed mock-chain and connect a hydra-tui (or any websocket client) to it:

docker run -d --name hydra-node --network host -v $PWD:/data inputoutput/hydra:hydra-node-latest --me data/test.sk
docker run -d --name mock-chain --network host inputoutput/hydra:mock-chain-latest
docker run --rm -it --network host inputoutput/hydra:hydra-tui-latest

Now you should see the terminal user interface connected to your node and you can initialize a Head, commit (generated) funds to it, send transactions and close the Head using the Commands/Hotkeys shown. Admittedly, as there are no other participants, this is a bit pointless. For a more interesting scenario with three nodes connected off-chain and three Head participants, check out our demo section.

❓ Contributing

The best way to contribute right now is to provide feedback. Give the demo a test drive and have a look at our documentation. Should you have any questions, ideas or issues, we would like to hear from you:

When contributing to this project and interacting with other contributors, please follow our Code of Conduct.

πŸ”§ Development

See the Wiki

πŸ“š Documentation

Adding onto the information found here and the wiki there is some technical documentation, which is also published online at https://input-output-hk.github.io/hydra-poc.

API Documentation is available for:

Haddock documentation is also published for each package:

About

Proof of concept for the Hydra Head protocol :construction_worker:

License:Apache License 2.0


Languages

Language:Haskell 97.4%Language:Nix 1.1%Language:Shell 1.0%Language:Dockerfile 0.5%