Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Blockchain with scala

28 views

Published on

2018-11-20 Goteborg

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

Blockchain with scala

  1. 1. Blockchain with Scala Hongchao Liu
  2. 2. Agenda ● The significance or insignificance of the blockchain. ● Dive into Bitcoin, the foundation of all blockchains. ● Verify real Bitcoin transactions in Scala ● Zoom out and look at Scorex and see how it generalizes a lot of the Bitcoin concepts.
  3. 3. What is Blockchain? ● Chain of blocks linked by hash pointers? ● Distributed event sourcing? ● Peer to peer digital money / gold? ● Platform that runs unstoppable programs? ● Decentralized web (a.k.a web3)? ● A new asset class? ● Token economy? ● New financial revolution / Bank 2.0? ● Decentralized autonomous organization (DAO)? ● Criminal / Silk road / Money laundry? ● Hyped useless crap? ● Ponzi scheme ● ……
  4. 4. What is Blockchain? ● Centralized trust ○ Implies power, power corrupts ○ No need to encode it ● Decentralized trust ○ Didn’t exist a way to encode it ● No way to encode trust in a program before ● What does it take to encode decentralized trust?
  5. 5. Programming Decentralized Trust ● What kind of trust ○ Understand the problem! ● “Hard” trust ○ Science side of things ○ Pigs can’t fly ● “Soft” trust ○ Game theoretical side of things ○ Pigs will continue to exist as an specie in 100 years ● Glue the “hard” and the “soft” ○ Machine + Human ○ “Full stack” blockchain developer ○ Key: incentive has to exist on Machine side
  6. 6. Bitcoin ● What kind of trust ○ Ownership of money ○ No double spend ○ Transaction processed in timely manner ○ Other characteristics (e.g. 21m cap) ● “Hard” trust ○ Cryptography (Hash, Pubkey crypto) ○ Immutable data structures ● “Soft” trust ○ Market economy ● Glue the “hard” and the “soft” ○ Bitcoin token itself! ○ Proof of work (Nakamoto Consensus)
  7. 7. The Bitcoin Event Sourcing Block Transaction Transaction Transaction Transaction Block Transaction Transaction Transaction Transaction Events Block Transaction Transaction Transaction Transaction Block Transaction Transaction Transaction Transaction Block Transaction Transaction Transaction Transaction PoW Event store View store UTXO set Update Query
  8. 8. Data model - Transaction ● The UTXO model ● Unlock multiple inputs ● Lock multiple outputs ● Unlimited types of locks and keys ○ Bitcoin Script (Smart contract) ○ Encodes ownership of the coin ○ Center of innovation ○ E.g. Multi-sig, lightning, MAST, Segwit Transaction 1 Transaction 3 Locking LockingUnLocking
  9. 9. Bitcoin Script P2PKH, Source: Mastering Bitcoin
  10. 10. Data model - Transaction Demo
  11. 11. Bitcoin script debugger ● https://nioctib.tech ● Step through execution of real Bitcoin transactions. ● More info can be displayed
  12. 12. Scorex ● Blockchain framework ● Small codebase ~4k Scala ● Well typed abstractions ● Implemented network layer, wallet, node, APIs, etc
  13. 13. Scorex’s blockchain abstractions Scorex Bitcoin History (HS) Blockchain Minimal State (MS) UTXO set Memory Pool (MP) Memory Pool NodeViewHolder Full node NodeViewModifier Block / Transaction Vault (VL) Wallet Box Transaction input / output Proposition / Proof Locking / Unlocking Script
  14. 14. Scorex - Twincoin ● PoW / PoS hybrid ● UTXO model without script ● Transaction / Blocks
  15. 15. More Scala crypto projects ● Eclair ○ Scala implementation of lightning network ○ code: https://github.com/ACINQ/eclair ● Waves platform ○ Platform for storing, managing, trading, issuing tokens. Built on top of Scorex. ○ code: https://github.com/wavesplatform/Waves ● Mantis ○ Ethereum Classic Client ○ code: https://github.com/input-output-hk/mantis ● Rchain ○ Smart contract platform built for “efficiency and scalability” ○ code: https://github.com/rchain/rchain
  16. 16. Thanks

×