From 00f7324f8e02499d0c4ad791dbd5075a8832edce Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Sat, 28 Mar 2026 03:57:14 -0300 Subject: [PATCH] clippy --- nssa/core/src/circuit_io.rs | 2 +- nssa/core/src/lib.rs | 8 ++--- nssa/core/src/program.rs | 11 +++--- .../transaction.rs | 34 ++++++------------- sequencer/core/src/lib.rs | 8 +++-- .../src/bin/validity_window_chain_caller.rs | 2 +- 6 files changed, 28 insertions(+), 37 deletions(-) diff --git a/nssa/core/src/circuit_io.rs b/nssa/core/src/circuit_io.rs index eeaf2fa0..9f4b1255 100644 --- a/nssa/core/src/circuit_io.rs +++ b/nssa/core/src/circuit_io.rs @@ -103,7 +103,7 @@ mod tests { ), [0xab; 32], )], - block_validity_window: (Some(1u64), None).try_into().unwrap(), + block_validity_window: (Some(1_u64), None).try_into().unwrap(), timestamp_validity_window: TimestampValidityWindow::new_unbounded(), }; let bytes = output.to_bytes(); diff --git a/nssa/core/src/lib.rs b/nssa/core/src/lib.rs index 32224a9a..a4fcdee1 100644 --- a/nssa/core/src/lib.rs +++ b/nssa/core/src/lib.rs @@ -3,10 +3,6 @@ reason = "We prefer to group methods by functionality rather than by type for encoding" )] -pub type BlockId = u64; -/// Unix timestamp in milliseconds. -pub type Timestamp = u64; - pub use circuit_io::{PrivacyPreservingCircuitInput, PrivacyPreservingCircuitOutput}; pub use commitment::{ Commitment, CommitmentSetDigest, DUMMY_COMMITMENT, DUMMY_COMMITMENT_HASH, MembershipProof, @@ -25,3 +21,7 @@ pub mod program; #[cfg(feature = "host")] pub mod error; + +pub type BlockId = u64; +/// Unix timestamp in milliseconds. +pub type Timestamp = u64; diff --git a/nssa/core/src/program.rs b/nssa/core/src/program.rs index e3953f6a..cb52a9b6 100644 --- a/nssa/core/src/program.rs +++ b/nssa/core/src/program.rs @@ -5,7 +5,10 @@ use borsh::{BorshDeserialize, BorshSerialize}; use risc0_zkvm::{DeserializeOwned, guest::env, serde::Deserializer}; use serde::{Deserialize, Serialize}; -use crate::account::{Account, AccountId, AccountWithMetadata}; +use crate::{ + BlockId, Timestamp, + account::{Account, AccountId, AccountWithMetadata}, +}; pub const DEFAULT_PROGRAM_ID: ProgramId = [0; 8]; pub const MAX_NUMBER_CHAINED_CALLS: usize = 10; @@ -153,8 +156,6 @@ impl AccountPostState { } } -use crate::{BlockId, Timestamp}; - pub type BlockValidityWindow = ValidityWindow; pub type TimestampValidityWindow = ValidityWindow; @@ -198,13 +199,13 @@ impl ValidityWindow { /// Inclusive lower bound. `None` means no lower bound. #[must_use] - pub fn start(&self) -> Option { + pub const fn start(&self) -> Option { self.from } /// Exclusive upper bound. `None` means no upper bound. #[must_use] - pub fn end(&self) -> Option { + pub const fn end(&self) -> Option { self.to } } diff --git a/nssa/src/privacy_preserving_transaction/transaction.rs b/nssa/src/privacy_preserving_transaction/transaction.rs index 496da5fa..977bb0d0 100644 --- a/nssa/src/privacy_preserving_transaction/transaction.rs +++ b/nssa/src/privacy_preserving_transaction/transaction.rs @@ -5,17 +5,14 @@ use std::{ use borsh::{BorshDeserialize, BorshSerialize}; use nssa_core::{ - BlockId, Commitment, CommitmentSetDigest, Nullifier, PrivacyPreservingCircuitOutput, Timestamp, + BlockId, PrivacyPreservingCircuitOutput, Timestamp, account::{Account, AccountWithMetadata}, - program::{BlockValidityWindow, TimestampValidityWindow}, }; use sha2::{Digest as _, digest::FixedOutput as _}; use super::{message::Message, witness_set::WitnessSet}; use crate::{ - AccountId, V03State, - error::NssaError, - privacy_preserving_transaction::{circuit::Proof, message::EncryptedAccountData}, + AccountId, V03State, error::NssaError, privacy_preserving_transaction::circuit::Proof, }; #[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)] @@ -118,12 +115,7 @@ impl PrivacyPreservingTransaction { check_privacy_preserving_circuit_proof_is_valid( &witness_set.proof, &public_pre_states, - &message.public_post_states, - &message.encrypted_private_post_states, - &message.new_commitments, - &message.new_nullifiers, - &message.block_validity_window, - &message.timestamp_validity_window, + message, )?; // 5. Commitment freshness @@ -181,25 +173,21 @@ impl PrivacyPreservingTransaction { fn check_privacy_preserving_circuit_proof_is_valid( proof: &Proof, public_pre_states: &[AccountWithMetadata], - public_post_states: &[Account], - encrypted_private_post_states: &[EncryptedAccountData], - new_commitments: &[Commitment], - new_nullifiers: &[(Nullifier, CommitmentSetDigest)], - block_validity_window: &BlockValidityWindow, - timestamp_validity_window: &TimestampValidityWindow, + message: &Message, ) -> Result<(), NssaError> { let output = PrivacyPreservingCircuitOutput { public_pre_states: public_pre_states.to_vec(), - public_post_states: public_post_states.to_vec(), - ciphertexts: encrypted_private_post_states + public_post_states: message.public_post_states.clone(), + ciphertexts: message + .encrypted_private_post_states .iter() .cloned() .map(|value| value.ciphertext) .collect(), - new_commitments: new_commitments.to_vec(), - new_nullifiers: new_nullifiers.to_vec(), - block_validity_window: block_validity_window.to_owned(), - timestamp_validity_window: timestamp_validity_window.to_owned(), + new_commitments: message.new_commitments.clone(), + new_nullifiers: message.new_nullifiers.clone(), + block_validity_window: message.block_validity_window, + timestamp_validity_window: message.timestamp_validity_window, }; proof .is_valid_for(&output) diff --git a/sequencer/core/src/lib.rs b/sequencer/core/src/lib.rs index 1c6b37e5..16667051 100644 --- a/sequencer/core/src/lib.rs +++ b/sequencer/core/src/lib.rs @@ -524,7 +524,7 @@ mod tests { let tx = tx.transaction_stateless_check().unwrap(); // Signature is not from sender. Execution fails - let result = sequencer.execute_check_transaction_on_state(tx); + let result = sequencer.execute_check_transaction_on_state(tx, 0, 0); assert!(matches!( result, @@ -550,7 +550,7 @@ mod tests { // Passed pre-check assert!(result.is_ok()); - let result = sequencer.execute_check_transaction_on_state(result.unwrap()); + let result = sequencer.execute_check_transaction_on_state(result.unwrap(), 0, 0); let is_failed_at_balance_mismatch = matches!( result.err().unwrap(), nssa::error::NssaError::ProgramExecutionFailed(_) @@ -572,7 +572,9 @@ mod tests { acc1, 0, acc2, 100, &sign_key1, ); - sequencer.execute_check_transaction_on_state(tx).unwrap(); + sequencer + .execute_check_transaction_on_state(tx, 0, 0) + .unwrap(); let bal_from = sequencer.state.get_account_by_id(acc1).balance; let bal_to = sequencer.state.get_account_by_id(acc2).balance; diff --git a/test_program_methods/guest/src/bin/validity_window_chain_caller.rs b/test_program_methods/guest/src/bin/validity_window_chain_caller.rs index 9acce64b..39f8ad69 100644 --- a/test_program_methods/guest/src/bin/validity_window_chain_caller.rs +++ b/test_program_methods/guest/src/bin/validity_window_chain_caller.rs @@ -9,7 +9,7 @@ use risc0_zkvm::serde::to_vec; /// /// Instruction: (`window`, `chained_program_id`, `chained_window`) /// The initial output uses `window` and chains to `chained_program_id` with `chained_window`. -/// The chained program (validity_window) expects `(BlockValidityWindow, TimestampValidityWindow)` +/// The chained program (`validity_window`) expects `(BlockValidityWindow, TimestampValidityWindow)` /// so an unbounded timestamp window is appended automatically. type Instruction = (BlockValidityWindow, ProgramId, BlockValidityWindow);