top of page

Lightning Protocol & The Raiden Network: A Beginner’s Guide

Updated: Feb 17, 2018

Researcher at SpringRole

Dec 4, 2017. Originally published here.


With the rise in their popularity, both Bitcoin and Ethereum were both forced to acknowledge a very fundamental flaw in their design i.e. the lack of scalability.


Recently a lot of innovations have been done, which has addressed the scalability issues. Bitcoin has activated Segwit, and Ethereum has solved some of the issues via the recent Byzantium hardfork.


However, both of these cryptocurrency heavyweights are planning to implement something soon which can, well and truly, solve this problem for good. They are both planning to implement their own version of “Payment Channels”.


So, before we understand what they are, let’s see why they are necessary.


The Problem With Transactions


The real problem is the way the whole mechanism has been designed. Each and every transaction goes through because of one reason alone:


The miners verify the validity of the sender and then add the said transaction to the block that they have mined.


Inevitably, the miners become the bottleneck to this transaction process. This was doable when bitcoin first started out but it is not the most practical method anymore.


Let’s see why that is so.

📷This is a graph that shows the number of confirmed bitcoin transactions per day. In this extract the least amount of transactions happened on August 1: 131,875. Image Credit: Blockchain.info

This is a graph that shows the number of confirmed bitcoin transactions per day. In this extract the least amount of transactions happened on August 1: 131,875.

Image Credit: Blockchain.info


So, over the last 11 months (as of writing), 131,875 is the least amount of transactions per day!


Because the miners simply can’t handle these amounts of transactions, the waiting period for each transaction has skyrocketed.


Check out this graph:

📷Image Credit: Blockchain.info

As you can see, people have had to wait upto 29 mins to get their transactions confirmed.


This means that more often than not, people would have to wait for a new block to be mined (one block is mined every 10 mins in Bitcoin), in order to see their transactions through.


Unfortunately, Ethereum isn’t doing any better in this regard either.


Theoretically speaking, Ethereum is supposed to process 1000 transactions per second. However, in practice, Ethereum is limited by 6.7 million gas limit on each block.

📷Image Credit: Etherscan

So, the miners are once again handicapped with the number of transactions they can add to the block.

📷Image courtesy: Hackernoon

Obviously, a solution was needed, and that’s when people looked to payment channels.


What Are State Channels?


A state channel is a two-way communication channel between participants which enables them to conduct interactions, which would normally occur on the blockchain, off the blockchain.


Doing this greatly helps cutting down the waiting time since you are no longer dependent on a third party like a miner.


So, how does a state channel work?

  • A portion of the blockchain is sealed off via multi-signature or some sort of smart contract which is pre-agreed by the participants.

  • The participants interact by signing transactions among each other without submitting anything to the miners.

  • The entire transaction set is then added to the blockchain.

The state channels can be closed at a point which is predetermined by the participants according to Slock.it founder Stephan Tual it could either be:

  • Time lapsed eg the participants can agree beforehand to close the channel in 1 hour. The parameter “nLocktime” is used to measure this.

  • The total amount of transactions done eg. close the chain after $50 worth of transactions have been done.

A state channel which exclusively deals with payments is called a “payment channel”. Some of the more popular form of payment channels are:

  • Nakamoto High-Frequency Transactions.

  • Spillman-Style Payment Channel.

  • CLTV-Style Payment Channels.

  • Hashed Timelock Contracts (HTLC)


What Is The Lightning Network?

📷Image Credit: Bitcoin.com

The lightning network is an off-chain, HTLC style, micropayment system which is designed to make transactions work faster in the blockchain. It was conceptualized by Joseph Poon and Tadge Dryja and is often referred to as “Layer 2”.


Hashed timelock contracts or “HTLCs” are the most popular form of payment channels.


Let’s see how it works. (The values that we are using in the examples i.e. the 0.1 BTC and 2 days of nLocktime are all arbitrary. They are being chosen for ease of explanation).


Imagine Alice has to send 0.1 BTC to Charlie via Bob.

So, what is going in this infographic?

  • Alice opens a channel with Bob and Bob opens a channel with Charlie.

  • Alice declares that she wants to pay Charlie 0.1 BTC.

  • Charlie declares a random string S and generates its hash H and hands it to Alice.


  • Alice sends Bob the hash H and they open a multi-sig channel between them. The conditions of the channel are:  a) Bob gets the 0.1 BTC if and only if he can show Alice the string S from which the H is derived.  b) There is an nLocktime of 2 days wherein, if Bob cannot produce the string then Alice gets a refund of 0.1 BTC.


  • Bob then shows the hash H to Charlie, proving that he has interacted with Alice and they proceed to open a multi-sig channel between them with the following conditions:  a) Charlie gets 0.1 BTC if and only he shows Bob the String S from which the hash H has been derived.  b) There is an nLocktime of 1 day (less than the locktime of the Bob-Alice channel) wherein if Charlie can’t produce the string then Bob gets a refund of 0.1 BTC.


  • If Charlie produces the string S then Bob sends him the 0.1 BTC.

  • Similarly, Bob shows Alice the string S and gets the 0.1 BTC from her.

