Add Logging in Signing and Broadcasting phase
MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
@@ -162,21 +162,43 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
{
var coinjoin = round.Coinjoin;
var isFullySigned = coinjoin.Inputs.All(x => x.HasWitScript());
+ bool timeout = round.TransactionSigningStart + round.TransactionSigningTimeout < DateTimeOffset.UtcNow;
+
+ try
+ {
if (isFullySigned)
{
- try
+ // Logging.
+ round.LogInfo("Trying to broadcast coinjoin.");
+ Coin[]? spentCoins = round.Alices.SelectMany(x => x.Coins).ToArray();
+ Money networkFee = coinjoin.GetFee(spentCoins);
+ Guid roundId = round.Id;
+ FeeRate feeRate = coinjoin.GetFeeRate(spentCoins);
+ round.LogInfo($"Network Fee: {networkFee.ToString(false, false)} BTC.");
+ round.LogInfo($"Network Fee Rate: {feeRate.FeePerK.ToDecimal(MoneyUnit.Satoshi) / 1000} sat/vByte.");
+ round.LogInfo($"Number of inputs: {coinjoin.Inputs.Count}.");
+ round.LogInfo($"Number of outputs: {coinjoin.Outputs.Count}.");
+ round.LogInfo($"Serialized Size: {coinjoin.GetSerializedSize() / 1024} KB.");
+ round.LogInfo($"VSize: {coinjoin.GetVirtualSize() / 1024} KB.");
+ foreach (var (value, count) in coinjoin.GetIndistinguishableOutputs(includeSingle: false))
{
+ round.LogInfo($"There are {count} occurrences of {value.ToString(true, false)} BTC output.");
+ }
+
+ // Broadcasting.
await Rpc.SendRawTransactionAsync(coinjoin).ConfigureAwait(false);
round.SetPhase(Phase.TransactionBroadcasting);
+
+ round.LogInfo($"Successfully broadcast the CoinJoin: {coinjoin.GetHash()}.");
}
- catch (Exception ex)
+ else if (timeout)
{
- Logger.LogWarning(ex);
- await FailTransactionSigningPhaseAsync(round).ConfigureAwait(false);
+ throw new TimeoutException($"Signing phase timed out after {round.TransactionSigningTimeout.TotalSeconds} seconds");
}
}
- else if (round.TransactionSigningStart + round.TransactionSigningTimeout < DateTimeOffset.UtcNow)
+ catch (Exception ex)
{
+ round.LogWarning($"Signing phase failed, reason: '{ex}'.");
await FailTransactionSigningPhaseAsync(round).ConfigureAwait(false);
}
}

ADD
WalletWasabi/WabiSabi/LoggerTools.cs
+using NBitcoin;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using WalletWasabi.Logging;
+using WalletWasabi.WabiSabi.Backend.Rounds;
+
+namespace WalletWasabi.WabiSabi
+{
+ public static class LoggerTools
+ {
+ public static void Log(this Round round, LogLevel logLevel, string logMessage, [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1)
+ {
+ Logger.Log(logLevel, $"Round ({round.Id}): {logMessage}", callerFilePath: callerFilePath, callerLineNumber: callerLineNumber);
+ }
+
+ public static void LogInfo(this Round round, string logMessage, [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1)
+ {
+ Log(round, LogLevel.Info, logMessage, callerFilePath: callerFilePath, callerLineNumber: callerLineNumber);
+ }
+
+ public static void LogWarning(this Round round, string logMessage, [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1)
+ {
+ Log(round, LogLevel.Warning, logMessage, callerFilePath: callerFilePath, callerLineNumber: callerLineNumber);
+ }
+ }
+}

Add Logging in Signing and Broadcasting phase