Add roundStateUpdater to ConfirmConnectionAsync
MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/AliceTimeoutTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/AliceTimeoutTests.cs
@@ -30,8 +30,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
// Register Alices.
var minAliceDeadline = DateTimeOffset.UtcNow + cfg.ConnectionConfirmationTimeout * 0.9;
- using RoundStateUpdater roundStateUpdater = new(TimeSpan.FromSeconds(2), new ArenaRequestHandlerAdapter(arena));
- var aliceClient = new AliceClient(round.Id, arenaClient, coin, round.FeeRate, key.GetBitcoinSecret(round.Network), roundStateUpdater);
+ var aliceClient = new AliceClient(round.Id, arenaClient, coin, round.FeeRate, key.GetBitcoinSecret(round.Network));
await aliceClient.RegisterInputAsync(CancellationToken.None);
var alice = Assert.Single(round.Alices);

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepOutputRegistrationTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepOutputRegistrationTests.cs
@@ -207,9 +207,8 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
var round = Assert.Single(arena.Rounds);
// Register Alices.
- using RoundStateUpdater roundStateUpdater = new(TimeSpan.FromSeconds(2), new ArenaRequestHandlerAdapter(arena));
- var aliceClient1 = new AliceClient(round.Id, arenaClient, coin1, round.FeeRate, key1.GetBitcoinSecret(round.Network), roundStateUpdater);
- var aliceClient2 = new AliceClient(round.Id, arenaClient, coin2, round.FeeRate, key2.GetBitcoinSecret(round.Network), roundStateUpdater);
+ var aliceClient1 = new AliceClient(round.Id, arenaClient, coin1, round.FeeRate, key1.GetBitcoinSecret(round.Network));
+ var aliceClient2 = new AliceClient(round.Id, arenaClient, coin2, round.FeeRate, key2.GetBitcoinSecret(round.Network));
await aliceClient1.RegisterInputAsync(CancellationToken.None).ConfigureAwait(false);
await aliceClient2.RegisterInputAsync(CancellationToken.None).ConfigureAwait(false);
@@ -218,16 +217,19 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
Assert.Equal(Phase.ConnectionConfirmation, round.Phase);
// Confirm connections.
+ using RoundStateUpdater roundStateUpdater = new(TimeSpan.FromSeconds(2), new ArenaRequestHandlerAdapter(arena));
await aliceClient1.ConfirmConnectionAsync(
TimeSpan.FromSeconds(1),
new long[] { coin1.EffectiveValue(round.FeeRate) },
new long[] { round.MaxVsizeAllocationPerAlice - coin1.ScriptPubKey.EstimateInputVsize() },
+ roundStateUpdater,
CancellationToken.None).ConfigureAwait(false);
await aliceClient2.ConfirmConnectionAsync(
TimeSpan.FromSeconds(1),
new long[] { coin2.EffectiveValue(round.FeeRate) },
new long[] { round.MaxVsizeAllocationPerAlice - coin2.ScriptPubKey.EstimateInputVsize() },
+ roundStateUpdater,
CancellationToken.None).ConfigureAwait(false);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepTransactionSigningTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepTransactionSigningTests.cs
@@ -236,11 +236,9 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
var round = Assert.Single(arena.Rounds);
var arenaClient = WabiSabiFactory.CreateArenaClient(arena);
- using RoundStateUpdater roundStateUpdater = new(TimeSpan.FromSeconds(2), new ArenaRequestHandlerAdapter(arena));
-
// Register Alices.
- var aliceClient1 = new AliceClient(round.Id, arenaClient, coin1, round.FeeRate, key1.GetBitcoinSecret(round.Network), roundStateUpdater);
- var aliceClient2 = new AliceClient(round.Id, arenaClient, coin2, round.FeeRate, key2.GetBitcoinSecret(round.Network), roundStateUpdater);
+ var aliceClient1 = new AliceClient(round.Id, arenaClient, coin1, round.FeeRate, key1.GetBitcoinSecret(round.Network));
+ var aliceClient2 = new AliceClient(round.Id, arenaClient, coin2, round.FeeRate, key2.GetBitcoinSecret(round.Network));
await aliceClient1.RegisterInputAsync(CancellationToken.None).ConfigureAwait(false);
await aliceClient2.RegisterInputAsync(CancellationToken.None).ConfigureAwait(false);
@@ -249,16 +247,19 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
Assert.Equal(Phase.ConnectionConfirmation, round.Phase);
// Confirm connections.
+ using RoundStateUpdater roundStateUpdater = new(TimeSpan.FromSeconds(2), new ArenaRequestHandlerAdapter(arena));
await aliceClient1.ConfirmConnectionAsync(
TimeSpan.FromMilliseconds(100),
new long[] { coin1.EffectiveValue(round.FeeRate) },
new long[] { round.MaxVsizeAllocationPerAlice - coin1.ScriptPubKey.EstimateInputVsize() },
+ roundStateUpdater,
CancellationToken.None).ConfigureAwait(false);
await aliceClient2.ConfirmConnectionAsync(
TimeSpan.FromMilliseconds(100),
new long[] { coin2.EffectiveValue(round.FeeRate) },
new long[] { round.MaxVsizeAllocationPerAlice - coin2.ScriptPubKey.EstimateInputVsize() },
+ roundStateUpdater,
CancellationToken.None).ConfigureAwait(false);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/AliceClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/AliceClientTests.cs
@@ -48,14 +48,15 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
var bitcoinSecret = km.GetSecrets("", coin1.ScriptPubKey).Single().PrivateKey.GetBitcoinSecret(Network.Main);
- using RoundStateUpdater roundStateUpdater = new(TimeSpan.FromSeconds(2), wabiSabiApi);
- var aliceClient = new AliceClient(round.Id, arenaClient, coin1.Coin, round.FeeRate, bitcoinSecret, roundStateUpdater);
+ var aliceClient = new AliceClient(round.Id, arenaClient, coin1.Coin, round.FeeRate, bitcoinSecret);
await aliceClient.RegisterInputAsync(CancellationToken.None);
+ using RoundStateUpdater roundStateUpdater = new(TimeSpan.FromSeconds(2), wabiSabiApi);
Task confirmationTask = aliceClient.ConfirmConnectionAsync(
TimeSpan.FromSeconds(1),
new long[] { coin1.EffectiveValue(round.FeeRate) },
new long[] { roundState.MaxVsizeAllocationPerAlice - coin1.ScriptPubKey.EstimateInputVsize() },
+ roundStateUpdater,
CancellationToken.None);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromMinutes(1));

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/BobClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/BobClientTests.cs
@@ -49,14 +49,15 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
var bitcoinSecret = km.GetSecrets("", coin1.ScriptPubKey).Single().PrivateKey.GetBitcoinSecret(Network.Main);
- using RoundStateUpdater roundStateUpdater = new(TimeSpan.FromSeconds(2), wabiSabiApi);
- var aliceClient = new AliceClient(round.Id, aliceArenaClient, coin1.Coin, round.FeeRate, bitcoinSecret, roundStateUpdater);
+ var aliceClient = new AliceClient(round.Id, aliceArenaClient, coin1.Coin, round.FeeRate, bitcoinSecret);
await aliceClient.RegisterInputAsync(CancellationToken.None);
+ using RoundStateUpdater roundStateUpdater = new(TimeSpan.FromSeconds(2), wabiSabiApi);
Task confirmationTask = aliceClient.ConfirmConnectionAsync(
TimeSpan.FromSeconds(1),
new long[] { coin1.EffectiveValue(round.FeeRate) },
new long[] { roundState.MaxVsizeAllocationPerAlice - coin1.ScriptPubKey.EstimateInputVsize() },
+ roundStateUpdater,
CancellationToken.None);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromMinutes(1));

