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

DApps開発特有の_ハマりポイントご紹介.pdf

Avatar for yudetamago yudetamago
October 10, 2019

 DApps開発特有の_ハマりポイントご紹介.pdf

Avatar for yudetamago

yudetamago

October 10, 2019
Tweet

More Decks by yudetamago

Other Decks in Technology

Transcript

  1. このスライドでのアーキテクチャの前提 11 Quorum indexer API DB App Quorum indexer API

    DB App ➢ 同じネットワークIDを使っているQuorumをそれぞれ運用している ➢ それぞれが独自のDAppsを提供している
  2. Indexerとは? 13 Quorum indexer DB イベント監視 保存 API 取得 ➢

    コントラクト上にあるデータをDBなどにコピー(キャッシュ)するもの
  3. 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を更新 イベント
  4. Transaction A イベント駆動のtx実行(ignitor) 17 Quorum Quorum eventA a=10 kicker Transaction

    B API ①tx A実行 ③eventAを取得 ④eventAをトリ ガーとしてtx Bを実 行 ➢ txでのイベント発火を起点として別のtxを実行する ②eventA発火
  5. コントラクト上の工夫 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ではなくイベントで表現する
  6. 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の値が変 わってしまう)
  7. tx実行中という状態をどう見せる? 25 Quorum API DB a=10 未indexing a 20 a=20

    a=20 ➢ indexingする前だとAPIから古い データが取得されてしまう ?