Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generate multiple proofs #661

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 24 additions & 26 deletions storage-provider/server/src/pipeline/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod types;

use std::{path::PathBuf, sync::Arc};
use std::{collections::BTreeSet, path::PathBuf, sync::Arc};

use polka_storage_proofs::{
porep::{
Expand Down Expand Up @@ -667,36 +667,35 @@ async fn submit_windowed_post(
return Err(PipelineError::DeadlineStateNotFound);
};

if deadline_state.partitions.len() > 1 {
todo!("I don't know what to do: polka-storage#595");
}
if deadline_state.partitions.len() == 0 {
tracing::info!("There are not partitions in this deadline yet. Nothing to prove here.");
schedule_post(state, deadline_index)?;
return Ok(());
}

let partitions = deadline_state.partitions.keys().cloned().collect();
let (_partition_number, PartitionState { sectors }) = deadline_state
.partitions
.first_key_value()
.expect("1 partition to be there");
let all_sectors = BTreeSet::from_iter(
deadline_state
.partitions
.into_iter()
.flat_map(|(_, PartitionState { sectors })| sectors),
);

if sectors.len() == 0 {
if all_sectors.len() == 0 {
tracing::info!("Every sector expired... Nothing to prove here.");
schedule_post(state, deadline_index)?;
return Ok(());
}

let mut replicas = Vec::new();
for sector_number in sectors {
for sector_number in all_sectors {
let sector = state
.db
.get_sector::<ProvenSector>(*sector_number)?
.get_sector::<ProvenSector>(sector_number)?
.ok_or(PipelineError::SectorNotFound)?;

replicas.push(ReplicaInfo {
sector_id: *sector_number,
sector_id: sector_number,
comm_r: sector.comm_r.raw(),
cache_path: sector.cache_path.clone(),
replica_path: sector.sealed_path.clone(),
Expand All @@ -714,17 +713,19 @@ async fn submit_windowed_post(
})
};
let proofs = handle.await??;

// TODO(@th7nder,#595,06/12/2024): how many proofs are for how many partitions and why
// don't now why yet, need to figure this out
let proof: SubstrateProof = proofs[0]
.clone()
.try_into()
.expect("converstion between rust-fil-proofs and polka-storage-proofs to work");
let proof = codec::Encode::encode(&proof);

tracing::info!("Generated PoSt proof for partitions: {:?}", partitions);

let proofs = proofs
.into_iter()
.map(|p| PoStProof {
post_proof: state.server_info.post_proof,
proof_bytes: codec::Encode::encode(
&TryInto::<SubstrateProof>::try_into(p.clone())
.expect("converstion between rust-fil-proofs and polka-storage-proofs to work"),
jmg-duarte marked this conversation as resolved.
Show resolved Hide resolved
),
})
.collect::<Vec<_>>();

tracing::info!("Wait for block {} for open deadline", deadline.start,);
state
.xt_client
Expand All @@ -737,11 +738,8 @@ async fn submit_windowed_post(
&state.xt_keypair,
SubmitWindowedPoStParams {
deadline: deadline_index,
partitions: partitions,
proofs: vec![PoStProof {
post_proof: state.server_info.post_proof,
proof_bytes: proof,
}],
partitions,
proofs,
},
true,
)
Expand Down
Loading