Remove fallback mechanism
MODIFY
WalletWasabi.Fluent/Config.cs
WalletWasabi.Fluent/Config.cs
@@ -21,7 +21,7 @@ public class Config : ConfigBase
public static readonly Money DefaultDustThreshold = Money.Coins(Constants.DefaultDustThreshold);
private Uri? _backendUri = null;
- private Uri? _fallbackBackendUri;
+ private Uri? _clearnetBackendUri;
/// <summary>
/// Constructor for config population using Newtonsoft.JSON.
@@ -50,11 +50,11 @@ public class Config : ConfigBase
[DefaultValue("https://wasabiwallet.io/")]
[JsonProperty(PropertyName = "MainNetFallbackBackendUri", DefaultValueHandling = DefaultValueHandling.Populate)]
- public string MainNetFallbackBackendUri { get; private set; } = "https://wasabiwallet.io/";
+ public string MainNetClearnetBackendUri { get; private set; } = "https://wasabiwallet.io/";
[DefaultValue("https://wasabiwallet.co/")]
[JsonProperty(PropertyName = "TestNetFallbackBackendUri", DefaultValueHandling = DefaultValueHandling.Populate)]
- public string TestNetFallbackBackendUri { get; private set; } = "https://wasabiwallet.co/";
+ public string TestNetClearnetBackendUri { get; private set; } = "https://wasabiwallet.co/";
[DefaultValue("http://localhost:37127/")]
[JsonProperty(PropertyName = "RegTestBackendUriV3", DefaultValueHandling = DefaultValueHandling.Populate)]
@@ -127,6 +127,7 @@ public class Config : ConfigBase
public ServiceConfiguration ServiceConfiguration { get; private set; }
+ /// <remarks>Currently unused.</remarks>
public Uri GetCurrentBackendUri()
{
if (_backendUri is { })
@@ -154,31 +155,31 @@ public class Config : ConfigBase
return _backendUri;
}
- public Uri GetFallbackBackendUri()
+ public Uri GetClearnetBackendUri()
{
- if (_fallbackBackendUri is { })
+ if (_clearnetBackendUri is { })
{
- return _fallbackBackendUri;
+ return _clearnetBackendUri;
}
if (Network == Network.Main)
{
- _fallbackBackendUri = new Uri(MainNetFallbackBackendUri);
+ _clearnetBackendUri = new Uri(MainNetClearnetBackendUri);
}
else if (Network == Network.TestNet)
{
- _fallbackBackendUri = new Uri(TestNetFallbackBackendUri);
+ _clearnetBackendUri = new Uri(TestNetClearnetBackendUri);
}
else if (Network == Network.RegTest)
{
- _fallbackBackendUri = new Uri(RegTestBackendUriV3);
+ _clearnetBackendUri = new Uri(RegTestBackendUriV3);
}
else
{
throw new NotSupportedNetworkException(Network);
}
- return _fallbackBackendUri;
+ return _clearnetBackendUri;
}
public EndPoint GetBitcoinP2pEndPoint()

MODIFY
WalletWasabi.Fluent/Global.cs
WalletWasabi.Fluent/Global.cs
@@ -90,8 +90,7 @@ public class Global
HttpClientFactory = new HttpClientFactory(
Config.UseTor ? TorSettings.SocksEndpoint : null,
- backendUriGetter: () =>
- Config.GetFallbackBackendUri());
+ backendUriGetter: () => Config.GetClearnetBackendUri());
Synchronizer = new WasabiSynchronizer(BitcoinStore, HttpClientFactory);
LegalChecker = new(DataDir);
@@ -234,7 +233,7 @@ public class Global
Logger.LogInfo($"{nameof(TorProcessManager)} is initialized.");
}
- HostedServices.Register<TorMonitor>(() => new TorMonitor(period: TimeSpan.FromMinutes(1), Config.GetFallbackBackendUri(), TorManager, HttpClientFactory), nameof(TorMonitor));
+ HostedServices.Register<TorMonitor>(() => new TorMonitor(period: TimeSpan.FromMinutes(1), torProcessManager: TorManager, httpClientFactory: HttpClientFactory), nameof(TorMonitor));
HostedServices.Register<TorStatusChecker>(() => TorStatusChecker, "Tor Network Checker");
}
}

