ππ π π -Tree: A Gas-Efficient Structure for Authenticated Range Queries in Blockchain Ce Zhang, Cheng Xu, Jianliang Xu, Yuzhe Tang, Byron Choi Hong Kong Baptist University, Hong Kong Syracuse University, NY, USA
Introduction Source: FAHM Technology Partners 4/10/2019 2
Blockchain Technology β’ Distributed Ledger maintained by a community of (untrusted) users β’ Decentralization β’ Consensus β’ Immutability β’ Provenance 4/10/2019 3
Smart Contract β’ A trusted program to execute user-defined computation upon the blockchain β’ Read and write blockchain data β’ Execution integrity is ensured by the consensus protocol β’ Offer trusted storage and computation capabilities β’ Function as a trusted virtual machine Traditional Blockchain Computer VM Storage RAM Blockchain Smart Computation CPU Contract 4/10/2019 4
Blockchain Scalability β’ Scalability problem β’ Storing any information on chain is not scalable β’ Large size data: document, image, etc. β’ Ethereum: block size 20KB, 15 sec per block β’ Off-chain storage β’ Raw data is stored outside of the blockchain β’ A hash of the data is kept on chain to ensure integrity 4/10/2019 5
Blockchain Hybrid Storage πππ§, π€πππ£π πππ§ Service Provider π€πππ£π Data Owner Client πππ§, h(π€πππ£π) h(π€πππ£π) Blockchain Hybrid Storage β’ Pros: high scalability, result integrity assured β’ Cons: only support exact search β’ Consider other type of queries? 4/10/2019 6
Objective and General Idea ADS π = [π, π] πππ§, π€πππ£π Service Provider π, ππ π‘π ADS Data Owner Client πππ§, h(π€πππ£π) ππ πβπππ Blockchain Hybrid Storage β’ Support integrity-assured range queries β’ Inspiration: authenticated query processing β’ Use the authenticated data structure (ADS) to support queries β’ Leverage both smart contract and the SP to maintain the ADS 4/10/2019 7
System Overview ADS π = [π, π] πππ§, π€πππ£π Service Provider π, ππ π‘π ADS Data Owner Client πππ§, h(π€πππ£π) ππ πβπππ Blockchain Hybrid Storage β’ Data Owner: send meta-data to blockchain and full data to SP β’ Smart Contract: update on-chain ADS β’ Service Provider: maintain the same ADS and process queries β’ Client: verify results with respect to the ADS from the blockchain 4/10/2019 8
Challenge β’ Each on-chain update requires a transaction β’ Transaction fee for smart contract-enabled blockchain β’ Modeled by gas for storage and computation (Ethereum) β’ Objective: How to design efficient ADS to be maintained by smart contract under the gas cost model Ethereum Gas Cost Model 4/10/2019 9
Contributions β’ A novel GasβEfficient Merkle Merge Tree (GEM 2 -Tree) β’ Reduce the storage and computation cost of the smart contract β’ Optimized version GEM 2β -Tree β’ Further reduce the maintenance cost without sacrificing much of the query performance 4/10/2019 10
Preliminaries β’ Authenticated Query Processing β’ The DO outsources the authenticated data structure (ADS) to the SP β’ The SP returns results and verification object (VO) β’ The client verifies the result using VO β’ ADS: Merkle Hash Tree (MHT) β’ Binary tree β’ Hash function combining the child nodes β’ VO: sibling hashes along the search path β’ Verification: reconstructing the root hash Result: {13,16} β’ Merkle B-Tree (MB-Tree) VO: {4, 24, β 6 } β’ Integrate B-tree with MHT 4/10/2019 11
Baseline Solution (1) β’ MB-tree β’ Maintained by both the smart contract and the SP β’ Data update requires writes on the entire tree path insert β’ π· MBβtree = log πΊ π 2π· π‘π‘π’ππ π + 2π· π‘π£ππππ’π + 2πΊ + 1 π· π‘ππππ + π· βππ‘β + π· π‘π‘π’ππ π SP Client ππ πβπππ = {β 7 } MB-tree Smart Contract 4/10/2019 12
Baseline Solution (2) β’ Suppressed Merkle B-tree (SMB-tree) β’ Observation of MB-tree: only root hash ππ πβπππ is used during query processing β’ Idea: β’ Suppress all internal nodes and only materialize the root node in the blockchain β’ The smart contract computes all nodes of the SMB-tree on the fly and updates the root hash to the blockchain storage β’ The SMB-tree in the SP keeps the complete structure (to retain the query performance) 1 insert β’ π· SMBβtree = π π· π‘ππππ + log π β π· πππ + πΊ π· βππ‘β + π· π‘π‘π’ππ π + π· π‘π£ππππ’π 4/10/2019 13
MB-tree vs SMB-tree 4/10/2019 14
Gas-Efficient Merkle Merge Tree (GEM 2 -Tree) β’ Maintain multiple separate structures β’ A series of small SMB-trees: index newly inserted objects β’ A full materialized MB-tree: merge the objects of the largest SMB-trees in batch Bulk Insert New object β¦ MB-tree SMB-trees 4/10/2019 15
An Example β’ Exponentially-sized partition space: each contains 1 or 2 SMB-trees β’ Partition table stores location range and root hash values β’ Key_map stores the key with the storage location (used in update operation) 4/10/2019 16
An Example β’ Exponentially-sized partition space: each contains 1 or 2 SMB-trees β’ Partition table stores location range and root hash values β’ Key_map stores the key with the storage location (used in update operation) 4/10/2019 16
An Example Exponential size β’ Exponentially-sized partition space: each contains 1 or 2 SMB-trees β’ Partition table stores location range and root hash values β’ Key_map stores the key with the storage location (used in update operation) 4/10/2019 16
An Example Exponential size β’ Exponentially-sized partition space: each contains 1 or 2 SMB-trees β’ Partition table stores location range and root hash values β’ Key_map stores the key with the storage location (used in update operation) 4/10/2019 16
An Example Exponential size Unsorted Sorted β’ Exponentially-sized partition space: each contains 1 or 2 SMB-trees β’ Partition table stores location range and root hash values β’ Key_map stores the key with the storage location (used in update operation) 4/10/2019 16
An Example Exponential size Unsorted Sorted β’ Exponentially-sized partition space: each contains 1 or 2 SMB-trees β’ Partition table stores location range and root hash values β’ Key_map stores the key with the storage location (used in update operation) 4/10/2019 16
Insertion If π πππ¦ is not full, insert object to π πππ¦ ; β’ β’ Example ( π = 2 ) β’ Else merge the two SMB-trees to a bigger SMB-tree 4/10/2019 17
Insertion If π πππ¦ is not full, insert object to π πππ¦ ; β’ β’ Example ( π = 2 ) β’ Else merge the two SMB-trees to a bigger SMB-tree πππ¦ = 1 [1-2] [3-4] π 1 4/10/2019 17
Insertion If π πππ¦ is not full, insert object to π πππ¦ ; β’ β’ Example ( π = 2 ) β’ Else merge the two SMB-trees to a bigger SMB-tree πππ¦ = 1 [1-2] [3-4] π 1 πππ¦ = 2 [1-4] null [5-6] [7-8] π π 2 1 4/10/2019 17
Insertion If π πππ¦ is not full, insert object to π πππ¦ ; β’ β’ Example ( π = 2 ) β’ Else merge the two SMB-trees to a bigger SMB-tree πππ¦ = 1 [1-2] [3-4] π 1 πππ¦ = 2 [1-4] null [5-6] [7-8] π π 2 1 πππ¦ = 2 [1-4] [5-8] [9-10] [11-12] π π 2 1 4/10/2019 17
Insertion If π πππ¦ is not full, insert object to π πππ¦ ; β’ β’ Example ( π = 2 ) β’ Else merge the two SMB-trees to a bigger SMB-tree πππ¦ = 1 [1-2] [3-4] π 1 πππ¦ = 2 [1-4] null [5-6] [7-8] π π 2 1 πππ¦ = 2 [1-4] [5-8] [9-10] [11-12] π π 2 1 πππ¦ = 3 [1-8] null [9-12] null [13-14] [15-16] π π 2 π 3 4/10/2019 1 17
Update and Query Processing β’ Update β’ Observation: storage location of each search key is fixed (key_map) β’ The GEM 2 -tree structure remains unchanged β’ Update the value of an existing key with a new value β’ Recompute the root hash of the MB-tree or SMB-tree β’ Query processing β’ The SP traverses the MB-tree and multiple SMB-trees β’ Process the range query on them individually β’ Combines the results and VO for each of these trees β’ The client checks the VO and results against each of these trees 4/10/2019 18
Optimized GEM 2* -Tree β’ Objective: to further reduce the gas consumption without sacrificing much of the query overhead β’ Design structure β’ Two-level index β’ Upper level: split the search key domain into several regions β’ Lower level: a GEM 2 -tree is built for each region π½ π β’ Only one single MB-tree for the entire GEM 2β -tree 4/10/2019 19
Recommend
More recommend