Building the next step of Blockchain - Thorchain Update 001

Oumnia El Khazzani

Oumnia El Khazzani

over 5 years ago

Building the next step of Blockchain - Thorchain Update 001

The Swish blockchain team has been working for a few months now on the development of the Thorchain project, a highly scalable and interoperable payment network and decentralized cryptocurrency exchange solution, based on a cutting-edge multi-chain blockchain. With the recent public launch of the project and the start of the ongoing token sale, we thought it was time for us to share with the community about the development efforts.

We will release a series of development updates, this is number #1. These regular updates will include candid discussions of the problems we encounter, the code we write and the decisions the team has to make. While a lot of research effort has been dedicated to the Thorchain technical specification, we are not expecting a smooth ride. After all, we are operating at the forefront of cutting-edge blockchain technology and are trying to achieve unprecedented levels of decentralization and scalability. Before we get into detail on what we have actually implemented so far and what is planned for the near future, let’s have brief look at what exactly the team intends to build.

What is Thorchain?

The Problem with Cryptocurrency Exchanges Traditionally, cryptocurrency exchanges are centralized entities. Trusted third parties tend to act as custodians for users’ funds, hold private keys to user wallets on different blockchains, and, thus, constitute the weakest link in the chain. This weakness exists both in terms of trust and security. Users have to trust centralized exchanges with their funds and they have to trust the security measures put in place by those exchanges. Centralized exchanges are in fact very similar to traditional financial institutions, the very stakeholders cryptocurrencies were meant to replace, except that they are currently much less regulated and have much more freedom do whatever they wish with users’ assets.

The answer to this centralization issue is, of course, to build decentralized exchanges controlled in a distributed manner by their users and assisted by built-in trust mechanisms. However, current decentralized exchanges perform very badly for a number of reasons: **Interoperability. **Moving assets from one blockchain to another is hard. Different blockchains work in different ways and bridges between them need to consider differences in latency, finality and asset modeling (UTXO, accounts, smart contracts). At the same time, these exchanges must maintain the principles of decentralization and create trust across blockchain boundaries.

Scalability. It is very difficult to perform cross-blockchain trading efficiently and in a scalable way. Low transaction throughput and high latency mean that the user experience of decentralized exchanges is currently poor and that they scale badly.

Liquidity. Decentralized exchanges have a liquidity problem. In order to perform peer-to-peer trading, buyers need to be matched to sellers. This is not always possible, especially in low volume cryptocurrencies. These issues are not unique to decentralized exchanges. Interoperability, scalability, and liquidity are central properties that any global payment and asset transfer solution will require in order to further the increased adoption of cryptocurrencies. For this reason, we are building Thorchain from the ground up, defining a protocol-level solution for a global payment and liquidity network.

The Thorchain Solution

Thorchain is a protocol-level solution for highly scalable payment networks with cross-blockchain interoperability and built-in liquidity features. At the core of the system is a high-throughput blockchain based on a multi-chain protocol. Numerous parallel chains, each representing a different token, are linked through a so-called MerkleChain, which stores the roots of the merkle trees of TokenChain transactions to ensure overall consistency and avoid double-spending between chains. The first TokenChain hosts Thorchain’s native cryptocurrency, the Rune.

http://res.cloudinary.com/ho14lqzev/image/upload/v1539973532/mfx8su37evansfrcf0ls.png

“We are operating at the forefront of cutting-edge blockchain technology and are trying to achieve unprecedented levels of decentralization and scalability.”

The Rune serves as a settlement currency for the Thorchain ecosystem and is intrinsically linked to Continuous Liquidity Pools (CLP), the platform’s protocol-level liquidity support. CLPs ensure that assets are always available for trading. Each token is created from a Genesis account which holds information of the token and acts as a CLP. CLPs essentially provide a bucket (or a pool), in which assets are placed and bonded to another asset (Rune).

The Rune acts as an exchange intermediary asset between all trading pairs.

In terms of interoperability, Thorchain’s multi-chain approach provides the means to set up tokens representing other blockchains such as Bitcoin or Ethereum. A cross-blockchain communication protocol for atomic asset transfers allows users to move tokens from these chains onto their Thorchain equivalent TokenChains, tBitcoin or tEthereum.

Thorchain also implements a number of features aimed at performance and scalability, including a PBFT-based delegated proof-of-stake consensus protocol with on-chain governance, a sharding protocol, and a second layer off-chain payment channel network. Importantly, block and transaction finality is almost instant in Thorchain, due to the consensus mechanism used. In Thorchain, transactions are confirmed as soon as they are included in a block. In contrast, proof-of-work blockchains such as Bitcoin or Ethereum provide a probabilistic model of transaction finality. In Bitcoin, for example, six consecutive block confirmations are generally considered to be a safe threshold for considering a transaction final. On average, this means waiting for one hour. By using a consensus mechanism with finality, Thorchain eliminates this waiting period.

Protocol Definition Phase

