Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Blockchain on Go

4,827 views

Published on

The presentation at DevFest Tokyo 2017 / @__timakin__
An introduction of blockchain and why go is nice to implement blockchain.
Additionally described about the blockchain projects that are based on Go.

Published in: Engineering

Blockchain on Go

  1. 1. BlockChain on Go @__timakin__ / DevFest Tokyo 2017
  2. 2. • • Github: timakin / Twitter: @__timakin__ • Gunosy Inc. • Go / Swift • community • golang.tokyo • roppongi-golunch • blockchain.tokyo
  3. 3. golangtokyo.connpass.com
  4. 4. • Blockchain • Go Blockchain
  5. 5. Blockchain • • -> JSON • P2P
  6. 6. Chain Flow hash target nonce transactions transactions transactions blockblock block
  7. 7. Example of block { difficulty: '137447', extraData: '0x476574682f76312e302e312f6c696e75782f676f312e342e32', gasLimit: 3141592, gasUsed: 0, hash: '0x4d3063b91cbaa12bf2de81014c1319febc9f197c93f81b0746afaffaa9496620', nonce: '0x28fda83cb19ed497', number: 100, parentHash: '0x5885cdec1d1410580eaaf1fb7ef9db245a735822d48e816c73d926b7c9872f15', size: 536, timestamp: 1439451765, totalDifficulty: '13551548', transactions: [ ], transactionsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', }
  8. 8. Consensus Algorithm • Proof of Work • Node 0 
 Node • target nonce(hash value) • Node 
 
 • Proof of Stake • • ex) SHA256(prevhash + address + timestamp) <= 2^256 * balance (volume of stake) / diff • 
 Proof of Stake Velocity
  9. 9. Decentralized Application Processing File Storage Database Processing File Storage Database
  10. 10. • • • • • • ms •
  11. 11. • • 2017/10/1 135GB •
  12. 12. • • Bitcoin Ethereum • • Read/Write
  13. 13. • ms • •
  14. 14. http://blockchaindemo.io/
  15. 15. Go Blockchain • Go C++ Python • Go
  16. 16. Go? • • • •
  17. 17. btcd • Bitcoin fork • bitcoin/bitcoin C++ • libbitcoin(C++), BitcoinJ(Java) • • JSON-RPC API 

  18. 18. geth(go-ethereum) • Go • Ethereum protocol Go • Ethereum • Windows OS • geth( 7832) cpp-ethereum( 1710), pythereum( 1487), ethereumj(760)
  19. 19. Ethereum 
 (geth) 
 P2P Network +
  20. 20. Mist Wallet
  21. 21. https://ethstats.net/
  22. 22. HyperLedger • • Supported by The Linux Foundation • • IBM Intel J.P.Morgan MUFG NEC etc…
  23. 23. HyperLedger ref: http://gaiax-blockchain.com/hyperledger-project
  24. 24. HyperLedger Projects Fabric PBFT 
 
 
 * 
 * http://www.jpx.co.jp/corporate/research-study/working-paper/tvdivq0000008q5y-att/ JPX_working_paper_No15.pdf

  25. 25. HyperLedger Fabric Network ref: https://www.ibm.com/developerworks/jp/cloud/library/j_cl-blockchain-basics-bluemix/
  26. 26. PBFT (Practical Byzantine Fault Tolelance) ref: https://www.ibm.com/developerworks/jp/cloud/library/j_cl-blockchain-basics-bluemix/
  27. 27. ChainCode • Go Java
  28. 28. ChainCode
  29. 29. World State • ChainCode R/W KVS JSON • ChainCode
  30. 30. shim.ChaincodeStubInterface • chaincode WorldState Ledger API • Init, Invoke • Get/Put/Delete State World State • shim.Success, shim.Error res payload writer 200, 400, 500
  31. 31. HyperLedger Composer Fabric Web IDE
  32. 32. HyperLedger Composer Web UI (Fabric) 4 Model: Access Control: Read/Write Script: JS Query: Model REST API
  33. 33. IPFS • P2P • Blockchain • • ipfs.pics Gyazo Winny
  34. 34. Upload assets # $ ipfs add test.jpg added QmaC9pUA3grWJ948u1VWRLG1wPLP8YZe7b3HopBGk4zZyA test.jpg $ ipfs cat /ipfs/QmaC9pUA3grWJ948u1VWRLG1wPLP8YZe7b3HopBGk4zZyA > butaman.jpg $ open https://ipfs.io/ipfs/QmaC9pUA3grWJ948u1VWRLG1wPLP8YZe7b3HopBGk4zZyA # $ ipfs add -r ~/myproject # Fuse $ ipfs mount $ ls /ipfs/$hash/ # $ ipfs add -q test.mp4
  35. 35. API Client var ipfs = require('ipfs-client'); var stream = ipfs.cat('QmTE9Xp76E67vkYeygbKJrsVj8W2LLcyUifuMHMEkyRfUL'); stream.pipe(process.stdout); ipfs.add(process.stdin, function(err, hash) { console.log(hash); }); https://www.npmjs.com/package/ipfs-client API Scala Go JavaScript
  36. 36. WebUI
  37. 37. • Go C++ • API CLI • WebUI

×