MODIFY
WalletWasabi/Tor/TorMonitor.cs
WalletWasabi/Tor/TorMonitor.cs
using System.Collections.Generic;
-using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Bases;
@@ -43,22 +42,14 @@ public class TorMonitor : PeriodicRunner
/// <remarks>Guards <see cref="ForceTorRestartCts"/>.</remarks>
private readonly object _lock = new();
- public TorMonitor(TimeSpan period, Uri fallbackBackendUri, TorProcessManager torProcessManager, HttpClientFactory httpClientFactory) : base(period)
+ public TorMonitor(TimeSpan period, TorProcessManager torProcessManager, HttpClientFactory httpClientFactory) : base(period)
{
TorProcessManager = torProcessManager;
TorHttpPool = httpClientFactory.TorHttpPool!;
HttpClient = httpClientFactory.NewTorHttpClient(Mode.DefaultCircuit);
- TestApiUri = new Uri(fallbackBackendUri, "/api/Software/versions");
}
private CancellationTokenSource LoopCts { get; } = new();
- public static bool RequestFallbackAddressUsage { get; private set; }
-
- /// <summary>Simple Backend API endpoint that allows us to test whether Backend is actually running or not.</summary>
- private Uri TestApiUri { get; }
-
- /// <summary>When the fallback address was started to be used, <c>null</c> if fallback address is not in use.</summary>
- private DateTime? FallbackStarted { get; set; }
private TorHttpClient HttpClient { get; }
private TorProcessManager TorProcessManager { get; }
@@ -242,7 +233,7 @@ public class TorMonitor : PeriodicRunner
protected override async Task ActionAsync(CancellationToken token)
{
// If Tor misbehaves and we have not requested the fallback mechanism yet.
- if (!RequestFallbackAddressUsage && TorHttpPool.TorDoesntWorkSince is not null)
+ if (TorHttpPool.TorDoesntWorkSince is not null)
{
TimeSpan torMisbehavedFor = DateTimeOffset.UtcNow - TorHttpPool.TorDoesntWorkSince ?? TimeSpan.Zero;
@@ -257,7 +248,6 @@ public class TorMonitor : PeriodicRunner
if (latestTorException is TorConnectCommandFailedException e)
{
- // Tor must be running for us to consider switching to the fallback address.
bool isRunning = await HttpClient.IsTorRunningAsync(token).ConfigureAwait(false);
if (!isRunning)
@@ -285,27 +275,6 @@ public class TorMonitor : PeriodicRunner
}
TryTorRestart = true;
-
- // Check if the fallback address (clearnet through exit nodes) works. It must work.
- try
- {
- Logger.LogInfo("Tor cannot access remote host. Test fallback URI.");
- using HttpRequestMessage request = new(HttpMethod.Get, TestApiUri);
-
- // Any HTTP response is fine (e.g. the response message might have the status code 403, 404, etc.) as we test only that
- // the transport layer works.
- using HttpResponseMessage response = await HttpClient.SendAsync(request, token).ConfigureAwait(false);
- }
- catch (Exception ex)
- {
- // The fallback address does not work too. We do not want to switch.
- Logger.LogInfo($"Communication through the fallback URL with the backend does not work either. Probably it is down, keep trying... Exception: '{ex}'");
- return;
- }
-
- Logger.LogInfo("Switching to the fallback URL.");
- RequestFallbackAddressUsage = true;
- FallbackStarted = DateTime.UtcNow;
}
else if (torMisbehavedFor - CheckIfRunningAfterTorMisbehavedFor < Period)
{
@@ -313,15 +282,6 @@ public class TorMonitor : PeriodicRunner
}
}
}
-
- // Every two hours try to revert to the original Backend onion Tor address. It might be already fixed.
- // If not, we will get back to the fallback URI again later on.
- if (FallbackStarted is not null && DateTime.UtcNow - FallbackStarted > TimeSpan.FromHours(2))
- {
- Logger.LogInfo("Attempt to revert to the more private onion address of the Backend server.");
- FallbackStarted = null;
- RequestFallbackAddressUsage = false;
- }
}
/// <inheritdoc/>

Remove fallback mechanism