607: Tidy up tracing statements r=da-kami a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
This commit is contained in:
bors[bot] 2021-07-07 06:03:49 +00:00 committed by GitHub
commit 15751f8a0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 94 additions and 93 deletions

View file

@ -14,7 +14,6 @@ use std::ffi::OsStr;
use std::fs; use std::fs;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::str::FromStr; use std::str::FromStr;
use tracing::info;
use url::Url; use url::Url;
pub trait GetDefaults { pub trait GetDefaults {
@ -178,9 +177,9 @@ pub struct ConfigNotInitialized {}
pub fn read_config(config_path: PathBuf) -> Result<Result<Config, ConfigNotInitialized>> { pub fn read_config(config_path: PathBuf) -> Result<Result<Config, ConfigNotInitialized>> {
if config_path.exists() { if config_path.exists() {
info!( tracing::info!(
path = %config_path.display(), path = %config_path.display(),
"Using config file at", "Reading config file",
); );
} else { } else {
return Ok(Err(ConfigNotInitialized {})); return Ok(Err(ConfigNotInitialized {}));
@ -198,7 +197,7 @@ pub fn initial_setup(config_path: PathBuf, config: Config) -> Result<()> {
ensure_directory_exists(config_path.as_path())?; ensure_directory_exists(config_path.as_path())?;
fs::write(&config_path, toml)?; fs::write(&config_path, toml)?;
info!( tracing::info!(
path = %config_path.as_path().display(), path = %config_path.as_path().display(),
"Initial setup complete, config file created", "Initial setup complete, config file created",
); );

View file

@ -174,13 +174,13 @@ where
let _ = self.handle_execution_setup_done(peer_id, swap_id, state3).await; let _ = self.handle_execution_setup_done(peer_id, swap_id, state3).await;
} }
SwarmEvent::Behaviour(OutEvent::SwapDeclined { peer, error }) => { SwarmEvent::Behaviour(OutEvent::SwapDeclined { peer, error }) => {
tracing::warn!(%peer, "Ignoring spot price request because: {}", error); tracing::warn!(%peer, "Ignoring spot price request: {}", error);
} }
SwarmEvent::Behaviour(OutEvent::QuoteRequested { channel, peer }) => { SwarmEvent::Behaviour(OutEvent::QuoteRequested { channel, peer }) => {
let quote = match self.make_quote(self.min_buy, self.max_buy).await { let quote = match self.make_quote(self.min_buy, self.max_buy).await {
Ok(quote) => quote, Ok(quote) => quote,
Err(error) => { Err(error) => {
tracing::warn!(%peer, "Failed to make quote. Error {:#}", error); tracing::warn!(%peer, "Failed to make quote: {:#}", error);
continue; continue;
} }
}; };
@ -253,7 +253,7 @@ where
SwarmEvent::Behaviour(OutEvent::Failure {peer, error}) => { SwarmEvent::Behaviour(OutEvent::Failure {peer, error}) => {
tracing::error!( tracing::error!(
%peer, %peer,
"Communication error. Error {:#}", error); "Communication error: {:#}", error);
} }
SwarmEvent::ConnectionEstablished { peer_id: peer, endpoint, .. } => { SwarmEvent::ConnectionEstablished { peer_id: peer, endpoint, .. } => {
tracing::debug!(%peer, address = %endpoint.get_remote_address(), "New connection established"); tracing::debug!(%peer, address = %endpoint.get_remote_address(), "New connection established");
@ -268,16 +268,16 @@ where
} }
} }
SwarmEvent::IncomingConnectionError { send_back_addr: address, error, .. } => { SwarmEvent::IncomingConnectionError { send_back_addr: address, error, .. } => {
tracing::warn!(%address, "Failed to set up connection with peer. Error {:#}", error); tracing::warn!(%address, "Failed to set up connection with peer: {:#}", error);
} }
SwarmEvent::ConnectionClosed { peer_id: peer, num_established, endpoint, cause: Some(error) } if num_established == 0 => { SwarmEvent::ConnectionClosed { peer_id: peer, num_established, endpoint, cause: Some(error) } if num_established == 0 => {
tracing::warn!(%peer, address = %endpoint.get_remote_address(), "Lost connection. Error {:#}", error); tracing::warn!(%peer, address = %endpoint.get_remote_address(), "Lost connection to peer: {:#}", error);
} }
SwarmEvent::ConnectionClosed { peer_id: peer, num_established, endpoint, cause: None } if num_established == 0 => { SwarmEvent::ConnectionClosed { peer_id: peer, num_established, endpoint, cause: None } if num_established == 0 => {
tracing::info!(%peer, address = %endpoint.get_remote_address(), "Successfully closed connection"); tracing::info!(%peer, address = %endpoint.get_remote_address(), "Successfully closed connection");
} }
SwarmEvent::NewListenAddr(address) => { SwarmEvent::NewListenAddr(address) => {
tracing::info!(%address, "New listen address detected"); tracing::info!(%address, "New listen address reported");
} }
_ => {} _ => {}
} }
@ -295,7 +295,7 @@ where
self.inflight_transfer_proofs.insert(id, responder); self.inflight_transfer_proofs.insert(id, responder);
}, },
Some(Err(error)) => { Some(Err(error)) => {
tracing::debug!("A swap stopped without sending a transfer proof. Error {:#}", error); tracing::debug!("A swap stopped without sending a transfer proof: {:#}", error);
} }
None => { None => {
unreachable!("stream of transfer proof receivers must never terminate") unreachable!("stream of transfer proof receivers must never terminate")
@ -354,11 +354,11 @@ where
match self.db.insert_peer_id(swap_id, bob_peer_id).await { match self.db.insert_peer_id(swap_id, bob_peer_id).await {
Ok(_) => { Ok(_) => {
if let Err(error) = self.swap_sender.send(swap).await { if let Err(error) = self.swap_sender.send(swap).await {
tracing::warn!(%swap_id, "Swap cannot be spawned: {}", error); tracing::warn!(%swap_id, "Failed to start swap: {}", error);
} }
} }
Err(error) => { Err(error) => {
tracing::warn!(%swap_id, "Unable to save peer-id, swap cannot be spawned: {}", error); tracing::warn!(%swap_id, "Unable to save peer-id in database: {}", error);
} }
} }
} }

View file

@ -36,7 +36,6 @@ use swap::protocol::alice::run;
use swap::seed::Seed; use swap::seed::Seed;
use swap::tor::AuthenticatedClient; use swap::tor::AuthenticatedClient;
use swap::{asb, bitcoin, kraken, monero, tor}; use swap::{asb, bitcoin, kraken, monero, tor};
use tracing::{debug, info, warn};
use tracing_subscriber::filter::LevelFilter; use tracing_subscriber::filter::LevelFilter;
const DEFAULT_WALLET_NAME: &str = "asb-wallet"; const DEFAULT_WALLET_NAME: &str = "asb-wallet";
@ -90,11 +89,6 @@ async fn main() -> Result<()> {
)); ));
} }
info!(
db_folder = %config.data.dir.display(),
"Database and Seed will be stored in",
);
let db_path = config.data.dir.join("database"); let db_path = config.data.dir.join("database");
let db = Database::open(config.data.dir.join(db_path).as_path()) let db = Database::open(config.data.dir.join(db_path).as_path())
@ -110,17 +104,17 @@ async fn main() -> Result<()> {
let monero_wallet = init_monero_wallet(&config, env_config).await?; let monero_wallet = init_monero_wallet(&config, env_config).await?;
let bitcoin_balance = bitcoin_wallet.balance().await?; let bitcoin_balance = bitcoin_wallet.balance().await?;
info!(%bitcoin_balance, "Initialized Bitcoin wallet"); tracing::info!(%bitcoin_balance, "Initialized Bitcoin wallet");
let monero_balance = monero_wallet.get_balance().await?; let monero_balance = monero_wallet.get_balance().await?;
if monero_balance == Amount::ZERO { if monero_balance == Amount::ZERO {
let monero_address = monero_wallet.get_main_address(); let monero_address = monero_wallet.get_main_address();
warn!( tracing::warn!(
%monero_address, %monero_address,
"The Monero balance is 0, make sure to deposit funds at", "The Monero balance is 0, make sure to deposit funds at",
) )
} else { } else {
info!(%monero_balance, "Initialized Monero wallet"); tracing::info!(%monero_balance, "Initialized Monero wallet");
} }
let kraken_price_updates = kraken::connect(config.maker.price_ticker_ws_url.clone())?; let kraken_price_updates = kraken::connect(config.maker.price_ticker_ws_url.clone())?;
@ -130,7 +124,7 @@ async fn main() -> Result<()> {
tor::Client::new(config.tor.socks5_port).with_control_port(config.tor.control_port); tor::Client::new(config.tor.socks5_port).with_control_port(config.tor.control_port);
let _ac = match tor_client.assert_tor_running().await { let _ac = match tor_client.assert_tor_running().await {
Ok(_) => { Ok(_) => {
tracing::info!("Tor found. Setting up hidden service"); tracing::info!("Setting up Tor hidden service");
let ac = let ac =
register_tor_services(config.network.clone().listen, tor_client, &seed) register_tor_services(config.network.clone().listen, tor_client, &seed)
.await?; .await?;
@ -196,10 +190,10 @@ async fn main() -> Result<()> {
let swap_id = swap.swap_id; let swap_id = swap.swap_id;
match run(swap, rate).await { match run(swap, rate).await {
Ok(state) => { Ok(state) => {
tracing::debug!(%swap_id, %state, "Swap finished with state") tracing::debug!(%swap_id, final_state=%state, "Swap completed")
} }
Err(error) => { Err(error) => {
tracing::error!(%swap_id, "Swap failed. Error {:#}", error) tracing::error!(%swap_id, "Swap failed: {:#}", error)
} }
} }
}); });
@ -314,7 +308,7 @@ async fn init_bitcoin_wallet(
seed: &Seed, seed: &Seed,
env_config: swap::env::Config, env_config: swap::env::Config,
) -> Result<bitcoin::Wallet> { ) -> Result<bitcoin::Wallet> {
debug!("Opening Bitcoin wallet"); tracing::debug!("Opening Bitcoin wallet");
let wallet_dir = config.data.dir.join("wallet"); let wallet_dir = config.data.dir.join("wallet");
let wallet = bitcoin::Wallet::new( let wallet = bitcoin::Wallet::new(
@ -336,7 +330,7 @@ async fn init_monero_wallet(
config: &Config, config: &Config,
env_config: swap::env::Config, env_config: swap::env::Config,
) -> Result<monero::Wallet> { ) -> Result<monero::Wallet> {
debug!("Opening Monero wallet"); tracing::debug!("Opening Monero wallet");
let wallet = monero::Wallet::open_or_create( let wallet = monero::Wallet::open_or_create(
config.monero.wallet_rpc_url.clone(), config.monero.wallet_rpc_url.clone(),
DEFAULT_WALLET_NAME.to_string(), DEFAULT_WALLET_NAME.to_string(),
@ -384,7 +378,7 @@ async fn register_tor_services(
hidden_services_details.iter().for_each(|(port, _)| { hidden_services_details.iter().for_each(|(port, _)| {
let onion_address = format!("/onion3/{}:{}", onion_address, port); let onion_address = format!("/onion3/{}:{}", onion_address, port);
tracing::info!(%onion_address); tracing::info!(%onion_address, "Successfully created hidden service");
}); });
Ok(ac) Ok(ac)

View file

@ -34,7 +34,6 @@ use swap::protocol::bob;
use swap::protocol::bob::Swap; use swap::protocol::bob::Swap;
use swap::seed::Seed; use swap::seed::Seed;
use swap::{bitcoin, cli, monero}; use swap::{bitcoin, cli, monero};
use tracing::{debug, error, info, warn};
use url::Url; use url::Url;
use uuid::Uuid; use uuid::Uuid;
@ -111,7 +110,7 @@ async fn main() -> Result<()> {
) )
.await?; .await?;
info!(%amount, %fees, %swap_id, "Swapping"); tracing::info!(%amount, %fees, %swap_id, "Starting new swap");
db.insert_peer_id(swap_id, seller_peer_id).await?; db.insert_peer_id(swap_id, seller_peer_id).await?;
db.insert_monero_address(swap_id, monero_receive_address) db.insert_monero_address(swap_id, monero_receive_address)
@ -185,7 +184,7 @@ async fn main() -> Result<()> {
let mut swarm = let mut swarm =
swarm::cli(seed.derive_libp2p_identity(), tor_socks5_port, behaviour).await?; swarm::cli(seed.derive_libp2p_identity(), tor_socks5_port, behaviour).await?;
let our_peer_id = swarm.local_peer_id(); let our_peer_id = swarm.local_peer_id();
tracing::debug!(peer_id = %our_peer_id, "Initializing network module"); tracing::debug!(peer_id = %our_peer_id, "Network layer initialized");
for seller_address in seller_addresses { for seller_address in seller_addresses {
swarm swarm
@ -242,10 +241,10 @@ async fn main() -> Result<()> {
match cancel { match cancel {
Ok((txid, _)) => { Ok((txid, _)) => {
debug!("Cancel transaction successfully published with id {}", txid) tracing::debug!("Cancel transaction successfully published with id {}", txid)
} }
Err(cli::cancel::Error::CancelTimelockNotExpiredYet) => error!( Err(cli::cancel::Error::CancelTimelockNotExpiredYet) => tracing::error!(
"The Cancel Transaction cannot be published yet, because the timelock has not expired. Please try again later" "The cancel transaction cannot be published yet, because the timelock has not expired. Please try again later"
), ),
} }
} }
@ -395,9 +394,9 @@ where
TS: Future<Output = Result<()>>, TS: Future<Output = Result<()>>,
FS: Fn() -> TS, FS: Fn() -> TS,
{ {
debug!("Requesting quote"); tracing::debug!("Requesting quote");
let bid_quote = bid_quote.await?; let bid_quote = bid_quote.await?;
info!( tracing::info!(
price = %bid_quote.price, price = %bid_quote.price,
minimum_amount = %bid_quote.min_quantity, minimum_amount = %bid_quote.min_quantity,
maximum_amount = %bid_quote.max_quantity, maximum_amount = %bid_quote.max_quantity,
@ -415,15 +414,15 @@ where
eprintln!("{}", qr_code(&deposit_address)?); eprintln!("{}", qr_code(&deposit_address)?);
} }
info!( loop {
tracing::info!(
%deposit_address, %deposit_address,
%max_giveable, %max_giveable,
%minimum_amount, %minimum_amount,
%maximum_amount, %maximum_amount,
"Please deposit BTC you want to swap to", "Waiting for Bitcoin deposit",
); );
loop {
sync().await?; sync().await?;
let new_max_givable = max_giveable_fn().await?; let new_max_givable = max_giveable_fn().await?;
@ -435,17 +434,13 @@ where
tracing::info!( tracing::info!(
%new_balance, %new_balance,
%max_giveable, %max_giveable,
"Received BTC", "Received Bitcoin",
); );
if max_giveable >= bid_quote.min_quantity { if max_giveable >= bid_quote.min_quantity {
break; break;
} else { } else {
tracing::info!( tracing::info!("Deposited amount is less than `min_quantity`",);
%minimum_amount,
%deposit_address,
"Please deposit more, not enough BTC to trigger swap with",
);
} }
} }

View file

@ -11,6 +11,7 @@ use miniscript::{Descriptor, DescriptorTrait};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::cmp::Ordering; use std::cmp::Ordering;
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt;
use std::ops::Add; use std::ops::Add;
/// Represent a timelock, expressed in relative block height as defined in /// Represent a timelock, expressed in relative block height as defined in
@ -47,6 +48,12 @@ impl PartialEq<CancelTimelock> for u32 {
} }
} }
impl fmt::Display for CancelTimelock {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} blocks", self.0)
}
}
/// Represent a timelock, expressed in relative block height as defined in /// Represent a timelock, expressed in relative block height as defined in
/// [BIP68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki). /// [BIP68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki).
/// E.g. The timelock expires 10 blocks after the reference transaction is /// E.g. The timelock expires 10 blocks after the reference transaction is

View file

@ -151,14 +151,14 @@ impl TxLock {
witness: Vec::new(), witness: Vec::new(),
}; };
let spending_fee = spending_fee.as_sat(); let fee = spending_fee.as_sat();
tracing::debug!(%spending_fee, "Redeem tx fee");
let tx_out = TxOut { let tx_out = TxOut {
value: self.inner.clone().extract_tx().output[self.lock_output_vout()].value value: self.inner.clone().extract_tx().output[self.lock_output_vout()].value - fee,
- spending_fee,
script_pubkey: spend_address.script_pubkey(), script_pubkey: spend_address.script_pubkey(),
}; };
tracing::debug!(%fee, "Constructed Bitcoin spending transaction");
Transaction { Transaction {
version: 2, version: 2,
lock_time: 0, lock_time: 0,

View file

@ -144,13 +144,18 @@ impl Wallet {
let new_status = match client.lock().await.status_of_script(&tx) { let new_status = match client.lock().await.status_of_script(&tx) {
Ok(new_status) => new_status, Ok(new_status) => new_status,
Err(error) => { Err(error) => {
tracing::warn!(%txid, "Failed to get status of script. Error {:#}", error); tracing::warn!(%txid, "Failed to get status of script: {:#}", error);
return; return;
} }
}; };
if Some(new_status) != last_status { match (last_status, new_status) {
tracing::debug!(%txid, status = %new_status, "Transaction"); (None, new_status) => {
tracing::debug!(%txid, status = %new_status, "Found relevant Bitcoin transaction");
},
(Some(old_status), new_status) => {
tracing::debug!(%txid, %new_status, %old_status, "Bitcoin transaction status changed");
}
} }
last_status = Some(new_status); last_status = Some(new_status);
@ -409,9 +414,7 @@ where
) -> Result<bitcoin::Amount> { ) -> Result<bitcoin::Amount> {
let client = self.client.lock().await; let client = self.client.lock().await;
let fee_rate = client.estimate_feerate(self.target_block)?; let fee_rate = client.estimate_feerate(self.target_block)?;
let min_relay_fee = client.min_relay_fee()?; let min_relay_fee = client.min_relay_fee()?;
tracing::debug!("Min relay fee: {}", min_relay_fee);
estimate_fee(weight, transfer_amount, fee_rate, min_relay_fee) estimate_fee(weight, transfer_amount, fee_rate, min_relay_fee)
} }
@ -443,20 +446,21 @@ fn estimate_fee(
let weight = Decimal::from(weight); let weight = Decimal::from(weight);
let weight_factor = dec!(4.0); let weight_factor = dec!(4.0);
let fee_rate = Decimal::from_f32(fee_rate_svb).context("Could not parse fee_rate.")?; let fee_rate = Decimal::from_f32(fee_rate_svb).context("Failed to parse fee rate")?;
let sats_per_vbyte = weight / weight_factor * fee_rate; let sats_per_vbyte = weight / weight_factor * fee_rate;
tracing::debug!( tracing::debug!(
"Estimated fee for weight: {} for fee_rate: {:?} is in total: {}", %weight,
weight, %fee_rate,
fee_rate, %sats_per_vbyte,
sats_per_vbyte "Estimated fee for transaction",
); );
let transfer_amount = Decimal::from(transfer_amount.as_sat()); let transfer_amount = Decimal::from(transfer_amount.as_sat());
let max_allowed_fee = transfer_amount * MAX_RELATIVE_TX_FEE; let max_allowed_fee = transfer_amount * MAX_RELATIVE_TX_FEE;
let min_relay_fee = Decimal::from(min_relay_fee.as_sat()); let min_relay_fee = Decimal::from(min_relay_fee.as_sat());
let recommended_fee = if sats_per_vbyte < min_relay_fee { let recommended_fee = if sats_per_vbyte < min_relay_fee {
tracing::warn!( tracing::warn!(
"Estimated fee of {} is smaller than the min relay fee, defaulting to min relay fee {}", "Estimated fee of {} is smaller than the min relay fee, defaulting to min relay fee {}",
@ -482,6 +486,7 @@ fn estimate_fee(
let amount = recommended_fee let amount = recommended_fee
.map(bitcoin::Amount::from_sat) .map(bitcoin::Amount::from_sat)
.context("Could not estimate tranasction fee.")?; .context("Could not estimate tranasction fee.")?;
Ok(amount) Ok(amount)
} }

View file

@ -157,12 +157,12 @@ impl Wallet {
Err(error) => { Err(error) => {
tracing::warn!( tracing::warn!(
address = %self.main_address, address = %self.main_address,
"Transferring Monero back to default wallet failed. Error {:#}", error "Failed to transfer Monero to default wallet: {:#}", error
); );
} }
}, },
Err(error) => { Err(error) => {
tracing::warn!("Refreshing the generated wallet failed. Error {:#}", error); tracing::warn!("Failed to refresh generated wallet: {:#}", error);
} }
} }
@ -192,7 +192,7 @@ impl Wallet {
%amount, %amount,
to = %public_spend_key, to = %public_spend_key,
tx_id = %res.tx_hash, tx_id = %res.tx_hash,
"Sent transfer" "Successfully initiated Monero transfer"
); );
Ok(TransferProof::new( Ok(TransferProof::new(
@ -202,7 +202,7 @@ impl Wallet {
)) ))
} }
pub async fn watch_for_transfer(&self, request: WatchRequest) -> Result<()> { pub async fn watch_for_transfer(&self, request: WatchRequest) -> Result<(), InsufficientFunds> {
let WatchRequest { let WatchRequest {
conf_target, conf_target,
public_view_key, public_view_key,
@ -314,7 +314,7 @@ where
Err(error) => { Err(error) => {
tracing::debug!( tracing::debug!(
%txid, %txid,
"Failed to retrieve tx from blockchain. Error {:#}", error "Failed to retrieve tx from blockchain: {:#}", error
); );
continue; // treating every error as transient and retrying continue; // treating every error as transient and retrying
// is obviously wrong but the jsonrpc client is // is obviously wrong but the jsonrpc client is

View file

@ -128,7 +128,7 @@ impl WalletRpc {
tracing::debug!( tracing::debug!(
%port, %port,
"Starting monero-wallet-rpc on" "Starting monero-wallet-rpc"
); );
let network_flag = match network { let network_flag = match network {

View file

@ -42,7 +42,7 @@ impl Transport for TorDialOnlyTransport {
} }
let dial_future = async move { let dial_future = async move {
tracing::trace!("Connecting through Tor proxy to address: {}", addr); tracing::trace!(address = %addr, "Establishing connection through Tor proxy");
let stream = let stream =
Socks5Stream::connect((Ipv4Addr::LOCALHOST, self.socks_port), address.to_string()) Socks5Stream::connect((Ipv4Addr::LOCALHOST, self.socks_port), address.to_string())

View file

@ -8,7 +8,6 @@ use crate::{bitcoin, database, monero};
use anyhow::{bail, Context, Result}; use anyhow::{bail, Context, Result};
use tokio::select; use tokio::select;
use tokio::time::timeout; use tokio::time::timeout;
use tracing::{error, info, warn};
use uuid::Uuid; use uuid::Uuid;
pub async fn run<LR>(swap: Swap, rate_service: LR) -> Result<AliceState> pub async fn run<LR>(swap: Swap, rate_service: LR) -> Result<AliceState>
@ -66,7 +65,7 @@ where
.latest_rate() .latest_rate()
.map_or("NaN".to_string(), |rate| format!("{}", rate)); .map_or("NaN".to_string(), |rate| format!("{}", rate));
info!(%state, %rate, "Advancing state"); tracing::info!(%state, %rate, "Advancing state");
Ok(match state { Ok(match state {
AliceState::Started { state3 } => { AliceState::Started { state3 } => {
@ -78,7 +77,7 @@ where
.await .await
{ {
Err(_) => { Err(_) => {
info!( tracing::info!(
minutes = %env_config.bitcoin_lock_mempool_timeout.as_secs_f64() / 60.0, minutes = %env_config.bitcoin_lock_mempool_timeout.as_secs_f64() / 60.0,
"TxLock lock was not seen in mempool in time", "TxLock lock was not seen in mempool in time",
); );
@ -99,7 +98,7 @@ where
.await .await
{ {
Err(_) => { Err(_) => {
info!( tracing::info!(
confirmations_needed = %env_config.bitcoin_finality_confirmations, confirmations_needed = %env_config.bitcoin_finality_confirmations,
minutes = %env_config.bitcoin_lock_confirmed_timeout.as_secs_f64() / 60.0, minutes = %env_config.bitcoin_lock_confirmed_timeout.as_secs_f64() / 60.0,
"TxLock lock did not get enough confirmations in time", "TxLock lock did not get enough confirmations in time",
@ -204,7 +203,7 @@ where
} }
} }
enc_sig = event_loop_handle.recv_encrypted_signature() => { enc_sig = event_loop_handle.recv_encrypted_signature() => {
info!("Received encrypted signature"); tracing::info!("Received encrypted signature");
AliceState::EncSigLearned { AliceState::EncSigLearned {
monero_wallet_restore_blockheight, monero_wallet_restore_blockheight,
@ -232,10 +231,7 @@ where
} }
}, },
Err(error) => { Err(error) => {
error!( tracing::error!("Failed to publish redeem transaction: {:#}", error);
"Publishing the redeem transaction failed. Error {:#}",
error
);
tx_lock_status tx_lock_status
.wait_until_confirmed_with(state3.cancel_timelock) .wait_until_confirmed_with(state3.cancel_timelock)
.await?; .await?;
@ -248,8 +244,12 @@ where
} }
}, },
Err(error) => { Err(error) => {
error!( tracing::error!("Failed to construct redeem transaction: {:#}", error);
"Constructing the redeem transaction failed. Attempting to wait for cancellation now. Error {:#}", error); tracing::info!(
timelock = %state3.cancel_timelock,
"Waiting for cancellation timelock to expire",
);
tx_lock_status tx_lock_status
.wait_until_confirmed_with(state3.cancel_timelock) .wait_until_confirmed_with(state3.cancel_timelock)
.await?; .await?;
@ -361,10 +361,7 @@ where
match punish { match punish {
Ok(_) => AliceState::BtcPunished, Ok(_) => AliceState::BtcPunished,
Err(error) => { Err(error) => {
warn!( tracing::warn!("Failed to publish punish transaction: {:#}", error);
"Falling back to refund because punish transaction failed. Error {:#}",
error
);
// Upon punish failure we assume that the refund tx was included but we // Upon punish failure we assume that the refund tx was included but we
// missed seeing it. In case we fail to fetch the refund tx we fail // missed seeing it. In case we fail to fetch the refund tx we fail
@ -373,6 +370,8 @@ where
// because a punish tx failure is not recoverable (besides re-trying) if the // because a punish tx failure is not recoverable (besides re-trying) if the
// refund tx was not included. // refund tx was not included.
tracing::info!("Falling back to refund");
let published_refund_tx = bitcoin_wallet let published_refund_tx = bitcoin_wallet
.get_raw_transaction(state3.tx_refund().txid()) .get_raw_transaction(state3.tx_refund().txid())
.await?; .await?;

View file

@ -149,8 +149,10 @@ async fn next_state(
received_xmr = monero_wallet.watch_for_transfer(watch_request) => { received_xmr = monero_wallet.watch_for_transfer(watch_request) => {
match received_xmr { match received_xmr {
Ok(()) => BobState::XmrLocked(state.xmr_locked(monero_wallet_restore_blockheight)), Ok(()) => BobState::XmrLocked(state.xmr_locked(monero_wallet_restore_blockheight)),
Err(e) => { Err(monero::InsufficientFunds { expected, actual }) => {
tracing::warn!("Waiting for refund because insufficient Monero have been locked! {:#}", e); tracing::warn!(%expected, %actual, "Insufficient Monero have been locked!");
tracing::info!(timelock = %state.cancel_timelock, "Waiting for cancel timelock to expire");
tx_lock_status.wait_until_confirmed_with(state.cancel_timelock).await?; tx_lock_status.wait_until_confirmed_with(state.cancel_timelock).await?;
BobState::CancelTimelockExpired(state.cancel()) BobState::CancelTimelockExpired(state.cancel())
@ -229,7 +231,7 @@ async fn next_state(
let tx_hashes = monero_wallet.sweep_all(monero_receive_address).await?; let tx_hashes = monero_wallet.sweep_all(monero_receive_address).await?;
for tx_hash in tx_hashes { for tx_hash in tx_hashes {
tracing::info!(%monero_receive_address, txid=%tx_hash.0, "Sent XMR to"); tracing::info!(%monero_receive_address, txid=%tx_hash.0, "Successfully transferred XMR to wallet");
} }
BobState::XmrRedeemed { BobState::XmrRedeemed {

View file

@ -64,7 +64,7 @@ impl Seed {
return Self::from_file(&file_path); return Self::from_file(&file_path);
} }
tracing::debug!("No seed file found, creating at: {}", file_path.display()); tracing::debug!("No seed file found, creating at {}", file_path.display());
let random_seed = Seed::random()?; let random_seed = Seed::random()?;
random_seed.write_to(file_path.to_path_buf())?; random_seed.write_to(file_path.to_path_buf())?;