Просмотр исходного кода

Change some logs from trace to debug in the codebase.

parazyd 4 лет назад
Родитель
Сommit
dc79fe325c
7 измененных файлов с 78 добавлено и 81 удалено
  1. 5 5
      src/blockchain/slabstore.rs
  2. 0 3
      src/cli/cli_parser.rs
  3. 19 19
      src/client.rs
  4. 6 6
      src/service/bridge.rs
  5. 14 14
      src/service/gateway.rs
  6. 13 13
      src/state.rs
  7. 21 21
      src/wallet/cashierdb.rs

+ 5 - 5
src/blockchain/slabstore.rs

@@ -1,6 +1,6 @@
 use std::sync::Arc;
 use std::sync::Arc;
 
 
-use log::trace;
+use log::debug;
 
 
 use super::{
 use super::{
     rocks::{columns, IteratorMode, RocksColumn},
     rocks::{columns, IteratorMode, RocksColumn},
@@ -21,14 +21,14 @@ impl SlabStore {
     }
     }
 
 
     pub fn get(&self, key: Vec<u8>) -> Result<Option<Vec<u8>>> {
     pub fn get(&self, key: Vec<u8>) -> Result<Option<Vec<u8>>> {
-        trace!(target: "SLABSTORE", "get value");
+        debug!(target: "SLABSTORE", "get value");
         let key: u64 = deserialize(&key)?;
         let key: u64 = deserialize(&key)?;
         let value = self.rocks.get(key)?;
         let value = self.rocks.get(key)?;
         Ok(value)
         Ok(value)
     }
     }
 
 
     pub fn put(&self, slab: Slab) -> Result<Option<u64>> {
     pub fn put(&self, slab: Slab) -> Result<Option<u64>> {
-        trace!(target: "SLABSTORE", "Put slab");
+        debug!(target: "SLABSTORE", "Put slab");
         let last_index = self.get_last_index()?;
         let last_index = self.get_last_index()?;
         let key = last_index + 1;
         let key = last_index + 1;
 
 
@@ -45,7 +45,7 @@ impl SlabStore {
     }
     }
 
 
     pub fn get_last_index(&self) -> Result<u64> {
     pub fn get_last_index(&self) -> Result<u64> {
-        trace!(target: "SLABSTORE", "Get last index");
+        debug!(target: "SLABSTORE", "Get last index");
         let last_index = self.rocks.iterator(IteratorMode::End)?.next();
         let last_index = self.rocks.iterator(IteratorMode::End)?.next();
         match last_index {
         match last_index {
             Some((index, _)) => Ok(deserialize(&index)?),
             Some((index, _)) => Ok(deserialize(&index)?),
@@ -54,7 +54,7 @@ impl SlabStore {
     }
     }
 
 
     pub fn get_last_index_as_bytes(&self) -> Result<Vec<u8>> {
     pub fn get_last_index_as_bytes(&self) -> Result<Vec<u8>> {
-        trace!(target: "SLABSTORE", "Get last index as bytes");
+        debug!(target: "SLABSTORE", "Get last index as bytes");
         let last_index = self.rocks.iterator(IteratorMode::End)?.next();
         let last_index = self.rocks.iterator(IteratorMode::End)?.next();
         match last_index {
         match last_index {
             Some((index, _)) => Ok(index.to_vec()),
             Some((index, _)) => Ok(index.to_vec()),

+ 0 - 3
src/cli/cli_parser.rs

@@ -111,9 +111,6 @@ pub struct CliGatewayd {
     /// Increase verbosity
     /// Increase verbosity
     #[clap(short, parse(from_occurrences))]
     #[clap(short, parse(from_occurrences))]
     pub verbose: u8,
     pub verbose: u8,
-    /// Show event trace
-    #[clap(short, long)]
-    pub trace: bool,
 }
 }
 
 
 /// Darkfid cli
 /// Darkfid cli

+ 19 - 19
src/client.rs

@@ -1,7 +1,7 @@
 use async_std::sync::{Arc, Mutex};
 use async_std::sync::{Arc, Mutex};
 
 
 use incrementalmerkletree::{bridgetree::BridgeTree, Tree};
 use incrementalmerkletree::{bridgetree::BridgeTree, Tree};
-use log::{debug, info, trace, warn};
+use log::{debug, info, warn};
 use smol::Executor;
 use smol::Executor;
 use url::Url;
 use url::Url;
 
 
@@ -106,7 +106,7 @@ impl Client {
         let main_keypair = wallet.get_default_keypair().await?;
         let main_keypair = wallet.get_default_keypair().await?;
         info!("Main keypair: {}", Address::from(main_keypair.public).to_string());
         info!("Main keypair: {}", Address::from(main_keypair.public).to_string());
 
 
-        trace!("Creating GatewayClient");
+        debug!("Creating GatewayClient");
         let slabstore = RocksColumn::<columns::Slabs>::new(rocks);
         let slabstore = RocksColumn::<columns::Slabs>::new(rocks);
         let gateway = GatewayClient::new(gateway_addrs.0, gateway_addrs.1, slabstore)?;
         let gateway = GatewayClient::new(gateway_addrs.0, gateway_addrs.1, slabstore)?;
 
 
@@ -132,7 +132,7 @@ impl Client {
         clear_input: bool,
         clear_input: bool,
         state: Arc<Mutex<State>>,
         state: Arc<Mutex<State>>,
     ) -> ClientResult<Vec<Coin>> {
     ) -> ClientResult<Vec<Coin>> {
-        trace!("Begin building slab from tx");
+        debug!("Begin building slab from tx");
         let mut clear_inputs: Vec<tx::TransactionBuilderClearInputInfo> = vec![];
         let mut clear_inputs: Vec<tx::TransactionBuilderClearInputInfo> = vec![];
         let mut inputs: Vec<tx::TransactionBuilderInputInfo> = vec![];
         let mut inputs: Vec<tx::TransactionBuilderInputInfo> = vec![];
         let mut outputs: Vec<tx::TransactionBuilderOutputInfo> = vec![];
         let mut outputs: Vec<tx::TransactionBuilderOutputInfo> = vec![];
@@ -144,7 +144,7 @@ impl Client {
             let input = tx::TransactionBuilderClearInputInfo { value, token_id, signature_secret };
             let input = tx::TransactionBuilderClearInputInfo { value, token_id, signature_secret };
             clear_inputs.push(input);
             clear_inputs.push(input);
         } else {
         } else {
-            trace!("Start building tx inputs");
+            debug!("Start building tx inputs");
             let mut inputs_value = 0_u64;
             let mut inputs_value = 0_u64;
             let state_m = state.lock().await;
             let state_m = state.lock().await;
             let own_coins = self.wallet.get_own_coins().await?;
             let own_coins = self.wallet.get_own_coins().await?;
@@ -185,7 +185,7 @@ impl Client {
                 });
                 });
             }
             }
 
 
-            trace!("Finish building inputs");
+            debug!("Finish building inputs");
         }
         }
 
 
         outputs.push(tx::TransactionBuilderOutputInfo { value, token_id, public: pubkey });
         outputs.push(tx::TransactionBuilderOutputInfo { value, token_id, public: pubkey });
@@ -198,15 +198,15 @@ impl Client {
         tx.encode(&mut tx_data).expect("encode tx");
         tx.encode(&mut tx_data).expect("encode tx");
 
 
         let slab = Slab::new(tx_data);
         let slab = Slab::new(tx_data);
-        trace!("Finish building slab from tx");
+        debug!("Finish building slab from tx");
 
 
         // Check if it's valid before sending to gateway
         // Check if it's valid before sending to gateway
         let state = &*state.lock().await;
         let state = &*state.lock().await;
         state_transition(state, tx)?;
         state_transition(state, tx)?;
 
 
-        trace!("Sending slab to gateway");
+        debug!("Sending slab to gateway");
         self.gateway.put_slab(slab).await?;
         self.gateway.put_slab(slab).await?;
-        trace!("Slab sent to gateway successfully");
+        debug!("Slab sent to gateway successfully");
         Ok(coins)
         Ok(coins)
     }
     }
 
 
@@ -261,31 +261,31 @@ impl Client {
         wallet: WalletPtr,
         wallet: WalletPtr,
         notify: Option<async_channel::Sender<(PublicKey, u64)>>,
         notify: Option<async_channel::Sender<(PublicKey, u64)>>,
     ) -> Result<()> {
     ) -> Result<()> {
-        trace!("Building tx from slab and updating the state");
+        debug!("Building tx from slab and updating the state");
         let payload = slab.get_payload();
         let payload = slab.get_payload();
         /*
         /*
         use std::io::Write;
         use std::io::Write;
         let mut file = std::fs::File::create("/tmp/payload.txt")?;
         let mut file = std::fs::File::create("/tmp/payload.txt")?;
         file.write_all(&payload)?;
         file.write_all(&payload)?;
         */
         */
-        trace!("Decoding payload");
+        debug!("Decoding payload");
         let tx = tx::Transaction::decode(&payload[..])?;
         let tx = tx::Transaction::decode(&payload[..])?;
 
 
         let update: StateUpdate;
         let update: StateUpdate;
 
 
         // This is separate because otherwise the mutex is never unlocked.
         // This is separate because otherwise the mutex is never unlocked.
         {
         {
-            trace!("Acquiring state lock");
+            debug!("Acquiring state lock");
             let state = &*state.lock().await;
             let state = &*state.lock().await;
             update = state_transition(state, tx)?;
             update = state_transition(state, tx)?;
-            trace!("Successfully passed state_transition");
+            debug!("Successfully passed state_transition");
         }
         }
 
 
-        trace!("Acquiring state lock");
+        debug!("Acquiring state lock");
         let mut state = state.lock().await;
         let mut state = state.lock().await;
-        trace!("Trying to apply the new state");
+        debug!("Trying to apply the new state");
         state.apply(update, secret_keys, notify, wallet).await?;
         state.apply(update, secret_keys, notify, wallet).await?;
-        trace!("Successfully passed state.apply");
+        debug!("Successfully passed state.apply");
 
 
         Ok(())
         Ok(())
     }
     }
@@ -297,7 +297,7 @@ impl Client {
         notify: async_channel::Sender<(PublicKey, u64)>,
         notify: async_channel::Sender<(PublicKey, u64)>,
         executor: Arc<Executor<'_>>,
         executor: Arc<Executor<'_>>,
     ) -> Result<()> {
     ) -> Result<()> {
-        trace!("Start subscriber for cashier");
+        debug!("Start subscriber for cashier");
         let gateway_slabs_sub = self.gateway.start_subscriber(executor.clone()).await?;
         let gateway_slabs_sub = self.gateway.start_subscriber(executor.clone()).await?;
 
 
         let secret_key = self.main_keypair.secret;
         let secret_key = self.main_keypair.secret;
@@ -306,7 +306,7 @@ impl Client {
         let task: smol::Task<Result<()>> = executor.spawn(async move {
         let task: smol::Task<Result<()>> = executor.spawn(async move {
             loop {
             loop {
                 let slab = gateway_slabs_sub.recv().await?;
                 let slab = gateway_slabs_sub.recv().await?;
-                trace!("Received new slab");
+                debug!("Received new slab");
 
 
                 let mut secret_keys = vec![secret_key];
                 let mut secret_keys = vec![secret_key];
                 let mut withdraw_keys = cashier_wallet.get_withdraw_private_keys().await?;
                 let mut withdraw_keys = cashier_wallet.get_withdraw_private_keys().await?;
@@ -337,7 +337,7 @@ impl Client {
         state: Arc<Mutex<State>>,
         state: Arc<Mutex<State>>,
         executor: Arc<Executor<'_>>,
         executor: Arc<Executor<'_>>,
     ) -> Result<()> {
     ) -> Result<()> {
-        trace!("Start subscriber for darkfid");
+        debug!("Start subscriber for darkfid");
         let gateway_slabs_sub = self.gateway.start_subscriber(executor.clone()).await?;
         let gateway_slabs_sub = self.gateway.start_subscriber(executor.clone()).await?;
 
 
         let secret_key = self.main_keypair.secret;
         let secret_key = self.main_keypair.secret;
@@ -346,7 +346,7 @@ impl Client {
         let task: smol::Task<Result<()>> = executor.spawn(async move {
         let task: smol::Task<Result<()>> = executor.spawn(async move {
             loop {
             loop {
                 let slab = gateway_slabs_sub.recv().await?;
                 let slab = gateway_slabs_sub.recv().await?;
-                trace!("Received new slab");
+                debug!("Received new slab");
 
 
                 let update_state = Self::update_state(
                 let update_state = Self::update_state(
                     vec![secret_key],
                     vec![secret_key],

+ 6 - 6
src/service/bridge.rs

@@ -4,7 +4,7 @@ use async_executor::Executor;
 use async_std::sync::{Arc, Mutex};
 use async_std::sync::{Arc, Mutex};
 use async_trait::async_trait;
 use async_trait::async_trait;
 use futures::stream::{FuturesUnordered, StreamExt};
 use futures::stream::{FuturesUnordered, StreamExt};
-use log::{error, trace};
+use log::{debug, error};
 
 
 use crate::{
 use crate::{
     crypto::keypair::PublicKey, types::*, util::NetworkName, wallet::cashierdb::TokenKey, Error,
     crypto::keypair::PublicKey, types::*, util::NetworkName, wallet::cashierdb::TokenKey, Error,
@@ -76,7 +76,7 @@ impl Bridge {
         network: NetworkName,
         network: NetworkName,
         client: Arc<dyn NetworkClient + Send + Sync>,
         client: Arc<dyn NetworkClient + Send + Sync>,
     ) -> Result<()> {
     ) -> Result<()> {
-        trace!(target: "BRIDGE", "Adding new client");
+        debug!(target: "BRIDGE", "Adding new client");
 
 
         let client2 = client.clone();
         let client2 = client.clone();
         let notifier = client2.get_notifier().await?;
         let notifier = client2.get_notifier().await?;
@@ -92,7 +92,7 @@ impl Bridge {
 
 
     pub async fn listen(self: Arc<Self>) -> Option<Result<TokenNotification>> {
     pub async fn listen(self: Arc<Self>) -> Option<Result<TokenNotification>> {
         if !self.notifiers.is_empty() {
         if !self.notifiers.is_empty() {
-            trace!(target: "BRIDGE", "Start listening for new notifications");
+            debug!(target: "BRIDGE", "Start listening for new notifications");
             let notification = self
             let notification = self
                 .notifiers
                 .notifiers
                 .iter()
                 .iter()
@@ -102,7 +102,7 @@ impl Bridge {
                 .await
                 .await
                 .map(|o| o.map_err(Error::from));
                 .map(|o| o.map_err(Error::from));
 
 
-            trace!(target: "BRIDGE", "Stop listening for new notifications");
+            debug!(target: "BRIDGE", "Stop listening for new notifications");
 
 
             notification
             notification
         } else {
         } else {
@@ -116,7 +116,7 @@ impl Bridge {
         mint: Option<String>,
         mint: Option<String>,
         executor: Arc<Executor<'_>>,
         executor: Arc<Executor<'_>>,
     ) -> BridgeSubscribtion {
     ) -> BridgeSubscribtion {
-        trace!(target: "BRIDGE", "Start new subscription");
+        debug!(target: "BRIDGE", "Start new subscription");
         let (sender, req) = async_channel::unbounded();
         let (sender, req) = async_channel::unbounded();
         let (rep, receiver) = async_channel::unbounded();
         let (rep, receiver) = async_channel::unbounded();
 
 
@@ -135,7 +135,7 @@ impl Bridge {
         mint: Option<String>,
         mint: Option<String>,
         executor: Arc<Executor<'_>>,
         executor: Arc<Executor<'_>>,
     ) -> Result<()> {
     ) -> Result<()> {
-        trace!(target: "BRIDGE", "Listen for new subscriptions");
+        debug!(target: "BRIDGE", "Listen for new subscriptions");
         let req = req.recv().await?;
         let req = req.recv().await?;
 
 
         let network = req.network;
         let network = req.network;

+ 14 - 14
src/service/gateway.rs

@@ -5,7 +5,7 @@ use std::{
 };
 };
 
 
 use async_executor::Executor;
 use async_executor::Executor;
-use log::trace;
+use log::debug;
 use url::Url;
 use url::Url;
 
 
 use super::reqrep::{PeerId, Publisher, RepProtocol, Reply, ReqProtocol, Request, Subscriber};
 use super::reqrep::{PeerId, Publisher, RepProtocol, Reply, ReqProtocol, Request, Subscriber};
@@ -117,7 +117,7 @@ impl GatewayService {
         let peer = msg.0;
         let peer = msg.0;
         match request.get_command() {
         match request.get_command() {
             0 => {
             0 => {
-                trace!(target: "GATEWAY DAEMON" ,"Received putslab msg");
+                debug!(target: "GATEWAY DAEMON", "Received putslab msg");
                 // PUTSLAB
                 // PUTSLAB
                 let slab = request.get_payload();
                 let slab = request.get_payload();
 
 
@@ -137,7 +137,7 @@ impl GatewayService {
                 publish_queue.send(slab).await?;
                 publish_queue.send(slab).await?;
             }
             }
             1 => {
             1 => {
-                trace!(target: "GATEWAY DAEMON", "Received getslab msg");
+                debug!(target: "GATEWAY DAEMON", "Received getslab msg");
                 let index = request.get_payload();
                 let index = request.get_payload();
                 let slab = slabstore.get(index)?;
                 let slab = slabstore.get(index)?;
 
 
@@ -154,7 +154,7 @@ impl GatewayService {
                 // GETSLAB
                 // GETSLAB
             }
             }
             2 => {
             2 => {
-                trace!(target: "GATEWAY DAEMON","Received getlastindex msg");
+                debug!(target: "GATEWAY DAEMON","Received getlastindex msg");
                 let index = slabstore.get_last_index_as_bytes()?;
                 let index = slabstore.get_last_index_as_bytes()?;
 
 
                 let reply = Reply::from(&request, GatewayError::NoError as u32, index);
                 let reply = Reply::from(&request, GatewayError::NoError as u32, index);
@@ -226,7 +226,7 @@ impl GatewayClient {
     }
     }
 
 
     pub async fn sync(&mut self) -> Result<u64> {
     pub async fn sync(&mut self) -> Result<u64> {
-        trace!(target: "GATEWAY CLIENT", "Start Syncing");
+        debug!(target: "GATEWAY CLIENT", "Start Syncing");
 
 
         let local_last_index = self.slabstore.get_last_index()?;
         let local_last_index = self.slabstore.get_last_index()?;
 
 
@@ -248,12 +248,12 @@ impl GatewayClient {
             }
             }
         }
         }
 
 
-        trace!(target: "GATEWAY CLIENT","End Syncing");
+        debug!(target: "GATEWAY CLIENT","End Syncing");
         Ok(last_index)
         Ok(last_index)
     }
     }
 
 
     pub async fn get_slab(&mut self, index: u64) -> Result<Option<Slab>> {
     pub async fn get_slab(&mut self, index: u64) -> Result<Option<Slab>> {
-        trace!(target: "GATEWAY CLIENT","Get slab");
+        debug!(target: "GATEWAY CLIENT","Get slab");
 
 
         let handle_error = Arc::new(handle_error);
         let handle_error = Arc::new(handle_error);
         let rep = self
         let rep = self
@@ -272,7 +272,7 @@ impl GatewayClient {
     }
     }
 
 
     pub async fn put_slab(&mut self, mut slab: Slab) -> Result<()> {
     pub async fn put_slab(&mut self, mut slab: Slab) -> Result<()> {
-        trace!(target: "GATEWAY CLIENT","Put slab");
+        debug!(target: "GATEWAY CLIENT","Put slab");
 
 
         loop {
         loop {
             let last_index = self.sync().await?;
             let last_index = self.sync().await?;
@@ -294,7 +294,7 @@ impl GatewayClient {
     }
     }
 
 
     pub async fn get_last_index(&mut self) -> Result<u64> {
     pub async fn get_last_index(&mut self) -> Result<u64> {
-        trace!(target: "GATEWAY CLIENT","Get last index");
+        debug!(target: "GATEWAY CLIENT","Get last index");
 
 
         let handle_error = Arc::new(handle_error);
         let handle_error = Arc::new(handle_error);
 
 
@@ -314,7 +314,7 @@ impl GatewayClient {
         &self,
         &self,
         executor: Arc<Executor<'_>>,
         executor: Arc<Executor<'_>>,
     ) -> Result<GatewaySlabsSubscriber> {
     ) -> Result<GatewaySlabsSubscriber> {
-        trace!(target: "GATEWAY CLIENT","Start subscriber");
+        debug!(target: "GATEWAY CLIENT", "Start subscriber");
 
 
         let mut subscriber = Subscriber::new(self.sub_addr, String::from("GATEWAY CLIENT"));
         let mut subscriber = Subscriber::new(self.sub_addr, String::from("GATEWAY CLIENT"));
         subscriber.start().await?;
         subscriber.start().await?;
@@ -333,11 +333,11 @@ impl GatewayClient {
         slabstore: Arc<SlabStore>,
         slabstore: Arc<SlabStore>,
         gateway_slabs_sub_s: async_channel::Sender<Slab>,
         gateway_slabs_sub_s: async_channel::Sender<Slab>,
     ) -> Result<()> {
     ) -> Result<()> {
-        trace!(target: "GATEWAY CLIENT","Start subscribe loop");
+        debug!(target: "GATEWAY CLIENT", "Start subscribe loop");
 
 
         loop {
         loop {
             let slab = subscriber.fetch::<Slab>().await?;
             let slab = subscriber.fetch::<Slab>().await?;
-            trace!(target: "GATEWAY CLIENT","Received new slab");
+            debug!(target: "GATEWAY CLIENT", "Received new slab");
             gateway_slabs_sub_s.send(slab.clone()).await?;
             gateway_slabs_sub_s.send(slab.clone()).await?;
             slabstore.put(slab)?;
             slabstore.put(slab)?;
         }
         }
@@ -351,10 +351,10 @@ impl GatewayClient {
 fn handle_error(status_code: u32) {
 fn handle_error(status_code: u32) {
     match status_code {
     match status_code {
         1 => {
         1 => {
-            trace!(target: "GATEWAY SERVICE", "Reply has an Error: Index is not updated");
+            debug!(target: "GATEWAY SERVICE", "Reply has an Error: Index is not updated");
         }
         }
         2 => {
         2 => {
-            trace!(target: "GATEWAY SERVICE", "Reply has an Error: Index Not Exist");
+            debug!(target: "GATEWAY SERVICE", "Reply has an Error: Index Not Exist");
         }
         }
         _ => {}
         _ => {}
     }
     }

+ 13 - 13
src/state.rs

@@ -1,5 +1,5 @@
 use incrementalmerkletree::{bridgetree::BridgeTree, Frontier, Tree};
 use incrementalmerkletree::{bridgetree::BridgeTree, Frontier, Tree};
-use log::{debug, trace};
+use log::{debug, error};
 
 
 use crate::{
 use crate::{
     blockchain::{rocks::columns, RocksColumn},
     blockchain::{rocks::columns, RocksColumn},
@@ -66,18 +66,18 @@ impl From<error::Error> for VerifyFailed {
 
 
 pub fn state_transition<S: ProgramState>(state: &S, tx: Transaction) -> VerifyResult<StateUpdate> {
 pub fn state_transition<S: ProgramState>(state: &S, tx: Transaction) -> VerifyResult<StateUpdate> {
     // Check deposits are legit
     // Check deposits are legit
-    trace!(target: "STATE TRANSITION", "iterate clear_inputs");
+    debug!(target: "STATE TRANSITION", "iterate clear_inputs");
 
 
     for (i, input) in tx.clear_inputs.iter().enumerate() {
     for (i, input) in tx.clear_inputs.iter().enumerate() {
         // Check the public key in the clear inputs
         // Check the public key in the clear inputs
         // It should be a valid public key for the cashier
         // It should be a valid public key for the cashier
         if !state.is_valid_cashier_public_key(&input.signature_public) {
         if !state.is_valid_cashier_public_key(&input.signature_public) {
-            log::error!(target: "STATE TRANSITION", "Invalid cashier public key");
+            error!(target: "STATE TRANSITION", "Invalid cashier public key");
             return Err(VerifyFailed::InvalidCashierKey(i))
             return Err(VerifyFailed::InvalidCashierKey(i))
         }
         }
     }
     }
 
 
-    trace!(target: "STATE TRANSITION", "iterate inputs");
+    debug!(target: "STATE TRANSITION", "iterate inputs");
 
 
     for (i, input) in tx.inputs.iter().enumerate() {
     for (i, input) in tx.inputs.iter().enumerate() {
         let merkle = &input.revealed.merkle_root;
         let merkle = &input.revealed.merkle_root;
@@ -97,9 +97,9 @@ pub fn state_transition<S: ProgramState>(state: &S, tx: Transaction) -> VerifyRe
         }
         }
     }
     }
 
 
-    trace!(target: "STATE TRANSITION", "Check the tx verifies correctly");
+    debug!(target: "STATE TRANSITION", "Check the tx verifies correctly");
     tx.verify(state.mint_vk(), state.spend_vk())?;
     tx.verify(state.mint_vk(), state.spend_vk())?;
-    trace!(target: "STATE TRANSITION", "Verified successfully");
+    debug!(target: "STATE TRANSITION", "Verified successfully");
 
 
     let mut nullifiers = vec![];
     let mut nullifiers = vec![];
     for input in tx.inputs {
     for input in tx.inputs {
@@ -143,12 +143,12 @@ impl State {
         wallet: WalletPtr,
         wallet: WalletPtr,
     ) -> Result<()> {
     ) -> Result<()> {
         // Extend our list of nullifiers with the ones from the update.
         // Extend our list of nullifiers with the ones from the update.
-        trace!("Extend nullifiers");
+        debug!("Extend nullifiers");
         for nullifier in update.nullifiers {
         for nullifier in update.nullifiers {
             self.nullifiers.put(nullifier, vec![] as Vec<u8>)?;
             self.nullifiers.put(nullifier, vec![] as Vec<u8>)?;
         }
         }
 
 
-        trace!("Update Merkle tree and witness");
+        debug!("Update Merkle tree and witness");
         for (coin, enc_note) in update.coins.into_iter().zip(update.enc_notes.iter()) {
         for (coin, enc_note) in update.coins.into_iter().zip(update.enc_notes.iter()) {
             // Add the new coins to the Merkle tree
             // Add the new coins to the Merkle tree
             let node = MerkleNode(coin.0);
             let node = MerkleNode(coin.0);
@@ -169,7 +169,7 @@ impl State {
                     let pubkey = PublicKey::from_secret(*secret);
                     let pubkey = PublicKey::from_secret(*secret);
 
 
                     debug!("Received a coin: amount {}", note.value);
                     debug!("Received a coin: amount {}", note.value);
-                    trace!("Send a notification");
+                    debug!("Send a notification");
                     if let Some(ch) = notify.clone() {
                     if let Some(ch) = notify.clone() {
                         ch.send((pubkey, note.value)).await?;
                         ch.send((pubkey, note.value)).await?;
                     }
                     }
@@ -179,7 +179,7 @@ impl State {
             wallet.put_tree(&self.tree).await?;
             wallet.put_tree(&self.tree).await?;
         }
         }
 
 
-        trace!("apply() exiting successfully");
+        debug!("apply() exiting successfully");
         Ok(())
         Ok(())
     }
     }
 
 
@@ -193,12 +193,12 @@ impl State {
 
 
 impl ProgramState for State {
 impl ProgramState for State {
     fn is_valid_cashier_public_key(&self, public: &PublicKey) -> bool {
     fn is_valid_cashier_public_key(&self, public: &PublicKey) -> bool {
-        trace!("Check if it is a valid cashier public key");
+        debug!("Check if it is a valid cashier public key");
         self.public_keys.contains(public)
         self.public_keys.contains(public)
     }
     }
 
 
     fn is_valid_merkle(&self, merkle_root: &MerkleNode) -> bool {
     fn is_valid_merkle(&self, merkle_root: &MerkleNode) -> bool {
-        trace!("Check if it is valid merkle");
+        debug!("Check if it is valid merkle");
         if let Ok(mr) = self.merkle_roots.key_exist(merkle_root.clone()) {
         if let Ok(mr) = self.merkle_roots.key_exist(merkle_root.clone()) {
             return mr
             return mr
         }
         }
@@ -206,7 +206,7 @@ impl ProgramState for State {
     }
     }
 
 
     fn nullifier_exists(&self, nullifier: &Nullifier) -> bool {
     fn nullifier_exists(&self, nullifier: &Nullifier) -> bool {
-        trace!("Check if nullifier exists");
+        debug!("Check if nullifier exists");
         if let Ok(nl) = self.nullifiers.key_exist(nullifier.to_bytes()) {
         if let Ok(nl) = self.nullifiers.key_exist(nullifier.to_bytes()) {
             return nl
             return nl
         }
         }

+ 21 - 21
src/wallet/cashierdb.rs

@@ -2,7 +2,7 @@ use std::{fs::create_dir_all, path::Path, str::FromStr, time::Duration};
 
 
 use async_std::sync::Arc;
 use async_std::sync::Arc;
 use incrementalmerkletree::bridgetree::BridgeTree;
 use incrementalmerkletree::bridgetree::BridgeTree;
-use log::{error, info, trace, LevelFilter};
+use log::{debug, error, info, LevelFilter};
 use sqlx::{
 use sqlx::{
     sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePoolOptions},
     sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePoolOptions},
     ConnectOptions, Row, SqlitePool,
     ConnectOptions, Row, SqlitePool,
@@ -50,7 +50,7 @@ impl WalletApi for CashierDb {}
 
 
 impl CashierDb {
 impl CashierDb {
     pub async fn new(path: &str, password: String) -> Result<CashierDbPtr> {
     pub async fn new(path: &str, password: String) -> Result<CashierDbPtr> {
-        trace!("new() Constructor called");
+        debug!("new() Constructor called");
         if password.trim().is_empty() {
         if password.trim().is_empty() {
             error!("Password is empty. You must set a password to use the wallet.");
             error!("Password is empty. You must set a password to use the wallet.");
             return Err(Error::from(ClientFailed::EmptyPassword))
             return Err(Error::from(ClientFailed::EmptyPassword))
@@ -85,24 +85,24 @@ impl CashierDb {
 
 
         let mut conn = self.conn.acquire().await?;
         let mut conn = self.conn.acquire().await?;
 
 
-        trace!("Initializing main keypairs table");
+        debug!("Initializing main keypairs table");
         sqlx::query(main_kps).execute(&mut conn).await?;
         sqlx::query(main_kps).execute(&mut conn).await?;
 
 
-        trace!("Initializing deposit keypairs table");
+        debug!("Initializing deposit keypairs table");
         sqlx::query(deposit_kps).execute(&mut conn).await?;
         sqlx::query(deposit_kps).execute(&mut conn).await?;
 
 
-        trace!("Initializing withdraw keypairs table");
+        debug!("Initializing withdraw keypairs table");
         sqlx::query(withdraw_kps).execute(&mut conn).await?;
         sqlx::query(withdraw_kps).execute(&mut conn).await?;
         Ok(())
         Ok(())
     }
     }
 
 
     pub async fn tree_gen(&self) -> Result<()> {
     pub async fn tree_gen(&self) -> Result<()> {
-        trace!("Attempting to generate merkle tree");
+        debug!("Attempting to generate merkle tree");
         let mut conn = self.conn.acquire().await?;
         let mut conn = self.conn.acquire().await?;
 
 
         match sqlx::query("SELECT * FROM tree").fetch_one(&mut conn).await {
         match sqlx::query("SELECT * FROM tree").fetch_one(&mut conn).await {
             Ok(_) => {
             Ok(_) => {
-                error!("Tree already exist");
+                error!("Tree already exists");
                 Err(Error::from(ClientFailed::TreeExists))
                 Err(Error::from(ClientFailed::TreeExists))
             }
             }
             Err(_) => {
             Err(_) => {
@@ -114,7 +114,7 @@ impl CashierDb {
     }
     }
 
 
     pub async fn get_tree(&self) -> Result<BridgeTree<MerkleNode, 32>> {
     pub async fn get_tree(&self) -> Result<BridgeTree<MerkleNode, 32>> {
-        trace!("Getting merkle tree");
+        debug!("Getting merkle tree");
         let mut conn = self.conn.acquire().await?;
         let mut conn = self.conn.acquire().await?;
 
 
         let row = sqlx::query("SELECT tree FROM tree").fetch_one(&mut conn).await?;
         let row = sqlx::query("SELECT tree FROM tree").fetch_one(&mut conn).await?;
@@ -123,7 +123,7 @@ impl CashierDb {
     }
     }
 
 
     pub async fn put_tree(&self, tree: &BridgeTree<MerkleNode, 32>) -> Result<()> {
     pub async fn put_tree(&self, tree: &BridgeTree<MerkleNode, 32>) -> Result<()> {
-        trace!("Attempting to write merkle tree");
+        debug!("Attempting to write merkle tree");
         let mut conn = self.conn.acquire().await?;
         let mut conn = self.conn.acquire().await?;
 
 
         let tree_bytes = bincode::serialize(tree)?;
         let tree_bytes = bincode::serialize(tree)?;
@@ -136,7 +136,7 @@ impl CashierDb {
     }
     }
 
 
     pub async fn put_main_keys(&self, token_key: &TokenKey, network: &NetworkName) -> Result<()> {
     pub async fn put_main_keys(&self, token_key: &TokenKey, network: &NetworkName) -> Result<()> {
-        trace!("Writing main keys into the database");
+        debug!("Writing main keys into the database");
         let network = self.get_value_serialized(network)?;
         let network = self.get_value_serialized(network)?;
 
 
         let mut conn = self.conn.acquire().await?;
         let mut conn = self.conn.acquire().await?;
@@ -156,7 +156,7 @@ impl CashierDb {
     }
     }
 
 
     pub async fn get_main_keys(&self, network: &NetworkName) -> Result<Vec<TokenKey>> {
     pub async fn get_main_keys(&self, network: &NetworkName) -> Result<Vec<TokenKey>> {
-        trace!("Returning main keypairs");
+        debug!("Returning main keypairs");
         let network = self.get_value_serialized(network)?;
         let network = self.get_value_serialized(network)?;
 
 
         let mut conn = self.conn.acquire().await?;
         let mut conn = self.conn.acquire().await?;
@@ -180,7 +180,7 @@ impl CashierDb {
     }
     }
 
 
     pub async fn remove_withdraw_and_deposit_keys(&self) -> Result<()> {
     pub async fn remove_withdraw_and_deposit_keys(&self) -> Result<()> {
-        trace!("Removing withdraw and deposit keys");
+        debug!("Removing withdraw and deposit keys");
         let mut conn = self.conn.acquire().await?;
         let mut conn = self.conn.acquire().await?;
         sqlx::query("DROP TABLE deposit_keypairs;").execute(&mut conn).await?;
         sqlx::query("DROP TABLE deposit_keypairs;").execute(&mut conn).await?;
         sqlx::query("DROP TABLE withdraw_keypairs;").execute(&mut conn).await?;
         sqlx::query("DROP TABLE withdraw_keypairs;").execute(&mut conn).await?;
@@ -197,7 +197,7 @@ impl CashierDb {
         token_id: &DrkTokenId,
         token_id: &DrkTokenId,
         mint_address: String,
         mint_address: String,
     ) -> Result<()> {
     ) -> Result<()> {
-        trace!("Writing withdraw keys to database");
+        debug!("Writing withdraw keys to database");
         let public = self.get_value_serialized(d_key_public)?;
         let public = self.get_value_serialized(d_key_public)?;
         let secret = self.get_value_serialized(d_key_secret)?;
         let secret = self.get_value_serialized(d_key_secret)?;
         let network = self.get_value_serialized(network)?;
         let network = self.get_value_serialized(network)?;
@@ -235,7 +235,7 @@ impl CashierDb {
         token_id: &DrkTokenId,
         token_id: &DrkTokenId,
         mint_address: String,
         mint_address: String,
     ) -> Result<()> {
     ) -> Result<()> {
-        trace!("Writing deposit keys to database");
+        debug!("Writing deposit keys to database");
         let d_key_public = self.get_value_serialized(d_key_public)?;
         let d_key_public = self.get_value_serialized(d_key_public)?;
         let token_id = self.get_value_serialized(token_id)?;
         let token_id = self.get_value_serialized(token_id)?;
         let network = self.get_value_serialized(network)?;
         let network = self.get_value_serialized(network)?;
@@ -264,7 +264,7 @@ impl CashierDb {
     }
     }
 
 
     pub async fn get_withdraw_private_keys(&self) -> Result<Vec<SecretKey>> {
     pub async fn get_withdraw_private_keys(&self) -> Result<Vec<SecretKey>> {
-        trace!("Getting withdraw private keys");
+        debug!("Getting withdraw private keys");
         let confirm = self.get_value_serialized(&false)?;
         let confirm = self.get_value_serialized(&false)?;
 
 
         let mut conn = self.conn.acquire().await?;
         let mut conn = self.conn.acquire().await?;
@@ -289,7 +289,7 @@ impl CashierDb {
         &self,
         &self,
         pubkey: &PublicKey,
         pubkey: &PublicKey,
     ) -> Result<Option<WithdrawToken>> {
     ) -> Result<Option<WithdrawToken>> {
-        trace!("Get token address by pubkey");
+        debug!("Get token address by pubkey");
         let d_key_public = self.get_value_serialized(pubkey)?;
         let d_key_public = self.get_value_serialized(pubkey)?;
         let confirm = self.get_value_serialized(&false)?;
         let confirm = self.get_value_serialized(&false)?;
 
 
@@ -323,7 +323,7 @@ impl CashierDb {
         d_key_public: &PublicKey,
         d_key_public: &PublicKey,
         network: &NetworkName,
         network: &NetworkName,
     ) -> Result<Vec<TokenKey>> {
     ) -> Result<Vec<TokenKey>> {
-        trace!("Checking for existing dkey");
+        debug!("Checking for existing dkey");
         let d_key_public = self.get_value_serialized(d_key_public)?;
         let d_key_public = self.get_value_serialized(d_key_public)?;
         let network = self.get_value_serialized(network)?;
         let network = self.get_value_serialized(network)?;
         let confirm = self.get_value_serialized(&false)?;
         let confirm = self.get_value_serialized(&false)?;
@@ -357,7 +357,7 @@ impl CashierDb {
         token_key_public: &[u8],
         token_key_public: &[u8],
         network: &NetworkName,
         network: &NetworkName,
     ) -> Result<Option<Keypair>> {
     ) -> Result<Option<Keypair>> {
-        trace!("Checking for existing token address");
+        debug!("Checking for existing token address");
         let confirm = self.get_value_serialized(&false)?;
         let confirm = self.get_value_serialized(&false)?;
         let network = self.get_value_serialized(network)?;
         let network = self.get_value_serialized(network)?;
 
 
@@ -389,7 +389,7 @@ impl CashierDb {
         token_address: &[u8],
         token_address: &[u8],
         network: &NetworkName,
         network: &NetworkName,
     ) -> Result<()> {
     ) -> Result<()> {
-        trace!("Confirm withdraw keys");
+        debug!("Confirm withdraw keys");
         let network = self.get_value_serialized(network)?;
         let network = self.get_value_serialized(network)?;
         let confirm = self.get_value_serialized(&true)?;
         let confirm = self.get_value_serialized(&true)?;
 
 
@@ -414,7 +414,7 @@ impl CashierDb {
         d_key_public: &PublicKey,
         d_key_public: &PublicKey,
         network: &NetworkName,
         network: &NetworkName,
     ) -> Result<()> {
     ) -> Result<()> {
-        trace!("Confirm deposit keys");
+        debug!("Confirm deposit keys");
         let network = self.get_value_serialized(network)?;
         let network = self.get_value_serialized(network)?;
         let confirm = self.get_value_serialized(&true)?;
         let confirm = self.get_value_serialized(&true)?;
         let d_key_public = self.get_value_serialized(d_key_public)?;
         let d_key_public = self.get_value_serialized(d_key_public)?;
@@ -439,7 +439,7 @@ impl CashierDb {
         &self,
         &self,
         network: &NetworkName,
         network: &NetworkName,
     ) -> Result<Vec<DepositToken>> {
     ) -> Result<Vec<DepositToken>> {
-        trace!("Checking for existing dkey");
+        debug!("Checking for existing dkey");
         let network = self.get_value_serialized(network)?;
         let network = self.get_value_serialized(network)?;
         let confirm = self.get_value_serialized(&false)?;
         let confirm = self.get_value_serialized(&false)?;