So, what are the benefits of the lightning network?

  • Instantaneous payments.

  • Not dependent on third parties like miners.

  • Micropayment friendly.

  • Reduces blockchain load since the transactions are happening off-chain.

  • Decreases transaction waiting time.

  • Helps in blockchain scalability.


What Is The Raiden Network?

📷Image Credit: Medium.

Ethereum’s version of the lightning network is called “Raiden”.


Ethereum, quite like Bitcoin, is highly impractical for micro transactions. There is a huge waiting line for transactions anyway and more often than not, miners tend to prefer transactions with higher transaction fees/gas fees.


Ethereum, as of writing, can handle 15 transactions per second. While that is better than Bitcoin’s 7/second, it is still pretty abysmal.


It should ideally take a standard Ethereum transaction less than 20 seconds to be accepted into the blockchain. The most common and simplest of Ethereum transactions, an account transfer, costs around 21,000 gas.


However, it usually takes more time than that. There are a lot of reasons why transaction time gets delayed in Ethereum (data taken from Eth Gas Station):

  • Block Interval Time: A new block is mined every 15 seconds in Ethereum.

  • Mining Delay: Your transaction won’t be included in the next block after declaring itself to the network. Meaning if the transaction declaration happens at block 100, it won’t be included in block 101.  Miners aren’t comfortable changing the data of their blocks in the middle of the block interval to accommodate newly submitted transactions to the mempool. What this effectively means is that you will have to wait for the next to next block to get your transactions validated. Which means 15 + 15 = 30 seconds at least.

  • Gas Price: Whether your transaction gets included in the block or not is also directly related to the gas price of each and every transaction. Usually miners accept transactions with higher gas prices and give them special preference by allowing them to “cut in line” so to speak.

  • Empty Block Penalty: Sometimes the miners mine blocks which are empty no matter what transactions are there in the mempool. Even the best mining pools currently have a 1–2% empty block rate. So we need to factor in these times as well whilst calculating the average waiting time for each transactions.

So, if we were to make a graph of all these factors that delay a standard transaction, it would look like this:

📷Image Courtesy: Eth Gas Station.

In order to make these transactions faster and more pocket-friendly, the Raiden network was introduced.


How does Raiden circumvent all these possible transaction delays?


Like the lightning network, it takes these transactions off the blockchain and removes any third party whatsoever. All of the factors happen because:

  • Either a third party i.e. the miner, has to approve and validate the transaction.

  • The transaction needs to be put inside the blockchain.

Raiden, will allow two users to transact between them, as many times as they want, without having to interact with a miner or the blockchain.


Raiden will be structured like a mesh type structure running on top of the ethereum main chain:

📷Image Courtesy: Raiden.Network

Raiden was conceptualized by Brainbot technology.

“Basically all blockchain based applications that want to scale to real world usage will benefit from Raiden. It can be used for applications like asset trading in gaming or finance, retail payments, micropayments for content (think the next YouTube or Spotify where creators are directly paid for every second consumed). But it’s also suitable as an infrastructure for cheaper, faster and more secure correspondent banking.” — Heiko Hees, founder/CEO Brainbot technology.

So, how does Raiden work?


Suppose Alice and Bob want to interact with each other using Raiden. This is how they will go about it

  • Alice and Bob open an off-chain payment channel via deploying a smart contract.

  • Both parties invest some form of security deposit in the smart contract.

  • Suppose Alice wants to send 2 tokens to Bob, she signs the message “2” and sends it to Bob. Bob now has proof of Alice sending him 2 tokens.

  • Now, suppose Alice wants to send Bob 3 more tokens. She will update the state of the message to “5”. This shows that the message is conveying the previous and the latest transaction as well.

  • The moment Bob wants to redeem the 5 tokens, he will go the blockchain and close the channel. He will get the 5 tokens from the deposit that was initially made in the channel.

  • The information will be relayed to the blockchain and the only record that will be stored is the final 5 token deposit made to Bob.


Raiden’s ICO got done on 1st November and they raised ~$33 million.


The features of the Raiden Network are:

  • Easy to use API.

  • Helps Ethereum to scale up.

  • Can be operated by an ERC20 token i.e. the RDN token.

  • Enables fast and simple transfer of money.

  • Decreases load on the Ethereum blockchain.


Conclusion


As you can see, both Lightning and Raiden Network will go a long way in easing up the load on the main blockchain and increasing the rate of the transactions. If Bitcoin and Ethereum want to scale up, they will have to implement these payment channels properly.

80 views0 comments

Recent Posts

See All

SpringRole Manifesto: The Future of Hiring

By Springrole team March 15, 2018. This article was originally published here We live in a world where it’s hard to trust everything you...

Is Hashgraph the Blockchain Killer?

By Rajarshi Mitra Writer. Blockchain Researcher. Wielder of Pens. Researcher at SpringRole Dec 9, 2017. This piece was originally...

Comments


bottom of page