diff --git a/Earthfile b/Earthfile index 822b3c2524..caec32db90 100644 --- a/Earthfile +++ b/Earthfile @@ -1,7 +1,7 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.5.28 AS mdlint-ci -IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.5.28 AS cspell-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.5.29 AS mdlint-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.5.29 AS cspell-ci # cspell: words livedocs sitedocs diff --git a/docs/Earthfile b/docs/Earthfile index 27cb54f99f..18e4398655 100644 --- a/docs/Earthfile +++ b/docs/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.5.28 AS docs-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.5.29 AS docs-ci IMPORT .. AS repo IMPORT ../hermes AS hermes diff --git a/hermes/Cargo.toml b/hermes/Cargo.toml index 88ce7e8b9e..5b39f8031f 100644 --- a/hermes/Cargo.toml +++ b/hermes/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -resolver = "2" +resolver = "3" members = [ "bin", "bin/tests/integration/components/http_request_rte_01", @@ -13,7 +13,7 @@ default-members = [ ] [workspace.package] -edition = "2021" +edition = "2024" version = "0.0.1" authors = [ "Steven Johnson " diff --git a/hermes/Earthfile b/hermes/Earthfile index 2cec85262e..f526bcbac1 100644 --- a/hermes/Earthfile +++ b/hermes/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.5.28 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.5.29 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci diff --git a/hermes/apps/athena/Cargo.toml b/hermes/apps/athena/Cargo.toml index 87f4d251ac..02b7d9f63b 100644 --- a/hermes/apps/athena/Cargo.toml +++ b/hermes/apps/athena/Cargo.toml @@ -1,9 +1,9 @@ [workspace] -resolver = "2" +resolver = "3" members = ["shared", "modules/*"] [workspace.package] -edition = "2021" +edition = "2024" [workspace.lints.rust] warnings = "deny" diff --git a/hermes/apps/athena/Earthfile b/hermes/apps/athena/Earthfile index 1ec5b639d4..e96ddf8c5f 100644 --- a/hermes/apps/athena/Earthfile +++ b/hermes/apps/athena/Earthfile @@ -1,7 +1,7 @@ VERSION 0.8 IMPORT ../../../wasm AS wasm -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.5.28 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.5.29 AS rust-ci # Make an artifact which consists of the common code shared by Athena modules. workspace-src: diff --git a/hermes/apps/athena/modules/rbac-registration-indexer/src/database/create.rs b/hermes/apps/athena/modules/rbac-registration-indexer/src/database/create.rs index bc4ae14228..e53127a100 100644 --- a/hermes/apps/athena/modules/rbac-registration-indexer/src/database/create.rs +++ b/hermes/apps/athena/modules/rbac-registration-indexer/src/database/create.rs @@ -6,9 +6,9 @@ use shared::{ }; use crate::database::{ - query_builder::QueryBuilder, RBAC_REGISTRATION_PERSISTENT_TABLE_NAME, - RBAC_REGISTRATION_VOLATILE_TABLE_NAME, RBAC_STAKE_ADDRESS_PERSISTENT_TABLE_NAME, - RBAC_STAKE_ADDRESS_VOLATILE_TABLE_NAME, + RBAC_REGISTRATION_PERSISTENT_TABLE_NAME, RBAC_REGISTRATION_VOLATILE_TABLE_NAME, + RBAC_STAKE_ADDRESS_PERSISTENT_TABLE_NAME, RBAC_STAKE_ADDRESS_VOLATILE_TABLE_NAME, + query_builder::QueryBuilder, }; /// Create a persistent `rbac_registration` and `rbac_stake_address` table. diff --git a/hermes/apps/athena/modules/rbac-registration-indexer/src/lib.rs b/hermes/apps/athena/modules/rbac-registration-indexer/src/lib.rs index eaf9bbfea8..7800b3397a 100644 --- a/hermes/apps/athena/modules/rbac-registration-indexer/src/lib.rs +++ b/hermes/apps/athena/modules/rbac-registration-indexer/src/lib.rs @@ -40,6 +40,8 @@ use shared::{ }; use crate::database::{ + RBAC_REGISTRATION_PERSISTENT_TABLE_NAME, RBAC_REGISTRATION_VOLATILE_TABLE_NAME, + RBAC_STAKE_ADDRESS_PERSISTENT_TABLE_NAME, RBAC_STAKE_ADDRESS_VOLATILE_TABLE_NAME, create::{create_rbac_persistent_tables, create_rbac_volatile_tables}, data::{rbac_db::RbacDbData, rbac_stake_db::RbacStakeDbData}, delete::{ @@ -52,8 +54,6 @@ use crate::database::{ rbac_table::{insert_rbac_registration, prepare_insert_rbac_registration}, stake_addr_table::{insert_rbac_stake_address, prepare_insert_rbac_stake_address}, }, - RBAC_REGISTRATION_PERSISTENT_TABLE_NAME, RBAC_REGISTRATION_VOLATILE_TABLE_NAME, - RBAC_STAKE_ADDRESS_PERSISTENT_TABLE_NAME, RBAC_STAKE_ADDRESS_VOLATILE_TABLE_NAME, }; /// RBAC registration component. diff --git a/hermes/apps/athena/modules/rbac-registration/src/database/select/cat_id.rs b/hermes/apps/athena/modules/rbac-registration/src/database/select/cat_id.rs index d86d07e405..2d2e5d2400 100644 --- a/hermes/apps/athena/modules/rbac-registration/src/database/select/cat_id.rs +++ b/hermes/apps/athena/modules/rbac-registration/src/database/select/cat_id.rs @@ -7,15 +7,15 @@ use shared::{ log::log_error, sqlite::{ operation::Operation, - statement::{column_as, DatabaseStatement}, + statement::{DatabaseStatement, column_as}, }, }, }; use crate::{ database::{ - query_builder::QueryBuilder, select::TableSource, RBAC_REGISTRATION_PERSISTENT_TABLE_NAME, - RBAC_REGISTRATION_VOLATILE_TABLE_NAME, + RBAC_REGISTRATION_PERSISTENT_TABLE_NAME, RBAC_REGISTRATION_VOLATILE_TABLE_NAME, + query_builder::QueryBuilder, select::TableSource, }, rbac::{rbac_chain_metadata::RbacChainMetadata, registration_location::RegistrationLocation}, }; diff --git a/hermes/apps/athena/modules/rbac-registration/src/database/select/stake_addr.rs b/hermes/apps/athena/modules/rbac-registration/src/database/select/stake_addr.rs index 3c0e8125de..a36cc01149 100644 --- a/hermes/apps/athena/modules/rbac-registration/src/database/select/stake_addr.rs +++ b/hermes/apps/athena/modules/rbac-registration/src/database/select/stake_addr.rs @@ -3,7 +3,7 @@ use cardano_blockchain_types::StakeAddress; use shared::{ bindings::hermes::{ - logging::api::{log, Level}, + logging::api::{Level, log}, sqlite::api::{Sqlite, Statement, StepResult, Value}, }, sqlite_bind_parameters, @@ -11,16 +11,16 @@ use shared::{ log::log_error, sqlite::{ operation::Operation, - statement::{column_as, DatabaseStatement}, + statement::{DatabaseStatement, column_as}, }, }, }; use crate::{ database::{ - query_builder::QueryBuilder, select::cat_id::select_rbac_registration_chain_from_cat_id, RBAC_REGISTRATION_PERSISTENT_TABLE_NAME, RBAC_REGISTRATION_VOLATILE_TABLE_NAME, RBAC_STAKE_ADDRESS_PERSISTENT_TABLE_NAME, RBAC_STAKE_ADDRESS_VOLATILE_TABLE_NAME, + query_builder::QueryBuilder, select::cat_id::select_rbac_registration_chain_from_cat_id, }, rbac::{rbac_chain_metadata::RbacChainMetadata, registration_location::RegistrationLocation}, }; @@ -264,7 +264,7 @@ fn get_registration_info_from_txn_id( DatabaseStatement::reset_statement(stmt, FUNCTION_NAME)?; sqlite_bind_parameters!(stmt, FUNCTION_NAME, txn_id.to_vec() => "txn_id")?; - let result = match stmt.step() { + match stmt.step() { // This should have data since txn_id is extract from `rbac_stake_address` Ok(StepResult::Row) => { Ok(Some(( @@ -274,9 +274,7 @@ fn get_registration_info_from_txn_id( column_as::(stmt, 3, FUNCTION_NAME, "txn_idx")?, ))) }, - Ok(StepResult::Done) => { - return Ok(None); - }, + Ok(StepResult::Done) => Ok(None), Err(e) => { let error = format!("Failed to step: {e}"); log_error( @@ -288,8 +286,7 @@ fn get_registration_info_from_txn_id( ); anyhow::bail!(error); }, - }; - result + } } /// Construct a registration chain by walking back a chain diff --git a/hermes/apps/athena/modules/rbac-registration/src/lib.rs b/hermes/apps/athena/modules/rbac-registration/src/lib.rs index af70dba812..e3338221ad 100644 --- a/hermes/apps/athena/modules/rbac-registration/src/lib.rs +++ b/hermes/apps/athena/modules/rbac-registration/src/lib.rs @@ -91,7 +91,7 @@ impl exports::hermes::http_gateway::event::Guest for RbacRegistrationComponent { Some(HttpGatewayResponse::Http(HttpResponse { code, headers: vec![("content-type".to_string(), vec![ - "application/json".to_string() + "application/json".to_string(), ])], body: Bstr::from(match result.to_json() { Ok(json) => json, diff --git a/hermes/apps/athena/modules/rbac-registration/src/rbac/rbac_chain_metadata.rs b/hermes/apps/athena/modules/rbac-registration/src/rbac/rbac_chain_metadata.rs index 970424aa20..3f01a7fd1a 100644 --- a/hermes/apps/athena/modules/rbac-registration/src/rbac/rbac_chain_metadata.rs +++ b/hermes/apps/athena/modules/rbac-registration/src/rbac/rbac_chain_metadata.rs @@ -1,6 +1,6 @@ //! RBAC chain metadata. -use cardano_blockchain_types::{hashes::TransactionId, Slot}; +use cardano_blockchain_types::{Slot, hashes::TransactionId}; /// RBAC chain metadata. #[derive(Debug, Clone, Default)] diff --git a/hermes/apps/athena/modules/rbac-registration/src/service/api/registration_get/v1/chain_info.rs b/hermes/apps/athena/modules/rbac-registration/src/service/api/registration_get/v1/chain_info.rs index 5c6293bdf7..715cd5c6bc 100644 --- a/hermes/apps/athena/modules/rbac-registration/src/service/api/registration_get/v1/chain_info.rs +++ b/hermes/apps/athena/modules/rbac-registration/src/service/api/registration_get/v1/chain_info.rs @@ -1,6 +1,6 @@ //! A RBAC registration chain information. -use cardano_blockchain_types::{hashes::TransactionId, Network, Slot}; +use cardano_blockchain_types::{Network, Slot, hashes::TransactionId}; use rbac_registration::registration::cardano::RegistrationChain; /// A RBAC registration chain along with additional information. diff --git a/hermes/apps/athena/modules/rbac-registration/src/service/common/types/cardano/cip19_stake_address.rs b/hermes/apps/athena/modules/rbac-registration/src/service/common/types/cardano/cip19_stake_address.rs index deb20bbcf4..e276a60c8d 100644 --- a/hermes/apps/athena/modules/rbac-registration/src/service/common/types/cardano/cip19_stake_address.rs +++ b/hermes/apps/athena/modules/rbac-registration/src/service/common/types/cardano/cip19_stake_address.rs @@ -2,7 +2,7 @@ //! //! More information can be found in [CIP-19](https://cips.cardano.org/cip/CIP-19) -use cardano_blockchain_types::{pallas_addresses::Address, StakeAddress}; +use cardano_blockchain_types::{StakeAddress, pallas_addresses::Address}; /// Length of the decoded address. const DECODED_ADDR_LEN: usize = 29; diff --git a/hermes/apps/athena/modules/rbac-registration/src/service/common/types/cardano/transaction_id.rs b/hermes/apps/athena/modules/rbac-registration/src/service/common/types/cardano/transaction_id.rs index 61c8c5deee..91b808d77c 100644 --- a/hermes/apps/athena/modules/rbac-registration/src/service/common/types/cardano/transaction_id.rs +++ b/hermes/apps/athena/modules/rbac-registration/src/service/common/types/cardano/transaction_id.rs @@ -1,6 +1,6 @@ //! Transaction ID. -use cardano_blockchain_types::hashes::{TransactionId, BLAKE_2B256_SIZE}; +use cardano_blockchain_types::hashes::{BLAKE_2B256_SIZE, TransactionId}; use serde::Serialize; /// A Cardano transaction ID. diff --git a/hermes/apps/athena/modules/rbac-registration/src/service/common/types/generic/uuidv4.rs b/hermes/apps/athena/modules/rbac-registration/src/service/common/types/generic/uuidv4.rs index dd579a3412..0367875cc2 100644 --- a/hermes/apps/athena/modules/rbac-registration/src/service/common/types/generic/uuidv4.rs +++ b/hermes/apps/athena/modules/rbac-registration/src/service/common/types/generic/uuidv4.rs @@ -19,10 +19,10 @@ fn is_valid(uuidv4: &str) -> bool { #[allow(clippy::unwrap_used)] // Safe because the Regex is constant. static RE: LazyLock = LazyLock::new(|| Regex::new(PATTERN).unwrap()); - if RE.is_match(uuidv4) { - if let Ok(uuid) = uuid::Uuid::parse_str(uuidv4) { - return uuid.get_version() == Some(uuid::Version::Random); - } + if RE.is_match(uuidv4) + && let Ok(uuid) = uuid::Uuid::parse_str(uuidv4) + { + return uuid.get_version() == Some(uuid::Version::Random); } false } diff --git a/hermes/apps/athena/modules/staked-ada-indexer/src/index.rs b/hermes/apps/athena/modules/staked-ada-indexer/src/index.rs index 94b80c31ce..427ffd10bd 100644 --- a/hermes/apps/athena/modules/staked-ada-indexer/src/index.rs +++ b/hermes/apps/athena/modules/staked-ada-indexer/src/index.rs @@ -6,10 +6,10 @@ use shared::{ cardano_blockchain_types::{ + MultiEraBlock, Network, StakeAddress, hashes::{Blake2b256Hash, TransactionId}, pallas_addresses::{Address, ShelleyDelegationPart}, pallas_traverse::{MultiEraOutput, MultiEraTx}, - MultiEraBlock, Network, StakeAddress, }, database::staked_ada::{TxiByTxnIdRow, TxoAssetsByStakeRow, TxoByStakeRow}, utils::log::{error, warn}, diff --git a/hermes/apps/athena/modules/staked-ada/src/api/assets_get.rs b/hermes/apps/athena/modules/staked-ada/src/api/assets_get.rs index 150da844a7..8ff90b3591 100644 --- a/hermes/apps/athena/modules/staked-ada/src/api/assets_get.rs +++ b/hermes/apps/athena/modules/staked-ada/src/api/assets_get.rs @@ -5,8 +5,8 @@ use std::collections::{HashMap, HashSet}; use cardano_blockchain_types::StakeAddress; use shared::{ database::staked_ada::{ - get_txi_by_txn_ids, get_txo_assets_by_stake_address, get_txo_by_stake_address, - update_txo_spent, UpdateTxoSpentParams, + UpdateTxoSpentParams, get_txi_by_txn_ids, get_txo_assets_by_stake_address, + get_txo_by_stake_address, update_txo_spent, }, utils::{ common::{ @@ -241,10 +241,10 @@ fn build_stake_info( continue; } // Filter out spent TXOs. - if let Some(spent_slot) = txo_info.spent_slot_no { - if spent_slot <= slot_num { - continue; - } + if let Some(spent_slot) = txo_info.spent_slot_no + && spent_slot <= slot_num + { + continue; } let value = AdaValue::try_from(txo_info.value) diff --git a/hermes/apps/athena/modules/staked-ada/src/api/types.rs b/hermes/apps/athena/modules/staked-ada/src/api/types.rs index b5cacc184c..1cc654445e 100644 --- a/hermes/apps/athena/modules/staked-ada/src/api/types.rs +++ b/hermes/apps/athena/modules/staked-ada/src/api/types.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; -use cardano_blockchain_types::{hashes::TransactionId, Slot, TxnIndex}; +use cardano_blockchain_types::{Slot, TxnIndex, hashes::TransactionId}; use shared::utils::common::{ objects::cardano::stake_info::FullStakeInfo, responses::WithErrorResponses, }; diff --git a/hermes/apps/athena/modules/staked-ada/src/lib.rs b/hermes/apps/athena/modules/staked-ada/src/lib.rs index 048d8ad909..82bdec7202 100644 --- a/hermes/apps/athena/modules/staked-ada/src/lib.rs +++ b/hermes/apps/athena/modules/staked-ada/src/lib.rs @@ -26,7 +26,7 @@ shared::bindings_generate!({ }); export!(CatGatewayAPI); -use http::{header::CONTENT_TYPE, StatusCode}; +use http::{StatusCode, header::CONTENT_TYPE}; use mime::{APPLICATION_JSON, TEXT_HTML}; use regex::Regex; use shared::utils::{ @@ -39,7 +39,7 @@ use shared::utils::{ }; use crate::{ - api::{staked_ada_get, types::Responses, GetStakedAdaRequest}, + api::{GetStakedAdaRequest, staked_ada_get, types::Responses}, config::messages, error::{Result, StakedAdaError}, }; diff --git a/hermes/apps/athena/shared/Cargo.toml b/hermes/apps/athena/shared/Cargo.toml index aab490268c..41bafd64d2 100644 --- a/hermes/apps/athena/shared/Cargo.toml +++ b/hermes/apps/athena/shared/Cargo.toml @@ -1,5 +1,5 @@ [package] -edition = "2021" +edition = "2024" name = "shared" version = "0.1.0" license = "MIT OR Apache-2.0" diff --git a/hermes/apps/athena/shared/src/database/staked_ada/select.rs b/hermes/apps/athena/shared/src/database/staked_ada/select.rs index 8bc627fcf2..9ba0a1591e 100644 --- a/hermes/apps/athena/shared/src/database/staked_ada/select.rs +++ b/hermes/apps/athena/shared/src/database/staked_ada/select.rs @@ -1,6 +1,6 @@ //! `SELECT` queries. -use cardano_blockchain_types::{hashes::TransactionId, StakeAddress}; +use cardano_blockchain_types::{StakeAddress, hashes::TransactionId}; use crate::{ database::{ diff --git a/hermes/apps/athena/shared/src/database/staked_ada/types.rs b/hermes/apps/athena/shared/src/database/staked_ada/types.rs index bdbd1bf68c..8120b7a748 100644 --- a/hermes/apps/athena/shared/src/database/staked_ada/types.rs +++ b/hermes/apps/athena/shared/src/database/staked_ada/types.rs @@ -1,6 +1,6 @@ //! `SQLite` queries types. -use cardano_blockchain_types::{hashes::TransactionId, pallas_primitives::PolicyId, StakeAddress}; +use cardano_blockchain_types::{StakeAddress, hashes::TransactionId, pallas_primitives::PolicyId}; use derive_more::From; use num_bigint::{BigInt, BigUint}; diff --git a/hermes/apps/athena/shared/src/utils/common/auth/rbac/token.rs b/hermes/apps/athena/shared/src/utils/common/auth/rbac/token.rs index 93f569328d..3d0433ada6 100644 --- a/hermes/apps/athena/shared/src/utils/common/auth/rbac/token.rs +++ b/hermes/apps/athena/shared/src/utils/common/auth/rbac/token.rs @@ -9,12 +9,12 @@ use std::{ time::Duration, }; -use anyhow::{anyhow, Context, Result}; -use base64::{prelude::BASE64_URL_SAFE_NO_PAD, Engine}; +use anyhow::{Context, Result, anyhow}; +use base64::{Engine, prelude::BASE64_URL_SAFE_NO_PAD}; use cardano_blockchain_types::Network; use catalyst_types::catalyst_id::CatalystId; use chrono::{TimeDelta, Utc}; -use ed25519_dalek::{ed25519::signature::Signer, Signature, SigningKey, VerifyingKey}; +use ed25519_dalek::{Signature, SigningKey, VerifyingKey, ed25519::signature::Signer}; use rbac_registration::registration::cardano::RegistrationChain; use regex::Regex; diff --git a/hermes/apps/athena/shared/src/utils/common/types/cardano/as_at.rs b/hermes/apps/athena/shared/src/utils/common/types/cardano/as_at.rs index 86ebad2d47..72ee4865d5 100644 --- a/hermes/apps/athena/shared/src/utils/common/types/cardano/as_at.rs +++ b/hermes/apps/athena/shared/src/utils/common/types/cardano/as_at.rs @@ -20,7 +20,7 @@ pub struct AsAt((String, u64, SlotNo)); impl From for SlotNo { fn from(value: AsAt) -> Self { - value.0 .2 + value.0.2 } } @@ -29,6 +29,6 @@ impl Display for AsAt { &self, f: &mut fmt::Formatter<'_>, ) -> fmt::Result { - write!(f, "{}:{}", self.0 .0, self.0 .1) + write!(f, "{}:{}", self.0.0, self.0.1) } } diff --git a/hermes/apps/athena/shared/src/utils/common/types/cardano/cip19_stake_address.rs b/hermes/apps/athena/shared/src/utils/common/types/cardano/cip19_stake_address.rs index ed587b64a3..d4c75e461f 100644 --- a/hermes/apps/athena/shared/src/utils/common/types/cardano/cip19_stake_address.rs +++ b/hermes/apps/athena/shared/src/utils/common/types/cardano/cip19_stake_address.rs @@ -3,7 +3,7 @@ //! More information can be found in [CIP-19](https://cips.cardano.org/cip/CIP-19) use anyhow::bail; -use cardano_blockchain_types::{pallas_addresses::Address, StakeAddress}; +use cardano_blockchain_types::{StakeAddress, pallas_addresses::Address}; use crate::utils::common::types::string_types::impl_string_types; diff --git a/hermes/apps/athena/shared/src/utils/common/types/cardano/transaction_id.rs b/hermes/apps/athena/shared/src/utils/common/types/cardano/transaction_id.rs index 393f37ce40..5c994ba23e 100644 --- a/hermes/apps/athena/shared/src/utils/common/types/cardano/transaction_id.rs +++ b/hermes/apps/athena/shared/src/utils/common/types/cardano/transaction_id.rs @@ -1,6 +1,6 @@ //! Transaction ID. -use cardano_blockchain_types::hashes::{TransactionId, BLAKE_2B256_SIZE}; +use cardano_blockchain_types::hashes::{BLAKE_2B256_SIZE, TransactionId}; use crate::utils::{common::types::string_types::impl_string_types, hex::as_hex_string}; diff --git a/hermes/apps/athena/shared/src/utils/hex.rs b/hermes/apps/athena/shared/src/utils/hex.rs index f3bb0886c3..5127e41bea 100644 --- a/hermes/apps/athena/shared/src/utils/hex.rs +++ b/hermes/apps/athena/shared/src/utils/hex.rs @@ -1,6 +1,6 @@ //! Hex helper functions -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; /// Convert bytes to hex string with the `0x` prefix pub(crate) fn as_hex_string>(bytes: T) -> String { diff --git a/hermes/apps/athena/shared/src/utils/log.rs b/hermes/apps/athena/shared/src/utils/log.rs index 9c00b67a39..a9fa3bec21 100644 --- a/hermes/apps/athena/shared/src/utils/log.rs +++ b/hermes/apps/athena/shared/src/utils/log.rs @@ -3,7 +3,7 @@ use std::sync::Once; use log::Log; -pub use log::{debug, error, info, log_enabled, trace, warn, LevelFilter}; +pub use log::{LevelFilter, debug, error, info, log_enabled, trace, warn}; /// Compatibility between [`crate::bindings::hermes::logging`] and [`log`]. mod compat { diff --git a/hermes/apps/athena/shared/src/utils/settings/str_env_var.rs b/hermes/apps/athena/shared/src/utils/settings/str_env_var.rs index 7da1a0a0a5..793c5b6e38 100644 --- a/hermes/apps/athena/shared/src/utils/settings/str_env_var.rs +++ b/hermes/apps/athena/shared/src/utils/settings/str_env_var.rs @@ -132,7 +132,7 @@ impl StringEnvVar { (default.to_string().as_str(), redacted, choices.as_str()).into(), ); - let value = match T::from_str(choice.as_str()) { + match T::from_str(choice.as_str()) { Ok(var) => var, Err(error) => { error!( @@ -140,9 +140,7 @@ impl StringEnvVar { ); default }, - }; - - value + } } /// Get the read env var as a str. diff --git a/hermes/apps/athena/shared/src/utils/sqlite/mod.rs b/hermes/apps/athena/shared/src/utils/sqlite/mod.rs index b51e1f71b2..d21429136b 100644 --- a/hermes/apps/athena/shared/src/utils/sqlite/mod.rs +++ b/hermes/apps/athena/shared/src/utils/sqlite/mod.rs @@ -11,7 +11,7 @@ pub use wrappers::{Connection, Row, Rows, Statement, Transaction}; pub use crate::bindings::hermes::sqlite::api::Value; use crate::{ - bindings::hermes::sqlite::api::{open, Sqlite}, + bindings::hermes::sqlite::api::{Sqlite, open}, utils::log::log_error, }; diff --git a/hermes/apps/athena/shared/src/utils/sqlite/wrappers.rs b/hermes/apps/athena/shared/src/utils/sqlite/wrappers.rs index b0afcb1af2..a9a6517aaa 100644 --- a/hermes/apps/athena/shared/src/utils/sqlite/wrappers.rs +++ b/hermes/apps/athena/shared/src/utils/sqlite/wrappers.rs @@ -2,7 +2,7 @@ use std::{array, marker::PhantomData}; -use anyhow::{anyhow, Context as _}; +use anyhow::{Context as _, anyhow}; use derive_more::{Deref, DerefMut}; use crate::bindings::hermes::sqlite::api; diff --git a/hermes/bin/benches/module.rs b/hermes/bin/benches/module.rs index 578f57fe18..71b6f8f244 100644 --- a/hermes/bin/benches/module.rs +++ b/hermes/bin/benches/module.rs @@ -1,7 +1,7 @@ //! `wasm::Module` benchmark #![allow(missing_docs, clippy::missing_docs_in_private_items)] -use criterion::{criterion_group, criterion_main, Criterion}; +use criterion::{Criterion, criterion_group, criterion_main}; fn module_benches(c: &mut Criterion) { let mut group = c.benchmark_group("WASM module execution"); diff --git a/hermes/bin/src/cli/mod.rs b/hermes/bin/src/cli/mod.rs index 9054b6c80a..e70d5956d6 100644 --- a/hermes/bin/src/cli/mod.rs +++ b/hermes/bin/src/cli/mod.rs @@ -10,7 +10,7 @@ use std::{path::PathBuf, process::ExitCode}; use build_info::BUILD_INFO; use clap::{Parser, Subcommand}; -use console::{style, Emoji}; +use console::{Emoji, style}; use tracing::error; use crate::{ diff --git a/hermes/bin/src/cli/run.rs b/hermes/bin/src/cli/run.rs index c4eb7b3c1c..e4f86fbf2e 100644 --- a/hermes/bin/src/cli/run.rs +++ b/hermes/bin/src/cli/run.rs @@ -10,7 +10,7 @@ use crate::{ event::queue::Exit, ipfs, packaging::{ - app::{build_app, ApplicationPackage}, + app::{ApplicationPackage, build_app}, sign::certificate::{self, Certificate}, }, pool, reactor, diff --git a/hermes/bin/src/hdf5/dir.rs b/hermes/bin/src/hdf5/dir.rs index ae67eaa312..b970a35ca7 100644 --- a/hermes/bin/src/hdf5/dir.rs +++ b/hermes/bin/src/hdf5/dir.rs @@ -1,8 +1,8 @@ //! A Hermes HDF5 directory abstraction over the HDF5 Group object. use super::{ - resources::{Hdf5Resource, ResourceTrait}, File, Path, + resources::{Hdf5Resource, ResourceTrait}, }; use crate::errors::Errors; @@ -276,9 +276,10 @@ mod tests { assert!(dir.get_dir(&dir_1.into()).is_ok()); assert!(dir.get_dir(&format!("{dir_1}/{dir_2}").into()).is_ok()); - assert!(dir - .get_dir(&format!("{dir_1}/{dir_2}/{dir_3}").into()) - .is_ok()); + assert!( + dir.get_dir(&format!("{dir_1}/{dir_2}/{dir_3}").into()) + .is_ok() + ); assert!(dir.get_dir(&Path::from_str("not_created_dir")).is_err()); assert!(dir.create_dir(dir_1.into()).is_err()); @@ -307,18 +308,20 @@ mod tests { assert!(dir1.get_dir(&mounted_dir_name.into()).is_ok()); assert_eq!(dir1.get_dirs(&"".into()).unwrap().len(), 1); - assert!(dir1 - .get_dir(&format!("{mounted_dir_name}/{child_dir_name}").into()) - .is_ok()); + assert!( + dir1.get_dir(&format!("{mounted_dir_name}/{child_dir_name}").into()) + .is_ok() + ); assert_eq!( dir1.get_dirs(&format!("{mounted_dir_name}/{child_dir_name}").into()) .unwrap() .len(), 1 ); - assert!(dir1 - .get_dir(&format!("{mounted_dir_name}/{child_dir_name}/{child_dir_name}").into()) - .is_ok()); + assert!( + dir1.get_dir(&format!("{mounted_dir_name}/{child_dir_name}/{child_dir_name}").into()) + .is_ok() + ); } #[test] @@ -410,19 +413,23 @@ mod tests { .unwrap(); assert!(dir.get_dir(&base_dir_name.into()).is_ok()); - assert!(dir - .get_file(format!("{base_dir_name}/{file_1_name}").into()) - .is_ok()); - assert!(dir - .get_file(format!("{base_dir_name}/{file_2_name}").into()) - .is_ok()); - - assert!(dir - .get_dir(&format!("{base_dir_name}/{child_dir_name}").into()) - .is_ok()); - assert!(dir - .get_file(format!("{base_dir_name}/{child_dir_name}/{file_3_name}").into()) - .is_ok()); + assert!( + dir.get_file(format!("{base_dir_name}/{file_1_name}").into()) + .is_ok() + ); + assert!( + dir.get_file(format!("{base_dir_name}/{file_2_name}").into()) + .is_ok() + ); + + assert!( + dir.get_dir(&format!("{base_dir_name}/{child_dir_name}").into()) + .is_ok() + ); + assert!( + dir.get_file(format!("{base_dir_name}/{child_dir_name}/{file_3_name}").into()) + .is_ok() + ); // Remove directory from package assert!( @@ -431,18 +438,22 @@ mod tests { ); assert!(dir.remove_dir(base_dir_name.into()).is_ok()); assert!(dir.get_dir(&base_dir_name.into()).is_err()); - assert!(dir - .get_file(format!("{base_dir_name}/{file_1_name}").into()) - .is_err()); - assert!(dir - .get_file(format!("{base_dir_name}/{file_2_name}").into()) - .is_err()); - assert!(dir - .get_dir(&format!("{base_dir_name}/{child_dir_name}").into()) - .is_err()); - assert!(dir - .get_file(format!("{base_dir_name}/{child_dir_name}/{file_3_name}").into()) - .is_err()); + assert!( + dir.get_file(format!("{base_dir_name}/{file_1_name}").into()) + .is_err() + ); + assert!( + dir.get_file(format!("{base_dir_name}/{file_2_name}").into()) + .is_err() + ); + assert!( + dir.get_dir(&format!("{base_dir_name}/{child_dir_name}").into()) + .is_err() + ); + assert!( + dir.get_file(format!("{base_dir_name}/{child_dir_name}/{file_3_name}").into()) + .is_err() + ); } #[test] diff --git a/hermes/bin/src/hdf5/resources/builder.rs b/hermes/bin/src/hdf5/resources/builder.rs index c366c7b37a..1c0c99d5ef 100644 --- a/hermes/bin/src/hdf5/resources/builder.rs +++ b/hermes/bin/src/hdf5/resources/builder.rs @@ -6,7 +6,7 @@ use std::path::{Path, PathBuf}; use serde::{Deserialize, Deserializer}; -use super::{fs::FsResource, uri::Uri, ResourceTrait}; +use super::{ResourceTrait, fs::FsResource, uri::Uri}; /// Resource builder definition with the `serde::Deserialize` implementation. #[cfg_attr(debug_assertions, derive(Debug))] diff --git a/hermes/bin/src/ipfs/api.rs b/hermes/bin/src/ipfs/api.rs index ed72f8301b..c22e5967d2 100644 --- a/hermes/bin/src/ipfs/api.rs +++ b/hermes/bin/src/ipfs/api.rs @@ -1,5 +1,5 @@ //! Hermes IPFS State API -use super::{is_valid_dht_content, is_valid_pubsub_content, HERMES_IPFS}; +use super::{HERMES_IPFS, is_valid_dht_content, is_valid_pubsub_content}; use crate::{ app::ApplicationName, runtime_extensions::bindings::hermes::ipfs::api::{ @@ -134,7 +134,7 @@ pub(crate) fn hermes_ipfs_publish( ) -> Result { let ipfs = HERMES_IPFS.get().ok_or(Errno::ServiceUnavailable)?; ipfs.pubsub_publish(topic.to_string(), message) - .map(|m| m.0 .0) + .map(|m| m.0.0) } /// Evict Peer from node diff --git a/hermes/bin/src/ipfs/mod.rs b/hermes/bin/src/ipfs/mod.rs index 32b605a342..04934c9c50 100644 --- a/hermes/bin/src/ipfs/mod.rs +++ b/hermes/bin/src/ipfs/mod.rs @@ -15,7 +15,7 @@ use hermes_ipfs::{ MessageId as PubsubMessageId, }; use once_cell::sync::OnceCell; -use task::{ipfs_command_handler, IpfsCommand}; +use task::{IpfsCommand, ipfs_command_handler}; use tokio::{ runtime::Builder, sync::{mpsc, oneshot}, diff --git a/hermes/bin/src/ipfs/task.rs b/hermes/bin/src/ipfs/task.rs index 26ecc667b1..c4b275fe3f 100644 --- a/hermes/bin/src/ipfs/task.rs +++ b/hermes/bin/src/ipfs/task.rs @@ -2,8 +2,8 @@ use std::str::FromStr; use hermes_ipfs::{ - subscription_stream_task, AddIpfsFile, Cid, HermesIpfs, IpfsPath as PathIpfsFile, - MessageId as PubsubMessageId, PeerId as TargetPeerId, + AddIpfsFile, Cid, HermesIpfs, IpfsPath as PathIpfsFile, MessageId as PubsubMessageId, + PeerId as TargetPeerId, subscription_stream_task, }; use tokio::{ sync::{mpsc, oneshot}, @@ -12,7 +12,7 @@ use tokio::{ use super::HERMES_IPFS; use crate::{ - event::{queue::send, HermesEvent}, + event::{HermesEvent, queue::send}, runtime_extensions::{ bindings::hermes::ipfs::api::{ DhtKey, DhtValue, Errno, MessageData, PeerId, PubsubMessage, PubsubTopic, diff --git a/hermes/bin/src/logger.rs b/hermes/bin/src/logger.rs index 2b2dfd831b..41ff848c09 100644 --- a/hermes/bin/src/logger.rs +++ b/hermes/bin/src/logger.rs @@ -5,8 +5,8 @@ use std::str::FromStr; use derive_more::Display; use tracing::level_filters::LevelFilter; use tracing_subscriber::{ - fmt::{format::FmtSpan, time}, EnvFilter, FmtSubscriber, + fmt::{format::FmtSpan, time}, }; use crate::runtime_extensions::bindings::hermes::logging; diff --git a/hermes/bin/src/packaging/app/manifest.rs b/hermes/bin/src/packaging/app/manifest.rs index c9cc1e6da9..dba9b31247 100644 --- a/hermes/bin/src/packaging/app/manifest.rs +++ b/hermes/bin/src/packaging/app/manifest.rs @@ -2,7 +2,7 @@ use std::path::Path; -use super::super::{schema_validation::SchemaValidator, FileError}; +use super::super::{FileError, schema_validation::SchemaValidator}; use crate::hdf5::resources::ResourceBuilder; /// Hermes application package manifest.json definition. diff --git a/hermes/bin/src/packaging/app/mod.rs b/hermes/bin/src/packaging/app/mod.rs index d002300ac9..f6d68a553e 100644 --- a/hermes/bin/src/packaging/app/mod.rs +++ b/hermes/bin/src/packaging/app/mod.rs @@ -13,6 +13,7 @@ pub(crate) use manifest::{Manifest, ManifestModule}; pub(crate) use module_info::AppModuleInfo; use super::{ + FileError, MissingPackageFileError, hash::Blake2b256, metadata::{Metadata, MetadataSchema}, module::{self, ModulePackage}, @@ -22,13 +23,12 @@ use super::{ keys::PrivateKey, signature::{Signature, SignaturePayloadEncoding}, }, - FileError, MissingPackageFileError, }; use crate::{ errors::Errors, hdf5::{ - resources::{BytesResource, ResourceTrait}, Dir, File, Path, + resources::{BytesResource, ResourceTrait}, }, }; diff --git a/hermes/bin/src/packaging/app/module_info.rs b/hermes/bin/src/packaging/app/module_info.rs index bb169b1dbb..044476effd 100644 --- a/hermes/bin/src/packaging/app/module_info.rs +++ b/hermes/bin/src/packaging/app/module_info.rs @@ -1,8 +1,8 @@ //! An application's module info object use super::{ - module::{Config, ConfigInfo, SignaturePayload}, Metadata, ModulePackage, Signature, + module::{Config, ConfigInfo, SignaturePayload}, }; use crate::{ app::ApplicationName, @@ -121,7 +121,7 @@ mod tests { use super::{ super::{ super::sign::{certificate::Certificate, keys::PrivateKey}, - module::tests::{check_module_package_integrity, ModulePackageContent}, + module::tests::{ModulePackageContent, check_module_package_integrity}, }, *, }; diff --git a/hermes/bin/src/packaging/app/tests.rs b/hermes/bin/src/packaging/app/tests.rs index 4d1a4353ee..ba28ed8f5f 100644 --- a/hermes/bin/src/packaging/app/tests.rs +++ b/hermes/bin/src/packaging/app/tests.rs @@ -3,11 +3,11 @@ use std::io::Write; use module::{ + Config, tests::{ - check_package_dir_integrity, prepare_package_dir_dir, ModulePackageContent, - PackageDirContent, + ModulePackageContent, PackageDirContent, check_package_dir_integrity, + prepare_package_dir_dir, }, - Config, }; use temp_dir::TempDir; diff --git a/hermes/bin/src/packaging/module/manifest.rs b/hermes/bin/src/packaging/module/manifest.rs index d949424024..d95099723d 100644 --- a/hermes/bin/src/packaging/module/manifest.rs +++ b/hermes/bin/src/packaging/module/manifest.rs @@ -2,7 +2,7 @@ use std::path::Path; -use super::super::{schema_validation::SchemaValidator, FileError}; +use super::super::{FileError, schema_validation::SchemaValidator}; use crate::hdf5::resources::ResourceBuilder; /// WASM module package manifest.json definition. diff --git a/hermes/bin/src/packaging/module/mod.rs b/hermes/bin/src/packaging/module/mod.rs index 6f4aab51b2..2e5fc25c4f 100644 --- a/hermes/bin/src/packaging/module/mod.rs +++ b/hermes/bin/src/packaging/module/mod.rs @@ -16,6 +16,7 @@ pub(crate) use manifest::{Manifest, ManifestConfig}; pub(crate) use settings::SettingsSchema; use super::{ + FileError, MissingPackageFileError, metadata::{Metadata, MetadataSchema}, package::Package, sign::{ @@ -23,14 +24,13 @@ use super::{ keys::PrivateKey, signature::{Signature, SignaturePayloadEncoding}, }, - FileError, MissingPackageFileError, }; use crate::{ app::ApplicationName, errors::Errors, hdf5::{ - resources::{bytes::BytesResource, ResourceTrait}, Dir, File, Path, + resources::{ResourceTrait, bytes::BytesResource}, }, wasm::module::Module, }; diff --git a/hermes/bin/src/packaging/sign/certificate/mod.rs b/hermes/bin/src/packaging/sign/certificate/mod.rs index eba51c56a8..9fe86e8d7e 100644 --- a/hermes/bin/src/packaging/sign/certificate/mod.rs +++ b/hermes/bin/src/packaging/sign/certificate/mod.rs @@ -6,7 +6,7 @@ use std::path::Path; use x509_cert::der::{DecodePem, Encode}; -use super::super::{hash::Blake2b256, sign::keys::PublicKey, FileError}; +use super::super::{FileError, hash::Blake2b256, sign::keys::PublicKey}; /// x.509 cert instance. /// Wrapper over `x509_cert::Certificate` diff --git a/hermes/bin/src/packaging/sign/keys.rs b/hermes/bin/src/packaging/sign/keys.rs index 33a0f3c882..c2ee5e4018 100644 --- a/hermes/bin/src/packaging/sign/keys.rs +++ b/hermes/bin/src/packaging/sign/keys.rs @@ -6,9 +6,9 @@ use std::path::Path; use anyhow::anyhow; use ed25519_dalek::{ + SigningKey, VerifyingKey, ed25519::signature::Signer, pkcs8::{DecodePrivateKey, DecodePublicKey}, - SigningKey, VerifyingKey, }; use super::super::FileError; diff --git a/hermes/bin/src/packaging/sign/signature.rs b/hermes/bin/src/packaging/sign/signature.rs index 76c8f1744f..c58d7a7740 100644 --- a/hermes/bin/src/packaging/sign/signature.rs +++ b/hermes/bin/src/packaging/sign/signature.rs @@ -5,8 +5,8 @@ use std::io::Read; use coset::{ - iana, CborSerializable, CoseSign, CoseSignBuilder, CoseSignature, CoseSignatureBuilder, Header, - HeaderBuilder, + CborSerializable, CoseSign, CoseSignBuilder, CoseSignature, CoseSignatureBuilder, Header, + HeaderBuilder, iana, }; use super::{ @@ -275,19 +275,21 @@ mod tests { let mut cose_sign_modified_alg = cose_sign.clone(); cose_sign_modified_alg.protected.original_data = None; cose_sign_modified_alg.protected.header.alg = None; - assert!(Signature::::from_bytes( - &cose_sign_modified_alg.clone().to_vec().unwrap() - ) - .is_err()); + assert!( + Signature::::from_bytes( + &cose_sign_modified_alg.clone().to_vec().unwrap() + ) + .is_err() + ); cose_sign_modified_alg.protected.original_data = None; cose_sign_modified_alg.protected.header.alg = Some( coset::RegisteredLabelWithPrivate::Assigned(iana::Algorithm::ES256), ); - assert!(Signature::::from_bytes( - &cose_sign_modified_alg.to_vec().unwrap() - ) - .is_err()); + assert!( + Signature::::from_bytes(&cose_sign_modified_alg.to_vec().unwrap()) + .is_err() + ); let mut cose_sign_modified_content_type = cose_sign.clone(); cose_sign_modified_content_type.protected.original_data = None; @@ -295,10 +297,12 @@ mod tests { .protected .header .content_type = None; - assert!(Signature::::from_bytes( - &cose_sign_modified_content_type.clone().to_vec().unwrap() - ) - .is_err()); + assert!( + Signature::::from_bytes( + &cose_sign_modified_content_type.clone().to_vec().unwrap() + ) + .is_err() + ); cose_sign_modified_content_type.protected.original_data = None; cose_sign_modified_content_type @@ -307,10 +311,12 @@ mod tests { .content_type = Some(coset::RegisteredLabel::Assigned( iana::CoapContentFormat::Cbor, )); - assert!(Signature::::from_bytes( - &cose_sign_modified_content_type.clone().to_vec().unwrap() - ) - .is_err()); + assert!( + Signature::::from_bytes( + &cose_sign_modified_content_type.clone().to_vec().unwrap() + ) + .is_err() + ); } #[test] diff --git a/hermes/bin/src/pool.rs b/hermes/bin/src/pool.rs index 94e3bea054..e24fa1d12d 100644 --- a/hermes/bin/src/pool.rs +++ b/hermes/bin/src/pool.rs @@ -12,7 +12,7 @@ //! concurrently within this pool. use std::{ - sync::{atomic::AtomicUsize, Condvar, Mutex}, + sync::{Condvar, Mutex, atomic::AtomicUsize}, thread::available_parallelism, }; diff --git a/hermes/bin/src/reactor.rs b/hermes/bin/src/reactor.rs index 1fe6644604..5ea385b1a7 100644 --- a/hermes/bin/src/reactor.rs +++ b/hermes/bin/src/reactor.rs @@ -1,6 +1,6 @@ //! Hermes Reactor implementation. -use dashmap::{mapref::one::Ref, DashMap}; +use dashmap::{DashMap, mapref::one::Ref}; use once_cell::sync::OnceCell; use crate::{ diff --git a/hermes/bin/src/runtime_extensions/bindings/unchecked_exports.rs b/hermes/bin/src/runtime_extensions/bindings/unchecked_exports.rs index 7d651ae56b..dd2a9c4834 100644 --- a/hermes/bin/src/runtime_extensions/bindings/unchecked_exports.rs +++ b/hermes/bin/src/runtime_extensions/bindings/unchecked_exports.rs @@ -2,8 +2,8 @@ //! use. use wasmtime::{ - component::{self, ComponentNamedList, TypedFunc}, AsContextMut, + component::{self, ComponentNamedList, TypedFunc}, }; use crate::runtime_context::HermesRuntimeContext; diff --git a/hermes/bin/src/runtime_extensions/hermes/cardano/chain_sync.rs b/hermes/bin/src/runtime_extensions/hermes/cardano/chain_sync.rs index 2954d6b777..7f4263de07 100644 --- a/hermes/bin/src/runtime_extensions/hermes/cardano/chain_sync.rs +++ b/hermes/bin/src/runtime_extensions/hermes/cardano/chain_sync.rs @@ -1,6 +1,6 @@ //! Chain sync task -use cardano_chain_follower::{turbo_downloader::DlConfig, ChainSyncConfig}; +use cardano_chain_follower::{ChainSyncConfig, turbo_downloader::DlConfig}; use crate::runtime_extensions::hermes::cardano::{STATE, TOKIO_RUNTIME}; diff --git a/hermes/bin/src/runtime_extensions/hermes/cardano/host.rs b/hermes/bin/src/runtime_extensions/hermes/cardano/host.rs index b7d6ce604d..a2c46c2e58 100644 --- a/hermes/bin/src/runtime_extensions/hermes/cardano/host.rs +++ b/hermes/bin/src/runtime_extensions/hermes/cardano/host.rs @@ -11,10 +11,10 @@ use crate::{ SubscriptionId, SyncSlot, Transaction, TransactionError, TxnHash, TxnIdx, }, hermes::cardano::{ + STATE, SubscriptionType, block::{get_block_relative, get_is_rollback, get_tips}, chain_sync::spawn_chain_sync_task, network::{spawn_subscribe, sync_slot_to_point}, - SubscriptionType, STATE, }, utils::conversion::array_u8_32_to_tuple, }, diff --git a/hermes/bin/src/runtime_extensions/hermes/cardano/network.rs b/hermes/bin/src/runtime_extensions/hermes/cardano/network.rs index d94b6ef543..2988f21238 100644 --- a/hermes/bin/src/runtime_extensions/hermes/cardano/network.rs +++ b/hermes/bin/src/runtime_extensions/hermes/cardano/network.rs @@ -11,9 +11,9 @@ use crate::{ runtime_extensions::{ bindings::hermes::cardano::api::{CardanoNetwork, SubscriptionId, SyncSlot}, hermes::cardano::{ + CardanoError, STATE, SubscriptionType, block::get_tips, event::{build_and_send_block_event, build_and_send_roll_forward_event}, - CardanoError, SubscriptionType, STATE, }, }, wasm::module::ModuleId, diff --git a/hermes/bin/src/runtime_extensions/hermes/cron/state.rs b/hermes/bin/src/runtime_extensions/hermes/cron/state.rs index b49e2a319b..26f6c30696 100644 --- a/hermes/bin/src/runtime_extensions/hermes/cron/state.rs +++ b/hermes/bin/src/runtime_extensions/hermes/cron/state.rs @@ -14,7 +14,7 @@ use super::{ }; use crate::{ app::ApplicationName, - event::{queue::send, HermesEvent, TargetApp, TargetModule}, + event::{HermesEvent, TargetApp, TargetModule, queue::send}, runtime_extensions::{ bindings::hermes::cron::api::{CronEventTag, CronTagged, Instant}, hermes::cron::mkdelay_crontab, @@ -408,9 +408,11 @@ mod tests { // List returns empty vec. assert!(state.ls_crontabs(&hermes_app, None).is_empty()); // Delay returns false - assert!(!state - .delay_crontab(&hermes_app, 0, "test".to_string()) - .unwrap()); + assert!( + !state + .delay_crontab(&hermes_app, 0, "test".to_string()) + .unwrap() + ); // Remove returns false assert!(!state.rm_crontab(&hermes_app, CronTagged { when: "*".to_string(), diff --git a/hermes/bin/src/runtime_extensions/hermes/crypto/bip32_ed25519.rs b/hermes/bin/src/runtime_extensions/hermes/crypto/bip32_ed25519.rs index 9f03df7432..6ad181025e 100644 --- a/hermes/bin/src/runtime_extensions/hermes/crypto/bip32_ed25519.rs +++ b/hermes/bin/src/runtime_extensions/hermes/crypto/bip32_ed25519.rs @@ -151,6 +151,9 @@ mod tests_bip32_ed25519 { fn test_derive_new_private_key() { let xprv = XPrv::from_extended_and_chaincode(&XPRV1, &CHAINCODE1); let derived_xprv = derive_new_private_key(xprv, "m/1852'/1815'/0'/2/0").unwrap(); - assert_eq!(derived_xprv.to_string(), "b8ab42f1aacbcdb3ae858e3a3df88142b3ed27a2d3f432024e0d943fc1e597442d57545d84c8db2820b11509d944093bc605350e60c533b8886a405bd59eed6dcf356648fe9e9219d83e989c8ff5b5b337e2897b6554c1ab4e636de791fe5427"); + assert_eq!( + derived_xprv.to_string(), + "b8ab42f1aacbcdb3ae858e3a3df88142b3ed27a2d3f432024e0d943fc1e597442d57545d84c8db2820b11509d944093bc605350e60c533b8886a405bd59eed6dcf356648fe9e9219d83e989c8ff5b5b337e2897b6554c1ab4e636de791fe5427" + ); } } diff --git a/hermes/bin/src/runtime_extensions/hermes/crypto/bip39.rs b/hermes/bin/src/runtime_extensions/hermes/crypto/bip39.rs index 9b5af4dc6d..8ede9808e3 100644 --- a/hermes/bin/src/runtime_extensions/hermes/crypto/bip39.rs +++ b/hermes/bin/src/runtime_extensions/hermes/crypto/bip39.rs @@ -239,10 +239,10 @@ fn get_word_indices( for i in 0..word_count { let mut idx: u16 = 0; for j in 0..11 { - if let Some(value) = entropy_bits.get(i.saturating_mul(11).saturating_add(j)) { - if *value > 0 { - idx = idx.saturating_add(1 << (10_usize.saturating_sub(j))); - } + if let Some(value) = entropy_bits.get(i.saturating_mul(11).saturating_add(j)) + && *value > 0 + { + idx = idx.saturating_add(1 << (10_usize.saturating_sub(j))); } } word_index_vec.push(idx); diff --git a/hermes/bin/src/runtime_extensions/hermes/hash/blake2b.rs b/hermes/bin/src/runtime_extensions/hermes/hash/blake2b.rs index b265b186ce..2896915a74 100644 --- a/hermes/bin/src/runtime_extensions/hermes/hash/blake2b.rs +++ b/hermes/bin/src/runtime_extensions/hermes/hash/blake2b.rs @@ -123,7 +123,9 @@ mod tests_blake2b { assert_eq!( result.as_ref(), - hex!("8e27b2481dd1fe73d598104c03b1f67da60725abb73cf66e400177d73aee01e74b93f55adda27b0ad92e22e284b5e0cc95ad81b04b496bd58c4ae6bca5f56196") + hex!( + "8e27b2481dd1fe73d598104c03b1f67da60725abb73cf66e400177d73aee01e74b93f55adda27b0ad92e22e284b5e0cc95ad81b04b496bd58c4ae6bca5f56196" + ) ); } @@ -147,7 +149,9 @@ mod tests_blake2b { assert_eq!( result.as_ref(), - hex!("8e27b2481dd1fe73d598104c03b1f67da60725abb73cf66e400177d73aee01e74b93f55adda27b0ad92e22e284b5e0cc95ad81b04b496bd58c4ae6bca5f56196") + hex!( + "8e27b2481dd1fe73d598104c03b1f67da60725abb73cf66e400177d73aee01e74b93f55adda27b0ad92e22e284b5e0cc95ad81b04b496bd58c4ae6bca5f56196" + ) ); } @@ -175,8 +179,11 @@ mod tests_blake2b { let result = blake2bmac_impl(&buf, outlen, &key, None, None).unwrap(); assert_eq!( - result.as_ref(), - hex!("c28029cbab4e11d759e971d7e2a13dbe9ef60d2fa539cc03138b0432c3fdb2757b6c87383bd1074f5533c0c2ad2a5d2ac71bbd96f0f8fbb4c3ba0d4abb309115")); + result.as_ref(), + hex!( + "c28029cbab4e11d759e971d7e2a13dbe9ef60d2fa539cc03138b0432c3fdb2757b6c87383bd1074f5533c0c2ad2a5d2ac71bbd96f0f8fbb4c3ba0d4abb309115" + ) + ); } #[test] diff --git a/hermes/bin/src/runtime_extensions/hermes/http_gateway/event.rs b/hermes/bin/src/runtime_extensions/hermes/http_gateway/event.rs index ac17fbe4c5..96c1467842 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_gateway/event.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_gateway/event.rs @@ -6,7 +6,7 @@ use std::{collections::HashSet, env, result::Result::Ok, sync::mpsc::Sender}; use hyper::{self, body::Bytes}; -use reqwest::{blocking, Method as request}; +use reqwest::{Method as request, blocking}; use serde::{Deserialize, Serialize}; use tracing::error; use url::Url; @@ -341,10 +341,9 @@ impl HTTPEvent { .headers() .iter() .map(|(name, value)| { - (name.to_string(), vec![value - .to_str() - .unwrap_or("") - .to_string()]) + (name.to_string(), vec![ + value.to_str().unwrap_or("").to_string(), + ]) }) .collect(); diff --git a/hermes/bin/src/runtime_extensions/hermes/http_gateway/mod.rs b/hermes/bin/src/runtime_extensions/hermes/http_gateway/mod.rs index 8b28a645ff..5d32650a72 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_gateway/mod.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_gateway/mod.rs @@ -2,7 +2,7 @@ use gateway_task::spawn; use serde::Deserialize; -use subscription::{register_global_endpoint_subscription, EndpointSubscription}; +use subscription::{EndpointSubscription, register_global_endpoint_subscription}; use tracing::{error, info}; mod auth; diff --git a/hermes/bin/src/runtime_extensions/hermes/http_gateway/routing.rs b/hermes/bin/src/runtime_extensions/hermes/http_gateway/routing.rs index 3091c37fc1..19f1615ca8 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_gateway/routing.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_gateway/routing.rs @@ -2,8 +2,8 @@ use std::{ net::SocketAddr, result::Result::Ok, sync::{ - mpsc::{channel, Receiver, Sender}, LazyLock, + mpsc::{Receiver, Sender, channel}, }, time::Duration, }; @@ -11,9 +11,8 @@ use std::{ use anyhow::anyhow; use http_body_util::{BodyExt, Full}; use hyper::{ - self, + self, HeaderMap, Request, Response, StatusCode, body::{Body, Bytes, Incoming}, - HeaderMap, Request, Response, StatusCode, }; use regex::Regex; #[allow(unused_imports, reason = "`debug` used only in debug builds.")] diff --git a/hermes/bin/src/runtime_extensions/hermes/http_gateway/utils.rs b/hermes/bin/src/runtime_extensions/hermes/http_gateway/utils.rs index a4e53b2b1a..ebac1d4b8b 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_gateway/utils.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_gateway/utils.rs @@ -1,6 +1,6 @@ //! Utility functions for HTTP gateway -use hyper::{body::Body, HeaderMap, Response}; +use hyper::{HeaderMap, Response, body::Body}; use crate::runtime_extensions::hermes::http_gateway::event::HeadersKV; @@ -9,10 +9,9 @@ pub(crate) fn extract_headers_kv(headers: &HeaderMap) -> HeadersKV { headers .iter() .map(|(name, value)| { - (name.to_string(), vec![value - .to_str() - .unwrap_or_default() - .to_string()]) + (name.to_string(), vec![ + value.to_str().unwrap_or_default().to_string(), + ]) }) .collect() } diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index d243821bdf..4be7c7ddab 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -1,12 +1,12 @@ use std::sync::{Arc, LazyLock}; -use rustls::{pki_types::ServerName, ClientConfig, RootCertStore}; +use rustls::{ClientConfig, RootCertStore, pki_types::ServerName}; use tokio::{ io::{AsyncRead, AsyncReadExt, AsyncWriteExt}, net::TcpStream, sync::oneshot, }; -use tokio_rustls::{client, TlsConnector}; +use tokio_rustls::{TlsConnector, client}; use tracing::{error, trace}; use webpki_roots::TLS_SERVER_ROOTS; @@ -167,7 +167,7 @@ impl Connection { ) -> Result, ErrorCode> { let mut response = Vec::new(); match self { - Connection::Http(ref mut tcp_stream) => { + Connection::Http(tcp_stream) => { tcp_stream.write_all(body).await.map_err(|err| { error!("failed to send HTTP request: {err}"); ErrorCode::HttpSendFailed diff --git a/hermes/bin/src/runtime_extensions/hermes/integration_test/event.rs b/hermes/bin/src/runtime_extensions/hermes/integration_test/event.rs index c9454f8471..8bb8687dfc 100644 --- a/hermes/bin/src/runtime_extensions/hermes/integration_test/event.rs +++ b/hermes/bin/src/runtime_extensions/hermes/integration_test/event.rs @@ -10,7 +10,7 @@ use once_cell::sync::OnceCell; use temp_dir::TempDir; use crate::{ - app::{module_dispatch_event, ApplicationName}, + app::{ApplicationName, module_dispatch_event}, event::HermesEventPayload, runtime_extensions::bindings::{hermes::integration_test::api::TestResult, unchecked_exports}, vfs::VfsBootstrapper, diff --git a/hermes/bin/src/runtime_extensions/hermes/logging/log_msg.rs b/hermes/bin/src/runtime_extensions/hermes/logging/log_msg.rs index 652f15cb86..d8f4ae20b0 100644 --- a/hermes/bin/src/runtime_extensions/hermes/logging/log_msg.rs +++ b/hermes/bin/src/runtime_extensions/hermes/logging/log_msg.rs @@ -29,7 +29,7 @@ pub(crate) fn log_message( mod tests_log_msg { use super::*; use crate::{ - logger::{init, LoggerConfig}, + logger::{LoggerConfig, init}, runtime_extensions::bindings::hermes::logging::api::Level, }; diff --git a/hermes/bin/src/runtime_extensions/hermes/sqlite/connection/core.rs b/hermes/bin/src/runtime_extensions/hermes/sqlite/connection/core.rs index 340eb7de8f..5e27763b3f 100644 --- a/hermes/bin/src/runtime_extensions/hermes/sqlite/connection/core.rs +++ b/hermes/bin/src/runtime_extensions/hermes/sqlite/connection/core.rs @@ -5,8 +5,8 @@ use std::ptr::null_mut; use libsqlite3_sys::{ - sqlite3, sqlite3_close, sqlite3_errcode, sqlite3_errmsg, sqlite3_exec, sqlite3_prepare_v3, - sqlite3_stmt, SQLITE_OK, + SQLITE_OK, sqlite3, sqlite3_close, sqlite3_errcode, sqlite3_errmsg, sqlite3_exec, + sqlite3_prepare_v3, sqlite3_stmt, }; use stringzilla::stringzilla::StringZillableBinary; diff --git a/hermes/bin/src/runtime_extensions/hermes/sqlite/host.rs b/hermes/bin/src/runtime_extensions/hermes/sqlite/host.rs index 55a5c5d114..fde6eef4df 100644 --- a/hermes/bin/src/runtime_extensions/hermes/sqlite/host.rs +++ b/hermes/bin/src/runtime_extensions/hermes/sqlite/host.rs @@ -49,8 +49,8 @@ impl Host for HermesRuntimeContext { Err(err) => { if let Err(errno) = close(db_ptr) { anyhow::bail!( - "failed to create connection resource: {err}, also failed to close the connection with errno: {errno}..." - ) + "failed to create connection resource: {err}, also failed to close the connection with errno: {errno}..." + ) } anyhow::bail!( "failed to create connection resource: {err}, closing the connection..." diff --git a/hermes/bin/src/runtime_extensions/hermes/sqlite/kernel.rs b/hermes/bin/src/runtime_extensions/hermes/sqlite/kernel.rs index a7cc979565..0ba58ff15a 100644 --- a/hermes/bin/src/runtime_extensions/hermes/sqlite/kernel.rs +++ b/hermes/bin/src/runtime_extensions/hermes/sqlite/kernel.rs @@ -1,16 +1,16 @@ //! Core functionality implementation for the `SQLite` open function. use std::{ - ffi::{c_int, c_void, CString}, + ffi::{CString, c_int, c_void}, path::{Path, PathBuf}, time::Duration, }; use libsqlite3_sys::{ - sqlite3, sqlite3_busy_handler, sqlite3_db_filename, sqlite3_db_name, sqlite3_exec, - sqlite3_filename_database, sqlite3_filename_journal, sqlite3_filename_wal, sqlite3_open_v2, - sqlite3_soft_heap_limit64, sqlite3_wal_autocheckpoint, SQLITE_OK, SQLITE_OPEN_CREATE, - SQLITE_OPEN_NOMUTEX, SQLITE_OPEN_READONLY, SQLITE_OPEN_READWRITE, + SQLITE_OK, SQLITE_OPEN_CREATE, SQLITE_OPEN_NOMUTEX, SQLITE_OPEN_READONLY, + SQLITE_OPEN_READWRITE, sqlite3, sqlite3_busy_handler, sqlite3_db_filename, sqlite3_db_name, + sqlite3_exec, sqlite3_filename_database, sqlite3_filename_journal, sqlite3_filename_wal, + sqlite3_open_v2, sqlite3_soft_heap_limit64, sqlite3_wal_autocheckpoint, }; use rand::random; diff --git a/hermes/bin/src/runtime_extensions/hermes/sqlite/state/manager.rs b/hermes/bin/src/runtime_extensions/hermes/sqlite/state/manager.rs index 980ebf30eb..134e9fe51d 100644 --- a/hermes/bin/src/runtime_extensions/hermes/sqlite/state/manager.rs +++ b/hermes/bin/src/runtime_extensions/hermes/sqlite/state/manager.rs @@ -7,9 +7,9 @@ use crate::{ runtime_extensions::{ bindings::hermes::sqlite::api::Sqlite, hermes::sqlite::state::{ + ObjectPointer, connection::{AppConnections, DbHandle}, statement::AppStatement, - ObjectPointer, }, }, }; diff --git a/hermes/bin/src/runtime_extensions/hermes/sqlite/state/resource_manager.rs b/hermes/bin/src/runtime_extensions/hermes/sqlite/state/resource_manager.rs index ee92959e0c..a42f9dc3bb 100644 --- a/hermes/bin/src/runtime_extensions/hermes/sqlite/state/resource_manager.rs +++ b/hermes/bin/src/runtime_extensions/hermes/sqlite/state/resource_manager.rs @@ -7,11 +7,10 @@ use crate::{ runtime_extensions::{ bindings::hermes::sqlite::api::{Sqlite, Statement}, hermes::sqlite::state::{ - app_not_found_err, + ObjectPointer, app_not_found_err, connection::DbHandle, connection_not_found_err, manager::{AppSqliteState, SqliteState}, - ObjectPointer, }, }, }; diff --git a/hermes/bin/src/runtime_extensions/hermes/sqlite/statement/core.rs b/hermes/bin/src/runtime_extensions/hermes/sqlite/statement/core.rs index e7306c0a7a..58011acdb5 100644 --- a/hermes/bin/src/runtime_extensions/hermes/sqlite/statement/core.rs +++ b/hermes/bin/src/runtime_extensions/hermes/sqlite/statement/core.rs @@ -2,12 +2,11 @@ use std::os::raw::c_char; use libsqlite3_sys::{ - sqlite3_bind_blob, sqlite3_bind_double, sqlite3_bind_int, sqlite3_bind_int64, - sqlite3_bind_null, sqlite3_bind_text, sqlite3_column_blob, sqlite3_column_bytes, - sqlite3_column_double, sqlite3_column_int64, sqlite3_column_text, sqlite3_column_type, - sqlite3_finalize, sqlite3_reset, sqlite3_step, sqlite3_stmt, SQLITE_BLOB, SQLITE_DONE, - SQLITE_FLOAT, SQLITE_INTEGER, SQLITE_NULL, SQLITE_OK, SQLITE_ROW, SQLITE_TEXT, - SQLITE_TRANSIENT, + SQLITE_BLOB, SQLITE_DONE, SQLITE_FLOAT, SQLITE_INTEGER, SQLITE_NULL, SQLITE_OK, SQLITE_ROW, + SQLITE_TEXT, SQLITE_TRANSIENT, sqlite3_bind_blob, sqlite3_bind_double, sqlite3_bind_int, + sqlite3_bind_int64, sqlite3_bind_null, sqlite3_bind_text, sqlite3_column_blob, + sqlite3_column_bytes, sqlite3_column_double, sqlite3_column_int64, sqlite3_column_text, + sqlite3_column_type, sqlite3_finalize, sqlite3_reset, sqlite3_step, sqlite3_stmt, }; use crate::runtime_extensions::bindings::hermes::sqlite::api::{Errno, StepResult, Value}; diff --git a/hermes/bin/src/runtime_extensions/init/priority.rs b/hermes/bin/src/runtime_extensions/init/priority.rs index 0f48ea15b2..af80c854c4 100644 --- a/hermes/bin/src/runtime_extensions/init/priority.rs +++ b/hermes/bin/src/runtime_extensions/init/priority.rs @@ -19,10 +19,6 @@ impl RteInitPriority { &self, init: bool, ) -> i32 { - if init { - self.init - } else { - self.fini - } + if init { self.init } else { self.fini } } } diff --git a/hermes/bin/src/runtime_extensions/init/trait_app.rs b/hermes/bin/src/runtime_extensions/init/trait_app.rs index 9e3baed84e..db8ccce3c3 100644 --- a/hermes/bin/src/runtime_extensions/init/trait_app.rs +++ b/hermes/bin/src/runtime_extensions/init/trait_app.rs @@ -7,7 +7,7 @@ use std::sync::LazyLock; use dashmap::DashSet; use keyed_lock::sync::KeyedLock; -use tracing::{error, span, Level}; +use tracing::{Level, error, span}; use crate::{ app::ApplicationName, @@ -127,15 +127,13 @@ impl RteInitApp for RteApp { return Ok(()); // Not an error which should stop us running. } - let errors = run_init_fini!( + run_init_fini!( init = true, registry = RTE_INIT_APP_REGISTRY, rte_trait = RteInitApp, span_label = "Runtime Extension Node Initialization Span", (name) - ); - - errors + ) } fn fini( @@ -150,15 +148,13 @@ impl RteInitApp for RteApp { return Ok(()); // Not an error which should stop us running. } - let errors = run_init_fini!( + run_init_fini!( init = false, registry = RTE_INIT_APP_REGISTRY, rte_trait = RteInitApp, span_label = "Runtime Extension Node Initialization Span", (name) - ); - - errors + ) } } @@ -171,13 +167,15 @@ mod tests { fn test_all_registered_apps_have_constructors() { for registered in RTE_INIT_APP_REGISTRY.iter() { // Check all registered App Initializers have constructors. - assert!(registered.instanciate().is_some(), "Missing Constructor in the registered runtime extension [ name:{} - path:{} - file:{} - trait_name:{} - module_path:{} ]", - registered.name(), - registered.path(), - registered.file(), - registered.trait_name(), - registered.module_path(), - ); + assert!( + registered.instanciate().is_some(), + "Missing Constructor in the registered runtime extension [ name:{} - path:{} - file:{} - trait_name:{} - module_path:{} ]", + registered.name(), + registered.path(), + registered.file(), + registered.trait_name(), + registered.module_path(), + ); } } } diff --git a/hermes/bin/src/runtime_extensions/init/trait_event.rs b/hermes/bin/src/runtime_extensions/init/trait_event.rs index faa6a65b15..62eb3cbf50 100644 --- a/hermes/bin/src/runtime_extensions/init/trait_event.rs +++ b/hermes/bin/src/runtime_extensions/init/trait_event.rs @@ -7,7 +7,7 @@ use std::sync::LazyLock; use dashmap::DashSet; use keyed_lock::sync::KeyedLock; -use tracing::{error, span, Level}; +use tracing::{Level, error, span}; use crate::{ run_init_fini, @@ -146,15 +146,13 @@ impl RteInitEvent for RteEvent { return Ok(()); // Not an error which should stop us running. } - let errors = run_init_fini!( + run_init_fini!( init = true, registry = RTE_INIT_EVENT_REGISTRY, rte_trait = RteInitEvent, span_label = "Runtime Extension Event Initialization Span", (ctx) - ); - - errors + ) } fn fini( @@ -176,15 +174,13 @@ impl RteInitEvent for RteEvent { return Ok(()); // Not an error which should stop us running. } - let errors = run_init_fini!( + run_init_fini!( init = false, registry = RTE_INIT_EVENT_REGISTRY, rte_trait = RteInitEvent, span_label = "Runtime Extension Event Finalization Span", (ctx) - ); - - errors + ) } } @@ -197,13 +193,15 @@ mod tests { fn test_all_registered_apps_have_constructors() { for registered in RTE_INIT_EVENT_REGISTRY.iter() { // Check all registered App Initializers have constructors. - assert!(registered.instanciate().is_some(), "Missing Constructor in the registered runtime extension [ name:{} - path:{} - file:{} - trait_name:{} - module_path:{} ]", - registered.name(), - registered.path(), - registered.file(), - registered.trait_name(), - registered.module_path(), - ); + assert!( + registered.instanciate().is_some(), + "Missing Constructor in the registered runtime extension [ name:{} - path:{} - file:{} - trait_name:{} - module_path:{} ]", + registered.name(), + registered.path(), + registered.file(), + registered.trait_name(), + registered.module_path(), + ); } } } diff --git a/hermes/bin/src/runtime_extensions/init/trait_module.rs b/hermes/bin/src/runtime_extensions/init/trait_module.rs index 26e2954c04..d469665bce 100644 --- a/hermes/bin/src/runtime_extensions/init/trait_module.rs +++ b/hermes/bin/src/runtime_extensions/init/trait_module.rs @@ -7,7 +7,7 @@ use std::sync::LazyLock; use dashmap::DashSet; use keyed_lock::sync::KeyedLock; -use tracing::{error, span, Level}; +use tracing::{Level, error, span}; use crate::{ app::ApplicationName, @@ -141,15 +141,13 @@ impl RteInitModule for RteModule { return Ok(()); // Not an error which should stop us running. } - let errors = run_init_fini!( + run_init_fini!( init = true, registry = RTE_INIT_MODULE_REGISTRY, rte_trait = RteInitModule, span_label = "Runtime Extension Module Initialization Span", (name, module) - ); - - errors + ) } fn fini( @@ -167,15 +165,13 @@ impl RteInitModule for RteModule { return Ok(()); // Not an error which should stop us running. } - let errors = run_init_fini!( + run_init_fini!( init = false, registry = RTE_INIT_MODULE_REGISTRY, rte_trait = RteInitModule, span_label = "Runtime Extension Module Initialization Span", (name, module) - ); - - errors + ) } } @@ -188,13 +184,15 @@ mod tests { fn test_all_registered_apps_have_constructors() { for registered in RTE_INIT_MODULE_REGISTRY.iter() { // Check all registered App Initializers have constructors. - assert!(registered.instanciate().is_some(), "Missing Constructor in the registered runtime extension [ name:{} - path:{} - file:{} - trait_name:{} - module_path:{} ]", - registered.name(), - registered.path(), - registered.file(), - registered.trait_name(), - registered.module_path(), - ); + assert!( + registered.instanciate().is_some(), + "Missing Constructor in the registered runtime extension [ name:{} - path:{} - file:{} - trait_name:{} - module_path:{} ]", + registered.name(), + registered.path(), + registered.file(), + registered.trait_name(), + registered.module_path(), + ); } } } diff --git a/hermes/bin/src/runtime_extensions/init/trait_runtime.rs b/hermes/bin/src/runtime_extensions/init/trait_runtime.rs index a456f5d684..dc5ee2f75a 100644 --- a/hermes/bin/src/runtime_extensions/init/trait_runtime.rs +++ b/hermes/bin/src/runtime_extensions/init/trait_runtime.rs @@ -6,7 +6,7 @@ use std::sync::{LazyLock, Mutex}; -use tracing::{error, span, Level}; +use tracing::{Level, error, span}; use crate::{ add_rte_error, run_init_fini, @@ -105,7 +105,9 @@ impl RteInitRuntime for RteRuntime { match IS_RTE_RUNTIME_INITIALIZED.lock() { Ok(mut initialized) => { if *initialized { - error!("Multiple calls to RTE Node `init()`. This does not cause problems, but don't do it."); + error!( + "Multiple calls to RTE Node `init()`. This does not cause problems, but don't do it." + ); return Ok(()); // Not an error which should stop us running. } @@ -142,14 +144,18 @@ impl RteInitRuntime for RteRuntime { match IS_RTE_RUNTIME_INITIALIZED.lock() { Ok(initialized) => { if !*initialized { - error!("RTE Node `fini()` called but runtimes are not initialized. This does not cause problems by itself, but you probably did something very wrong."); + error!( + "RTE Node `fini()` called but runtimes are not initialized. This does not cause problems by itself, but you probably did something very wrong." + ); return Ok(()); // Not an error which stops us ending ok. } match IS_RTE_RUNTIME_FINALIZED.lock() { Ok(mut finalized) => { if *finalized { - error!("`runtime_fini()` called multiple times. This does not cause problems by itself, but you probably did something very wrong."); + error!( + "`runtime_fini()` called multiple times. This does not cause problems by itself, but you probably did something very wrong." + ); return Ok(()); // Not fatal, but still wrong. } @@ -206,13 +212,15 @@ mod tests { fn test_all_registered_apps_have_constructors() { for registered in RTE_INIT_RUNTIME_REGISTRY.iter() { // Check all registered App Initializers have constructors. - assert!(registered.instanciate().is_some(), "Missing Constructor in the registered runtime extension [ name:{} - path:{} - file:{} - trait_name:{} - module_path:{} ]", - registered.name(), - registered.path(), - registered.file(), - registered.trait_name(), - registered.module_path(), - ); + assert!( + registered.instanciate().is_some(), + "Missing Constructor in the registered runtime extension [ name:{} - path:{} - file:{} - trait_name:{} - module_path:{} ]", + registered.name(), + registered.path(), + registered.file(), + registered.trait_name(), + registered.module_path(), + ); } } } diff --git a/hermes/bin/src/runtime_extensions/mod.rs b/hermes/bin/src/runtime_extensions/mod.rs index b000e3aecd..166f3d4232 100644 --- a/hermes/bin/src/runtime_extensions/mod.rs +++ b/hermes/bin/src/runtime_extensions/mod.rs @@ -1,7 +1,7 @@ //! Hermes runtime extensions #![allow(clippy::disallowed_macros)] -use tracing::{span, Level}; +use tracing::{Level, span}; mod app_config; pub(crate) mod bindings; diff --git a/hermes/bin/src/runtime_extensions/resource_manager.rs b/hermes/bin/src/runtime_extensions/resource_manager.rs index 3921918e34..1ffdce5a92 100644 --- a/hermes/bin/src/runtime_extensions/resource_manager.rs +++ b/hermes/bin/src/runtime_extensions/resource_manager.rs @@ -166,10 +166,10 @@ where WitType: 'static /// Application not found error message. fn app_not_found_err() -> wasmtime::Error { let msg = format!( - "Application not found for resource <{}, {}>, need to add application first by calling `add_app`", - type_name::(), - type_name::() - ); + "Application not found for resource <{}, {}>, need to add application first by calling `add_app`", + type_name::(), + type_name::() + ); wasmtime::Error::msg(msg) } } diff --git a/hermes/bin/src/runtime_extensions/wasi/filesystem/host.rs b/hermes/bin/src/runtime_extensions/wasi/filesystem/host.rs index daef572f59..f59c30ae69 100644 --- a/hermes/bin/src/runtime_extensions/wasi/filesystem/host.rs +++ b/hermes/bin/src/runtime_extensions/wasi/filesystem/host.rs @@ -2,7 +2,7 @@ use std::io::{Seek, SeekFrom}; -use super::state::{get_state, Descriptor}; +use super::state::{Descriptor, get_state}; use crate::{ hdf5::Path, runtime_context::HermesRuntimeContext, diff --git a/hermes/bin/src/runtime_extensions/wasi/random/secure/host.rs b/hermes/bin/src/runtime_extensions/wasi/random/secure/host.rs index 16b6dd0ac0..e4a05a7725 100644 --- a/hermes/bin/src/runtime_extensions/wasi/random/secure/host.rs +++ b/hermes/bin/src/runtime_extensions/wasi/random/secure/host.rs @@ -1,6 +1,6 @@ //! Random RNG host implementation for WASM runtime. -use rand::{rngs::OsRng, TryRngCore}; +use rand::{TryRngCore, rngs::OsRng}; use crate::{ runtime_context::HermesRuntimeContext, runtime_extensions::bindings::wasi::random::random::Host, diff --git a/hermes/bin/src/vfs/bootstrap.rs b/hermes/bin/src/vfs/bootstrap.rs index 531fc70efd..25ee61ab59 100644 --- a/hermes/bin/src/vfs/bootstrap.rs +++ b/hermes/bin/src/vfs/bootstrap.rs @@ -5,8 +5,8 @@ use std::path::PathBuf; use hdf5 as hdf5_lib; use super::{ - permission::{PermissionLevel, PermissionsState}, Vfs, + permission::{PermissionLevel, PermissionsState}, }; use crate::hdf5 as hermes_hdf5; diff --git a/hermes/bin/src/vfs/permission.rs b/hermes/bin/src/vfs/permission.rs index caa3604816..fd3fde02a4 100644 --- a/hermes/bin/src/vfs/permission.rs +++ b/hermes/bin/src/vfs/permission.rs @@ -1,8 +1,8 @@ //! Permissions state management of the Hermes virtual file system. use std::sync::{ - atomic::{AtomicBool, Ordering}, Arc, + atomic::{AtomicBool, Ordering}, }; use dashmap::DashMap; @@ -94,7 +94,7 @@ impl PermissionsState { let new_node = PermissionNodeRef::default(); node.childs.insert(path_element, new_node.clone()); walk = new_node; - }; + } } // Update the last node with the provided permission walk.permission.store(permission.into(), Ordering::Release); @@ -122,7 +122,7 @@ impl PermissionsState { walk = child_node.clone(); } else { break; - }; + } } permission diff --git a/hermes/bin/src/wasm/module.rs b/hermes/bin/src/wasm/module.rs index 8245c60187..05a2f2d2cd 100644 --- a/hermes/bin/src/wasm/module.rs +++ b/hermes/bin/src/wasm/module.rs @@ -7,18 +7,18 @@ use std::{ io::Read, sync::{ - atomic::{AtomicU32, Ordering}, Arc, + atomic::{AtomicU32, Ordering}, }, }; use anyhow::Context as _; use rusty_ulid::Ulid; use wasmtime::{ + Store as WasmStore, component::{ self, Component as WasmModule, InstancePre as WasmInstancePre, Linker as WasmLinker, }, - Store as WasmStore, }; use crate::{ @@ -26,7 +26,7 @@ use crate::{ event::HermesEventPayload, runtime_context::HermesRuntimeContext, runtime_extensions::{ - bindings::{self, unchecked_exports, LinkOptions}, + bindings::{self, LinkOptions, unchecked_exports}, hermes::init::ComponentInstanceExt as _, init::{ trait_event::{RteEvent, RteInitEvent}, diff --git a/hermes/bin/src/wasm/patcher.rs b/hermes/bin/src/wasm/patcher.rs index 5e88b52115..d5bd163477 100644 --- a/hermes/bin/src/wasm/patcher.rs +++ b/hermes/bin/src/wasm/patcher.rs @@ -497,12 +497,12 @@ impl Patcher { #[cfg(test)] mod tests { use wasmtime::{ - component::{bindgen, Instance, Linker}, AsContextMut, Engine, Store, + component::{Instance, Linker, bindgen}, }; - use wasmtime_wasi::{p2::add_to_linker_sync, ResourceTable, WasiCtx, WasiCtxBuilder, WasiView}; + use wasmtime_wasi::{ResourceTable, WasiCtx, WasiCtxBuilder, WasiView, p2::add_to_linker_sync}; - use crate::wasm::patcher::{Patcher, WasmInternals, MAGIC}; + use crate::wasm::patcher::{MAGIC, Patcher, WasmInternals}; const LINEAR_MEMORY_PAGE_SIZE_BYTES: u32 = 65536; @@ -1083,9 +1083,11 @@ mod tests { let expected_pattern: Vec = std::iter::repeat_n([0xAA, 0xBB, 0xCC, 0xDD], 1024 / 4) .flatten() .collect(); - assert!(linear_memory - .windows(1024) - .any(|window| window == expected_pattern)); + assert!( + linear_memory + .windows(1024) + .any(|window| window == expected_pattern) + ); } struct MyCtx { diff --git a/hermes/bin/tests/integration/components/cron_callback/src/lib.rs b/hermes/bin/tests/integration/components/cron_callback/src/lib.rs index 7ffbe88967..45704cb6e1 100644 --- a/hermes/bin/tests/integration/components/cron_callback/src/lib.rs +++ b/hermes/bin/tests/integration/components/cron_callback/src/lib.rs @@ -38,7 +38,7 @@ impl bindings::exports::hermes::init::event::Guest for CronCallbackApp { CRON_TAG, ); - test_log(&format!("cron event added with result={}", result)); + test_log(&format!("cron event added with result={result}")); assert!(result); true diff --git a/hermes/bin/tests/integration/components/staked_ada_indexer_mock/src/events.rs b/hermes/bin/tests/integration/components/staked_ada_indexer_mock/src/events.rs index 08c041816b..2ecb00f368 100644 --- a/hermes/bin/tests/integration/components/staked_ada_indexer_mock/src/events.rs +++ b/hermes/bin/tests/integration/components/staked_ada_indexer_mock/src/events.rs @@ -2,7 +2,7 @@ use cardano_blockchain_types::hashes::{Blake2bHash, TransactionId}; use shared::{ - database::staked_ada::{create_tables, insert_txo_by_stake, TxoByStakeRow}, + database::staked_ada::{TxoByStakeRow, create_tables, insert_txo_by_stake}, utils::{common::types::cardano::cip19_stake_address::Cip19StakeAddress, log::info, sqlite}, }; diff --git a/hermes/bin/tests/integration/tests/serial/staked_ada.rs b/hermes/bin/tests/integration/tests/serial/staked_ada.rs index 946ef5680c..49c37b11a7 100644 --- a/hermes/bin/tests/integration/tests/serial/staked_ada.rs +++ b/hermes/bin/tests/integration/tests/serial/staked_ada.rs @@ -2,8 +2,8 @@ use std::{path::Path, str::FromStr, sync::Arc, time::Duration}; use anyhow::Context; use reqwest::{ - header::{HeaderName, HeaderValue, AUTHORIZATION, CONTENT_TYPE, HOST}, StatusCode, + header::{AUTHORIZATION, CONTENT_TYPE, HOST, HeaderName, HeaderValue}, }; use serial_test::serial; use temp_dir::TempDir; diff --git a/hermes/bin/tests/wasm-integration/main.rs b/hermes/bin/tests/wasm-integration/main.rs index 4a76aa0b3e..66ef8228c4 100644 --- a/hermes/bin/tests/wasm-integration/main.rs +++ b/hermes/bin/tests/wasm-integration/main.rs @@ -20,12 +20,12 @@ use std::{env, error::Error, ffi::OsStr, fs, path::Path, sync::Arc, time::Instan use hermes::{ app::ApplicationName, - runtime_extensions::hermes::integration_test::event::{execute_event, EventType}, + runtime_extensions::hermes::integration_test::event::{EventType, execute_event}, wasm::module::Module, }; use libtest_mimic::{Arguments, Failed, Measurement, Trial}; use tracing::{level_filters::LevelFilter, subscriber::SetGlobalDefaultError}; -use tracing_subscriber::{fmt::time, FmtSubscriber}; +use tracing_subscriber::{FmtSubscriber, fmt::time}; /// Init the logger #[allow(dead_code)] diff --git a/hermes/clippy.toml b/hermes/clippy.toml index caa289b27b..a03fd62fdb 100644 --- a/hermes/clippy.toml +++ b/hermes/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/hermes/rustfmt.toml b/hermes/rustfmt.toml index 8f2417eeb6..e1a6e84ac5 100644 --- a/hermes/rustfmt.toml +++ b/hermes/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/utilities/docs-preview/Earthfile b/utilities/docs-preview/Earthfile index 5da4f544c3..b09dfea46a 100644 --- a/utilities/docs-preview/Earthfile +++ b/utilities/docs-preview/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.5.28 AS docs-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.5.29 AS docs-ci # update-docs-dev-script: get the latest docs dev script from CI. update-docs-dev-script: diff --git a/wasm/examples/rust/cardano/Cargo.toml b/wasm/examples/rust/cardano/Cargo.toml index 84650aa83b..5d519508e6 100644 --- a/wasm/examples/rust/cardano/Cargo.toml +++ b/wasm/examples/rust/cardano/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "cardano" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] # The name of the built .wasm file. diff --git a/wasm/examples/rust/cardano_age/Cargo.toml b/wasm/examples/rust/cardano_age/Cargo.toml index 0f8744344b..4900833f29 100644 --- a/wasm/examples/rust/cardano_age/Cargo.toml +++ b/wasm/examples/rust/cardano_age/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "cardano_age" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] # The name of the built .wasm file. diff --git a/wasm/examples/rust/next_century/Cargo.toml b/wasm/examples/rust/next_century/Cargo.toml index 83befedabd..4eaf8b7636 100644 --- a/wasm/examples/rust/next_century/Cargo.toml +++ b/wasm/examples/rust/next_century/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "next_century" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] # The name of the built .wasm file. diff --git a/wasm/examples/rust/sqlite_version/Cargo.toml b/wasm/examples/rust/sqlite_version/Cargo.toml index 6ed689c71f..3e99806fc3 100644 --- a/wasm/examples/rust/sqlite_version/Cargo.toml +++ b/wasm/examples/rust/sqlite_version/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sqlite_version" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] # The name of the built .wasm file. diff --git a/wasm/integration-test/cardano/Cargo.toml b/wasm/integration-test/cardano/Cargo.toml index 872dd77abf..81edc149bf 100644 --- a/wasm/integration-test/cardano/Cargo.toml +++ b/wasm/integration-test/cardano/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "cardano-rte-test-component" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] # The name of the built .wasm file. diff --git a/wasm/integration-test/golang/Earthfile b/wasm/integration-test/golang/Earthfile index 34c3b3ce60..1918a6505d 100644 --- a/wasm/integration-test/golang/Earthfile +++ b/wasm/integration-test/golang/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/go:v3.5.28 AS go-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/go:v3.5.29 AS go-ci IMPORT ../.. AS wasm diff --git a/wasm/integration-test/http_reply/Cargo.toml b/wasm/integration-test/http_reply/Cargo.toml index b83eb40799..6d43747bcb 100644 --- a/wasm/integration-test/http_reply/Cargo.toml +++ b/wasm/integration-test/http_reply/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "http-test-component" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] # The name of the built .wasm file. diff --git a/wasm/integration-test/ipfs/Cargo.toml b/wasm/integration-test/ipfs/Cargo.toml index 4d79e06528..2faef17ea1 100644 --- a/wasm/integration-test/ipfs/Cargo.toml +++ b/wasm/integration-test/ipfs/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ipfs-test-component" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] # The name of the built .wasm file. diff --git a/wasm/integration-test/sqlite/Cargo.toml b/wasm/integration-test/sqlite/Cargo.toml index 4728a9dcd0..d629ef3f8f 100644 --- a/wasm/integration-test/sqlite/Cargo.toml +++ b/wasm/integration-test/sqlite/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sqlite-test-component" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] # The name of the built .wasm file. diff --git a/wasm/integration-test/wasi-filesystem/Cargo.toml b/wasm/integration-test/wasi-filesystem/Cargo.toml index d65f3596b3..a85831d510 100644 --- a/wasm/integration-test/wasi-filesystem/Cargo.toml +++ b/wasm/integration-test/wasi-filesystem/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wasi-filesystem" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] # The name of the built .wasm file. diff --git a/wasm/wasi/Earthfile b/wasm/wasi/Earthfile index 89f6ecfbfd..8391ab6b4a 100644 --- a/wasm/wasi/Earthfile +++ b/wasm/wasi/Earthfile @@ -1,8 +1,8 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.5.28 AS rust-ci -IMPORT github.com/input-output-hk/catalyst-ci/earthly/go:v3.5.28 AS go-ci -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.5.28 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.5.29 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/go:v3.5.29 AS go-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.5.29 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci