A Brief Introduction of State Channel Technology

TrinityProtocol
Nov 1, 2018 · 9 min read

State channel technology is used to carry out transactions and state updates off-chain. Though it is an off-chain technology, the inside-channel transactions are highly secured and consistent — if any error occurs, we can always track the on-chain records and verify the details of a certain transaction.

Most of us are familiar with payment channels since this concept was born several years ago and manifested by the Lightning Network of Bitcoin. However, the general state channel technology is more than a way of payment, it can also update ‘state’ of the blockchain, such as changes in a smart contract.

Hence, we can comprehend the state channel technology as a generalized scaling solution for blockchain. It is also a widely adopted scaling solution in the current blockchain space. I will go through the state channel technology by its background, realization and progress in the following paragraphs.

I. Background of its creation — blockchain scaling

i. Why scaling?

Blockchain evolves so fast that people hold high expectation on the revolution it will bring, but low TPS in real use cases cast doubts on this emerging technology. While Ethereum boasts 1500+ dapps, a cryptokitty clogged the entire network. Earlier this year, FCoin new token listing rules again makes ethereum network suffer ‘indigestion’, which later was taken advantaged by hackers in Fomo3D game. Therefore, the current blockchain ecosystem needs scaling to speed up transactions.

ii. How to scale?

Where is the bottleneck limiting the blockchain performance?

1. P2P network: blockchain is a peer-to-peer network, where every node has to synchronize messages of the whole network. Any network latency will affect the efficiency.

2. Blocksize: there is a limit on the storage of each block, so when the number of transactions goes up, a lot of transactions will line up in the buffer and wait to be validated into the blocks.

3. Consensus: consensus is the core of blockchain. PoW mechanism will consume computing power and time when reaching consensus among nodes.

As a result, there are two main directions on scaling the blockchain:

1. Optimize blockchain itself to increase TPS

1) Restructure blocks

Bitcoin, for example, by moving signature data from the basic structure (about 1M in computational size) to the new structure, increased block size to 2M, thus doubling the amount of transactions in each block and lifting the TPS. This scaling solution is straight to the point but yield little effect. Unlimited block size will bring many security problems.

2) Change consensus

Due the inefficiency of PoW, more projects pro to use PoS, DPoS or PBFT to increase consensus efficiency. EOS, for instance, decreased block generation time to 0.5 seconds, which is a great improvement. However, there are also arguments criticizing EOS as it goes against the idea of decentralization.

3) Sharding

Sharding is a traditional scaling technology based on database shards. What sharding does is that it breaks down a transaction into shards and allocate them to different nodes. Instead of computing all the transactions in the network, each node only processes a small proportion of it. And the nodes work on individual shards side-by-side. This in turn decreases the computation cost and increases the processing power in a time unit as well as TPS. Sharding will take network, transactions and states into consideration, so implementation would be a great challenge.

2. Second-layer Scaling

Layer 2 scaling takes an opposite approach — putting transactions off-chain while leaving the on-chain protocol unchanged. This reduces on-chain operation and increases the throughput by making full use of off-chain computational power. Secondary layer network includes state channel technology and side chain structure.

1) Side Chains

Side chains are a separated network dependent on the main blockchain through 2WP. Side chains have every feature of blockchain, adopting an independent consensus algorithm and pegging smart contract or transactions when interacting with the main chain. Usually, side chains only need to maintain the state of themselves. By doing so, most of the transactions are processed on the side chain, thus lifting the load for the main chain.

2) State Channels

Comparatively, state channel is the lighter way of scaling. By locking on-chain, state channel will hold transactions off-chain between the parties, which makes the transactions more efficient with low cost. Different from side chains, state channel does not need consensus, lighting the process while achieving scalability.

II. Implementation and Core Ideas of State Channels

Implementation of State Channels

State channels are a strategy that aims to solve the scalability challenge by keeping the underlying blockchain protocol the same, instead changing how the protocol is used: rather than using the blockchain as a primary processing layer for every kind of transaction, the blockchain is instead used purely as a settlement layer. State update occurs more off the chain and the off-chain state will be updated on the blockchain only when necessary.

Moving transactions off the chain requires the following consensus reached by the parties to the transactions:

1. Transactions should occur on the chain, but they do not.

2. Participants in the transactions assume that the transactions occur on the chain and raise no objection for the outcome of the transactions.

3. Any participant in the transactions can submit the transactions to the blockchain at any time and these transactions can be executed fairly on the blockchain.

A transaction that occurs in a state channel is the one that is agreed upon by the parties to the transaction and confirmed by the parties via signature. As long as the parties manage the local transaction data, they can complete the transaction off the chain. Either party can broadcast its own transaction on the blockchain at any time without the need for the counterparty to fully agree, and move the off-chain transaction on the blockchain. Off-chain transactions require following characteristics:

1) Off-chain transactions should be an extension of the on-chain transactions. The transaction should be able to be executed on the chain and produce unique and deterministic results.

2) Deterministic signature of transaction parties. The parties to the transactions must reach a consensus on the transactions off the chain, and agree by signing the confirmed transactions.

3) Newer transactions generated off-chain can replace previous transactions. The replacement requires the confirmation of both parties by signature.

