Scorex, the Modular Blockchain Framework

639 views

Published on

Slides from my talk @ Bitcoin Summer School Corfu, 2016

Published in: Engineering
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
639
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
17
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Scorex, the Modular Blockchain Framework

  1. 1. Bitcoin Summer School Scorex, the Modular Blockchain Framework Alexander Chepurnoy (aka kushti) @chepurnoy IOHK Research
  2. 2. Section 1. „Scorex In General“
  3. 3. Use Cases ● Implement new consensus protocol and plug it easily into a prototypical blockchain system to run a system against a testbed ● In the same way, implement and spread a proof-of-concept impl. for anew transactional language
  4. 4. Use Cases ● Proof-of-Stake protocols ● Permacoin implementation
  5. 5. The Problem ● Bitcoin(reference impl): > 80K lines of C++ code ● EthereumJ: > 55K of Java code ● Nxt: > 40K lines of Java code ● Every codebase is highly optimized for a concrete production environment
  6. 6. The Problem ● It is hard to locate, inject, swap functionalities ● Hard to make experiments/prototypes
  7. 7. Scorex in General ● Find fast where to inject ● Modular stacked design ● Externalised cryptography(scrypto) ● One testnet application atm(Lagonaki)
  8. 8. Scorex in General, pt 2 ● Everything is open-sourced immediately ● CC0 license ● Maintained by IOHK Research
  9. 9. Competitors Intel's „Sawtooth Lake“ (https://github.com/IntelLedger) „a highly modular platform for building, deploying and running distributed ledgers" (Intel Corp.)
  10. 10. Intel's „Sawtooth Lake“ ● Consensus / „transaction family“ ● Proof of Elapsed Time (Intel SGX) ● Assets marketplace ● Python ● Apache License 2.0
  11. 11. Section 2. „Scorex In Details“
  12. 12. Scorex is in Scala ● Functional language, strict static typing ● JVM ● Could be enhanced with any JVM language(Java, Clojure, Kotlin, Groovy, Jython, Frege etc)
  13. 13. Development Philosophy ● Flexible design could be hard to understand ● Simple code could be not flexible or error-prone ● We need to find a balance! ● Give a maximum for free!
  14. 14. Design In General ● Compact core – always for free ● Consensus module - implement or take ready ● Transactional module - implement or take ready ● Network protocols – partly for free ● API – partly for free ● Application – lean! ● Wallet, configs – partly for free
  15. 15. A Module ● Writes and reads certain block parts ● Implements corresponding interface
  16. 16. Code Quality ● Compact code, strict types ● Good test coverage(70-80%) ● Continuous integration
  17. 17. Getting Started ● Docs on GitHub: https://github.com/ScorexProject/Scorex/wiki/Getting-started ● Java 8 SDK ● sbt is recommended for Scala
  18. 18. Adding Modules libraryDependencies ++= Seq( "org.consensusresearch" %% "scorex-basics" % "1.+", "org.consensusresearch" %% "scorex-consensus" % "1.+", "org.consensusresearch" %% "scorex-transaction" % "1.+" ) scorex-basics -core scorex-consensus - two Proof-of-Stake consensus protocols scorex-transaction – simplest transactions
  19. 19. Adding Modules libraryDependencies ++= Seq( "org.consensusresearch" %% "scorex-basics" % "1.+", "org.consensusresearch" %% "scorex-perma" % "1.+", "org.consensusresearch" %% "scorex-transaction" % "1.+" ) scorex-perma – Permacoin consensus protocol implementation
  20. 20. Application - modules class MyApplication(val settingsFilename: String) extends Application { // Your application config override val applicationName = "my cool application" override val appVersion = ApplicationVersion(0, 1, 0) override implicit lazy val settings = new Settings with TransactionSettings { override val filename: String = settingsFilename } // Define consensus and transaction modules of your application override implicit lazy val consensusModule = new NxtLikeConsensusModule() override implicit lazy val transactionModule = new SimpleTransactionModule()(settings, this)
  21. 21. Application - API // Define API routes of your application override lazy val apiRoutes = Seq( BlocksApiRoute(this), TransactionsApiRoute(this), NxtConsensusApiRoute(this), WalletApiRoute(this), PaymentApiRoute(this), UtilsApiRoute(this), PeersApiRoute(this), AddressApiRoute(this) ) // API types are required for swagger support override lazy val apiTypes = Seq( typeOf[BlocksApiRoute], typeOf[TransactionsApiRoute], typeOf[NxtConsensusApiRoute], typeOf[WalletApiRoute], typeOf[PaymentApiRoute], typeOf[UtilsApiRoute], typeOf[PeersApiRoute], typeOf[AddressApiRoute] )
  22. 22. Application – network protocols // Create your custom messages and add them to additionalMessageSpecs override lazy val additionalMessageSpecs = TransactionalMessagesRepo.specs // Start additional actors actorSystem.actorOf(Props(classOf[UnconfirmedPoolSynchronizer], this)) }
  23. 23. Launch The Application object MyApplication extends App { // Provide filename by command-line arguments val filename = args.headOption.getOrElse("settings.json") // Create application instance val application = new MyApplication(filename) // Run it application.run() // Generate account in your wallet if (application.wallet.privateKeyAccounts().isEmpty) application.wallet.generateNewAccounts(1) }
  24. 24. UI
  25. 25. Settings https://github.com/ScorexProject/Scorex/wiki/Settings { "p2p": { "bindAddress": "0.0.0.0", "upnp": false, "upnpGatewayTimeout": 7000, "upnpDiscoverTimeout": 3000, "port": 9084, "knownPeers": [ "23.94.190.226:9185" ], "maxConnections": 10 }, "walletDir": "/tmp/scorex/wallet", "dataDir": "/tmp/scorex/data", "rpcPort": 9085, "rpcAllowed": [], "maxRollback": 100, "blockGenerationDelay": 0, "genesisTimestamp": 1460952000000, "apiKeyHash": "GmVvcpx1BRUPDZiADbZ7a6zgQV3Sgj2GhNoEiTH9Drdx", "cors": false }
  26. 26. Lagonaki ● Permacoin implementation ● Simplest transactional module, account-2-account payments
  27. 27. Launch Lagonaki ● docker run -i -p 9085:9085 "scorex/lagonaki:1.2.7" ● debian package ● https://github.com/ScorexProject/Lagonaki
  28. 28. Lagonaki Block Explorer http://cryptorevolution.me/
  29. 29. Run own network ● src/main/resources/lagonaki.conf app { product = "Scorex" release = "Lagonaki" version = "1.2.7" consensusAlgo = "perma" }
  30. 30. Section 3. „Further Work“
  31. 31. 1.2.7 → 1.3.0 ● Flexible state models(now account-based) ● Flexible signing schemes(now EdDSA-25519 only)
  32. 32. Ergaki ● Blockchain for protocols ● Rollerchain implementation: safely prunable fullblocks ● Σ-coin implementation: wide class of NIZKPoK for DLOG statements ● Rent-a-Box fee model ● Improved difficulty adjustment
  33. 33. Scrypto ● Еncoding functions(Base16/58/64) ● Hash functions(Blake2, Keccak etc) ● 25519 from WhisperSystems ● Authenticated data structures(Merkle trees, authenticated skiplists coming in next release)
  34. 34. Section 4. „Coordination“
  35. 35. Contribution ● Comments ● Todos (search for „todo:“) ● Documentation ● Bugs ● Bitcoin UTXO model implementation (BitcoinJ) ● EVM implementation (EthereumJ)
  36. 36. Reach Us ● Maillist https://scorex-dev.groups.io/g/main ● GitHub https://github.com/ScorexProject ● https://iohk.io/team/
  37. 37. Questions? https://github.com/ScorexProject/Scorex

×