MODIFY
WalletWasabi/WabiSabi/Client/AliceClient.cs
WalletWasabi/WabiSabi/Client/AliceClient.cs
@@ -15,7 +15,7 @@ namespace WalletWasabi.WabiSabi.Client
{
public class AliceClient
{
- public AliceClient(uint256 roundId, ArenaClient arenaClient, Coin coin, FeeRate feeRate, BitcoinSecret bitcoinSecret, RoundStateUpdater roundStatusUpdater)
+ public AliceClient(uint256 roundId, ArenaClient arenaClient, Coin coin, FeeRate feeRate, BitcoinSecret bitcoinSecret)
{
AliceId = CalculateHash(coin, bitcoinSecret, roundId);
RoundId = roundId;
@@ -23,7 +23,6 @@ namespace WalletWasabi.WabiSabi.Client
Coin = coin;
FeeRate = feeRate;
BitcoinSecret = bitcoinSecret;
- RoundStatusUpdater = roundStatusUpdater;
IssuedAmountCredentials = Array.Empty<Credential>();
IssuedVsizeCredentials = Array.Empty<Credential>();
}
@@ -34,7 +33,6 @@ namespace WalletWasabi.WabiSabi.Client
public Coin Coin { get; }
private FeeRate FeeRate { get; }
private BitcoinSecret BitcoinSecret { get; }
- private RoundStateUpdater RoundStatusUpdater { get; }
public IEnumerable<Credential> IssuedAmountCredentials { get; private set; }
public IEnumerable<Credential> IssuedVsizeCredentials { get; private set; }
@@ -51,7 +49,7 @@ namespace WalletWasabi.WabiSabi.Client
Logger.LogInfo($"Round ({RoundId}), Alice ({AliceId}): Registered an input.");
}
- public async Task ConfirmConnectionAsync(TimeSpan connectionConfirmationTimeout, IEnumerable<long> amountsToRequest, IEnumerable<long> vsizesToRequest, CancellationToken cancellationToken)
+ public async Task ConfirmConnectionAsync(TimeSpan connectionConfirmationTimeout, IEnumerable<long> amountsToRequest, IEnumerable<long> vsizesToRequest, RoundStateUpdater roundStatusUpdater, CancellationToken cancellationToken)
{
do
{
@@ -60,7 +58,7 @@ namespace WalletWasabi.WabiSabi.Client
try
{
- await RoundStatusUpdater
+ await roundStatusUpdater
.CreateRoundAwaiter(
RoundId,
roundState => roundState.Phase == Phase.ConnectionConfirmation,

MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
@@ -93,7 +93,7 @@ namespace WalletWasabi.WabiSabi.Client
await RegisterCoinsAsync(aliceClients, cancellationToken).ConfigureAwait(false);
// Confirm coins.
- await scheduler.StartConfirmConnectionsAsync(aliceClients, dependencyGraph, roundState.ConnectionConfirmationTimeout, cancellationToken).ConfigureAwait(false);
+ await scheduler.StartConfirmConnectionsAsync(aliceClients, dependencyGraph, roundState.ConnectionConfirmationTimeout, RoundStatusUpdater, cancellationToken).ConfigureAwait(false);
// Re-issuances.
var bobClient = CreateBobClient(roundState);
@@ -137,7 +137,7 @@ namespace WalletWasabi.WabiSabi.Client
var hdKey = Keymanager.GetSecrets(Kitchen.SaltSoup(), coin.ScriptPubKey).Single();
var secret = hdKey.PrivateKey.GetBitcoinSecret(Keymanager.GetNetwork());
- aliceClients.Add(new AliceClient(roundState.Id, aliceArenaClient, coin, roundState.FeeRate, secret, RoundStatusUpdater));
+ aliceClients.Add(new AliceClient(roundState.Id, aliceArenaClient, coin, roundState.FeeRate, secret));
}
return aliceClients;
}

MODIFY
WalletWasabi/WabiSabi/Client/DependencyGraphTaskScheduler.cs
WalletWasabi/WabiSabi/Client/DependencyGraphTaskScheduler.cs
@@ -25,7 +25,7 @@ namespace WalletWasabi.WabiSabi.Client
private DependencyGraph Graph { get; }
private Dictionary<CredentialDependency, TaskCompletionSource<Credential>> DependencyTasks { get; }
- public async Task StartConfirmConnectionsAsync(IEnumerable<AliceClient> aliceClients, DependencyGraph dependencyGraph, TimeSpan connectionConfirmationTimeout, CancellationToken cancellationToken)
+ public async Task StartConfirmConnectionsAsync(IEnumerable<AliceClient> aliceClients, DependencyGraph dependencyGraph, TimeSpan connectionConfirmationTimeout, RoundStateUpdater roundStateUpdater, CancellationToken cancellationToken)
{
var aliceNodePairs = PairAliceClientAndRequestNodes(aliceClients, Graph);
@@ -56,6 +56,7 @@ namespace WalletWasabi.WabiSabi.Client
vsizesToRequest,
node.EffectiveValue,
node.VsizeRemainingAllocation,
+ roundStateUpdater,
linkedCts.Token)
.ContinueWith((t) =>
{

MODIFY
WalletWasabi/WabiSabi/Client/SmartRequestNode.cs
WalletWasabi/WabiSabi/Client/SmartRequestNode.cs
@@ -35,12 +35,13 @@ namespace WalletWasabi.WabiSabi.Client
IEnumerable<long> vsizes,
Money effectiveValue,
int vsizeValue,
+ RoundStateUpdater roundStateUpdater,
CancellationToken cancellationToken)
{
var amountsToRequest = AddExtraCredentialRequests(amounts, effectiveValue.Satoshi);
var vsizesToRequest = AddExtraCredentialRequests(vsizes, vsizeValue);
- await aliceClient.ConfirmConnectionAsync(connectionConfirmationTimeout, amountsToRequest, vsizesToRequest, cancellationToken).ConfigureAwait(false);
+ await aliceClient.ConfirmConnectionAsync(connectionConfirmationTimeout, amountsToRequest, vsizesToRequest, roundStateUpdater, cancellationToken).ConfigureAwait(false);
// TODO keep extra credentials
var (amountCredentials, _) = SeparateExtraCredentials(aliceClient.IssuedAmountCredentials, amounts);

Add roundStateUpdater to ConfirmConnectionAsync