From a51b84261f13d72916c9776fb7ec05f238927080 Mon Sep 17 00:00:00 2001 From: Volker Mische Date: Wed, 8 Jan 2025 13:03:19 +0100 Subject: [PATCH] fix: clean up public API for clearing files `clear_layer_data()` and `clear_caches` are never called within `rust-fil-proofs` and also not used in `rust-filecoin-proofs-api`, hence remove them. The `clear_cache()` and `clear_synthetic_proofs()` functions don't need to be generic over the tree as it's never used within those functions. This is a breaking change. BREAKING CHANGE: signature of `clear_cache()` and `clear_synthetic_proofs()` changed. The generic parameter is no longer needed. --- fil-proofs-tooling/src/bin/benchy/porep.rs | 2 +- fil-proofs-tooling/src/shared.rs | 2 +- filecoin-proofs/src/api/mod.rs | 45 ++-------------------- 3 files changed, 6 insertions(+), 43 deletions(-) diff --git a/fil-proofs-tooling/src/bin/benchy/porep.rs b/fil-proofs-tooling/src/bin/benchy/porep.rs index 697cf178b..dc3ba4818 100644 --- a/fil-proofs-tooling/src/bin/benchy/porep.rs +++ b/fil-proofs-tooling/src/bin/benchy/porep.rs @@ -431,7 +431,7 @@ pub fn run_porep_bench( let phase1_output = seal_commit_phase1_measurement.return_value; if porep_config.feature_enabled(ApiFeature::SyntheticPoRep) { - clear_synthetic_proofs::(&cache_dir)?; + clear_synthetic_proofs(&cache_dir)?; } // Persist commit phase1_output here diff --git a/fil-proofs-tooling/src/shared.rs b/fil-proofs-tooling/src/shared.rs index ca6c76aef..76004e75e 100644 --- a/fil-proofs-tooling/src/shared.rs +++ b/fil-proofs-tooling/src/shared.rs @@ -278,7 +278,7 @@ pub fn create_replicas( piece_infos[i].as_slice(), ) .expect("failed to generate synthetic proofs"); - clear_cache::(cache_dirs[i].path()) + clear_cache(cache_dirs[i].path()) .expect("failed to clear synthetic porep layer data"); } else { info!("SyntheticPoRep is NOT enabled"); diff --git a/filecoin-proofs/src/api/mod.rs b/filecoin-proofs/src/api/mod.rs index 0789f46fd..6e9f657ed 100644 --- a/filecoin-proofs/src/api/mod.rs +++ b/filecoin-proofs/src/api/mod.rs @@ -1,4 +1,3 @@ -use std::collections::BTreeMap; use std::fs::{File, OpenOptions}; use std::io::{self, BufReader, BufWriter, Read, Write}; use std::path::{Path, PathBuf}; @@ -28,8 +27,8 @@ use crate::{ parameters::public_params, pieces::{get_piece_alignment, sum_piece_bytes_with_alignment}, types::{ - Commitment, MerkleTreeTrait, PaddedBytesAmount, PieceInfo, PoRepConfig, PrivateReplicaInfo, - ProverId, SealPreCommitPhase1Output, Ticket, UnpaddedByteIndex, UnpaddedBytesAmount, + Commitment, MerkleTreeTrait, PaddedBytesAmount, PieceInfo, PoRepConfig, ProverId, + SealPreCommitPhase1Output, Ticket, UnpaddedByteIndex, UnpaddedBytesAmount, }, }; @@ -51,10 +50,7 @@ pub use winning_post::*; pub use storage_proofs_update::constants::{partition_count, TreeRHasher}; -// TODO vmx 2023-09-26: The `Tree` generic is not needed, it's only there in order to not breaking -// the public API. Once we break the API, remove that generic. -// Ensure that any associated cached data persisted is discarded. -pub fn clear_cache(cache_dir: &Path) -> Result<()> { +pub fn clear_cache(cache_dir: &Path) -> Result<()> { info!("clear_cache:start"); let result = stacked::clear_cache_dir(cache_dir); @@ -64,40 +60,7 @@ pub fn clear_cache(cache_dir: &Path) -> Result<()> { result } -// TODO vmx 2023-09-26: The `Tree` generic is not needed, it's only there in order to not breaking -// the public API. Once we break the API, remove that generic. -// Ensure that any associated cached data persisted is discarded. -pub fn clear_caches( - replicas: &BTreeMap>, -) -> Result<()> { - info!("clear_caches:start"); - - for replica in replicas.values() { - clear_cache::(replica.cache_dir.as_path())?; - } - - info!("clear_caches:finish"); - - Ok(()) -} - -// TODO vmx 2023-09-26: The `Tree` generic is not needed, it's only there in order to not breaking -// the public API. Once we break the API, remove that generic. -// Ensure that any persisted layer data generated from porep are discarded. -pub fn clear_layer_data(cache_dir: &Path) -> Result<()> { - info!("clear_layer_data:start"); - - let result = stacked::clear_cache_dir(cache_dir); - - info!("clear_layer_data:finish"); - - result -} - -// TODO vmx 2023-09-26: The `Tree` generic is not needed, it's only there in order to not breaking -// the public API. Once we break the API, remove that generic. -// Ensure that any persisted vanilla proofs generated from synthetic porep are discarded. -pub fn clear_synthetic_proofs(cache_dir: &Path) -> Result<()> { +pub fn clear_synthetic_proofs(cache_dir: &Path) -> Result<()> { info!("clear_synthetic_proofs:start"); let result = stacked::clear_synthetic_proofs(cache_dir);