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

Goはブロックチェーン領域でなぜ使われ、どのように活躍しているのか

uji
June 02, 2023
600

 Goはブロックチェーン領域でなぜ使われ、どのように活躍しているのか

uji

June 02, 2023
Tweet

Transcript

  1. uji
 • Software engineer
 @Money Forward, Inc. Web3 group (Osaka)

    • A four-year-old Gopher • Kyoto.go organizer
  2. • εϚʔτίϯτϥΫτͱݺ͹ΕΔ࢓૊Έ͕ଘࡏ͢Δ৔߹͕ଟ͍ ◦ ͋Β͔͡ΊܾΊΒΕͨܖ໿΍औҾΛɺ஥հऀͳ͠ͰࣗಈࣥߦͰ͖Δ࢓૊Έ • ϓϩάϥϜΛॻ͘͜ͱͰɺ༷ʑͳऔҾͷ
 ϒϩοΫνΣʔϯ্Ͱͷࣗಈࣥߦ͕࣮ݱͰ͖Δ ◦ ྫ ▪

    ҉߸ࢿ࢈ಉ࢜ͷ׵ۚ ▪ ΦϦδφϧͷ௨՟΍NFTͷൃߦɾৡ౉ ϒϩοΫνΣʔϯͷ֓ཁ ਗ਼ྋҿྉਫͷࣗಈൢചػ΋
 εϚʔτίϯτϥΫτͱݴ͑Δ Kyoto.goϒʔεͰ NFT഑෍தʂ
  3. ϒϩοΫνΣʔϯͰ҉߸ٕज़͸ॏཁͳ໾ׂΛ୲͓ͬͯΓɺ
 ͋ΒΏΔ৔໘Ͱར༻͞Ε͍ͯΔ • ΞΧ΢ϯτͷ؅ཧ ◦ ϒϩοΫνΣʔϯͷΞΧ΢ϯτ͸ɺެ։伴ͱൿີ伴ͷϖΞͰѻΘΕΔ͜ͱ͕ଟ͍ ◦ 伴ϖΞͷੜ੒΍؅ཧʹ͸ɺsecp256k1ͳͲͷପԁۂઢ҉߸͕ར༻͞ΕΔ • τϥϯβΫγϣϯͷॺ໊

    ◦ τϥϯβΫγϣϯൃߦऀ͸σδλϧॺ໊ʹͯΞΧ΢ϯτͷূ໌Λߦ͏ ◦ ECDSA΍EdDSAͳͲͷॺ໊ΞϧΰϦζϜ͕ར༻͞ΕΔ • ϋογϡؔ਺ͷར༻ ◦ ϒϩοΫͷϋογϡ஋ͷܭࢉͳͲ ◦ ओʹKeccak256ͳͲ͕ར༻͞ΕΔ ϒϩοΫνΣʔϯΛࢧ͑Δٕज़ʢ̍ʣ
 ҉߸ٕज़
  4. • ωοτϫʔΫ಺ͷ͢΂ͯͷϊʔυ͕ϒϩοΫνΣʔϯͷঢ়ଶʹ͍ͭͯ
 ߹ҙΛܗ੒͢ΔͨΊͷ࢓૊Έ • ϒϩοΫੜ੒ऀͷܾఆ΍ɺϒϩοΫʹؚ·ΕΔऔҾͷॱং͚ͮͳͲʹ
 ϧʔϧΛઃ͚Δ͜ͱͰɺೋॏࢧ෷͍΍ωοτϫʔΫࢀՃऀͷෆਖ਼ߦҝΛ๷͙ • νΣʔϯʹΑͬͯ͞·͟· ◦ ྫ:

    PoW(ϓϧʔϑɾΦϒɾϫʔΫ) ▪ ϏοτίΠϯͰ࢖ΘΕ͍ͯΔ ▪ ϚΠχϯάʢܭࢉ໰୊Λղ͘ߦҝʣͨ͠ϊʔυʹ
 ϒϩοΫੜ੒ݖ͕༩͑ΒΕΔϧʔϧʹΑΓɺෆਖ਼ߦҝͷίετΛ૿Ճ ϒϩοΫνΣʔϯΛࢧ͑Δٕज़ʢ̐ʣ
 ίϯηϯαεΞϧΰϦζϜ
  5. • ϊʔυ͸ॊೈͳऔҾΛ࣮ݱ͢ΔͨΊʹɺ
 εϚʔτίϯτϥΫτͳͲͷϓϩάϥϜΛ࣮ߦ͢Δ • ࣮ߦ΍݁ՌͷݕূΛߦ͏ͨΊͷ؀ڥ͕ඞཁͱͳΔ • ϥϯλΠϜͷಛੑ͸ϒϩοΫνΣʔϯʹΑ༷ͬͯʑ
 ੍໿΍ར༻Ͱ͖Δϓϩάϥϛϯάݴޠ͕มΘͬͯ͘Δ ◦ ྫɿEthereum

    Virtual MachineʢEVMʣ ▪ Solidity΍VyperͳͲͷݴޠͰهड़͞ΕͨεϚʔτίϯτϥΫτΛ࣮ߦͰ͖Δ ▪ νϡʔϦϯά׬શʢϧʔϓΛؚΉ೚ҙͷϓϩάϥϜΛ࣮ߦͰ͖Δʣ ϒϩοΫνΣʔϯΛࢧ͑Δٕज़ʢ̑ʣ
 τϥϯβΫγϣϯΛॲཧ͢ΔϥϯλΠϜ
  6. ϒϩοΫνΣʔϯͷTLV(ϩοΫ͞Ε͍ͯΔ҉߸ࢿ࢈ͷֹ)ʹΑΔϥϯΩϯά ϒϩοΫνΣʔϯࣗମͷ։ൃݴޠ ॱҐ νΣʔϯ ϝΠϯݴޠ ॱҐ νΣʔϯ ϝΠϯݴޠ 1 Ethereum

    11 Fantom 2 Tron 12 Cronos 3 BSC 13 DefiChain 4 Arbitrum 14 Klaytn 5 Polygon 15 Bitcoin 6 Optimism 16 Parallel 7 Avalanche 17 Acala 8 Solana 18 Fusion 9 Mixin 19 Algorand 10 Kava 20 Osmosis CoinMarketCap “Largest Blockchains in Crypto Ranked by TVL” ΑΓҾ༻ https://coinmarketcap.com/ja/chain-ranking/ (2023/05/16)
  7. CoinMarketCap “Largest Blockchains in Crypto Ranked by TVL” ΑΓҾ༻ https://coinmarketcap.com/ja/chain-ranking/

    (2023/05/16) ϒϩοΫνΣʔϯͷTLV(ϩοΫ͞Ε͍ͯΔ҉߸ࢿ࢈ͷֹ)ʹΑΔϥϯΩϯά ϒϩοΫνΣʔϯࣗମͷ։ൃݴޠ ॱҐ νΣʔϯ ϝΠϯݴޠ ॱҐ νΣʔϯ ϝΠϯݴޠ 1 Ethereum Go 11 Fantom Go 2 Tron Java 12 Cronos Go 3 BSC Go 13 DefiChain C++ 4 Arbitrum Go 14 Klaytn Go 5 Polygon Go 15 Bitcoin C++ 6 Optimism Go 16 Parallel Rust 7 Avalanche Go 17 Acala Rust 8 Solana Rust 18 Fusion C++ 9 Mixin Go 19 Algorand C, Go 10 Kava Go 20 Osmosis Go
  8. • EthereumͷϝΠϯͷ։ൃݴޠʹબ͹Εͨ͜ͱ͕ىҼ͍ͯ͠Δ • Ethereum͸εϚʔτίϯτϥΫτΛ
 ॳΊͯϒϩοΫνΣʔϯʹ૊ΈࠐΜͩࣄྫ • Ethereumͷ࠷ॳͷΫϥΠΞϯτ࣮૷ͷ1ͭͰ Go ͕બ͹Εͨ •

    go-ethereum ͸ Ethereum ωοτϫʔΫͷ
 80%Ҏ্ͷϊʔυͰར༻͞Ε͍ͯΔ • ࠷΋࢖ΘΕςετ͞ΕͨΫϥΠΞϯτͱͯ͠ɺ
 ଟ͘ͷνΣʔϯͷࢀߟ࣮૷ʹͳ͍ͬͯΔ Go͕ϒϩοΫνΣʔϯࣗମͷ։ൃʹ࢖ΘΕ͖ͯͨཧ༝
  9. ΄ͱΜͲͷ৔໘Ͱɺར༻࣮੷ͷଟ͍ϥΠϒϥϦ͕ར༻͞Ε͍ͯΔ
 ʢϓϦίϯύΠϧυίϯτϥΫτͷ҉߸Խؔ਺ͳͲɺҰ෦ಠࣗʹ࣮૷͞Ε͍ͯΔ΋ͷ ΋͋Δʣ • ඪ४ύοέʔδ crypto • ४ඪ४ύοέʔδ golang.org/x/crypto •

    BitcoinͷGo࣮૷ύοέʔδ btcsuite/btcd, bitcoin-core/secp256k1 ࣮੷ͷ͋ΔϥΠϒϥϦΛ࠶ར༻͢Δ͜ͱͰɺ
 ҆શੑ΍ੑೳͱɺ։ൃ༰қੑΛཱ͍྆ͯ͠Δ ࣮ࡍʹͲͷΑ͏ʹGo͕࢖ΘΕ͍ͯΔͷ͔
 ҉߸ٕज़ͷ࣮ݱํ๏ ৄࡉ͸ͪ͜Βˠ
  10. Goͷ۩ମతͳ࢖ΘΕํ
 ౬ਫͷΑ͏ʹ࢖ΘΕΔgoroutine go-ethereumͰ͸ɺGoͷΰϧʔνϯͱνϟωϧ͕๛෋ʹ࢖ΘΕ͍ͯΔ ֤छΠϕϯτΛ chan Ͱఆٛ͠ɺfor, select Λ࢖ͬͯΠϕϯτϋϯυϥΛ࣮ݱ ͜ͷύλʔϯ͕࢖ΘΕ͍ͯΔՕॴ •

    P2Pαʔόʔ
 https://github.com/ethereum/go-ethereum/blob/v1.11.6/p2p/server.go#L705 • Transactionͷϓʔϧ
 https://github.com/ethereum/go-ethereum/blob/v1.11.6/core/txpool/txpool.go#L349 • ϚΠχϯάϫʔΧʔ
 https://github.com/ethereum/go-ethereum/blob/v1.11.6/miner/worker.go 

  11. sync ύοέʔδͷػೳ΋ଟ༻ ྫɿϒϩοΫϋογϡͷಋग़ʹར༻͢Δϋογϡؔ਺ͷϩδοΫ • x/crypto/sha3 ͷ NewLegacyKeccak256() Λ࢖͍ͬͯΔ • sync.Pool

    Ͱ buffer Λ
 Ωϟογϡ͠
 ࠶ར༻͢Δ͜ͱͰɺ
 GC΁ͷෛ୲Λܰݮ͍ͯ͠Δ Goͷ۩ମతͳ࢖ΘΕํ
 ౬ਫͷΑ͏ʹ࢖ΘΕΔgoroutine https://github.com/ethereum/go-ethereum/blob/v1.11.6/cmd/geth/main.go#L331-L346
  12. • prysmaticlabs/prysm ◦ EthereumͷίϯηϯαεΫϥΠΞϯτͷGo࣮૷ ◦ Ethereum͸go-ethereumͷ֎ͰϒϩοΫੜ੒ͷίϯηϯαεΛܗ੒͍ͯ͠Δ • 0xPolygonHermez/zkevm-node ◦ zkEVMͷGoͷϊʔυ࣮૷

    ◦ θϩ஌ࣝূ໌Λ࢖ͬͯEthereumͷ֎෦ͰτϥϯβΫγϣϯΛॲཧ͢ΔϨΠϠʔ2νΣʔϯ • cosmos/cosmos-sdk ◦ ϒϩοΫνΣʔϯΛߏங͢ΔͨΊͷϞδϡϥʔϑϨʔϜϫʔΫ ◦ GoݴޠͰϒϩοΫνΣʔϯΞϓϦέʔγϣϯΛ؆୯ʹߏஙͰ͖Δ • ava-labs/avalanchego ◦ AvalancheνΣʔϯͷGoͷϊʔυ࣮૷ ◦ Avalanche subnetͱݺ͹ΕΔɺෳ਺ͷϒϩοΫνΣʔϯΛ࿈ܞͤͯ͞
 ૬ޓӡ༻ੑʢΠϯλʔΦϖϥϏϦςΟʣΛ୲อ͢Δ࢓૊Έ͕͋Δ Goͷ۩ମతͳ࢖ΘΕํ
 ͦͷଞίʔυϦʔσΟϯά͕໘നͦ͏ͳrepository
  13. ࠷ޙʹ • 6݄15೔(໦) 19:00͔Βɺ
 ʰϚωʔϑΥϫʔυʱʰΧϯϜʱ
 ʰϛϥςΟϒʱʰφϨοδϫʔΫʱ
 ͷ4ࣾʹΑΔGoಉษڧձΛ։࠵༧ఆ
 On Thursday, June

    15th at 7:00 PM, there will be a Go study group held by four companies: Money Forward, Kamu, Mirrativ, and Knowledge Work. • ඇެࣜAfter Partyͱͯ͠ɺ
 ֤ࣾͷΤϯδχΞ͕LTͱ
 Go Conferenceײ૝ઓΛ࣮ࢪ
 As an unofficial after party, engineers from each company will hold an LT and a discussion on the Go Conference.
  14. • Ethereum։ൃυΩϡϝϯτ
 https://ethereum.org/ja/developers/docs/ • Ethereum EVM illustrated
 https://takenobu-hs.github.io/downloads/ethereum_evm_illustrated.pdf • Bitcoin

    white paper
 https://bitcoin.org/bitcoin.pdf • Total Value Locked (TVL) Definition (coinmarketcap)
 https://coinmarketcap.com/alexandria/glossary/total-value-locked-tvl • ͨͩͷ෼ࢄDBͱԿ͕ҧ͏ʁ࠷લઢΤϯδχΞ͕ޠΔBlockchainͷ࣮༻Մೳੑ
 https://www.youtube.com/watch?v=UQUfpUPz9Ic Gopher Illustrations ©tottie / Renée French ࢀߟจݙ