Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

Commit

Permalink
feat: add cache path to unseal and remove t_aux/p_aux
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptonemo authored and dignifiedquire committed Nov 20, 2019
1 parent aa64462 commit 9a0fe0d
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- run:
name: Generate Groth parameters and verifying keys
command: paramcache
no_output_timeout: 60m
no_output_timeout: 1h
- save_parameter_cache

cargo_fetch:
Expand Down
25 changes: 19 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions sector-builder-ffi/examples/simple/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn main() {
let test_idx = env::args()
.collect::<Vec<String>>()
.get(2)
.expect("first argument must test index")
.expect("first argument must be test index")
.parse::<usize>()
.expect("could not parse argument to a usize");

Expand Down Expand Up @@ -106,7 +106,7 @@ unsafe fn sector_state_transitions(sector_size: u64) -> Result<(), failure::Erro
},
half_sector_size_unpadded: ((508.0 / 1024.0) * (sector_size as f64)) as usize,
max_num_staged_sectors: 2,
max_secs_to_seal_sector: 60 * 60, // TODO: something more rigorous
max_secs_to_seal_sector: 60 * 60 * 2, // TODO: something more rigorous
prover_id: [4u8; 32],
};

Expand Down Expand Up @@ -314,7 +314,7 @@ unsafe fn kill_restart_recovery(sector_size: u64) -> Result<(), failure::Error>
porep_proof_partitions: 2,
},
max_num_staged_sectors: 2,
max_secs_to_seal_sector: 60 * 60, // TODO: something more rigorous
max_secs_to_seal_sector: 60 * 60 * 2, // TODO: something more rigorous
};

info!("running FFI test using cfg={:?}", cfg);
Expand Down Expand Up @@ -536,7 +536,7 @@ unsafe fn sector_builder_lifecycle(sector_size: u64) -> Result<(), failure::Erro
third_piece_bytes: ((508.0 / 1024.0) * (sector_size as f64)) as usize,

max_num_staged_sectors: 2,
max_secs_to_seal_sector: 60 * 60, // TODO: something more rigorous
max_secs_to_seal_sector: 60 * 60 * 2, // TODO: something more rigorous
};

info!("running FFI test using cfg={:?}", cfg);
Expand Down
9 changes: 2 additions & 7 deletions sector-builder-ffi/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use filecoin_proofs_ffi::types::FFICandidate;
use storage_proofs::fr32::fr_into_bytes;
use storage_proofs::hasher::pedersen::PedersenDomain;
use storage_proofs::hasher::Domain;
use storage_proofs::stacked::PersistentAux;

