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

[Denis Radin] Mining crypto in browser: GPU, WebAssembly, JavaScript and all the good things to try

[Denis Radin] Mining crypto in browser: GPU, WebAssembly, JavaScript and all the good things to try

Content level: Beginner
A year ago an unnamed investor asked me for a consultancy on topic:"If this is possible to mine crypto in a browser using GPU?". The talk shares some insights/outcome found during the research and give an idea of what to expect when mining cryptocurrencies using a pool of browser-based miners. Let`s review mining as a top-notch performance challenge for the Web platform.

Denis Radin
Evolution Gaming / Netherlands

3a6de6bc902de7f75c0e753b3202ed52?s=128

Google Developers Group Lviv

October 13, 2018
Tweet

Transcript

  1. Mining crypto in browser GPU, WebAssembly and all the good

    things to try
  2. @PixelsCommander denis.radin@gmail.com

  3. None
  4. None
  5. State of the art games engineering

  6. + Using React/Redux for managing HTML UI and game graphics

  7. None
  8. ChallengingNative.com Fast web applications development, profiling and optimization

  9. None
  10. None
  11. Mining as a bleeding edge performance challenge for web platform

  12. What the hack is mining?

  13. None
  14. None
  15. None
  16. None
  17. None
  18. None
  19. None
  20. What if I want to add a block? And what

    if everyone wants?
  21. None
  22. None
  23. Blockchain might get out of control So we need to

    limit the ability for adding blocks
  24. Proof of work Solving math problems

  25. Solved task = added block

  26. Сryptocurrency rewards us for keeping chain going!

  27. Mining Bitcoin in browser Starting from the mainstream

  28. None
  29. 00000000000000000 Hash to start with for valid block

  30. None
  31. SHA256 for hashing blocks Which is a well explained algorithm

  32. Nonce: ?

  33. 1.4x10^20 Chance to get a right nonce... A lot of

    work!
  34. So miners unite in pools...

  35. And what if your users will mine for you in

    a pool?
  36. Time for...

  37. Is my hash implementation slow? Nope

  38. May be workers are better? Doing job in parallel is

    definitely something to keep eye on
  39. Time for...

  40. What about WebAssembly? The promise to have nearly native performance...

  41. Time for...

  42. I heard mining on GPU is fast...

  43. None
  44. None
  45. In WebGL we can mine with pixel shaders Every pixel

    is a thread
  46. None
  47. None
  48. Time for...

  49. And reading results from a texture Every pixel is a

    result for particular nonce
  50. None
  51. GetPixel and check in JS for every nonce hashed Let`s

    reduce this performance leak by 1024 times
  52. Time for...

  53. None
  54. 200x improvement but still no money... Lets see what happened

  55. Evolution of mining tooling

  56. CPU era

  57. None
  58. None
  59. GPU era As fast as 1600 CPUs

  60. None
  61. None
  62. ASIC era As fast as 20000 GPU

  63. None
  64. None
  65. 20000 GPUs? Is not this broken? So new generation of

    cryptocurrency fixes this
  66. Etherium? Yes, it is ASICs-proof! But...

  67. 3Gb RAM Required for operating algorithm

  68. Web is failing here... Nor JS nor WebGL can allocate

    3Gb
  69. Alternatives? Algorithm should be ASIC-proof but available under Web limitations

  70. XMR Monero This would work...

  71. Time for...

  72. And even better! There is mining as a JS plugin

    proposed
  73. CoinHive The mainstream

  74. CoinImp Zero commission

  75. CryptoNoter Open source

  76. Pros? GDPR will make traditional monetisation with ads less efficient,

    some opportunities there
  77. Ethics? You decide, but sometimes it makes sense

  78. Is it worth money? You decide, but cryptos are there

    for a long
  79. @PixelsCommander denis.radin@gmail.com