From 00773d7457cb185c8b9cc55ae2e76dd421bbcc9a Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Sat, 9 Aug 2025 18:40:32 -0300 Subject: [PATCH] clippy --- accounts/src/account_core/address.rs | 2 -- accounts/src/account_core/mod.rs | 4 ++-- accounts/src/key_management/mod.rs | 8 ++++---- common/src/block.rs | 2 +- common/src/rpc_primitives/requests.rs | 1 - common/src/sequencer_client/json.rs | 1 - common/src/sequencer_client/mod.rs | 1 - common/src/test_utils.rs | 8 +------- nssa/core/src/program.rs | 1 - nssa/src/signature.rs | 4 ++-- nssa/src/state.rs | 9 +++++---- sequencer_core/src/lib.rs | 13 +++---------- sequencer_core/src/sequencer_store/block_store.rs | 4 ++-- sequencer_core/src/sequencer_store/mod.rs | 8 ++------ sequencer_rpc/src/process.rs | 10 +++------- wallet/src/lib.rs | 7 +------ 16 files changed, 26 insertions(+), 57 deletions(-) diff --git a/accounts/src/account_core/address.rs b/accounts/src/account_core/address.rs index 3b61521..0740027 100644 --- a/accounts/src/account_core/address.rs +++ b/accounts/src/account_core/address.rs @@ -1,5 +1,3 @@ -use common::transaction::SignaturePublicKey; -use tiny_keccak::{Hasher, Keccak}; // TODO: Consider wrapping `AccountAddress` in a struct. diff --git a/accounts/src/account_core/mod.rs b/accounts/src/account_core/mod.rs index 6b8384d..58154f0 100644 --- a/accounts/src/account_core/mod.rs +++ b/accounts/src/account_core/mod.rs @@ -117,7 +117,7 @@ impl AccountPublicMask { impl Account { pub fn new() -> Self { let key_holder = AddressKeyHolder::new_os_random(); - let public_key = nssa::PublicKey::new(&key_holder.get_pub_account_signing_key()); + let public_key = nssa::PublicKey::new(key_holder.get_pub_account_signing_key()); let address = nssa::Address::from_public_key(&public_key); let balance = 0; let utxos = HashMap::new(); @@ -132,7 +132,7 @@ impl Account { pub fn new_with_balance(balance: u64) -> Self { let key_holder = AddressKeyHolder::new_os_random(); - let public_key = nssa::PublicKey::new(&key_holder.get_pub_account_signing_key()); + let public_key = nssa::PublicKey::new(key_holder.get_pub_account_signing_key()); let address = nssa::Address::from_public_key(&public_key); let utxos = HashMap::new(); diff --git a/accounts/src/key_management/mod.rs b/accounts/src/key_management/mod.rs index 055b34d..c0d26fb 100644 --- a/accounts/src/key_management/mod.rs +++ b/accounts/src/key_management/mod.rs @@ -1,15 +1,15 @@ use aes_gcm::{aead::Aead, Aes256Gcm, KeyInit}; use constants_types::{CipherText, Nonce}; use elliptic_curve::point::AffineCoordinates; -use k256::{ecdsa::SigningKey, AffinePoint, FieldBytes}; +use k256::AffinePoint; use log::info; -use rand::{rngs::OsRng, Rng, RngCore}; +use rand::{rngs::OsRng, Rng}; use secret_holders::{SeedHolder, TopSecretKeyHolder, UTXOSecretKeyHolder}; use serde::{Deserialize, Serialize}; use crate::account_core::PublicKey; pub type PublicAccountSigningKey = [u8; 32]; -use nssa::{self, PrivateKey}; +use nssa::{self}; pub mod constants_types; pub mod ephemeral_key_holder; @@ -118,7 +118,7 @@ mod tests { use elliptic_curve::point::AffineCoordinates; use k256::{AffinePoint, ProjectivePoint, Scalar}; - use crate::{account_core::address, key_management::ephemeral_key_holder::EphemeralKeyHolder}; + use crate::key_management::ephemeral_key_holder::EphemeralKeyHolder; use super::*; diff --git a/common/src/block.rs b/common/src/block.rs index 52d70ba..65514e2 100644 --- a/common/src/block.rs +++ b/common/src/block.rs @@ -1,7 +1,7 @@ use rs_merkle::Hasher; use serde::{Deserialize, Serialize}; -use crate::{merkle_tree_public::hasher::OwnHasher, transaction::Transaction}; +use crate::merkle_tree_public::hasher::OwnHasher; use nssa; pub type BlockHash = [u8; 32]; diff --git a/common/src/rpc_primitives/requests.rs b/common/src/rpc_primitives/requests.rs index fa78f74..ebfad60 100644 --- a/common/src/rpc_primitives/requests.rs +++ b/common/src/rpc_primitives/requests.rs @@ -1,6 +1,5 @@ use crate::block::Block; use crate::parse_request; -use crate::transaction::Transaction; use super::errors::RpcParseError; use super::parser::parse_params; diff --git a/common/src/sequencer_client/json.rs b/common/src/sequencer_client/json.rs index 11a8888..3afb54f 100644 --- a/common/src/sequencer_client/json.rs +++ b/common/src/sequencer_client/json.rs @@ -1,6 +1,5 @@ use serde::{Deserialize, Serialize}; -use crate::transaction::Transaction; //Requests diff --git a/common/src/sequencer_client/mod.rs b/common/src/sequencer_client/mod.rs index 7fcca2d..82f30a9 100644 --- a/common/src/sequencer_client/mod.rs +++ b/common/src/sequencer_client/mod.rs @@ -8,7 +8,6 @@ use reqwest::Client; use serde_json::Value; use crate::sequencer_client::json::AccountInitialData; -use crate::transaction::Transaction; use crate::{SequencerClientError, SequencerRpcError}; pub mod json; diff --git a/common/src/test_utils.rs b/common/src/test_utils.rs index 0a98dd2..bf734af 100644 --- a/common/src/test_utils.rs +++ b/common/src/test_utils.rs @@ -1,12 +1,6 @@ -use k256::ecdsa::SigningKey; use nssa; -use secp256k1_zkp::Tweak; -use crate::{ - block::{Block, HashableBlockData}, - execution_input::PublicNativeTokenSend, - transaction::{SignaturePrivateKey, Transaction, TransactionBody, TxKind}, -}; +use crate::block::{Block, HashableBlockData}; //Dummy producers diff --git a/nssa/core/src/program.rs b/nssa/core/src/program.rs index ec9bdc7..24db838 100644 --- a/nssa/core/src/program.rs +++ b/nssa/core/src/program.rs @@ -1,4 +1,3 @@ -use serde::{Deserialize, Serialize}; use crate::account::{Account, AccountWithMetadata}; diff --git a/nssa/src/signature.rs b/nssa/src/signature.rs index 4c0ebb7..9cdc9b6 100644 --- a/nssa/src/signature.rs +++ b/nssa/src/signature.rs @@ -28,11 +28,11 @@ impl PublicKey { } impl Signature { - pub(crate) fn new(key: &PrivateKey, message: &[u8]) -> Self { + pub(crate) fn new(_key: &PrivateKey, message: &[u8]) -> Self { Self } - pub(crate) fn is_valid_for(&self, message: &Message, public_key: &PublicKey) -> bool { + pub(crate) fn is_valid_for(&self, _message: &Message, _public_key: &PublicKey) -> bool { // TODO: implement true } diff --git a/nssa/src/state.rs b/nssa/src/state.rs index b4d697a..319a9c2 100644 --- a/nssa/src/state.rs +++ b/nssa/src/state.rs @@ -19,9 +19,11 @@ impl V01State { .to_owned() .into_iter() .map(|(address_value, balance)| { - let mut account = Account::default(); - account.balance = balance; - account.program_owner = AUTHENTICATED_TRANSFER_PROGRAM.id; + let account = Account { + balance: balance, + program_owner: AUTHENTICATED_TRANSFER_PROGRAM.id, + ..Account::default() + }; let address = Address::new(address_value); (address, account) }) @@ -188,7 +190,6 @@ mod tests { let from_key = PrivateKey(99); let to = Address::new(initial_data[0].0); let balance_to_move = 8; - let to_previous_balance = state.get_account_by_address(&to).balance; let tx = transfer_transaction_for_tests(from.clone(), from_key, 0, to.clone(), balance_to_move); state.transition_from_public_transaction(&tx).unwrap(); diff --git a/sequencer_core/src/lib.rs b/sequencer_core/src/lib.rs index 33e00df..0123b66 100644 --- a/sequencer_core/src/lib.rs +++ b/sequencer_core/src/lib.rs @@ -1,14 +1,9 @@ use std::fmt::Display; -use accounts::account_core::address::{self, AccountAddress}; use anyhow::Result; use common::{ block::HashableBlockData, - execution_input::PublicNativeTokenSend, merkle_tree_public::TreeHashType, - nullifier::UTXONullifier, - transaction::{AuthenticatedTransaction, Transaction, TransactionBody, TxKind}, - utxo_commitment::UTXOCommitment, }; use config::SequencerConfig; use mempool::MemPool; @@ -86,7 +81,7 @@ impl SequencerCore { let authenticated_tx = self.transaction_pre_check(transaction)?; - self.mempool.push_item(authenticated_tx.into()); + self.mempool.push_item(authenticated_tx); Ok(()) } @@ -144,7 +139,7 @@ mod tests { use crate::config::AccountInitialData; use super::*; - use nssa::Program; + fn setup_sequencer_config_variable_initial_accounts( initial_accounts: Vec, @@ -310,8 +305,6 @@ mod tests { let initial_accounts = vec![initial_acc1, initial_acc2]; - let intial_accounts_len = initial_accounts.len(); - let config = setup_sequencer_config_variable_initial_accounts(initial_accounts); let sequencer = SequencerCore::start_from_config(config.clone()); @@ -507,7 +500,7 @@ mod tests { assert!(matches!( result, - Err(TransactionMalformationErrorKind::MempoolFullForRound { .. }) + Err(TransactionMalformationErrorKind::MempoolFullForRound) )); } diff --git a/sequencer_core/src/sequencer_store/block_store.rs b/sequencer_core/src/sequencer_store/block_store.rs index ca31c8f..b06fd73 100644 --- a/sequencer_core/src/sequencer_store/block_store.rs +++ b/sequencer_core/src/sequencer_store/block_store.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, path::Path}; use anyhow::Result; -use common::{block::Block, merkle_tree_public::TreeHashType, transaction::Transaction}; +use common::{block::Block, merkle_tree_public::TreeHashType}; use storage::RocksDBIO; pub struct SequecerBlockStore { @@ -76,7 +76,7 @@ fn block_to_transactions_map(block: &Block) -> HashMap { #[cfg(test)] mod tests { use super::*; - use nssa::Program; + use tempfile::tempdir; // // fn create_dummy_block_with_transaction(block_id: u64) -> (Block, nssa::PublicTransaction) { diff --git a/sequencer_core/src/sequencer_store/mod.rs b/sequencer_core/src/sequencer_store/mod.rs index 9fc266c..e0a15fc 100644 --- a/sequencer_core/src/sequencer_store/mod.rs +++ b/sequencer_core/src/sequencer_store/mod.rs @@ -1,12 +1,8 @@ -use std::{collections::HashSet, path::Path}; +use std::path::Path; use accounts::account_core::address::AccountAddress; use block_store::SequecerBlockStore; -use common::{ - block::HashableBlockData, - merkle_tree_public::merkle_tree::{PublicTransactionMerkleTree, UTXOCommitmentsMerkleTree}, - nullifier::UTXONullifier, -}; +use common::block::HashableBlockData; use nssa; use rand::{rngs::OsRng, RngCore}; diff --git a/sequencer_rpc/src/process.rs b/sequencer_rpc/src/process.rs index 066700c..fabf31e 100644 --- a/sequencer_rpc/src/process.rs +++ b/sequencer_rpc/src/process.rs @@ -18,8 +18,7 @@ use common::{ use common::rpc_primitives::requests::{ GetBlockDataRequest, GetBlockDataResponse, GetGenesisIdRequest, GetGenesisIdResponse, - GetLastBlockRequest, GetLastBlockResponse, HelloRequest, HelloResponse, RegisterAccountRequest, - RegisterAccountResponse, SendTxRequest, SendTxResponse, + GetLastBlockRequest, GetLastBlockResponse, HelloRequest, HelloResponse, SendTxRequest, SendTxResponse, }; use super::{respond, types::err_rpc::RpcErr, JsonHandler}; @@ -203,11 +202,8 @@ mod tests { use std::sync::Arc; use crate::{rpc_handler, JsonHandler}; - use common::{ - rpc_primitives::RpcPollingConfig, - transaction::{SignaturePrivateKey, Transaction, TransactionBody}, - }; - use nssa::Program; + use common::rpc_primitives::RpcPollingConfig; + use sequencer_core::{ config::{AccountInitialData, SequencerConfig}, SequencerCore, diff --git a/wallet/src/lib.rs b/wallet/src/lib.rs index 26a4fe3..9f80d8e 100644 --- a/wallet/src/lib.rs +++ b/wallet/src/lib.rs @@ -1,23 +1,18 @@ use std::sync::Arc; use common::{ - execution_input::PublicNativeTokenSend, sequencer_client::{json::SendTxResponse, SequencerClient}, - transaction::Transaction, ExecutionFailureKind, }; use accounts::account_core::{address::AccountAddress, Account}; use anyhow::Result; use chain_storage::NodeChainStore; -use common::transaction::TransactionBody; use config::NodeConfig; use log::info; -use sc_core::proofs_circuits::pedersen_commitment_vec; use tokio::sync::RwLock; use clap::{Parser, Subcommand}; -use nssa; use crate::helperfunctions::{fetch_config, produce_account_addr_from_hex}; @@ -101,7 +96,7 @@ impl NodeCore { let signing_key = account.key_holder.get_pub_account_signing_key(); let witness_set = - nssa::public_transaction::WitnessSet::for_message(&message, &[&signing_key]); + nssa::public_transaction::WitnessSet::for_message(&message, &[signing_key]); let tx = nssa::PublicTransaction::new(message, witness_set);