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

20k mRuby devices in Production

20k mRuby devices in Production

One of the biggest cases of mruby in world. I've changed an entire solid runtime for mRuby, and for 3 years, even if is not recommend, we've been running mRuby in production reaching 20k machines and billons of dollars in payment transactions. We faced a lot of problems, but even more benefits adopting mRuby. This talk is about those topics, like:

Runtime and application Update/Upgrade
Communication configuration and intelligence
Payment transaction security and cryptography
Concurrency
Code sharing between CRuby and mRuby
Memory management and leaks
Open Source

Scalone

June 01, 2018
Tweet

More Decks by Scalone

Other Decks in Programming

Transcript

  1. @scalone
    20k mRuby devices
    Production
    Thiago Scalone - @scalone

    View Slide

  2. @scalone
    こんばんは
    私の名前はThiago Scalone です よろしくお願いします!
    私はブラジルのソフトウェアエンジニアです

    View Slide

  3. @scalone

    View Slide

  4. @scalone
    Speak Portuguese, not Spanish
    Not everyone likes socker/football
    Some people like contact and hugs
    We do Party and drink
    We work hard
    Brazilian

    View Slide

  5. @scalone
    @scalone
    Free hugs!

    View Slide

  6. The digital payment acquirer
    @scalone

    View Slide

  7. @scalone

    View Slide

  8. @scalone

    View Slide

  9. @scalone

    View Slide

  10. @scalone

    View Slide

  11. @scalone

    View Slide

  12. Payment acquirers are very inefficient


    Most using outdated technology


    Incapable of offering digital products
    @scalone

    View Slide

  13. @scalone

    View Slide

  14. @scalone
    @scalone

    View Slide

  15. @scalone
    @scalone

    View Slide

  16. @scalone
    @scalone

    View Slide

  17. @scalone
    @scalone

    View Slide

  18. @scalone
    @scalone

    View Slide

  19. @scalone
    ERC20
    @scalone

    View Slide

  20. @scalone
    ERC20

    View Slide

  21. @scalone
    Demo application creation/deploy
    Runtime and application Update/Upgrade
    Communication configuration and intelligence
    Payment transaction security and cryptography
    Code sharing between CRuby and mRuby
    Concurrency / Memory management and leaks
    Demo chip/pin Payment Transaction
    Topics

    View Slide

  22. @scalone
    Demo
    Thiago Scalone - @scalone

    View Slide

  23. @scalone
    @scalone

    View Slide

  24. @scalone
    CLI
    @scalone

    View Slide

  25. @scalone
    PROJECT
    CLI
    @scalone

    View Slide

  26. @scalone
    PROJECT
    COMPILE
    CLI
    @scalone

    View Slide

  27. @scalone
    PROJECT
    COMPILE
    DEPLOY
    CLI
    @scalone

    View Slide

  28. @scalone
    PROJECT
    COMPILE
    DEPLOY
    CLI
    RUN
    @scalone

    View Slide

  29. @scalone
    PROJECT
    COMPILE
    DEPLOY
    CLI
    RUN
    @scalone

    View Slide

  30. @scalone
    PROJECT
    COMPILE
    DEPLOY
    CLI
    RUN
    mRuby
    mruby-cli
    da_funk
    @scalone

    View Slide

  31. @scalone
    Created by Matz
    Small
    Cross-compilation / ANSI C
    Modular
    No gems, mrbgems static compilation
    .mrb
    https://github.com/mruby/mruby
    mRuby

    View Slide

  32. @scalone
    CLI apps framework
    Created and maintained by hone, zzak and toch
    Power of mruby to generate standalone binary
    Linux, Windows, and OS X
    Docker Compose
    https://github.com/hone/mruby-cli
    https://github.com/cloudwalkio/cloudwalk
    mruby-cli

    View Slide

  33. @scalone
    Open Source IOT Embedded Framework
    Created by CloudWalk
    Adopt adapter pattern to hardware interface
    Compilation and packaging tools
    Helpers
    https://github.com/cloudwalkio/da_funk
    da_funk

    View Slide

  34. @scalone
    lib/device/
    !"" application.rb
    !"" audio.rb
    !"" crypto.rb
    !"" display.rb
    !"" io.rb
    !"" magnetic.rb
    !"" network.rb
    !"" printer.rb
    !"" runtime.rb
    !"" system.rb
    #"" version.rb
    class Device
    class Audio
    def self.adapter
    Device.adapter::Audio
    end
    def self.beep(tone, seconds)
    milli = seconds * 1000
    adapter.beep(tone, milli)
    end
    end
    end
    da_funk
    da_funk

    View Slide

  35. @scalone
    @scalone
    GPRS/3G/WIFI
    Persistent Connection
    TCP + TLS 1.2
    WebSocket
    Download in chunks

    View Slide

  36. @scalone
    Push Notification / Transaction / Package Download
    Past ISO8583 and Serfx :(
    Ping 6 bytes and Data Consumption (2mb limit per month)
    Inflate/deflate
    Heroku
    Implemented by DaFunk
    WebSocket

    View Slide

  37. @scalone
    AT Command Interface Ruby
    Communication

    View Slide

  38. @scalone
    AT Command Interface Ruby
    Attach
    Connection Management
    Communication

    View Slide

  39. @scalone
    Security and Crypto

    View Slide

  40. @scalone
    PTS Terminal
    3DES + Working Key
    PIN / DATA DUKPT (Derived Unique Key Per Transaction)
    (SDK bind)
    SSL Library mbed TLS / PolarSSL
    hKps:/
    /github.com/luisbebop/mruby-polarssl
    HMAC, SHA1, MD5 and etc on mruby suite


    Security and Crypto

    View Slide

  41. @scalone
    PTS Terminal
    3DES + Working Key
    PIN / DATA DUKPT (Derived Unique Key Per Transaction)
    (SDK bind)
    SSL Library mbed TLS / PolarSSL
    hKps:/
    /github.com/luisbebop/mruby-polarssl
    HMAC, SHA1, MD5 and etc on mruby suite


    Security and Crypto

    View Slide

  42. @scalone
    Security and Crypto

    View Slide

  43. @scalone
    Take advantage of Bundler
    Rake tasks
    Adopt the same code in some scenarios ISO8583
    CRuby + mRuby

    View Slide

  44. @scalone
    Gem Spec
    DaFunk compilation
    CRuby + mRuby

    View Slide

  45. @scalone
    Memory and leaks

    View Slide

  46. @scalone
    Memory and leaks

    View Slide

  47. @scalone
    Concurrency

    View Slide

  48. @scalone
    Status Bar Update
    Connection Management
    Sharing memory for communication by controlled queue
    Concurrency

    View Slide

  49. @scalone
    CloudWalk mruby gem mruby-context
    C structure implementation using semaphores
    Concurrency

    View Slide

  50. @scalone
    MRuby Libraries to make the runPme works
    h"ps:/
    /github.com/cloudwalkio/mruby-da-funk
    IOT Framework
    h"ps:/
    /github.com/cloudwalkio/da_funk
    TLV Parser (Payment TransacPon)
    h"ps:/
    /github.com/scalone/funky-tlv
    CloudWalk CLI
    h"ps:/
    /github.com/cloudwalkio/cloudwalk
    SSL Library mbed TLS / PolarSSL bind
    h"ps:/
    /github.com/luisbebop/mruby-polarssl
    Open Source

    View Slide

  51. @scalone
    MRuby EMV Interface (Payment TransacPon)
    h"ps:/
    /github.com/cloudwalkio/mruby-emv
    RIPEMD-160 hash
    h"ps:/
    /github.com/scalone/mruby-ripemd
    QRCode generaPon
    h"ps:/
    /github.com/scalone/mruby-qrcode
    Miniz bind to ZIP/UNZIP inflate/deflate
    h"ps:/
    /github.com/scalone/mruby-miniz
    HMAC hash
    h"ps:/
    /github.com/scalone/mruby-hmac
    Open Source

    View Slide

  52. @scalone
    PAX Terminals
    h"ps:/
    /github.com/cloudwalkio/robot_rock
    Open Source TODAY

    View Slide

  53. @scalone
    Demo
    Thiago Scalone - @scalone

    View Slide

  54. @scalone
    20k mRuby devices
    Production
    Thiago Scalone - @scalone

    View Slide

  55. @scalone
    40.375 Devices
    Production
    Thiago Scalone - @scalone

    View Slide

  56. @scalone
    40.375 Devices
    $ +1bi 50% mRuby
    Production
    Thiago Scalone - @scalone

    View Slide

  57. @scalone
    mRuby in
    Production
    Thiago Scalone - @scalone

    View Slide

  58. @scalone
    in mRuby
    We Trust
    Thiago Scalone - @scalone

    View Slide

  59. @scalone
    Thank you
    We Trust
    Thiago Scalone - @scalone

    View Slide