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
54
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
24
Plasma on Substrate @Fukuoka
staketechnologies
0
62
Sub0 Recap Japanese
staketechnologies
0
54
Plasm Introduction
staketechnologies
1
110
0318Substrateプレゼン資料.pdf
staketechnologies
4
620
2019.01ブロックチェーントレンド
staketechnologies
0
34
Other Decks in Technology
See All in Technology
AI Agentと MCP Serverで実現する iOSアプリの 自動テスト作成の効率化
spiderplus_cb
0
500
Access-what? why and how, A11Y for All - Nordic.js 2025
gdomiciano
1
110
空間を設計する力を考える / 20251004 Naoki Takahashi
shift_evolve
PRO
3
340
SREとソフトウェア開発者の合同チームはどのようにS3のコストを削減したか?
muziyoshiz
1
100
GC25 Recap+: Advancing Go Garbage Collection with Green Tea
logica0419
1
410
業務自動化プラットフォーム Google Agentspace に入門してみる #devio2025
maroon1st
0
190
Escaping_the_Kraken_-_October_2025.pdf
mdalmijn
0
140
LLM時代にデータエンジニアの役割はどう変わるか?
ikkimiyazaki
0
280
Where will it converge?
ibknadedeji
0
180
stupid jj tricks
indirect
0
8k
pprof vs runtime/trace (FlightRecorder)
task4233
0
170
PLaMoの事後学習を支える技術 / PFN LLMセミナー
pfn
PRO
9
3.8k
Featured
See All Featured
A better future with KSS
kneath
239
17k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
Optimizing for Happiness
mojombo
379
70k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
53k
The Language of Interfaces
destraynor
162
25k
Speed Design
sergeychernyshev
32
1.1k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
610
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.7k
Designing Experiences People Love
moore
142
24k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.2k
Rails Girls Zürich Keynote
gr2m
95
14k
Typedesign – Prime Four
hannesfritz
42
2.8k
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