mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-05 23:03:06 +00:00
fix: latest lint fixes
This commit is contained in:
parent
1c4ec47f1a
commit
b9d3f921e9
@ -207,7 +207,7 @@ impl NodeCore {
|
||||
serde_json::to_vec(&ephm_key_holder.generate_ephemeral_public_key()).unwrap();
|
||||
|
||||
let encoded_data = Account::encrypt_data(
|
||||
ephm_key_holder,
|
||||
&ephm_key_holder,
|
||||
account.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo).unwrap(),
|
||||
);
|
||||
@ -299,7 +299,7 @@ impl NodeCore {
|
||||
.map(|utxo| {
|
||||
(
|
||||
Account::encrypt_data(
|
||||
ephm_key_holder,
|
||||
&ephm_key_holder,
|
||||
account.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo).unwrap(),
|
||||
),
|
||||
@ -413,7 +413,7 @@ impl NodeCore {
|
||||
let accout_enc = acc_map_read_guard.acc_map.get(&utxo_enc.owner).unwrap();
|
||||
|
||||
let (ciphertext, nonce) = Account::encrypt_data(
|
||||
ephm_key_holder,
|
||||
&ephm_key_holder,
|
||||
accout_enc.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo_enc).unwrap(),
|
||||
);
|
||||
@ -534,7 +534,7 @@ impl NodeCore {
|
||||
let accout_enc = acc_map_read_guard.acc_map.get(&utxo_enc.owner).unwrap();
|
||||
|
||||
let (ciphertext, nonce) = Account::encrypt_data(
|
||||
ephm_key_holder,
|
||||
&ephm_key_holder,
|
||||
accout_enc.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo_enc).unwrap(),
|
||||
);
|
||||
@ -551,7 +551,7 @@ impl NodeCore {
|
||||
let accout_enc = acc_map_read_guard.acc_map.get(&utxo_enc.owner).unwrap();
|
||||
|
||||
let (ciphertext, nonce) = Account::encrypt_data(
|
||||
ephm_key_holder,
|
||||
&ephm_key_holder,
|
||||
accout_enc.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo_enc).unwrap(),
|
||||
);
|
||||
@ -678,7 +678,7 @@ impl NodeCore {
|
||||
let accout_enc = acc_map_read_guard.acc_map.get(&utxo_enc.owner).unwrap();
|
||||
|
||||
let (ciphertext, nonce) = Account::encrypt_data(
|
||||
ephm_key_holder,
|
||||
&ephm_key_holder,
|
||||
accout_enc.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo_enc).unwrap(),
|
||||
);
|
||||
@ -1392,7 +1392,7 @@ impl NodeCore {
|
||||
let accout_enc = acc_map_read_guard.acc_map.get(&utxo_enc.owner).unwrap();
|
||||
|
||||
let (ciphertext, nonce) = Account::encrypt_data(
|
||||
ephm_key_holder,
|
||||
&ephm_key_holder,
|
||||
accout_enc.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo_enc).unwrap(),
|
||||
);
|
||||
|
||||
@ -16,19 +16,13 @@ pub fn produce_blob_list_from_sc_public_state<S: Serialize>(
|
||||
|
||||
//`ToDo` Replace with `next_chunk` usage, when feature stabilizes in Rust
|
||||
for i in 0..=(ser_data.len() / SC_DATA_BLOB_SIZE) {
|
||||
let next_chunk: Vec<u8>;
|
||||
|
||||
if (i + 1) * SC_DATA_BLOB_SIZE < ser_data.len() {
|
||||
next_chunk = ser_data[(i * SC_DATA_BLOB_SIZE)..((i + 1) * SC_DATA_BLOB_SIZE)]
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect();
|
||||
let next_chunk: Vec<u8> = if (i + 1) * SC_DATA_BLOB_SIZE < ser_data.len() {
|
||||
ser_data[(i * SC_DATA_BLOB_SIZE)..((i + 1) * SC_DATA_BLOB_SIZE)]
|
||||
.to_vec()
|
||||
} else {
|
||||
next_chunk = ser_data[(i * SC_DATA_BLOB_SIZE)..(ser_data.len())]
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect();
|
||||
}
|
||||
ser_data[(i * SC_DATA_BLOB_SIZE)..(ser_data.len())]
|
||||
.to_vec()
|
||||
};
|
||||
|
||||
blob_list.push(produce_blob_from_fit_vec(next_chunk));
|
||||
}
|
||||
@ -52,10 +46,10 @@ pub fn compare_blob_lists(
|
||||
changed_ids.push(DataBlobChangeVariant::Deleted { id });
|
||||
}
|
||||
} else if new_len > old_len {
|
||||
for id in old_len..new_len {
|
||||
for (id, blob) in blob_list_new.iter().enumerate().take(new_len).skip(old_len) {
|
||||
changed_ids.push(DataBlobChangeVariant::Created {
|
||||
id,
|
||||
blob: blob_list_new[id],
|
||||
blob: *blob,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,10 +52,10 @@ pub fn generate_commitments(input_utxos: &[UTXO]) -> Vec<Vec<u8>> {
|
||||
///
|
||||
/// ToDo: Solve it in more scalable way
|
||||
pub fn validate_in_commitments_tree(
|
||||
in_commitment: &Vec<u8>,
|
||||
in_commitment: &[u8],
|
||||
commitment_tree: &UTXOCommitmentsMerkleTree,
|
||||
) -> bool {
|
||||
let alighned_hash: [u8; 32] = in_commitment.clone().try_into().unwrap();
|
||||
let alighned_hash: [u8; 32] = in_commitment.try_into().unwrap();
|
||||
|
||||
commitment_tree.get_proof(alighned_hash).is_some()
|
||||
}
|
||||
@ -104,7 +104,7 @@ pub fn private_circuit(
|
||||
assert!(!public_context.nullifiers_set.contains(&nullifier));
|
||||
}
|
||||
|
||||
(in_nullifiers, generate_commitments(&output_utxos))
|
||||
(in_nullifiers, generate_commitments(output_utxos))
|
||||
}
|
||||
|
||||
/// Check balances DE
|
||||
@ -124,7 +124,7 @@ pub fn deshielded_circuit(
|
||||
) -> Vec<Vec<u8>> {
|
||||
assert!(check_balances_de(input_utxos, output_balance));
|
||||
|
||||
let in_commitments = generate_commitments(&input_utxos);
|
||||
let in_commitments = generate_commitments(input_utxos);
|
||||
|
||||
let mut in_nullifiers = vec![];
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ pub fn encode_utxos_to_receivers(
|
||||
let ephm_key_holder = EphemeralKeyHolder::new_os_random();
|
||||
|
||||
let encoded_data = Account::encrypt_data(
|
||||
ephm_key_holder,
|
||||
&ephm_key_holder,
|
||||
receiver.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo).unwrap(),
|
||||
);
|
||||
|
||||
@ -344,13 +344,13 @@ mod tests {
|
||||
assert_eq!(sequencer.sequencer_config.port, 8080);
|
||||
|
||||
let acc1_addr: [u8; 32] = hex::decode(
|
||||
"bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117d09a8c".to_string(),
|
||||
"bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117d09a8c",
|
||||
)
|
||||
.unwrap()
|
||||
.try_into()
|
||||
.unwrap();
|
||||
let acc2_addr: [u8; 32] = hex::decode(
|
||||
"20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1e376f31".to_string(),
|
||||
"20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1e376f31",
|
||||
)
|
||||
.unwrap()
|
||||
.try_into()
|
||||
@ -398,13 +398,13 @@ mod tests {
|
||||
let sequencer = SequencerCore::start_from_config(config.clone());
|
||||
|
||||
let acc1_addr: [u8; 32] = hex::decode(
|
||||
"bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117ffffff".to_string(),
|
||||
"bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117ffffff",
|
||||
)
|
||||
.unwrap()
|
||||
.try_into()
|
||||
.unwrap();
|
||||
let acc2_addr: [u8; 32] = hex::decode(
|
||||
"20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1effffff".to_string(),
|
||||
"20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1effffff",
|
||||
)
|
||||
.unwrap()
|
||||
.try_into()
|
||||
|
||||
@ -85,6 +85,11 @@ impl SequencerAccountsStore {
|
||||
pub fn len(&self) -> usize {
|
||||
self.accounts.len()
|
||||
}
|
||||
|
||||
///Is accounts store empty
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.accounts.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SequencerAccountsStore {
|
||||
@ -213,4 +218,12 @@ mod tests {
|
||||
|
||||
assert!(acc_balance.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn account_sequencer_store_is_empty_test() {
|
||||
let seq_acc_store =
|
||||
SequencerAccountsStore::default();
|
||||
|
||||
assert!(seq_acc_store.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use serde::{de::Error, Deserialize, Serialize};
|
||||
|
||||
use crate::SC_DATA_BLOB_SIZE;
|
||||
@ -51,6 +49,7 @@ impl DataBlob {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum DataBlobChangeVariant {
|
||||
Created {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user