diff --git a/common/Cargo.toml b/common/Cargo.toml index 4e29b1e..54923a3 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "common" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/common/src/merkle_tree_public/hasher.rs b/common/src/merkle_tree_public/hasher.rs index b23388f..ed9443a 100644 --- a/common/src/merkle_tree_public/hasher.rs +++ b/common/src/merkle_tree_public/hasher.rs @@ -1,5 +1,5 @@ use rs_merkle::Hasher; -use sha2::{digest::FixedOutput, Digest, Sha256}; +use sha2::{Digest, Sha256, digest::FixedOutput}; use super::TreeHashType; diff --git a/common/src/merkle_tree_public/merkle_tree.rs b/common/src/merkle_tree_public/merkle_tree.rs index e2eb715..8911344 100644 --- a/common/src/merkle_tree_public/merkle_tree.rs +++ b/common/src/merkle_tree_public/merkle_tree.rs @@ -2,14 +2,14 @@ use std::{collections::HashMap, fmt, marker::PhantomData}; use rs_merkle::{MerkleProof, MerkleTree}; use serde::{ + Deserialize, Deserializer, Serialize, de::{SeqAccess, Visitor}, ser::SerializeSeq, - Deserialize, Deserializer, Serialize, }; use crate::{transaction::Transaction, utxo_commitment::UTXOCommitment}; -use super::{hasher::OwnHasher, tree_leav_item::TreeLeavItem, TreeHashType}; +use super::{TreeHashType, hasher::OwnHasher, tree_leav_item::TreeLeavItem}; #[derive(Clone)] pub struct HashStorageMerkleTree { diff --git a/common/src/rpc_primitives/errors.rs b/common/src/rpc_primitives/errors.rs index 6bbf207..fc52dd0 100644 --- a/common/src/rpc_primitives/errors.rs +++ b/common/src/rpc_primitives/errors.rs @@ -1,4 +1,4 @@ -use serde_json::{to_value, Value}; +use serde_json::{Value, to_value}; use std::fmt; #[derive(serde::Serialize)] @@ -65,7 +65,7 @@ impl RpcError { return Self::server_error(Some(format!( "Failed to serialize invalid parameters error: {:?}", err.to_string() - ))) + ))); } }; RpcError::new(-32_602, "Invalid params".to_owned(), Some(value)) @@ -178,7 +178,7 @@ impl From for RpcError { let error_data = match to_value(&e) { Ok(value) => value, Err(_err) => { - return RpcError::new_internal_error(None, "Failed to serialize ServerError") + return RpcError::new_internal_error(None, "Failed to serialize ServerError"); } }; RpcError::new_internal_error(Some(error_data), e.to_string().as_str()) diff --git a/common/src/rpc_primitives/message.rs b/common/src/rpc_primitives/message.rs index c6bdc58..e8e4186 100644 --- a/common/src/rpc_primitives/message.rs +++ b/common/src/rpc_primitives/message.rs @@ -315,10 +315,10 @@ impl From for Vec { #[cfg(test)] mod tests { + use serde_json::Value; use serde_json::de::from_slice; use serde_json::json; use serde_json::ser::to_vec; - use serde_json::Value; use super::*; diff --git a/common/src/rpc_primitives/requests.rs b/common/src/rpc_primitives/requests.rs index a4c18d7..a566ee2 100644 --- a/common/src/rpc_primitives/requests.rs +++ b/common/src/rpc_primitives/requests.rs @@ -1,8 +1,8 @@ use crate::parse_request; use super::errors::RpcParseError; -use super::parser::parse_params; use super::parser::RpcRequest; +use super::parser::parse_params; use serde::{Deserialize, Serialize}; use serde_json::Value; diff --git a/common/src/transaction.rs b/common/src/transaction.rs index afc4559..1d0ccec 100644 --- a/common/src/transaction.rs +++ b/common/src/transaction.rs @@ -1,12 +1,12 @@ use k256::ecdsa::{ - signature::{Signer, Verifier}, Signature, SigningKey, VerifyingKey, + signature::{Signer, Verifier}, }; use log::info; use secp256k1_zkp::{PedersenCommitment, Tweak}; use serde::{Deserialize, Serialize}; -use sha2::{digest::FixedOutput, Digest}; +use sha2::{Digest, digest::FixedOutput}; use crate::merkle_tree_public::TreeHashType; @@ -297,9 +297,9 @@ impl AuthenticatedTransaction { #[cfg(test)] mod tests { use super::*; - use k256::{ecdsa::signature::Signer, FieldBytes}; - use secp256k1_zkp::{constants::SECRET_KEY_SIZE, Tweak}; - use sha2::{digest::FixedOutput, Digest}; + use k256::{FieldBytes, ecdsa::signature::Signer}; + use secp256k1_zkp::{Tweak, constants::SECRET_KEY_SIZE}; + use sha2::{Digest, digest::FixedOutput}; use crate::{ merkle_tree_public::TreeHashType, @@ -378,11 +378,13 @@ mod tests { assert_eq!(authenticated_tx.transaction(), &transaction); assert_eq!(hash, &transaction.body.hash()); - assert!(authenticated_tx - .transaction() - .public_key - .verify(&transaction.body.to_bytes(), &signature) - .is_ok()); + assert!( + authenticated_tx + .transaction() + .public_key + .verify(&transaction.body.to_bytes(), &signature) + .is_ok() + ); } #[test] diff --git a/key_protocol/Cargo.toml b/key_protocol/Cargo.toml index 2f2bb07..3150dfe 100644 --- a/key_protocol/Cargo.toml +++ b/key_protocol/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "key_protocol" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/key_protocol/src/key_management/ephemeral_key_holder.rs b/key_protocol/src/key_management/ephemeral_key_holder.rs index ecfb09e..b304292 100644 --- a/key_protocol/src/key_management/ephemeral_key_holder.rs +++ b/key_protocol/src/key_management/ephemeral_key_holder.rs @@ -1,9 +1,9 @@ -use aes_gcm::{aead::Aead, AeadCore, Aes256Gcm, KeyInit}; -use elliptic_curve::point::AffineCoordinates; +use aes_gcm::{AeadCore, Aes256Gcm, KeyInit, aead::Aead}; use elliptic_curve::PrimeField; +use elliptic_curve::point::AffineCoordinates; use k256::{AffinePoint, FieldBytes, Scalar}; use log::info; -use rand::{rngs::OsRng, RngCore}; +use rand::{RngCore, rngs::OsRng}; use super::constants_types::{CipherText, Nonce}; diff --git a/key_protocol/src/key_management/mod.rs b/key_protocol/src/key_management/mod.rs index 2c38375..1a037ef 100644 --- a/key_protocol/src/key_management/mod.rs +++ b/key_protocol/src/key_management/mod.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use aes_gcm::{aead::Aead, Aes256Gcm, KeyInit}; +use aes_gcm::{Aes256Gcm, KeyInit, aead::Aead}; use constants_types::{CipherText, Nonce}; use elliptic_curve::point::AffineCoordinates; use k256::AffinePoint; @@ -136,8 +136,8 @@ impl KeyChain { #[cfg(test)] mod tests { use aes_gcm::{ - aead::{Aead, KeyInit, OsRng}, Aes256Gcm, + aead::{Aead, KeyInit, OsRng}, }; use constants_types::{CipherText, Nonce}; use constants_types::{NULLIFIER_SECRET_CONST, VIEWING_SECRET_CONST}; diff --git a/key_protocol/src/key_management/secret_holders.rs b/key_protocol/src/key_management/secret_holders.rs index 47342ec..c6b2948 100644 --- a/key_protocol/src/key_management/secret_holders.rs +++ b/key_protocol/src/key_management/secret_holders.rs @@ -1,9 +1,9 @@ use common::merkle_tree_public::TreeHashType; use elliptic_curve::PrimeField; use k256::{AffinePoint, FieldBytes, Scalar}; -use rand::{rngs::OsRng, RngCore}; +use rand::{RngCore, rngs::OsRng}; use serde::{Deserialize, Serialize}; -use sha2::{digest::FixedOutput, Digest}; +use sha2::{Digest, digest::FixedOutput}; use super::constants_types::{NULLIFIER_SECRET_CONST, VIEWING_SECRET_CONST}; diff --git a/key_protocol/src/key_protocol_core/mod.rs b/key_protocol/src/key_protocol_core/mod.rs index 67cb52c..7757183 100644 --- a/key_protocol/src/key_protocol_core/mod.rs +++ b/key_protocol/src/key_protocol_core/mod.rs @@ -36,7 +36,9 @@ impl NSSAUserData { accounts_keys: HashMap, ) -> Result { if !Self::valid_key_transaction_pairing_check(&accounts_keys) { - anyhow::bail!("Key transaction pairing check not satisfied, there is addresses, which is not derived from keys"); + anyhow::bail!( + "Key transaction pairing check not satisfied, there is addresses, which is not derived from keys" + ); } let key_holder = KeyChain::new_os_random_with_accounts(accounts_keys); diff --git a/mempool/Cargo.toml b/mempool/Cargo.toml index ff8b855..16327ac 100644 --- a/mempool/Cargo.toml +++ b/mempool/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "mempool" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/nssa/program_methods/Cargo.toml b/nssa/program_methods/Cargo.toml index af52307..40dab21 100644 --- a/nssa/program_methods/Cargo.toml +++ b/nssa/program_methods/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "program-methods" version = "0.1.0" -edition = "2021" +edition = "2024" [build-dependencies] risc0-build = { version = "3.0.3" } diff --git a/nssa/program_methods/guest/Cargo.toml b/nssa/program_methods/guest/Cargo.toml index 0d47ccd..da4dbe8 100644 --- a/nssa/program_methods/guest/Cargo.toml +++ b/nssa/program_methods/guest/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "programs" version = "0.1.0" -edition = "2021" +edition = "2024" [workspace] diff --git a/nssa/test_program_methods/Cargo.toml b/nssa/test_program_methods/Cargo.toml index 50d6ca2..0317d2b 100644 --- a/nssa/test_program_methods/Cargo.toml +++ b/nssa/test_program_methods/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "test-program-methods" version = "0.1.0" -edition = "2021" +edition = "2024" [build-dependencies] risc0-build = { version = "3.0.3" } diff --git a/nssa/test_program_methods/guest/Cargo.toml b/nssa/test_program_methods/guest/Cargo.toml index 0d47ccd..da4dbe8 100644 --- a/nssa/test_program_methods/guest/Cargo.toml +++ b/nssa/test_program_methods/guest/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "programs" version = "0.1.0" -edition = "2021" +edition = "2024" [workspace] diff --git a/rustfmt.toml b/rustfmt.toml index 3a26366..f216078 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1 +1 @@ -edition = "2021" +edition = "2024" diff --git a/sequencer_core/Cargo.toml b/sequencer_core/Cargo.toml index 2e3570b..ecfb323 100644 --- a/sequencer_core/Cargo.toml +++ b/sequencer_core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sequencer_core" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] hex.workspace = true diff --git a/sequencer_core/src/sequencer_store/mod.rs b/sequencer_core/src/sequencer_store/mod.rs index 4254ed7..bb0a7c1 100644 --- a/sequencer_core/src/sequencer_store/mod.rs +++ b/sequencer_core/src/sequencer_store/mod.rs @@ -3,7 +3,7 @@ use std::path::Path; use block_store::SequecerBlockStore; use common::block::HashableBlockData; use nssa::{self, Address}; -use rand::{rngs::OsRng, RngCore}; +use rand::{RngCore, rngs::OsRng}; use crate::config::AccountInitialData; diff --git a/sequencer_rpc/Cargo.toml b/sequencer_rpc/Cargo.toml index c6ce004..a0111f6 100644 --- a/sequencer_rpc/Cargo.toml +++ b/sequencer_rpc/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sequencer_rpc" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/sequencer_rpc/src/lib.rs b/sequencer_rpc/src/lib.rs index 1112dbd..2973c42 100644 --- a/sequencer_rpc/src/lib.rs +++ b/sequencer_rpc/src/lib.rs @@ -5,8 +5,8 @@ pub mod types; use std::sync::Arc; use common::rpc_primitives::{ - errors::{RpcError, RpcErrorKind}, RpcPollingConfig, + errors::{RpcError, RpcErrorKind}, }; use sequencer_core::SequencerCore; use serde::Serialize; diff --git a/sequencer_rpc/src/net_utils.rs b/sequencer_rpc/src/net_utils.rs index c421f17..b373823 100644 --- a/sequencer_rpc/src/net_utils.rs +++ b/sequencer_rpc/src/net_utils.rs @@ -2,13 +2,13 @@ use std::io; use std::sync::Arc; use actix_cors::Cors; -use actix_web::{http, middleware, web, App, Error as HttpError, HttpResponse, HttpServer}; +use actix_web::{App, Error as HttpError, HttpResponse, HttpServer, http, middleware, web}; use futures::Future; use futures::FutureExt; use log::info; -use common::rpc_primitives::message::Message; use common::rpc_primitives::RpcConfig; +use common::rpc_primitives::message::Message; use sequencer_core::SequencerCore; use tokio::sync::Mutex; diff --git a/sequencer_rpc/src/process.rs b/sequencer_rpc/src/process.rs index 5d7b4be..ad05843 100644 --- a/sequencer_rpc/src/process.rs +++ b/sequencer_rpc/src/process.rs @@ -1,5 +1,5 @@ use actix_web::Error as HttpError; -use base64::{engine::general_purpose, Engine}; +use base64::{Engine, engine::general_purpose}; use nssa; use sequencer_core::config::AccountInitialData; use serde_json::Value; @@ -26,7 +26,7 @@ use common::rpc_primitives::requests::{ SendTxResponse, }; -use super::{respond, types::err_rpc::RpcErr, JsonHandler}; +use super::{JsonHandler, respond, types::err_rpc::RpcErr}; pub const HELLO: &str = "hello"; pub const SEND_TX: &str = "send_tx"; @@ -276,13 +276,13 @@ impl JsonHandler { mod tests { use std::sync::Arc; - use crate::{rpc_handler, JsonHandler}; - use base64::{engine::general_purpose, Engine}; + use crate::{JsonHandler, rpc_handler}; + use base64::{Engine, engine::general_purpose}; use common::rpc_primitives::RpcPollingConfig; use sequencer_core::{ - config::{AccountInitialData, SequencerConfig}, SequencerCore, + config::{AccountInitialData, SequencerConfig}, }; use serde_json::Value; use tempfile::tempdir; @@ -368,7 +368,7 @@ mod tests { } async fn call_rpc_handler_with_json(handler: JsonHandler, request_json: Value) -> Value { - use actix_web::{test, web, App}; + use actix_web::{App, test, web}; let app = test::init_service( App::new() diff --git a/sequencer_runner/Cargo.toml b/sequencer_runner/Cargo.toml index b42fcb6..a610f8d 100644 --- a/sequencer_runner/Cargo.toml +++ b/sequencer_runner/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sequencer_runner" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/sequencer_runner/src/lib.rs b/sequencer_runner/src/lib.rs index 625350b..b682a18 100644 --- a/sequencer_runner/src/lib.rs +++ b/sequencer_runner/src/lib.rs @@ -5,7 +5,7 @@ use anyhow::Result; use clap::Parser; use common::rpc_primitives::RpcConfig; use log::info; -use sequencer_core::{config::SequencerConfig, SequencerCore}; +use sequencer_core::{SequencerCore, config::SequencerConfig}; use sequencer_rpc::new_http_server; use tokio::{sync::Mutex, task::JoinHandle}; @@ -71,7 +71,9 @@ pub async fn main_runner() -> Result<()> { if let Some(ref rust_log) = app_config.override_rust_log { info!("RUST_LOG env var set to {rust_log:?}"); - std::env::set_var(RUST_LOG, rust_log); + unsafe { + std::env::set_var(RUST_LOG, rust_log); + } } //ToDo: Add restart on failures diff --git a/storage/Cargo.toml b/storage/Cargo.toml index c4fd3a9..d756dd3 100644 --- a/storage/Cargo.toml +++ b/storage/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "storage" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/storage/src/lib.rs b/storage/src/lib.rs index 0dd12b7..9ead317 100644 --- a/storage/src/lib.rs +++ b/storage/src/lib.rs @@ -5,7 +5,7 @@ use error::DbError; use rocksdb::{ BoundColumnFamily, ColumnFamilyDescriptor, DBWithThreadMode, MultiThreaded, Options, }; -use sc_db_utils::{produce_blob_from_fit_vec, DataBlob, DataBlobChangeVariant}; +use sc_db_utils::{DataBlob, DataBlobChangeVariant, produce_blob_from_fit_vec}; pub mod error; pub mod sc_db_utils; diff --git a/storage/src/sc_db_utils.rs b/storage/src/sc_db_utils.rs index c86828e..af982cf 100644 --- a/storage/src/sc_db_utils.rs +++ b/storage/src/sc_db_utils.rs @@ -1,4 +1,4 @@ -use serde::{de::Error, Deserialize, Serialize}; +use serde::{Deserialize, Serialize, de::Error}; use crate::SC_DATA_BLOB_SIZE; diff --git a/wallet/Cargo.toml b/wallet/Cargo.toml index b973e1c..6078f68 100644 --- a/wallet/Cargo.toml +++ b/wallet/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wallet" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] anyhow.workspace = true diff --git a/wallet/src/helperfunctions.rs b/wallet/src/helperfunctions.rs index 0ad9aed..8a7b7b6 100644 --- a/wallet/src/helperfunctions.rs +++ b/wallet/src/helperfunctions.rs @@ -5,8 +5,8 @@ use key_protocol::key_protocol_core::NSSAUserData; use nssa::Address; use crate::{ - config::{PersistentAccountData, WalletConfig}, HOME_DIR_ENV_VAR, + config::{PersistentAccountData, WalletConfig}, }; ///Get home dir for wallet. Env var `NSSA_WALLET_HOME_DIR` must be set before execution to succeed. @@ -69,12 +69,16 @@ mod tests { #[test] fn test_get_home_get_env_var() { - std::env::set_var(HOME_DIR_ENV_VAR, "/path/to/configs"); + unsafe { + std::env::set_var(HOME_DIR_ENV_VAR, "/path/to/configs"); + } let home = get_home().unwrap(); assert_eq!(PathBuf::from_str("/path/to/configs").unwrap(), home); - std::env::remove_var(HOME_DIR_ENV_VAR); + unsafe { + std::env::remove_var(HOME_DIR_ENV_VAR); + } } } diff --git a/wallet/src/lib.rs b/wallet/src/lib.rs index 8d4efc8..3814925 100644 --- a/wallet/src/lib.rs +++ b/wallet/src/lib.rs @@ -2,8 +2,8 @@ use std::{fs::File, io::Write, path::PathBuf, str::FromStr, sync::Arc}; use base64::Engine; use common::{ - sequencer_client::{json::SendTxResponse, SequencerClient}, ExecutionFailureKind, + sequencer_client::{SequencerClient, json::SendTxResponse}, }; use anyhow::Result; diff --git a/wallet/src/main.rs b/wallet/src/main.rs index f8c91f8..b296400 100644 --- a/wallet/src/main.rs +++ b/wallet/src/main.rs @@ -1,7 +1,7 @@ use anyhow::Result; use clap::Parser; use tokio::runtime::Builder; -use wallet::{execute_subcommand, Args}; +use wallet::{Args, execute_subcommand}; pub const NUM_THREADS: usize = 2;