Audit is the interface about proof of storage, which mainly deals with the proofs submission and verification of the data segments.
//pool of the proof of replication(PoRep) ready to verify which is generated by idle segment
VerPoolA = StorageDoubleMap<accountid, segment_id, (is_ready, size_type, proof, sealed_cid, rand, block_num)>
//pool of the proof of space time(PoSt) ready to verify which is generated by idle segment
VerPoolB = StorageDoubleMap<accountid, segment_id, (is_ready, size_type, proof, sealed_cid, rand, block_num)>
//pool of PoRep verified which is generated by idle segment
PrePoolA = StorageDoubleMap<accountid, segment_id, (size_type, proof, sealed_cid, block_num)>
//pool of PoSt verified which is generated by idle segment
PrePoolB = StorageDoubleMap<accountid, segment_id, (size_type, proof, sealed_cid, block_num)>
//count the total block height of all idle segments of miner
BlockNumberB = StorageMap<accountid, (block_num, total_num)>
- 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 <VerPoolA>;
}
: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 <VerPoolB>;
}
: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 <VerPoolA>){
1. update params with adding proof and sealed_cid in <VerPoolA>;
}
: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 <VerPoolA>){
if(result){
1. record current block number;
2. insert params of segment_id in <PrePoolA> and <PrePoolB>;
3. update <BlockNumberB>;
4. add storage power;
}
1. remove params from <VerPoolA>;
}
: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 <VerPoolB>){
1. update params with adding proof and sealed_cid in <VerPoolB>;
}
: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 <VerPoolB>){
if(result){
1. record current block number;
2. update params of segment_id in <PrePoolB>;
3. update <BlockNumberB>;
}
1. remove params from <VerPoolB>;
}
:end
//pool of PoRep ready to verify which is generated by service segment
VerPoolC = StorageDoubleMap<accountid, segment_id, (is_ready, size_type, proof, sealed_cid, rand, block_num)>
//pool of PoSt ready to verify which is generated by service segment
VerPoolD = StorageDoubleMap<accountid, segment_id, (is_ready, size_type, proof, sealed_cid, rand, block_num)>
//pool of PoRep verified which is generated by service segment
PrePoolC = StorageDoubleMap<accountid, segment_id, (size_type, proof, sealed_cid, block_num)>
//pool of PoSt verified which is generated by service segment
PrePoolD = StorageDoubleMap<accountid, segment_id, (size_type, proof, sealed_cid, block_num)>
//count the total block height of all service segments of miner
BlockNumberD = StorageMap<accountid, (block_num, total_num)>
- 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 <VerPoolC>;
}
: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 <VerPoolD>;
}
: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 <VerPoolC>){
1. update params with adding proof and sealed_cid in <VerPoolC>;
}
: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 <VerPoolC>){
if(result){
1. record current block number;
2. update params of segment_id in <PrePoolC> and <PrePoolD>;
3. update <BlockNumberD>;
4. add storage power and space;
}
1. remove params from <VerPoolC>;
}
: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 <VerPoolD>){
1. update params with adding proof and sealed_cid in <VerPoolD>;
}
: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 <VerPoolD>){
if(result){
1. record current block number;
2. update params of segment_id in <PrePoolD>;
3. update <BlockNumberD>;
}
1. remove params from <VerPoolD>;
}
:end
- 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 <PrePoolB> {
if(x not submitted during last period){
1. deduct power;
2. remove x from <PrePoolB>;
}
}
for x in <PrePoolD> {
if(x not submitted during last period){
1. deduct power;
2. remove x from <PrePoolD>;
}
}
}
:end