Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scaling Blockchain with state channels

Scaling Blockchain with state channels

Workshop/talk on Applications of blockchain in Cyber Security at "Deep learning for Big Data and Cyber Security Applications" Conference
Agenda:
Blockchain scaling issues
Layer 2 protocol basics
State channels and side chains
Lightning Network design
Setting up LN nodes
Interacting with LN nodes
Basic LApp
Raiden network
Payment channel
Payment network
Benefits and limitations
Getting started

Koshik Raj

July 02, 2019
Tweet

More Decks by Koshik Raj

Other Decks in Technology

Transcript

  1. Agenda • Blockchain scaling issues • Layer 2 protocol basics

    • State channels and side chains • Lightning Network design • Setting up LN nodes • Interacting with LN nodes • Basic LApp • Raiden network • Payment channel • Payment network • Benefits and limitations • Getting started
  2. Scaling issues in blockchain • Remember CryptoKitties? 7 TPS 50,000

    TPS • Bitcoin cannot scale like centralized payment gateways such as VISA ◦ In December, 2017, CryptoKitties clogged up Ethereum network due to increased transactions
  3. Why doesn’t blockchain scale? • CAP theorem states any distributed

    system cannot possess consistency, availability and partition tolerance properties • Due to blockchain trilemma, any DLT can possess only 2 of the 3 properties Scalability Decentralization Security
  4. How to scale? Layer 1 solution: • Modifying the core

    blockchain consensus algorithms to support higher transaction rates: • Increase the blocksize Layer 2 solutions: • Take the transaction outside blockchain (offchain transactions) ◦ State channels ◦ Sidechains
  5. Off-chain state channels Nodes create a channel and perform a

    series of transactions and commit only the final state to the blockchain Alice Bob
  6. Lightning Network (LN) • A layer-2 protocol built for Bitcoin

    based blockchain. • It was created to reduce the transaction fee for micropayments. • Lightning network essentially performs only 2 blockchain transactions for every channel • Currently runs beta implementation on Bitcoin mainnet
  7. A basic design • Create a payment channel by committing

    initial funds • Perform micro transactions using and update the funds in the channel • Close and broadcast the final state at any time to include in the blockchain Alice Bob Multisig account
  8. Channel commitments • Alice and Bob can perform any number

    of operations. • Every operation must create a commitment in the channel. • Finally commit the last transaction to the blockchain Alice Bob 10 10 07 13 05 06 6.5 15 14 13.5 03 02 01 0.5
  9. Trustless channel But there is a problem:“ What if either

    Alice or Bob commit any of the old commitment?” We need to create a trustless channel • Solution 1: Time locked commitments • Solution 2: Revocable commitments
  10. Time locked commitments Alice Bob 10 10 07 13 05

    06 6.5 15 14 13.5 03 02 01 0.5 +10 blocks +09 blocks +08 blocks +07 blocks
  11. Routed payment channel in LN • LN can perform transactions

    without creating a direct channel • Routed payment system uses Hash time lock contracts (HTLC) • HTLC makes sure that none of the actors in the routed channel can cheat Alice Carol Bob
  12. Routed payment channel in LN • Alice creates a routed

    channel with Carol via Bob • Carol creates a Secret and shares only its hash value • Alice constructs an HTLC worth 1.1 BTC and shares it with Bob • Bob constructs an HTLC worth 1.0 BTC and shares it with Carol • Funds are retrieved by Bob and Carol only after they disclose the secret 1.1 BTC 1.0 BTC 2.0 2.0 4.0 3.0 3.0 0.9 4.1 Alice Carol Bob
  13. LN implementations • There are several implementations of LN. Few

    of them are: ◦ Lightning network daemon (Scala implementation by Lightning Labs) ◦ C-lightning (C) ◦ Eclair (Go) • Huge number of apps (LApps) have been built using these LN implementations: ◦ FileBazar - A marketplace for images, video. ◦ Lightning Tip - Tipping service in LN ◦ HamerCoin - RPG that uses LN for payment
  14. Setting up Lightning nodes cluster 1. Install any LN node

    implementation 2. Configure the LN nodes with BTC node 3. Find other LN nodes and setup and connection 4. Create channels with the connected nodes
  15. Other layer 1 scaling solutions • Sharding ◦ Provides solution

    to the Increasing size of blockchain ◦ Ethereum is implementing sharding in the serenity release using PoS • Improved consensus algorithms: ◦ Variants of BFT (FBFT, DBFT) ◦ PoS, DPoS, PoET, PoA
  16. Raiden network ➔ Raiden Network is an off-chain scaling solution

    for performing ERC20-compliant token transfers on the Ethereum blockchain ➔ Ethereum’s version of Lightning Network ➔ Allows unlimited bidirectional transfers with the help of payment channels
  17. Payment channel ➔ Initial balances are locked into the smart

    contract ➔ Micro payments are made through balance proof (Hash locks) ➔ Either of the participants will produce the final transaction to the blockchain
  18. Payment channel network ➔ A network of channels to route

    a payment ➔ The network route should have enough token balance in the channels ➔ Optimised route will be selected for each transaction
  19. Benefits of Raiden ➔ Instant settlement of the fund transfer

    ➔ Scales payment system in any of the ERC20 token services ➔ Provides greater privacy of the transactions through private channel
  20. Limitations of Raiden ➔ Need to lock certain funds into

    the channel contract ➔ May not be suitable for payment needs of every use case ➔ May not find a suitable path for some of the transactions (higher value)
  21. Getting started ➔ Connect to an Ethereum full node (Mainnet,

    Testnet or Private) ➔ Start the Raiden client ➔ Register/join Raiden network ➔ Create a channel and deposit token ➔ Create a transaction