Skip to content

Latest commit

 

History

History
525 lines (350 loc) · 10.3 KB

skycoin.libs.md

File metadata and controls

525 lines (350 loc) · 10.3 KB

Skycoin client libraries

Foundations of 3rd generation DApps



Copyright 2019 Skycoin project


Outline

  • How do cryptocurrencies work?
  • Skycoin Ecosystem
  • Understanding API sets
  • Node REST API endpoints
  • Open API specs
  • Future work

Recap

--

Replicated State Machines

  • Deploy replicas of the software
  • Receive client requests (i.e. inputs)
  • Order the inputs
  • Execute SM transition over and over
  • Monitor replicas for differences in State or Output

--

The scalability problem

--

Stats of the Bitcoin blockchain

--

Skycoin logo

  • Why Skycoin?
  • Core values
  • Five pillars of Skycoin
  • Understanding Skycoin transactions
  • Skycoin ecosystem
  • What's next?

  • Issues with Proof of Work
  • Proof of Stake: More Centralization Problems
  • Technical improvements
    • Security problems associated with other blockchain networks
    • Decouple coin creation from the "mining" process
    • Fast confirmation of transaction
  • Inflationary policies
    • The supply of Skycoin is fixed

--

Issues with proof of work

  • Control of the network => economic power
  • Monopolization of mining
  • Incentivized the purchase of hashing power
    • Disproportionate control over the network.
    • Bitcoin => SlushPool , Bitmain , BTCC
    • revert and falsify transactions 51% attack
  • Economic and environmental cost

--

SlushPool

Hash rate distribution

--

Bitcoin inflation

  • Transaction fees and inflation bleeding users dry.
    • Over $50, and go to centralized mining pools.
  • More expensive than international bank transfer

  • Skycoin a coin technically better than Bitcoin
  • Skywire a mesh network
  • Fiber, like Ethereum's ERC20, but better
    • Every coin their own blockchain
    • CX programming language
    • add your own features
  • DApps ecosystem
  • Our own hardware platform

Bitcoin - Problems with UTXO

![BTC TX c60e4dc5e69c19ff53a45954d8a8996fd9aac6fda317fd7238dec6a482c718cf](img/bitcoin.tx.c60e4dc5e69c19ff53a45954d8a8996fd9aac6fda317fd7238dec6a482c718cf.png)
  • Dust attack
    • Resource exhaustion
    • RAM and disk space

Skycoin UXTX Spending

UXTX graph

  • Pruning spent UX is easy
  • No mining, no fee (no mining, no fee ...)
    • Proof of burn - CoinHours

--

Skycoin Coin Hours

The Fuel for the Skycoin ecosystem
  • Holding Skycoin in a wallet
    • ... automatically generates Coin Hours
    • 1 SKY * 1 hour = 1 Coin Hour.
  • Keep the Skywire network free of transaction fees.
  • Virtual cat games can't skyrocket tx fees up 1600%
    • Recent issue in the Ethereum network.
  • Users never pay to access and use the network

--

Skycoin Coin Hours

What if ... ?

  • ... Coin Hours inflate dramatically
    • Max = 100 million Coin Hour per hour
    • Will be reached in decades
  • ... no transactions ever took place on the network
    • max Coin Hours would not exceed uint64 for centuries.

--

Skycoin Spending transactions

Proof of burn

Burn percents Coin Hours

--

Skycoin spend example

Comparison of number of purchases

Skycoin Purchases

--

Skycoin spend example

After 1 hour

Skycoin purchase results


Skycoin Protocol Overview

  • No DNS during P2P discovery

Skycoin P2P protocol


Skycoin logo

  • Wallets
    • Desktop (Electron), Android, iOS
  • Exchange integrations
  • CX programming language
    • Smart contracts
  • DApps

A community of developers

  • CX
  • Use your preferred programming language

Skycoin core libraries

Skycoin libraries overview

--

Skycoin core libraries

  • Transpiled
    • go src => transpiler => lang X src => ...
    • e.g. skycoin-lite
    • need maintenance
  • Crypto API
    • go src => cgo => binary + header => ...
  • REST API
    • go annotations => swagger => spec => lang X src => ...

What are API sets?

  • Groups API endpoints
  • Related in intent
  • Enabled / disabled at once via CLI
    • --enable-api-sets
    • -disable-api-sets
    • -enable-all-api-sets

Skycoin 0.25.1 API sets

  • READ - Query data. Read only.
  • STATUS - A subset of READ exposing node status
    • Application
    • Network
    • Blockchain
  • PROMETHEUS - Node metrics in Prometheus text format

