Bitcoin Summer School
Scorex, the Modular Blockchain Framework
Alexander Chepurnoy
(aka kushti)
@chepurnoy
IOHK Research
Section 1. „Scorex In General“
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
Use Cases
● Proof-of-Stake protocols
● Permacoin implementation
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
The Problem
● It is hard to locate, inject, swap functionalities
● Hard to make experiments/prototypes
Scorex in General
● Find fast where to inject
● Modular stacked design
● Externalised cryptography(scrypto)
● One testnet application atm(Lagonaki)
Scorex in General, pt 2
● Everything is open-sourced immediately
● CC0 license
● Maintained by IOHK Research
Competitors
Intel's „Sawtooth Lake“
(https://github.com/IntelLedger)
„a highly modular platform for building, deploying and
running distributed ledgers" (Intel Corp.)
Intel's „Sawtooth Lake“
● Consensus / „transaction family“
● Proof of Elapsed Time (Intel SGX)
● Assets marketplace
● Python
● Apache License 2.0
Section 2. „Scorex In Details“
Scorex is in Scala
● Functional language, strict static typing
● JVM
● Could be enhanced with any JVM language(Java, Clojure,
Kotlin, Groovy, Jython, Frege etc)
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!
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
A Module
● Writes and reads certain block parts
● Implements corresponding interface
Code Quality
● Compact code, strict types
● Good test coverage(70-80%)
● Continuous integration
Getting Started
● Docs on GitHub:
https://github.com/ScorexProject/Scorex/wiki/Getting-started
● Java 8 SDK
● sbt is recommended for Scala
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
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
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)
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]
)
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))
}
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)
}
UI
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
}
Lagonaki
● Permacoin implementation
● Simplest transactional module, account-2-account
payments
Launch Lagonaki
● docker run -i -p 9085:9085 "scorex/lagonaki:1.2.7"
● debian package
● https://github.com/ScorexProject/Lagonaki
Lagonaki Block Explorer
http://cryptorevolution.me/
Run own network
● src/main/resources/lagonaki.conf
app {
product = "Scorex"
release = "Lagonaki"
version = "1.2.7"
consensusAlgo = "perma"
}
Section 3. „Further Work“
1.2.7 → 1.3.0
● Flexible state models(now account-based)
● Flexible signing schemes(now EdDSA-25519 only)
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
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)
Section 4. „Coordination“
Contribution
● Comments
● Todos (search for „todo:“)
● Documentation
● Bugs
● Bitcoin UTXO model implementation (BitcoinJ)
● EVM implementation (EthereumJ)
Reach Us
● Maillist https://scorex-dev.groups.io/g/main
● GitHub https://github.com/ScorexProject
● https://iohk.io/team/
Questions?
https://github.com/ScorexProject/Scorex

Scorex, the Modular Blockchain Framework

  • 1.
    Bitcoin Summer School Scorex,the Modular Blockchain Framework Alexander Chepurnoy (aka kushti) @chepurnoy IOHK Research
  • 2.
    Section 1. „ScorexIn General“
  • 3.
    Use Cases ● Implementnew 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.
    Use Cases ● Proof-of-Stakeprotocols ● Permacoin implementation
  • 5.
    The Problem ● Bitcoin(referenceimpl): > 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.
    The Problem ● Itis hard to locate, inject, swap functionalities ● Hard to make experiments/prototypes
  • 7.
    Scorex in General ●Find fast where to inject ● Modular stacked design ● Externalised cryptography(scrypto) ● One testnet application atm(Lagonaki)
  • 8.
    Scorex in General,pt 2 ● Everything is open-sourced immediately ● CC0 license ● Maintained by IOHK Research
  • 9.
    Competitors Intel's „Sawtooth Lake“ (https://github.com/IntelLedger) „ahighly modular platform for building, deploying and running distributed ledgers" (Intel Corp.)
  • 10.
    Intel's „Sawtooth Lake“ ●Consensus / „transaction family“ ● Proof of Elapsed Time (Intel SGX) ● Assets marketplace ● Python ● Apache License 2.0
  • 11.
    Section 2. „ScorexIn Details“
  • 12.
    Scorex is inScala ● Functional language, strict static typing ● JVM ● Could be enhanced with any JVM language(Java, Clojure, Kotlin, Groovy, Jython, Frege etc)
  • 13.
    Development Philosophy ● Flexibledesign 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.
    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.
    A Module ● Writesand reads certain block parts ● Implements corresponding interface
  • 16.
    Code Quality ● Compactcode, strict types ● Good test coverage(70-80%) ● Continuous integration
  • 17.
    Getting Started ● Docson GitHub: https://github.com/ScorexProject/Scorex/wiki/Getting-started ● Java 8 SDK ● sbt is recommended for Scala
  • 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.
    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.
    Application - modules classMyApplication(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.
    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.
    Application – networkprotocols // 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.
    Launch The Application objectMyApplication 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.
  • 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.
    Lagonaki ● Permacoin implementation ●Simplest transactional module, account-2-account payments
  • 27.
    Launch Lagonaki ● dockerrun -i -p 9085:9085 "scorex/lagonaki:1.2.7" ● debian package ● https://github.com/ScorexProject/Lagonaki
  • 28.
  • 29.
    Run own network ●src/main/resources/lagonaki.conf app { product = "Scorex" release = "Lagonaki" version = "1.2.7" consensusAlgo = "perma" }
  • 30.
  • 31.
    1.2.7 → 1.3.0 ●Flexible state models(now account-based) ● Flexible signing schemes(now EdDSA-25519 only)
  • 32.
    Ergaki ● Blockchain forprotocols ● Rollerchain implementation: safely prunable fullblocks ● Σ-coin implementation: wide class of NIZKPoK for DLOG statements ● Rent-a-Box fee model ● Improved difficulty adjustment
  • 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.
  • 35.
    Contribution ● Comments ● Todos(search for „todo:“) ● Documentation ● Bugs ● Bitcoin UTXO model implementation (BitcoinJ) ● EVM implementation (EthereumJ)
  • 36.
    Reach Us ● Maillisthttps://scorex-dev.groups.io/g/main ● GitHub https://github.com/ScorexProject ● https://iohk.io/team/
  • 37.