mLSM mLSM: Making Authenticated Storage Faster in Ethereum
Pandian Raju1, Soujanya Ponnapalli1, Evan Kaminsky1, Gilad Oved1, Zachary Keener1 Vijay Chidambaram1,2, Ittai Abraham2
1The University of Texas at Austin; 2VMware Research
1
mLSM : Making Authenticated Storage Faster in Ethereum Pandian Raju - - PowerPoint PPT Presentation
mLSM mLSM : Making Authenticated Storage Faster in Ethereum Pandian Raju 1 , Soujanya Ponnapalli 1 , Evan Kaminsky 1 , Gilad Oved 1 , Zachary Keener 1 Vijay Chidambaram 1,2 , Ittai Abraham 2 1 The University of Texas at Austin; 2 VMware Research 1
Pandian Raju1, Soujanya Ponnapalli1, Evan Kaminsky1, Gilad Oved1, Zachary Keener1 Vijay Chidambaram1,2, Ittai Abraham2
1The University of Texas at Austin; 2VMware Research
1
2
3
B1 B2 B3 Node1 Node2 Node4 Node3 Node4 B4
4
User A, Balance: $500 User C, Balance: $500000
A
User B, Balance: $5000 User B, Balance: $5000 User A, Balance: $0 User C, Balance: $0
Balance (A) ? Balance : $0 Balance : $0
5
User A, Balance: $500 User C, Balance: $500000
A
User B, Balance: $5000
Balance (A) ? [ $500, PROOF ]
6
Client
User data : 10 GB
Server User data : 10 GB Total write IO : 500 GB Write Amplification : 50
(Intel SSD DC P4600 can last ~5 years assuming ~5 TB write per day) For the same SSD life expectancy, with 65x IO Amplification, instead of 5TB of data we can now only write ~75 GB of user data per day
7
Merkelized LSM
8
9
10
11
K1 : v1 K2 : v2 K3 : v3 K4 : v4 H(v1-2) H(v3-4) H(v1-4) K4 : V4’ H(v3-4’) H(v1-4’) With a constant sized root hash, we can authenticate all the key-value pairs Root hash is publicly available to all clients
k4
12
K1 : v1 K2 : v2 K3 : v3 P1 P2 Root K4 : v4 K4 : v4
k4
13
K1 : v1 K2 : v2 K3 : v3 K4 : v4 P1 P2 Root K4 : v4 K3 : v3 P1 Root
k4
14
K1 : v1 K2 : v2 K3 : v3 K4 : v4 P1 P2 Root K4 : v4 k3 : v3 Root P1 K4 : v4
Response :
calculating the root hash from the value and Merkle proof
15
K1 : v1 K2 : v2 K3 : v3 K4 : v4 P1 P2 Root K4 : v4 k3 : v3 Root P1 K4 : v4
Response :
16
K1 : v1 K2 : v2 K3 : v3 K4 : v4 P1 P2 Root K4 : v4
calculating the root hash from the value and Merkle proof
K3 : v3 Root P1 K4 : v4
Response :
17
K1 : v1 K2 : v2 P1 P2 Root
calculating the root hash from the value and Merkle proof
Root P1
Response :
P2 K3 : v3 K4 : v4 P2
k4
Merkle Proof
18
K1 : v1 K2 : v2 K3 : v3 P1 P2 Root K4 : v4 Root P1
Response :
P2
k4
Merkle Proof
19
K1 : v1 K2 : v2 K3 : v3 P1 P2 Root K4 : v4 Root P1
Response :
P2 P1
calculating the root hash from the value and Merkle proof
20
K1 : v1 K2 : v2 K3 : v3 K4 : v4 Root
Response :
Root Root P1 P2
calculating the root hash from the value and Merkle proof
21
K1 : v1 K2 : v2 K3 : v3 P1 P2 Root K4 : v4 Root
Response :
Root ?
the data
22
K1 : v1 K2 : v2 K3 : v3 K4 : v4 P1 P2 Root K4 : v4 k3 : v3 Root P1 K4 : v4’
Response :
23
K1 : v1 K2 : v2 K3 : v3 K4 : v4 P1 P2 Root K4 : v4
the value
K3 : v3 Root P1 K4 : v4’
Response :
24
K1 : v1 K2 : v2 P1 P2 Root
calculating the root hash from the value and Merkle proof
Root P1
Response :
P2’ K3 : v3 K4 : v4 P2
k4
Merkle Proof
25
K1 : v1 K2 : v2 K3 : v3 P1 P2 Root K4 : v4 Root P1
Response :
P2’
k4
Merkle Proof
26
K1 : v1 K2 : v2 K3 : v3 P1 P2 Root K4 : v4 Root P1
Response :
P2’ P1
calculating the root hash from the value and Merkle proof
27
K1 : v1 K2 : v2 K3 : v3 K4 : v4 Root
Response :
Root’ Root P1 P2
value
28
K1 : v1 K2 : v2 K3 : v3 P1 P2 Root K4 : v4 Root
Response :
Root’ ?
29
2
Root Hash P1
5 f 1
Branching: 0 - f V1 P2 V2 V3
e
V4
value pairs
[Hash(V) -> V]
[Hash(P) -> [ … ]].
30
2
Root Hash P1
5 f 1
Branching: 0 - f V1 P2 V2 V3
e
V4
31
2
Root Hash P1
5 f 1
Branching: 0 - f V1 P2 V2 V3
e
V4 KEY VALUE
32
2
Root Hash P1
5 f 1
Branching: 0 - f V1 P2 V2 V3
e
V4 KEY VALUE Hash (V1) V1 Hash (V2) V2 Hash (V3) V3 Hash (V4) V4
33
2
Root Hash P1
5 f 1
Branching: 0 - f V1 P2 V2 V3
e
V4 KEY VALUE Hash (V1) V1 Hash (V2) V2 Hash (V3) V2 Hash (V4) V3 Hash (P1) Hash (V1), Hash (V2) Hash (P2) Hash (V3), Hash (V4)
34
2
Root Hash P1
5 f 1
Branching: 0 - f V1 P2 V2 V3
e
V4 KEY VALUE Hash (V1) V1 Hash (V2) V2 Hash (V3) V3 Hash (V4) V4 Hash (P1) Hash (V1), Hash (V2) Hash (P2) Hash (V3), Hash (V4) Hash (RH) Hash (P1), Hash (P2)
35
2
Root Hash P1
5 f 1
Branching: 0 - f V1 P2 V2 V3
e
V4 KEY VALUE Hash (V1) V1 Hash (V2) V2 Hash (V3) V3 Hash (V4) V4 Hash (P1) Hash (V1), Hash (V2) Hash (P2) Hash (V3), Hash (V4) Hash (RH) Hash (P1), Hash (P2) Get (0x2f)
36
2
Root Hash P1
5 f 1
Branching: 0 - f V1 P2 V2 V3
e
V4 Get (0x2f) Get (Hash(RH)) KEY VALUE Hash (V1) V1 Hash (V2) V2 Hash (V3) V3 Hash (V4) V4 Hash (P1) Hash (V1), Hash (V2) Hash (P2) Hash (V3), Hash (V4) Hash (RH) Hash (P1), Hash (P2)
37
2
Root Hash P1
5 f 1
Branching: 0 - f V1 P2 V2 V3
e
V4 Get (0x2f) Get (Hash(P1)) KEY VALUE Hash (V1) V1 Hash (V2) V2 Hash (V3) V3 Hash (V4) V4 Hash (P1) Hash (V1), Hash (V2) Hash (P2) Hash (V3), Hash (V4) Hash (RH) Hash (P1), Hash (P2)
38
2
Root Hash P1
5 f 1
Branching: 0 - f V1 P2 V2 V3
e
V4 Get (0x2f) Get (Hash(V2)) KEY VALUE Hash (V1) V1 Hash (V2) V2 Hash (V3) V3 Hash (V4) V4 Hash (P1) Hash (V1), Hash (V2) Hash (P2) Hash (V3), Hash (V4) Hash (RH) Hash (P1), Hash (P2)
39
2
Root Hash P1
5 f 1
Branching: 0 - f V1 P2 V5 V3
e
V4 Update (0x2f, 5) Update (Hash(V5), V5) KEY VALUE Hash (V1) V1 Hash (V5) V5 Hash (V3) V3 Hash (V4) V4 Hash (P1) Hash (V1), Hash (V2) Hash (P2) Hash (V3), Hash (V4) Hash (RH) Hash (P1), Hash (P2)
40
2
Root Hash P1’
5 f 1
Branching: 0 - f V1 P2 V5 V3
e
V4 Put (0x2f, 5) Update (Hash (P1’)) KEY VALUE Hash (V1) V1 Hash (V5) V5 Hash (V3) V3 Hash (V4) V4 Hash (P1’) Hash (V1), Hash (V2) Hash (P2) Hash (V3), Hash (V4) Hash (RH) Hash (P1), Hash (P2)
41
2
Root Hash’ P1’
5 f 1
Branching: 0 - f 1 Hash 3 - 4 5 3
e
4 Put (0x2f, 5) Update (RH’) KEY VALUE Hash (V1) V1 Hash (V5) V5 Hash (V3) V3 Hash (V4) V4 Hash (P1’) Hash (V1), Hash (V2) Hash (P2) Hash (V3), Hash (V4) Hash (RH’) Hash (P1’), Hash (P2)
42
43
44
45
46
2
Root Hash P1
5 f 1
Branching: 0 - f 1 P2 2 3
e
4
the Merkle Proof
47
2
Root Hash P1
5 f 1
Branching: 0 - f 1 P2 2 3
e
4 Key Value Proof 0x2f 2 [1, P2, Root Hash]
the Merkle Proof
48
2
Root Hash P1
5 f 1
Branching: 0 - f 1 P2 2 3
e
4 Key Value Proof 0x2f 2 [1, P2, Root Hash] 0x20 1 [2, P2, Root Hash]
the Merkle Proof
49
2
Root Hash P1
5 f 1
Branching: 0 - f 1 P2 2 3
e
4 Key Value Proof 0x2f 2 [1, P2, Root Hash] 0x20 1 [2, P2, Root Hash] 0x51 3 [4, P1, Root Hash]
the Merkle Proof
50
2
Root Hash P1
5 f 1
Branching: 0 - f 1 P2 2 3
e
4 Key Value Proof 0x2f 2 [1, P2, Root Hash] 0x20 1 [2, P2, Root Hash] 0x51 3 [4, P1, Root Hash] 0x5e 4 [3, P1, Root Hash]
51
2
Root Hash P1
5 f 1
Branching: 0 - f 1 P2 2 3
e
4 Key Value Proof 0x2f 2 [1, P2, Root Hash] 0x20 1 [2, P2, Root Hash] 0x51 3 [4, P1, Root Hash] 0x5e 4 [3, P1, Root Hash]
Reads can be served from the cache
52
2
Root Hash’ P1’
5 f 1
Branching: 0 - f 1 P2 5 3
e
4 Key Value Proof 0x2f 2 [1, P2, Root Hash] 0x20 1 [2, P2, Root Hash] 0x51 3 [4, P1, Root Hash] 0x5e 4 [3, P1, Root Hash]
53
2
Root Hash P1
5 f 1
Branching: 0 - f 1 P2 5 3
e
4 Key Value Proof 0x2f 5 [1, P2, Root Hash] 0x20 1 [2, P2, Root Hash] 0x51 3 [4, P1, Root Hash] 0x5e 4 [3, P1, Root Hash]
54
2
Root Hash P1’
5 f 1
Branching: 0 - f 1 P2 5 3
e
4 Key Value Proof 0x2f 5 [1, P2, Root Hash] 0x20 1 [2, P2, Root Hash] 0x51 3 [4, P1’, Root Hash] 0x5e 4 [3, P1’, Root Hash]
55
2
Root Hash’ P1’
5 f 1
Branching: 0 - f 1 P2 5 3
e
4 Key Value Proof 0x2f 5 [1, P2, Root Hash’] 0x20 1 [2, P2, Root Hash’] 0x51 3 [4, P1’, Root Hash’] 0x5e 4 [3, P1’, Root Hash’]
56
2
Root Hash’ P1
5 f 1
Branching: 0 - f 1 P2 5 3
e
4 Key Value Proof 0x2f 5 [1, P2, Root Hash’] 0x20 1 [2, P2, Root Hash’] 0x51 3 [4, P1’, Root Hash’] 0x5e 4 [3, P1’, Root Hash’]
Works only for read-only workloads
57
58
59
60
61
In-Memory Memory Storage
In-memory and On-disk layers
62
In memory data is periodically written as binary Merkle trees to storage
In-Memory Memory Storage
63
64
Merkle Trees on storage are logically arranged in different levels
In-Memory Memory Storage Level 0 Level 1 Level n
65
Compaction is performed once #Trees in a level reaches a threshold
In-Memory Memory Storage Level 0 Level 1 Level n Compaction
66
Compaction is performed once #Trees in a level reaches a threshold
In-Memory Memory Storage Level 0 Level 1 Level n Compaction
67
Writes are handled in-memory
In-Memory Memory Storage Level 0 Level 1 Level n Write (Key, Value)
68
Writes are batched and written onto storage
In-Memory Memory Storage Level 0 Level 1 Level n Write (Key, Value)
69
Numbers of files on reaching the threshold at the level
In-Memory Memory Storage Level 0 Level 1 Level n Compaction In-Memory Memory Storage Level 1 Level n Compaction Write (Key, Value)
70
Compaction is performed from lower levels to higher levels
In-Memory Memory Storage Level 0 Level 1 Level n Compaction
71
In-Memory Memory Storage Level 0 Level 1 Level n
72
In-Memory Memory Storage Level 0 Level 1 Level n
Every binary merkle tree on level has a local root
73
In-Memory Memory Storage Level 0 Level 1 Level n
Global Master Root dynamically computes global Merkle Tree
74
In-Memory Memory Storage Level 0 Level 1 Level n
Merkle Proof includes the local and the global Merkle proofs
75
76
LevelDB cache to store ( Key, Level : Value, Merkle Proof )
Key, Level Value, Proof LevelDB cache In-Memory Memory Storage Level 0 Level 1 Level n
77
Key, Level Value, Proof LevelDB cache In-Memory Memory Storage Level 0 Level 1 Level n Get (key)
78
In-memory structure is searched for the value
Key, Level Value, Proof LevelDB cache In-Memory Memory Storage Level 0 Level 1 Level n Get (key)
79
mLSM is traversed level by level in-order
Key, Level Value, Proof LevelDB cache In-Memory Memory Storage Level 0 Level 1 Level n Get (key)
80
First occurrence of the key value pair is returned
Key, Level Value, Proof LevelDB cache In-Memory Memory Storage Level 0 Level 1 Level n Get (key)
81
<Key, level : value, local Merkle proof> are cached
Key, Level Value, Proof key, Level value, Local proof LevelDB cache In-Memory Memory Storage Level 0 Level 1 Level n Get (key)
82
Key, Level Value, Proof key, Level value, Local Proof LevelDB cache In-Memory Memory Storage Level 0 Level 1 Level n Get (key)
NOTE: Global Proof is not cached
83
Key, Level Value, Proof key, Level value, Local Proof LevelDB cache In-Memory Memory Storage Level 0 Level 1 Level n
Subsequent reads are served from the cache
Get (key)
84
LevelDB cache can be populated once a new binary Merkle tree is created
In-Memory Memory Storage Compaction Level 0 Level 1 Level n Key, Level Value, Proof key, Level value, Local Proof LevelDB cache
85
In-Memory Memory Storage Level 0 Level 1 Level n
Writes affect values in a single local tree and the global root
Put (Key, value)
86
87
88
Reads Complexity Served by Cache Hit O(Levels in Cache) LevelDB cache Cache Miss O(Height of mLSM x Height of the binary tree) Traversing mLSM
89
90
In-Memory Memory Storage Level 0 Level 1 Level n
Compaction changes the local roots
Compaction
91
In-Memory Memory Storage Level 0 Level 1 Level n
Compaction changes the local roots and the global root
Compaction
92