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
Plasma NFT Deposit Range
Search
Stake Technologies
July 29, 2019
Technology
0
49
Plasma NFT Deposit Range
Stake Technologies
July 29, 2019
Tweet
Share
More Decks by Stake Technologies
See All by Stake Technologies
Substrate ink!
staketechnologies
0
20
Plasma on Substrate @Fukuoka
staketechnologies
0
58
Sub0 Recap Japanese
staketechnologies
0
49
Plasm Introduction
staketechnologies
1
100
0318Substrateプレゼン資料.pdf
staketechnologies
4
620
2019.01ブロックチェーントレンド
staketechnologies
0
30
Other Decks in Technology
See All in Technology
ビジネスモデリング道場 目的と背景
masuda220
PRO
9
560
OpenID Connect for Identity Assurance の概要と翻訳版のご紹介 / 20250219-BizDay17-OIDC4IDA-Intro
oidfj
0
280
組織貢献をするフリーランスエンジニアという生き方
n_takehata
2
1.3k
転生CISOサバイバル・ガイド / CISO Career Transition Survival Guide
kanny
3
1k
株式会社EventHub・エンジニア採用資料
eventhub
0
4.3k
Goで作って学ぶWebSocket
ryuichi1208
3
1.7k
Helm , Kustomize に代わる !? 次世代 k8s パッケージマネージャー Glasskube 入門 / glasskube-entry
parupappa2929
0
250
「海外登壇」という 選択肢を与えるために 〜Gophers EX
logica0419
0
720
人はなぜISUCONに夢中になるのか
kakehashi
PRO
6
1.7k
関東Kaggler会LT: 人狼コンペとLLM量子化について
nejumi
3
600
リアルタイム分析データベースで実現する SQLベースのオブザーバビリティ
mikimatsumoto
0
1.4k
Classmethod AI Talks(CATs) #17 司会進行スライド(2025.02.19) / classmethod-ai-talks-aka-cats_moderator-slides_vol17_2025-02-19
shinyaa31
0
130
Featured
See All Featured
Practical Orchestrator
shlominoach
186
10k
Faster Mobile Websites
deanohume
306
31k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
10
1.3k
Git: the NoSQL Database
bkeepers
PRO
427
64k
A better future with KSS
kneath
238
17k
Optimizing for Happiness
mojombo
376
70k
Into the Great Unknown - MozCon
thekraken
35
1.6k
Bootstrapping a Software Product
garrettdimon
PRO
306
110k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2.1k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
Become a Pro
speakerdeck
PRO
26
5.1k
Transcript
DepositedRanges
概要 PlasmaCash 派生ではすべての資産を NFT として扱う。 子チェーンに資産を移すことを Deposit 子チェーンから親チェーンに資産を戻すことを Exit と呼ぶ。
親チェーンでは不正な Exit を防ぐために 子チェーンに存在する資産を把握している必要がある。 DepositedRanges は子チェーンに移した NFT を把握し 子チェーンに存在しない資産を不正に Exit できないようにするためのデータ構造。
データ構造 区間を表す構造体、 Range を定義する。 struct Range { start: u128, end:
u128 } Plasma 上の NFT は index が連番で割り振られており Range を使って どの NFT を指しているかを特定する。 DepositedRanges を定義する。 DepositedRanges: storage::HashMap<u128, Range>; DepositedRanges は現在 Deposit されている NFT の ID を管理する。
要件 DepositedRanges は以下のことがそれぞれ O(1) でできる。 • 区間の拡張。 ◦ Input ▪
amount : u128 ◦ 現在の Deposit されている総量から新たに amount だけ区間を拡張する。 • 区間の削除。 ◦ Input ▪ range: Range ▪ deposited_range_id: u128 ◦ 任意の区間を指定して削除する。 ◦ この際、削除する部分区間とする区間の左端の index が入力で与えられる。 (deposited_range_id)
Deposit アルゴリズム 初期状態 : total_deposit = 0; depositedRanges = {
} 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Deposit( amount = 4 ); total_deposit = 0; depositedRanges =
{ 4: Range { 0, 4 }, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Deposit( amount = 4 ); total_deposit = 4; depositedRanges =
{ 4: Range { 0, 4 }, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Deposit ( amount = 6 ); total_deposit = 4; depositedRanges
= { 4: Range { 0, 4 }, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Deposit ( amount = 6 ); total_deposit = 10; depositedRanges
= { 10: Range { 0, 10 }, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Deposit ( amount = 2 ); total_deposit = 10; depositedRanges
= { 10: Range { 0, 10 }, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Deposit ( amount = 2 ); total_deposit = 12; depositedRanges
= { 12: Range { 0,12}, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Exit ( range = Range { 2, 8 } );
total_deposit = 12; depositedRanges = { 12: Range { 0,12}, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Exit ( range = Range { 2, 8 } );
total_deposit = 12; depositedRanges = { 12: Range { 0,12}, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 deposited_range_id = 12 ※ deposited_range_id は 作用したい区間を含むような 区間を depositedRanges から 取得するためのキー。 左端の index と等しい。
Exit ( range = Range { 2, 8 } );
total_deposit = 12; depositedRanges = { 2: Range { 0, 2 }, 12: Range { 8,12}, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 deposited_range_id = 12 ※ deposited_range_id は 作用したい区間を含むような 区間を depositedRanges から 取得するためのキー。 左端の index と等しい。
Exit ( range = Range { 6, 10 } );
total_deposit = 12; depositedRanges = { 2: Range { 0, 2 }, 12: Range { 8,12}, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 deposited_range_id = 12
Exit ( range = Range { 6, 10 } );
total_deposit = 12; depositedRanges = { 2: Range { 0, 2 }, 12: Range { 8,12}, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 deposited_range_id = 12
Exit ( range = Range { 10, 12 } );
total_deposit = 12; depositedRanges = { 2: Range { 0, 2 }, 12: Range { 8,12}, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 deposited_range_id = 12
Exit ( range = Range { 10, 12 } );
total_deposit = 12; depositedRanges = { 2: Range { 0, 2 }, 10: Range { 8,10}, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 deposited_range_id = 12
Deposit ( acmount = 5 ); total_deposit = 12; depositedRanges
= { 2: Range { 0, 2 }, 10: Range { 8,10}, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Deposit ( acmount = 5 ); total_deposit = 17; depositedRanges
= { 2: Range { 0, 2 }, 10: Range { 8,10}, 17: Range {12,17}, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Exit ( Range { 12, 14 } ); total_deposit =
17; depositedRanges = { 2: Range { 0, 2 }, 10: Range { 8,10}, 17: Range {12,17}, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Exit ( Range { 12, 14 } ); total_deposit =
17; depositedRanges = { 2: Range { 0, 2 }, 10: Range { 8,10}, 17: Range {14,17}, } 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
How do I know deposited_range_id? 方法①:ルートチェーンから発行されるイベントを 全て捜査してクライアント側で構築 方法②:DepositedRanges の Map
の実装を平衡二分探索木などを 用いて key をBinarySearch