A decentralized distributed storage service will be an important and necessary component of a blockchain in the future. At this project, we build a storage service for blockchain system based on IPFS protocol.
Tiny-storage includes several features:
- Read and write data from tiny-storage.
- Interact with smart contracts in blockchain.
- Provable data possession.
Interface layer exposes the interact interface for blockchain.
Service layer implements services and interfaces provided for upper layer. We provide several services at v1.0:
- Data reading and writing.
- Provable data possession.
We defined a structure called Data Possesion Description(copy for short):
cid- content hash of datasignature- signature of ownerpubkey- public key of ownert- expected storing durationn- expected replica nodes
At data writing protocol, we define message as m = <copy,proof,n,signs,src_peer>:
copy- data possesion descriptionproof- id of proof stored in smart contractsn- the number of remote peers should be transferredsrc_peer- pid of the original source peer (namely the peer broadcasting message first)signs- list of signatures. If a peer accept the message, it will sign and append the signature and public key to the list. Each entry includes two elements:- pk - publick key
- sign - signature
The process of writing data is asynchronous as below:
- A contract is deployed in blockchain before using storage service. Users invoke contract methods with
cid,n,t,size,signatureas parameters. Using these parameters, contract calculates the expected fee of this storing request with a pre-defined formula, and charge callers. At the same time, it generates aproof, stored in blockchain, and returns proof id. If caller's balance is not enough, returns error.proofincludes several fields:id- proof idcid- content hash of data.size- size of data.t- expected data storing duration.n- expected number of replica peers.sign- signature for params collection includingcid,size,tandnfrom caller.
- Users upload real data to a certain blockchain node(
Onodefor short), and specify expected number of replica peersnand storing durationt.Onodeinvoke contract method with proof id passed by users to get the proof details, and verify whether the actual size of data exceed that specified byproofor not. - When verification passes,
Onodeadd data to IPFS(operated by nodes in blockchain). And then the node multicast a messagem=<copy,proof,n-1,signs,src_peer>to n-1 neighbors. - When a certain node receive the message, it kicks off a countdown to collect enough messages with the same proof id. After the countdown offs, the node will choose the message with the same proof id and the longest signs list(
k=len(signs)), which means transferred farthest, and verify signatures in signs list. If pass, process four steps as below:- Get proof details from blockchain with proof id.
- Fetch data from IPFS with
cid. A timeout is necessary. After retrieves data, verify the actual size and storing expires with proof details. - If verification passes, sign
<copy>, append the signature and public key to the signs list, and multicastm=<copy,proof,n-k,signs,src_peer>to other n-k neighbors. Otherwise, do nothing. If n - k = 0, do nothing. - At the same time, response success message to src_peer.
- Users are allowed to retrieve the amount of replica peers with a given cid from
Onodeat any time.
Notice: This solution makes sure that the storing request message m=<copy,proof,n,signs,src_peer> will be sent to at least n peers, but not guarantees the number of actual replica peers is not smaller than n.
Some key details:
- Should it charge for data storing? What is the strategy?
- Should we set the max limit of data size? If so, what's the limit we prefer?
- We need experiments to figure out the best timeout when collecting storing request messages and fetching data from IPFS.
Client send GET request to a certain node with cid as parameter. This node will fetch data from IPFS and returns the file path. Client download data with the url combining the url and path.
All storing nodes can only delete local data, and cannot force other peers to delete data. Users cannot delete data has been stored in tiny-storage subjectively.
Every data has a deadline. When reaches deadline, the data will be removed automatically.
For all decentralized distributed storage, how to prove the data is really stored in certain nodes is always a big problem. At this project, we want to design a mechanism of provable data posession. It's independent of consensus mechanism, and only implemented at application layer.
This part is working in progress. Most part of work will be based on the paper 《Provable Data Possession at Untrusted Stores》.
To encourage peers to store data, we need to design a reasonable reward mechanism.
This part is working in progress.
At protocol layer, we build a private IPFS network, operated by nodes in blockchain, and provide data management, visualization, interact abilities and so on. Some features are involved in this part:
- Old data eviction according to specified strategies.
- Peers with high quality have a higher priority to store data. Quality and weight of peers judgement (calculation) mechanism need to be designed.
- Good peers declare reward after storing data.
- Detection and punishment for malicious peers.
