From cb8181ce2ac36c48057b37a8242f0a55539c4c4b Mon Sep 17 00:00:00 2001 From: George Mulhearn <57472912+gmulhearn@users.noreply.github.com> Date: Tue, 23 Jul 2024 12:40:04 +1000 Subject: [PATCH] (chore) update to rust 1.79 (#1274) * update to rust 1.79 and remove warnings/errors Signed-off-by: George Mulhearn * make clippy happy Signed-off-by: George Mulhearn --------- Signed-off-by: George Mulhearn Co-authored-by: George Mulhearn --- .github/workflows/main.yml | 2 +- .github/workflows/mediator.pr.yml | 2 +- README.md | 1 + aries/agents/aath-backchannel/Dockerfile.aries-vcx | 2 +- .../src/common/proofs/prover/prover_internal.rs | 10 ++++------ .../src/protocols/connection/generic/mod.rs | 4 ++-- .../src/protocols/issuance/holder/state_machine.rs | 4 ++-- aries/aries_vcx/src/utils/encryption_envelope.rs | 2 +- .../aries_vcx/tests/utils/scenarios/connection.rs | 14 -------------- aries/aries_vcx_anoncreds/src/utils/json.rs | 5 ++--- .../aries_vcx_ledger/src/ledger/indy_vdr_ledger.rs | 5 +---- aries/misc/anoncreds_types/src/utils/query.rs | 1 + .../src/domain/attrib.rs | 2 ++ .../src/domain/cred_def.rs | 1 + .../src/domain/response.rs | 1 + .../src/domain/schema.rs | 1 + .../misc/legacy/libvdrtools/indy-utils/src/lib.rs | 3 ++- .../misc/legacy/libvdrtools/indy-wallet/src/lib.rs | 2 ++ aries/misc/test_utils/src/devsetup.rs | 8 ++++---- did_core/did_resolver_registry/src/lib.rs | 1 + 20 files changed, 31 insertions(+), 40 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cee2c03cd5..a9baffc82f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ env: DOCKER_REPO_LOCAL_VDRPROXY: vdrproxy DOCKER_REPO_LOCAL_AATH: aath-backchannel - RUST_TOOLCHAIN_VERSION: 1.76.0 + RUST_TOOLCHAIN_VERSION: 1.79.0 NODE_VERSION: 18.x jobs: diff --git a/.github/workflows/mediator.pr.yml b/.github/workflows/mediator.pr.yml index 29c5a80d82..a7c332c38d 100644 --- a/.github/workflows/mediator.pr.yml +++ b/.github/workflows/mediator.pr.yml @@ -14,7 +14,7 @@ env: DOCKER_BUILDKIT: 1 MAIN_BRANCH: main - RUST_TOOLCHAIN_VERSION: 1.76.0 + RUST_TOOLCHAIN_VERSION: 1.79.0 jobs: diff --git a/README.md b/README.md index 16206b6673..11a2560a82 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,4 @@ There's 2 best way to reach us: - We bump minor version on releases containing new features, significant refactors or breaking changes. - We bump patch version if release only contains fixes or smaller refactoring. - See [releases](https://github.com/hyperledger/aries-vcx/releases) page. + - Crates are known to be stable with atleast Rust version 1.79 diff --git a/aries/agents/aath-backchannel/Dockerfile.aries-vcx b/aries/agents/aath-backchannel/Dockerfile.aries-vcx index 1bd280a631..0b2ac20f05 100644 --- a/aries/agents/aath-backchannel/Dockerfile.aries-vcx +++ b/aries/agents/aath-backchannel/Dockerfile.aries-vcx @@ -14,7 +14,7 @@ RUN apk update && apk upgrade && \ USER aries WORKDIR /home/aries -ARG RUST_VER="1.76.0" +ARG RUST_VER="1.79.0" RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUST_VER --default-host x86_64-unknown-linux-musl ENV PATH="/home/aries/.cargo/bin:$PATH" RUSTFLAGS="-C target-feature=-crt-static" diff --git a/aries/aries_vcx/src/common/proofs/prover/prover_internal.rs b/aries/aries_vcx/src/common/proofs/prover/prover_internal.rs index c0e0be0121..1f78080675 100644 --- a/aries/aries_vcx/src/common/proofs/prover/prover_internal.rs +++ b/aries/aries_vcx/src/common/proofs/prover/prover_internal.rs @@ -41,7 +41,7 @@ pub async fn build_schemas_json_prover( let mut rtn: SchemasMap = HashMap::new(); for cred_info in credentials_identifiers { - if rtn.get(&cred_info.schema_id).is_none() { + if !rtn.contains_key(&cred_info.schema_id) { let schema_json = ledger .get_schema(&cred_info.schema_id, None) .await @@ -157,7 +157,7 @@ pub async fn build_rev_states_json( &cred_info.cred_rev_id, &cred_info.tails_dir, ) { - if rtn.get(rev_reg_id).is_none() { + if !rtn.contains_key(rev_reg_id) { // Does this make sense in case cred_info's for same rev_reg_ids have different // revocation intervals let (from, to) = if let Some(ref interval) = cred_info.revocation_interval { @@ -226,8 +226,7 @@ pub fn build_requested_credentials_json( if proof_req .value() .requested_attributes - .get(&cred_info.referent) - .is_some() + .contains_key(&cred_info.referent) { rtn.requested_attributes.insert( cred_info.referent.to_owned(), @@ -244,8 +243,7 @@ pub fn build_requested_credentials_json( if proof_req .value() .requested_predicates - .get(&cred_info.referent) - .is_some() + .contains_key(&cred_info.referent) { rtn.requested_predicates.insert( cred_info.referent.to_owned(), diff --git a/aries/aries_vcx/src/protocols/connection/generic/mod.rs b/aries/aries_vcx/src/protocols/connection/generic/mod.rs index 49cc93544b..7d9ecf8a49 100644 --- a/aries/aries_vcx/src/protocols/connection/generic/mod.rs +++ b/aries/aries_vcx/src/protocols/connection/generic/mod.rs @@ -427,7 +427,7 @@ mod connection_serde_tests { let wallet = MockWallet; let con = make_invitee_requested().await; let mut con_data = ConnectionData::new(PW_KEY.to_owned(), AriesDidDoc::default()); - con_data.did_doc.id = PW_KEY.to_owned(); + PW_KEY.clone_into(&mut con_data.did_doc.id); con_data.did_doc.set_recipient_keys(vec![PW_KEY.to_owned()]); con_data.did_doc.set_routing_keys(Vec::new()); @@ -476,7 +476,7 @@ mod connection_serde_tests { let new_routing_keys = vec![]; let mut con_data = ConnectionData::new(PW_KEY.to_owned(), AriesDidDoc::default()); - con_data.did_doc.id = PW_KEY.to_owned(); + PW_KEY.clone_into(&mut con_data.did_doc.id); con_data.did_doc.set_recipient_keys(vec![PW_KEY.to_owned()]); con_data.did_doc.set_routing_keys(Vec::new()); diff --git a/aries/aries_vcx/src/protocols/issuance/holder/state_machine.rs b/aries/aries_vcx/src/protocols/issuance/holder/state_machine.rs index 4c7a1785e1..7b534dd140 100644 --- a/aries/aries_vcx/src/protocols/issuance/holder/state_machine.rs +++ b/aries/aries_vcx/src/protocols/issuance/holder/state_machine.rs @@ -168,12 +168,12 @@ impl HolderSM { let state = match self.state { HolderFullState::Initial(_) => { let mut proposal = proposal; - proposal.id = self.thread_id.clone(); + proposal.id.clone_from(&self.thread_id); HolderFullState::ProposalSet(ProposalSetState::new(proposal)) } HolderFullState::OfferReceived(_) => { let mut proposal = proposal; - proposal.id = self.thread_id.clone(); + proposal.id.clone_from(&self.thread_id); HolderFullState::ProposalSet(ProposalSetState::new(proposal)) } s => { diff --git a/aries/aries_vcx/src/utils/encryption_envelope.rs b/aries/aries_vcx/src/utils/encryption_envelope.rs index 30fc4e75a9..90f7534213 100644 --- a/aries/aries_vcx/src/utils/encryption_envelope.rs +++ b/aries/aries_vcx/src/utils/encryption_envelope.rs @@ -147,7 +147,7 @@ impl EncryptionEnvelope { data = EncryptionEnvelope::wrap_into_forward(wallet, data, &forward_to_key, routing_key) .await?; - forward_to_key = routing_key.clone(); + forward_to_key.clone_from(routing_key); } Ok(data) } diff --git a/aries/aries_vcx/tests/utils/scenarios/connection.rs b/aries/aries_vcx/tests/utils/scenarios/connection.rs index fce7ae6490..915546f8da 100644 --- a/aries/aries_vcx/tests/utils/scenarios/connection.rs +++ b/aries/aries_vcx/tests/utils/scenarios/connection.rs @@ -1,18 +1,15 @@ use aries_vcx::{ - errors::error::VcxResult, handlers::{out_of_band::sender::OutOfBandSender, util::AnyInvitation}, protocols::{ connection::{invitee::any_invitation_into_did_doc, Connection, GenericConnection}, mediated_connection::pairwise_info::PairwiseInfo, }, - transport::Transport, }; use aries_vcx_anoncreds::anoncreds::base_anoncreds::BaseAnonCreds; use aries_vcx_ledger::ledger::base_ledger::{ AnoncredsLedgerRead, AnoncredsLedgerWrite, IndyLedgerRead, IndyLedgerWrite, }; use aries_vcx_wallet::wallet::base_wallet::BaseWallet; -use async_trait::async_trait; use messages::{ msg_fields::protocols::{ connection::invitation::{Invitation, InvitationContent}, @@ -23,7 +20,6 @@ use messages::{ Protocol, }, }; -use url::Url; use uuid::Uuid; use crate::utils::test_agent::TestAgent; @@ -44,16 +40,6 @@ async fn establish_connection_from_invite( invitation: AnyInvitation, inviter_pairwise_info: PairwiseInfo, ) -> (GenericConnection, GenericConnection) { - // TODO: Temporary, delete - struct DummyHttpClient; - - #[async_trait] - impl Transport for DummyHttpClient { - async fn send_message(&self, _msg: Vec, _service_endpoint: &Url) -> VcxResult<()> { - Ok(()) - } - } - let invitee_pairwise_info = PairwiseInfo::create(&alice.wallet).await.unwrap(); let invitee = Connection::new_invitee("".to_owned(), invitee_pairwise_info) .accept_invitation(&alice.ledger_read, invitation.clone()) diff --git a/aries/aries_vcx_anoncreds/src/utils/json.rs b/aries/aries_vcx_anoncreds/src/utils/json.rs index 1e35a1cfde..ee470acb5a 100644 --- a/aries/aries_vcx_anoncreds/src/utils/json.rs +++ b/aries/aries_vcx_anoncreds/src/utils/json.rs @@ -7,13 +7,12 @@ use serde_json::{Map, Value}; use crate::errors::error::{VcxAnoncredsError, VcxAnoncredsResult}; +#[allow(unused)] +// some methods not used yet or by all features, but still a useful util pub(crate) trait AsTypeOrDeserializationError { fn try_as_str(&self) -> VcxAnoncredsResult<&str>; - fn try_as_object(&self) -> VcxAnoncredsResult<&Map>; - #[allow(dead_code)] fn try_as_bool(&self) -> VcxAnoncredsResult; - #[allow(dead_code)] fn try_as_array(&self) -> VcxAnoncredsResult<&Vec>; } diff --git a/aries/aries_vcx_ledger/src/ledger/indy_vdr_ledger.rs b/aries/aries_vcx_ledger/src/ledger/indy_vdr_ledger.rs index e9f30b170e..4e55fea7d5 100644 --- a/aries/aries_vcx_ledger/src/ledger/indy_vdr_ledger.rs +++ b/aries/aries_vcx_ledger/src/ledger/indy_vdr_ledger.rs @@ -693,10 +693,7 @@ pub struct VcxPoolConfig { pub fn build_ledger_components( pool_config: VcxPoolConfig, ) -> VcxLedgerResult<(DefaultIndyLedgerRead, DefaultIndyLedgerWrite)> { - let indy_vdr_config = match pool_config.indy_vdr_config { - None => PoolConfig::default(), - Some(cfg) => cfg, - }; + let indy_vdr_config = pool_config.indy_vdr_config.unwrap_or_default(); let cache_config = match pool_config.response_cache_config { None => InMemoryResponseCacherConfig::builder() .ttl(std::time::Duration::from_secs(60)) diff --git a/aries/misc/anoncreds_types/src/utils/query.rs b/aries/misc/anoncreds_types/src/utils/query.rs index 55287fef80..b6d2bd5852 100644 --- a/aries/misc/anoncreds_types/src/utils/query.rs +++ b/aries/misc/anoncreds_types/src/utils/query.rs @@ -284,6 +284,7 @@ where } } +#[allow(clippy::to_string_trait_impl)] // mimicks upstream anoncreds-rs, allow this to avoid divergence impl string::ToString for Query { fn to_string(&self) -> String { self.to_value().to_string() diff --git a/aries/misc/indy_ledger_response_parser/src/domain/attrib.rs b/aries/misc/indy_ledger_response_parser/src/domain/attrib.rs index d68a216354..4ec8a4daab 100644 --- a/aries/misc/indy_ledger_response_parser/src/domain/attrib.rs +++ b/aries/misc/indy_ledger_response_parser/src/domain/attrib.rs @@ -2,6 +2,8 @@ use indy_vdr::utils::did::ShortDidValue; use super::response::GetReplyResultV1; +#[allow(unused)] +// unused for now, but domain defined: https://github.com/hyperledger/indy-node/blob/main/docs/source/transactions.md#attrib #[derive(Debug, Deserialize)] #[serde(untagged)] pub enum GetAttrReplyResult { diff --git a/aries/misc/indy_ledger_response_parser/src/domain/cred_def.rs b/aries/misc/indy_ledger_response_parser/src/domain/cred_def.rs index 5e3e0fc8ec..0e3a05e8d9 100644 --- a/aries/misc/indy_ledger_response_parser/src/domain/cred_def.rs +++ b/aries/misc/indy_ledger_response_parser/src/domain/cred_def.rs @@ -40,6 +40,7 @@ pub struct GetCredDefResultV0 { #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] pub struct GetCredDefResultDataV1 { + #[allow(unused)] // unused, but part of entity pub ver: String, pub id: CredentialDefinitionId, #[serde(rename = "type")] diff --git a/aries/misc/indy_ledger_response_parser/src/domain/response.rs b/aries/misc/indy_ledger_response_parser/src/domain/response.rs index 21a8d624d9..8a0fac4a89 100644 --- a/aries/misc/indy_ledger_response_parser/src/domain/response.rs +++ b/aries/misc/indy_ledger_response_parser/src/domain/response.rs @@ -3,6 +3,7 @@ use crate::error::LedgerResponseParserError; #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] pub struct Response { + #[allow(unused)] // unused, but part of entity pub req_id: u64, pub reason: String, } diff --git a/aries/misc/indy_ledger_response_parser/src/domain/schema.rs b/aries/misc/indy_ledger_response_parser/src/domain/schema.rs index 03470c5176..74096e0b13 100644 --- a/aries/misc/indy_ledger_response_parser/src/domain/schema.rs +++ b/aries/misc/indy_ledger_response_parser/src/domain/schema.rs @@ -38,6 +38,7 @@ pub struct GetSchemaResultV0 { #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] pub struct GetSchemaResultDataV1 { + #[allow(unused)] // unused, but part of entity pub ver: String, pub id: SchemaId, pub schema_name: String, diff --git a/aries/misc/legacy/libvdrtools/indy-utils/src/lib.rs b/aries/misc/legacy/libvdrtools/indy-utils/src/lib.rs index 2888fda516..92e2aaccf2 100644 --- a/aries/misc/legacy/libvdrtools/indy-utils/src/lib.rs +++ b/aries/misc/legacy/libvdrtools/indy-utils/src/lib.rs @@ -1,4 +1,5 @@ -#![allow(clippy::not_unsafe_ptr_arg_deref)] +// allow all clippy warnings, given this is legacy to be removed soon +#![allow(clippy::all)] #[macro_use] extern crate serde_json; diff --git a/aries/misc/legacy/libvdrtools/indy-wallet/src/lib.rs b/aries/misc/legacy/libvdrtools/indy-wallet/src/lib.rs index 7004da52d3..48df31dac3 100644 --- a/aries/misc/legacy/libvdrtools/indy-wallet/src/lib.rs +++ b/aries/misc/legacy/libvdrtools/indy-wallet/src/lib.rs @@ -1,3 +1,5 @@ +// allow all clippy warnings, given this is legacy to be removed soon +#![allow(clippy::all)] use std::{ collections::{HashMap, HashSet}, fmt, fs, diff --git a/aries/misc/test_utils/src/devsetup.rs b/aries/misc/test_utils/src/devsetup.rs index 5265a40394..817804f5b3 100644 --- a/aries/misc/test_utils/src/devsetup.rs +++ b/aries/misc/test_utils/src/devsetup.rs @@ -42,10 +42,10 @@ pub mod vdrtools_wallet; const DEFAULT_AML_LABEL: &str = "eula"; -pub fn write_file>(file: P, content: &str) -> TestUtilsResult<()> -where - P: std::convert::AsRef, -{ +pub fn write_file + AsRef>( + file: P, + content: &str, +) -> TestUtilsResult<()> { let path = PathBuf::from(&file); if let Some(parent_path) = path.parent() { diff --git a/did_core/did_resolver_registry/src/lib.rs b/did_core/did_resolver_registry/src/lib.rs index 05cf3d0b42..e50cbc4bf8 100644 --- a/did_core/did_resolver_registry/src/lib.rs +++ b/did_core/did_resolver_registry/src/lib.rs @@ -113,6 +113,7 @@ mod tests { use super::*; + #[allow(unused)] // false positive. used for automock struct DummyDidResolver; #[async_trait]