Skip to content
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
1 change: 1 addition & 0 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ mdns
MEMMAP
memx
Metadatum
metno
mgrybyk
mimalloc
minicbor
Expand Down
1 change: 0 additions & 1 deletion integration_tests/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion rust/Earthfile
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
1 change: 0 additions & 1 deletion rust/c509-certificate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions rust/c509-certificate/examples/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(())
}

Expand Down Expand Up @@ -328,7 +328,7 @@ fn decode(file: &PathBuf, output: Option<PathBuf>) -> 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(())
Expand Down
2 changes: 1 addition & 1 deletion rust/c509-certificate/src/attributes/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}
Expand Down
7 changes: 4 additions & 3 deletions rust/c509-certificate/src/attributes/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -62,7 +63,7 @@ impl AttributeData {
}

/// Define static lookup for attributes table
static ATTRIBUTES_TABLES: Lazy<AttributeData> = Lazy::new(|| {
static ATTRIBUTES_TABLES: LazyLock<AttributeData> = LazyLock::new(|| {
let mut int_to_oid_table = IntegerToOidTable::new();

for data in ATTRIBUTE_DATA {
Expand All @@ -73,7 +74,7 @@ static ATTRIBUTES_TABLES: Lazy<AttributeData> = Lazy::new(|| {
});

/// Static reference to the `AttributeData` lookup table.
pub(crate) static ATTRIBUTES_LOOKUP: &Lazy<AttributeData> = &ATTRIBUTES_TABLES;
pub(crate) static ATTRIBUTES_LOOKUP: &LazyLock<AttributeData> = &ATTRIBUTES_TABLES;

/// Get the OID from the int value.
pub(crate) fn get_oid_from_int(i: i16) -> Result<Oid<'static>, Error> {
Expand Down
2 changes: 1 addition & 1 deletion rust/c509-certificate/src/c509.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}
Expand Down
7 changes: 3 additions & 4 deletions rust/c509-certificate/src/extensions/extension/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -96,7 +95,7 @@ impl ExtensionData {
}

/// Define static lookup for extensions table
static EXTENSIONS_TABLES: Lazy<ExtensionData> = Lazy::new(|| {
static EXTENSIONS_TABLES: LazyLock<ExtensionData> = LazyLock::new(|| {
let mut int_to_oid_table = IntegerToOidTable::new();
let mut int_to_type_table = HashMap::<i16, ExtensionValueType>::new();

Expand All @@ -112,7 +111,7 @@ static EXTENSIONS_TABLES: Lazy<ExtensionData> = Lazy::new(|| {
});

/// Static reference to the `ExtensionData` lookup table.
pub(crate) static EXTENSIONS_LOOKUP: &Lazy<ExtensionData> = &EXTENSIONS_TABLES;
pub(crate) static EXTENSIONS_LOOKUP: &LazyLock<ExtensionData> = &EXTENSIONS_TABLES;

/// Get the OID from the int value.
pub(crate) fn get_oid_from_int(i: i16) -> Result<Oid<'static>, Error> {
Expand Down
5 changes: 2 additions & 3 deletions rust/c509-certificate/src/general_names/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -81,7 +80,7 @@ impl IntegerToGNTable {
}

/// Define static lookup for general names table
static GENERAL_NAME_TABLES: Lazy<GeneralNameData> = Lazy::new(|| {
static GENERAL_NAME_TABLES: LazyLock<GeneralNameData> = LazyLock::new(|| {
let mut int_to_name_table = IntegerToGNTable::new();
let mut int_to_type_table = HashMap::new();

Expand Down
2 changes: 1 addition & 1 deletion rust/c509-certificate/src/general_names/general_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Encode<()> for GeneralNameValue {
"Cannot encode unsupported GeneralName value",
))
},
};
}
Ok(())
}
}
Expand Down
7 changes: 4 additions & 3 deletions rust/c509-certificate/src/issuer_sig_algo/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -56,7 +57,7 @@ impl IssuerSigAlgoData {
}

/// Define static lookup for issuer signature algorithm table
static ISSUER_SIG_ALGO_TABLE: Lazy<IssuerSigAlgoData> = Lazy::new(|| {
static ISSUER_SIG_ALGO_TABLE: LazyLock<IssuerSigAlgoData> = LazyLock::new(|| {
let mut int_to_oid_table = IntegerToOidTable::new();

for data in SIG_ALGO_DATA {
Expand All @@ -67,7 +68,7 @@ static ISSUER_SIG_ALGO_TABLE: Lazy<IssuerSigAlgoData> = Lazy::new(|| {
});

/// Static reference to the `IssuerSigAlgoData` lookup table.
pub(crate) static ISSUER_SIG_ALGO_LOOKUP: &Lazy<IssuerSigAlgoData> = &ISSUER_SIG_ALGO_TABLE;
pub(crate) static ISSUER_SIG_ALGO_LOOKUP: &LazyLock<IssuerSigAlgoData> = &ISSUER_SIG_ALGO_TABLE;

/// Get the OID from the int value.
pub(crate) fn get_oid_from_int(i: i16) -> Result<Oid<'static>, Error> {
Expand Down
7 changes: 4 additions & 3 deletions rust/c509-certificate/src/subject_pub_key_algo/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -48,7 +49,7 @@ impl SubjectPubKeyAlgoData {
}

/// Define static lookup for subject publickey table
static SUBJECT_PUB_KEY_ALGO_TABLE: Lazy<SubjectPubKeyAlgoData> = Lazy::new(|| {
static SUBJECT_PUB_KEY_ALGO_TABLE: LazyLock<SubjectPubKeyAlgoData> = LazyLock::new(|| {
let mut int_to_oid_table = IntegerToOidTable::new();

for data in PUB_KEY_ALGO_DATA {
Expand All @@ -59,7 +60,7 @@ static SUBJECT_PUB_KEY_ALGO_TABLE: Lazy<SubjectPubKeyAlgoData> = Lazy::new(|| {
});

/// Static reference to the `SubjectPubKeyAlgoData` lookup table.
pub(crate) static SUBJECT_PUB_KEY_ALGO_LOOKUP: &Lazy<SubjectPubKeyAlgoData> =
pub(crate) static SUBJECT_PUB_KEY_ALGO_LOOKUP: &LazyLock<SubjectPubKeyAlgoData> =
&SUBJECT_PUB_KEY_ALGO_TABLE;

/// Get the OID from the int value.
Expand Down
2 changes: 1 addition & 1 deletion rust/cardano-blockchain-types/src/auxdata/aux_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
2 changes: 1 addition & 1 deletion rust/cardano-blockchain-types/src/auxdata/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl TryFrom<&MultiEraBlock<'_>> for BlockAuxData {
}
} else {
bail!("Undecodable metadata, unknown Era");
};
}
}

Ok(Self(Arc::new(aux_data.into_read_only())))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Cip36 {
"Validate CIP36 Signature",
);
self.is_valid_signature = false;
};
}
}

/// Validate the payment address network against the given network.
Expand Down
4 changes: 2 additions & 2 deletions rust/cardano-blockchain-types/src/txn_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl TxnWitness {
map.insert(vkey_hash, (vkey, new_set));
}
}
};
}
Ok(())
}

Expand All @@ -71,7 +71,7 @@ impl TxnWitness {
_ => {
return Err(anyhow::anyhow!("Unsupported transaction Era"));
},
};
}
}
Ok(Self(map))
}
Expand Down
5 changes: 1 addition & 4 deletions rust/cardano-chain-follower/src/chain_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}");
Expand Down
2 changes: 1 addition & 1 deletion rust/cardano-chain-follower/src/chain_sync_live_chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion rust/cardano-chain-follower/src/mithril_snapshot_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl MithrilSnapshotConfig {
);
cleanup_tasks.push(fs::remove_dir_all(entry.path()));
}
};
}
}
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl MithrilSnapshotIterator {
return None;
},
None => break,
};
}
}

debug!("Best Found for {from}. {this:?} > {previous:?}");
Expand Down
1 change: 1 addition & 0 deletions rust/cardano-chain-follower/src/mithril_snapshot_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}'.");
Expand Down
15 changes: 5 additions & 10 deletions rust/cardano-chain-follower/src/snapshot_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64> {
// 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::<u64>()
{
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.
Expand Down
Loading
Loading