# Designs of Storage Mining Audit is the interface about proof of storage, which mainly deals with the proofs submission and verification of the data segments. ![Image](https://raw.githubusercontent.com/CESSProject/W3F-illustration/main/cess-v0.1.1/Substrate-Node-Template-2.png) ![Image](https://raw.githubusercontent.com/CESSProject/W3F-illustration/main/cess-v0.1.1/segmentbook.png) ## Proofs of idle segments ### Storage items ``` //pool of the proof of replication(PoRep) ready to verify which is generated by idle segment VerPoolA = StorageDoubleMap //pool of the proof of space time(PoSt) ready to verify which is generated by idle segment VerPoolB = StorageDoubleMap //pool of PoRep verified which is generated by idle segment PrePoolA = StorageDoubleMap //pool of PoSt verified which is generated by idle segment PrePoolB = StorageDoubleMap //count the total block height of all idle segments of miner BlockNumberB = StorageMap ``` ### Call functions - intent_submit: Outputs parameters such as segment-id, random number and other parameters required by miners to generate the PoRep, and submit some proof parameters to the unverified pool in advance. ``` begin with input(sender, size_type, submit_type, peerid, uncid, hash, shardhash): 1. get segement_id; 2. get random; if(segement_id unused){ 1. store params in ; } :end ``` - intent_submit_po_st: Outputs parameters such as random number and other parameters required by miners to generate the PoSt, and submit some proof parameters to the unverified pool in advance. ``` begin with input(sender, size_type, submit_type, segment_id): 1. get random; if(segement_id unused){ 1. store params in ; } :end ``` - submit_to_vpa: Submits the PoRep to the unverified pool to verify for scheduler node. ``` begin with input(sender, peer_id, segment_id, proof, sealed_cid): if(segement_id in ){ 1. update params with adding proof and sealed_cid in ; } :end ``` - verify_in_vpa: Verifies the PoRep from unverified pool, and submit the results. ``` begin with input(sender, peer_id, segment_id, result): if(segement_id in ){ if(result){ 1. record current block number; 2. insert params of segment_id in and ; 3. update ; 4. add storage power; } 1. remove params from ; } :end ``` - submit_to_vpb: Submits the PoSt to the unverified pool to verify for scheduler node. ``` begin with input(sender, peer_id, segment_id, proof, sealed_cid): if(segement_id in ){ 1. update params with adding proof and sealed_cid in ; } :end ``` - verify_in_vpb: Verifies the PoSt from unverified pool, and submit the results. ``` begin with input(sender, peer_id, segment_id, result): if(segement_id in ){ if(result){ 1. record current block number; 2. update params of segment_id in ; 3. update ; } 1. remove params from ; } :end ``` ## Proofs of service segments ### Storage items ``` //pool of PoRep ready to verify which is generated by service segment VerPoolC = StorageDoubleMap //pool of PoSt ready to verify which is generated by service segment VerPoolD = StorageDoubleMap //pool of PoRep verified which is generated by service segment PrePoolC = StorageDoubleMap //pool of PoSt verified which is generated by service segment PrePoolD = StorageDoubleMap //count the total block height of all service segments of miner BlockNumberD = StorageMap ``` ### Call functions - intent_submit: Outputs parameters such as segment-id, random number and other parameters required by miners to generate the PoRep, and submit some proof parameters to the unverified pool in advance. ``` begin with input(sender, size_type, submit_type, peerid, uncid, hash, shardhash): 1. get segement_id; 2. get random; if(segement_id unused){ 1. store params in ; } :end ``` - intent_submit_po_st: Outputs parameters such as random number and other parameters required by miners to generate the PoSt, and submit some proof parameters to the unverified pool in advance. ``` begin with input(sender, size_type, submit_type, segment_id): 1. get random; if(segement_id unused){ 1. store params in ; } :end ``` - submit_to_vpc: Submits the PoRep to the unverified pool to verify for scheduler node. ``` begin with input(sender, peer_id, segment_id, proof, sealed_cid): if(segement_id in ){ 1. update params with adding proof and sealed_cid in ; } :end ``` - verify_in_vpc: Verifies the PoRep from unverified pool, and submit the results. ``` begin with input(sender, peer_id, segment_id, result): if(segement_id in ){ if(result){ 1. record current block number; 2. update params of segment_id in and ; 3. update ; 4. add storage power and space; } 1. remove params from ; } :end ``` - submit_to_vpd: Submits the PoSt to the unverified pool to verify for scheduler node. ``` begin with input(sender, peer_id, segment_id, proof, sealed_cid): if(segement_id in ){ 1. update params with adding proof and sealed_cid in ; } :end ``` - verify_in_vpd: Verifies the PoSt from unverified pool, and submit the results. ``` begin with input(sender, peer_id, segment_id, result): if(segement_id in ){ if(result){ 1. record current block number; 2. update params of segment_id in ; 3. update ; } 1. remove params from ; } :end ``` ## Scheduler - check proofs of submission: Called in a 12-hour cycle to check whether the data segment submits the proofs on time and passes the verification. ``` begin with input(): if(period met){ for x in { if(x not submitted during last period){ 1. deduct power; 2. remove x from ; } } for x in { if(x not submitted during last period){ 1. deduct power; 2. remove x from ; } } } :end ```