/// Writes user piece-bytes to a staged sector and returns the id of the sector
/// to which the bytes were written.
Expand Down Expand Up @@ -410,7 +409,7 @@ pub unsafe extern "C" fn sector_builder_ffi_seal_pre_commit(

match (*ptr).seal_pre_commit(sector_id.into(), seal_ticket.into()) {
Ok(meta) => {
if let SealStatus::PreCommitted(t, _, p) = meta.seal_status {
if let SealStatus::PreCommitted(t, p) = meta.seal_status {
let pieces = meta
.pieces
.into_iter()
Expand Down Expand Up @@ -511,7 +510,7 @@ pub unsafe extern "C" fn sector_builder_ffi_resume_seal_pre_commit(

match (*ptr).resume_seal_pre_commit(sector_id.into()) {
Ok(meta) => {
if let SealStatus::PreCommitted(t, _, p) = meta.seal_status {
if let SealStatus::PreCommitted(t, p) = meta.seal_status {
let pieces = meta
.pieces
.into_iter()
Expand Down Expand Up @@ -684,10 +683,6 @@ pub unsafe extern "C" fn sector_builder_ffi_import_sealed_sector(
seal_seed.into(),
*comm_r,
*comm_d,
PersistentAux {
comm_c: comm_c.unwrap(),
comm_r_last: comm_r_last.unwrap(),
},
pieces,
proof,
) {
Expand Down
2 changes: 2 additions & 0 deletions sector-builder-ffi/src/reexported.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ pub unsafe extern "C" fn sector_builder_ffi_reexported_seal_commit(
#[no_mangle]
pub unsafe extern "C" fn sector_builder_ffi_reexported_unseal(
sector_class: filecoin_proofs_ffi::types::FFISectorClass,
cache_dir_path: *const libc::c_char,
sealed_sector_path: *const libc::c_char,
unseal_output_path: *const libc::c_char,
sector_id: u64,
Expand All @@ -237,6 +238,7 @@ pub unsafe extern "C" fn sector_builder_ffi_reexported_unseal(

filecoin_proofs_ffi::api::unseal(
sector_class,
cache_dir_path,
sealed_sector_path,
unseal_output_path,
sector_id,
Expand Down
6 changes: 3 additions & 3 deletions sector-builder-ffi/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ impl From<SealStatus> for FFISealStatus {
match ss {
SealStatus::AcceptingPieces => FFISealStatus::AcceptingPieces,
SealStatus::Committed(_) => FFISealStatus::Committed,
SealStatus::Committing(_, _, _, _) => FFISealStatus::Committing,
SealStatus::CommittingPaused(_, _, _, _) => FFISealStatus::CommittingPaused,
SealStatus::Committing(_, _, _) => FFISealStatus::Committing,
SealStatus::CommittingPaused(_, _, _) => FFISealStatus::CommittingPaused,
SealStatus::Failed(_) => FFISealStatus::Failed,
SealStatus::PreCommitted(_, _, _) => FFISealStatus::PreCommitted,
SealStatus::PreCommitted(_, _) => FFISealStatus::PreCommitted,
SealStatus::PreCommitting(_) => FFISealStatus::PreCommitting,
SealStatus::PreCommittingPaused(_) => FFISealStatus::PreCommittingPaused,
SealStatus::FullyPacked => FFISealStatus::FullyPacked,
Expand Down
3 changes: 0 additions & 3 deletions sector-builder/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use crate::metadata_manager::SectorMetadataManager;
use crate::scheduler::{PerformHealthCheck, Scheduler, SchedulerTask};
use crate::state::SectorBuilderState;
use crate::worker::*;
use filecoin_proofs::PersistentAux;
use std::io::Read;

const FATAL_NOLOAD: &str = "could not load snapshot";
Expand Down Expand Up @@ -228,7 +227,6 @@ impl<R: 'static + Send + std::io::Read> SectorBuilder<R> {
seal_seed: SealSeed,
comm_r: [u8; 32],
comm_d: [u8; 32],
p_aux: PersistentAux,
pieces: Vec<PieceMetadata>,
proof: Vec<u8>,
) -> Result<()> {
Expand All @@ -240,7 +238,6 @@ impl<R: 'static + Send + std::io::Read> SectorBuilder<R> {
seal_seed,
comm_r,
comm_d,
p_aux,
pieces,
proof,
done_tx: tx,
Expand Down
39 changes: 13 additions & 26 deletions sector-builder/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::TemporaryAuxKey;
use filecoin_proofs::types::UnpaddedBytesAmount;
use filecoin_proofs::{Commitment, PersistentAux, PieceInfo};
use filecoin_proofs::{Commitment, PieceInfo};
use serde::{Deserialize, Serialize};
use storage_proofs::sector::SectorId;

Expand All @@ -24,7 +23,6 @@ pub struct SealedSectorMetadata {
pub blake2b_checksum: Vec<u8>,
/// number of bytes in the sealed sector-file as returned by `std::fs::metadata`
pub len: u64,
pub p_aux: PersistentAux,
pub ticket: SealTicket,
pub seed: SealSeed,
}
Expand All @@ -49,28 +47,17 @@ impl From<PieceMetadata> for PieceInfo {
pub struct PersistablePreCommitOutput {
pub comm_d: Commitment,
pub comm_r: Commitment,
pub p_aux: PersistentAux,
}

#[allow(clippy::large_enum_variant)]
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub enum SealStatus {
Committed(Box<SealedSectorMetadata>),
Committing(
SealTicket,
TemporaryAuxKey,
PersistablePreCommitOutput,
SealSeed,
),
CommittingPaused(
SealTicket,
TemporaryAuxKey,
PersistablePreCommitOutput,
SealSeed,
),
Committing(SealTicket, PersistablePreCommitOutput, SealSeed),
CommittingPaused(SealTicket, PersistablePreCommitOutput, SealSeed),
Failed(String),
AcceptingPieces,
PreCommitted(SealTicket, TemporaryAuxKey, PersistablePreCommitOutput),
PreCommitted(SealTicket, PersistablePreCommitOutput),
PreCommitting(SealTicket),
PreCommittingPaused(SealTicket),
FullyPacked,
Expand All @@ -80,11 +67,11 @@ impl SealStatus {
pub fn persistable_pre_commit_output(&self) -> Option<&PersistablePreCommitOutput> {
match self {
SealStatus::Committed(_) => None,
SealStatus::Committing(_, _, p, _) => Some(&p),
SealStatus::CommittingPaused(_, _, p, _) => Some(&p),
SealStatus::Committing(_, p, _) => Some(&p),
SealStatus::CommittingPaused(_, p, _) => Some(&p),
SealStatus::Failed(_) => None,
SealStatus::AcceptingPieces => None,
SealStatus::PreCommitted(_, _, p) => Some(&p),
SealStatus::PreCommitted(_, p) => Some(&p),
SealStatus::PreCommitting(_) => None,
SealStatus::PreCommittingPaused(_) => None,
SealStatus::FullyPacked => None,
Expand All @@ -94,11 +81,11 @@ impl SealStatus {
pub fn ticket(&self) -> Option<&SealTicket> {
match self {
SealStatus::Committed(meta) => Some(&meta.ticket),
SealStatus::Committing(t, _, _, _) => Some(&t),
SealStatus::CommittingPaused(t, _, _, _) => Some(&t),
SealStatus::Committing(t, _, _) => Some(&t),
SealStatus::CommittingPaused(t, _, _) => Some(&t),
SealStatus::Failed(_) => None,
SealStatus::AcceptingPieces => None,
SealStatus::PreCommitted(t, _, _) => Some(&t),
SealStatus::PreCommitted(t, _) => Some(&t),
SealStatus::PreCommitting(t) => Some(&t),
SealStatus::PreCommittingPaused(t) => Some(&t),
SealStatus::FullyPacked => None,
Expand All @@ -108,11 +95,11 @@ impl SealStatus {
pub fn seed(&self) -> Option<&SealSeed> {
match self {
SealStatus::Committed(meta) => Some(&meta.seed),
SealStatus::Committing(_, _, _, s) => Some(&s),
SealStatus::CommittingPaused(_, _, _, s) => Some(&s),
SealStatus::Committing(_, _, s) => Some(&s),
SealStatus::CommittingPaused(_, _, s) => Some(&s),
SealStatus::Failed(_) => None,
SealStatus::AcceptingPieces => None,
SealStatus::PreCommitted(_, _, _) => None,
SealStatus::PreCommitted(_, _) => None,
SealStatus::PreCommitting(_) => None,
SealStatus::PreCommittingPaused(_) => None,
SealStatus::FullyPacked => None,
Expand Down
Loading

0 comments on commit 9a0fe0d

Please sign in to comment.