diff --git a/rust/rust-toolchain.toml b/rust/rust-toolchain.toml index 3c4b81eb..4ec1fbb2 100644 --- a/rust/rust-toolchain.toml +++ b/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.73.0" +channel = "1.80.1" components = ["clippy", "rustfmt"] diff --git a/rust/src/bls/api.rs b/rust/src/bls/api.rs index e5d92805..c442d9dd 100644 --- a/rust/src/bls/api.rs +++ b/rust/src/bls/api.rs @@ -25,6 +25,7 @@ pub type BLSDigest = [u8; DIGEST_BYTES]; /// Unwraps or returns the passed in value. macro_rules! try_ffi { ($res:expr, $val:expr) => {{ + #[allow(clippy::blocks_in_conditions)] match $res { Ok(res) => res, Err(_) => return $val, diff --git a/rust/src/fvm/engine.rs b/rust/src/fvm/engine.rs index 025adf0b..80c7f88e 100644 --- a/rust/src/fvm/engine.rs +++ b/rust/src/fvm/engine.rs @@ -109,7 +109,6 @@ impl MultiEngineContainer { // fvm v4 implementation mod v4 { - use anyhow::anyhow; use cid::Cid; use std::sync::Mutex; @@ -158,11 +157,7 @@ mod v4 { blockstore: CgoBlockstore, externs: CgoExterns, ) -> anyhow::Result { - let mut network_config = NetworkConfig::new( - cfg.network_version - .try_into() - .map_err(|nv| anyhow!("network version {nv} not supported"))?, - ); + let mut network_config = NetworkConfig::new(cfg.network_version.into()); network_config.chain_id(ChainID::from(cfg.chain_id)); if cfg.actor_debugging { @@ -194,7 +189,7 @@ mod v4 { // fvm v3 implementation mod v3 { - use anyhow::{anyhow, Context}; + use anyhow::Context; use cid::Cid; use fvm4_shared::event::{self, ActorEvent, Entry, StampedEvent}; use num_traits::FromPrimitive; @@ -434,11 +429,7 @@ mod v3 { blockstore: CgoBlockstore, externs: CgoExterns, ) -> anyhow::Result { - let mut network_config = NetworkConfig3::new( - cfg.network_version - .try_into() - .map_err(|nv| anyhow!("network version {nv} not supported"))?, - ); + let mut network_config = NetworkConfig3::new(cfg.network_version.into()); network_config.chain_id(ChainID3::from(cfg.chain_id)); if cfg.actor_debugging { diff --git a/rust/src/fvm/machine.rs b/rust/src/fvm/machine.rs index 517419d9..f398a154 100644 --- a/rust/src/fvm/machine.rs +++ b/rust/src/fvm/machine.rs @@ -629,7 +629,7 @@ mod test { assert_eq!(lotus_trace.gas_charges.len(), 1); assert_eq!( - *lotus_trace.gas_charges.get(0).unwrap(), + *lotus_trace.gas_charges.first().unwrap(), LotusGasCharge { name: initial_gas_charge.clone().name, total_gas: initial_gas_charge.total().round_up(), diff --git a/rust/src/fvm/mod.rs b/rust/src/fvm/mod.rs index 66ed6237..87294c64 100644 --- a/rust/src/fvm/mod.rs +++ b/rust/src/fvm/mod.rs @@ -4,7 +4,6 @@ mod externs; pub mod engine; pub mod machine; -#[allow(clippy::incorrect_clone_impl_on_copy_type)] pub mod types; pub use cgo::FvmError; diff --git a/rust/src/fvm/types.rs b/rust/src/fvm/types.rs index 87d2a2b4..7aa9703a 100644 --- a/rust/src/fvm/types.rs +++ b/rust/src/fvm/types.rs @@ -1,3 +1,5 @@ +#![allow(clippy::non_canonical_clone_impl)] + use std::sync::Mutex; use safer_ffi::prelude::*; diff --git a/rust/src/proofs/api.rs b/rust/src/proofs/api.rs index 2b145e94..a4c7a282 100644 --- a/rust/src/proofs/api.rs +++ b/rust/src/proofs/api.rs @@ -2068,7 +2068,7 @@ pub mod tests { let f_new_sealed_sector = OpenOptions::new() .read(true) .write(true) - .create(true) + .create_new(true) .open(&new_sealed_path)?; f_new_sealed_sector.set_len(new_sealed_target_len)?; @@ -2185,7 +2185,7 @@ pub mod tests { let f_decoded_sector = OpenOptions::new() .read(true) .write(true) - .create(true) + .create_new(true) .open(&decoded_path)?; f_decoded_sector.set_len(new_sealed_target_len)?; @@ -2212,7 +2212,7 @@ pub mod tests { let f_removed_data_sector = OpenOptions::new() .read(true) .write(true) - .create(true) + .create_new(true) .open(&removed_data_path)?; f_removed_data_sector.set_len(new_sealed_target_len)?; @@ -2352,7 +2352,7 @@ pub mod tests { panic!("generate_candidates produced no results"); } - let private_replicas = vec![PrivateReplicaInfo { + let private_replicas = [PrivateReplicaInfo { registered_proof: registered_proof_winning_post, cache_dir_path: cache_dir_path_ref.to_vec().into_boxed_slice().into(), comm_r: resp_b2.comm_r, @@ -2369,12 +2369,11 @@ pub mod tests { let msg = str::from_utf8(&resp_h.error_msg).unwrap(); panic!("generate_winning_post failed: {:?}", msg); } - let public_replicas = vec![PublicReplicaInfo { + let public_replicas = [PublicReplicaInfo { registered_proof: registered_proof_winning_post, sector_id, comm_r: resp_b2.comm_r, - }] - .into_boxed_slice(); + }]; let resp_i = verify_winning_post( &randomness, @@ -2475,7 +2474,7 @@ pub mod tests { // window post - let private_replicas = vec![PrivateReplicaInfo { + let private_replicas = [PrivateReplicaInfo { registered_proof: registered_proof_window_post, cache_dir_path: cache_dir_path_ref.to_vec().into_boxed_slice().into(), comm_r: resp_b2.comm_r, @@ -2490,7 +2489,7 @@ pub mod tests { panic!("generate_window_post failed: {:?}", msg); } - let public_replicas = vec![PublicReplicaInfo { + let public_replicas = [PublicReplicaInfo { registered_proof: registered_proof_window_post, sector_id, comm_r: resp_b2.comm_r, @@ -2514,7 +2513,7 @@ pub mod tests { // Generate a legacy WindowPoSt for later use. let legacy_registered_proof_window_post = RegisteredPoStProof::StackedDrgWindow2KiBV1; - let legacy_private_replicas = vec![PrivateReplicaInfo { + let legacy_private_replicas = [PrivateReplicaInfo { registered_proof: legacy_registered_proof_window_post, cache_dir_path: cache_dir_path_ref.to_vec().into_boxed_slice().into(), comm_r: resp_b2.comm_r, @@ -2530,7 +2529,7 @@ pub mod tests { panic!("generate_window_post failed: {:?}", msg); } - let public_replicas = vec![PublicReplicaInfo { + let public_replicas = [PublicReplicaInfo { registered_proof: legacy_registered_proof_window_post, // legacy registered proofs type sector_id, comm_r: resp_b2.comm_r, @@ -2554,7 +2553,7 @@ pub mod tests { // Lastly ensure that the legacy WindowPoSt generated proof // does not verify with the new proof version - let public_replicas = vec![PublicReplicaInfo { + let public_replicas = [PublicReplicaInfo { registered_proof: registered_proof_window_post, // new registered proof type/version sector_id, comm_r: resp_b2.comm_r, @@ -2585,7 +2584,7 @@ pub mod tests { ////////////////////////////////////////////// let sectors = [sector_id, sector_id2]; - let private_replicas = vec![ + let private_replicas = [ PrivateReplicaInfo { registered_proof: registered_proof_window_post, cache_dir_path: cache_dir_path_ref.to_vec().into_boxed_slice().into(), @@ -2601,7 +2600,7 @@ pub mod tests { sector_id: sector_id2, }, ]; - let public_replicas = vec![ + let public_replicas = [ PublicReplicaInfo { registered_proof: registered_proof_window_post, sector_id, @@ -2764,7 +2763,7 @@ pub mod tests { let resp_k3 = verify_window_post( &randomness, public_replicas[..].into(), - vec![merged_proof_resp.value.clone()][..].into(), + [merged_proof_resp.value.clone()][..].into(), &prover_id, ); @@ -2909,7 +2908,7 @@ pub mod tests { panic!("write_with_alignment failed: {:?}", msg); } - let pieces = vec![ + let pieces = [ PublicPieceInfo { num_bytes: 127, comm_p: resp_a1.comm_p, @@ -2959,7 +2958,7 @@ pub mod tests { let faulty_sealed_file = tempfile::NamedTempFile::new()?; let faulty_sealed_path_ref = as_bytes(faulty_sealed_file.path()); - let private_replicas = vec![PrivateReplicaInfo { + let private_replicas = [PrivateReplicaInfo { registered_proof: registered_proof_window_post, cache_dir_path: cache_dir_path_ref.to_vec().into_boxed_slice().into(), comm_r: resp_b2.comm_r, @@ -3002,7 +3001,7 @@ pub mod tests { #[test] #[ignore] fn test_sealing_aggregation_versions() -> Result<()> { - let versions = vec![ + let versions = [ ( RegisteredSealProof::StackedDrg2KiBV1, RegisteredAggregationProof::SnarkPackV1, @@ -3098,7 +3097,7 @@ pub mod tests { panic!("write_with_alignment failed: {:?}", msg); } - let pieces = vec![ + let pieces = [ PublicPieceInfo { num_bytes: 127, comm_p: resp_a1.comm_p, @@ -3239,7 +3238,7 @@ pub mod tests { ); } - let inputs: Vec = vec![ + let inputs = [ AggregationInputs { comm_r: resp_b2.comm_r, comm_d: resp_b2.comm_d, diff --git a/rust/src/util/types.rs b/rust/src/util/types.rs index 426651e0..837c5b43 100644 --- a/rust/src/util/types.rs +++ b/rust/src/util/types.rs @@ -210,13 +210,15 @@ where T: Sized, F: FnOnce() -> anyhow::Result + std::panic::UnwindSafe, { - let result = match panic::catch_unwind(|| { + let result = panic::catch_unwind(|| { init_log(); log::debug!("{}: start", name); let res = callback(); log::debug!("{}: end", name); res - }) { + }); + + repr_c::Box::new(match result { Ok(t) => match t { Ok(t) => Result::ok(t), Err(err) => Result::err_no_default(format!("{err:?}").into_bytes().into_boxed_slice()), @@ -233,9 +235,7 @@ where .into_boxed_slice(), ) } - }; - - repr_c::Box::new(result) + }) } /// Generate a destructor for the given type wrapped in a `repr_c::Box`.