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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
アクセスキーこわい やめかたと漏らさない工夫
sassssan68
1
620
2026-09-18 gotanda.sre Terraformで複数環境作ったり、複数Stateに分割したりそれとTerragrunt / Terraform multi envs and multi states
masasuzu
4
690
[Kiro Meetup #7] Kiro Crew Dive Deep
konippi
0
200
ScotSecure West 2026 - Glasgow
raybugg
0
150
「どのログを見ればいい?」 から始めた サーバーレス障害解析
y_waka1
1
120
SREの視点で考えるSIEM活用術 〜AWS環境でのセキュリティ強化〜
cscengineer
PRO
0
190
品質と信頼性を地続きにする
grimoh
2
920
白金鉱業Meetup Vol.25 アウトカムが二値のデータに対するCausal Impact
brainpadpr
0
280
AIエージェントを最高のパートナーに育てる方法|評価と判断軸を育てる5つのステップ
koichiaoki
1
160
AIエージェントの自己改善をどう設計するか / How to Design Self-Improvement for AI Agents
22mi
25
17k
なぜ「決定性」が 決定的に重要なのか? Durable Execution 基盤の数理的理解 #serverlessjp / ServerlessDays Tokyo 2026
ytaka23
3
1.2k
CLIライブラリ開発を支える技術
htnabe
0
150
Featured
See All Featured
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
500
How to make the Groovebox
asonas
2
2.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
260
Crafting Experiences
bethany
1
350
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
360
Leo the Paperboy
mayatellez
10
2.3k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
67
58k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
700
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
510
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