mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-05 23:03:06 +00:00
clippy
This commit is contained in:
parent
fcb90f6f11
commit
00773d7457
@ -1,5 +1,3 @@
|
|||||||
use common::transaction::SignaturePublicKey;
|
|
||||||
use tiny_keccak::{Hasher, Keccak};
|
|
||||||
|
|
||||||
// TODO: Consider wrapping `AccountAddress` in a struct.
|
// TODO: Consider wrapping `AccountAddress` in a struct.
|
||||||
|
|
||||||
|
|||||||
@ -117,7 +117,7 @@ impl AccountPublicMask {
|
|||||||
impl Account {
|
impl Account {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let key_holder = AddressKeyHolder::new_os_random();
|
let key_holder = AddressKeyHolder::new_os_random();
|
||||||
let public_key = nssa::PublicKey::new(&key_holder.get_pub_account_signing_key());
|
let public_key = nssa::PublicKey::new(key_holder.get_pub_account_signing_key());
|
||||||
let address = nssa::Address::from_public_key(&public_key);
|
let address = nssa::Address::from_public_key(&public_key);
|
||||||
let balance = 0;
|
let balance = 0;
|
||||||
let utxos = HashMap::new();
|
let utxos = HashMap::new();
|
||||||
@ -132,7 +132,7 @@ impl Account {
|
|||||||
|
|
||||||
pub fn new_with_balance(balance: u64) -> Self {
|
pub fn new_with_balance(balance: u64) -> Self {
|
||||||
let key_holder = AddressKeyHolder::new_os_random();
|
let key_holder = AddressKeyHolder::new_os_random();
|
||||||
let public_key = nssa::PublicKey::new(&key_holder.get_pub_account_signing_key());
|
let public_key = nssa::PublicKey::new(key_holder.get_pub_account_signing_key());
|
||||||
let address = nssa::Address::from_public_key(&public_key);
|
let address = nssa::Address::from_public_key(&public_key);
|
||||||
let utxos = HashMap::new();
|
let utxos = HashMap::new();
|
||||||
|
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
use aes_gcm::{aead::Aead, Aes256Gcm, KeyInit};
|
use aes_gcm::{aead::Aead, Aes256Gcm, KeyInit};
|
||||||
use constants_types::{CipherText, Nonce};
|
use constants_types::{CipherText, Nonce};
|
||||||
use elliptic_curve::point::AffineCoordinates;
|
use elliptic_curve::point::AffineCoordinates;
|
||||||
use k256::{ecdsa::SigningKey, AffinePoint, FieldBytes};
|
use k256::AffinePoint;
|
||||||
use log::info;
|
use log::info;
|
||||||
use rand::{rngs::OsRng, Rng, RngCore};
|
use rand::{rngs::OsRng, Rng};
|
||||||
use secret_holders::{SeedHolder, TopSecretKeyHolder, UTXOSecretKeyHolder};
|
use secret_holders::{SeedHolder, TopSecretKeyHolder, UTXOSecretKeyHolder};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::account_core::PublicKey;
|
use crate::account_core::PublicKey;
|
||||||
pub type PublicAccountSigningKey = [u8; 32];
|
pub type PublicAccountSigningKey = [u8; 32];
|
||||||
use nssa::{self, PrivateKey};
|
use nssa::{self};
|
||||||
|
|
||||||
pub mod constants_types;
|
pub mod constants_types;
|
||||||
pub mod ephemeral_key_holder;
|
pub mod ephemeral_key_holder;
|
||||||
@ -118,7 +118,7 @@ mod tests {
|
|||||||
use elliptic_curve::point::AffineCoordinates;
|
use elliptic_curve::point::AffineCoordinates;
|
||||||
use k256::{AffinePoint, ProjectivePoint, Scalar};
|
use k256::{AffinePoint, ProjectivePoint, Scalar};
|
||||||
|
|
||||||
use crate::{account_core::address, key_management::ephemeral_key_holder::EphemeralKeyHolder};
|
use crate::key_management::ephemeral_key_holder::EphemeralKeyHolder;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use rs_merkle::Hasher;
|
use rs_merkle::Hasher;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{merkle_tree_public::hasher::OwnHasher, transaction::Transaction};
|
use crate::merkle_tree_public::hasher::OwnHasher;
|
||||||
use nssa;
|
use nssa;
|
||||||
|
|
||||||
pub type BlockHash = [u8; 32];
|
pub type BlockHash = [u8; 32];
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
use crate::block::Block;
|
use crate::block::Block;
|
||||||
use crate::parse_request;
|
use crate::parse_request;
|
||||||
use crate::transaction::Transaction;
|
|
||||||
|
|
||||||
use super::errors::RpcParseError;
|
use super::errors::RpcParseError;
|
||||||
use super::parser::parse_params;
|
use super::parser::parse_params;
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::transaction::Transaction;
|
|
||||||
|
|
||||||
//Requests
|
//Requests
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,6 @@ use reqwest::Client;
|
|||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use crate::sequencer_client::json::AccountInitialData;
|
use crate::sequencer_client::json::AccountInitialData;
|
||||||
use crate::transaction::Transaction;
|
|
||||||
use crate::{SequencerClientError, SequencerRpcError};
|
use crate::{SequencerClientError, SequencerRpcError};
|
||||||
|
|
||||||
pub mod json;
|
pub mod json;
|
||||||
|
|||||||
@ -1,12 +1,6 @@
|
|||||||
use k256::ecdsa::SigningKey;
|
|
||||||
use nssa;
|
use nssa;
|
||||||
use secp256k1_zkp::Tweak;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::block::{Block, HashableBlockData};
|
||||||
block::{Block, HashableBlockData},
|
|
||||||
execution_input::PublicNativeTokenSend,
|
|
||||||
transaction::{SignaturePrivateKey, Transaction, TransactionBody, TxKind},
|
|
||||||
};
|
|
||||||
|
|
||||||
//Dummy producers
|
//Dummy producers
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
use crate::account::{Account, AccountWithMetadata};
|
use crate::account::{Account, AccountWithMetadata};
|
||||||
|
|
||||||
|
|||||||
@ -28,11 +28,11 @@ impl PublicKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Signature {
|
impl Signature {
|
||||||
pub(crate) fn new(key: &PrivateKey, message: &[u8]) -> Self {
|
pub(crate) fn new(_key: &PrivateKey, message: &[u8]) -> Self {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn is_valid_for(&self, message: &Message, public_key: &PublicKey) -> bool {
|
pub(crate) fn is_valid_for(&self, _message: &Message, _public_key: &PublicKey) -> bool {
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,9 +19,11 @@ impl V01State {
|
|||||||
.to_owned()
|
.to_owned()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(address_value, balance)| {
|
.map(|(address_value, balance)| {
|
||||||
let mut account = Account::default();
|
let account = Account {
|
||||||
account.balance = balance;
|
balance: balance,
|
||||||
account.program_owner = AUTHENTICATED_TRANSFER_PROGRAM.id;
|
program_owner: AUTHENTICATED_TRANSFER_PROGRAM.id,
|
||||||
|
..Account::default()
|
||||||
|
};
|
||||||
let address = Address::new(address_value);
|
let address = Address::new(address_value);
|
||||||
(address, account)
|
(address, account)
|
||||||
})
|
})
|
||||||
@ -188,7 +190,6 @@ mod tests {
|
|||||||
let from_key = PrivateKey(99);
|
let from_key = PrivateKey(99);
|
||||||
let to = Address::new(initial_data[0].0);
|
let to = Address::new(initial_data[0].0);
|
||||||
let balance_to_move = 8;
|
let balance_to_move = 8;
|
||||||
let to_previous_balance = state.get_account_by_address(&to).balance;
|
|
||||||
let tx =
|
let tx =
|
||||||
transfer_transaction_for_tests(from.clone(), from_key, 0, to.clone(), balance_to_move);
|
transfer_transaction_for_tests(from.clone(), from_key, 0, to.clone(), balance_to_move);
|
||||||
state.transition_from_public_transaction(&tx).unwrap();
|
state.transition_from_public_transaction(&tx).unwrap();
|
||||||
|
|||||||
@ -1,14 +1,9 @@
|
|||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
use accounts::account_core::address::{self, AccountAddress};
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use common::{
|
use common::{
|
||||||
block::HashableBlockData,
|
block::HashableBlockData,
|
||||||
execution_input::PublicNativeTokenSend,
|
|
||||||
merkle_tree_public::TreeHashType,
|
merkle_tree_public::TreeHashType,
|
||||||
nullifier::UTXONullifier,
|
|
||||||
transaction::{AuthenticatedTransaction, Transaction, TransactionBody, TxKind},
|
|
||||||
utxo_commitment::UTXOCommitment,
|
|
||||||
};
|
};
|
||||||
use config::SequencerConfig;
|
use config::SequencerConfig;
|
||||||
use mempool::MemPool;
|
use mempool::MemPool;
|
||||||
@ -86,7 +81,7 @@ impl SequencerCore {
|
|||||||
|
|
||||||
let authenticated_tx = self.transaction_pre_check(transaction)?;
|
let authenticated_tx = self.transaction_pre_check(transaction)?;
|
||||||
|
|
||||||
self.mempool.push_item(authenticated_tx.into());
|
self.mempool.push_item(authenticated_tx);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -144,7 +139,7 @@ mod tests {
|
|||||||
use crate::config::AccountInitialData;
|
use crate::config::AccountInitialData;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use nssa::Program;
|
|
||||||
|
|
||||||
fn setup_sequencer_config_variable_initial_accounts(
|
fn setup_sequencer_config_variable_initial_accounts(
|
||||||
initial_accounts: Vec<AccountInitialData>,
|
initial_accounts: Vec<AccountInitialData>,
|
||||||
@ -310,8 +305,6 @@ mod tests {
|
|||||||
|
|
||||||
let initial_accounts = vec![initial_acc1, initial_acc2];
|
let initial_accounts = vec![initial_acc1, initial_acc2];
|
||||||
|
|
||||||
let intial_accounts_len = initial_accounts.len();
|
|
||||||
|
|
||||||
let config = setup_sequencer_config_variable_initial_accounts(initial_accounts);
|
let config = setup_sequencer_config_variable_initial_accounts(initial_accounts);
|
||||||
let sequencer = SequencerCore::start_from_config(config.clone());
|
let sequencer = SequencerCore::start_from_config(config.clone());
|
||||||
|
|
||||||
@ -507,7 +500,7 @@ mod tests {
|
|||||||
|
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
result,
|
result,
|
||||||
Err(TransactionMalformationErrorKind::MempoolFullForRound { .. })
|
Err(TransactionMalformationErrorKind::MempoolFullForRound)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use std::{collections::HashMap, path::Path};
|
use std::{collections::HashMap, path::Path};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use common::{block::Block, merkle_tree_public::TreeHashType, transaction::Transaction};
|
use common::{block::Block, merkle_tree_public::TreeHashType};
|
||||||
use storage::RocksDBIO;
|
use storage::RocksDBIO;
|
||||||
|
|
||||||
pub struct SequecerBlockStore {
|
pub struct SequecerBlockStore {
|
||||||
@ -76,7 +76,7 @@ fn block_to_transactions_map(block: &Block) -> HashMap<TreeHashType, u64> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use nssa::Program;
|
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
//
|
//
|
||||||
// fn create_dummy_block_with_transaction(block_id: u64) -> (Block, nssa::PublicTransaction) {
|
// fn create_dummy_block_with_transaction(block_id: u64) -> (Block, nssa::PublicTransaction) {
|
||||||
|
|||||||
@ -1,12 +1,8 @@
|
|||||||
use std::{collections::HashSet, path::Path};
|
use std::path::Path;
|
||||||
|
|
||||||
use accounts::account_core::address::AccountAddress;
|
use accounts::account_core::address::AccountAddress;
|
||||||
use block_store::SequecerBlockStore;
|
use block_store::SequecerBlockStore;
|
||||||
use common::{
|
use common::block::HashableBlockData;
|
||||||
block::HashableBlockData,
|
|
||||||
merkle_tree_public::merkle_tree::{PublicTransactionMerkleTree, UTXOCommitmentsMerkleTree},
|
|
||||||
nullifier::UTXONullifier,
|
|
||||||
};
|
|
||||||
use nssa;
|
use nssa;
|
||||||
use rand::{rngs::OsRng, RngCore};
|
use rand::{rngs::OsRng, RngCore};
|
||||||
|
|
||||||
|
|||||||
@ -18,8 +18,7 @@ use common::{
|
|||||||
|
|
||||||
use common::rpc_primitives::requests::{
|
use common::rpc_primitives::requests::{
|
||||||
GetBlockDataRequest, GetBlockDataResponse, GetGenesisIdRequest, GetGenesisIdResponse,
|
GetBlockDataRequest, GetBlockDataResponse, GetGenesisIdRequest, GetGenesisIdResponse,
|
||||||
GetLastBlockRequest, GetLastBlockResponse, HelloRequest, HelloResponse, RegisterAccountRequest,
|
GetLastBlockRequest, GetLastBlockResponse, HelloRequest, HelloResponse, SendTxRequest, SendTxResponse,
|
||||||
RegisterAccountResponse, SendTxRequest, SendTxResponse,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{respond, types::err_rpc::RpcErr, JsonHandler};
|
use super::{respond, types::err_rpc::RpcErr, JsonHandler};
|
||||||
@ -203,11 +202,8 @@ mod tests {
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::{rpc_handler, JsonHandler};
|
use crate::{rpc_handler, JsonHandler};
|
||||||
use common::{
|
use common::rpc_primitives::RpcPollingConfig;
|
||||||
rpc_primitives::RpcPollingConfig,
|
|
||||||
transaction::{SignaturePrivateKey, Transaction, TransactionBody},
|
|
||||||
};
|
|
||||||
use nssa::Program;
|
|
||||||
use sequencer_core::{
|
use sequencer_core::{
|
||||||
config::{AccountInitialData, SequencerConfig},
|
config::{AccountInitialData, SequencerConfig},
|
||||||
SequencerCore,
|
SequencerCore,
|
||||||
|
|||||||
@ -1,23 +1,18 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use common::{
|
use common::{
|
||||||
execution_input::PublicNativeTokenSend,
|
|
||||||
sequencer_client::{json::SendTxResponse, SequencerClient},
|
sequencer_client::{json::SendTxResponse, SequencerClient},
|
||||||
transaction::Transaction,
|
|
||||||
ExecutionFailureKind,
|
ExecutionFailureKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
use accounts::account_core::{address::AccountAddress, Account};
|
use accounts::account_core::{address::AccountAddress, Account};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use chain_storage::NodeChainStore;
|
use chain_storage::NodeChainStore;
|
||||||
use common::transaction::TransactionBody;
|
|
||||||
use config::NodeConfig;
|
use config::NodeConfig;
|
||||||
use log::info;
|
use log::info;
|
||||||
use sc_core::proofs_circuits::pedersen_commitment_vec;
|
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use nssa;
|
|
||||||
|
|
||||||
use crate::helperfunctions::{fetch_config, produce_account_addr_from_hex};
|
use crate::helperfunctions::{fetch_config, produce_account_addr_from_hex};
|
||||||
|
|
||||||
@ -101,7 +96,7 @@ impl NodeCore {
|
|||||||
|
|
||||||
let signing_key = account.key_holder.get_pub_account_signing_key();
|
let signing_key = account.key_holder.get_pub_account_signing_key();
|
||||||
let witness_set =
|
let witness_set =
|
||||||
nssa::public_transaction::WitnessSet::for_message(&message, &[&signing_key]);
|
nssa::public_transaction::WitnessSet::for_message(&message, &[signing_key]);
|
||||||
|
|
||||||
let tx = nssa::PublicTransaction::new(message, witness_set);
|
let tx = nssa::PublicTransaction::new(message, witness_set);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user