Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
DApps開発特有の_ハマりポイントご紹介.pdf
Search
yudetamago
October 10, 2019
Technology
1.5k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
DApps開発特有の_ハマりポイントご紹介.pdf
yudetamago
October 10, 2019
More Decks by yudetamago
See All by yudetamago
ブロックチェーンとIndexer
yudetamago
0
980
Unityでブロックチェーンアプリを作る
yudetamago
0
1.9k
スマートコントラクトの監査について
yudetamago
2
650
DApps開発事例 ~CryptoCrystal概要編~
yudetamago
3
350
Gasを誰が払うのか問題について
yudetamago
5
4.7k
Solidityの複数コントラク ト連携を色々試してる話
yudetamago
1
2.4k
Dapps開発におけるSoliidityのはまりどころ
yudetamago
3
2.4k
Other Decks in Technology
See All in Technology
バイブコーディング時代のWebアプリ開発入門~Cloud Runで学ぶセキュアなビルドとデプロイ
waiwai2111
1
140
Minecraft JavaのMODをSwiftで作る
1mash0
0
200
beyond jj: config & tools ecosystem
indirect
0
5.8k
GoのInterface内部構造から学ぶ!最高パフォーマンスを出すコード設計
yappli_developers
1
250
技術的負債から考える、AI時代のエンジニアリング投資 — ビズリーチの技術的負債と向き合った経験から、変更し続けられるソフトウェアを考える/ technical-debt-con2026
visional_engineering_and_design
4
3.6k
`t*(42&t>>10)`だけで音楽が鳴る、Swiftで実装するBytebeat / iOSDC Japan 2026
yutailang0119
0
130
JSONataとAWS Step Functionsで目指すRuntimelessな世界
mu7889yoon
0
410
登壇の自信を奪う3匹のオバケ / 3 Ghosts That Rob You of Your Confidence in Public Speaking
pauli
9
1.1k
【技術的負債conf】事業成長に伴う技術的負債の説明責任とAIによるモニタリング、認知的負債について
i35_267
3
2k
ScotSecure West 2026 - Glasgow
raybugg
0
150
おい、エージェントを使って終わらせろ
nwiizo
2
850
Issue 駆動でスペシャリストの意図を届ける、AI 実装のアクセシビリティ向上
thkt
0
130
Featured
See All Featured
4 Signs Your Business is Dying
shpigford
187
23k
The SEO Collaboration Effect
kristinabergwall1
1
570
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.1k
Faster Mobile Websites
deanohume
310
32k
エンジニアに許された特別な時間の終わり
watany
109
250k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Automating Front-end Workflow
addyosmani
1369
210k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
470
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
440
Abbi's Birthday
coloredviolet
4
10k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Transcript
DApps開発特有の ハマりポイントご紹介 株式会社LayerX 神場 貴之 2019/10/10 Blockchain GIG #5 1
自己紹介 株式会社LayerX 神場貴之(じんば たかゆき) Senior Architect / Engineer Github: yudetamago
Twitter: @takayukib 好きな言語: Ruby 2
ブロックチェーンそのものの話 ➢ アプリ開発の1つのコンポーネントとして ブロックチェーンを使う時の話 (概要より実践向けの話が多いです) 3
アジェンダ • DAppsのアーキテクチャ全体像 • Indexer • イベント駆動のtx実行(ignitor?) • コントラクトデプロイのフロー •
UX 4
DAppsアーキテクチャ 5
6 Blockchain node Frontend (+MetaMaskなど) Q. これで要求を満たすようなアプリケーションを作れるでしょうか? tx送信
7 Blockchain node Frontend A. このぐらい必要でした indexer API (サーバ) DB
tx送信 イベント監視 保存 取得
なぜサーバが必要? MetaMaskのようなWalletプラグイン(アプリ)は まだ一般に浸透しているとは言えない 8 秘密鍵?ニーモニック...?
なぜIndexerが必要?(1) 9 Quorum ページング、検索、join、etc ➢ コントラクト側であらかじめ全てを用意しておくのは(一般には)難しい
なぜIndexerが必要?(2) 10 Quorum indexer DB イベント監視 保存 ページング、検索、join、etc API 取得
このスライドでのアーキテクチャの前提 11 Quorum indexer API DB App Quorum indexer API
DB App ➢ 同じネットワークIDを使っているQuorumをそれぞれ運用している ➢ それぞれが独自のDAppsを提供している
Indexer 12
Indexerとは? 13 Quorum indexer DB イベント監視 保存 API 取得 ➢
コントラクト上にあるデータをDBなどにコピー(キャッシュ)するもの
Indexer全体の流れ 14 indexing_status not_indexing block_height 123 Quorum name data A
a=10 B b=20 a 10 block_height 124 b 20 block_height 124 ①現在indexing中でないことを 確認 ②indexing済みの次のブロック からログを取得する ③取得したイベントのログの数 だけループ ④indexing対象のログなら block_heightと共にDBに保存 DB ⑤保存済みblock_heightを更新 イベント
indexerその他 • イベントログが中途半端に反映されないように、1つの(RDBの)トランザクションで DBへの保存を行う • nodeとのコネクション管理などをしなくても良いように、WebSocketではなく Polling(定期的にHTTP get)をすることでブロックの取得を行う 15
イベント駆動のtx実行 (ignitor?) 16
Transaction A イベント駆動のtx実行(ignitor) 17 Quorum Quorum eventA a=10 kicker Transaction
B API ①tx A実行 ③eventAを取得 ④eventAをトリ ガーとしてtx Bを実 行 ➢ txでのイベント発火を起点として別のtxを実行する ②eventA発火
コントラクト上の工夫 18 contract TestContract { event Succeeded(uint256 a); event Failed(uint256
a); function testFunction(uint256 a) public { if (a < 100) { emit Succeeded(a); } else { emit Failed(a); ... トリガー専用のイベントを用意 require(a < 100); ではない 失敗専用のイベントを発火 ➢ 「失敗」をトランザクションのrevertではなくイベントで表現する
ignitorとindexerとの協調(1) 19 Transaction 1 eventA a=10 block_height 123 DB a
10 Transaction 2 eventB b=10 block_height 124 Transaction 3 eventA a=30 block_height 125 function test(uint256 a) eventBをトリガーにして、testを実行(a=10) eventAをindexing ➢ block_height=124のイベントをトリガにして別のtxを実行 するには、block_height=123の時のindexingされたDB の情報が必要(block_height=125の時にはaの値が変 わってしまう)
ignitorとindexerとの協調(2) 20 • ignitorとindexerを完全に独立にすることは出来ない • indexerは1ブロックに含まれるイベントをatomicにDBに保存しているので、 indexingが失敗したときにignitorが実行されないようにしないといけない ◦ e.g. Transaction
2が来たタイミングで次のtxの引数だけ作っておき、indexingが成功し たときだけtxを実行する
コントラクト デプロイフロー 21
デプロイのフロー(1) nodeの運用主体が1つだけならtruffleのmigrationで良い。 複数の主体が別々にコントラクトをデプロイするときは? 22
デプロイのフロー(2) 23 Quorum Quorum ①自分のコントラクトデプロイ ②seedデータなどを設定 ④他のnodeに依存するデータを設定 ③ABI(truffle artifact)を共有する
UX 24
tx実行中という状態をどう見せる? 25 Quorum API DB a=10 未indexing a 20 a=20
a=20 ➢ indexingする前だとAPIから古い データが取得されてしまう ?
API側でのレスポンスのタイミング 26 Quorum API DB ①txの送信終了時? ②ブロックの取り込み終了時? ③indexing終了時? ➢ ①に近いほどクライアントの待ち時間は短くなるが、クライアントから見た時
に状態が不整合となる期間は長くなるというトレードオフ
実行中のtxどう管理する? • 異常系(e.g. APIの実行失敗)のフローでは①〜③どれを選んでもクライアント側に 対して何かしらのフォローが必要 • indexing済みかどうかはサーバ側でしか分からないのでサーバで管理 ◦ txごとにどういう状態かを管理する? •
txがどういう状態にあるかを返すAPIを作ってクライアントで出し分けする? 27 ➢ To Be Continued...
まとめ • 複数の主体がnodeを運用しているときには、コントラクトのデ プロイフローやイベント駆動のtx実行のためのワークフローが 必要 • 閲覧・検索系の機能を作るためにはindexerが必要 • UX上、実行中(indexing中)のtxを何かしらの方法で判別する 必要あり
28