diff --git a/.config/dictionaries/project.dic b/.config/dictionaries/project.dic index b25e8a564f5..97e8cb1b802 100644 --- a/.config/dictionaries/project.dic +++ b/.config/dictionaries/project.dic @@ -171,6 +171,7 @@ mdns MEMMAP memx Metadatum +metno mgrybyk mimalloc minicbor diff --git a/integration_tests/rust/Cargo.toml b/integration_tests/rust/Cargo.toml index 0d6087382ac..e58daff297c 100644 --- a/integration_tests/rust/Cargo.toml +++ b/integration_tests/rust/Cargo.toml @@ -30,7 +30,6 @@ exit = "deny" get_unwrap = "deny" index_refutable_slice = "deny" indexing_slicing = "deny" -match_on_vec_items = "deny" match_wild_err_arm = "deny" missing_panics_doc = "deny" panic = "deny" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index e48ccdcf2de..df963adefce 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -52,7 +52,6 @@ exit = "deny" get_unwrap = "deny" index_refutable_slice = "deny" indexing_slicing = "deny" -match_on_vec_items = "deny" match_wild_err_arm = "deny" missing_panics_doc = "deny" panic = "deny" diff --git a/rust/Earthfile b/rust/Earthfile index ccbb3c9bc08..373108a861b 100644 --- a/rust/Earthfile +++ b/rust/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.1 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.9 AS rust-ci IMPORT ../ AS repo-ci COPY_SRC: diff --git a/rust/c509-certificate/Cargo.toml b/rust/c509-certificate/Cargo.toml index 4a4e70b1f10..67b96ec2e12 100644 --- a/rust/c509-certificate/Cargo.toml +++ b/rust/c509-certificate/Cargo.toml @@ -25,7 +25,6 @@ oid-registry = "0.7.1" asn1-rs = "0.6.2" anyhow = "1.0.95" bimap = "0.6.3" -once_cell = "1.20.2" strum = "0.26.3" strum_macros = "0.26.4" regex = "1.11.1" diff --git a/rust/c509-certificate/examples/cli/main.rs b/rust/c509-certificate/examples/cli/main.rs index 185291dd639..cf80c5fc85c 100644 --- a/rust/c509-certificate/examples/cli/main.rs +++ b/rust/c509-certificate/examples/cli/main.rs @@ -200,7 +200,7 @@ fn generate( // If the output path is provided, write to the file if let Some(output) = output { write_to_output_file(output, &cert)?; - }; + } println!("Hex: {:?}", hex::encode(&cert)); println!("Bytes: {:?}", &cert); @@ -290,7 +290,7 @@ fn verify(file: &PathBuf, public_key: PathBuf) -> anyhow::Result<()> { match c509_certificate::verify(&cert, &pk) { Ok(()) => println!("Signature verified!"), Err(e) => println!("Signature verification failed: {e}"), - }; + } Ok(()) } @@ -328,7 +328,7 @@ fn decode(file: &PathBuf, output: Option) -> anyhow::Result<()> { // If the output path is provided, write to the file if let Some(output) = output { write_to_output_file(output, data.as_bytes())?; - }; + } println!("{data}"); Ok(()) diff --git a/rust/c509-certificate/src/attributes/attribute.rs b/rust/c509-certificate/src/attributes/attribute.rs index 5eb871fd9e8..4a179e18915 100644 --- a/rust/c509-certificate/src/attributes/attribute.rs +++ b/rust/c509-certificate/src/attributes/attribute.rs @@ -198,7 +198,7 @@ impl Encode<()> for AttributeValue { match self { AttributeValue::Text(text) => encode_helper(e, "Attribute value", ctx, text)?, AttributeValue::Bytes(bytes) => encode_helper(e, "Attribute value", ctx, bytes)?, - }; + } Ok(()) } } diff --git a/rust/c509-certificate/src/attributes/data.rs b/rust/c509-certificate/src/attributes/data.rs index 0ae826a3453..0002f1225b7 100644 --- a/rust/c509-certificate/src/attributes/data.rs +++ b/rust/c509-certificate/src/attributes/data.rs @@ -2,9 +2,10 @@ //! Attribute. See [C509 Certificate](https://datatracker.ietf.org/doc/draft-ietf-cose-cbor-encoded-cert/11/) //! Section 9.3 C509 Attributes Registry for more information. +use std::sync::LazyLock; + use anyhow::Error; use asn1_rs::{oid, Oid}; -use once_cell::sync::Lazy; use crate::tables::IntegerToOidTable; @@ -62,7 +63,7 @@ impl AttributeData { } /// Define static lookup for attributes table -static ATTRIBUTES_TABLES: Lazy = Lazy::new(|| { +static ATTRIBUTES_TABLES: LazyLock = LazyLock::new(|| { let mut int_to_oid_table = IntegerToOidTable::new(); for data in ATTRIBUTE_DATA { @@ -73,7 +74,7 @@ static ATTRIBUTES_TABLES: Lazy = Lazy::new(|| { }); /// Static reference to the `AttributeData` lookup table. -pub(crate) static ATTRIBUTES_LOOKUP: &Lazy = &ATTRIBUTES_TABLES; +pub(crate) static ATTRIBUTES_LOOKUP: &LazyLock = &ATTRIBUTES_TABLES; /// Get the OID from the int value. pub(crate) fn get_oid_from_int(i: i16) -> Result, Error> { diff --git a/rust/c509-certificate/src/c509.rs b/rust/c509-certificate/src/c509.rs index 72c3bc90368..4018740e240 100644 --- a/rust/c509-certificate/src/c509.rs +++ b/rust/c509-certificate/src/c509.rs @@ -51,7 +51,7 @@ impl Encode<()> for C509 { match self.issuer_signature_value { Some(ref value) => encode_bytes(e, "C509 Issuer Signature value", value)?, None => encode_null(e, "C509 Issuer Signature value")?, - }; + } Ok(()) } } diff --git a/rust/c509-certificate/src/extensions/extension/data.rs b/rust/c509-certificate/src/extensions/extension/data.rs index 9edc3a94d6f..36a409938e7 100644 --- a/rust/c509-certificate/src/extensions/extension/data.rs +++ b/rust/c509-certificate/src/extensions/extension/data.rs @@ -4,11 +4,10 @@ // cspell: words Evt -use std::collections::HashMap; +use std::{collections::HashMap, sync::LazyLock}; use anyhow::Error; use asn1_rs::{oid, Oid}; -use once_cell::sync::Lazy; use super::ExtensionValueType; use crate::tables::IntegerToOidTable; @@ -96,7 +95,7 @@ impl ExtensionData { } /// Define static lookup for extensions table -static EXTENSIONS_TABLES: Lazy = Lazy::new(|| { +static EXTENSIONS_TABLES: LazyLock = LazyLock::new(|| { let mut int_to_oid_table = IntegerToOidTable::new(); let mut int_to_type_table = HashMap::::new(); @@ -112,7 +111,7 @@ static EXTENSIONS_TABLES: Lazy = Lazy::new(|| { }); /// Static reference to the `ExtensionData` lookup table. -pub(crate) static EXTENSIONS_LOOKUP: &Lazy = &EXTENSIONS_TABLES; +pub(crate) static EXTENSIONS_LOOKUP: &LazyLock = &EXTENSIONS_TABLES; /// Get the OID from the int value. pub(crate) fn get_oid_from_int(i: i16) -> Result, Error> { diff --git a/rust/c509-certificate/src/general_names/data.rs b/rust/c509-certificate/src/general_names/data.rs index 993d031ecf2..0099a381839 100644 --- a/rust/c509-certificate/src/general_names/data.rs +++ b/rust/c509-certificate/src/general_names/data.rs @@ -4,11 +4,10 @@ // cspell: words Gntr Gnvt -use std::collections::HashMap; +use std::{collections::HashMap, sync::LazyLock}; use anyhow::Error; use bimap::BiMap; -use once_cell::sync::Lazy; use super::general_name::{GeneralNameTypeRegistry, GeneralNameValueType}; use crate::tables::{IntTable, TableTrait}; @@ -81,7 +80,7 @@ impl IntegerToGNTable { } /// Define static lookup for general names table -static GENERAL_NAME_TABLES: Lazy = Lazy::new(|| { +static GENERAL_NAME_TABLES: LazyLock = LazyLock::new(|| { let mut int_to_name_table = IntegerToGNTable::new(); let mut int_to_type_table = HashMap::new(); diff --git a/rust/c509-certificate/src/general_names/general_name.rs b/rust/c509-certificate/src/general_names/general_name.rs index 9cce5cc59df..990bde6a82d 100644 --- a/rust/c509-certificate/src/general_names/general_name.rs +++ b/rust/c509-certificate/src/general_names/general_name.rs @@ -181,7 +181,7 @@ impl Encode<()> for GeneralNameValue { "Cannot encode unsupported GeneralName value", )) }, - }; + } Ok(()) } } diff --git a/rust/c509-certificate/src/issuer_sig_algo/data.rs b/rust/c509-certificate/src/issuer_sig_algo/data.rs index c052c7e438b..52afd8f3015 100644 --- a/rust/c509-certificate/src/issuer_sig_algo/data.rs +++ b/rust/c509-certificate/src/issuer_sig_algo/data.rs @@ -4,9 +4,10 @@ // cspell: words RSASSA XMSS +use std::sync::LazyLock; + use anyhow::Error; use asn1_rs::{oid, Oid}; -use once_cell::sync::Lazy; use crate::tables::IntegerToOidTable; @@ -56,7 +57,7 @@ impl IssuerSigAlgoData { } /// Define static lookup for issuer signature algorithm table -static ISSUER_SIG_ALGO_TABLE: Lazy = Lazy::new(|| { +static ISSUER_SIG_ALGO_TABLE: LazyLock = LazyLock::new(|| { let mut int_to_oid_table = IntegerToOidTable::new(); for data in SIG_ALGO_DATA { @@ -67,7 +68,7 @@ static ISSUER_SIG_ALGO_TABLE: Lazy = Lazy::new(|| { }); /// Static reference to the `IssuerSigAlgoData` lookup table. -pub(crate) static ISSUER_SIG_ALGO_LOOKUP: &Lazy = &ISSUER_SIG_ALGO_TABLE; +pub(crate) static ISSUER_SIG_ALGO_LOOKUP: &LazyLock = &ISSUER_SIG_ALGO_TABLE; /// Get the OID from the int value. pub(crate) fn get_oid_from_int(i: i16) -> Result, Error> { diff --git a/rust/c509-certificate/src/subject_pub_key_algo/data.rs b/rust/c509-certificate/src/subject_pub_key_algo/data.rs index 0a29de39f48..a494a6a5e2e 100644 --- a/rust/c509-certificate/src/subject_pub_key_algo/data.rs +++ b/rust/c509-certificate/src/subject_pub_key_algo/data.rs @@ -4,9 +4,10 @@ // cspell: words Weierstraß secp XMSS brainpool +use std::sync::LazyLock; + use anyhow::Error; use asn1_rs::{oid, Oid}; -use once_cell::sync::Lazy; use crate::tables::IntegerToOidTable; @@ -48,7 +49,7 @@ impl SubjectPubKeyAlgoData { } /// Define static lookup for subject publickey table -static SUBJECT_PUB_KEY_ALGO_TABLE: Lazy = Lazy::new(|| { +static SUBJECT_PUB_KEY_ALGO_TABLE: LazyLock = LazyLock::new(|| { let mut int_to_oid_table = IntegerToOidTable::new(); for data in PUB_KEY_ALGO_DATA { @@ -59,7 +60,7 @@ static SUBJECT_PUB_KEY_ALGO_TABLE: Lazy = Lazy::new(|| { }); /// Static reference to the `SubjectPubKeyAlgoData` lookup table. -pub(crate) static SUBJECT_PUB_KEY_ALGO_LOOKUP: &Lazy = +pub(crate) static SUBJECT_PUB_KEY_ALGO_LOOKUP: &LazyLock = &SUBJECT_PUB_KEY_ALGO_TABLE; /// Get the OID from the int value. diff --git a/rust/cardano-blockchain-types/src/auxdata/aux_data.rs b/rust/cardano-blockchain-types/src/auxdata/aux_data.rs index a5b79fefbdc..55182e838af 100644 --- a/rust/cardano-blockchain-types/src/auxdata/aux_data.rs +++ b/rust/cardano-blockchain-types/src/auxdata/aux_data.rs @@ -78,7 +78,7 @@ impl TransactionAuxData { "Error decoding Transaction Aux Data: {error}." ))); }, - }; + } let metadata = Metadata::decode(d, &mut ())?; let script_array = ScriptArray::decode(d, &mut ScriptType::Native)?; diff --git a/rust/cardano-blockchain-types/src/auxdata/block.rs b/rust/cardano-blockchain-types/src/auxdata/block.rs index 2bb98df3d97..e3df6a2cc2e 100644 --- a/rust/cardano-blockchain-types/src/auxdata/block.rs +++ b/rust/cardano-blockchain-types/src/auxdata/block.rs @@ -60,7 +60,7 @@ impl TryFrom<&MultiEraBlock<'_>> for BlockAuxData { } } else { bail!("Undecodable metadata, unknown Era"); - }; + } } Ok(Self(Arc::new(aux_data.into_read_only()))) diff --git a/rust/cardano-blockchain-types/src/metadata/cip36/validation.rs b/rust/cardano-blockchain-types/src/metadata/cip36/validation.rs index 601d17e2239..9a906caf20c 100644 --- a/rust/cardano-blockchain-types/src/metadata/cip36/validation.rs +++ b/rust/cardano-blockchain-types/src/metadata/cip36/validation.rs @@ -59,7 +59,7 @@ impl Cip36 { "Validate CIP36 Signature", ); self.is_valid_signature = false; - }; + } } /// Validate the payment address network against the given network. diff --git a/rust/cardano-blockchain-types/src/txn_witness.rs b/rust/cardano-blockchain-types/src/txn_witness.rs index 58341b54a6d..be369f1dbc2 100644 --- a/rust/cardano-blockchain-types/src/txn_witness.rs +++ b/rust/cardano-blockchain-types/src/txn_witness.rs @@ -47,7 +47,7 @@ impl TxnWitness { map.insert(vkey_hash, (vkey, new_set)); } } - }; + } Ok(()) } @@ -71,7 +71,7 @@ impl TxnWitness { _ => { return Err(anyhow::anyhow!("Unsupported transaction Era")); }, - }; + } } Ok(Self(map)) } diff --git a/rust/cardano-chain-follower/src/chain_sync.rs b/rust/cardano-chain-follower/src/chain_sync.rs index b00ae03d378..916fe9638ba 100644 --- a/rust/cardano-chain-follower/src/chain_sync.rs +++ b/rust/cardano-chain-follower/src/chain_sync.rs @@ -75,10 +75,7 @@ async fn retry_connect( retries = retries.saturating_sub(1); if retries == 0 { return Err(pallas::network::facades::Error::ConnectFailure( - tokio::io::Error::new( - tokio::io::ErrorKind::Other, - format!("failed to connect to {addr} : {error}"), - ), + tokio::io::Error::other(format!("failed to connect to {addr} : {error}")), )); } debug!("retrying {retries} connect to {addr} : {error:?}"); diff --git a/rust/cardano-chain-follower/src/chain_sync_live_chains.rs b/rust/cardano-chain-follower/src/chain_sync_live_chains.rs index fb0743d6af7..5de6a000d4e 100644 --- a/rust/cardano-chain-follower/src/chain_sync_live_chains.rs +++ b/rust/cardano-chain-follower/src/chain_sync_live_chains.rs @@ -376,7 +376,7 @@ impl ProtectedLiveChainBlockList { }; if entry.value().point() == previous_point { break; - }; + } previous_point = entry.value().point(); intersect_points.push(previous_point.clone().into()); slot_age *= 2; diff --git a/rust/cardano-chain-follower/src/mithril_snapshot_config.rs b/rust/cardano-chain-follower/src/mithril_snapshot_config.rs index 70d5394173c..a198ea9241a 100644 --- a/rust/cardano-chain-follower/src/mithril_snapshot_config.rs +++ b/rust/cardano-chain-follower/src/mithril_snapshot_config.rs @@ -210,7 +210,7 @@ impl MithrilSnapshotConfig { ); cleanup_tasks.push(fs::remove_dir_all(entry.path())); } - }; + } } }, } diff --git a/rust/cardano-chain-follower/src/mithril_snapshot_iterator.rs b/rust/cardano-chain-follower/src/mithril_snapshot_iterator.rs index b3b913e7e39..db1d0211859 100644 --- a/rust/cardano-chain-follower/src/mithril_snapshot_iterator.rs +++ b/rust/cardano-chain-follower/src/mithril_snapshot_iterator.rs @@ -116,7 +116,7 @@ impl MithrilSnapshotIterator { return None; }, None => break, - }; + } } debug!("Best Found for {from}. {this:?} > {previous:?}"); diff --git a/rust/cardano-chain-follower/src/mithril_snapshot_sync.rs b/rust/cardano-chain-follower/src/mithril_snapshot_sync.rs index b5b6863f9ab..f561606ebb9 100644 --- a/rust/cardano-chain-follower/src/mithril_snapshot_sync.rs +++ b/rust/cardano-chain-follower/src/mithril_snapshot_sync.rs @@ -473,6 +473,7 @@ async fn recover_existing_snapshot( } /// Status of checking if we have a new snapshot to get or not. +#[allow(clippy::large_enum_variant)] enum SnapshotStatus { /// No update, sleep for this long before checking again Sleep(Duration), diff --git a/rust/cardano-chain-follower/src/mithril_turbo_downloader.rs b/rust/cardano-chain-follower/src/mithril_turbo_downloader.rs index 1b448be8b8f..585e0b25929 100644 --- a/rust/cardano-chain-follower/src/mithril_turbo_downloader.rs +++ b/rust/cardano-chain-follower/src/mithril_turbo_downloader.rs @@ -411,7 +411,7 @@ impl FileDownloader for MithrilTurboDownloader { } impl MithrilTurboDownloader { - /// Set up the download. + /// Set up the download.\ /// Called `probe` as this used to exist in an earlier trait which was removed. async fn probe(&self, location: &str) -> MithrilResult<()> { debug!("Probe Snapshot location='{location}'."); diff --git a/rust/cardano-chain-follower/src/snapshot_id.rs b/rust/cardano-chain-follower/src/snapshot_id.rs index 876a39c9118..66cf3ee2591 100644 --- a/rust/cardano-chain-follower/src/snapshot_id.rs +++ b/rust/cardano-chain-follower/src/snapshot_id.rs @@ -25,20 +25,15 @@ pub(crate) struct SnapshotId { impl SnapshotId { /// See if we can Parse the path into an immutable file number. pub(crate) fn parse_path(path: &Path) -> Option { - // Path must actually exist, and be a directory. if !path.is_dir() { - None - } else if let Ok(numeric_name) = path - .file_name() + return None; + } + + path.file_name() .unwrap_or_default() .to_string_lossy() .parse::() - { - Some(numeric_name) - } else { - // If we couldn't parse the file name as a number, then it's not an immutable file. - None - } + .ok() } /// Try and create a new `SnapshotID` from a given path. diff --git a/rust/cardano-chain-follower/src/turbo_downloader/mod.rs b/rust/cardano-chain-follower/src/turbo_downloader/mod.rs index f32155942ac..ffb2bc4bc9f 100644 --- a/rust/cardano-chain-follower/src/turbo_downloader/mod.rs +++ b/rust/cardano-chain-follower/src/turbo_downloader/mod.rs @@ -106,14 +106,11 @@ impl BalancingResolver { addresses }; let worker_addresses = worker.checked_rem(addresses.len()).ok_or_else(|| { - std::io::Error::new( - std::io::ErrorKind::Other, - format!( - "Unexpected index: worker = {}, addresses len = {}", - worker, - addresses.len() - ), - ) + std::io::Error::other(format!( + "Unexpected index: worker = {}, addresses len = {}", + worker, + addresses.len() + )) })?; // Safe because we bound the index with the length of `addresses`. #[allow(clippy::indexing_slicing)] @@ -191,10 +188,7 @@ impl DlConfig { /// Resolve DNS addresses using Hickory Resolver fn resolve(url: &str, worker: usize) -> std::io::Result> { let Some(resolver) = RESOLVER.get() else { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "Resolver not initialized.", - )); + return Err(std::io::Error::other("Resolver not initialized.")); }; resolver.resolve(url, worker) @@ -529,7 +523,7 @@ impl ParallelDownloadProcessor { }) { error!("Error sending chunk: {:?}, error: {:?}", next_chunk, error); break; - }; + } // debug!("Worker {worker_id} DL chunk queued {next_chunk}"); } debug!("Worker {worker_id} ended"); @@ -596,7 +590,7 @@ impl ParallelDownloadProcessor { .0 .left_over_bytes .lock() - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("{e:?}")))?; + .map_err(|e| std::io::Error::other(format!("{e:?}")))?; let (left_over_bytes, offset) = if let Some((left_over_bytes, offset)) = left_over_buffer.take() { @@ -608,25 +602,23 @@ impl ParallelDownloadProcessor { // Wait here until we actually have the next chunk in the reorder queue. while !self.0.reorder_queue.contains_key(&next_chunk) { if let Err(error) = self.0.new_chunk_queue_rx.recv() { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Next Chunk Queue Error: {error:?}"), - )); + return Err(std::io::Error::other(format!( + "Next Chunk Queue Error: {error:?}" + ))); } } let Some((_, chunk)) = self.0.reorder_queue.remove(&next_chunk) else { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Expected Chunk {next_chunk} Didn't get any"), - )); + return Err(std::io::Error::other(format!( + "Expected Chunk {next_chunk} Didn't get any" + ))); }; if chunk.chunk_num != next_chunk { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Expected Chunk {next_chunk} Got {}", chunk.chunk_num), - )); + return Err(std::io::Error::other(format!( + "Expected Chunk {next_chunk} Got {}", + chunk.chunk_num + ))); } let Some(ref block) = chunk.chunk else { return Ok(0); // EOF @@ -640,10 +632,10 @@ impl ParallelDownloadProcessor { // Send more work to the worker that just finished a work order. // Or Stop the worker if there is no more work they can do. if let Err(error) = self.send_work_order(chunk.worker, next_work_order) { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!("Failed to send work order to {} : {error:?}", chunk.worker), - )); + return Err(std::io::Error::other(format!( + "Failed to send work order to {} : {error:?}", + chunk.worker + ))); } // If this was the last chunk, we can stop all the workers and cleanup. @@ -657,28 +649,20 @@ impl ParallelDownloadProcessor { // Send whats leftover or new. let bytes_left = left_over_bytes.len().checked_sub(offset).ok_or_else(|| { - std::io::Error::new( - std::io::ErrorKind::Other, - format!( - "Invalid left over bytes value: {}, offset = {}", - left_over_bytes.len(), - offset - ), - ) + std::io::Error::other(format!( + "Invalid left over bytes value: {}, offset = {}", + left_over_bytes.len(), + offset + )) })?; let bytes_to_copy = bytes_left.min(buf.len()); let sub_buf = offset .checked_add(bytes_to_copy) .and_then(|upper_bound| left_over_bytes.get(offset..upper_bound)) - .ok_or_else(|| { - std::io::Error::new(std::io::ErrorKind::Other, "Slicing Sub Buffer failed") - })?; + .ok_or_else(|| std::io::Error::other("Slicing Sub Buffer failed"))?; if let Err(error) = memx::memcpy(buf, sub_buf) { error!(error=?error, "memx::memcpy failed"); - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "memx::memcpy failed", - )); + return Err(std::io::Error::other("memx::memcpy failed")); } // Save whats leftover back inside the mutex, if there is anything. @@ -761,7 +745,7 @@ fn get_content_length(url: &str) -> Result { } } else { bail!("Server doesn't support HTTP range requests (missing ACCEPT_RANGES header)"); - }; + } let content_length = if let Some(content_length) = response.header(CONTENT_LENGTH.as_str()) { let content_length: usize = content_length diff --git a/rust/catalyst-types/Cargo.toml b/rust/catalyst-types/Cargo.toml index 6107421e10f..0b550d8ec68 100644 --- a/rust/catalyst-types/Cargo.toml +++ b/rust/catalyst-types/Cargo.toml @@ -31,7 +31,6 @@ base64-url = "3.0.0" uuid = { version = "1.12.0", features = ["v4", "v7", "serde"] } chrono = "0.4.39" fmmap = { version = "0.4.0", features = ["sync", "tokio"] } -once_cell = "1.20.2" tracing = "0.1.41" strum = { version = "0.27.1", features = ["derive"] } diff --git a/rust/catalyst-types/src/catalyst_id/mod.rs b/rust/catalyst-types/src/catalyst_id/mod.rs index bf9a11038ec..8557e34ef6c 100644 --- a/rust/catalyst-types/src/catalyst_id/mod.rs +++ b/rust/catalyst-types/src/catalyst_id/mod.rs @@ -520,7 +520,7 @@ impl CatalystId { impl FromStr for CatalystId { type Err = errors::CatalystIdError; - /// This will parse a URI or a RAW ID. + /// This will parse a URI or a RAW ID.\ /// The only difference between them is a URI has the scheme, a raw ID does not. fn from_str(s: &str) -> Result { // Did we serialize an ID? @@ -588,7 +588,7 @@ impl FromStr for CatalystId { // Less than 3 handled by errors below (4 because of leading `/` in path). if path.len() > 4 { return Err(errors::CatalystIdError::InvalidPath); - }; + } // Decode and validate the Role0 Public key from the path let encoded_role0_key = path @@ -770,7 +770,7 @@ mod tests { assert_eq!(uri_id.as_short_id(), short_id); } - #[ignore] + #[ignore = "Test to be fixed and re-enabled"] #[test] fn gen_pk() { let mut csprng = OsRng; diff --git a/rust/catalyst-types/src/mmap_file.rs b/rust/catalyst-types/src/mmap_file.rs index 0595853e6c8..044b1ff996d 100644 --- a/rust/catalyst-types/src/mmap_file.rs +++ b/rust/catalyst-types/src/mmap_file.rs @@ -2,11 +2,10 @@ use std::{ path::Path, - sync::{Arc, RwLock}, + sync::{Arc, LazyLock, RwLock}, }; use fmmap::{MmapFile, MmapFileExt}; -use once_cell::sync::Lazy; use serde::Serialize; use tracing::error; @@ -19,8 +18,8 @@ pub struct MemoryMapFile { } /// Global statistic for memory-mapped files. -static MEMMAP_FILE_STATS: Lazy>> = - Lazy::new(|| Arc::new(RwLock::new(MemMapFileStat::default()))); +static MEMMAP_FILE_STATS: LazyLock>> = + LazyLock::new(|| Arc::new(RwLock::new(MemMapFileStat::default()))); /// Memory-mapped file statistic. #[derive(Debug, Default, Clone, Serialize)] diff --git a/rust/deny.toml b/rust/deny.toml index 1ba4478ceed..d69e5b55657 100644 --- a/rust/deny.toml +++ b/rust/deny.toml @@ -58,6 +58,8 @@ allow-git = [ "https://github.com/txpipe/kes", "https://github.com/txpipe/curve25519-dalek", "https://github.com/input-output-hk/mithril", + # Maintained fork of an archived crates-io version. + "https://github.com/dariusc93/rust-ipfs", ] [licenses] @@ -81,6 +83,7 @@ allow = [ "Zlib", "MIT-0", "CDLA-Permissive-2.0", + "OpenSSL", ] exceptions = [ #{ allow = ["Zlib"], crate = "tinyvec" }, @@ -94,15 +97,16 @@ expression = "Apache-2.0 WITH LLVM-exception" license-files = [{ path = "../../../LICENSE", hash = 0x001c7e6c }] [[licenses.clarify]] -crate = "hdf5-src" +crate = "hdf5-metno-src" expression = "MIT" -license-files = [{ path = "../LICENSE-MIT", hash = 0x001c7e6c }] +license-files = [{ path = "ext/hdf5/COPYING", hash = 0xf13e3591 }] [[licenses.clarify]] crate = "ring" expression = "MIT" license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] + # SPDX considers OpenSSL to encompass both the OpenSSL and SSLeay licenses # https://spdx.org/licenses/OpenSSL.html # ISC - Both BoringSSL and ring use this for their new files diff --git a/rust/hermes-ipfs/Cargo.toml b/rust/hermes-ipfs/Cargo.toml index 572ab714c99..dca8c10dc6f 100644 --- a/rust/hermes-ipfs/Cargo.toml +++ b/rust/hermes-ipfs/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "hermes-ipfs" -version = "0.0.3" +version = "0.0.4" edition.workspace = true license.workspace = true authors.workspace = true @@ -16,8 +16,9 @@ workspace = true anyhow = "1.0.95" derive_more = {version = "1.0.0", features = ["from","into","display"] } ipld-core = { version = "0.4.1", features = ["serde"]} -rust-ipfs = "0.14.1" -tokio = "1.42.0" +# A fork of crates-io version with updated dependencies (`libp2p` and `ring` in particular). +rust-ipfs = { version = "0.15.0", git = "https://github.com/dariusc93/rust-ipfs" } +tokio = "1.46.0" # Its a transitive dependency of the "rust-ipfs" crate, # could be removed after bumped to the rustc compiler 1.87 yamux = "=0.13.5" diff --git a/rust/hermes-ipfs/examples/add-file-with-pinning.rs b/rust/hermes-ipfs/examples/add-file-with-pinning.rs index 53a924b3e5b..517502326d0 100644 --- a/rust/hermes-ipfs/examples/add-file-with-pinning.rs +++ b/rust/hermes-ipfs/examples/add-file-with-pinning.rs @@ -41,7 +41,7 @@ async fn main() -> anyhow::Result<()> { } else { println!("AN ERROR OCCURRED: {e}"); } - }; + } println!("* Removing pin."); hermes_ipfs.remove_pin(cid).await?; print_cid_pinned(&hermes_ipfs, cid).await?; @@ -53,7 +53,7 @@ async fn main() -> anyhow::Result<()> { } else { println!("AN ERROR OCCURRED: {e}"); } - }; + } print_cid_pinned(&hermes_ipfs, cid).await?; println!("***************************************"); println!(""); diff --git a/rust/hermes-ipfs/src/lib.rs b/rust/hermes-ipfs/src/lib.rs index 30f1de11bd0..9bfbd78f8b2 100644 --- a/rust/hermes-ipfs/src/lib.rs +++ b/rust/hermes-ipfs/src/lib.rs @@ -17,6 +17,8 @@ pub use rust_ipfs::libp2p::futures::{pin_mut, stream::BoxStream, FutureExt, Stre pub use rust_ipfs::p2p::PeerInfo; /// Enum for specifying paths in IPFS. pub use rust_ipfs::path::IpfsPath; +/// Storage type for IPFS node. +pub use rust_ipfs::repo::StorageTypes; /// Server, Client, or Auto mode pub use rust_ipfs::DhtMode; /// Server, Client, or Auto mode @@ -25,8 +27,6 @@ pub use rust_ipfs::Ipfs; pub use rust_ipfs::Multiaddr; /// Peer ID type. pub use rust_ipfs::PeerId; -/// Storage type for IPFS node. -pub use rust_ipfs::StorageType; /// Stream for `PubSub` Topic Subscriptions. pub use rust_ipfs::SubscriptionStream; /// Builder type for IPFS Node configuration. @@ -71,7 +71,7 @@ impl IpfsBuilder { pub fn set_disk_storage>(self, storage_path: T) -> Self { Self( self.0 - .set_storage_type(rust_ipfs::StorageType::Disk(storage_path.into())), + .set_repo(&rust_ipfs::repo::Repo::new_fs(storage_path.into())), ) } diff --git a/rust/immutable-ledger/src/serialize.rs b/rust/immutable-ledger/src/serialize.rs index 53fb9cb9068..c385fde9cd1 100644 --- a/rust/immutable-ledger/src/serialize.rs +++ b/rust/immutable-ledger/src/serialize.rs @@ -198,7 +198,7 @@ impl Block { self.block_header, previous_block.block_header )); - }; + } // height MUST be incremented by 1 from the previous block height value (except for // genesis and final block). Genesis block MUST have 0 value. Final block MUST hash be diff --git a/rust/rbac-registration/src/cardano/cip509/cip509.rs b/rust/rbac-registration/src/cardano/cip509/cip509.rs index 570f565172c..a7d497e1a8f 100644 --- a/rust/rbac-registration/src/cardano/cip509/cip509.rs +++ b/rust/rbac-registration/src/cardano/cip509/cip509.rs @@ -169,7 +169,7 @@ impl Cip509 { if let Some(txn_inputs_hash) = &cip509.txn_inputs_hash { validate_txn_inputs_hash(txn_inputs_hash, txn, &cip509.report); - }; + } validate_aux( raw_aux_data, txn.transaction_body.auxiliary_data_hash.as_ref(), @@ -412,7 +412,7 @@ impl Decode<'_, DecodeContext<'_, '_>> for Cip509 { ); break; }, - }; + } } } diff --git a/rust/rbac-registration/src/cardano/cip509/utils/cip134_uri_set.rs b/rust/rbac-registration/src/cardano/cip509/utils/cip134_uri_set.rs index bb4ac8a52f6..69ed737db7e 100644 --- a/rust/rbac-registration/src/cardano/cip509/utils/cip134_uri_set.rs +++ b/rust/rbac-registration/src/cardano/cip509/utils/cip134_uri_set.rs @@ -199,9 +199,8 @@ fn extract_x509_uris(certificates: &[X509DerCert], report: &ProblemReport) -> Ur // X.509 doesn't restrict the "alternative name" extension to be utf8 only, so // we cannot treat this as error. debug!("Ignoring invalid CIP-0134 address: {e:?}"); - continue; }, - }; + } } if !uris.is_empty() { @@ -264,9 +263,8 @@ fn extract_c509_uris(certificates: &[C509Cert], report: &ProblemReport) -> UrisM Ok(u) => uris.push(u), Err(e) => { debug!("Ignoring invalid CIP-0134 address: {e:?}"); - continue; }, - }; + } } if !uris.is_empty() { diff --git a/rust/rbac-registration/src/cardano/cip509/validation.rs b/rust/rbac-registration/src/cardano/cip509/validation.rs index 2a46068db47..9399927039e 100644 --- a/rust/rbac-registration/src/cardano/cip509/validation.rs +++ b/rust/rbac-registration/src/cardano/cip509/validation.rs @@ -59,7 +59,7 @@ pub fn validate_txn_inputs_hash( context, ); return; - }; + } for input in inputs { if let Err(e) = input.encode(&mut e, &mut ()) { report.other( diff --git a/rust/rust-toolchain.toml b/rust/rust-toolchain.toml index 8c8ca6d417b..17b9824d906 100644 --- a/rust/rust-toolchain.toml +++ b/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.85" +channel = "1.88" profile = "default" \ No newline at end of file diff --git a/rust/signed_doc/bins/mk_signed_doc.rs b/rust/signed_doc/bins/mk_signed_doc.rs index a22b1ddf91f..6912a9397e4 100644 --- a/rust/signed_doc/bins/mk_signed_doc.rs +++ b/rust/signed_doc/bins/mk_signed_doc.rs @@ -141,7 +141,7 @@ where T: for<'de> serde::Deserialize<'de> { fn write_bytes_to_file(bytes: &[u8], output: &PathBuf) -> anyhow::Result<()> { File::create(output)? .write_all(bytes) - .context(format!("Failed to write to file {output:?}")) + .context(format!("Failed to write to file {}", output.display())) } fn load_secret_key(sk_hex: &str) -> anyhow::Result { diff --git a/rust/signed_doc/src/metadata/extra_fields.rs b/rust/signed_doc/src/metadata/extra_fields.rs index 5decc4a7849..d002b422102 100644 --- a/rust/signed_doc/src/metadata/extra_fields.rs +++ b/rust/signed_doc/src/metadata/extra_fields.rs @@ -218,7 +218,7 @@ impl ExtraFields { "Expected a CBOR Array", &format!("{COSE_DECODING_CONTEXT}, converting collaborators to Array",), ); - }; + } } extra