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

Bump rust-toolchain to 1.59.0 #1607

Merged
merged 3 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion fil-proofs-param/src/bin/fakeipfsadd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum Cli {
#[structopt(help = "Positional argument for the path to the file to add.")]
file_path: String,
#[structopt(short = "Q", help = "Simulates the -Q argument to `ipfs add`.")]
vmx marked this conversation as resolved.
Show resolved Hide resolved
quieter: bool,
_quieter: bool,
},
}

Expand Down
8 changes: 0 additions & 8 deletions fil-proofs-param/src/bin/srspublish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,6 @@ fn write_param_map_to_disk(param_map: &ParameterMap, json_path: &str) -> Result<
#[derive(Debug, StructOpt)]
#[structopt(name = "srspublish", version = "1.0", about = CLI_ABOUT.as_str())]
struct Cli {
#[structopt(
long = "list-all",
short = "a",
help = "The user will be prompted to select the files to publish from the set of all files \
found in the cache dir. Excluding the -a/--list-all flag will result in the user being \
prompted for a single param version number for filtering-in files in the cache dir."
)]
list_all_files: bool,
#[structopt(
long = "ipfs-bin",
value_name = "PATH TO IPFS BINARY",
Expand Down
71 changes: 38 additions & 33 deletions fil-proofs-param/tests/paramfetch/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,42 +63,47 @@ impl ParamFetchSessionBuilder {

/// Launch paramfetch in an environment configured by the builder.
pub fn build(self) -> ParamFetchSession {
let mut p = spawn_bash_with_retries(10, Some(self.session_timeout_ms))
.unwrap_or_else(|err| panic_any(err));

let cache_dir_path = format!("{:?}", self.cache_dir.path());

let paramfetch_path = cargo_bin("paramfetch");

let whitelist: String = self
.whitelisted_sector_sizes
.map(|wl| {
let mut s = "--sector-sizes=".to_string();
s.push_str(&wl.join(","));
s
})
.unwrap_or_else(|| "".to_string());

let json_argument = if self.manifest.is_some() {
format!("--json={:?}", self.manifest.expect("missing manifest"))
} else {
"".to_string()
let pty_session = match spawn_bash_with_retries(10, Some(self.session_timeout_ms)) {
Err(e) => panic_any(e),
Ok(mut session) => {
let cache_dir_path = format!("{:?}", self.cache_dir.path());

let paramfetch_path = cargo_bin("paramfetch");

let whitelist: String = self
.whitelisted_sector_sizes
.map(|wl| {
let mut s = "--sector-sizes=".to_string();
s.push_str(&wl.join(","));
s
})
.unwrap_or_else(|| "".to_string());

let json_argument = if self.manifest.is_some() {
format!("--json={:?}", self.manifest.expect("missing manifest"))
} else {
"".to_string()
};

let cmd = format!(
"{}={} {:?} {} {} {}",
"FIL_PROOFS_PARAMETER_CACHE", // related to var name in core/src/settings.rs
cache_dir_path,
paramfetch_path,
if self.prompt_enabled { "" } else { "--all" },
json_argument,
whitelist,
);

session
.execute(&cmd, ".*")
.expect("could not execute paramfetch");
session
}
};

let cmd = format!(
"{}={} {:?} {} {} {}",
"FIL_PROOFS_PARAMETER_CACHE", // related to var name in core/src/settings.rs
cache_dir_path,
paramfetch_path,
if self.prompt_enabled { "" } else { "--all" },
json_argument,
whitelist,
);

p.execute(&cmd, ".*").expect("could not execute paramfetch");

ParamFetchSession {
pty_session: p,
pty_session,
_cache_dir: self.cache_dir,
}
}
Expand Down
44 changes: 24 additions & 20 deletions fil-proofs-param/tests/parampublish/support/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,35 +116,39 @@ impl ParamPublishSessionBuilder {

/// Launch parampublish in an environment configured by the builder.
pub fn build(self) -> (ParamPublishSession, Vec<PathBuf>) {
let mut p = spawn_bash_with_retries(10, Some(self.session_timeout_ms))
.unwrap_or_else(|err| panic_any(err));

let cache_dir_path = format!("{:?}", self.cache_dir.path());
let pty_session = match spawn_bash_with_retries(10, Some(self.session_timeout_ms)) {
Err(err) => panic_any(err),
Ok(mut session) => {
let cache_dir_path = format!("{:?}", self.cache_dir.path());

let parampublish_path = cargo_bin("parampublish");

let cmd = format!(
"{}={} {:?} {} --ipfs-bin={:?} --json={:?}",
"FIL_PROOFS_PARAMETER_CACHE", // related to var name in core/src/settings.rs
cache_dir_path,
parampublish_path,
if self.list_all_files { "-a" } else { "" },
self.ipfs_bin_path,
self.manifest
);

session
.execute(&cmd, ".*")
.expect("could not execute parampublish");
session
}
};

let cache_contents: Vec<PathBuf> = read_dir(&self.cache_dir)
.unwrap_or_else(|_| panic_any(format!("failed to read cache dir {:?}", self.cache_dir)))
.map(|x| x.expect("failed to get dir entry"))
.map(|x| x.path())
.collect();

let parampublish_path = cargo_bin("parampublish");

let cmd = format!(
"{}={} {:?} {} --ipfs-bin={:?} --json={:?}",
"FIL_PROOFS_PARAMETER_CACHE", // related to var name in core/src/settings.rs
cache_dir_path,
parampublish_path,
if self.list_all_files { "-a" } else { "" },
self.ipfs_bin_path,
self.manifest
);

p.execute(&cmd, ".*")
.expect("could not execute parampublish");

(
ParamPublishSession {
pty_session: p,
pty_session,
_cache_dir: self.cache_dir,
},
cache_contents,
Expand Down
2 changes: 1 addition & 1 deletion fil-proofs-tooling/src/bin/check_parameters/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use clap::{Arg, Command};
use storage_proofs_core::parameter_cache::read_cached_params;

fn run_map(parameter_file: &Path) -> Result<MappedParameters<Bls12>> {
read_cached_params(&parameter_file.to_path_buf())
read_cached_params(parameter_file)
}

fn main() {
Expand Down
1 change: 1 addition & 0 deletions fil-proofs-tooling/src/bin/gpu-cpu-test/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ impl FromStr for Mode {
}

#[derive(Debug)]
#[allow(dead_code)]
pub struct RunInfo {
elapsed: Duration,
iterations: u8,
Expand Down
8 changes: 1 addition & 7 deletions filecoin-hashers/src/poseidon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Hashable<PoseidonFunction> for PoseidonDomain {
}
}

#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[derive(Default, Copy, Clone, Debug, Serialize, Deserialize)]
pub struct PoseidonDomain(pub <Fr as PrimeField>::Repr);

impl AsRef<PoseidonDomain> for PoseidonDomain {
Expand All @@ -79,12 +79,6 @@ impl PartialEq for PoseidonDomain {

impl Eq for PoseidonDomain {}

impl Default for PoseidonDomain {
fn default() -> PoseidonDomain {
PoseidonDomain(<Fr as PrimeField>::Repr::default())
}
}

impl Ord for PoseidonDomain {
#[inline(always)]
fn cmp(&self, other: &PoseidonDomain) -> Ordering {
Expand Down
4 changes: 1 addition & 3 deletions filecoin-proofs/tests/pieces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ fn test_get_piece_alignment() {
(300, 300, (208, 208)),
];

for (bytes_in_sector, bytes_in_piece, (expected_left_align, expected_right_align)) in
table.clone()
{
for (bytes_in_sector, bytes_in_piece, (expected_left_align, expected_right_align)) in table {
let PieceAlignment {
left_bytes: UnpaddedBytesAmount(actual_left_align),
right_bytes: UnpaddedBytesAmount(actual_right_align),
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.56.0
1.59.0
1 change: 1 addition & 0 deletions sha2raw/src/sha256_intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use x86::{

/// Process a block with the SHA-256 algorithm.
/// Based on https://github.com/noloader/SHA-Intrinsics/blob/master/sha256-x86.c
#[allow(clippy::needless_late_init)]
#[inline(always)]
pub unsafe fn compress256(state: &mut [u32; 8], blocks: &[&[u8]]) {
assert_eq!(blocks.len() % 2, 0);
Expand Down
3 changes: 1 addition & 2 deletions storage-proofs-core/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ pub fn reverse_bit_numbering(bits: Vec<Boolean>) -> Vec<Boolean> {

padded_bits
.chunks(8)
.map(|chunk| chunk.iter().rev())
.flatten()
.flat_map(|chunk| chunk.iter().rev())
.cloned()
.collect()
}
Expand Down
2 changes: 1 addition & 1 deletion storage-proofs-porep/src/stacked/vanilla/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl ParentCache {
let mut digest_hex: String = "".to_string();
let sector_size = graph.size() * NODE_SIZE;

with_exclusive_lock(&path.to_path_buf(), |file| {
with_exclusive_lock(path, |file| {
let cache_size = cache_entries as usize * NODE_BYTES * DEGREE;
file.as_ref()
.set_len(cache_size as u64)
Expand Down
4 changes: 2 additions & 2 deletions storage-proofs-porep/src/stacked/vanilla/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,15 +578,15 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
];

// gather all layer data.
for (layer_index, mut layer_bytes) in
for (layer_index, layer_bytes) in
layer_data.iter_mut().enumerate()
{
let store = labels.labels_for_layer(layer_index + 1);
let start = (i * nodes_count) + node_index;
let end = start + chunked_nodes_count;

store
.read_range_into(start, end, &mut layer_bytes)
.read_range_into(start, end, layer_bytes)
.expect("failed to read store range");
}

Expand Down
8 changes: 5 additions & 3 deletions storage-proofs-porep/src/stacked/vanilla/utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::mut_from_ref)]

use std::cell::UnsafeCell;
use std::slice::{self, ChunksExactMut};

Expand All @@ -6,7 +8,7 @@ use std::slice::{self, ChunksExactMut};
#[derive(Debug)]
pub struct UnsafeSlice<'a, T> {
// holds the data to ensure lifetime correctness
data: UnsafeCell<&'a mut [T]>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure about this one, but this doesn't seem right. As the comment suggests, I think we still want to have a reference to the data for correctness purpose. Hence I would just rename it to _data instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, keeping this lifetime is important, to make sure it is tracked properly

Copy link
Contributor Author

@storojs72 storojs72 May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Returned lifetime and renamed data to _data in 9af5c14. Could You please elaborate more on proper tracking?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that if we just use the raw pointer the compiler won't be able to track the lifetime for us. if we keep it in here we get the tracking for it.

_data: UnsafeCell<&'a mut [T]>,
/// pointer to the data
ptr: *mut T,
/// Number of elements, not bytes.
Expand All @@ -20,8 +22,8 @@ impl<'a, T> UnsafeSlice<'a, T> {
pub fn from_slice(source: &'a mut [T]) -> Self {
let len = source.len();
let ptr = source.as_mut_ptr();
let data = UnsafeCell::new(source);
Self { data, ptr, len }
let _data = UnsafeCell::new(source);
Self { _data, ptr, len }
}

/// Safety: The caller must ensure that there are no unsynchronized parallel access to the same regions.
Expand Down