Use connection confirmation timeout
MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/AliceClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/AliceClientTests.cs
@@ -56,7 +56,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
var aliceClient = new AliceClient(round.Id, arenaClient, coin1.Coin, round.FeeRate, bitcoinSecret);
await aliceClient.RegisterInputAsync(CancellationToken.None);
- Task confirmationTask = aliceClient.ConfirmConnectionAsync(CancellationToken.None);
+ Task confirmationTask = aliceClient.ConfirmConnectionAsync(TimeSpan.FromSeconds(1),CancellationToken.None);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromMinutes(1));
await confirmationTask;

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/BobClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/BobClientTests.cs
@@ -57,7 +57,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
var aliceClient = new AliceClient(round.Id, aliceArenaClient, coin1.Coin, round.FeeRate, bitcoinSecret);
await aliceClient.RegisterInputAsync(CancellationToken.None);
- Task confirmationTask = aliceClient.ConfirmConnectionAsync(CancellationToken.None);
+ Task confirmationTask = aliceClient.ConfirmConnectionAsync(TimeSpan.FromSeconds(1), CancellationToken.None);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromMinutes(1));
await confirmationTask;

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Models/MultipartyTransactionTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Models/MultipartyTransactionTests.cs
@@ -13,7 +13,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Models
public class MultipartyTransactionTests
{
private static MoneyRange DefaultAllowedAmounts = new(Money.Zero, Money.Coins(1));
- private static MultipartyTransactionParameters DefaultParameters = new(FeeRate.Zero, DefaultAllowedAmounts, DefaultAllowedAmounts, Network.Main);
+ private static MultipartyTransactionParameters DefaultParameters = new(FeeRate.Zero, DefaultAllowedAmounts, DefaultAllowedAmounts, Network.Main, TimeSpan.FromSeconds(10));
private static void ThrowsProtocolException(WabiSabiProtocolErrorCode expectedError, Action action) =>
Assert.Equal(expectedError, Assert.Throws<WabiSabiProtocolException>(action).ErrorCode);

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
@@ -24,7 +24,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
VsizeCredentialIssuerParameters = VsizeCredentialIssuer.CredentialIssuerSecretKey.ComputeCredentialIssuerParameters();
var allowedAmounts = new MoneyRange(roundParameters.MinRegistrableAmount, RoundParameters.MaxRegistrableAmount);
- var txParams = new MultipartyTransactionParameters(roundParameters.FeeRate, allowedAmounts, allowedAmounts, roundParameters.Network);
+ var txParams = new MultipartyTransactionParameters(roundParameters.FeeRate, allowedAmounts, allowedAmounts, roundParameters.Network, roundParameters.ConnectionConfirmationTimeout);
CoinjoinState = new ConstructionState(txParams);
Id = CalculateHash();

MODIFY
WalletWasabi/WabiSabi/Client/AliceClient.cs
WalletWasabi/WabiSabi/Client/AliceClient.cs
@@ -46,11 +46,11 @@ namespace WalletWasabi.WabiSabi.Client
Logger.LogInfo($"Round ({RoundId}), Alice ({AliceId}): Registered an input.");
}
- public async Task ConfirmConnectionAsync(CancellationToken cancellationToken)
+ public async Task ConfirmConnectionAsync(TimeSpan connectionConfirmationTimeout, CancellationToken cancellationToken)
{
while (!await TryConfirmConnectionAsync(cancellationToken).ConfigureAwait(false))
{
- await Task.Delay(1_000, cancellationToken).ConfigureAwait(false);
+ await Task.Delay(connectionConfirmationTimeout / 2, cancellationToken).ConfigureAwait(false);
}
}

MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
@@ -69,7 +69,7 @@ namespace WalletWasabi.WabiSabi.Client
aliceClients = await RegisterCoinsAsync(aliceClients, cancellationToken).ConfigureAwait(false);
// Confirm coins.
- aliceClients = await ConfirmConnectionsAsync(aliceClients, cancellationToken).ConfigureAwait(false);
+ aliceClients = await ConfirmConnectionsAsync(aliceClients, constructionState.ConnectionConfirmationTimeout, cancellationToken).ConfigureAwait(false);
// Output registration.
roundState = await RoundStatusUpdater.CreateRoundAwaiter(roundState.Id, rs => rs.Phase == Phase.OutputRegistration, cancellationToken).ConfigureAwait(false);
@@ -133,13 +133,13 @@ namespace WalletWasabi.WabiSabi.Client
return completedRequests.Where(x => x is not null).Cast<AliceClient>().ToList();
}
- private async Task<List<AliceClient>> ConfirmConnectionsAsync(IEnumerable<AliceClient> aliceClients, CancellationToken cancellationToken)
+ private async Task<List<AliceClient>> ConfirmConnectionsAsync(IEnumerable<AliceClient> aliceClients, TimeSpan connectionConfirmationTimeout, CancellationToken cancellationToken)
{
async Task<AliceClient?> ConfirmConnectionTask(AliceClient aliceClient)
{
try
{
- await aliceClient.ConfirmConnectionAsync(cancellationToken).ConfigureAwait(false);
+ await aliceClient.ConfirmConnectionAsync(connectionConfirmationTimeout, cancellationToken).ConfigureAwait(false);
return aliceClient;
}
catch (Exception e)

MODIFY
WalletWasabi/WabiSabi/Models/MultipartyTransaction/ConstructionState.cs
WalletWasabi/WabiSabi/Models/MultipartyTransaction/ConstructionState.cs
@@ -13,6 +13,8 @@ namespace WalletWasabi.WabiSabi.Models.MultipartyTransaction
{
}
+ public TimeSpan ConnectionConfirmationTimeout => Parameters.ConnectionConfirmationTimeout;
+
// TODO ownership proofs and spend status also in scope
public ConstructionState AddInput(Coin coin)
{

MODIFY
WalletWasabi/WabiSabi/Models/MultipartyTransaction/MultipartyTransactionParameters.cs
WalletWasabi/WabiSabi/Models/MultipartyTransaction/MultipartyTransactionParameters.cs
using NBitcoin;
using NBitcoin.Policy;
+using System;
using System.Collections.Immutable;
namespace WalletWasabi.WabiSabi.Models.MultipartyTransaction
@@ -17,12 +18,14 @@ namespace WalletWasabi.WabiSabi.Models.MultipartyTransaction
FeeRate feeRate,
MoneyRange allowedInputAmounts,
MoneyRange allowedOutputAmounts,
- Network network)
+ Network network,
+ TimeSpan connectionConfirmationTimeout)
{
FeeRate = feeRate;
AllowedInputAmounts = allowedInputAmounts;
AllowedOutputAmounts = allowedOutputAmounts;
Network = network;
+ ConnectionConfirmationTimeout = connectionConfirmationTimeout;
}
// These parameters need to be committed to the transcript, but we want
@@ -38,6 +41,7 @@ namespace WalletWasabi.WabiSabi.Models.MultipartyTransaction
public MoneyRange AllowedInputAmounts { get; init; }
public MoneyRange AllowedOutputAmounts { get; init; }
public Network Network { get; }
+ public TimeSpan ConnectionConfirmationTimeout { get; }
// implied:
// segwit transaction

Use connection confirmation timeout