mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-06 23:33:10 +00:00
logging added to UTXO, Account, Transaction
This commit is contained in:
parent
637adf9d22
commit
e7cc33c88a
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -4349,6 +4349,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"elliptic-curve",
|
||||
"env_logger",
|
||||
"hex",
|
||||
"log",
|
||||
"lru",
|
||||
"monotree",
|
||||
@ -4817,6 +4818,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"env_logger",
|
||||
"hex",
|
||||
"log",
|
||||
"monotree",
|
||||
"serde",
|
||||
|
||||
@ -2,6 +2,7 @@ use std::collections::HashMap;
|
||||
|
||||
use anyhow::Result;
|
||||
use k256::AffinePoint;
|
||||
use log::info;
|
||||
use serde::Serialize;
|
||||
use storage::{merkle_tree_public::TreeHashType, nullifier::UTXONullifier};
|
||||
use utxo::{
|
||||
@ -115,6 +116,12 @@ impl Account {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn log(&self) {
|
||||
self.key_holder.log();
|
||||
info!("Account address is {:?}", hex::encode(self.address));
|
||||
info!("Account balance is {:?}", self.balance);
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Account {
|
||||
|
||||
@ -3,6 +3,7 @@ use constants_types::{CipherText, Nonce};
|
||||
use elliptic_curve::group::GroupEncoding;
|
||||
use ephemeral_key_holder::EphemeralKeyHolder;
|
||||
use k256::AffinePoint;
|
||||
use log::info;
|
||||
use secret_holders::{SeedHolder, TopSecretKeyHolder, UTXOSecretKeyHolder};
|
||||
use storage::merkle_tree_public::TreeHashType;
|
||||
|
||||
@ -74,6 +75,14 @@ impl AddressKeyHolder {
|
||||
|
||||
cipher.decrypt(&nonce, ciphertext.as_slice()).unwrap()
|
||||
}
|
||||
|
||||
pub fn log(&self) {
|
||||
info!("AddressKeyHolder top_secret_key_holder is {:?}", self.top_secret_key_holder);
|
||||
info!("AddressKeyHolder utxo_secret_key_holder is {:?}", self.utxo_secret_key_holder);
|
||||
info!("AddressKeyHolder address is {:?}", self.address);
|
||||
info!("AddressKeyHolder nullifer_public_key is {:?}", self.nullifer_public_key);
|
||||
info!("AddressKeyHolder viewing_public_key is {:?}", self.viewing_public_key);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@ -140,6 +140,7 @@ impl NodeCore {
|
||||
|
||||
pub async fn create_new_account(&mut self) -> AccountAddress {
|
||||
let account = Account::new();
|
||||
account.log();
|
||||
|
||||
let addr = account.address;
|
||||
|
||||
@ -163,6 +164,7 @@ impl NodeCore {
|
||||
let acc_map_read_guard = self.storage.read().await;
|
||||
|
||||
let accout = acc_map_read_guard.acc_map.get(&acc).unwrap();
|
||||
accout.log();
|
||||
|
||||
let ephm_key_holder = &accout.produce_ephemeral_key_holder();
|
||||
|
||||
@ -222,6 +224,7 @@ impl NodeCore {
|
||||
let acc_map_read_guard = self.storage.read().await;
|
||||
|
||||
let accout = acc_map_read_guard.acc_map.get(&utxo.owner).unwrap();
|
||||
accout.log();
|
||||
|
||||
let commitment_in = {
|
||||
let guard = self.storage.write().await;
|
||||
@ -300,6 +303,7 @@ impl NodeCore {
|
||||
let acc_map_read_guard = self.storage.read().await;
|
||||
|
||||
let accout = acc_map_read_guard.acc_map.get(&acc).unwrap();
|
||||
accout.log();
|
||||
|
||||
let commitment_secrets = CommitmentSecrets {
|
||||
value: balance,
|
||||
@ -397,6 +401,7 @@ impl NodeCore {
|
||||
let commitment_in = acc_map_read_guard.utxo_commitments_store.get_tx(comm_gen_hash).unwrap().hash;
|
||||
|
||||
let accout = acc_map_read_guard.acc_map.get(&utxo.owner).unwrap();
|
||||
accout.log();
|
||||
|
||||
let nullifier = generate_nullifiers(
|
||||
&utxo,
|
||||
@ -436,6 +441,7 @@ impl NodeCore {
|
||||
) -> Result<(SendTxResponse, [u8; 32], [u8; 32])> {
|
||||
let point_before_prove = std::time::Instant::now();
|
||||
let (tx, utxo_hash) = self.mint_utxo_private(acc, amount).await;
|
||||
tx.log();
|
||||
let point_after_prove = std::time::Instant::now();
|
||||
|
||||
let commitment_generated_hash = tx.utxo_commitments_created_hashes[0];
|
||||
@ -464,6 +470,7 @@ impl NodeCore {
|
||||
) -> Result<(SendTxResponse, Vec<([u8; 32], [u8; 32])>)> {
|
||||
let point_before_prove = std::time::Instant::now();
|
||||
let (tx, utxo_hashes) = self.transfer_utxo_private(utxo, receivers).await;
|
||||
tx.log();
|
||||
let point_after_prove = std::time::Instant::now();
|
||||
|
||||
let timedelta = (point_after_prove - point_before_prove).as_millis();
|
||||
@ -480,6 +487,7 @@ impl NodeCore {
|
||||
) -> Result<(SendTxResponse, Vec<([u8; 32], [u8; 32])>)> {
|
||||
let point_before_prove = std::time::Instant::now();
|
||||
let (tx, utxo_hashes) = self.transfer_balance_shielded(acc, amount, receivers).await;
|
||||
tx.log();
|
||||
let point_after_prove = std::time::Instant::now();
|
||||
|
||||
let timedelta = (point_after_prove - point_before_prove).as_millis();
|
||||
@ -496,6 +504,7 @@ impl NodeCore {
|
||||
) -> Result<SendTxResponse> {
|
||||
let point_before_prove = std::time::Instant::now();
|
||||
let tx = self.transfer_utxo_deshielded(utxo, comm_gen_hash, receivers).await;
|
||||
tx.log();
|
||||
let point_after_prove = std::time::Instant::now();
|
||||
|
||||
let timedelta = (point_after_prove - point_before_prove).as_millis();
|
||||
@ -519,6 +528,7 @@ impl NodeCore {
|
||||
let mut write_guard = self.storage.write().await;
|
||||
|
||||
let acc = write_guard.acc_map.get_mut(&acc_addr).unwrap();
|
||||
acc.log();
|
||||
|
||||
acc.utxo_tree
|
||||
.get_item(new_utxo_hash)
|
||||
@ -527,6 +537,8 @@ impl NodeCore {
|
||||
.clone()
|
||||
};
|
||||
|
||||
new_utxo.log();
|
||||
|
||||
let resp = self
|
||||
.send_deshielded_send_tx(new_utxo, comm_gen_hash, vec![(100, acc_addr)])
|
||||
.await
|
||||
@ -540,6 +552,7 @@ impl NodeCore {
|
||||
let acc_map_read_guard = self.storage.read().await;
|
||||
|
||||
let acc = acc_map_read_guard.acc_map.get(&acc_addr).unwrap();
|
||||
acc.log();
|
||||
|
||||
acc.balance
|
||||
};
|
||||
@ -561,6 +574,7 @@ impl NodeCore {
|
||||
let acc_map_read_guard = self.storage.read().await;
|
||||
|
||||
let acc = acc_map_read_guard.acc_map.get(&acc_addr).unwrap();;
|
||||
acc.log();
|
||||
|
||||
info!("New acconut public balance is {:?}", acc.balance);
|
||||
};
|
||||
@ -580,6 +594,7 @@ impl NodeCore {
|
||||
let mut write_guard = self.storage.write().await;
|
||||
|
||||
let acc = write_guard.acc_map.get_mut(&acc_addr).unwrap();
|
||||
acc.log();
|
||||
|
||||
acc.utxo_tree
|
||||
.get_item(new_utxo_hash)
|
||||
@ -587,6 +602,8 @@ impl NodeCore {
|
||||
.unwrap()
|
||||
.clone()
|
||||
};
|
||||
new_utxo.log();
|
||||
|
||||
info!("User received new utxo {new_utxo:?}");
|
||||
}
|
||||
|
||||
@ -605,6 +622,7 @@ impl NodeCore {
|
||||
let mut write_guard = self.storage.write().await;
|
||||
|
||||
let acc = write_guard.acc_map.get_mut(&acc_addr).unwrap();
|
||||
acc.log();
|
||||
|
||||
acc.utxo_tree
|
||||
.get_item(new_utxo_hash)
|
||||
@ -612,6 +630,7 @@ impl NodeCore {
|
||||
.unwrap()
|
||||
.clone()
|
||||
};
|
||||
new_utxo.log();
|
||||
|
||||
let (resp, new_utxo_hashes) = self
|
||||
.send_private_send_tx(new_utxo, vec![(100, acc_addr_rec)])
|
||||
@ -628,6 +647,7 @@ impl NodeCore {
|
||||
let mut write_guard = self.storage.write().await;
|
||||
|
||||
let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap();
|
||||
acc.log();
|
||||
|
||||
acc.utxo_tree
|
||||
.get_item(new_utxo_hash)
|
||||
@ -653,6 +673,7 @@ impl NodeCore {
|
||||
{
|
||||
let acc_map_read_guard = self.storage.read().await;
|
||||
let acc = acc_map_read_guard.acc_map.get(&acc_addr).unwrap();
|
||||
acc.log();
|
||||
|
||||
info!("New acconut public balance is {:?}", acc.balance);
|
||||
}
|
||||
@ -672,6 +693,7 @@ impl NodeCore {
|
||||
let mut write_guard = self.storage.write().await;
|
||||
|
||||
let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap();
|
||||
acc.log();
|
||||
|
||||
acc.utxo_tree
|
||||
.get_item(new_utxo_hash)
|
||||
@ -698,6 +720,7 @@ impl NodeCore {
|
||||
let mut write_guard = self.storage.write().await;
|
||||
|
||||
let acc = write_guard.acc_map.get_mut(&acc_addr).unwrap();
|
||||
acc.log();
|
||||
|
||||
acc.utxo_tree
|
||||
.get_item(new_utxo_hash)
|
||||
@ -705,6 +728,7 @@ impl NodeCore {
|
||||
.unwrap()
|
||||
.clone()
|
||||
};
|
||||
new_utxo.log();
|
||||
|
||||
let resp = self
|
||||
.send_deshielded_send_tx(new_utxo, comm_gen_hash, vec![(100, acc_addr_rec)])
|
||||
@ -718,6 +742,7 @@ impl NodeCore {
|
||||
{
|
||||
let read_guard = self.storage.read().await;
|
||||
let acc_rec = read_guard.acc_map.get(&acc_addr_rec).unwrap();
|
||||
acc_rec.log();
|
||||
|
||||
info!("New account public balance is {:?}", acc_rec.balance);
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ serde.workspace = true
|
||||
lru.workspace = true
|
||||
thiserror.workspace = true
|
||||
elliptic-curve.workspace = true
|
||||
hex.workspace = true
|
||||
|
||||
rocksdb.workspace = true
|
||||
rs_merkle.workspace = true
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sha2::{digest::FixedOutput, Digest};
|
||||
|
||||
@ -89,3 +90,18 @@ impl From<TransactionPayload> for Transaction {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Transaction {
|
||||
pub fn log(&self) {
|
||||
info!("Transaction hash is {:?}", hex::encode(self.hash));
|
||||
info!("Transaction tx_kind is {:?}", self.tx_kind);
|
||||
info!("Transaction execution_input is {:?}", hex::encode(self.execution_input.clone()));
|
||||
info!("Transaction execution_output is {:?}", hex::encode(self.execution_output.clone()));
|
||||
info!("Transaction utxo_commitments_spent_hashes is {:?}", self.utxo_commitments_spent_hashes.iter().map(|val| hex::encode(val.clone())));
|
||||
info!("Transaction utxo_commitments_created_hashes is {:?}", self.utxo_commitments_created_hashes.iter().map(|val| hex::encode(val.clone())));
|
||||
info!("Transaction nullifier_created_hashes is {:?}", self.nullifier_created_hashes.iter().map(|val| hex::encode(val.clone())));
|
||||
info!("Transaction execution_proof_private is {:?}", self.execution_proof_private);
|
||||
info!("Transaction encoded_data is {:?}", self.encoded_data.iter().map(|val| (hex::encode(val.0.clone()), hex::encode(val.1.clone()))));
|
||||
info!("Transaction ephemeral_pub_key is {:?}", hex::encode(self.ephemeral_pub_key.clone()));
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,7 @@ log.workspace = true
|
||||
serde.workspace = true
|
||||
monotree.workspace = true
|
||||
sha2.workspace = true
|
||||
hex.workspace = true
|
||||
|
||||
[dependencies.storage]
|
||||
path = "../storage"
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use anyhow::Result;
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sha2::{digest::FixedOutput, Digest};
|
||||
use storage::{merkle_tree_public::TreeHashType, nullifier::UTXONullifier, AccountId};
|
||||
@ -69,6 +70,15 @@ impl UTXO {
|
||||
privacy_flag: self.privacy_flag,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn log(&self) {
|
||||
info!("UTXO hash is {:?}", hex::encode(self.hash));
|
||||
info!("UTXO owner is {:?}", self.owner);
|
||||
info!("UTXO nullifier is {:?}", self.nullifier.clone().map(|val| hex::encode(val.utxo_hash)));
|
||||
info!("UTXO asset is {:?}", hex::encode(self.asset.clone()));
|
||||
info!("UTXO amount is {:?}", self.amount);
|
||||
info!("UTXO privacy_flag is {:?}", self.privacy_flag);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user