Thorchain is, of course, a very ambitious project, extending the current blockchain state of the art in terms of decentralization, speed, and reliability significantly. Because of this, the first few months of the project were spent on fundamental research activities which resulted in the definition of the different protocols in a number of white papers, which are publicly available:

  • The overall Thorchain whitepaper gives an overview of the whole protocol stack and introduces the main concepts of the platform. This main whitepaper is supplemented with individual whitepapers for specific protocols.
  • The Bifröst whitepaper describes Thorchain’s cross-blockchain bridges, a feature that facilitates moving assets to and from external chains, such as Bitcoin and Ethereum.
  • On-chain governance related to the delegated proof-of-stake validator selection process is described in the Æsir protocol whitepaper.
  • The Flash Network is a layer 2 payment channel network protocol that allows instant asset trading.
  • Further scalability is provided by the innovative sharding algorithm explained in the Yggdrasil protocol paper.

These technical specifications have been public for a while and have gone through an extensive review process that included a number of external blockchain industry experts.

We are currently seeking academic feedback and collaborations, so if you are part of a distributed systems research group or are working on a blockchain-related doctorate or masters thesis and wish to collaborate with a cutting-edge real-world project, please contact us through the contact form of the Thorchain website or by replying to this article.

Technology Stack Selection One of the first decisions to be made when starting a project of this scale is to select a technology stack and a starting codebase. We decided to build on Tendermint and the Cosmos SDK for a number of reasons.

First of all, Tendermint is a sound implementation of the PBFT consensus protocol and very close to the technical specification of Thorchain consensus, with the exception with some support required for the Thorchain sharding protocol.

Secondly, the Cosmos multi-chain approach is fairly similar to Thorchain’s architecture and proved to be a good basis to start implementing the MerkleChain, the Rune TokenChain and the mechanisms for creating additional TokenChains. It also follows an account-based blockchain model (as opposed to UTXO-based), which is what we had in mind for Thorchain all along, as it provides the necessary features for implementing our liquidity and trading model. As in Thorchain, tokens in Cosmos are generated as native tokens on their own connected chain, rather than in smart contracts (Ethereum’s approach).

Last but not least, the chosen codebase is written in Golang, allowing us to develop Thorchain in what is arguably the most flexible and reliable language for distributed systems programming. As such, we forked the Cosmos SDK codebase, built the Thorchain account addressing scheme on top of it and implemented the Rune TokenChain.

Continuous Liquidity Pools

http://res.cloudinary.com/ho14lqzev/image/upload/v1539974043/htajysmpsqf1y69iglqp.png

The next big development phase consisted of implementing support for CLPs. As explained above, CLPs are liquidity features built into the protocol. Each TokenChain is issued with a pool which locks in liquidity to be used for on-chain trading and, importantly, acts as a price feed for second layer trading. Trading through CLPs avoids having to match buyers to sellers. Instead, the actual protocol provides a reserve of assets for trading.

The pricing mechanism relies on free market rules. We expect that whenever there are arbitrage opportunities, the self-interest of traders will cause them to become active until the price is rectified.

So where does the liquidity come from? Initially, liquidity will be fed into the Rune CLP from the ongoing token sale. The distribution model ensures funds are made available for CLPs, with 30% reserved for on-chain liquidity. Eventually, anyone will be incentivized to contribute to CLPs through the liquidity fee model. In contrast to other exchanges, the Thorchain economy pays out transaction fees to its users. Fees are calculated dynamically based on the requirements of individual CLPs, incentivizing users to contribute liquidity to the liquidity pools of the less “healthy” tokens. We implemented CLP support for Thorchain’s first big milestone deliverable, as liquidity is central to the protocol, providing the basis for a decentralized exchange with an unheard-of user experience in terms of the speed and price efficiency of trading.

Genesis Testnet

With the delivery of our first big milestone, the first testnet was launched. The Genesis testnet has been live for a few weeks now and is currently undergoing extensive performance testing. In order to demonstrate the functioning testnet, we developed a block explorer for it. The Genesis testnet, and future iterations following the testnet roadmap, can be viewed at https://thorchain.info/.

What’s Next?

We are now busy working on the Helheim milestone, which will be delivered with the launch of the next iteration testnet. Currently, the development priority is implementing the Bifröst protocol (initially with a bridge to the Ethereum blockchain) to allow interfacing with external blockchains. The team is also developing the first version of Asgardex, the first decentralized exchange built on the Thorchain protocol. In parallel, the Genesis network is undergoing performance testing. We have developed several bots that continually escalate transaction load to benchmark and stress test the network.

We will provide an update on performance testing and the ongoing Helheim deliverable very soon. In the meantime, you can follow progress on the public Thorchain Github repository.

This update was brought to you by the Blockchain team at Swish.

We build cutting-edge blockchain-based solutions for inspiring projects. Have an idea we can bring to life? Let’s talk.

Share this post

twitter iconfacebook iconmedium icon

© 2018 Swish Labs, Inc. All Rights Reserved.