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

Introduction to stellar-core

Eva
September 09, 2015

Introduction to stellar-core

Nicolas Barry explores stellar-core, the code that powers the Stellar network.

Stellar is an open network that lets you send money as easily as email, for a fraction of a fraction of a cent.

Eva

September 09, 2015
Tweet

More Decks by Eva

Other Decks in Technology

Transcript

  1. BEFORE WE START ! Stellard = code that runs the

    old network ! I am not talking about this today. ! New stack is built with different priorities and design principles ! Complete rewrite ! This presentation.
  2. AGENDA ! High level goals ! Design principles ! High

    level architecture ! New features ! Q&A
  3. HIGH LEVEL GOALS ! ! The only limiting factor to

    the ecosystem of apps written on Stellar should be entrepreneurs’ creativity ! Simple APIs ! Easy to write secure and correct code ! Rich developer community around the Stellar stack ! Low bar of entry ! Leverage skills of all developers ! Running the network should be cheap and easy ! Design for billions of accounts and thousands of transactions per second running on commodity hardware
  4. DESIGN PRINCIPLES ! Split the notion of “Core protocol” and

    middleware goodness ! “Core protocol implementation” == stellar-core ! Unlock innovation where people have expertise ! The “Core protocol” is standard ! Simple to understand and validate ! Documented, aiming for RFC ! Bar for writing correct and secure applications on top of stellar-core should be low ! Clear split between Stellar-core components (historical vs real time) ! Runtime is predictable: quality, performance
  5. ARCHITECTURE:
 BASIC RESPONSIBILITIES ! Manages the ledger chain ! Ledger

    = state of all entries (Accounts, Order Book, etc.) + link to previous ledger ! Picks the set of transactions to include in the next ledger ! Enforces invariants ! Transaction validity ! Signatures ! No double spend ! Consistent ledger state (minimum balance, etc.) ! P2P, Designed for decentralized runtime
  6. LEDGER BASICS: APPLYING TRANSACTIONS Ledger #1000 {A=100, B = 1000,

    C = 5000} • A: send 10 to B • A: send 20 to C Ledger #1001 {A=70, B = 1010, C = 5020} • A: send 10 to B • B: send 20 to C Ledger #1002 {A=60, B= 1000, C = 5040}
  7. LEDGER BASICS: DATA ! Stellar-core is optimized to make changes

    to the “latest ledger”. ! While doing so, it also generates data kept in a historical data store. ! For new nodes to catch up ! Confirm transactions and their results ! Auditing
  8. LEDGER BASICS: LEDGER CHAIN Ledger 1000 • State = {A=100,

    B = 1000, C = 5000} • Transaction Set 1000 Ledger 999 • State = {A=70, B = 1010, C = 5020} • Transactio n Set 999 Ledger … Ledger 1 (genesis) • State = {} • (no transactio ns)
  9. KEY CHANGES : THE STACK Clients/Gateways APIs • Ledger API

    • Historical APIs Core engine • Consensus • P2P • Storage Working set store (SQL) • stellar- core engine • Ledger API Transaction Meta Data (SQL) • Raw historical store (S3) • History APIs Processed historical store (*SQL) • Processor • Extende d APIs Then Now Dev Expertise: C++ Full Stack Storage stellard Consensus P2P
  10. KEY CHANGES: THE STACK ! Ledger API ! Query the

    current state of the ledger (latest) ! Submit transactions to the network ! History API ! Transactions results ! Transaction history for an account ! State of an account at arbitrary point in time ! Extended APIs ! Path finding ! Complex auditing ! <your new idea here>
  11. PROGRESS ! Enable a rich ecosystem ! Horizon (go/ruby) !

    <your work here> ! Easy to write secure and correct code ! Protocol definition in XDR for both input and output (strict & less bugs) ! Ease of access for core contributors ! Nimble code base: 45k lines of code (from 200k without much tests) ! C++ 11 ! Low bar of entry for running nodes ! Low memory and CPU footprint ! Rich built in metrics for monitoring all parts of the system
  12. NEW FEATURES ! Low level ! New consensus algorithm (SCP)

    ! Rich support for protocol upgrade ! Multi-sig ! Batching ! Simple contracts ! New asset classes ! Federation (KYC)
  13. MULTI-SIG: INTRO ! An account has the following optional properties:

    ! List of (signer, weight) – signer is just a public key, weight a number ! thresholds for various operations ! ! A transaction originating from an account is validated by computing the sum of the weights of all signatures attached to the transaction
  14. MULTI-SIG: EXAMPLE ! An account (A,10) has (S1, 3) and

    (S2, 3) and a threshold of 3 for medium operations, and 6 for high operations. ! Such an account can: ! Send a payment using any one of A, S1 or S2. ! Change the policy either by signing a “change policy” operation with A or by signing with both S1 and S2. ! Changing the threshold to 10 for high operations would cause only A to have the right to change the policy. ! The key trivially associated with A is called the “master key”.
  15. BATCHING ! Transactions are now conceptually decoupled from what we

    call operations. ! An operation is something like “Payment” or “Create an offer”. ! A transaction is an ordered list of operations that get applied in order atomically. ! If all operations succeed, the transaction is considered “successful” ! If one of the operations fails, the transaction is marked as “failed” and none of the operations are applied
  16. MULTI-SIG+BATCHING Batching gets particularly powerful when combined with multi-sig as

    operations can operate on different accounts within the same transaction.
  17. MULTI-SIG+BATCHING: EXAMPLE ! Private exchange without third party/escrow ! !

    A wants to send B some credits X (Operation 1) in exchange for credits Y (Operation 2). ! ! The transaction looks like: ! Operation 1 = A: send X -> B ! Operation 2 = B: send Y -> A ! ! The transaction needs to be signed with signatures that control accounts A and B. ! In this case the transaction needs to be signed by A, S1 or S2 ; and by B
  18. WHAT NEXT? ! Launch of production network ! (fix bugs)

    ! Iterate from feedback ! Compliance & Privacy
  19. THIS IS JUST THE BEGINNING ! The Stack built on

    top of stellar-core is really a family of stacks ! Horizon is the first pass at what can be built on Stellar ! ! I envision many other stacks or mini stacks built on top of the low level primitives ! Some may push more logic client side, removing the need for trusting single services (ssl-proxy like access to the network as a whole). ! ! Some will probably come to light with alternate implementations of stellar-core that expose new ways to communicate what the network is doing to other layers
  20. THANK YOU ! Resources ! stellar-core GitHub https://github.com/stellar/stellar-core/ ! IRC/Slack

    #stellar-dev ! Documentation https://www.stellar.org/developers/ ! Ask me questions @MonsieurNicolas