Skycoin 0.25.1 API sets

  • TXN - Transaction ops (no wallet)
  • WALLET - Local wallet files
  • NET_CTRL - Network admin
  • INSECURE_WALLET_SEED - BIP39 mnemonic
    • Used by desktop wallet only

Swagger a.k.a Open API

  • Model driven (Swagger spec)
  • Literate programming go-swagger
    • Generate Swagger spec from annotations
    • only v2, no v3 support
  • Auto-generate
    • REST client / server code
    • Documentation
    • Database models
    • ...

--

Why Open API v3

URI: /api/v1/transaction
Method: GET
Args:
    txid: transaction id
    verbose: [bool] include verbose transaction input data
    encoded: [bool] return the transaction as hex-encoded serialized bytes

--

{
    ...
        "inputs": [
            "5287f390628909dd8c25fad0feb37859c0c1ddcf90da0c040c837c89fefd9191"
        ],
    ...
}

--

{
    ...
        "inputs": [
            {
                "uxid": "5287f390628909dd8c25fad0feb37859c0c1ddcf90da0c040c837c89fefd9191",
                "owner": "2K6NuLBBapWndAssUtkxKfCtyjDQDHrEhhT",
                "coins": "8.000000",
                "hours": 7454,
                "calculated_hours": 7454
            }
        ],
    ...
}

Other projects

  • Skywire
  • Hardware wallet daemon
  • CXO
  • DApps (BBS, ...)

Swagger client libraries

Status

  • Partially tested
    • Python, .NET, Java
  • Fully generated
    • Objective-C, C (libcurl), Ruby
    • PHP, Javascript (node + axios)
  • Work in progress

Hardware wallet daemon

finished before product itself

Skycoin hardware wallet architecture


REST API test suite - golang

TestVersion test case @ v0.26.0

TestVersion test case

--

REST API test suite - golang

newClient @ v0.26.0

newClient test function


Doing tests using docker

--

Ruby

Setup library ruby

git clone http://[email protected]:30080/simelo/python-hackday.git

cd ruby-hackaday

docker run -it --network=host -v $(pwd):/app -w /app ruby-sky-meetup /bin/bash

--

Python

Setup library python

git clone http://[email protected]:30080/simelo/python-hackday.git

cd python-hackaday

docker run -it --network=host -v $(pwd):/app -w /app skyapi-python-meetup /bin/bash

--

Dotnet

Setup library dotnet

git clone http://[email protected]:30080/simelo/python-hackday.git

cd dotnet-hackaday

docker run -it --network=host -v $(pwd):/app -w /app skyapi-dotnet-meetup /bin/bash

Testing with unittest in python

Unittest Example

--

import skyapi
import unittest

configuration = skyapi.Configuration()
configuration.host = 'http://localhost:6420'
api_instance = skyapi.DefaultApi(skyapi.ApiClient(configuration))

class TestSum(unittest.TestCase):
    def test_version(self):
        """
        Test /api/v1/version
        """
        result = api_instance.version()

        self.assertEqual(result['branch'], 'v0.26.0')
        self.assertEqual(result['commit'], 'ff754084df0912bc0d151529e2893ca86618fb3f')
        self.assertEqual(result['version'], '0.26.0')

if __name__ == '__main__':
    unittest.main()

--

Testing with RSpec in ruby

Rspec Example

--

require 'sky_api'

api_instance = SkyApi::DefaultApi.new
api_instance.api_client.config.host = 'http://localhost:6420'

describe 'version' do
  result = api_instance.version
  
  it 'check branch' do
    expect(result.branch).to eq 'v0.26.0'
  end
  
  it 'check version' do
    expect(result.commit).to eq 'ff754084df0912bc0d151529e2893ca86618fb3f'
  end

  it 'check commit' do
    expect(result.version).to eq '0.26.0'
  end
end

--

Testing with Xunit in Dotnet

Xunit Example

--

public class UnitTest1
{
    [Fact]
    public void Version() {

    Configuration.Default.BasePath = "http://localhost:6420";
    var apiInstance = new DefaultApi(Configuration.Default);

    try {
        var result = apiInstance.Version();
        Assert.Equal("v0.26.0", result.Branch);
        Assert.Equal("ff754084df0912bc0d151529e2893ca86618fb3f", result.Commit);
        Assert.Equal("0.26.0", result.Version);
        Console.WriteLine(result);
    }
    ...

What's next?


Thanks for your attention!

Questions?