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