diff --git a/common/src/block.rs b/common/src/block.rs index f7feb0d1..92adbdb1 100644 --- a/common/src/block.rs +++ b/common/src/block.rs @@ -1,11 +1,10 @@ use borsh::{BorshDeserialize, BorshSerialize}; use nssa_core::BlockId; +pub use nssa_core::Timestamp; use serde::{Deserialize, Serialize}; use sha2::{Digest as _, Sha256, digest::FixedOutput as _}; use crate::{HashType, transaction::NSSATransaction}; - -pub use nssa_core::Timestamp; pub type MantleMsgId = [u8; 32]; pub type BlockHash = HashType; diff --git a/nssa/core/src/lib.rs b/nssa/core/src/lib.rs index f5b81348..a4fcdee1 100644 --- a/nssa/core/src/lib.rs +++ b/nssa/core/src/lib.rs @@ -3,7 +3,6 @@ reason = "We prefer to group methods by functionality rather than by type for encoding" )] - pub use circuit_io::{PrivacyPreservingCircuitInput, PrivacyPreservingCircuitOutput}; pub use commitment::{ Commitment, CommitmentSetDigest, DUMMY_COMMITMENT, DUMMY_COMMITMENT_HASH, MembershipProof, diff --git a/nssa/src/privacy_preserving_transaction/transaction.rs b/nssa/src/privacy_preserving_transaction/transaction.rs index fbf09833..2e46f628 100644 --- a/nssa/src/privacy_preserving_transaction/transaction.rs +++ b/nssa/src/privacy_preserving_transaction/transaction.rs @@ -1,7 +1,7 @@ use std::collections::HashSet; use borsh::{BorshDeserialize, BorshSerialize}; -use nssa_core::account::{Account, AccountId}; +use nssa_core::account::AccountId; use sha2::{Digest as _, digest::FixedOutput as _}; use super::{message::Message, witness_set::WitnessSet}; diff --git a/nssa/src/program.rs b/nssa/src/program.rs index 94a2a215..b8fb2595 100644 --- a/nssa/src/program.rs +++ b/nssa/src/program.rs @@ -9,7 +9,8 @@ use serde::Serialize; use crate::{ error::NssaError, program_methods::{ - AMM_ELF, ASSOCIATED_TOKEN_ACCOUNT_ELF, AUTHENTICATED_TRANSFER_ELF, CLOCK_ELF, PINATA_ELF, TOKEN_ELF, + AMM_ELF, ASSOCIATED_TOKEN_ACCOUNT_ELF, AUTHENTICATED_TRANSFER_ELF, CLOCK_ELF, PINATA_ELF, + TOKEN_ELF, }, }; diff --git a/nssa/src/state.rs b/nssa/src/state.rs index d78d4eec..a81e5364 100644 --- a/nssa/src/state.rs +++ b/nssa/src/state.rs @@ -1,6 +1,11 @@ use std::collections::{BTreeSet, HashMap, HashSet}; use borsh::{BorshDeserialize, BorshSerialize}; +use clock_core::ClockAccountData; +pub use clock_core::{ + CLOCK_01_PROGRAM_ACCOUNT_ID, CLOCK_10_PROGRAM_ACCOUNT_ID, CLOCK_50_PROGRAM_ACCOUNT_ID, + CLOCK_PROGRAM_ACCOUNT_IDS, +}; use nssa_core::{ BlockId, Commitment, CommitmentSetDigest, DUMMY_COMMITMENT, MembershipProof, Nullifier, Timestamp, @@ -8,18 +13,11 @@ use nssa_core::{ program::ProgramId, }; -pub use clock_core::{ - CLOCK_01_PROGRAM_ACCOUNT_ID, CLOCK_10_PROGRAM_ACCOUNT_ID, CLOCK_50_PROGRAM_ACCOUNT_ID, - CLOCK_PROGRAM_ACCOUNT_IDS, -}; -use clock_core::ClockAccountData; - use crate::{ error::NssaError, merkle_tree::MerkleTree, privacy_preserving_transaction::PrivacyPreservingTransaction, program::Program, program_deployment_transaction::ProgramDeploymentTransaction, - public_transaction::PublicTransaction, - validated_state_diff::ValidatedStateDiff, + public_transaction::PublicTransaction, validated_state_diff::ValidatedStateDiff, }; pub const MAX_NUMBER_CHAINED_CALLS: usize = 10; @@ -164,7 +162,11 @@ impl V03State { } fn insert_clock_accounts(&mut self, genesis_timestamp: nssa_core::Timestamp) { - let data = ClockAccountData { block_id: 0, timestamp: genesis_timestamp }.to_bytes(); + let data = ClockAccountData { + block_id: 0, + timestamp: genesis_timestamp, + } + .to_bytes(); let clock_program_id = Program::clock().id(); for account_id in CLOCK_PROGRAM_ACCOUNT_IDS { self.public_state.insert( @@ -186,7 +188,8 @@ impl V03State { } pub fn apply_state_diff(&mut self, diff: ValidatedStateDiff) { - let (signer_account_ids, public_diff, new_commitments, new_nullifiers, program) = diff.into_parts(); + let (signer_account_ids, public_diff, new_commitments, new_nullifiers, program) = + diff.into_parts(); #[expect( clippy::iter_over_hash_type, reason = "Iteration order doesn't matter here" @@ -195,11 +198,13 @@ impl V03State { *self.get_account_by_id_mut(account_id) = account; } for account_id in signer_account_ids { - self.get_account_by_id_mut(account_id).nonce.public_account_nonce_increment(); + self.get_account_by_id_mut(account_id) + .nonce + .public_account_nonce_increment(); } self.private_state.0.extend(&new_commitments); self.private_state.1.extend(&new_nullifiers); - if let Some(program) =program { + if let Some(program) = program { self.insert_program(program); } } diff --git a/nssa/src/validated_state_diff.rs b/nssa/src/validated_state_diff.rs index fd9de432..6598f711 100644 --- a/nssa/src/validated_state_diff.rs +++ b/nssa/src/validated_state_diff.rs @@ -7,16 +7,16 @@ use log::debug; use nssa_core::{ BlockId, Commitment, Nullifier, PrivacyPreservingCircuitOutput, Timestamp, account::{Account, AccountId, AccountWithMetadata}, - program::{ChainedCall, Claim, DEFAULT_PROGRAM_ID, compute_authorized_pdas, validate_execution}, + program::{ + ChainedCall, Claim, DEFAULT_PROGRAM_ID, compute_authorized_pdas, validate_execution, + }, }; use crate::{ V03State, ensure, error::NssaError, privacy_preserving_transaction::{ - PrivacyPreservingTransaction, - circuit::Proof, - message::Message, + PrivacyPreservingTransaction, circuit::Proof, message::Message, }, program::Program, program_deployment_transaction::ProgramDeploymentTransaction, @@ -349,7 +349,7 @@ impl ValidatedStateDiff { let new_nullifiers = message .new_nullifiers .iter() - .cloned() + .copied() .map(|(nullifier, _)| nullifier) .collect(); @@ -389,15 +389,23 @@ impl ValidatedStateDiff { self.public_diff.clone() } - pub(crate) fn into_parts(self) -> ( - Vec, - HashMap, - Vec, - Vec, - Option, - ) { - (self.signer_account_ids, self.public_diff, self.new_commitments, self.new_nullifiers, self.program) - } + pub(crate) fn into_parts( + self, + ) -> ( + Vec, + HashMap, + Vec, + Vec, + Option, + ) { + ( + self.signer_account_ids, + self.public_diff, + self.new_commitments, + self.new_nullifiers, + self.program, + ) + } } fn check_privacy_preserving_circuit_proof_is_valid( diff --git a/program_methods/guest/src/bin/clock.rs b/program_methods/guest/src/bin/clock.rs index c31383c6..9e15cc8b 100644 --- a/program_methods/guest/src/bin/clock.rs +++ b/program_methods/guest/src/bin/clock.rs @@ -57,7 +57,11 @@ fn main() { .checked_add(1) .expect("Next block id should be within u64 boundaries"); - let updated_data = ClockAccountData { block_id: current_block_id, timestamp }.to_bytes(); + let updated_data = ClockAccountData { + block_id: current_block_id, + timestamp, + } + .to_bytes(); let (pre_01, post_01) = update_if_multiple(pre_01, 1, current_block_id, updated_data); let (pre_10, post_10) = update_if_multiple(pre_10, 10, current_block_id, updated_data); diff --git a/sequencer/core/src/lib.rs b/sequencer/core/src/lib.rs index 592dd5c6..be4906ee 100644 --- a/sequencer/core/src/lib.rs +++ b/sequencer/core/src/lib.rs @@ -259,11 +259,15 @@ impl SequencerCore { - let touches_system = clock_accounts_pre - .iter() - .any(|(id, pre)| diff.public_diff().get(id).is_some_and(|post| post != pre)); + let touches_system = clock_accounts_pre.iter().any(|(id, pre)| { + diff.public_diff().get(id).is_some_and(|post| post != pre) + }); if touches_system { warn!( "Dropping transaction from mempool: user transactions may not modify the system clock account" @@ -321,7 +325,7 @@ impl SequencerCore