diff --git a/rust/Cargo.toml b/rust/Cargo.toml index e48ccdcf2d..7d2b2a8a8c 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -resolver = "2" +resolver = "3" members = [ "c509-certificate", "cardano-blockchain-types", @@ -19,7 +19,7 @@ members = [ ] [workspace.package] -edition = "2021" +edition = "2024" authors = ["Steven Johnson "] homepage = "https://github.com/input-output-hk/catalyst-libs" repository = "https://github.com/input-output-hk/catalyst-libs" diff --git a/rust/Earthfile b/rust/Earthfile index 9ea482c726..03ae665eb7 100644 --- a/rust/Earthfile +++ b/rust/Earthfile @@ -1,6 +1,7 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.37 AS rust-ci +# TODO: FIXME: Use release instead of branch +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:2024-edition AS rust-ci COPY_SRC: FUNCTION diff --git a/rust/c509-certificate/Cargo.toml b/rust/c509-certificate/Cargo.toml index 4a4e70b1f1..bc78fd6d94 100644 --- a/rust/c509-certificate/Cargo.toml +++ b/rust/c509-certificate/Cargo.toml @@ -43,7 +43,7 @@ ignored = ["strum"] [dev-dependencies] clap = { version = "4.5.23", features = ["derive"] } serde_json = "1.0.134" -rand = "0.8.5" +rand = "0.9.0" chrono = "0.4.39" [[example]] diff --git a/rust/c509-certificate/examples/cli/main.rs b/rust/c509-certificate/examples/cli/main.rs index 185291dd63..4bd89a3808 100644 --- a/rust/c509-certificate/examples/cli/main.rs +++ b/rust/c509-certificate/examples/cli/main.rs @@ -6,7 +6,7 @@ use std::{ path::PathBuf, }; -use asn1_rs::{oid, Oid}; +use asn1_rs::{Oid, oid}; use c509_certificate::{ attributes::attribute::Attribute, big_uint::UnwrappedBigUint, @@ -131,7 +131,7 @@ struct C509Json { } /// Ed25519 oid and parameter - default algorithm. -const ED25519: (Oid, Option) = (oid!(1.3.101 .112), None); +const ED25519: (Oid, Option) = (oid!(1.3.101.112), None); /// Integer indicate that certificate is self-signed. /// 2 for Natively Signed C509 Certificate following X.509 v3 @@ -277,7 +277,7 @@ fn parse_or_default_date(date_option: Option, default: u64) -> Result) -> UnwrappedBigUint { - let random_number: u64 = rand::thread_rng().gen(); + let random_number: u64 = rand::rng().random(); serial_number.unwrap_or(UnwrappedBigUint::new(random_number)) } diff --git a/rust/c509-certificate/src/algorithm_identifier.rs b/rust/c509-certificate/src/algorithm_identifier.rs index c30d7d32bf..561d68876f 100644 --- a/rust/c509-certificate/src/algorithm_identifier.rs +++ b/rust/c509-certificate/src/algorithm_identifier.rs @@ -14,7 +14,7 @@ //! visit [C509 Certificate](https://datatracker.ietf.org/doc/draft-ietf-cose-cbor-encoded-cert/11/) use asn1_rs::Oid; -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Serialize}; use crate::{ diff --git a/rust/c509-certificate/src/attributes/attribute.rs b/rust/c509-certificate/src/attributes/attribute.rs index 5eb871fd9e..ef06e20d82 100644 --- a/rust/c509-certificate/src/attributes/attribute.rs +++ b/rust/c509-certificate/src/attributes/attribute.rs @@ -18,10 +18,10 @@ use std::str::FromStr; use asn1_rs::Oid; -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Deserializer, Serialize}; -use super::data::{get_oid_from_int, ATTRIBUTES_LOOKUP}; +use super::data::{ATTRIBUTES_LOOKUP, get_oid_from_int}; use crate::{ helper::{ decode::{decode_array_len, decode_datatype, decode_helper}, @@ -241,7 +241,7 @@ mod test_attribute { fn encode_decode_attribute_int() { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let mut attribute = Attribute::new(oid!(1.2.840 .113549 .1 .9 .1)); + let mut attribute = Attribute::new(oid!(1.2.840.113549.1.9.1)); attribute.add_value(AttributeValue::Text("example@example.com".to_string())); attribute .encode(&mut encoder, &mut ()) @@ -263,7 +263,7 @@ mod test_attribute { fn empty_attribute_value() { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let attribute = Attribute::new(oid!(1.2.840 .113549 .1 .9 .1)); + let attribute = Attribute::new(oid!(1.2.840.113549.1.9.1)); attribute .encode(&mut encoder, &mut ()) .expect_err("Failed to encode Attribute"); diff --git a/rust/c509-certificate/src/attributes/data.rs b/rust/c509-certificate/src/attributes/data.rs index 0ae826a345..ef0c6496eb 100644 --- a/rust/c509-certificate/src/attributes/data.rs +++ b/rust/c509-certificate/src/attributes/data.rs @@ -3,7 +3,7 @@ //! Section 9.3 C509 Attributes Registry for more information. use anyhow::Error; -use asn1_rs::{oid, Oid}; +use asn1_rs::{Oid, oid}; use once_cell::sync::Lazy; use crate::tables::IntegerToOidTable; diff --git a/rust/c509-certificate/src/attributes/mod.rs b/rust/c509-certificate/src/attributes/mod.rs index e608244c44..e140c4e0eb 100644 --- a/rust/c509-certificate/src/attributes/mod.rs +++ b/rust/c509-certificate/src/attributes/mod.rs @@ -14,7 +14,7 @@ //! visit [C509 Certificate](https://datatracker.ietf.org/doc/draft-ietf-cose-cbor-encoded-cert/11/) use attribute::Attribute; -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Serialize}; use crate::helper::{decode::decode_array_len, encode::encode_array_len}; @@ -105,7 +105,7 @@ mod test_attributes { fn encode_decode_attributes_int() { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let mut attr = Attribute::new(oid!(1.2.840 .113549 .1 .9 .1)); + let mut attr = Attribute::new(oid!(1.2.840.113549.1.9.1)); attr.add_value(AttributeValue::Text("example@example.com".to_string())); attr.add_value(AttributeValue::Text("example@example.com".to_string())); let mut attributes = Attributes::new(); diff --git a/rust/c509-certificate/src/big_uint.rs b/rust/c509-certificate/src/big_uint.rs index a6e67ad0a5..9313d72946 100644 --- a/rust/c509-certificate/src/big_uint.rs +++ b/rust/c509-certificate/src/big_uint.rs @@ -5,7 +5,7 @@ // cspell: words Bignum bignum biguint -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Serialize}; use crate::helper::{decode::decode_bytes, encode::encode_bytes}; diff --git a/rust/c509-certificate/src/c509.rs b/rust/c509-certificate/src/c509.rs index 72c3bc9036..4697cb1658 100644 --- a/rust/c509-certificate/src/c509.rs +++ b/rust/c509-certificate/src/c509.rs @@ -1,6 +1,6 @@ //! C509 Certificate -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Serialize}; use crate::{ diff --git a/rust/c509-certificate/src/cert_tbs.rs b/rust/c509-certificate/src/cert_tbs.rs index fb80182ed8..8394871fdf 100644 --- a/rust/c509-certificate/src/cert_tbs.rs +++ b/rust/c509-certificate/src/cert_tbs.rs @@ -1,6 +1,6 @@ //! C509 certificate To Be Sign Certificate (TBS Certificate) -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Serialize}; use crate::{ @@ -204,9 +204,9 @@ pub(crate) mod test_tbs_cert { extension::{Extension, ExtensionValue}, }, general_names::{ + GeneralNames, general_name::{GeneralName, GeneralNameTypeRegistry, GeneralNameValue}, other_name_hw_module::OtherNameHardwareModuleName, - GeneralNames, }, name::NameValue, }; @@ -218,31 +218,31 @@ pub(crate) mod test_tbs_cert { // A.1. Example RFC 7925 profiled X.509 Certificate pub(crate) fn tbs_1() -> (TbsCert, String) { let tbs_certificate = ( - 3, // c509_certificate_type - 128_269, // certificate_serial_number - oid!(1.2.840 .10045 .4 .3 .2), // issuer_signature_algorithm (ecdsa-with-SHA256) + 3, // c509_certificate_type + 128_269, // certificate_serial_number + oid!(1.2.840.10045.4.3.2), // issuer_signature_algorithm (ecdsa-with-SHA256) ( // issuer - oid!(2.5.4 .3), // oid (commonName) - "RFC test CA", // value - false, // critical + oid!(2.5.4.3), // oid (commonName) + "RFC test CA", // value + false, // critical ), 1_672_531_200, // validity_not_before 1_767_225_600, // validity_not_after ( // subject - oid!(2.5.4 .3), // oid (commonName) + oid!(2.5.4.3), // oid (commonName) "01-23-45-FF-FE-67-89-AB", // value false, // critical ), - oid!(1.2.840 .10045 .2 .1), /* subject_public_key_algorithm (id-ecPublicKey - * prime256v1 P-256) */ + oid!(1.2.840.10045.2.1), /* subject_public_key_algorithm (id-ecPublicKey + * prime256v1 P-256) */ PUBKEY, // subject_public_key (modified from the example) ( // extensions - oid!(2.5.29 .15), // oid (keyUsage) - 1, // value - false, // critical + oid!(2.5.29.15), // oid (keyUsage) + 1, // value + false, // critical ), ); @@ -260,21 +260,21 @@ pub(crate) mod test_tbs_cert { ]; // Issuer - let mut attr1 = Attribute::new(tbs_certificate.3 .0); - attr1.add_value(AttributeValue::Text(tbs_certificate.3 .1.to_string())); + let mut attr1 = Attribute::new(tbs_certificate.3.0); + attr1.add_value(AttributeValue::Text(tbs_certificate.3.1.to_string())); let issuer = Name::new(NameValue::Attribute(vec![attr1])); // Subject - let mut attr2 = Attribute::new(tbs_certificate.6 .0); - attr2.add_value(AttributeValue::Text(tbs_certificate.6 .1.to_string())); + let mut attr2 = Attribute::new(tbs_certificate.6.0); + attr2.add_value(AttributeValue::Text(tbs_certificate.6.1.to_string())); let subject = Name::new(NameValue::Attribute(vec![attr2])); // Extensions let mut extensions = Extensions::new(); extensions.add_extension(Extension::new( - tbs_certificate.9 .0, - ExtensionValue::Int(tbs_certificate.9 .1), - tbs_certificate.9 .2, + tbs_certificate.9.0, + ExtensionValue::Int(tbs_certificate.9.1), + tbs_certificate.9.2, )); let data = TbsCert::new( @@ -318,35 +318,35 @@ pub(crate) mod test_tbs_cert { #[allow(clippy::too_many_lines)] fn tbs_2() -> (TbsCert, String) { let tbs_certificate = ( - 3, // c509_certificate_type - 9_112_578_475_118_446_130, // certificate_serial_number - oid!(1.2.840 .10045 .4 .3 .2), // issuer_signature_algorithm (ecdsa-with-SHA256) + 3, // c509_certificate_type + 9_112_578_475_118_446_130, // certificate_serial_number + oid!(1.2.840.10045.4.3.2), // issuer_signature_algorithm (ecdsa-with-SHA256) [ // issuer ( - oid!(2.5.4 .6), // oid (C: countryName) - "US", // value - false, // critical + oid!(2.5.4.6), // oid (C: countryName) + "US", // value + false, // critical ), ( - oid!(2.5.4 .8), // oid (ST: stateOrProvinceName) - "CA", // value - false, // critical + oid!(2.5.4.8), // oid (ST: stateOrProvinceName) + "CA", // value + false, // critical ), ( - oid!(2.5.4 .10), // oid (O: organizationName) - "Example Inc", // value - false, // critical + oid!(2.5.4.10), // oid (O: organizationName) + "Example Inc", // value + false, // critical ), ( - oid!(2.5.4 .11), // oid (OU: organizationalUnitName) + oid!(2.5.4.11), // oid (OU: organizationalUnitName) "certification", // value false, // critical ), ( - oid!(2.5.4 .3), // oid (CN: commonName) - "802.1AR CA", // value - false, // critical + oid!(2.5.4.3), // oid (CN: commonName) + "802.1AR CA", // value + false, // critical ), ], 1_548_934_156, // validity_not_before @@ -354,64 +354,64 @@ pub(crate) mod test_tbs_cert { [ // subject ( - oid!(2.5.4 .6), // oid (C: countryName) - "US", // value - false, // critical + oid!(2.5.4.6), // oid (C: countryName) + "US", // value + false, // critical ), ( - oid!(2.5.4 .8), // oid (ST: stateOrProvinceName) - "CA", // value - false, // critical + oid!(2.5.4.8), // oid (ST: stateOrProvinceName) + "CA", // value + false, // critical ), ( - oid!(2.5.4 .7), // oid (L: localityName) - "LA", // value - false, // critical + oid!(2.5.4.7), // oid (L: localityName) + "LA", // value + false, // critical ), ( - oid!(2.5.4 .10), // oid (O: organizationName) - "example Inc", // value - false, // critical + oid!(2.5.4.10), // oid (O: organizationName) + "example Inc", // value + false, // critical ), ( - oid!(2.5.4 .11), // oid (OU: organizationalUnitName) - "IoT", // value - false, // critical + oid!(2.5.4.11), // oid (OU: organizationalUnitName) + "IoT", // value + false, // critical ), ( - oid!(2.5.4 .5), // oid (serialNumber) - "Wt1234", // value - false, // critical + oid!(2.5.4.5), // oid (serialNumber) + "Wt1234", // value + false, // critical ), ], - oid!(1.2.840 .10045 .2 .1), /* subject_public_key_algorithm (id-ecPublicKey - * prime256v1 P-256) */ + oid!(1.2.840.10045.2.1), /* subject_public_key_algorithm (id-ecPublicKey + * prime256v1 P-256) */ PUBKEY, // subject_public_key (modified from the example) ( // extensions ( - oid!(2.5.29 .19), // oid (basicConstraints) - -2, // value - false, // critical + oid!(2.5.29.19), // oid (basicConstraints) + -2, // value + false, // critical ), ( - oid!(2.5.29 .14), // oid (subjectKeyIdentifier) + oid!(2.5.29.14), // oid (subjectKeyIdentifier) [ 0x96, 0x60, 0x0D, 0x87, 0x16, 0xBF, 0x7F, 0xD0, 0xE7, 0x52, 0xD0, 0xAC, 0x76, 0x07, 0x77, 0xAD, 0x66, 0x5D, 0x02, 0xA0, ], // value - false, // critical + false, // critical ), ( - oid!(2.5.29 .15), // oid (keyUsage) - 5, // value - true, // critical + oid!(2.5.29.15), // oid (keyUsage) + 5, // value + true, // critical ), ( - oid!(2.5.29 .17), // oid (subjectAltName) + oid!(2.5.29.17), // oid (subjectAltName) ( - oid!(1.3.6 .1 .4 .1 .6175 .10 .1), // hwType - [0x01, 0x02, 0x03, 0x04], // hwSerialNum + oid!(1.3.6.1.4.1.6175.10.1), // hwType + [0x01, 0x02, 0x03, 0x04], // hwSerialNum ), false, // critical ), @@ -419,17 +419,17 @@ pub(crate) mod test_tbs_cert { ); let tbs_certificate_cbor = [ - "03", // c509_certificate_type - "487e7661d7b54e4632", // certificate_serial_number - "00", // issuer_signature_algorithm - "8a0462555306624341086b4578616d706c6520496e63096d63657274696669636174696f6e016a3830322e314152204341", // issuer - "1a5c52dc0c", // validity_not_before - "f6", // validity_not_after - "8c046255530662434105624c41086b6578616d706c6520496e630963496f540366577431323334", // subject - "01", // subject_public_key_algorithm - "4888d0b6b0b37baa46", // subject_public_key - "840421015496600d8716bf7fd0e752d0ac760777ad665d02a0210503822082492b06010401b01f0a014401020304", // extensions - ]; + "03", // c509_certificate_type + "487e7661d7b54e4632", // certificate_serial_number + "00", // issuer_signature_algorithm + "8a0462555306624341086b4578616d706c6520496e63096d63657274696669636174696f6e016a3830322e314152204341", /* issuer */ + "1a5c52dc0c", // validity_not_before + "f6", // validity_not_after + "8c046255530662434105624c41086b6578616d706c6520496e630963496f540366577431323334", /* subject */ + "01", // subject_public_key_algorithm + "4888d0b6b0b37baa46", // subject_public_key + "840421015496600d8716bf7fd0e752d0ac760777ad665d02a0210503822082492b06010401b01f0a014401020304", /* extensions */ + ]; // Issuer let mut attributes_1 = Vec::new(); @@ -456,24 +456,24 @@ pub(crate) mod test_tbs_cert { // Extensions let mut extensions = Extensions::new(); extensions.add_extension(Extension::new( - tbs_certificate.9 .0 .0, - ExtensionValue::Int(tbs_certificate.9 .0 .1), - tbs_certificate.9 .0 .2, + tbs_certificate.9.0.0, + ExtensionValue::Int(tbs_certificate.9.0.1), + tbs_certificate.9.0.2, )); extensions.add_extension(Extension::new( - tbs_certificate.9 .1 .0, - ExtensionValue::Bytes(tbs_certificate.9 .1 .1.to_vec()), - tbs_certificate.9 .1 .2, + tbs_certificate.9.1.0, + ExtensionValue::Bytes(tbs_certificate.9.1.1.to_vec()), + tbs_certificate.9.1.2, )); extensions.add_extension(Extension::new( - tbs_certificate.9 .2 .0, - ExtensionValue::Int(tbs_certificate.9 .2 .1), - tbs_certificate.9 .2 .2, + tbs_certificate.9.2.0, + ExtensionValue::Int(tbs_certificate.9.2.1), + tbs_certificate.9.2.2, )); let mut gns = GeneralNames::new(); let hw = OtherNameHardwareModuleName::new( - tbs_certificate.9 .3 .1 .0, - tbs_certificate.9 .3 .1 .1.to_vec(), + tbs_certificate.9.3.1.0, + tbs_certificate.9.3.1.1.to_vec(), ); gns.add_general_name(GeneralName::new( GeneralNameTypeRegistry::OtherNameHardwareModuleName, @@ -481,7 +481,7 @@ pub(crate) mod test_tbs_cert { )); extensions.add_extension(Extension::new( - tbs_certificate.9 .3 .0, + tbs_certificate.9.3.0, ExtensionValue::AlternativeName(AlternativeName::new( GeneralNamesOrText::GeneralNames(gns), )), diff --git a/rust/c509-certificate/src/extensions/alt_name.rs b/rust/c509-certificate/src/extensions/alt_name.rs index 0f9896c858..9ad5d1f794 100644 --- a/rust/c509-certificate/src/extensions/alt_name.rs +++ b/rust/c509-certificate/src/extensions/alt_name.rs @@ -1,13 +1,13 @@ //! C509 Alternative Name uses for Subject Alternative Name extension and //! Issuer Alternative Name extension. -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Serialize}; use crate::{ general_names::{ - general_name::{GeneralName, GeneralNameTypeRegistry, GeneralNameValue}, GeneralNames, + general_name::{GeneralName, GeneralNameTypeRegistry, GeneralNameValue}, }, helper::{ decode::{decode_datatype, decode_helper}, diff --git a/rust/c509-certificate/src/extensions/extension/data.rs b/rust/c509-certificate/src/extensions/extension/data.rs index 9edc3a94d6..d2791c8995 100644 --- a/rust/c509-certificate/src/extensions/extension/data.rs +++ b/rust/c509-certificate/src/extensions/extension/data.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; use anyhow::Error; -use asn1_rs::{oid, Oid}; +use asn1_rs::{Oid, oid}; use once_cell::sync::Lazy; use super::ExtensionValueType; diff --git a/rust/c509-certificate/src/extensions/extension/mod.rs b/rust/c509-certificate/src/extensions/extension/mod.rs index c442d7ccad..47432e261f 100644 --- a/rust/c509-certificate/src/extensions/extension/mod.rs +++ b/rust/c509-certificate/src/extensions/extension/mod.rs @@ -4,8 +4,8 @@ pub mod data; use std::{fmt::Debug, str::FromStr}; use asn1_rs::Oid; -use data::{get_extension_type_from_int, get_oid_from_int, EXTENSIONS_LOOKUP}; -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use data::{EXTENSIONS_LOOKUP, get_extension_type_from_int, get_oid_from_int}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Deserializer, Serialize}; use strum_macros::EnumDiscriminants; @@ -275,7 +275,7 @@ mod test_extension { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let ext = Extension::new(oid!(2.5.29 .54), ExtensionValue::Int(2), false); + let ext = Extension::new(oid!(2.5.29.54), ExtensionValue::Int(2), false); ext.encode(&mut encoder, &mut ()) .expect("Failed to encode Extension"); // Inhibit anyPolicy : 0x181e @@ -293,7 +293,7 @@ mod test_extension { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let ext = Extension::new(oid!(2.5.29 .15), ExtensionValue::Int(-1), true); + let ext = Extension::new(oid!(2.5.29.15), ExtensionValue::Int(-1), true); ext.encode(&mut encoder, &mut ()) .expect("Failed to encode Extension"); // Key Usage with critical true: 0x21 @@ -314,7 +314,7 @@ mod test_extension { // Not in the registry table // Value should be bytes let ext = Extension::new( - oid!(2.16.840 .1 .101 .3 .4 .2 .1), + oid!(2.16.840.1.101.3.4.2.1), ExtensionValue::Bytes("test".as_bytes().to_vec()), false, ); @@ -339,7 +339,7 @@ mod test_extension { let mut encoder = Encoder::new(&mut buffer); // Subject Key Identifier should be bytes - let ext = Extension::new(oid!(2.5.29 .14), ExtensionValue::Int(2), false); + let ext = Extension::new(oid!(2.5.29.14), ExtensionValue::Int(2), false); ext.encode(&mut encoder, &mut ()) .expect("Failed to encode Extension"); // SubjectKeyIdentifier : 0x01 diff --git a/rust/c509-certificate/src/extensions/mod.rs b/rust/c509-certificate/src/extensions/mod.rs index 5f1a99d579..31431091b4 100644 --- a/rust/c509-certificate/src/extensions/mod.rs +++ b/rust/c509-certificate/src/extensions/mod.rs @@ -19,9 +19,9 @@ pub mod extension; use std::fmt::Debug; -use asn1_rs::{oid, Oid}; +use asn1_rs::{Oid, oid}; use extension::{Extension, ExtensionValue}; -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Serialize}; use crate::helper::{ @@ -29,7 +29,7 @@ use crate::helper::{ encode::{encode_array_len, encode_helper}, }; /// OID of `KeyUsage` extension -static KEY_USAGE_OID: Oid<'static> = oid!(2.5.29 .15); +static KEY_USAGE_OID: Oid<'static> = oid!(2.5.29.15); /// A struct of C509 Extensions containing a vector of `Extension`. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] @@ -143,7 +143,7 @@ mod test_extensions { let mut exts = Extensions::new(); exts.add_extension(Extension::new( - oid!(2.5.29 .15), + oid!(2.5.29.15), ExtensionValue::Int(2), false, )); @@ -166,7 +166,7 @@ mod test_extensions { let mut exts = Extensions::new(); exts.add_extension(Extension::new( - oid!(2.5.29 .15), + oid!(2.5.29.15), ExtensionValue::Int(2), true, )); @@ -189,13 +189,13 @@ mod test_extensions { let mut exts = Extensions::new(); exts.add_extension(Extension::new( - oid!(2.5.29 .15), + oid!(2.5.29.15), ExtensionValue::Int(2), false, )); exts.add_extension(Extension::new( - oid!(2.5.29 .14), + oid!(2.5.29.14), ExtensionValue::Bytes([1, 2, 3, 4].to_vec()), false, )); diff --git a/rust/c509-certificate/src/general_names/general_name.rs b/rust/c509-certificate/src/general_names/general_name.rs index 9cce5cc59d..ab88a677c3 100644 --- a/rust/c509-certificate/src/general_names/general_name.rs +++ b/rust/c509-certificate/src/general_names/general_name.rs @@ -9,7 +9,7 @@ use std::fmt::Debug; -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Serialize}; use strum_macros::{EnumDiscriminants, EnumIs}; @@ -179,7 +179,7 @@ impl Encode<()> for GeneralNameValue { GeneralNameValue::Unsupported => { return Err(minicbor::encode::Error::message( "Cannot encode unsupported GeneralName value", - )) + )); }, }; Ok(()) @@ -255,7 +255,7 @@ mod test_general_name { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let hw = OtherNameHardwareModuleName::new(oid!(2.16.840 .1 .101 .3 .4 .2 .1), vec![ + let hw = OtherNameHardwareModuleName::new(oid!(2.16.840.1.101.3.4.2.1), vec![ 0x01, 0x02, 0x03, 0x04, ]); let gn = GeneralName::new( @@ -307,7 +307,7 @@ mod test_general_name { let gn = GeneralName::new( GeneralNameTypeRegistry::RegisteredID, - GeneralNameValue::Oid(C509oid::new(oid!(2.16.840 .1 .101 .3 .4 .2 .1))), + GeneralNameValue::Oid(C509oid::new(oid!(2.16.840.1.101.3.4.2.1))), ); gn.encode(&mut encoder, &mut ()) .expect("Failed to encode GeneralName"); @@ -328,7 +328,7 @@ mod test_general_name { let gn = GeneralName::new( GeneralNameTypeRegistry::OtherNameSmtpUTF8Mailbox, - GeneralNameValue::Oid(C509oid::new(oid!(2.16.840 .1 .101 .3 .4 .2 .1))), + GeneralNameValue::Oid(C509oid::new(oid!(2.16.840.1.101.3.4.2.1))), ); gn.encode(&mut encoder, &mut ()) .expect("Failed to encode GeneralName"); diff --git a/rust/c509-certificate/src/general_names/mod.rs b/rust/c509-certificate/src/general_names/mod.rs index 996a5a5a00..9f047189df 100644 --- a/rust/c509-certificate/src/general_names/mod.rs +++ b/rust/c509-certificate/src/general_names/mod.rs @@ -11,7 +11,7 @@ mod data; pub mod general_name; pub mod other_name_hw_module; use general_name::GeneralName; -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Serialize}; use crate::helper::{decode::decode_array_len, encode::encode_array_len}; @@ -108,7 +108,7 @@ mod test_general_names { gns.add_general_name(GeneralName::new( GeneralNameTypeRegistry::OtherNameHardwareModuleName, GeneralNameValue::OtherNameHWModuleName(OtherNameHardwareModuleName::new( - oid!(2.16.840 .1 .101 .3 .4 .2 .1), + oid!(2.16.840.1.101.3.4.2.1), vec![0x01, 0x02, 0x03, 0x04], )), )); @@ -118,7 +118,7 @@ mod test_general_names { )); gns.add_general_name(GeneralName::new( GeneralNameTypeRegistry::RegisteredID, - GeneralNameValue::Oid(C509oid::new(oid!(2.16.840 .1 .101 .3 .4 .2 .1))), + GeneralNameValue::Oid(C509oid::new(oid!(2.16.840.1.101.3.4.2.1))), )); gns.encode(&mut encoder, &mut ()) .expect("Failed to encode GeneralNames"); @@ -133,7 +133,10 @@ mod test_general_names { // IPAddress Value in bytes string 192, 168, 1, 1: 0x44c0a80101 // RegisteredID: 0x08 // OID 2.16.840 .1 .101 .3 .4 .2 .1: 0x49608648016503040201 - assert_eq!(hex::encode(buffer.clone()), "88026b6578616d706c652e636f6d20824960864801650304020144010203040744c0a801010849608648016503040201"); + assert_eq!( + hex::encode(buffer.clone()), + "88026b6578616d706c652e636f6d20824960864801650304020144010203040744c0a801010849608648016503040201" + ); let mut decoder = Decoder::new(&buffer); let gns_decoded = diff --git a/rust/c509-certificate/src/general_names/other_name_hw_module.rs b/rust/c509-certificate/src/general_names/other_name_hw_module.rs index 7e2660cc08..bb56b695ea 100644 --- a/rust/c509-certificate/src/general_names/other_name_hw_module.rs +++ b/rust/c509-certificate/src/general_names/other_name_hw_module.rs @@ -4,7 +4,7 @@ //! [RFC4108](https://datatracker.ietf.org/doc/rfc4108/) use asn1_rs::Oid; -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Serialize}; use crate::{ diff --git a/rust/c509-certificate/src/helper/decode.rs b/rust/c509-certificate/src/helper/decode.rs index d43ef62e5e..590c4c1ac4 100644 --- a/rust/c509-certificate/src/helper/decode.rs +++ b/rust/c509-certificate/src/helper/decode.rs @@ -1,6 +1,6 @@ //! Helper functions for decoding CBOR data. -use minicbor::{decode, Decoder}; +use minicbor::{Decoder, decode}; /// Generic helper function for decoding different types. pub(crate) fn decode_helper<'a, T, C>( diff --git a/rust/c509-certificate/src/helper/encode.rs b/rust/c509-certificate/src/helper/encode.rs index 3184ce0a4c..f0d3a6d51c 100644 --- a/rust/c509-certificate/src/helper/encode.rs +++ b/rust/c509-certificate/src/helper/encode.rs @@ -1,8 +1,8 @@ //! Helper functions for encoding CBOR data. use minicbor::{ - encode::{self, Write}, Encoder, + encode::{self, Write}, }; /// Generic helper function for encoding different types. diff --git a/rust/c509-certificate/src/issuer_sig_algo/data.rs b/rust/c509-certificate/src/issuer_sig_algo/data.rs index c052c7e438..3fbbe34508 100644 --- a/rust/c509-certificate/src/issuer_sig_algo/data.rs +++ b/rust/c509-certificate/src/issuer_sig_algo/data.rs @@ -5,7 +5,7 @@ // cspell: words RSASSA XMSS use anyhow::Error; -use asn1_rs::{oid, Oid}; +use asn1_rs::{Oid, oid}; use once_cell::sync::Lazy; use crate::tables::IntegerToOidTable; diff --git a/rust/c509-certificate/src/issuer_sig_algo/mod.rs b/rust/c509-certificate/src/issuer_sig_algo/mod.rs index 3fb049d2fa..dd6e61ecb7 100644 --- a/rust/c509-certificate/src/issuer_sig_algo/mod.rs +++ b/rust/c509-certificate/src/issuer_sig_algo/mod.rs @@ -13,8 +13,8 @@ mod data; use std::str::FromStr; use asn1_rs::Oid; -use data::{get_oid_from_int, ISSUER_SIG_ALGO_LOOKUP}; -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use data::{ISSUER_SIG_ALGO_LOOKUP, get_oid_from_int}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Deserializer, Serialize}; use crate::{ @@ -143,7 +143,7 @@ mod test_issuer_signature_algorithm { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let isa = IssuerSignatureAlgorithm::new(oid!(1.3.101 .112), None); + let isa = IssuerSignatureAlgorithm::new(oid!(1.3.101.112), None); isa.encode(&mut encoder, &mut ()) .expect("Failed to encode IssuerSignatureAlgorithm"); @@ -161,7 +161,7 @@ mod test_issuer_signature_algorithm { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let isa = IssuerSignatureAlgorithm::new(oid!(2.16.840 .1 .101 .3 .4 .2 .1), None); + let isa = IssuerSignatureAlgorithm::new(oid!(2.16.840.1.101.3.4.2.1), None); isa.encode(&mut encoder, &mut ()) .expect("Failed to encode IssuerSignatureAlgorithm"); @@ -180,7 +180,7 @@ mod test_issuer_signature_algorithm { let mut encoder = Encoder::new(&mut buffer); let isa = IssuerSignatureAlgorithm::new( - oid!(2.16.840 .1 .101 .3 .4 .2 .1), + oid!(2.16.840.1.101.3.4.2.1), Some("example".to_string()), ); isa.encode(&mut encoder, &mut ()) diff --git a/rust/c509-certificate/src/name/mod.rs b/rust/c509-certificate/src/name/mod.rs index d5032a64fc..6d5bfc2afd 100644 --- a/rust/c509-certificate/src/name/mod.rs +++ b/rust/c509-certificate/src/name/mod.rs @@ -12,8 +12,8 @@ //! For more information about Name, //! visit [C509 Certificate](https://datatracker.ietf.org/doc/draft-ietf-cose-cbor-encoded-cert/11/) -use asn1_rs::{oid, Oid}; -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use asn1_rs::{Oid, oid}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use regex::Regex; use serde::{Deserialize, Serialize}; @@ -25,7 +25,7 @@ use crate::{ }, }; /// OID of `CommonName` attribute. -const COMMON_NAME_OID: Oid<'static> = oid!(2.5.4 .3); +const COMMON_NAME_OID: Oid<'static> = oid!(2.5.4.3); /// EUI-64 prefix. const EUI64_PREFIX: u8 = 0x01; /// Hex prefix. @@ -325,7 +325,7 @@ mod test_name { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let mut attr = Attribute::new(oid!(2.5.4 .3)); + let mut attr = Attribute::new(oid!(2.5.4.3)); attr.add_value(AttributeValue::Text("RFC test CA".to_string())); let name = Name::new(NameValue::Attribute(vec![attr])); @@ -345,7 +345,7 @@ mod test_name { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let mut attr = Attribute::new(oid!(2.5.4 .3)); + let mut attr = Attribute::new(oid!(2.5.4.3)); attr.add_value(AttributeValue::Text("000123abcd".to_string())); let name = Name::new(NameValue::Attribute(vec![attr])); @@ -367,7 +367,7 @@ mod test_name { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let mut attr = Attribute::new(oid!(2.5.4 .3)); + let mut attr = Attribute::new(oid!(2.5.4.3)); attr.add_value(AttributeValue::Text("000123ABCD".to_string())); let name = Name::new(NameValue::Attribute(vec![attr])); @@ -388,7 +388,7 @@ mod test_name { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let mut attr = Attribute::new(oid!(2.5.4 .3)); + let mut attr = Attribute::new(oid!(2.5.4.3)); attr.add_value(AttributeValue::Text("01-23-45-FF-FE-67-89-AB".to_string())); let name = Name::new(NameValue::Attribute(vec![attr])); @@ -409,7 +409,7 @@ mod test_name { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let mut attr = Attribute::new(oid!(2.5.4 .3)); + let mut attr = Attribute::new(oid!(2.5.4.3)); attr.add_value(AttributeValue::Text("01-23-45-ff-fe-67-89-AB".to_string())); let name = Name::new(NameValue::Attribute(vec![attr])); @@ -433,7 +433,7 @@ mod test_name { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let mut attr = Attribute::new(oid!(2.5.4 .3)); + let mut attr = Attribute::new(oid!(2.5.4.3)); attr.add_value(AttributeValue::Text("01-23-45-67-89-AB-00-01".to_string())); let name = Name::new(NameValue::Attribute(vec![attr])); @@ -454,7 +454,7 @@ mod test_name { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let mut attr = Attribute::new(oid!(2.5.4 .3)); + let mut attr = Attribute::new(oid!(2.5.4.3)); attr.add_value(AttributeValue::Text("01-23-45-67-89-ab-00-01".to_string())); let name = Name::new(NameValue::Attribute(vec![attr])); @@ -482,15 +482,15 @@ mod test_name { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let mut attr1 = Attribute::new(oid!(2.5.4 .6)); + let mut attr1 = Attribute::new(oid!(2.5.4.6)); attr1.add_value(AttributeValue::Text("US".to_string())); - let mut attr2 = Attribute::new(oid!(2.5.4 .8)); + let mut attr2 = Attribute::new(oid!(2.5.4.8)); attr2.add_value(AttributeValue::Text("CA".to_string())); - let mut attr3 = Attribute::new(oid!(2.5.4 .10)); + let mut attr3 = Attribute::new(oid!(2.5.4.10)); attr3.add_value(AttributeValue::Text("Example Inc".to_string())); - let mut attr4 = Attribute::new(oid!(2.5.4 .11)); + let mut attr4 = Attribute::new(oid!(2.5.4.11)); attr4.add_value(AttributeValue::Text("certification".to_string())); - let mut attr5 = Attribute::new(oid!(2.5.4 .3)); + let mut attr5 = Attribute::new(oid!(2.5.4.3)); attr5.add_value(AttributeValue::Text("802.1AR CA".to_string())); let name = Name::new(NameValue::Attribute(vec![ @@ -499,7 +499,10 @@ mod test_name { name.encode(&mut encoder, &mut ()) .expect("Failed to encode Name"); - assert_eq!(hex::encode(buffer.clone()), "8a0462555306624341086b4578616d706c6520496e63096d63657274696669636174696f6e016a3830322e314152204341"); + assert_eq!( + hex::encode(buffer.clone()), + "8a0462555306624341086b4578616d706c6520496e63096d63657274696669636174696f6e016a3830322e314152204341" + ); let mut decoder = Decoder::new(&buffer); let name_decoded = Name::decode(&mut decoder, &mut ()).expect("Failed to decode Name"); diff --git a/rust/c509-certificate/src/oid.rs b/rust/c509-certificate/src/oid.rs index db4524a518..24f0d5b8b2 100644 --- a/rust/c509-certificate/src/oid.rs +++ b/rust/c509-certificate/src/oid.rs @@ -7,7 +7,7 @@ use std::str::FromStr; use anyhow::Result; -use minicbor::{decode, encode::Write, Decode, Decoder, Encode, Encoder}; +use minicbor::{Decode, Decoder, Encode, Encoder, decode, encode::Write}; use oid_registry::Oid; use serde::{Deserialize, Deserializer, Serialize}; @@ -140,7 +140,7 @@ mod test_c509_oid { fn encode_decode_unwrapped() { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let oid = C509oid::new(oid!(2.16.840 .1 .101 .3 .4 .2 .1)); + let oid = C509oid::new(oid!(2.16.840.1.101.3.4.2.1)); oid.encode(&mut encoder, &mut ()) .expect("Failed to encode OID"); // bytes(9) 0x49 @@ -156,7 +156,7 @@ mod test_c509_oid { #[test] fn partial_equal() { let oid1 = C509oid::new(oid_registry::OID_HASH_SHA1); - let oid2 = C509oid::new(oid!(1.3.14 .3 .2 .26)); + let oid2 = C509oid::new(oid!(1.3.14.3.2.26)); assert_eq!(oid1, oid2); } } diff --git a/rust/c509-certificate/src/signing.rs b/rust/c509-certificate/src/signing.rs index 6fc732c8ad..324acf2487 100644 --- a/rust/c509-certificate/src/signing.rs +++ b/rust/c509-certificate/src/signing.rs @@ -3,9 +3,9 @@ use std::{fmt::Display, path::Path, str::FromStr}; use ed25519_dalek::{ + SigningKey, VerifyingKey, ed25519::signature::Signer, pkcs8::{DecodePrivateKey, DecodePublicKey}, - SigningKey, VerifyingKey, }; // use wasm_bindgen::prelude::wasm_bindgen; 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 0a29de39f4..c1d5e95263 100644 --- a/rust/c509-certificate/src/subject_pub_key_algo/data.rs +++ b/rust/c509-certificate/src/subject_pub_key_algo/data.rs @@ -5,7 +5,7 @@ // cspell: words Weierstraß secp XMSS brainpool use anyhow::Error; -use asn1_rs::{oid, Oid}; +use asn1_rs::{Oid, oid}; use once_cell::sync::Lazy; use crate::tables::IntegerToOidTable; diff --git a/rust/c509-certificate/src/subject_pub_key_algo/mod.rs b/rust/c509-certificate/src/subject_pub_key_algo/mod.rs index b3d923bd1c..bd35018753 100644 --- a/rust/c509-certificate/src/subject_pub_key_algo/mod.rs +++ b/rust/c509-certificate/src/subject_pub_key_algo/mod.rs @@ -14,8 +14,8 @@ mod data; use std::str::FromStr; use asn1_rs::Oid; -use data::{get_oid_from_int, SUBJECT_PUB_KEY_ALGO_LOOKUP}; -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use data::{SUBJECT_PUB_KEY_ALGO_LOOKUP, get_oid_from_int}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Deserializer, Serialize}; use crate::{ @@ -141,7 +141,7 @@ mod test_subject_public_key_algorithm { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let spka = SubjectPubKeyAlgorithm::new(oid!(1.3.101 .112), None); + let spka = SubjectPubKeyAlgorithm::new(oid!(1.3.101.112), None); spka.encode(&mut encoder, &mut ()) .expect("Failed to encode SubjectPubKeyAlgorithm"); @@ -159,7 +159,7 @@ mod test_subject_public_key_algorithm { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let spka = SubjectPubKeyAlgorithm::new(oid!(2.16.840 .1 .101 .3 .4 .2 .1), None); + let spka = SubjectPubKeyAlgorithm::new(oid!(2.16.840.1.101.3.4.2.1), None); spka.encode(&mut encoder, &mut ()) .expect("Failed to encode SubjectPubKeyAlgorithm"); @@ -177,10 +177,8 @@ mod test_subject_public_key_algorithm { let mut buffer = Vec::new(); let mut encoder = Encoder::new(&mut buffer); - let spka = SubjectPubKeyAlgorithm::new( - oid!(2.16.840 .1 .101 .3 .4 .2 .1), - Some("example".to_string()), - ); + let spka = + SubjectPubKeyAlgorithm::new(oid!(2.16.840.1.101.3.4.2.1), Some("example".to_string())); spka.encode(&mut encoder, &mut ()) .expect("Failed to encode SubjectPubKeyAlgorithm"); // Array of 2 items: 0x82 diff --git a/rust/c509-certificate/src/time.rs b/rust/c509-certificate/src/time.rs index b3e74a178f..0ff2fe77b8 100644 --- a/rust/c509-certificate/src/time.rs +++ b/rust/c509-certificate/src/time.rs @@ -1,6 +1,6 @@ //! C509 Time -use minicbor::{encode::Write, Decode, Decoder, Encode, Encoder}; +use minicbor::{Decode, Decoder, Encode, Encoder, encode::Write}; use serde::{Deserialize, Serialize}; use crate::helper::{ diff --git a/rust/cardano-blockchain-types/src/auxdata/aux_data.rs b/rust/cardano-blockchain-types/src/auxdata/aux_data.rs index a5b79fefbd..c18fc6947e 100644 --- a/rust/cardano-blockchain-types/src/auxdata/aux_data.rs +++ b/rust/cardano-blockchain-types/src/auxdata/aux_data.rs @@ -71,7 +71,8 @@ impl TransactionAuxData { }, Ok(None) => { return Err(minicbor::decode::Error::message( - "Error decoding Transaction Aux Data: Indefinite Array found decoding Metadata. Invalid.")); + "Error decoding Transaction Aux Data: Indefinite Array found decoding Metadata. Invalid.", + )); }, Err(error) => { return Err(minicbor::decode::Error::message(format!( @@ -116,12 +117,12 @@ impl TransactionAuxData { Ok(None) => { return Err(minicbor::decode::Error::message( "Indefinite Map found decoding Alonzo+ Metadata. Invalid.", - )) + )); }, Err(error) => { return Err(minicbor::decode::Error::message(format!( "Error decoding Transaction Alonzo+ Aux Data: {error}." - ))) + ))); }, }; diff --git a/rust/cardano-blockchain-types/src/auxdata/scripts.rs b/rust/cardano-blockchain-types/src/auxdata/scripts.rs index a681a2e24a..7807b78dfe 100644 --- a/rust/cardano-blockchain-types/src/auxdata/scripts.rs +++ b/rust/cardano-blockchain-types/src/auxdata/scripts.rs @@ -41,7 +41,7 @@ impl minicbor::Decode<'_, ScriptType> for Script { Err(error) => { return Err(minicbor::decode::Error::message(format!( "Error decoding plutus script data: {error}" - ))) + ))); }, }; Ok(Self(Arc::new(script.to_vec()))) diff --git a/rust/cardano-blockchain-types/src/cip134_uri.rs b/rust/cardano-blockchain-types/src/cip134_uri.rs index 1f97d6dfe0..b1b3c5b786 100644 --- a/rust/cardano-blockchain-types/src/cip134_uri.rs +++ b/rust/cardano-blockchain-types/src/cip134_uri.rs @@ -5,7 +5,7 @@ use std::fmt::{Display, Formatter}; -use anyhow::{anyhow, Context, Error, Result}; +use anyhow::{Context, Error, Result, anyhow}; use pallas::ledger::addresses::Address; /// A URI in the CIP-0134 format. @@ -148,7 +148,7 @@ mod tests { "web+cardano://addr/drep_vk17axh4sc9zwkpsft3tlgpjemfwc0u5mnld80r85zw7zdqcst6w54sdv4a4e", Network::Other(7), "4d7ac30513ac1825715fd0196769761fca6e7f69de33d04ef09a0c41", - ) + ), ]; for (uri, network, payload) in test_data { @@ -175,7 +175,7 @@ mod tests { ( "web+cardano://addr/cc_hot_vk10y48lq72hypxraew74lwjjn9e2dscuwphckglh2nrrpkgweqk5hschnzv5", Network::Other(9), - ) + ), ]; for (uri, network) in test_data { diff --git a/rust/cardano-blockchain-types/src/lib.rs b/rust/cardano-blockchain-types/src/lib.rs index 5ae5f44225..259cd893bd 100644 --- a/rust/cardano-blockchain-types/src/lib.rs +++ b/rust/cardano-blockchain-types/src/lib.rs @@ -25,7 +25,7 @@ pub use auxdata::{ pub use cip134_uri::Cip0134Uri; pub use fork::Fork; pub use hashes::{PubKeyHash, TransactionId}; -pub use metadata::cip36::{voting_pk::VotingPubKey, Cip36}; +pub use metadata::cip36::{Cip36, voting_pk::VotingPubKey}; pub use multi_era_block_data::MultiEraBlock; pub use network::Network; pub use point::Point; diff --git a/rust/cardano-blockchain-types/src/metadata/cip36/key_registration.rs b/rust/cardano-blockchain-types/src/metadata/cip36/key_registration.rs index 2f9b8fd6fc..e47092cd8b 100644 --- a/rust/cardano-blockchain-types/src/metadata/cip36/key_registration.rs +++ b/rust/cardano-blockchain-types/src/metadata/cip36/key_registration.rs @@ -11,7 +11,7 @@ use catalyst_types::{ }; use cbork_utils::decode_helper::{decode_array_len, decode_bytes, decode_helper, decode_map_len}; use ed25519_dalek::VerifyingKey; -use minicbor::{decode, Decode, Decoder}; +use minicbor::{Decode, Decoder, decode}; use pallas::ledger::addresses::{Address, ShelleyAddress}; use strum::FromRepr; @@ -203,13 +203,22 @@ fn decode_voting_key( decode_array_len(d, "CIP36 Key Registration voting key, delegations")?; // This fixed array should be a length of 2 (voting key, weight). if len != 2 { - return Err(decode::Error::message(format!("Invalid length for CIP36 Key Registration voting key delegations, expected 2, got {len}"))); + return Err(decode::Error::message(format!( + "Invalid length for CIP36 Key Registration voting key delegations, expected 2, got {len}" + ))); } // The first entry. - let pub_key = decode_bytes(d, "CIP36 Key Registration voting key, delegation array first entry (voting public key)")?; + let pub_key = decode_bytes( + d, + "CIP36 Key Registration voting key, delegation array first entry (voting public key)", + )?; // The second entry. - let weight: u32 = decode_helper(d, "CIP36 Key Registration voting key, delegation array second entry (weight)", &mut (),)?; + let weight: u32 = decode_helper( + d, + "CIP36 Key Registration voting key, delegation array second entry (weight)", + &mut (), + )?; let vk = voting_pk_vec_to_verifying_key( &pub_key, @@ -221,7 +230,9 @@ fn decode_voting_key( }, _ => { - return Err(decode::Error::message("Invalid datatype for CIP36 Key Registration voting key, should be either Array or Bytes")); + return Err(decode::Error::message( + "Invalid datatype for CIP36 Key Registration voting key, should be either Array or Bytes", + )); }, } }, diff --git a/rust/cardano-blockchain-types/src/metadata/cip36/mod.rs b/rust/cardano-blockchain-types/src/metadata/cip36/mod.rs index 105ee3e158..5887ac1893 100644 --- a/rust/cardano-blockchain-types/src/metadata/cip36/mod.rs +++ b/rust/cardano-blockchain-types/src/metadata/cip36/mod.rs @@ -60,7 +60,7 @@ impl fmt::Display for Cip36 { is_valid_voting_keys = self.is_valid_voting_keys, is_valid_purpose = self.is_valid_purpose, err_report = serde_json::to_string(&self.err_report) - .unwrap_or_else(|_| String::from("Failed to serialize ProblemReport")) + .unwrap_or_else(|_| String::from("Failed to serialize ProblemReport")) ) } } diff --git a/rust/cardano-blockchain-types/src/metadata/cip36/registration_witness.rs b/rust/cardano-blockchain-types/src/metadata/cip36/registration_witness.rs index ee2ffbb7e6..406351f1d6 100644 --- a/rust/cardano-blockchain-types/src/metadata/cip36/registration_witness.rs +++ b/rust/cardano-blockchain-types/src/metadata/cip36/registration_witness.rs @@ -5,7 +5,7 @@ use catalyst_types::problem_report::ProblemReport; use cbork_utils::decode_helper::{decode_bytes, decode_helper, decode_map_len}; -use minicbor::{decode, Decode, Decoder}; +use minicbor::{Decode, Decoder, decode}; /// CIP-36 registration witness - 61285 /// diff --git a/rust/cardano-blockchain-types/src/metadata/cip36/validation.rs b/rust/cardano-blockchain-types/src/metadata/cip36/validation.rs index b25f52be95..502aa8a375 100644 --- a/rust/cardano-blockchain-types/src/metadata/cip36/validation.rs +++ b/rust/cardano-blockchain-types/src/metadata/cip36/validation.rs @@ -136,11 +136,11 @@ mod tests { use pallas::ledger::addresses::Address; use crate::{ + Cip36, Network, metadata::cip36::{ - key_registration::Cip36KeyRegistration, voting_pk::VotingPubKey, - Cip36RegistrationWitness, + Cip36RegistrationWitness, key_registration::Cip36KeyRegistration, + voting_pk::VotingPubKey, }, - Cip36, Network, }; fn create_cip36() -> Cip36 { diff --git a/rust/cardano-blockchain-types/src/multi_era_block_data.rs b/rust/cardano-blockchain-types/src/multi_era_block_data.rs index 935f26c04e..d49894713d 100644 --- a/rust/cardano-blockchain-types/src/multi_era_block_data.rs +++ b/rust/cardano-blockchain-types/src/multi_era_block_data.rs @@ -16,6 +16,7 @@ use pallas::ledger::traverse::MultiEraTx; use tracing::debug; use crate::{ + Slot, auxdata::{ block::BlockAuxData, metadatum_label::MetadatumLabel, metadatum_value::MetadatumValue, }, @@ -24,7 +25,6 @@ use crate::{ point::Point, txn_index::TxnIndex, txn_witness::{TxnWitness, VKeyHash}, - Slot, }; /// Self-referencing CBOR encoded data of a multi-era block. @@ -329,8 +329,12 @@ impl Display for MultiEraBlock { pallas::ledger::traverse::MultiEraBlock::Conway(_) => "Conway".to_string(), _ => "Unknown".to_string(), }; - write!(f, "{block_era} block : {}, Previous {} : Slot# {slot} : {fork} : Block# {block_number} : Size {size} : Txns {txns} : AuxData? {aux_data}", - self.point(), self.previous())?; + write!( + f, + "{block_era} block : {}, Previous {} : Slot# {slot} : {fork} : Block# {block_number} : Size {size} : Txns {txns} : AuxData? {aux_data}", + self.point(), + self.previous() + )?; Ok(()) } } @@ -486,10 +490,12 @@ pub(crate) mod tests { ); assert!(block.is_err()); - assert!(block - .unwrap_err() - .to_string() - .contains("Previous slot is not less than current slot")); + assert!( + block + .unwrap_err() + .to_string() + .contains("Previous slot is not less than current slot") + ); } Ok(()) diff --git a/rust/cardano-blockchain-types/src/network.rs b/rust/cardano-blockchain-types/src/network.rs index d0d93b49b8..6ef0927242 100644 --- a/rust/cardano-blockchain-types/src/network.rs +++ b/rust/cardano-blockchain-types/src/network.rs @@ -7,7 +7,7 @@ use catalyst_types::conversion::from_saturating; use chrono::{DateTime, Utc}; use pallas::{ ledger::{addresses::Network as PallasNetwork, traverse::wellknown::GenesisValues}, - network::miniprotocols::{MAINNET_MAGIC, PREVIEW_MAGIC, PRE_PRODUCTION_MAGIC}, + network::miniprotocols::{MAINNET_MAGIC, PRE_PRODUCTION_MAGIC, PREVIEW_MAGIC}, }; use tracing::debug; diff --git a/rust/cardano-blockchain-types/src/stake_address.rs b/rust/cardano-blockchain-types/src/stake_address.rs index b179363a7b..710434da92 100644 --- a/rust/cardano-blockchain-types/src/stake_address.rs +++ b/rust/cardano-blockchain-types/src/stake_address.rs @@ -4,7 +4,7 @@ use std::fmt::{Display, Formatter}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use pallas::{ crypto::hash::Hash, ledger::{ @@ -139,7 +139,6 @@ impl Display for StakeAddress { mod tests { use super::*; - #[allow(clippy::indexing_slicing)] #[test] fn roundtrip() { let hash: Hash<28> = "276fd18711931e2c0e21430192dbeac0e458093cd9d1fcd7210f64b3" diff --git a/rust/cardano-blockchain-types/src/txn_index.rs b/rust/cardano-blockchain-types/src/txn_index.rs index 825dc560e0..d8e712db63 100644 --- a/rust/cardano-blockchain-types/src/txn_index.rs +++ b/rust/cardano-blockchain-types/src/txn_index.rs @@ -7,12 +7,8 @@ use catalyst_types::conversion::from_saturating; pub struct TxnIndex(u16); impl< - T: Copy - + TryInto - + std::ops::Sub - + PartialOrd - + num_traits::identities::Zero, - > From for TxnIndex + T: Copy + TryInto + std::ops::Sub + PartialOrd + num_traits::identities::Zero, +> From for TxnIndex { fn from(value: T) -> Self { Self(from_saturating(value)) diff --git a/rust/cardano-blockchain-types/src/txn_output_offset.rs b/rust/cardano-blockchain-types/src/txn_output_offset.rs index efeb7aff3e..dd9a1684fe 100644 --- a/rust/cardano-blockchain-types/src/txn_output_offset.rs +++ b/rust/cardano-blockchain-types/src/txn_output_offset.rs @@ -6,12 +6,8 @@ use catalyst_types::conversion::from_saturating; pub struct TxnOutputOffset(u16); impl< - T: Copy - + TryInto - + std::ops::Sub - + PartialOrd - + num_traits::identities::Zero, - > From for TxnOutputOffset + T: Copy + TryInto + std::ops::Sub + PartialOrd + num_traits::identities::Zero, +> From for TxnOutputOffset { fn from(value: T) -> Self { Self(from_saturating(value)) diff --git a/rust/cardano-blockchain-types/src/txn_witness.rs b/rust/cardano-blockchain-types/src/txn_witness.rs index 60fd6707cb..58341b54a6 100644 --- a/rust/cardano-blockchain-types/src/txn_witness.rs +++ b/rust/cardano-blockchain-types/src/txn_witness.rs @@ -81,7 +81,7 @@ impl TxnWitness { pub fn check_witness_in_tx(&self, vkey_hash: &VKeyHash, tx_num: TxnIndex) -> bool { self.0 .get(vkey_hash) - .map_or(false, |entry| entry.1.contains(&tx_num)) + .is_some_and(|entry| entry.1.contains(&tx_num)) } /// Get the actual verifying key from the given public key hash. diff --git a/rust/cardano-chain-follower/examples/follow_chains.rs b/rust/cardano-chain-follower/examples/follow_chains.rs index e235f6e53d..e4ce4bf05f 100644 --- a/rust/cardano-chain-follower/examples/follow_chains.rs +++ b/rust/cardano-chain-follower/examples/follow_chains.rs @@ -20,7 +20,7 @@ static GLOBAL: MiMalloc = MiMalloc; use std::{error::Error, time::Duration}; use cardano_chain_follower::{ChainFollower, ChainSyncConfig, ChainUpdate, Kind, Statistics}; -use clap::{arg, ArgAction, ArgMatches, Command}; +use clap::{ArgAction, ArgMatches, Command, arg}; use tokio::time::Instant; use tracing::{error, info, level_filters::LevelFilter, warn}; use tracing_subscriber::EnvFilter; @@ -378,7 +378,7 @@ fn update_largest_aux( largest_metadata_size: &mut usize, ) { match block { - pallas::ledger::traverse::MultiEraBlock::AlonzoCompatible(ref b, _) => { + pallas::ledger::traverse::MultiEraBlock::AlonzoCompatible(b, _) => { b.auxiliary_data_set.iter().for_each(|(txn_idx, aux_data)| { compare_and_log_aux( aux_data.raw_cbor().len(), @@ -389,7 +389,7 @@ fn update_largest_aux( ); }); }, - pallas::ledger::traverse::MultiEraBlock::Babbage(ref b) => { + pallas::ledger::traverse::MultiEraBlock::Babbage(b) => { b.auxiliary_data_set.iter().for_each(|(txn_idx, aux_data)| { compare_and_log_aux( aux_data.raw_cbor().len(), @@ -400,7 +400,7 @@ fn update_largest_aux( ); }); }, - pallas::ledger::traverse::MultiEraBlock::Conway(ref b) => { + pallas::ledger::traverse::MultiEraBlock::Conway(b) => { b.auxiliary_data_set.iter().for_each(|(txn_idx, aux_data)| { compare_and_log_aux( aux_data.raw_cbor().len(), diff --git a/rust/cardano-chain-follower/src/chain_sync.rs b/rust/cardano-chain-follower/src/chain_sync.rs index e30a7149da..8afc3f68f6 100644 --- a/rust/cardano-chain-follower/src/chain_sync.rs +++ b/rust/cardano-chain-follower/src/chain_sync.rs @@ -22,19 +22,19 @@ use tokio::{ use tracing::{debug, error}; use crate::{ + ChainSyncConfig, chain_sync_live_chains::{ get_fill_to_point, get_intersect_points, get_live_block, get_live_head_point, get_peer_tip, live_chain_add_block_to_tip, live_chain_backfill, live_chain_length, purge_live_chain, }, chain_sync_ready::{ - get_chain_update_tx_queue, notify_follower, wait_for_sync_ready, SyncReadyWaiter, + SyncReadyWaiter, get_chain_update_tx_queue, notify_follower, wait_for_sync_ready, }, chain_update, error::{Error, Result}, mithril_snapshot_config::MithrilUpdateMessage, mithril_snapshot_data::latest_mithril_snapshot_id, stats::{self}, - ChainSyncConfig, }; /// The maximum number of seconds we wait for a node to connect. 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 bd2e2f42e2..d69051f17e 100644 --- a/rust/cardano-chain-follower/src/chain_sync_live_chains.rs +++ b/rust/cardano-chain-follower/src/chain_sync_live_chains.rs @@ -277,8 +277,8 @@ impl ProtectedLiveChainBlockList { let latest_mithril_tip = latest_mithril_snapshot_id(chain).tip(); if !point.strict_eq(&latest_mithril_tip) { return Err(Error::LiveSync(format!( - "First Block of Live Purge {point} MUST be last block of Mithril Snapshot {latest_mithril_tip}." - ))); + "First Block of Live Purge {point} MUST be last block of Mithril Snapshot {latest_mithril_tip}." + ))); } } @@ -299,8 +299,8 @@ impl ProtectedLiveChainBlockList { // Make sure the block that IS present, is the actual block, by strict equality. if !purge_start_block_entry.value().point().strict_eq(point) { return Err(Error::LiveSync(format!( - "The block to purge to {point} slot is in the live chain, but its hashes do not match." - ))); + "The block to purge to {point} slot is in the live chain, but its hashes do not match." + ))); } // Purge every block prior to the purge point. @@ -394,10 +394,7 @@ impl ProtectedLiveChainBlockList { // Search backwards for a fork smaller than or equal to the one we know. while this_block.fork() > fork { rollback_depth = rollback_depth.saturating_add(1); - entry = match entry.prev() { - Some(entry) => entry, - None => return None, - }; + entry = entry.prev()?; this_block = entry.value().clone(); } diff --git a/rust/cardano-chain-follower/src/chain_sync_ready.rs b/rust/cardano-chain-follower/src/chain_sync_ready.rs index 51c33f0e51..94d79dbb36 100644 --- a/rust/cardano-chain-follower/src/chain_sync_ready.rs +++ b/rust/cardano-chain-follower/src/chain_sync_ready.rs @@ -7,7 +7,7 @@ use cardano_blockchain_types::Network; use dashmap::DashMap; use strum::IntoEnumIterator; use tokio::{ - sync::{broadcast, oneshot, RwLock}, + sync::{RwLock, broadcast, oneshot}, time::sleep, }; use tracing::error; diff --git a/rust/cardano-chain-follower/src/error.rs b/rust/cardano-chain-follower/src/error.rs index 761c42f915..ffbd14cd1d 100644 --- a/rust/cardano-chain-follower/src/error.rs +++ b/rust/cardano-chain-follower/src/error.rs @@ -92,13 +92,19 @@ pub enum Error { #[error("Mithril Aggregator network mismatch. Wanted {0} Got {1}")] MithrilClientNetworkMismatch(Network, String), /// Mithril genesis VKEY Mismatch - #[error("Mithril Genesis VKEY for Network {0} is already set, and can not be changed to a different value.")] + #[error( + "Mithril Genesis VKEY for Network {0} is already set, and can not be changed to a different value." + )] MithrilGenesisVKeyMismatch(Network), /// Mithril genesis VKEY is not properly HEX Encoded - #[error("Mithril Genesis VKEY for Network {0} is not hex encoded. Needs to be only HEX Ascii characters, and even length.")] + #[error( + "Mithril Genesis VKEY for Network {0} is not hex encoded. Needs to be only HEX Ascii characters, and even length." + )] MithrilGenesisVKeyNotHex(Network), /// Mithril Auto-update requires an Aggregator and a VKEY and a Path - #[error("Mithril Auto Update Network {0} failed to start. No Aggregator and/or Genesis VKEY and/or Path are configured.")] + #[error( + "Mithril Auto Update Network {0} failed to start. No Aggregator and/or Genesis VKEY and/or Path are configured." + )] MithrilUpdateRequiresAggregatorAndVkeyAndPath(Network), /// Internal Error #[error("Internal error")] diff --git a/rust/cardano-chain-follower/src/follow.rs b/rust/cardano-chain-follower/src/follow.rs index 772eaa3051..a5fcc1ade5 100644 --- a/rust/cardano-chain-follower/src/follow.rs +++ b/rust/cardano-chain-follower/src/follow.rs @@ -6,6 +6,7 @@ use tokio::sync::broadcast::{self}; use tracing::{debug, error}; use crate::{ + Statistics, chain_sync::point_at_tip, chain_sync_live_chains::{find_best_fork_block, get_live_block, live_chain_length}, chain_sync_ready::{block_until_sync_ready, get_chain_update_rx_queue}, @@ -14,7 +15,6 @@ use crate::{ mithril_snapshot_data::latest_mithril_snapshot_id, mithril_snapshot_iterator::MithrilSnapshotIterator, stats::{self}, - Statistics, }; /// The Chain Follower diff --git a/rust/cardano-chain-follower/src/mithril_snapshot.rs b/rust/cardano-chain-follower/src/mithril_snapshot.rs index 2d8c9d31ab..22a4bd1455 100644 --- a/rust/cardano-chain-follower/src/mithril_snapshot.rs +++ b/rust/cardano-chain-follower/src/mithril_snapshot.rs @@ -56,7 +56,6 @@ impl MithrilSnapshot { /// /// Returns None if its not possible to iterate a mithril snapshot from the requested /// point for ANY reason. - #[allow(clippy::indexing_slicing)] #[logcall("debug")] pub(crate) async fn try_read_blocks_from_point( &self, point: &Point, @@ -76,7 +75,6 @@ impl MithrilSnapshot { } /// Read a single block from a known point. - #[allow(clippy::indexing_slicing)] #[logcall("debug")] pub(crate) async fn read_block_at(&self, point: &Point) -> Option { if let Some(iterator) = self.try_read_blocks_from_point(point).await { diff --git a/rust/cardano-chain-follower/src/mithril_snapshot_config.rs b/rust/cardano-chain-follower/src/mithril_snapshot_config.rs index 5de240287f..e5407b6dbc 100644 --- a/rust/cardano-chain-follower/src/mithril_snapshot_config.rs +++ b/rust/cardano-chain-follower/src/mithril_snapshot_config.rs @@ -14,14 +14,14 @@ use strum::IntoEnumIterator; use tokio::{ fs::{self}, io::{self}, - sync::{mpsc, Mutex}, + sync::{Mutex, mpsc}, task::JoinHandle, }; use tracing::{debug, error}; use crate::{ error::{Error, Result}, - mithril_snapshot_data::{latest_mithril_snapshot_id, SnapshotData}, + mithril_snapshot_data::{SnapshotData, latest_mithril_snapshot_id}, mithril_snapshot_sync::background_mithril_update, snapshot_id::SnapshotId, stats, diff --git a/rust/cardano-chain-follower/src/mithril_snapshot_iterator.rs b/rust/cardano-chain-follower/src/mithril_snapshot_iterator.rs index 67a9bbd1fe..23de83cb3c 100644 --- a/rust/cardano-chain-follower/src/mithril_snapshot_iterator.rs +++ b/rust/cardano-chain-follower/src/mithril_snapshot_iterator.rs @@ -14,7 +14,7 @@ use tracing_log::log; use crate::{ error::{Error, Result}, - mithril_query::{make_mithril_iterator, ImmutableBlockIterator}, + mithril_query::{ImmutableBlockIterator, make_mithril_iterator}, }; /// Search backwards by 60 slots (seconds) looking for a previous block. @@ -134,7 +134,6 @@ impl MithrilSnapshotIterator { /// Do a fuzzy search to establish the iterator. /// We use this when we don't know the previous point, and need to find it. - #[allow(clippy::indexing_slicing)] #[logcall("debug")] async fn fuzzy_iterator(chain: Network, path: &Path, from: &Point) -> MithrilSnapshotIterator { let mut backwards_search = BACKWARD_SEARCH_SLOT_INTERVAL; @@ -158,7 +157,6 @@ impl MithrilSnapshotIterator { /// hash, the iteration start is fuzzy. `previous`: The previous point we are /// iterating, if known. If the previous is NOT known, then the first block /// yielded by the iterator is discarded and becomes the known previous. - #[allow(clippy::indexing_slicing)] #[logcall(ok = "debug", err = "error")] pub(crate) async fn new( chain: Network, path: &Path, from: &Point, previous_point: Option, diff --git a/rust/cardano-chain-follower/src/mithril_snapshot_sync.rs b/rust/cardano-chain-follower/src/mithril_snapshot_sync.rs index b0026ed7a2..eb70235f3a 100644 --- a/rust/cardano-chain-follower/src/mithril_snapshot_sync.rs +++ b/rust/cardano-chain-follower/src/mithril_snapshot_sync.rs @@ -16,7 +16,7 @@ use mithril_client::{Client, MessageBuilder, MithrilCertificate, Snapshot, Snaps use tokio::{ fs::remove_dir_all, sync::mpsc::Sender, - time::{sleep, Duration}, + time::{Duration, sleep}, }; use tracing::{debug, error}; use tracing_log::log; @@ -57,14 +57,20 @@ async fn get_latest_snapshots( let snapshots = match client.snapshot().list().await { Ok(s) => s, Err(e) => { - error!("Unexpected Error [{}]: Unable to get Snapshot List from Aggregator for {}. Mithril Snapshots can not update. Sleeping.", network, e); + error!( + "Unexpected Error [{}]: Unable to get Snapshot List from Aggregator for {}. Mithril Snapshots can not update. Sleeping.", + network, e + ); return None; }, }; // Get the current latest snapshot. let Some(latest_snapshot) = snapshots.first() else { - error!("Unexpected Error: Empty Snapshot List from Aggregator for {}. Mithril Snapshots can not update. Sleeping", network); + error!( + "Unexpected Error: Empty Snapshot List from Aggregator for {}. Mithril Snapshots can not update. Sleeping", + network + ); return None; }; @@ -80,7 +86,10 @@ async fn get_snapshot_by_id( let snapshots = match client.snapshot().list().await { Ok(s) => s, Err(e) => { - error!("Unexpected Error [{}]: Unable to get Snapshot List from Aggregator for {}. Mithril Snapshots can not update. Sleeping.", network, e); + error!( + "Unexpected Error [{}]: Unable to get Snapshot List from Aggregator for {}. Mithril Snapshots can not update. Sleeping.", + network, e + ); return None; }, }; @@ -112,7 +121,11 @@ fn create_client(cfg: &MithrilSnapshotConfig) -> Option<(Client, Arc c, Err(err) => { - error!(chain=cfg.chain.to_string(),"Unexpected Error [{}]: Unable to create Mithril Client. Mithril Snapshots can not update.", err); + error!( + chain = cfg.chain.to_string(), + "Unexpected Error [{}]: Unable to create Mithril Client. Mithril Snapshots can not update.", + err + ); return None; }, }; @@ -250,7 +263,6 @@ pub(crate) const MITHRIL_IMMUTABLE_SUB_DIRECTORY: &str = "immutable"; /// /// This function returns the tip block point, and the block point immediately proceeding /// it in a tuple. -#[allow(clippy::indexing_slicing)] #[logcall(ok = "debug", err = "error")] pub(crate) async fn get_mithril_tip(chain: Network, path: &Path) -> Result { let mut path = path.to_path_buf(); @@ -352,7 +364,9 @@ async fn get_latest_validated_mithril_snapshot( debug!("Purging Bad Mithril Snapshot: {latest_mithril}"); if let Err(error) = remove_dir_all(&latest_mithril).await { // This should NOT happen because we already checked the Mithril path is fully writable. - error!("Mithril Snapshot background updater for: {chain}: Failed to remove old snapshot {latest_mithril}: {error}"); + error!( + "Mithril Snapshot background updater for: {chain}: Failed to remove old snapshot {latest_mithril}: {error}" + ); } } @@ -374,7 +388,9 @@ async fn get_latest_validated_mithril_snapshot( let Some(snapshot) = get_snapshot_by_id(client, chain, &latest_mithril).await else { // We have a latest snapshot, but the Aggregator does not know it. - error!("Mithril Snapshot background updater for: {chain}: Latest snapshot {latest_mithril} does not exist on the Aggregator."); + error!( + "Mithril Snapshot background updater for: {chain}: Latest snapshot {latest_mithril} does not exist on the Aggregator." + ); purge_bad_mithril_snapshot(chain, &latest_mithril).await; return None; }; @@ -454,7 +470,10 @@ async fn recover_existing_snapshot( } }, Err(error) => { - error!("Mithril snapshot validation failed for: {}. Could not read the TIP Block : {}.", cfg.chain, error); + error!( + "Mithril snapshot validation failed for: {}. Could not read the TIP Block : {}.", + cfg.chain, error + ); }, } } else { @@ -496,14 +515,20 @@ async fn check_snapshot_to_download( return SnapshotStatus::Sleep(DOWNLOAD_ERROR_RETRY_DURATION); }; - debug!("Mithril Snapshot background updater for: {chain} : Checking if we are up-to-date {current_snapshot:?}."); + debug!( + "Mithril Snapshot background updater for: {chain} : Checking if we are up-to-date {current_snapshot:?}." + ); // Check if the latest snapshot is different from our actual previous one. if let Some(current_mithril_snapshot) = current_snapshot { let latest_immutable_file_number = latest_snapshot.beacon.immutable_file_number; - debug!("We have a current snapshot: {current_mithril_snapshot} == {latest_immutable_file_number} ??"); + debug!( + "We have a current snapshot: {current_mithril_snapshot} == {latest_immutable_file_number} ??" + ); if *current_mithril_snapshot == latest_immutable_file_number { - debug!("Current Snapshot and latest are the same, so wait for it to likely to have changed."); + debug!( + "Current Snapshot and latest are the same, so wait for it to likely to have changed." + ); let next_sleep = calculate_sleep_duration(&latest_snapshot, &chronologically_previous_snapshot); return SnapshotStatus::Sleep(next_sleep); diff --git a/rust/cardano-chain-follower/src/mithril_turbo_downloader.rs b/rust/cardano-chain-follower/src/mithril_turbo_downloader.rs index 88f41a1d18..d56f4307e6 100644 --- a/rust/cardano-chain-follower/src/mithril_turbo_downloader.rs +++ b/rust/cardano-chain-follower/src/mithril_turbo_downloader.rs @@ -7,8 +7,8 @@ use std::{ path::{Path, PathBuf}, // process::Stdio, sync::{ - atomic::{AtomicU64, Ordering}, Arc, OnceLock, + atomic::{AtomicU64, Ordering}, }, }; @@ -18,7 +18,7 @@ use catalyst_types::{conversion::from_saturating, mmap_file::MemoryMapFile}; use dashmap::DashSet; use memx::memcmp; use mithril_client::{ - common::CompressionAlgorithm, snapshot_downloader::SnapshotDownloader, MithrilResult, + MithrilResult, common::CompressionAlgorithm, snapshot_downloader::SnapshotDownloader, }; use tar::{Archive, EntryType}; use tokio::{fs::create_dir_all, task::spawn_blocking}; diff --git a/rust/cardano-chain-follower/src/snapshot_id.rs b/rust/cardano-chain-follower/src/snapshot_id.rs index 876a39c911..8c8e5b1d64 100644 --- a/rust/cardano-chain-follower/src/snapshot_id.rs +++ b/rust/cardano-chain-follower/src/snapshot_id.rs @@ -10,7 +10,7 @@ use std::{ use cardano_blockchain_types::{Network, Point}; use tracing::debug; -use crate::mithril_snapshot_sync::{get_mithril_tip, MITHRIL_IMMUTABLE_SUB_DIRECTORY}; +use crate::mithril_snapshot_sync::{MITHRIL_IMMUTABLE_SUB_DIRECTORY, get_mithril_tip}; /// A representation of a Snapshot Path and its represented immutable file number. #[derive(Clone, Debug)] pub(crate) struct SnapshotId { diff --git a/rust/cardano-chain-follower/src/stats/mod.rs b/rust/cardano-chain-follower/src/stats/mod.rs index 31e1ed014a..3a9ab31959 100644 --- a/rust/cardano-chain-follower/src/stats/mod.rs +++ b/rust/cardano-chain-follower/src/stats/mod.rs @@ -11,7 +11,7 @@ use std::sync::{Arc, LazyLock, RwLock}; use cardano_blockchain_types::{Network, Slot}; use chrono::Utc; use dashmap::DashMap; -use rollback::{rollbacks, rollbacks_reset, RollbackType}; +use rollback::{RollbackType, rollbacks, rollbacks_reset}; use serde::Serialize; use strum::IntoEnumIterator; use thread::ThreadStat; diff --git a/rust/cardano-chain-follower/src/stats/thread/mod.rs b/rust/cardano-chain-follower/src/stats/thread/mod.rs index e409e516f9..23516e1d75 100644 --- a/rust/cardano-chain-follower/src/stats/thread/mod.rs +++ b/rust/cardano-chain-follower/src/stats/thread/mod.rs @@ -5,16 +5,16 @@ pub(crate) mod name; use std::{ fmt, sync::{ - atomic::{AtomicBool, AtomicU64, Ordering}, Arc, Mutex, + atomic::{AtomicBool, AtomicU64, Ordering}, }, time::Duration, }; use cpu_time::ThreadTime; use serde::{ - ser::{SerializeStruct, Serializer}, Serialize, + ser::{SerializeStruct, Serializer}, }; use tracing::error; diff --git a/rust/cardano-chain-follower/src/turbo_downloader/mod.rs b/rust/cardano-chain-follower/src/turbo_downloader/mod.rs index f32155942a..2f693b80cb 100644 --- a/rust/cardano-chain-follower/src/turbo_downloader/mod.rs +++ b/rust/cardano-chain-follower/src/turbo_downloader/mod.rs @@ -11,21 +11,21 @@ use std::{ io::Read, net::SocketAddr, sync::{ - atomic::{AtomicU64, AtomicUsize, Ordering}, Arc, Mutex, OnceLock, + atomic::{AtomicU64, AtomicUsize, Ordering}, }, thread, time::Duration, }; -use anyhow::{anyhow, bail, Context, Result}; +use anyhow::{Context, Result, anyhow, bail}; use cardano_blockchain_types::Network; use catalyst_types::conversion::from_saturating; use crossbeam_channel::{Receiver, RecvError}; use dashmap::DashMap; use http::{ - header::{ACCEPT_RANGES, CONTENT_LENGTH, RANGE}, StatusCode, + header::{ACCEPT_RANGES, CONTENT_LENGTH, RANGE}, }; use tracing::{debug, error}; @@ -52,7 +52,10 @@ impl BalancingResolver { let resolver = match hickory_resolver::Resolver::from_system_conf() { Ok(r) => r, Err(e) => { - error!("Failed to initialize DNS Balancing Resolver from system configuration, using Google DNS as fallback: {}", e); + error!( + "Failed to initialize DNS Balancing Resolver from system configuration, using Google DNS as fallback: {}", + e + ); hickory_resolver::Resolver::new( hickory_resolver::config::ResolverConfig::default(), hickory_resolver::config::ResolverOpts::default(), diff --git a/rust/catalyst-types/src/id_uri/mod.rs b/rust/catalyst-types/src/id_uri/mod.rs index eb48425ebd..f396e785eb 100644 --- a/rust/catalyst-types/src/id_uri/mod.rs +++ b/rust/catalyst-types/src/id_uri/mod.rs @@ -14,12 +14,12 @@ use std::{ use chrono::{DateTime, Duration, Utc}; use ed25519_dalek::VerifyingKey; use fluent_uri::{ + Uri, component::Scheme, encoding::{ - encoder::{Fragment, Path}, EStr, + encoder::{Fragment, Path}, }, - Uri, }; use key_rotation::KeyRotation; use role_index::RoleIndex; @@ -321,7 +321,7 @@ impl IdUri { /// # Examples /// /// ```rust - /// use catalyst_types::id_uri::{role_index::RoleIndex, IdUri}; + /// use catalyst_types::id_uri::{IdUri, role_index::RoleIndex}; /// /// let id_uri = "id.catalyst://cardano/FftxFnOrj2qmTuB2oZG2v0YEWJfKvQ9Gg8AgNAhDsKE" /// .parse::() @@ -350,7 +350,7 @@ impl IdUri { /// /// # Examples /// ```rust - /// use catalyst_types::id_uri::{key_rotation::KeyRotation, IdUri}; + /// use catalyst_types::id_uri::{IdUri, key_rotation::KeyRotation}; /// /// let id_uri = "id.catalyst://cardano/FftxFnOrj2qmTuB2oZG2v0YEWJfKvQ9Gg8AgNAhDsKE" /// .parse::() @@ -441,7 +441,7 @@ impl IdUri { /// # Examples /// /// ```rust - /// use catalyst_types::id_uri::{key_rotation::KeyRotation, role_index::RoleIndex, IdUri}; + /// use catalyst_types::id_uri::{IdUri, key_rotation::KeyRotation, role_index::RoleIndex}; /// /// let id_uri = /// "id.catalyst://user:1735689600@cardano/FftxFnOrj2qmTuB2oZG2v0YEWJfKvQ9Gg8AgNAhDsKE/7/5" diff --git a/rust/catalyst-types/src/uuid/uuid_v4.rs b/rust/catalyst-types/src/uuid/uuid_v4.rs index c7e2dbb814..79da996a14 100644 --- a/rust/catalyst-types/src/uuid/uuid_v4.rs +++ b/rust/catalyst-types/src/uuid/uuid_v4.rs @@ -4,7 +4,7 @@ use std::fmt::{Display, Formatter}; use minicbor::{Decode, Decoder, Encode}; use uuid::Uuid; -use super::{decode_cbor_uuid, encode_cbor_uuid, CborContext, UuidError, INVALID_UUID}; +use super::{CborContext, INVALID_UUID, UuidError, decode_cbor_uuid, encode_cbor_uuid}; /// Type representing a `UUIDv4`. #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, serde::Serialize)] diff --git a/rust/catalyst-types/src/uuid/uuid_v7.rs b/rust/catalyst-types/src/uuid/uuid_v7.rs index 98fbd8cda6..d42a25185f 100644 --- a/rust/catalyst-types/src/uuid/uuid_v7.rs +++ b/rust/catalyst-types/src/uuid/uuid_v7.rs @@ -4,7 +4,7 @@ use std::fmt::{Display, Formatter}; use minicbor::{Decode, Decoder, Encode}; use uuid::Uuid; -use super::{decode_cbor_uuid, encode_cbor_uuid, CborContext, UuidError, INVALID_UUID}; +use super::{CborContext, INVALID_UUID, UuidError, decode_cbor_uuid, encode_cbor_uuid}; /// Type representing a `UUIDv7`. #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, serde::Serialize)] diff --git a/rust/catalyst-voting/benches/vote_protocol.rs b/rust/catalyst-voting/benches/vote_protocol.rs index 4c2c40f5bc..6a61642509 100644 --- a/rust/catalyst-voting/benches/vote_protocol.rs +++ b/rust/catalyst-voting/benches/vote_protocol.rs @@ -16,20 +16,19 @@ use catalyst_voting::{ vote_protocol::{ committee::{ElectionPublicKey, ElectionSecretKey}, tally::{ - decrypt_tally, + DecryptionTallySetup, decrypt_tally, proof::{generate_tally_proof, verify_tally_proof}, - tally, DecryptionTallySetup, + tally, }, voter::{ - encrypt_vote, - proof::{generate_voter_proof, verify_voter_proof, VoterProofCommitment}, - Vote, + Vote, encrypt_vote, + proof::{VoterProofCommitment, generate_voter_proof, verify_voter_proof}, }, }, }; -use criterion::{criterion_group, criterion_main, Criterion}; +use criterion::{Criterion, criterion_group, criterion_main}; use proptest::{ - prelude::{any_with, Strategy}, + prelude::{Strategy, any_with}, sample::size_range, strategy::ValueTree, test_runner::TestRunner, diff --git a/rust/catalyst-voting/src/crypto/ed25519/decoding.rs b/rust/catalyst-voting/src/crypto/ed25519/decoding.rs index f40bf54163..6c05c73e5d 100644 --- a/rust/catalyst-voting/src/crypto/ed25519/decoding.rs +++ b/rust/catalyst-voting/src/crypto/ed25519/decoding.rs @@ -2,8 +2,8 @@ use anyhow::anyhow; use ed25519_dalek::{ - Signature as Ed25519Signature, SigningKey, VerifyingKey, PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH, - SIGNATURE_LENGTH, + PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH, SIGNATURE_LENGTH, Signature as Ed25519Signature, + SigningKey, VerifyingKey, }; use super::{PrivateKey, PublicKey, Signature}; diff --git a/rust/catalyst-voting/src/crypto/ed25519/mod.rs b/rust/catalyst-voting/src/crypto/ed25519/mod.rs index a2066ad4dd..dfb63a4fd9 100644 --- a/rust/catalyst-voting/src/crypto/ed25519/mod.rs +++ b/rust/catalyst-voting/src/crypto/ed25519/mod.rs @@ -3,7 +3,7 @@ mod decoding; use ed25519_dalek::{ - ed25519::signature::Signer, Signature as Ed25519Signature, SigningKey, VerifyingKey, + Signature as Ed25519Signature, SigningKey, VerifyingKey, ed25519::signature::Signer, }; use super::rng::default_rng; @@ -54,7 +54,7 @@ pub fn verify_signature(pk: &PublicKey, msg: &[u8], sig: &Signature) -> bool { #[cfg(test)] mod arbitrary_impl { - use proptest::prelude::{any, Arbitrary, BoxedStrategy, Strategy}; + use proptest::prelude::{Arbitrary, BoxedStrategy, Strategy, any}; use super::{PrivateKey, SigningKey}; diff --git a/rust/catalyst-voting/src/crypto/group/ristretto255/mod.rs b/rust/catalyst-voting/src/crypto/group/ristretto255/mod.rs index 93ffe6ac65..73e37767aa 100644 --- a/rust/catalyst-voting/src/crypto/group/ristretto255/mod.rs +++ b/rust/catalyst-voting/src/crypto/group/ristretto255/mod.rs @@ -10,14 +10,14 @@ use std::{ }; use curve25519_dalek::{ + RistrettoPoint, constants::{RISTRETTO_BASEPOINT_POINT, RISTRETTO_BASEPOINT_TABLE}, scalar::Scalar as IScalar, traits::Identity, - RistrettoPoint, }; use crate::crypto::{ - hash::digest::{consts::U64, Digest}, + hash::digest::{Digest, consts::U64}, rng::rand_core::CryptoRngCore, }; diff --git a/rust/catalyst-voting/src/crypto/hash.rs b/rust/catalyst-voting/src/crypto/hash.rs index 7ce3fe6f0b..a5877b617f 100644 --- a/rust/catalyst-voting/src/crypto/hash.rs +++ b/rust/catalyst-voting/src/crypto/hash.rs @@ -2,9 +2,9 @@ pub use curve25519_dalek::digest; use digest::{ + FixedOutput, HashMarker, Output, OutputSizeUser, Update, consts::{U32, U64}, typenum::Unsigned, - FixedOutput, HashMarker, Output, OutputSizeUser, Update, }; /// Blake2b-512 hasher instance. diff --git a/rust/catalyst-voting/src/crypto/zk_dl_equality.rs b/rust/catalyst-voting/src/crypto/zk_dl_equality.rs index 21d3e807d0..615e1948e5 100644 --- a/rust/catalyst-voting/src/crypto/zk_dl_equality.rs +++ b/rust/catalyst-voting/src/crypto/zk_dl_equality.rs @@ -14,7 +14,7 @@ use crate::crypto::{ group::{GroupElement, Scalar}, - hash::{digest::Digest, Blake2b512Hasher}, + hash::{Blake2b512Hasher, digest::Digest}, }; /// DLEQ proof struct diff --git a/rust/catalyst-voting/src/crypto/zk_unit_vector/challenges.rs b/rust/catalyst-voting/src/crypto/zk_unit_vector/challenges.rs index 35632a68f0..6cb57794a0 100644 --- a/rust/catalyst-voting/src/crypto/zk_unit_vector/challenges.rs +++ b/rust/catalyst-voting/src/crypto/zk_unit_vector/challenges.rs @@ -3,7 +3,7 @@ use crate::crypto::{ elgamal::Ciphertext, group::GroupElement, - hash::{digest::Digest, Blake2b512Hasher}, + hash::{Blake2b512Hasher, digest::Digest}, zk_unit_vector::randomness_announcements::Announcement, }; diff --git a/rust/catalyst-voting/src/crypto/zk_unit_vector/mod.rs b/rust/catalyst-voting/src/crypto/zk_unit_vector/mod.rs index 5a6a7881c6..164bad7cef 100644 --- a/rust/catalyst-voting/src/crypto/zk_unit_vector/mod.rs +++ b/rust/catalyst-voting/src/crypto/zk_unit_vector/mod.rs @@ -15,13 +15,13 @@ mod utils; use std::ops::Mul; use challenges::{calculate_first_challenge_hash, calculate_second_challenge_hash}; -use polynomial::{calculate_polynomial_val, generate_polynomial, Polynomial}; +use polynomial::{Polynomial, calculate_polynomial_val, generate_polynomial}; use randomness_announcements::{Announcement, BlindingRandomness, ResponseRandomness}; use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator}; use utils::get_bit; use crate::crypto::{ - elgamal::{encrypt, Ciphertext}, + elgamal::{Ciphertext, encrypt}, group::{GroupElement, Scalar}, rng::rand_core::CryptoRngCore, }; @@ -238,7 +238,7 @@ fn check_2( #[cfg(test)] mod arbitrary_impl { use proptest::{ - prelude::{any_with, Arbitrary, BoxedStrategy, Strategy}, + prelude::{Arbitrary, BoxedStrategy, Strategy, any_with}, sample::size_range, }; diff --git a/rust/catalyst-voting/src/vote_protocol/committee/mod.rs b/rust/catalyst-voting/src/vote_protocol/committee/mod.rs index 5f26aa4812..4a66ab61b4 100644 --- a/rust/catalyst-voting/src/vote_protocol/committee/mod.rs +++ b/rust/catalyst-voting/src/vote_protocol/committee/mod.rs @@ -38,7 +38,7 @@ pub struct ElectionPublicKey(pub(crate) GroupElement); #[cfg(test)] mod arbitrary_impl { - use proptest::prelude::{any, Arbitrary, BoxedStrategy, Strategy}; + use proptest::prelude::{Arbitrary, BoxedStrategy, Strategy, any}; use super::{ElectionSecretKey, Scalar}; diff --git a/rust/catalyst-voting/src/vote_protocol/mod.rs b/rust/catalyst-voting/src/vote_protocol/mod.rs index 1856d50082..249fad7917 100644 --- a/rust/catalyst-voting/src/vote_protocol/mod.rs +++ b/rust/catalyst-voting/src/vote_protocol/mod.rs @@ -4,16 +4,15 @@ //! use catalyst_voting::vote_protocol::{ //! committee::ElectionSecretKey, //! tally::{ -//! decrypt_tally, +//! DecryptionTallySetup, decrypt_tally, //! proof::{generate_tally_proof_with_default_rng, verify_tally_proof}, -//! tally, DecryptionTallySetup, +//! tally, //! }, //! voter::{ -//! encrypt_vote_with_default_rng, +//! Vote, encrypt_vote_with_default_rng, //! proof::{ -//! generate_voter_proof_with_default_rng, verify_voter_proof, VoterProofCommitment, +//! VoterProofCommitment, generate_voter_proof_with_default_rng, verify_voter_proof, //! }, -//! Vote, //! }, //! }; //! diff --git a/rust/catalyst-voting/src/vote_protocol/tally/mod.rs b/rust/catalyst-voting/src/vote_protocol/tally/mod.rs index 6613d6de75..3a3b33e53d 100644 --- a/rust/catalyst-voting/src/vote_protocol/tally/mod.rs +++ b/rust/catalyst-voting/src/vote_protocol/tally/mod.rs @@ -10,7 +10,7 @@ use super::committee::ElectionSecretKey; use crate::{ crypto::{ babystep_giantstep::BabyStepGiantStep, - elgamal::{decrypt, Ciphertext}, + elgamal::{Ciphertext, decrypt}, group::Scalar, }, vote_protocol::voter::EncryptedVote, diff --git a/rust/catalyst-voting/src/vote_protocol/tally/proof.rs b/rust/catalyst-voting/src/vote_protocol/tally/proof.rs index fbc8a16f30..7c8345b068 100644 --- a/rust/catalyst-voting/src/vote_protocol/tally/proof.rs +++ b/rust/catalyst-voting/src/vote_protocol/tally/proof.rs @@ -8,7 +8,7 @@ use crate::{ crypto::{ group::{GroupElement, Scalar}, rng::{default_rng, rand_core::CryptoRngCore}, - zk_dl_equality::{generate_dleq_proof, verify_dleq_proof, DleqProof}, + zk_dl_equality::{DleqProof, generate_dleq_proof, verify_dleq_proof}, }, vote_protocol::committee::{ElectionPublicKey, ElectionSecretKey}, }; diff --git a/rust/catalyst-voting/src/vote_protocol/voter/decoding.rs b/rust/catalyst-voting/src/vote_protocol/voter/decoding.rs index 8924d52513..2a42498a9e 100644 --- a/rust/catalyst-voting/src/vote_protocol/voter/decoding.rs +++ b/rust/catalyst-voting/src/vote_protocol/voter/decoding.rs @@ -4,7 +4,7 @@ use std::io::Read; use anyhow::anyhow; -use super::{proof::VoterProof, EncryptedVote}; +use super::{EncryptedVote, proof::VoterProof}; use crate::{ crypto::{elgamal::Ciphertext, zk_unit_vector::UnitVectorProof}, utils::read_array, diff --git a/rust/catalyst-voting/src/vote_protocol/voter/mod.rs b/rust/catalyst-voting/src/vote_protocol/voter/mod.rs index 6277dbd364..5d4962d700 100644 --- a/rust/catalyst-voting/src/vote_protocol/voter/mod.rs +++ b/rust/catalyst-voting/src/vote_protocol/voter/mod.rs @@ -9,7 +9,7 @@ use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIter use super::committee::{ElectionPublicKey, ElectionSecretKey}; use crate::crypto::{ babystep_giantstep::BabyStepGiantStep, - elgamal::{decrypt, encrypt, Ciphertext}, + elgamal::{Ciphertext, decrypt, encrypt}, group::Scalar, rng::{default_rng, rand_core::CryptoRngCore}, }; @@ -56,7 +56,10 @@ impl Vote { /// - Invalid voting choice, the value of `choice`, should be less than the number /// of `voting_options`. pub fn new(choice: usize, voting_options: usize) -> anyhow::Result { - ensure!(choice < voting_options,"Invalid voting choice, the value of choice: {choice}, should be less than the number of voting options: {voting_options}." ); + ensure!( + choice < voting_options, + "Invalid voting choice, the value of choice: {choice}, should be less than the number of voting options: {voting_options}." + ); Ok(Vote { choice, @@ -144,7 +147,7 @@ pub fn decrypt_vote(vote: &EncryptedVote, secret_key: &ElectionSecretKey) -> any #[cfg(test)] mod arbitrary_impl { use proptest::{ - prelude::{any_with, Arbitrary, BoxedStrategy, Strategy}, + prelude::{Arbitrary, BoxedStrategy, Strategy, any_with}, sample::size_range, }; diff --git a/rust/catalyst-voting/src/vote_protocol/voter/proof.rs b/rust/catalyst-voting/src/vote_protocol/voter/proof.rs index 2c68a7f3ff..c5eaf80511 100644 --- a/rust/catalyst-voting/src/vote_protocol/voter/proof.rs +++ b/rust/catalyst-voting/src/vote_protocol/voter/proof.rs @@ -9,9 +9,9 @@ use super::{EncryptedVote, EncryptionRandomness, Vote}; use crate::{ crypto::{ group::{GroupElement, Scalar}, - hash::digest::{consts::U64, Digest}, + hash::digest::{Digest, consts::U64}, rng::{default_rng, rand_core::CryptoRngCore}, - zk_unit_vector::{generate_unit_vector_proof, verify_unit_vector_proof, UnitVectorProof}, + zk_unit_vector::{UnitVectorProof, generate_unit_vector_proof, verify_unit_vector_proof}, }, vote_protocol::committee::ElectionPublicKey, }; @@ -109,7 +109,7 @@ pub fn verify_voter_proof( #[cfg(test)] mod arbitrary_impl { - use proptest::prelude::{any_with, Arbitrary, BoxedStrategy, Strategy}; + use proptest::prelude::{Arbitrary, BoxedStrategy, Strategy, any_with}; use super::{UnitVectorProof, VoterProof}; diff --git a/rust/catalyst-voting/tests/voting_test.rs b/rust/catalyst-voting/tests/voting_test.rs index 1e699bd4b8..51cc0c351e 100644 --- a/rust/catalyst-voting/tests/voting_test.rs +++ b/rust/catalyst-voting/tests/voting_test.rs @@ -3,18 +3,17 @@ use catalyst_voting::vote_protocol::{ committee::ElectionSecretKey, tally::{ - decrypt_tally, + DecryptionTallySetup, decrypt_tally, proof::{generate_tally_proof_with_default_rng, verify_tally_proof}, - tally, DecryptionTallySetup, + tally, }, voter::{ - decrypt_vote, encrypt_vote_with_default_rng, - proof::{generate_voter_proof_with_default_rng, verify_voter_proof, VoterProofCommitment}, - Vote, + Vote, decrypt_vote, encrypt_vote_with_default_rng, + proof::{VoterProofCommitment, generate_voter_proof_with_default_rng, verify_voter_proof}, }, }; use proptest::prelude::ProptestConfig; -use test_strategy::{proptest, Arbitrary}; +use test_strategy::{Arbitrary, proptest}; const VOTING_OPTIONS: usize = 3; const VOTERS_NUMBER: usize = 100; diff --git a/rust/cbork-cddl-parser/src/parser.rs b/rust/cbork-cddl-parser/src/parser.rs index ae4b16ed2b..5c29d7754f 100644 --- a/rust/cbork-cddl-parser/src/parser.rs +++ b/rust/cbork-cddl-parser/src/parser.rs @@ -1,7 +1,7 @@ //! A parser for CDDL using the [pest](https://github.com/pest-parser/pest). //! Utilized for parsing in accordance with RFC-8610, RFC-9165. -use pest::{iterators::Pair, Parser}; +use pest::{Parser, iterators::Pair}; use crate::Extension; diff --git a/rust/cbork-cddl-parser/src/preprocessor.rs b/rust/cbork-cddl-parser/src/preprocessor.rs index b20cc849de..bd347ca86c 100644 --- a/rust/cbork-cddl-parser/src/preprocessor.rs +++ b/rust/cbork-cddl-parser/src/preprocessor.rs @@ -6,9 +6,9 @@ //! into the final expression list use anyhow::{anyhow, ensure}; -use pest::{iterators::Pair, RuleType}; +use pest::{RuleType, iterators::Pair}; -use crate::parser::{cddl, rfc_8610, rfc_9165, Ast}; +use crate::parser::{Ast, cddl, rfc_8610, rfc_9165}; /// Processes the AST. pub(crate) fn process_ast(ast: Ast) -> anyhow::Result { diff --git a/rust/cbork-cddl-parser/tests/byte_sequences.rs b/rust/cbork-cddl-parser/tests/byte_sequences.rs index 48d6f819ed..d0e162e8a9 100644 --- a/rust/cbork-cddl-parser/tests/byte_sequences.rs +++ b/rust/cbork-cddl-parser/tests/byte_sequences.rs @@ -2,7 +2,7 @@ // cspell: words hexpair rstuvw abcdefghijklmnopqrstuvwyz rstuvw Xhhb Bhcm mod common; -use common::{byte_sequences::*, Rule}; +use common::{Rule, byte_sequences::*}; #[test] /// Test if the `HEX_PAIR` rule passes properly. diff --git a/rust/cbork-cddl-parser/tests/cddl.rs b/rust/cbork-cddl-parser/tests/cddl.rs index d66408d7e1..f9d5b0065a 100644 --- a/rust/cbork-cddl-parser/tests/cddl.rs +++ b/rust/cbork-cddl-parser/tests/cddl.rs @@ -1,7 +1,7 @@ //! CDDL Parser Tests use std::{ffi::OsStr, fs, io::Result}; -use cbork_cddl_parser::{validate_cddl, Extension}; +use cbork_cddl_parser::{Extension, validate_cddl}; #[test] /// # Panics diff --git a/rust/cbork-cddl-parser/tests/comments.rs b/rust/cbork-cddl-parser/tests/comments.rs index 142e7a0670..d0364ade49 100644 --- a/rust/cbork-cddl-parser/tests/comments.rs +++ b/rust/cbork-cddl-parser/tests/comments.rs @@ -1,6 +1,6 @@ //! Comment Tests mod common; -use common::{comments::*, Rule}; +use common::{Rule, comments::*}; #[test] /// Test if the `COMMENT` rule passes properly. diff --git a/rust/cbork-cddl-parser/tests/group_elements.rs b/rust/cbork-cddl-parser/tests/group_elements.rs index 3f7bf0131e..dbb49766f7 100644 --- a/rust/cbork-cddl-parser/tests/group_elements.rs +++ b/rust/cbork-cddl-parser/tests/group_elements.rs @@ -3,7 +3,7 @@ // cspell: words optcom memberkey grpent grpchoice mod common; -use common::{group_elements::*, identifiers::*, Rule}; +use common::{Rule, group_elements::*, identifiers::*}; #[test] /// Test if the `occur` rule passes properly. diff --git a/rust/cbork-cddl-parser/tests/identifiers.rs b/rust/cbork-cddl-parser/tests/identifiers.rs index a6d69eefc3..e5f4b864e5 100644 --- a/rust/cbork-cddl-parser/tests/identifiers.rs +++ b/rust/cbork-cddl-parser/tests/identifiers.rs @@ -2,7 +2,7 @@ // cspell: words aname groupsocket typesocket groupsocket mod common; -use common::{identifiers::*, Rule}; +use common::{Rule, identifiers::*}; /// Check if the name components pass properly. #[test] diff --git a/rust/cbork-cddl-parser/tests/literal_values.rs b/rust/cbork-cddl-parser/tests/literal_values.rs index 782968ce35..c955e5d5d0 100644 --- a/rust/cbork-cddl-parser/tests/literal_values.rs +++ b/rust/cbork-cddl-parser/tests/literal_values.rs @@ -3,7 +3,7 @@ use std::ops::Deref; mod common; -use common::{byte_sequences::*, literal_values::*, text_sequences::*, Rule}; +use common::{Rule, byte_sequences::*, literal_values::*, text_sequences::*}; #[test] /// Test if the `uint` rule passes properly. diff --git a/rust/cbork-cddl-parser/tests/rules.rs b/rust/cbork-cddl-parser/tests/rules.rs index 467db5c4cd..c7ba682af0 100644 --- a/rust/cbork-cddl-parser/tests/rules.rs +++ b/rust/cbork-cddl-parser/tests/rules.rs @@ -3,7 +3,7 @@ // cspell: words assigng assignt ASSIGNT GENERICPARM genericparm mod common; -use common::{rules::*, type_declarations::*, Rule}; +use common::{Rule, rules::*, type_declarations::*}; /// Test if the `genericarg` rule passes properly. /// This uses a special rule in the Grammar to test `genericarg` exhaustively. diff --git a/rust/cbork-cddl-parser/tests/text_sequences.rs b/rust/cbork-cddl-parser/tests/text_sequences.rs index 5e4e267895..c6efc1f1cd 100644 --- a/rust/cbork-cddl-parser/tests/text_sequences.rs +++ b/rust/cbork-cddl-parser/tests/text_sequences.rs @@ -1,6 +1,6 @@ //! Text Sequence Tests mod common; -use common::{text_sequences::*, Rule}; +use common::{Rule, text_sequences::*}; #[test] /// Test if the `S` rule passes properly. diff --git a/rust/cbork-cddl-parser/tests/type_declarations.rs b/rust/cbork-cddl-parser/tests/type_declarations.rs index c23c19e4fd..768869cbd0 100644 --- a/rust/cbork-cddl-parser/tests/type_declarations.rs +++ b/rust/cbork-cddl-parser/tests/type_declarations.rs @@ -3,7 +3,7 @@ // cspell: words rangeop RANGEOP mod common; -use common::{type_declarations::*, Rule}; +use common::{Rule, type_declarations::*}; /// Test if the `ctlop` rule passes properly. /// This uses a special rule in the Grammar to test `ctlop` exhaustively. diff --git a/rust/cbork-utils/src/decode_helper.rs b/rust/cbork-utils/src/decode_helper.rs index 1a8ab480f1..3a63cd156d 100644 --- a/rust/cbork-utils/src/decode_helper.rs +++ b/rust/cbork-utils/src/decode_helper.rs @@ -1,6 +1,6 @@ //! CBOR decoding helper functions. -use minicbor::{data::Tag, decode, Decoder}; +use minicbor::{Decoder, data::Tag, decode}; /// Generic helper function for decoding different types. /// diff --git a/rust/cbork/src/cli.rs b/rust/cbork/src/cli.rs index 01f3fea97a..88e5d5e9d4 100644 --- a/rust/cbork/src/cli.rs +++ b/rust/cbork/src/cli.rs @@ -2,9 +2,9 @@ use std::{path::PathBuf, process::exit}; -use cbork_cddl_parser::{validate_cddl, Extension}; +use cbork_cddl_parser::{Extension, validate_cddl}; use clap::Parser; -use console::{style, Emoji}; +use console::{Emoji, style}; /// CDDL linter cli tool #[derive(Parser)] diff --git a/rust/clippy.toml b/rust/clippy.toml index caa289b27b..a03fd62fdb 100644 --- a/rust/clippy.toml +++ b/rust/clippy.toml @@ -1,4 +1,5 @@ allow-unwrap-in-tests = true allow-expect-in-tests = true allow-panic-in-tests = true +allow-indexing-slicing-in-tests = true arithmetic-side-effects-allowed = ["num_bigint::BigInt"] diff --git a/rust/deny.toml b/rust/deny.toml index 8966bb9560..ca7ed44ecb 100644 --- a/rust/deny.toml +++ b/rust/deny.toml @@ -58,13 +58,12 @@ allow-git = [ "https://github.com/txpipe/kes", "https://github.com/txpipe/curve25519-dalek", "https://github.com/input-output-hk/mithril", - "https://github.com/orxfun/orx-pseudo-default", ] [licenses] version = 2 # Don't warn if a listed license isn't found -unused-allowed-license="allow" +unused-allowed-license = "allow" # We want really high confidence when inferring licenses from text confidence-threshold = 0.93 allow = [ diff --git a/rust/hermes-ipfs/examples/pubsub.rs b/rust/hermes-ipfs/examples/pubsub.rs index 58a8253387..b3141743d0 100644 --- a/rust/hermes-ipfs/examples/pubsub.rs +++ b/rust/hermes-ipfs/examples/pubsub.rs @@ -14,7 +14,7 @@ //! * The task that reads lines from stdin and publishes them as either node. use std::io::Write; -use hermes_ipfs::{pin_mut, FutureExt, HermesIpfs, StreamExt}; +use hermes_ipfs::{FutureExt, HermesIpfs, StreamExt, pin_mut}; use rust_ipfs::PubsubEvent; use rustyline_async::Readline; diff --git a/rust/hermes-ipfs/src/lib.rs b/rust/hermes-ipfs/src/lib.rs index 30f1de11bd..285188436f 100644 --- a/rust/hermes-ipfs/src/lib.rs +++ b/rust/hermes-ipfs/src/lib.rs @@ -11,12 +11,6 @@ pub use ipld_core::cid::Cid; pub use ipld_core::ipld::Ipld; /// `rust_ipfs` re-export. pub use rust_ipfs; -/// libp2p re-exports. -pub use rust_ipfs::libp2p::futures::{pin_mut, stream::BoxStream, FutureExt, StreamExt}; -/// Peer Info type. -pub use rust_ipfs::p2p::PeerInfo; -/// Enum for specifying paths in IPFS. -pub use rust_ipfs::path::IpfsPath; /// Server, Client, or Auto mode pub use rust_ipfs::DhtMode; /// Server, Client, or Auto mode @@ -31,11 +25,17 @@ pub use rust_ipfs::StorageType; pub use rust_ipfs::SubscriptionStream; /// Builder type for IPFS Node configuration. use rust_ipfs::UninitializedIpfsDefault as UninitializedIpfs; +/// libp2p re-exports. +pub use rust_ipfs::libp2p::futures::{FutureExt, StreamExt, pin_mut, stream::BoxStream}; +/// Peer Info type. +pub use rust_ipfs::p2p::PeerInfo; +/// Enum for specifying paths in IPFS. +pub use rust_ipfs::path::IpfsPath; use rust_ipfs::{ + PubsubEvent, Quorum, dag::ResolveError, libp2p::gossipsub::{Message as PubsubMessage, MessageId as PubsubMessageId}, unixfs::AddOpt, - PubsubEvent, Quorum, }; #[derive(Debug, Display, From, Into)] diff --git a/rust/immutable-ledger/src/serialize.rs b/rust/immutable-ledger/src/serialize.rs index 53fb9cb906..e95953909b 100644 --- a/rust/immutable-ledger/src/serialize.rs +++ b/rust/immutable-ledger/src/serialize.rs @@ -2,7 +2,7 @@ //! Block structure -use anyhow::{anyhow, bail, Ok}; +use anyhow::{Ok, anyhow, bail}; use blake2b_simd::{self, Params}; use uuid::Uuid; @@ -194,10 +194,10 @@ impl Block { // chain_id MUST be the same as for the previous block (except for genesis). if self.block_header.chain_id != previous_block.block_header.chain_id { return Err(anyhow::anyhow!( - "Module: Immutable ledger, Message: Chain_id MUST be the same as for the previous block {:?} {:?}", - self.block_header, - previous_block.block_header - )); + "Module: Immutable ledger, Message: Chain_id MUST be the same as for the previous block {:?} {:?}", + self.block_header, + previous_block.block_header + )); }; // height MUST be incremented by 1 from the previous block height value (except for @@ -280,9 +280,9 @@ impl Block { if self.block_header.previous_block_hash.1 != genesis_to_prev_hash { return Err(anyhow::anyhow!( - "Module: Immutable ledger, Message: Genesis block prev hash is invalid {:?}", - self.block_header, - )); + "Module: Immutable ledger, Message: Genesis block prev hash is invalid {:?}", + self.block_header, + )); } } } @@ -587,13 +587,13 @@ impl GenesisPreviousHash { #[allow(clippy::items_after_statements)] mod tests { - use ed25519_dalek::{Signature, Signer, SigningKey, SECRET_KEY_LENGTH}; + use ed25519_dalek::{SECRET_KEY_LENGTH, Signature, Signer, SigningKey}; use test_strategy::proptest; use uuid::Uuid; use super::{BlockHeader, Kid}; use crate::serialize::{ - blake2b_512, Block, BlockData, GenesisPreviousHash, HashFunction::Blake2b, Signatures, + Block, BlockData, GenesisPreviousHash, HashFunction::Blake2b, Signatures, blake2b_512, }; #[proptest] diff --git a/rust/rbac-registration/src/cardano/cip509/cip509.rs b/rust/rbac-registration/src/cardano/cip509/cip509.rs index 8de68fd704..ebcef962d8 100644 --- a/rust/rbac-registration/src/cardano/cip509/cip509.rs +++ b/rust/rbac-registration/src/cardano/cip509/cip509.rs @@ -4,19 +4,19 @@ use std::{borrow::Cow, collections::HashMap}; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use cardano_blockchain_types::{MetadatumLabel, MultiEraBlock, TransactionId, TxnIndex}; use catalyst_types::{ cbor_utils::{report_duplicated_key, report_missing_keys}, - hashes::{Blake2b256Hash, BLAKE_2B256_SIZE}, + hashes::{BLAKE_2B256_SIZE, Blake2b256Hash}, id_uri::IdUri, problem_report::ProblemReport, uuid::UuidV4, }; use cbork_utils::decode_helper::{decode_bytes, decode_helper, decode_map_len}; use minicbor::{ - decode::{self}, Decode, Decoder, + decode::{self}, }; use pallas::{ codec::utils::Nullable, @@ -31,6 +31,7 @@ use tracing::warn; use uuid::Uuid; use crate::cardano::cip509::{ + Payment, PointTxnIdx, RoleData, decode_context::DecodeContext, rbac::Cip509RbacMetadata, types::{PaymentHistory, RoleNumber, TxInputHash, ValidationSignature}, @@ -39,7 +40,6 @@ use crate::cardano::cip509::{ validate_aux, validate_role_data, validate_stake_public_key, validate_txn_inputs_hash, }, x509_chunks::X509Chunks, - Payment, PointTxnIdx, RoleData, }; /// A x509 metadata envelope. diff --git a/rust/rbac-registration/src/cardano/cip509/rbac/certs/c509.rs b/rust/rbac-registration/src/cardano/cip509/rbac/certs/c509.rs index 4911c7d974..839089cdcb 100644 --- a/rust/rbac-registration/src/cardano/cip509/rbac/certs/c509.rs +++ b/rust/rbac-registration/src/cardano/cip509/rbac/certs/c509.rs @@ -3,7 +3,7 @@ use c509_certificate::c509::C509; use catalyst_types::problem_report::ProblemReport; use cbork_utils::decode_helper::{decode_array_len, decode_bytes, decode_tag}; -use minicbor::{decode, Decode, Decoder}; +use minicbor::{Decode, Decoder, decode}; use crate::cardano::cip509::rbac::{certs::C509CertInMetadatumReference, tag::KeyTag}; diff --git a/rust/rbac-registration/src/cardano/cip509/rbac/certs/c509_metadatum.rs b/rust/rbac-registration/src/cardano/cip509/rbac/certs/c509_metadatum.rs index 7720867c7a..fa420e1cf2 100644 --- a/rust/rbac-registration/src/cardano/cip509/rbac/certs/c509_metadatum.rs +++ b/rust/rbac-registration/src/cardano/cip509/rbac/certs/c509_metadatum.rs @@ -1,7 +1,7 @@ //! C509 certificate in metadatum reference. use cbork_utils::decode_helper::{decode_array_len, decode_helper}; -use minicbor::{decode, Decode, Decoder}; +use minicbor::{Decode, Decoder, decode}; /// C509 certificate in metadatum reference. #[derive(Debug, PartialEq, Clone)] diff --git a/rust/rbac-registration/src/cardano/cip509/rbac/certs/x509.rs b/rust/rbac-registration/src/cardano/cip509/rbac/certs/x509.rs index abdbfcf015..e5593033bf 100644 --- a/rust/rbac-registration/src/cardano/cip509/rbac/certs/x509.rs +++ b/rust/rbac-registration/src/cardano/cip509/rbac/certs/x509.rs @@ -2,8 +2,8 @@ use catalyst_types::problem_report::ProblemReport; use cbork_utils::decode_helper::{decode_bytes, decode_tag}; -use minicbor::{decode, Decode, Decoder}; -use x509_cert::{der::Decode as x509Decode, Certificate}; +use minicbor::{Decode, Decoder, decode}; +use x509_cert::{Certificate, der::Decode as x509Decode}; use crate::cardano::cip509::rbac::tag::KeyTag; diff --git a/rust/rbac-registration/src/cardano/cip509/rbac/metadata.rs b/rust/rbac-registration/src/cardano/cip509/rbac/metadata.rs index df1aac5df6..c2d527af4c 100644 --- a/rust/rbac-registration/src/cardano/cip509/rbac/metadata.rs +++ b/rust/rbac-registration/src/cardano/cip509/rbac/metadata.rs @@ -6,14 +6,14 @@ use catalyst_types::{cbor_utils::report_duplicated_key, problem_report::ProblemR use cbork_utils::decode_helper::{ decode_any, decode_array_len, decode_bytes, decode_helper, decode_map_len, }; -use minicbor::{decode, Decode, Decoder}; +use minicbor::{Decode, Decoder, decode}; use strum_macros::FromRepr; use crate::cardano::cip509::{ + CertKeyHash, RoleData, RoleNumber, decode_context::DecodeContext, - rbac::{role_data::CborRoleData, C509Cert, SimplePublicKeyType, X509DerCert}, + rbac::{C509Cert, SimplePublicKeyType, X509DerCert, role_data::CborRoleData}, utils::Cip0134UriSet, - CertKeyHash, RoleData, RoleNumber, }; /// Cip509 RBAC metadata. diff --git a/rust/rbac-registration/src/cardano/cip509/rbac/pub_key.rs b/rust/rbac-registration/src/cardano/cip509/rbac/pub_key.rs index e3abfe0aa1..9fe2458b62 100644 --- a/rust/rbac-registration/src/cardano/cip509/rbac/pub_key.rs +++ b/rust/rbac-registration/src/cardano/cip509/rbac/pub_key.rs @@ -3,7 +3,7 @@ use catalyst_types::problem_report::ProblemReport; use cbork_utils::decode_helper::{decode_bytes, decode_tag}; use ed25519_dalek::VerifyingKey; -use minicbor::{decode, Decode, Decoder}; +use minicbor::{Decode, Decoder, decode}; use super::tag::KeyTag; diff --git a/rust/rbac-registration/src/cardano/cip509/rbac/role_data.rs b/rust/rbac-registration/src/cardano/cip509/rbac/role_data.rs index 7a46a4259b..1d51492902 100644 --- a/rust/rbac-registration/src/cardano/cip509/rbac/role_data.rs +++ b/rust/rbac-registration/src/cardano/cip509/rbac/role_data.rs @@ -7,7 +7,7 @@ use catalyst_types::{ problem_report::ProblemReport, }; use cbork_utils::decode_helper::{decode_any, decode_array_len, decode_helper, decode_map_len}; -use minicbor::{decode, Decode, Decoder}; +use minicbor::{Decode, Decoder, decode}; use strum_macros::FromRepr; use crate::cardano::cip509::{KeyLocalRef, RoleNumber}; diff --git a/rust/rbac-registration/src/cardano/cip509/types/key_local_ref.rs b/rust/rbac-registration/src/cardano/cip509/types/key_local_ref.rs index f8cc933e7f..ab58f1fee8 100644 --- a/rust/rbac-registration/src/cardano/cip509/types/key_local_ref.rs +++ b/rust/rbac-registration/src/cardano/cip509/types/key_local_ref.rs @@ -1,7 +1,7 @@ //! A local key reference. use cbork_utils::decode_helper::decode_helper; -use minicbor::{decode, Decode, Decoder}; +use minicbor::{Decode, Decoder, decode}; use strum_macros::FromRepr; use crate::cardano::cip509::rbac::Cip509RbacMetadataInt; diff --git a/rust/rbac-registration/src/cardano/cip509/types/role_data.rs b/rust/rbac-registration/src/cardano/cip509/types/role_data.rs index 7938f8a4d8..0029cc9507 100644 --- a/rust/rbac-registration/src/cardano/cip509/types/role_data.rs +++ b/rust/rbac-registration/src/cardano/cip509/types/role_data.rs @@ -11,9 +11,9 @@ use pallas::ledger::{ }; use crate::cardano::cip509::{ + KeyLocalRef, RoleNumber, rbac::role_data::CborRoleData, utils::cip19::{compare_key_hash, extract_key_hash}, - KeyLocalRef, RoleNumber, }; /// A role data. diff --git a/rust/rbac-registration/src/cardano/cip509/types/validation_signature.rs b/rust/rbac-registration/src/cardano/cip509/types/validation_signature.rs index e5120fa567..71208edce7 100644 --- a/rust/rbac-registration/src/cardano/cip509/types/validation_signature.rs +++ b/rust/rbac-registration/src/cardano/cip509/types/validation_signature.rs @@ -1,6 +1,6 @@ //! A validation signature wrapper. -use anyhow::{anyhow, Error}; +use anyhow::{Error, anyhow}; /// A validation signature. /// 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 7b0ae26dc5..b3a62d9866 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 @@ -3,9 +3,9 @@ use std::{collections::HashMap, sync::Arc}; use c509_certificate::{ + C509ExtensionType, extensions::{alt_name::GeneralNamesOrText, extension::ExtensionValue}, general_names::general_name::{GeneralNameTypeRegistry, GeneralNameValue}, - C509ExtensionType, }; use cardano_blockchain_types::Cip0134Uri; use catalyst_types::problem_report::ProblemReport; diff --git a/rust/rbac-registration/src/cardano/cip509/validation.rs b/rust/rbac-registration/src/cardano/cip509/validation.rs index 885e23f846..84c5ced1ff 100644 --- a/rust/rbac-registration/src/cardano/cip509/validation.rs +++ b/rust/rbac-registration/src/cardano/cip509/validation.rs @@ -13,7 +13,7 @@ use catalyst_types::{ id_uri::IdUri, problem_report::ProblemReport, }; -use ed25519_dalek::{VerifyingKey, PUBLIC_KEY_LENGTH}; +use ed25519_dalek::{PUBLIC_KEY_LENGTH, VerifyingKey}; use pallas::{ codec::{ minicbor::{Encode, Encoder}, @@ -25,8 +25,8 @@ use x509_cert::Certificate; use super::utils::cip19::compare_key_hash; use crate::cardano::cip509::{ - rbac::Cip509RbacMetadata, types::TxInputHash, C509Cert, Cip0134UriSet, LocalRefInt, RoleData, - RoleNumber, SimplePublicKeyType, X509DerCert, + C509Cert, Cip0134UriSet, LocalRefInt, RoleData, RoleNumber, SimplePublicKeyType, X509DerCert, + rbac::Cip509RbacMetadata, types::TxInputHash, }; /// Context-specific primitive type with tag number 6 (`raw_tag` 134) for @@ -448,8 +448,11 @@ mod tests { let report = registration.consume().unwrap_err(); assert!(report.is_problematic()); let report = format!("{report:?}"); - assert!(report - .contains("Role payment key reference index (1) is not found in transaction outputs")); + assert!( + report.contains( + "Role payment key reference index (1) is not found in transaction outputs" + ) + ); } #[test] diff --git a/rust/rbac-registration/src/cardano/cip509/x509_chunks.rs b/rust/rbac-registration/src/cardano/cip509/x509_chunks.rs index 92a8d56d94..38d3853c57 100644 --- a/rust/rbac-registration/src/cardano/cip509/x509_chunks.rs +++ b/rust/rbac-registration/src/cardano/cip509/x509_chunks.rs @@ -3,7 +3,7 @@ use std::io::Read; use cbork_utils::decode_helper::{decode_array_len, decode_bytes, decode_helper}; -use minicbor::{decode, Decode, Decoder}; +use minicbor::{Decode, Decoder, decode}; use strum_macros::FromRepr; use super::rbac::Cip509RbacMetadata; @@ -128,7 +128,7 @@ mod tests { // Brotli data: 11 const BROTLI: &str = "0b8958401bed02003c0e772c72637668c289a39b361dd1161a123da11e1118d08c7ab73ed1455e25aab3105e92334ba1fe128febedfb3e4912243755f42aca92094de82658404a4149a26917374c7cfd021376195439e4ea64844b46cfe1f87e9b6bf4d43c9dace1920ceeb2cc82bb60018b5b2de9571c5ea9c81dddd4077cc4571eb33181ce58409b38965811866581e4e903e6967333e85ab02e1b25665f272d24db06fb0183d3dd1cd937e2e260e3e0d045c976e057dde418766ea47dd551a68c20c015f508e25840118815ae0511d0e258b4440bd4b921222339016000ba853d2119394d8006a8a220d1c4755d3920f4403b302919d9c22f32106e1e10c3942a7d0f1c8ce42283205840528a20238dc8802d44cafe99612022d4abb8dc58894462642a21bb150449720b1f0e4e2a62bb9210b334d2f13ba4057d05f409d0fa3c666a3cb41cd012cc8e29584086ea45acd180f40932c052962cc156bad9f4a8a80d2f5d2e488c7ba8a496b1b1bf332482c7f8b9f981bfcb862878854a29842b460c8c782fb7905037399087685840693fc55005905188558891f50a0b0b0d8f0c04528e5d4a3c3c5c1cfc3360ef293f8938271225c0c6c727c4c59e3e4e09a2788847c7cfc79646ce62974cc11f1558405fbca2dc36eaf3594d18624bde0c7adac3324a828c2b833b3b3fbcd0c657c337f05bd53ece84f0adf329567b7234fe45897252656f11cf8ae6e56073452a93e85835133271a0fbc9f8d641adafb33a0267685f05fd95caf1ff3efa9d60febcfced727553ff21cd774cee682b161636860470b149c61f40"; // Zstd data: 12 - const ZSTD: &str= "0c89584028b52ffd6000029d1100b41fa30a815902ae308202aa3082025ca00302010202147735a70599e68b49554b1cb3a6cf5e34583b3c2f300506032b6570307c310b5840300906035504061302555331133011080c0a43616c69666f726e696131163014070c0d53616e204672616e636973636f311230100a0c094d79436f6d70616e79584031153013060355040b0c0c4d794465706172746d656e74030c0c6d79646f6d61696e2e636f6d301e170d3234313132393034333134305a170d32352a0321007e5840082c662a8d4d3271d797067f36caf25d6472b83901620a2eac193331a7f871a381ef3081ec30819e0603551d110481963081938282107777772e820b6578616d5840706c65820f86537765622b63617264616e6f3a2f2f616464722f7374616b655f7465737431757165686b636b306c616a713867723238743975786e7576676371584072633630373078336b3972383034387a3879356773737274766e300b0f0404030205e0301d2504082b06010505070301020e04160414251ddd56123655faa93458408ff93c1e92ce3bc15a294100b11c80d36fdcba650b950f0687e448b3bcbeb2caa5249b24aff83d16ebbb71249e44bd0ecfab8b40fb772b6f977f98ac9122e139584054439d0120980b347e3f9707181e81d9800558206e42f8e589a76ebb13ef279df7841efce978f106bee196f0e3cfd347bb31a2e8186481a4000001820a000301583d0a64546573740013003d3e631feb0da1b068d5115f8161e2aed10b46d3acd0c00e1b9c80e50abeed00ca66cc432659ca8c6f3affd9b92ccedd01d66906"; + const ZSTD: &str = "0c89584028b52ffd6000029d1100b41fa30a815902ae308202aa3082025ca00302010202147735a70599e68b49554b1cb3a6cf5e34583b3c2f300506032b6570307c310b5840300906035504061302555331133011080c0a43616c69666f726e696131163014070c0d53616e204672616e636973636f311230100a0c094d79436f6d70616e79584031153013060355040b0c0c4d794465706172746d656e74030c0c6d79646f6d61696e2e636f6d301e170d3234313132393034333134305a170d32352a0321007e5840082c662a8d4d3271d797067f36caf25d6472b83901620a2eac193331a7f871a381ef3081ec30819e0603551d110481963081938282107777772e820b6578616d5840706c65820f86537765622b63617264616e6f3a2f2f616464722f7374616b655f7465737431757165686b636b306c616a713867723238743975786e7576676371584072633630373078336b3972383034387a3879356773737274766e300b0f0404030205e0301d2504082b06010505070301020e04160414251ddd56123655faa93458408ff93c1e92ce3bc15a294100b11c80d36fdcba650b950f0687e448b3bcbeb2caa5249b24aff83d16ebbb71249e44bd0ecfab8b40fb772b6f977f98ac9122e139584054439d0120980b347e3f9707181e81d9800558206e42f8e589a76ebb13ef279df7841efce978f106bee196f0e3cfd347bb31a2e8186481a4000001820a000301583d0a64546573740013003d3e631feb0da1b068d5115f8161e2aed10b46d3acd0c00e1b9c80e50abeed00ca66cc432659ca8c6f3affd9b92ccedd01d66906"; #[test] fn test_decode_x509_chunks_raw() { diff --git a/rust/rust-toolchain.toml b/rust/rust-toolchain.toml index eb1d979459..5bedd373fc 100644 --- a/rust/rust-toolchain.toml +++ b/rust/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.83" -profile = "default" \ No newline at end of file +channel = "1.85" +profile = "default" diff --git a/rust/rustfmt.toml b/rust/rustfmt.toml index 905bde2d0b..18fac85edf 100644 --- a/rust/rustfmt.toml +++ b/rust/rustfmt.toml @@ -21,7 +21,7 @@ unstable_features = true # Compatibility: -edition = "2021" +edition = "2024" # Tabs & spaces - Defaults, listed for clarity tab_spaces = 4 diff --git a/rust/signed_doc/examples/mk_signed_doc.rs b/rust/signed_doc/examples/mk_signed_doc.rs index 8af76e5b63..51f975ab97 100644 --- a/rust/signed_doc/examples/mk_signed_doc.rs +++ b/rust/signed_doc/examples/mk_signed_doc.rs @@ -3,7 +3,7 @@ #![allow(missing_docs, clippy::missing_docs_in_private_items)] use std::{ - fs::{read_to_string, File}, + fs::{File, read_to_string}, io::{Read, Write}, path::PathBuf, }; diff --git a/rust/signed_doc/src/builder.rs b/rust/signed_doc/src/builder.rs index ed1f1b822f..e93e8a5a1f 100644 --- a/rust/signed_doc/src/builder.rs +++ b/rust/signed_doc/src/builder.rs @@ -1,10 +1,10 @@ //! Catalyst Signed Document Builder. use catalyst_types::{id_uri::IdUri, problem_report::ProblemReport}; -use ed25519_dalek::{ed25519::signature::Signer, SecretKey}; +use ed25519_dalek::{SecretKey, ed25519::signature::Signer}; use crate::{ - CatalystSignedDocument, Content, InnerCatalystSignedDocument, Metadata, Signatures, - PROBLEM_REPORT_CTX, + CatalystSignedDocument, Content, InnerCatalystSignedDocument, Metadata, PROBLEM_REPORT_CTX, + Signatures, }; /// Catalyst Signed Document Builder. diff --git a/rust/signed_doc/src/lib.rs b/rust/signed_doc/src/lib.rs index d78508ae53..2bed8d4a0e 100644 --- a/rust/signed_doc/src/lib.rs +++ b/rust/signed_doc/src/lib.rs @@ -22,7 +22,7 @@ use coset::{CborSerializable, Header}; pub use metadata::{ Algorithm, ContentEncoding, ContentType, DocumentRef, ExtraFields, Metadata, Section, }; -use minicbor::{decode, encode, Decode, Decoder, Encode}; +use minicbor::{Decode, Decoder, Encode, decode, encode}; use providers::VerifyingKeyProvider; pub use signature::{IdUri, Signatures}; @@ -411,10 +411,12 @@ mod tests { .unwrap(); assert!(!signed_doc.problem_report().is_problematic()); - assert!(signed_doc - .verify(&Provider(Err(anyhow::anyhow!("some error")))) - .await - .is_err()); + assert!( + signed_doc + .verify(&Provider(Err(anyhow::anyhow!("some error")))) + .await + .is_err() + ); assert!(signed_doc.verify(&Provider(Ok(Some(pk)))).await.unwrap()); assert!(!signed_doc.verify(&Provider(Ok(None))).await.unwrap()); } diff --git a/rust/signed_doc/src/metadata/content_encoding.rs b/rust/signed_doc/src/metadata/content_encoding.rs index d47f696e7f..749a9fd983 100644 --- a/rust/signed_doc/src/metadata/content_encoding.rs +++ b/rust/signed_doc/src/metadata/content_encoding.rs @@ -5,7 +5,7 @@ use std::{ str::FromStr, }; -use serde::{de, Deserialize, Deserializer}; +use serde::{Deserialize, Deserializer, de}; /// IANA `CoAP` Content Encoding. #[derive(Copy, Clone, Debug, PartialEq, Eq)] diff --git a/rust/signed_doc/src/metadata/content_type.rs b/rust/signed_doc/src/metadata/content_type.rs index b72cb4b9c2..9df47357fa 100644 --- a/rust/signed_doc/src/metadata/content_type.rs +++ b/rust/signed_doc/src/metadata/content_type.rs @@ -6,7 +6,7 @@ use std::{ }; use coset::iana::CoapContentFormat; -use serde::{de, Deserialize, Deserializer}; +use serde::{Deserialize, Deserializer, de}; use strum::VariantArray; /// Payload Content Type. diff --git a/rust/signed_doc/src/metadata/document_ref.rs b/rust/signed_doc/src/metadata/document_ref.rs index a225155073..bd7f2a31af 100644 --- a/rust/signed_doc/src/metadata/document_ref.rs +++ b/rust/signed_doc/src/metadata/document_ref.rs @@ -4,7 +4,7 @@ use std::fmt::Display; use coset::cbor::Value; -use super::{decode_cbor_uuid, encode_cbor_uuid, UuidV7}; +use super::{UuidV7, decode_cbor_uuid, encode_cbor_uuid}; /// Reference to a Document. #[derive(Copy, Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)] diff --git a/rust/signed_doc/src/metadata/extra_fields.rs b/rust/signed_doc/src/metadata/extra_fields.rs index b207f2e977..48f00607b6 100644 --- a/rust/signed_doc/src/metadata/extra_fields.rs +++ b/rust/signed_doc/src/metadata/extra_fields.rs @@ -1,9 +1,9 @@ //! Catalyst Signed Document Extra Fields. use catalyst_types::{problem_report::ProblemReport, uuid::UuidV4}; -use coset::{cbor::Value, Label, ProtectedHeader}; +use coset::{Label, ProtectedHeader, cbor::Value}; -use super::{cose_protected_header_find, decode_cbor_uuid, encode_cbor_uuid, DocumentRef, Section}; +use super::{DocumentRef, Section, cose_protected_header_find, decode_cbor_uuid, encode_cbor_uuid}; /// `ref` field COSE key value const REF_KEY: &str = "ref"; diff --git a/rust/signed_doc/src/validator/mod.rs b/rust/signed_doc/src/validator/mod.rs index a02c576f46..dce3b96817 100644 --- a/rust/signed_doc/src/validator/mod.rs +++ b/rust/signed_doc/src/validator/mod.rs @@ -12,12 +12,12 @@ use rules::{ }; use crate::{ + CatalystSignedDocument, ContentEncoding, ContentType, doc_types::{ COMMENT_DOCUMENT_UUID_TYPE, COMMENT_TEMPLATE_UUID_TYPE, PROPOSAL_DOCUMENT_UUID_TYPE, PROPOSAL_TEMPLATE_UUID_TYPE, }, providers::CatalystSignedDocumentProvider, - CatalystSignedDocument, ContentEncoding, ContentType, }; /// A table representing a full set or validation rules per document id. diff --git a/rust/signed_doc/src/validator/rules/category.rs b/rust/signed_doc/src/validator/rules/category.rs index 259e827539..8ca324b391 100644 --- a/rust/signed_doc/src/validator/rules/category.rs +++ b/rust/signed_doc/src/validator/rules/category.rs @@ -1,8 +1,8 @@ //! `content-type` rule type impl. use crate::{ - doc_types::CATEGORY_DOCUMENT_UUID_TYPE, providers::CatalystSignedDocumentProvider, - validator::utils::validate_provided_doc, CatalystSignedDocument, + CatalystSignedDocument, doc_types::CATEGORY_DOCUMENT_UUID_TYPE, + providers::CatalystSignedDocumentProvider, validator::utils::validate_provided_doc, }; /// `category_id` field validation rule diff --git a/rust/signed_doc/src/validator/rules/content_encoding.rs b/rust/signed_doc/src/validator/rules/content_encoding.rs index 734fc931f5..397d34fd58 100644 --- a/rust/signed_doc/src/validator/rules/content_encoding.rs +++ b/rust/signed_doc/src/validator/rules/content_encoding.rs @@ -1,6 +1,6 @@ //! `content-encoding` rule type impl. -use crate::{metadata::ContentEncoding, CatalystSignedDocument}; +use crate::{CatalystSignedDocument, metadata::ContentEncoding}; /// `content-encoding` field validation rule pub(crate) struct ContentEncodingRule { diff --git a/rust/signed_doc/src/validator/rules/content_type.rs b/rust/signed_doc/src/validator/rules/content_type.rs index 5c993eb794..fbe89260f4 100644 --- a/rust/signed_doc/src/validator/rules/content_type.rs +++ b/rust/signed_doc/src/validator/rules/content_type.rs @@ -1,6 +1,6 @@ //! `content-type` rule type impl. -use crate::{metadata::ContentType, CatalystSignedDocument}; +use crate::{CatalystSignedDocument, metadata::ContentType}; /// `content-type` field validation rule #[derive(Clone, Debug, PartialEq)] diff --git a/rust/signed_doc/src/validator/rules/doc_ref.rs b/rust/signed_doc/src/validator/rules/doc_ref.rs index 1f5a406d9a..1c3bddc612 100644 --- a/rust/signed_doc/src/validator/rules/doc_ref.rs +++ b/rust/signed_doc/src/validator/rules/doc_ref.rs @@ -3,8 +3,8 @@ use catalyst_types::uuid::Uuid; use crate::{ - providers::CatalystSignedDocumentProvider, validator::utils::validate_provided_doc, - CatalystSignedDocument, + CatalystSignedDocument, providers::CatalystSignedDocumentProvider, + validator::utils::validate_provided_doc, }; /// `ref` field validation rule diff --git a/rust/signed_doc/src/validator/rules/mod.rs b/rust/signed_doc/src/validator/rules/mod.rs index 81ebb39b27..74a76cd8a6 100644 --- a/rust/signed_doc/src/validator/rules/mod.rs +++ b/rust/signed_doc/src/validator/rules/mod.rs @@ -3,7 +3,7 @@ use futures::FutureExt; -use crate::{providers::CatalystSignedDocumentProvider, CatalystSignedDocument}; +use crate::{CatalystSignedDocument, providers::CatalystSignedDocumentProvider}; mod category; mod content_encoding; diff --git a/rust/signed_doc/src/validator/rules/reply.rs b/rust/signed_doc/src/validator/rules/reply.rs index f9cb5d2248..e781c18665 100644 --- a/rust/signed_doc/src/validator/rules/reply.rs +++ b/rust/signed_doc/src/validator/rules/reply.rs @@ -3,8 +3,8 @@ use catalyst_types::uuid::Uuid; use crate::{ - providers::CatalystSignedDocumentProvider, validator::utils::validate_provided_doc, - CatalystSignedDocument, + CatalystSignedDocument, providers::CatalystSignedDocumentProvider, + validator::utils::validate_provided_doc, }; /// `reply` field validation rule diff --git a/rust/signed_doc/src/validator/rules/template.rs b/rust/signed_doc/src/validator/rules/template.rs index ded33e0422..57a4e8ff4c 100644 --- a/rust/signed_doc/src/validator/rules/template.rs +++ b/rust/signed_doc/src/validator/rules/template.rs @@ -3,8 +3,8 @@ use catalyst_types::uuid::Uuid; use crate::{ - metadata::ContentType, providers::CatalystSignedDocumentProvider, - validator::utils::validate_provided_doc, CatalystSignedDocument, + CatalystSignedDocument, metadata::ContentType, providers::CatalystSignedDocumentProvider, + validator::utils::validate_provided_doc, }; /// `template` field validation rule diff --git a/rust/signed_doc/src/validator/utils.rs b/rust/signed_doc/src/validator/utils.rs index a6464bbc4c..46bd3e5fe3 100644 --- a/rust/signed_doc/src/validator/utils.rs +++ b/rust/signed_doc/src/validator/utils.rs @@ -2,7 +2,7 @@ use catalyst_types::problem_report::ProblemReport; -use crate::{providers::CatalystSignedDocumentProvider, CatalystSignedDocument, DocumentRef}; +use crate::{CatalystSignedDocument, DocumentRef, providers::CatalystSignedDocumentProvider}; /// A helper validation document function, which validates a document from the /// `ValidationDataProvider`. diff --git a/rust/vote-tx-v1/src/decoding.rs b/rust/vote-tx-v1/src/decoding.rs index 2f33c2d7d1..8078daecde 100644 --- a/rust/vote-tx-v1/src/decoding.rs +++ b/rust/vote-tx-v1/src/decoding.rs @@ -7,8 +7,8 @@ use anyhow::{anyhow, bail, ensure}; use catalyst_voting::crypto::ed25519::{PublicKey, Signature}; use crate::{ - utils::{read_array, read_be_u32, read_be_u64, read_be_u8}, EncryptedVote, Tx, VotePayload, VoterProof, + utils::{read_array, read_be_u8, read_be_u32, read_be_u64}, }; /// Jörmungandr tx fragment tag. @@ -105,7 +105,6 @@ impl Tx { /// - Invalid voter proof. /// - Invalid vote tag value. /// - Invalid public key. - #[allow(clippy::indexing_slicing)] pub fn from_bytes(reader: &mut R) -> anyhow::Result { // Skip tx size field read_be_u32(reader).map_err(|_| anyhow!("Missing tx size field."))?; diff --git a/rust/vote-tx-v1/src/lib.rs b/rust/vote-tx-v1/src/lib.rs index 55c4bdce64..371c202691 100644 --- a/rust/vote-tx-v1/src/lib.rs +++ b/rust/vote-tx-v1/src/lib.rs @@ -51,16 +51,15 @@ mod utils; use anyhow::ensure; use catalyst_voting::{ crypto::{ - ed25519::{sign, verify_signature, PrivateKey, PublicKey, Signature}, - hash::{digest::Digest, Blake2b256Hasher, Blake2b512Hasher}, + ed25519::{PrivateKey, PublicKey, Signature, sign, verify_signature}, + hash::{Blake2b256Hasher, Blake2b512Hasher, digest::Digest}, rng::{default_rng, rand_core::CryptoRngCore}, }, vote_protocol::{ committee::{ElectionPublicKey, ElectionSecretKey}, voter::{ - decrypt_vote, encrypt_vote, - proof::{generate_voter_proof, verify_voter_proof, VoterProof, VoterProofCommitment}, - EncryptedVote, Vote, + EncryptedVote, Vote, decrypt_vote, encrypt_vote, + proof::{VoterProof, VoterProofCommitment, generate_voter_proof, verify_voter_proof}, }, }, }; diff --git a/rust/vote-tx-v2/src/encoded_cbor.rs b/rust/vote-tx-v2/src/encoded_cbor.rs index 981fc12737..b2706e23d9 100644 --- a/rust/vote-tx-v2/src/encoded_cbor.rs +++ b/rust/vote-tx-v2/src/encoded_cbor.rs @@ -1,6 +1,6 @@ //! An encoded CBOR (tag 24) struct -use minicbor::{data::Tag, Decode, Decoder, Encode}; +use minicbor::{Decode, Decoder, Encode, data::Tag}; use crate::Cbor; diff --git a/rust/vote-tx-v2/src/gen_tx/builder.rs b/rust/vote-tx-v2/src/gen_tx/builder.rs index ab6cf9e264..35cd8f96e2 100644 --- a/rust/vote-tx-v2/src/gen_tx/builder.rs +++ b/rust/vote-tx-v2/src/gen_tx/builder.rs @@ -2,8 +2,8 @@ use anyhow::ensure; -use super::{cose_protected_header, EventKey, EventMap, GeneralizedTx, TxBody, Vote, VoterData}; -use crate::{encoded_cbor::EncodedCbor, uuid::Uuid, Cbor}; +use super::{EventKey, EventMap, GeneralizedTx, TxBody, Vote, VoterData, cose_protected_header}; +use crate::{Cbor, encoded_cbor::EncodedCbor, uuid::Uuid}; /// `GeneralizedTx` builder struct #[allow(clippy::module_name_repetitions)] diff --git a/rust/vote-tx-v2/src/gen_tx/event_map.rs b/rust/vote-tx-v2/src/gen_tx/event_map.rs index 91b6947c4a..ea28060e84 100644 --- a/rust/vote-tx-v2/src/gen_tx/event_map.rs +++ b/rust/vote-tx-v2/src/gen_tx/event_map.rs @@ -1,6 +1,6 @@ //! A generalized tx event map struct. -use minicbor::{data::Int, Decode, Decoder, Encode, Encoder}; +use minicbor::{Decode, Decoder, Encode, Encoder, data::Int}; use super::read_cbor_bytes; diff --git a/rust/vote-tx-v2/src/gen_tx/tx_body.rs b/rust/vote-tx-v2/src/gen_tx/tx_body.rs index c129a3e15c..2f27ed4d41 100644 --- a/rust/vote-tx-v2/src/gen_tx/tx_body.rs +++ b/rust/vote-tx-v2/src/gen_tx/tx_body.rs @@ -3,7 +3,7 @@ use minicbor::{Decode, Decoder, Encode, Encoder}; use super::{EventMap, Vote}; -use crate::{encoded_cbor::EncodedCbor, uuid::Uuid, Cbor}; +use crate::{Cbor, encoded_cbor::EncodedCbor, uuid::Uuid}; /// `TxBody` array struct length const TX_BODY_LEN: u64 = 4; diff --git a/rust/vote-tx-v2/src/gen_tx/vote.rs b/rust/vote-tx-v2/src/gen_tx/vote.rs index cd5c3c56ee..99945dda2f 100644 --- a/rust/vote-tx-v2/src/gen_tx/vote.rs +++ b/rust/vote-tx-v2/src/gen_tx/vote.rs @@ -2,7 +2,7 @@ use minicbor::{Decode, Decoder, Encode}; -use crate::{encoded_cbor::EncodedCbor, Cbor}; +use crate::{Cbor, encoded_cbor::EncodedCbor}; /// `Vote` array struct length const VOTE_LEN: u64 = 3; diff --git a/rust/vote-tx-v2/src/public_tx/mod.rs b/rust/vote-tx-v2/src/public_tx/mod.rs index af2262c585..706518454a 100644 --- a/rust/vote-tx-v2/src/public_tx/mod.rs +++ b/rust/vote-tx-v2/src/public_tx/mod.rs @@ -8,7 +8,7 @@ use std::ops::{Deref, DerefMut}; use minicbor::{Decode, Encode}; pub use vote::{Choice, Proof, PropId}; -use crate::{gen_tx::GeneralizedTx, Cbor}; +use crate::{Cbor, gen_tx::GeneralizedTx}; /// A public vote tx struct. #[derive(Debug, Clone, PartialEq)] diff --git a/rust/vote-tx-v2/src/uuid.rs b/rust/vote-tx-v2/src/uuid.rs index 6bb3b5d517..7d85a4a340 100644 --- a/rust/vote-tx-v2/src/uuid.rs +++ b/rust/vote-tx-v2/src/uuid.rs @@ -1,6 +1,6 @@ //! A CBOR encoded/decoded UUID struct. -use minicbor::{data::Tag, Decode, Decoder, Encode}; +use minicbor::{Decode, Decoder, Encode, data::Tag}; /// UUID CBOR tag . const UUID_TAG: u64 = 37;