Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ブロックチェーンとIndexer
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
yudetamago
January 24, 2020
Technology
0
950
ブロックチェーンとIndexer
yudetamago
January 24, 2020
Tweet
Share
More Decks by yudetamago
See All by yudetamago
Unityでブロックチェーンアプリを作る
yudetamago
0
1.8k
DApps開発特有の_ハマりポイントご紹介.pdf
yudetamago
1
1.4k
スマートコントラクトの監査について
yudetamago
2
620
DApps開発事例 ~CryptoCrystal概要編~
yudetamago
3
330
Gasを誰が払うのか問題について
yudetamago
5
4.6k
Solidityの複数コントラク ト連携を色々試してる話
yudetamago
1
2.3k
Dapps開発におけるSoliidityのはまりどころ
yudetamago
3
2.4k
Other Decks in Technology
See All in Technology
[CV勉強会@関東 World Model 読み会] Orbis: Overcoming Challenges of Long-Horizon Prediction in Driving World Models (Mousakhan+, NeurIPS 2025)
abemii
0
140
生成AIを活用した音声文字起こしシステムの2つの構築パターンについて
miu_crescent
PRO
3
210
Amazon S3 Vectorsを使って資格勉強用AIエージェントを構築してみた
usanchuu
3
450
モダンUIでフルサーバーレスなAIエージェントをAmplifyとCDKでサクッとデプロイしよう
minorun365
4
220
~Everything as Codeを諦めない~ 後からCDK
mu7889yoon
3
440
ブロックテーマでサイトをリニューアルした話 / 2026-01-31 Kansai WordPress Meetup
torounit
0
470
Agile Leadership Summit Keynote 2026
m_seki
1
650
10Xにおける品質保証活動の全体像と改善 #no_more_wait_for_test
nihonbuson
PRO
2
320
Bill One 開発エンジニア 紹介資料
sansan33
PRO
5
17k
学生・新卒・ジュニアから目指すSRE
hiroyaonoe
2
650
Bill One急成長の舞台裏 開発組織が直面した失敗と教訓
sansantech
PRO
2
380
ランサムウェア対策としてのpnpm導入のススメ
ishikawa_satoru
0
190
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
97
6.5k
Documentation Writing (for coders)
carmenintech
77
5.3k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
0
1.1k
GraphQLとの向き合い方2022年版
quramy
50
14k
Exploring anti-patterns in Rails
aemeredith
2
250
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.3k
Reality Check: Gamification 10 Years Later
codingconduct
0
2k
The Language of Interfaces
destraynor
162
26k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
180
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
From π to Pie charts
rasagy
0
120
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Transcript
ブロックチェーンとIndexer 株式会社LayerX 神場 貴之 2019/1/24 blockchain.tokyo#24 supported by AWS 1
自己紹介 神場 貴之(じんば たかゆき) 株式会社LayerX Software Engineer Github: yudetamago Twitter:
takayukib 2
このスライドの前提 • ブロックチェーンとしてはQuorumを使います • 秘密鍵はサービス提供者が管理しています • (ブロックチェーンにある程度触れている方向けです) 3
indexerとは 4
シンプルなDAppsの構成 Quorum Frontend (+MetaMaskなど) tx送信 5
こんなときどうする? 6
デプロイ済みのERC20トークンを使って • 現在balanceが100以上で • 直近1週間のtransfer回数が100以上 のアドレスをリアルタイムに取得出来るよう にしたい 7
何が必要? • 過去1週間分のtransferのイベントログ ◦ 大量のイベント取得、どのブロック番号まで取得すればいい?? • (transferに関連する)アドレスのbalanceの一覧 ◦ アドレスそれぞれに対してERC20のbalanceOfを呼ぶ?? 8
RDBなら addresses address 0x…. balances address balance 0x…. 100 transfer_histories
from to amount block_timestamp 0x…. 0x…. 10 1579791600 joinとwhereで良い 9
indexerを使う理由 • コントラクト(Solidity)で柔軟な検索用メソッドを作るのは難しい • デプロイしてしまったコントラクトに後から検索用メソッドを追加することは出来な い ◦ イベントの定義に貼っているindexも後からは変えられない 10
ストレージのデータ、イベントをRDBに キャッシュ(インデクシング)しよう 11
indexer全体像 12
全体像 Quorum indexer RDB ログ取得 保存 API 取得 13
Indexer全体の流れ1 indexing_status not_indexing block_height 123 RDB ①現在indexing中でないことを確認 ②indexing中状態に変更 ③indexing済みの次のブロック(124)からログを取得する •
現在のindexing状態を記録(二重 実行防止) • indexing済みのブロック番号を記録 14
Indexer全体の流れ2 a 10 block_height 124 b 20 block_height 124 RDB
Quorum name data A a=10 B b=20 ④取得したイベントのログの数だけループ ⑤indexing対象のログならblock_heightと共にDBに保存 • イベントと RDB上のテー ブルのマッピングを作っ ておく 15
Indexer全体の流れ3 indexing_status not_indexing block_height 124 RDB ⑥block_heightを最新のものに更新 16
Indexingの仕方 1. Push型(WebSocketで常時接続) 2. Pull型(HTTPでPolling) 17
Push型 WebSocketでQuorumと常時接続しておき、イベントまたはブロックをsubscribeする • Pros ◦ リアルタイムにindexingすることが出来る • Cons ◦ 受け取る側でエラーになったときに備えてリトライ機構が必要
18
Pull型 HTTPでPollingを行い、Quorumに定期的にブロックを取りに行く • Pros ◦ 失敗しても(ブロック番号を調整して)再実行することが出来る • Cons ◦ Push型よりもリアルタイム性は多少下がる
19
その他 • 一度に取得するブロック数を制限してデータ量・処理時間が長くなりすぎないよ うにする • 中途半端に保存されないように(RDBの)トランザクションで実行する • uint256など通常の数値型では収まらない値に注意する 20
フロントエンドのUX 21
ブロック取り込み前, 未indexingの状態 Quorum API DB 最新のデータ 古いデータ 古いデータ ??? 22
API側でのレスポンスのタイミング 1. トランザクションの送信終了時 2. Quorumのブロック取り込み終了時 3. Indexing終了時 23
24
(ユーザーから見たときの) • レスポンスの待ち時間 • 状態が不整合となる時間 のトレードオフ 25