4) There is also a penalty system in off-chain transactions. If either party incorrectly broadcasts the transactions that are replaced, the counterparty may punish the perpetrator via penalty system.

5) Either party should be allowed to unilaterally broadcast its transactions on the chain without requiring the other party to agree or stay online.

With the above characteristics, on-chain transactions can be moved off-chain. As both parties wish, all of their transactions are only recorded off the chain and not necessarily on the chain. The effect is the same as on-chain transaction. Since transactions only occur in the channels, the problem of TPS is solved and the frequency of on-chain transactions is reduced, which relieves the stress of the blockchain and effectively alleviates “indigestion”.

III. Development History of State Channels

Since the payment channel of Lightning Network on the Bitcoin network, the technology has been moving forward at a rapid pace. Based on different chains, there are different approaches. Since last year, state channel projects have been springing up in the market. The most popular projects include Lightning Network on the Bitcoin network, Raiden Network on the Ethereum network and Trinity Network. Trinity has released 2 versions: Trintiy-Neo on the Neo network and Trinity-Eth on the Ethereum network. The other new projects also include generalized state channels (explained in later parts) of Counterfactual that is launched by L4 and the state channels that are used for Dapps, like FunFair and SpankChain, which are referred to as specific state channels.

What are payment channels, specific state channels, and generalized state channels? How does the technology of state channels develop? The development stages of state channels are listed as below:

1)Payment Channels

2)Specialized State Channels

3)Generalized State Channels

4)Cross-chain State Channels

i. Payment Channels

State channel scales the underlying blockchain. Based on that, the services supported by the channels rely on the characteristics of the underlying blockchain. Lightning Network was the first to propose state channels. It is a scaling solution based on the Bitcoin network and is also the birth place of state channels. As Bitcoin is a payment network, the service that the Lightning Network provides is payment. As such, the state channel of the Lightning Network is a classic payment channel. In the payment channel, constructing transactions for payment is the core of the channel. State here refers to the payment state. For example, Lightning Network is the payment channel for Bitcoin, and Trintiy-Neo for Neo and Gas.

ii. Specific State Channels

With rising influence of the Lighting Network, other blockchains start to build their own state channel network with enhanced functions. Newly developed blockchains boast more state changes of the smart contract, so the corresponding state channels not only convey payment state but also other states of the contract. The smart contract is firstly configured on the blockchain and stored off-chain. Then channel parties interact in the channel, thus changing the state of the contract. The final state of the contract will be synchronized on-chain. A specialized state channel depends on the on-chain contract, which often designed for one token (token contract) or one type of contract (ERC20), such as Lightning Network, Trinity-for-Ethereum (designed for ERC20 contract), and Trinity-for-Neo (designed for NEP5 contract). As ERC20 and NEP5 standards are mostly used to perform transactions, many people refer the state channels based on these standards as payment channels.

iii. Generalized State Channels

As the function of smart contract evolves, the contract itself will undertake more complex business logic. When facing increasing business requirements, specialized state channels begin to show the short-comings as it is not possible to build a state channel for every token or standard. So, people expect a generalized state channel that can adapt to all contracts. A generalized state channel will carry out the contract off-chain and deploy it on-chain when necessary. The underlying blockchain only focus on the final state of the contract. In this way, the generalized state channel can process all business of the contract.

iv. Cross-chain State Channels

Until now, state channels are still a scaling solution for underlying blockchains, which are isolated from each other. One state channel is limited to a certain blockchain. As cross-chain technology matures, cross-chain scaling is becoming an indispensable direction of scaling.

Cross-chain state channels can build upon cross-chain networks, serving as a third layer channels.

The advantage of cross-chain state channels is the simplification of the channel architect as it does not take cross-chain conversion mechanism into consideration and focus solely on the channel itself. This design, however, has a high dependency on the cross-chain network. So, flexibility and adaptability of channels would be compromised.

Another idea is making state channels pluggable components, embedding the cross-chain conversion as a part of the channel layer, and abstracting the channel layer out of the adaptive components such as blockchain adapter and the cross-chain converter. This will increase channel’s flexibility and adaptability and provide larger space for cross-chain scaling.

Summary:

State channel technology is the most widely used off-chain scaling solution for blockchain. It preserves the decentralization of blockchain while massively increase the throughput of transactions. Although the present state channels are mainly for payments, exploration on generalized state channels never stops. As an outstanding scaling solution, state channel technology will enable the blockchain to undertake more business scenarios in a foreseeable feature.


Trinity Core Dev Team

Trinity Telegram Channel: https://t.me/TrinityStateChannels

Official Website: https://trinity.tech/#/

Trinity Github: https://github.com/trinity-project

Trinity Protocol

Universal Off-chain scaling solution. Available at: http://trinity.tech; Official telegram community: https://t.me/TrinityStateChannels

TrinityProtocol

Written by

Universal Off-chain scaling solution. Available at: http://trinity.tech; Official telegram community: https://t.me/TrinityStateChannels

Trinity Protocol

Universal Off-chain scaling solution. Available at: http://trinity.tech; Official telegram community: https://t.me/TrinityStateChannels

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade