mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-04-08 20:23:47 +00:00
fix clippy
This commit is contained in:
parent
7c1f8f4d68
commit
55c75c55ae
@ -14,10 +14,13 @@ use nssa_core::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
error::NssaError, merkle_tree::MerkleTree,
|
||||
privacy_preserving_transaction::PrivacyPreservingTransaction, program::Program,
|
||||
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::{StateDiff, ValidatedStateDiff},
|
||||
};
|
||||
|
||||
pub const MAX_NUMBER_CHAINED_CALLS: usize = 10;
|
||||
@ -188,8 +191,13 @@ 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 StateDiff {
|
||||
signer_account_ids,
|
||||
public_diff,
|
||||
new_commitments,
|
||||
new_nullifiers,
|
||||
program,
|
||||
} = diff.into_state_diff();
|
||||
#[expect(
|
||||
clippy::iter_over_hash_type,
|
||||
reason = "Iteration order doesn't matter here"
|
||||
|
||||
@ -24,17 +24,19 @@ use crate::{
|
||||
state::MAX_NUMBER_CHAINED_CALLS,
|
||||
};
|
||||
|
||||
pub struct StateDiff {
|
||||
pub signer_account_ids: Vec<AccountId>,
|
||||
pub public_diff: HashMap<AccountId, Account>,
|
||||
pub new_commitments: Vec<Commitment>,
|
||||
pub new_nullifiers: Vec<Nullifier>,
|
||||
pub program: Option<Program>,
|
||||
}
|
||||
|
||||
/// The validated output of executing or verifying a transaction, ready to be applied to the state.
|
||||
///
|
||||
/// Can only be constructed by the transaction validation functions inside this crate, ensuring the
|
||||
/// diff has been cryptographically checked before any state mutation occurs.
|
||||
pub struct ValidatedStateDiff {
|
||||
signer_account_ids: Vec<AccountId>,
|
||||
public_diff: HashMap<AccountId, Account>,
|
||||
new_commitments: Vec<Commitment>,
|
||||
new_nullifiers: Vec<Nullifier>,
|
||||
program: Option<Program>,
|
||||
}
|
||||
pub struct ValidatedStateDiff(StateDiff);
|
||||
|
||||
impl ValidatedStateDiff {
|
||||
pub fn from_public_transaction(
|
||||
@ -243,13 +245,13 @@ impl ValidatedStateDiff {
|
||||
);
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
Ok(Self(StateDiff {
|
||||
signer_account_ids,
|
||||
public_diff: state_diff,
|
||||
new_commitments: vec![],
|
||||
new_nullifiers: vec![],
|
||||
program: None,
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn from_privacy_preserving_transaction(
|
||||
@ -359,13 +361,13 @@ impl ValidatedStateDiff {
|
||||
.map(|(nullifier, _)| nullifier)
|
||||
.collect();
|
||||
|
||||
Ok(Self {
|
||||
Ok(Self(StateDiff {
|
||||
signer_account_ids,
|
||||
public_diff,
|
||||
new_commitments: message.new_commitments.clone(),
|
||||
new_nullifiers,
|
||||
program: None,
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn from_program_deployment_transaction(
|
||||
@ -377,13 +379,13 @@ impl ValidatedStateDiff {
|
||||
if state.programs().contains_key(&program.id()) {
|
||||
return Err(NssaError::ProgramAlreadyExists);
|
||||
}
|
||||
Ok(Self {
|
||||
Ok(Self(StateDiff {
|
||||
signer_account_ids: vec![],
|
||||
public_diff: HashMap::new(),
|
||||
new_commitments: vec![],
|
||||
new_nullifiers: vec![],
|
||||
program: Some(program),
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
/// Returns the public account changes produced by this transaction.
|
||||
@ -392,25 +394,11 @@ impl ValidatedStateDiff {
|
||||
/// to enforce that system accounts are not modified by user transactions.
|
||||
#[must_use]
|
||||
pub fn public_diff(&self) -> HashMap<AccountId, Account> {
|
||||
self.public_diff.clone()
|
||||
self.0.public_diff.clone()
|
||||
}
|
||||
|
||||
pub(crate) fn into_parts(
|
||||
self,
|
||||
) -> (
|
||||
Vec<AccountId>,
|
||||
HashMap<AccountId, Account>,
|
||||
Vec<Commitment>,
|
||||
Vec<Nullifier>,
|
||||
Option<Program>,
|
||||
) {
|
||||
(
|
||||
self.signer_account_ids,
|
||||
self.public_diff,
|
||||
self.new_commitments,
|
||||
self.new_nullifiers,
|
||||
self.program,
|
||||
)
|
||||
pub(crate) fn into_state_diff(self) -> StateDiff {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,6 @@ pub const CLOCK_PROGRAM_ACCOUNT_IDS: [AccountId; 3] = [
|
||||
/// The instruction type for the Clock Program. The sequencer passes the current block timestamp.
|
||||
pub type Instruction = Timestamp;
|
||||
|
||||
|
||||
/// The data stored in a clock account: `[block_id: u64 LE | timestamp: u64 LE]`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct ClockAccountData {
|
||||
|
||||
@ -259,7 +259,10 @@ impl<BC: BlockSettlementClientTrait, IC: IndexerClientTrait> SequencerCore<BC, I
|
||||
.transition_from_public_transaction(
|
||||
match &clock_nssa_tx {
|
||||
NSSATransaction::Public(tx) => tx,
|
||||
_ => unreachable!("clock_invocation always returns Public"),
|
||||
NSSATransaction::PrivacyPreserving(_)
|
||||
| NSSATransaction::ProgramDeployment(_) => {
|
||||
unreachable!("clock_invocation always returns Public")
|
||||
}
|
||||
},
|
||||
new_block_height,
|
||||
new_block_timestamp,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user